@hatiolab/things-scene 9.0.0-beta.21 → 9.0.0-beta.22

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/things-scene.mjs CHANGED
@@ -3,24 +3,24 @@ var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?windo
3
3
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
4
4
  i=function(){return e};var t,e={},r=Object.prototype,a=r.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",h=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),o=new R(n||[]);return s(a,"_invoke",{value:T(t,r,o)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var f="suspendedStart",g="suspendedYield",v="executing",m="completed",y={};function b(){}function w(){}function x(){}var A={};u(A,l,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(O([])));k&&k!==r&&a.call(k,l)&&(A=k);var S=x.prototype=b.prototype=Object.create(A);function E(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function M(t,e){function r(i,s,o,l){var h=p(t[i],t,s);if("throw"!==h.type){var c=h.arg,u=c.value;return u&&"object"==n(u)&&a.call(u,"__await")?e.resolve(u.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):e.resolve(u).then((function(t){c.value=t,o(c)}),(function(t){return r("throw",t,o,l)}))}l(h.arg)}var i;s(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(a,a):a()}})}function T(e,r,n){var i=f;return function(a,s){if(i===v)throw new Error("Generator is already running");if(i===m){if("throw"===a)throw s;return{value:t,done:!0}}for(n.method=a,n.arg=s;;){var o=n.delegate;if(o){var l=C(o,n);if(l){if(l===y)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var h=p(e,r,n);if("normal"===h.type){if(i=n.done?m:g,h.arg===y)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i=m,n.method="throw",n.arg=h.arg)}}}function C(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var s=a.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function O(e){if(e||""===e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function r(){for(;++i<e.length;)if(a.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return s.next=s}}throw new TypeError(n(e)+" is not iterable")}return w.prototype=x,s(S,"constructor",{value:x,configurable:!0}),s(x,"constructor",{value:w,configurable:!0}),w.displayName=u(x,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,u(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},E(M.prototype),u(M.prototype,h,(function(){return this})),e.AsyncIterator=M,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new M(d(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},E(S),u(S,c,"Generator"),u(S,l,(function(){return this})),u(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=O,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return o.type="throw",o.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),h=a.call(s,"finallyLoc");if(l&&h){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(l){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}var a=e("./utils"),s=function(){var e=i().mark(W),r=i().mark(U),s=i().mark(H),o=i().mark(G),l=i().mark(Q),h=i().mark(dt),c=i().mark(pt),u=i().mark(ft),d=i().mark(vt),p=i().mark(kt),f=i().mark(Tt),g=i().mark(It),v=a.isNumeric,m=a.isArrayOfStrings,y=a.isArrayOfNumbers,b=a.createSequence,w=a.isSequence,x=a.isFunction,A=a.isLambda,_=a.isIterable,k=a.getFunctionArity,S=a.isDeepEqual,E=a.stringToArray;function M(t){if(void 0!==t){var e=0;return t.forEach((function(t){e+=t})),e}}function T(t){return void 0===t?0:t.length}function C(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function P(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function I(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach((function(t){e+=t})),e/t.length}}function R(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var r;if("string"==typeof t)r=t;else if(x(t))r="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var n=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),r=JSON.stringify(t,(function(t,e){return null!=e&&e.toPrecision&&v(e)?Number(e.toPrecision(15)):e&&x(e)?"":e}),n)}return r}}function O(t,e,r){if(void 0!==t){var n=E(t),i=n.length;if(i+e<0&&(e=0),void 0!==r){if(r<=0)return"";var a=e>=0?e+r:i+e+r;return n.slice(e,a).join("")}return n.slice(e).join("")}}function L(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(0,r):t}}function D(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(r+e.length):t}}function F(t){if(void 0!==t)return t.toLowerCase()}function N(t){if(void 0!==t)return t.toUpperCase()}function j(t){if(void 0!==t)return E(t).length}function B(t){if(void 0!==t){var e=t.replace(/[ \t\n\r]+/gm," ");return" "===e.charAt(0)&&(e=e.substring(1))," "===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}function z(t,e,r){if(void 0!==t){var n;void 0!==r&&0!==r.length||(r=" ");var i=Math.abs(e)-j(t);if(i>0){var a=new Array(i+1).join(r);r.length>1&&(a=O(a,0,i)),n=e>0?t+a:a+t}else n=t;return n}}function W(t,r){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.apply(this,[r]),!_(n)){e.next=4;break}return e.delegateYield(n,"t0",3);case 3:n=e.t0;case 4:if(!n||"number"==typeof n.start||"number"===n.end||Array.isArray(n.groups)||x(n.next)){e.next=6;break}throw{code:"T1010",stack:(new Error).stack};case 6:return e.abrupt("return",n);case 7:case"end":return e.stop()}}),e,this)}function U(t,e){var n,a;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0!==t){r.next=2;break}return r.abrupt("return",void 0);case 2:if("string"!=typeof e){r.next=6;break}n=-1!==t.indexOf(e),r.next=9;break;case 6:return r.delegateYield(W(e,t),"t0",7);case 7:a=r.t0,n=void 0!==a;case 9:return r.abrupt("return",n);case 10:case"end":return r.stop()}}),r)}function H(t,e,r){var n,a,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{stack:(new Error).stack,value:r,code:"D3040",index:3};case 4:if(n=b(),!(void 0===r||r>0)){i.next=17;break}return a=0,i.delegateYield(W(e,t),"t0",8);case 8:if(void 0===(o=i.t0)){i.next=17;break}case 10:if(void 0===o||!(void 0===r||a<r)){i.next=17;break}return n.push({match:o.match,index:o.start,groups:o.groups}),i.delegateYield(W(o.next),"t1",13);case 13:o=i.t1,a++,i.next=10;break;case 17:return i.abrupt("return",n);case 18:case"end":return i.stop()}}),s)}function G(t,e,r,n){var a,s,l,h,c,u,d,p;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(a=this,""!==e){i.next=5;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 5:if(!(n<0)){i.next=7;break}throw{code:"D3011",stack:(new Error).stack,value:n,index:4};case 7:if(s="string"==typeof r?function(t){for(var e="",n=0,i=r.indexOf("$",n);-1!==i&&n<r.length;){e+=r.substring(n,i),n=i+1;var a=r.charAt(n);if("$"===a)e+="$",n++;else if("0"===a)e+=t.match,n++;else{var s;if(s=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,i=parseInt(r.substring(n,n+s),10),s>1&&i>t.groups.length&&(i=parseInt(r.substring(n,n+s-1),10)),isNaN(i))e+="$";else{if(t.groups.length>0){var o=t.groups[i-1];void 0!==o&&(e+=o)}n+=i.toString().length}}i=r.indexOf("$",n)}return e+=r.substring(n)}:r,l="",h=0,!(void 0===n||n>0)){i.next=44;break}if(c=0,"string"!=typeof e){i.next=18;break}for(u=t.indexOf(e,h);-1!==u&&(void 0===n||c<n);)l+=t.substring(h,u),l+=r,h=u+e.length,c++,u=t.indexOf(e,h);l+=t.substring(h),i.next=42;break;case 18:return i.delegateYield(W(e,t),"t0",19);case 19:if(void 0===(d=i.t0)){i.next=41;break}case 21:if(void 0===d||!(void 0===n||c<n)){i.next=38;break}if(l+=t.substring(h,d.start),p=s.apply(a,[d]),!_(p)){i.next=27;break}return i.delegateYield(p,"t1",26);case 26:p=i.t1;case 27:if("string"!=typeof p){i.next=31;break}l+=p,i.next=32;break;case 31:throw{code:"D3012",stack:(new Error).stack,value:p};case 32:return h=d.start+d.match.length,c++,i.delegateYield(W(d.next),"t2",35);case 35:d=i.t2,i.next=21;break;case 38:l+=t.substring(h),i.next=42;break;case 41:l=t;case 42:i.next=45;break;case 44:l=t;case 45:return i.abrupt("return",l);case 46:case"end":return i.stop()}}),o,this)}function Y(e){if(void 0!==e){var r="undefined"!=typeof window?window.btoa:function(e){return new t.Buffer.from(e,"binary").toString("base64")};return r(e)}}function V(e){if(void 0!==e){var r="undefined"!=typeof window?window.atob:function(e){return new t.Buffer.from(e,"base64").toString("binary")};return r(e)}}function q(t){if(void 0!==t){var e;try{e=encodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrlComponent"}}return e}}function X(t){if(void 0!==t){var e;try{e=encodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrl"}}return e}}function $(t){if(void 0!==t){var e;try{e=decodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrlComponent"}}return e}}function K(t){if(void 0!==t){var e;try{e=decodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrl"}}return e}}function Q(t,e,r){var n,a,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{code:"D3020",stack:(new Error).stack,value:r,index:3};case 4:if(n=[],!(void 0===r||r>0)){i.next=27;break}if("string"!=typeof e){i.next=10;break}n=t.split(e,r),i.next=27;break;case 10:return a=0,i.delegateYield(W(e,t),"t0",12);case 12:if(void 0===(s=i.t0)){i.next=26;break}o=0;case 15:if(void 0===s||!(void 0===r||a<r)){i.next=23;break}return n.push(t.substring(o,s.start)),o=s.end,i.delegateYield(W(s.next),"t1",19);case 19:s=i.t1,a++,i.next=15;break;case 23:(void 0===r||a<r)&&n.push(t.substring(o)),i.next=27;break;case 26:n.push(t);case 27:return i.abrupt("return",n);case 28:case"end":return i.stop()}}),l)}function J(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function Z(t,e,r){if(void 0!==t){var n={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==r&&Object.keys(r).forEach((function(t){n[t]=r[t]}));for(var i=[],a=n["zero-digit"].charCodeAt(0),s=a;s<a+10;s++)i.push(String.fromCharCode(s));var o=i.concat([n["decimal-separator"],n["exponent-separator"],n["grouping-separator"],n.digit,n["pattern-separator"]]),l=e.split(n["pattern-separator"]);if(l.length>2)throw{code:"D3080",stack:(new Error).stack};var h=function(t){var e,r,i,a,s=function(){for(var e,r=0;r<t.length;r++)if(e=t.charAt(r),-1!==o.indexOf(e)&&e!==n["exponent-separator"])return t.substring(0,r)}(),l=function(){for(var e,r=t.length-1;r>=0;r--)if(e=t.charAt(r),-1!==o.indexOf(e)&&e!==n["exponent-separator"])return t.substring(r+1)}(),h=t.substring(s.length,t.length-l.length),c=t.indexOf(n["exponent-separator"],s.length);-1===c||c>t.length-l.length?(e=h,r=void 0):(e=h.substring(0,c),r=h.substring(c+1));var u=e.indexOf(n["decimal-separator"]);return-1===u?(i=e,a=l):(i=e.substring(0,u),a=e.substring(u+1)),{prefix:s,suffix:l,activePart:h,mantissaPart:e,exponentPart:r,integerPart:i,fractionalPart:a,subpicture:t}},c=function(t){var e,r,a=t.subpicture,s=a.indexOf(n["decimal-separator"]);s!==a.lastIndexOf(n["decimal-separator"])&&(e="D3081"),a.indexOf(n.percent)!==a.lastIndexOf(n.percent)&&(e="D3082"),a.indexOf(n["per-mille"])!==a.lastIndexOf(n["per-mille"])&&(e="D3083"),-1!==a.indexOf(n.percent)&&-1!==a.indexOf(n["per-mille"])&&(e="D3084");var l=!1;for(r=0;r<t.mantissaPart.length;r++){var h=t.mantissaPart.charAt(r);if(-1!==i.indexOf(h)||h===n.digit){l=!0;break}}l||(e="D3085"),-1!==t.activePart.split("").map((function(t){return-1===o.indexOf(t)?"p":"a"})).join("").indexOf("p")&&(e="D3086"),-1!==s?a.charAt(s-1)!==n["grouping-separator"]&&a.charAt(s+1)!==n["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===n["grouping-separator"]&&(e="D3088"),-1!==a.indexOf(n["grouping-separator"]+n["grouping-separator"])&&(e="D3089");var c=t.integerPart.indexOf(n.digit);-1!==c&&t.integerPart.substring(0,c).split("").filter((function(t){return i.indexOf(t)>-1})).length>0&&(e="D3090"),-1!==(c=t.fractionalPart.lastIndexOf(n.digit))&&t.fractionalPart.substring(c).split("").filter((function(t){return i.indexOf(t)>-1})).length>0&&(e="D3091");var u="string"==typeof t.exponentPart;if(u&&t.exponentPart.length>0&&(-1!==a.indexOf(n.percent)||-1!==a.indexOf(n["per-mille"]))&&(e="D3092"),u&&(0===t.exponentPart.length||t.exponentPart.split("").filter((function(t){return-1===i.indexOf(t)})).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},u=function(t){var e=function(e,r){for(var a=[],s=e.indexOf(n["grouping-separator"]);-1!==s;){var o=(r?e.substring(0,s):e.substring(s)).split("").filter((function(t){return-1!==i.indexOf(t)||t===n.digit})).length;a.push(o),s=t.integerPart.indexOf(n["grouping-separator"],s+1)}return a},r=e(t.integerPart),a=function(t){if(0===t.length)return 0;for(var e=function t(e,r){return 0===r?e:t(r,e%r)},r=t.reduce(e),n=1;n<=t.length;n++)if(-1===t.indexOf(n*r))return 0;return r},s=a(r),o=e(t.fractionalPart,!0),l=t.integerPart.split("").filter((function(t){return-1!==i.indexOf(t)})).length,h=l,c=t.fractionalPart.split(""),u=c.filter((function(t){return-1!==i.indexOf(t)})).length,d=c.filter((function(t){return-1!==i.indexOf(t)||t===n.digit})).length,p="string"==typeof t.exponentPart;0===l&&0===d&&(p?(u=1,d=1):l=1),p&&0===l&&-1!==t.integerPart.indexOf(n.digit)&&(l=1),0===l&&0===u&&(u=1);var f=0;return p&&(f=t.exponentPart.split("").filter((function(t){return-1!==i.indexOf(t)})).length),{integerPartGroupingPositions:r,regularGrouping:s,minimumIntegerPartSize:l,scalingFactor:h,prefix:t.prefix,fractionalPartGroupingPositions:o,minimumFactionalPartSize:u,maximumFactionalPartSize:d,minimumExponentSize:f,suffix:t.suffix,picture:t.subpicture}},d=l.map(h);d.forEach(c);var p,f,g,v,m=d.map(u),y=n["minus-sign"],b=n["zero-digit"],w=n["decimal-separator"],x=n["grouping-separator"];if(1===m.length&&(m.push(JSON.parse(JSON.stringify(m[0]))),m[1].prefix=y+m[1].prefix),f=-1!==(p=t>=0?m[0]:m[1]).picture.indexOf(n.percent)?100*t:-1!==p.picture.indexOf(n["per-mille"])?1e3*t:t,0===p.minimumExponentSize)g=f;else{var A=Math.pow(10,p.scalingFactor),_=Math.pow(10,p.scalingFactor-1);for(g=f,v=0;g<_;)g*=10,v-=1;for(;g>A;)g/=10,v+=1}var k=function(t,e){var r=Math.abs(t).toFixed(e);return"0"!==b&&(r=r.split("").map((function(t){return t>="0"&&t<="9"?i[t.charCodeAt(0)-48]:t})).join("")),r},S=k(at(g,p.maximumFactionalPartSize),p.maximumFactionalPartSize),E=S.indexOf(".");for(-1===E?S+=w:S=S.replace(".",w);S.charAt(0)===b;)S=S.substring(1);for(;S.charAt(S.length-1)===b;)S=S.substring(0,S.length-1);E=S.indexOf(w);var M=p.minimumIntegerPartSize-E,T=p.minimumFactionalPartSize-(S.length-E-1);if(S=(M>0?new Array(M+1).join(b):"")+S,S+=T>0?new Array(T+1).join(b):"",E=S.indexOf(w),p.regularGrouping>0)for(var C=Math.floor((E-1)/p.regularGrouping),P=1;P<=C;P++)S=[S.slice(0,E-P*p.regularGrouping),x,S.slice(E-P*p.regularGrouping)].join("");else p.integerPartGroupingPositions.forEach((function(t){S=[S.slice(0,E-t),x,S.slice(E-t)].join(""),E++}));if(E=S.indexOf(w),p.fractionalPartGroupingPositions.forEach((function(t){S=[S.slice(0,t+E+1),x,S.slice(t+E+1)].join("")})),E=S.indexOf(w),-1!==p.picture.indexOf(w)&&E!==S.length-1||(S=S.substring(0,S.length-1)),void 0!==v){var I=k(v,0);(M=p.minimumExponentSize-I.length)>0&&(I=new Array(M+1).join(b)+I),S=S+n["exponent-separator"]+(v<0?y:"")+I}return S=p.prefix+S+p.suffix}}function tt(t,e){if(void 0!==t){if(t=at(t),(e=void 0===e?10:at(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function et(t){var e;if(void 0!==t){if("number"==typeof t)e=t;else if("string"==typeof t&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(t)&&!isNaN(parseFloat(t))&&isFinite(t))e=parseFloat(t);else if(!0===t)e=1;else{if(!1!==t)throw{code:"D3030",value:t,stack:(new Error).stack,index:1};e=0}return e}}function rt(t){if(void 0!==t)return Math.abs(t)}function nt(t){if(void 0!==t)return Math.floor(t)}function it(t){if(void 0!==t)return Math.ceil(t)}function at(t,e){var r;if(void 0!==t){if(e){var n=t.toString().split("e");t=+(n[0]+"e"+(n[1]?+n[1]+e:e))}var i=(r=Math.round(t))-t;return.5===Math.abs(i)&&1===Math.abs(r%2)&&(r-=1),e&&(n=r.toString().split("e"),r=+(n[0]+"e"+(n[1]?+n[1]-e:-e))),Object.is(r,-0)&&(r=0),r}}function st(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function ot(t,e){var r;if(void 0!==t){if(r=Math.pow(t,e),!isFinite(r))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return r}}function lt(){return Math.random()}function ht(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=ht(t[0]):t.length>1&&(e=t.filter((function(t){return ht(t)})).length>0):"string"==typeof t?t.length>0&&(e=!0):v(t)?0!==t&&(e=!0):null!==t&&"object"===n(t)?Object.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function ct(t){if(void 0!==t)return!ht(t)}function ut(t,e,r,n){var i=[e],a=k(t);return a>=2&&i.push(r),a>=3&&i.push(n),i}function dt(t,e){var r,n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=b(),n=0;case 4:if(!(n<t.length)){i.next=12;break}return a=ut(e,t[n],n,t),i.delegateYield(e.apply(this,a),"t0",7);case 7:void 0!==(s=i.t0)&&r.push(s);case 9:n++,i.next=4;break;case 12:return i.abrupt("return",r);case 13:case"end":return i.stop()}}),h,this)}function pt(t,e){var r,n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=b(),n=0;case 4:if(!(n<t.length)){i.next=13;break}return a=t[n],s=ut(e,a,n,t),i.delegateYield(e.apply(this,s),"t0",8);case 8:ht(i.t0)&&r.push(a);case 10:n++,i.next=4;break;case 13:return i.abrupt("return",r);case 14:case"end":return i.stop()}}),c,this)}function ft(t,e){var r,n,a,s,o,l,h;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=!1,a=0;case 4:if(!(a<t.length)){i.next=22;break}if(s=t[a],o=!0,void 0===e){i.next=12;break}return l=ut(e,s,a,t),i.delegateYield(e.apply(this,l),"t0",10);case 10:h=i.t0,o=ht(h);case 12:if(!o){i.next=19;break}if(r){i.next=18;break}n=s,r=!0,i.next=19;break;case 18:throw{stack:(new Error).stack,code:"D3138",index:a};case 19:a++,i.next=4;break;case 22:if(r){i.next=24;break}throw{stack:(new Error).stack,code:"D3139"};case 24:return i.abrupt("return",n);case 25:case"end":return i.stop()}}),u,this)}function gt(){for(var t=[],e=Array.prototype.slice.call(arguments),r=Math.min.apply(Math,e.map((function(t){return Array.isArray(t)?t.length:0}))),n=0;n<r;n++){var i=e.map((function(t){return t[n]}));t.push(i)}return t}function vt(t,e,r){var n,a,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!((a=k(e))<2)){i.next=5;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 5:void 0===r&&t.length>0?(n=t[0],s=1):(n=r,s=0);case 6:if(!(s<t.length)){i.next=15;break}return o=[n,t[s]],a>=3&&o.push(s),a>=4&&o.push(t),i.delegateYield(e.apply(this,o),"t0",11);case 11:n=i.t0,s++,i.next=6;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}}),d,this)}function mt(t){var e=b();if(Array.isArray(t)){var r={};t.forEach((function(t){mt(t).forEach((function(t){r[t]=!0}))})),e=mt(r)}else null===t||"object"!==n(t)||A(t)||Object.keys(t).forEach((function(t){return e.push(t)}));return e}function yt(t,e){var r;if(Array.isArray(t)){r=b();for(var i=0;i<t.length;i++){var a=yt(t[i],e);void 0!==a&&(Array.isArray(a)?a.forEach((function(t){return r.push(t)})):r.push(a))}}else null!==t&&"object"===n(t)&&(r=t[e]);return r}function bt(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=b(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function wt(t){return void 0!==t}function xt(t){var e=b();if(Array.isArray(t))t.forEach((function(t){e=bt(e,xt(t))}));else if(null===t||"object"!==n(t)||A(t))e=t;else for(var r in t){var i={};i[r]=t[r],e.push(i)}return e}function At(t){if(void 0!==t){var e={};return t.forEach((function(t){for(var r in t)e[r]=t[r]})),e}}function _t(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,r=new Array(e),n=0;n<e;n++)r[e-n-1]=t[n];return r}}function kt(t,e){var r,n,a,s;return i().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:r=b(),o.t0=i().keys(t);case 2:if((o.t1=o.t0()).done){o.next=10;break}return n=o.t1.value,a=ut(e,t[n],n,t),o.delegateYield(e.apply(this,a),"t2",6);case 6:void 0!==(s=o.t2)&&r.push(s),o.next=2;break;case 10:return o.abrupt("return",r);case 11:case"end":return o.stop()}}),p,this)}function St(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function Et(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function Mt(t){if(void 0!==t)return null===t?"null":v(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":x(t)?"function":"object"}function Tt(t,e){var r,n,a,s;return i().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(void 0!==t){o.next=2;break}return o.abrupt("return",void 0);case 2:if(!(t.length<=1)){o.next=4;break}return o.abrupt("return",t);case 4:if(void 0!==e){o.next=10;break}if(y(t)||m(t)){o.next=7;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 7:r=i().mark((function t(e,r){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e>r);case 1:case"end":return t.stop()}}),t)})),o.next=11;break;case 10:r=e;case 11:return n=i().mark((function t(e,n){var a,s;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=i().mark((function t(e,n,a){return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(0!==n.length){i.next=4;break}Array.prototype.push.apply(e,a),i.next=16;break;case 4:if(0!==a.length){i.next=8;break}Array.prototype.push.apply(e,n),i.next=16;break;case 8:return i.delegateYield(r(n[0],a[0]),"t0",9);case 9:if(!i.t0){i.next=14;break}return e.push(a[0]),i.delegateYield(t(e,n,a.slice(1)),"t1",12);case 12:i.next=16;break;case 14:return e.push(n[0]),i.delegateYield(t(e,n.slice(1),a),"t2",16);case 16:case"end":return i.stop()}}),t)})),s=[],t.delegateYield(a(s,e,n),"t0",3);case 3:return t.abrupt("return",s);case 4:case"end":return t.stop()}}),t)})),a=i().mark((function t(e){var r,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(Array.isArray(e)&&!(e.length<=1)){i.next=4;break}return i.abrupt("return",e);case 4:return r=Math.floor(e.length/2),a=e.slice(0,r),s=e.slice(r),i.delegateYield(t(a),"t0",8);case 8:return a=i.t0,i.delegateYield(t(s),"t1",10);case 10:return s=i.t1,i.delegateYield(n(a,s),"t2",12);case 12:return i.abrupt("return",i.t2);case 13:case"end":return i.stop()}}),t)})),o.delegateYield(a(t),"t0",14);case 14:return s=o.t0,o.abrupt("return",s);case 16:case"end":return o.stop()}}),f)}function Ct(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),r=0;r<t.length;r++){var n=Math.floor(Math.random()*(r+1));r!==n&&(e[r]=e[n]),e[n]=t[r]}return e}}function Pt(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=w(t)?b():[],r=0;r<t.length;r++){for(var n=t[r],i=!1,a=0;a<e.length;a++)if(S(n,e[a])){i=!0;break}i||e.push(n)}return e}}function It(t,e){var r,n,a,s;return i().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:r={},o.t0=i().keys(t);case 2:if((o.t1=o.t0()).done){o.next=11;break}return n=o.t1.value,a=t[n],s=ut(e,a,n,t),o.delegateYield(e.apply(this,s),"t2",7);case 7:ht(o.t2)&&(r[n]=a),o.next=2;break;case 11:return 0===Object.keys(r).length&&(r=void 0),o.abrupt("return",r);case 13:case"end":return o.stop()}}),g,this)}return{sum:M,count:T,max:C,min:P,average:I,string:R,substring:O,substringBefore:L,substringAfter:D,lowercase:F,uppercase:N,length:j,trim:B,pad:z,match:H,contains:U,replace:G,split:Q,join:J,formatNumber:Z,formatBase:tt,number:et,floor:nt,ceil:it,round:at,abs:rt,sqrt:st,power:ot,random:lt,boolean:ht,not:ct,map:dt,zip:gt,filter:pt,single:ft,foldLeft:vt,sift:It,keys:mt,lookup:yt,append:bt,exists:wt,spread:xt,merge:At,reverse:_t,each:kt,error:St,assert:Et,type:Mt,sort:Tt,shuffle:Ct,distinct:Pt,base64encode:Y,base64decode:V,encodeUrlComponent:q,encodeUrl:X,decodeUrlComponent:$,decodeUrl:K}}();r.exports=s}).call(this)}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,r){function n(t){return n="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},n(t)}function i(){
5
5
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
6
- i=function(){return e};var t,e={},r=Object.prototype,a=r.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",h=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),o=new R(n||[]);return s(a,"_invoke",{value:T(t,r,o)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var f="suspendedStart",g="suspendedYield",v="executing",m="completed",y={};function b(){}function w(){}function x(){}var A={};u(A,l,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(O([])));k&&k!==r&&a.call(k,l)&&(A=k);var S=x.prototype=b.prototype=Object.create(A);function E(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function M(t,e){function r(i,s,o,l){var h=p(t[i],t,s);if("throw"!==h.type){var c=h.arg,u=c.value;return u&&"object"==n(u)&&a.call(u,"__await")?e.resolve(u.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):e.resolve(u).then((function(t){c.value=t,o(c)}),(function(t){return r("throw",t,o,l)}))}l(h.arg)}var i;s(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(a,a):a()}})}function T(e,r,n){var i=f;return function(a,s){if(i===v)throw new Error("Generator is already running");if(i===m){if("throw"===a)throw s;return{value:t,done:!0}}for(n.method=a,n.arg=s;;){var o=n.delegate;if(o){var l=C(o,n);if(l){if(l===y)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var h=p(e,r,n);if("normal"===h.type){if(i=n.done?m:g,h.arg===y)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i=m,n.method="throw",n.arg=h.arg)}}}function C(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var s=a.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function O(e){if(e||""===e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function r(){for(;++i<e.length;)if(a.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return s.next=s}}throw new TypeError(n(e)+" is not iterable")}return w.prototype=x,s(S,"constructor",{value:x,configurable:!0}),s(x,"constructor",{value:w,configurable:!0}),w.displayName=u(x,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,u(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},E(M.prototype),u(M.prototype,h,(function(){return this})),e.AsyncIterator=M,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new M(d(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},E(S),u(S,c,"Generator"),u(S,l,(function(){return this})),u(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=O,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return o.type="throw",o.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),h=a.call(s,"finallyLoc");if(l&&h){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(l){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}var a=t("./datetime"),s=t("./functions"),o=t("./utils"),l=t("./parser"),h=t("./signature"),c=function(){var t=i().mark(z),e=i().mark(W),r=i().mark(H),c=i().mark(G),u=i().mark(Y),d=i().mark(V),p=i().mark(q),f=i().mark(X),g=i().mark(at),v=i().mark(lt),m=i().mark(ut),y=i().mark(dt),b=i().mark(pt),w=i().mark(vt),x=i().mark(bt),A=i().mark(wt),_=i().mark(xt),k=i().mark(At),S=i().mark(kt),E=i().mark(Et),M=i().mark(Ct),T=i().mark(Rt),C=o.isNumeric,P=o.isArrayOfStrings,I=o.isArrayOfNumbers,R=o.createSequence,O=o.isSequence,L=o.isFunction,D=o.isLambda,F=o.isIterable,N=o.getFunctionArity,j=o.isDeepEqual,B=Lt(null);function z(e,r,n){var a,s,o,l;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(s=n.lookup("__evaluate_entry"))&&s(e,r,n),t.t0=e.type,t.next="path"===t.t0?5:"binary"===t.t0?8:"unary"===t.t0?11:"name"===t.t0?14:"string"===t.t0||"number"===t.t0||"value"===t.t0?16:"wildcard"===t.t0?18:"descendant"===t.t0?20:"parent"===t.t0?22:"condition"===t.t0?24:"block"===t.t0?27:"bind"===t.t0?30:"regex"===t.t0?33:"function"===t.t0?35:"variable"===t.t0?38:"lambda"===t.t0?40:"partial"===t.t0?42:"apply"===t.t0?45:"transform"===t.t0?48:50;break;case 5:return t.delegateYield(W(e,r,n),"t1",6);case 6:return a=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(q(e,r,n),"t2",9);case 9:return a=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(X(e,r,n),"t3",12);case 12:return a=t.t3,t.abrupt("break",50);case 14:return a=$(e,r),t.abrupt("break",50);case 16:return a=K(e),t.abrupt("break",50);case 18:return a=Q(e,r),t.abrupt("break",50);case 20:return a=Z(e,r),t.abrupt("break",50);case 22:return a=n.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(dt(e,r,n),"t4",25);case 25:return a=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(pt(e,r,n),"t5",28);case 28:return a=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(ut(e,r,n),"t6",31);case 31:return a=t.t6,t.abrupt("break",50);case 33:return a=ft(e),t.abrupt("break",50);case 35:return t.delegateYield(wt(e,r,n),"t7",36);case 36:return a=t.t7,t.abrupt("break",50);case 38:return a=gt(e,r,n),t.abrupt("break",50);case 40:return a=_t(e,r,n),t.abrupt("break",50);case 42:return t.delegateYield(kt(e,r,n),"t8",43);case 43:return a=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(bt(e,r,n),"t9",46);case 46:return a=t.t9,t.abrupt("break",50);case 48:return a=mt(e,r,n),t.abrupt("break",50);case 50:if(!n.async||null!=a&&"function"==typeof a.then||(a=Promise.resolve(a)),!n.async||"function"!=typeof a.then||!e.nextFunction||"function"!=typeof a[e.nextFunction]){t.next=54;break}t.next=57;break;case 54:return t.next=56,a;case 56:a=t.sent;case 57:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.next=65;break}o=0;case 59:if(!(o<e.predicate.length)){t.next=65;break}return t.delegateYield(V(e.predicate[o].expr,a,n),"t10",61);case 61:a=t.t10;case 62:o++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(lt(e.group,a,n),"t11",67);case 67:a=t.t11;case 68:return(l=n.lookup("__evaluate_exit"))&&l(e,r,n,a),a&&O(a)&&!a.tupleStream&&(e.keepArray&&(a.keepSingleton=!0),0===a.length?a=void 0:1===a.length&&(a=a.keepSingleton?a:a[0])),t.abrupt("return",a);case 72:case"end":return t.stop()}}),t)}function W(t,r,n){var a,s,o,l,h,c;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=Array.isArray(r)&&"variable"!==t.steps[0].type?r:R(r),o=!1,l=void 0,h=0;case 4:if(!(h<t.steps.length)){e.next=25;break}if((c=t.steps[h]).tuple&&(o=!0),0!==h||!c.consarray){e.next=12;break}return e.delegateYield(z(c,a,n),"t0",9);case 9:s=e.t0,e.next=19;break;case 12:if(!o){e.next=17;break}return e.delegateYield(Y(c,a,l,n),"t1",14);case 14:l=e.t1,e.next=19;break;case 17:return e.delegateYield(H(c,a,n,h===t.steps.length-1),"t2",18);case 18:s=e.t2;case 19:if(o||void 0!==s&&0!==s.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===c.focus&&(a=s);case 22:h++,e.next=4;break;case 25:if(o)if(t.tuple)s=l;else for(s=R(),h=0;h<l.length;h++)s.push(l[h]["@"]);if(t.keepSingletonArray&&(Array.isArray(s)&&s.cons&&!s.sequence&&(s=R(s)),s.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(lt(t.group,o?l:s,n),"t3",29);case 29:s=e.t3;case 30:return e.abrupt("return",s);case 31:case"end":return e.stop()}}),e)}function U(t,e){var r=Lt(t);for(var n in e)r.bind(n,e[n]);return r}function H(t,e,n,a){var s,o,l,h,c;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("sort"!==t.type){r.next=7;break}return r.delegateYield(vt(t,e,n),"t0",2);case 2:if(s=r.t0,!t.stages){r.next=6;break}return r.delegateYield(G(t.stages,s,n),"t1",5);case 5:s=r.t1;case 6:return r.abrupt("return",s);case 7:s=R(),o=0;case 9:if(!(o<e.length)){r.next=24;break}return r.delegateYield(z(t,e[o],n),"t2",11);case 11:if(l=r.t2,!t.stages){r.next=20;break}h=0;case 14:if(!(h<t.stages.length)){r.next=20;break}return r.delegateYield(V(t.stages[h].expr,l,n),"t3",16);case 16:l=r.t3;case 17:h++,r.next=14;break;case 20:void 0!==l&&s.push(l);case 21:o++,r.next=9;break;case 24:return c=R(),a&&1===s.length&&Array.isArray(s[0])&&!O(s[0])?c=s[0]:s.forEach((function(t){!Array.isArray(t)||t.cons?c.push(t):t.forEach((function(t){return c.push(t)}))})),r.abrupt("return",c);case 27:case"end":return r.stop()}}),r)}function G(t,e,r){var n,a,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:n=e,a=0;case 2:if(!(a<t.length)){i.next=15;break}s=t[a],i.t0=s.type,i.next="filter"===i.t0?7:"index"===i.t0?10:12;break;case 7:return i.delegateYield(V(s.expr,n,r),"t1",8);case 8:return n=i.t1,i.abrupt("break",12);case 10:for(o=0;o<n.length;o++)n[o][s.value]=o;return i.abrupt("break",12);case 12:a++,i.next=2;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}}),c)}function Y(t,e,r,n){var a,s,o,l,h,c,d,p;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if("sort"!==t.type){i.next=15;break}if(!r){i.next=6;break}return i.delegateYield(vt(t,r,n),"t0",3);case 3:a=i.t0,i.next=11;break;case 6:return i.delegateYield(vt(t,e,n),"t1",7);case 7:for(s=i.t1,(a=R()).tupleStream=!0,o=0;o<s.length;o++)(l={"@":s[o]})[t.index]=o,a.push(l);case 11:if(!t.stages){i.next=14;break}return i.delegateYield(G(t.stages,a,n),"t2",13);case 13:a=i.t2;case 14:return i.abrupt("return",a);case 15:(a=R()).tupleStream=!0,h=n,void 0===r&&(r=e.map((function(t){return{"@":t}}))),c=0;case 20:if(!(c<r.length)){i.next=28;break}return h=U(n,r[c]),i.delegateYield(z(t,r[c]["@"],h),"t3",23);case 23:if(void 0!==(d=i.t3))for(Array.isArray(d)||(d=[d]),p=0;p<d.length;p++)l={},Object.assign(l,r[c]),d.tupleStream?Object.assign(l,d[p]):(t.focus?(l[t.focus]=d[p],l["@"]=r[c]["@"]):l["@"]=d[p],t.index&&(l[t.index]=p),t.ancestor&&(l[t.ancestor.label]=r[c]["@"])),a.push(l);case 25:c++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(G(t.stages,a,n),"t4",30);case 30:a=i.t4;case 31:return i.abrupt("return",a);case 32:case"end":return i.stop()}}),u)}function V(t,e,r){var n,a,o,l,h,c;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=R(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=R(e)),"number"!==t.type){i.next=10;break}(a=Math.floor(t.value))<0&&(a=e.length+a),void 0!==(o=e[a])&&(Array.isArray(o)?n=o:n.push(o)),i.next=23;break;case 10:a=0;case 11:if(!(a<e.length)){i.next=23;break}return o=e[a],l=o,h=r,e.tupleStream&&(l=o["@"],h=U(r,o)),i.delegateYield(z(t,l,h),"t0",17);case 17:c=i.t0,C(c)&&(c=[c]),I(c)?c.forEach((function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===a&&n.push(o)})):s.boolean(c)&&n.push(o);case 20:a++,i.next=11;break;case 23:return i.abrupt("return",n);case 24:case"end":return i.stop()}}),d)}function q(t,e,r){var n,a,s,o,l;return i().wrap((function(h){for(;;)switch(h.prev=h.next){case 0:return h.delegateYield(z(t.lhs,e,r),"t0",1);case 1:if(a=h.t0,s=t.value,o=i().mark((function n(){return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(z(t.rhs,e,r),"t0",1);case 1:return n.abrupt("return",n.t0);case 2:case"end":return n.stop()}}),n)})),"and"!==s&&"or"!==s){h.next=15;break}return h.prev=5,h.delegateYield(at(a,o,s),"t1",7);case 7:return h.abrupt("return",h.t1);case 10:throw h.prev=10,h.t2=h.catch(5),h.t2.position=t.position,h.t2.token=s,h.t2;case 15:return h.delegateYield(o(),"t3",16);case 16:l=h.t3,h.prev=17,h.t4=s,h.next="+"===h.t4||"-"===h.t4||"*"===h.t4||"/"===h.t4||"%"===h.t4?21:"="===h.t4||"!="===h.t4?23:"<"===h.t4||"<="===h.t4||">"===h.t4||">="===h.t4?25:"&"===h.t4?27:".."===h.t4?29:"in"===h.t4?31:33;break;case 21:return n=et(a,l,s),h.abrupt("break",33);case 23:return n=rt(a,l,s),h.abrupt("break",33);case 25:return n=nt(a,l,s),h.abrupt("break",33);case 27:return n=ot(a,l),h.abrupt("break",33);case 29:return n=ct(a,l),h.abrupt("break",33);case 31:return n=it(a,l),h.abrupt("break",33);case 33:h.next=40;break;case 35:throw h.prev=35,h.t5=h.catch(17),h.t5.position=t.position,h.t5.token=s,h.t5;case 40:return h.abrupt("return",n);case 41:case"end":return h.stop()}}),p,null,[[5,10],[17,35]])}function X(t,e,r){var n,a,o,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:i.t0=t.value,i.next="-"===i.t0?3:"["===i.t0?15:"{"===i.t0?27:30;break;case 3:return i.delegateYield(z(t.expression,e,r),"t1",4);case 4:if(void 0!==(n=i.t1)){i.next=9;break}n=void 0,i.next=14;break;case 9:if(!C(n)){i.next=13;break}n=-n,i.next=14;break;case 13:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:n};case 14:return i.abrupt("break",30);case 15:n=[],a=0;case 17:if(!(a<t.expressions.length)){i.next=25;break}return o=t.expressions[a],i.delegateYield(z(o,e,r),"t2",20);case 20:void 0!==(l=i.t2)&&("["===o.value?n.push(l):n=s.append(n,l));case 22:a++,i.next=17;break;case 25:return t.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0}),i.abrupt("break",30);case 27:return i.delegateYield(lt(t,e,r),"t3",28);case 28:return n=i.t3,i.abrupt("break",30);case 30:return i.abrupt("return",n);case 31:case"end":return i.stop()}}),f)}function $(t,e,r){return s.lookup(e,t.value)}function K(t){return t.value}function Q(t,e){var r=R();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null!==e&&"object"===n(e)&&Object.keys(e).forEach((function(t){var n=e[t];Array.isArray(n)?(n=J(n),r=s.append(r,n)):r.push(n)})),r}function J(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach((function(t){J(t,e)})):e.push(t),e}function Z(t,e){var r,n=R();return void 0!==e&&(tt(e,n),r=1===n.length?n[0]:n),r}function tt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?t.forEach((function(t){tt(t,e)})):null!==t&&"object"===n(t)&&Object.keys(t).forEach((function(r){tt(t[r],e)}))}function et(t,e,r){var n;if(void 0!==t&&!C(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!C(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;switch(r){case"+":n=t+e;break;case"-":n=t-e;break;case"*":n=t*e;break;case"/":n=t/e;break;case"%":n=t%e}return n}function rt(t,e,r){var i,a=n(t),s=n(e);if("undefined"===a||"undefined"===s)return!1;switch(r){case"=":i=j(t,e);break;case"!=":i=!j(t,e)}return i}function nt(t,e,r){var i,a=n(t),s=n(e);if("undefined"!==a&&"string"!==a&&"number"!==a||"undefined"!==s&&"string"!==s&&"number"!==s)throw{code:"T2010",stack:(new Error).stack,value:"string"!==a&&"number"!==a?t:e};if("undefined"!==a&&"undefined"!==s){if(a!==s)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(r){case"<":i=t<e;break;case"<=":i=t<=e;break;case">":i=t>e;break;case">=":i=t>=e}return i}}function it(t,e){var r=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var n=0;n<e.length;n++)if(e[n]===t){r=!0;break}return r}function at(t,e,r){var n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=st(t),i.t0=r,i.next="and"===i.t0?4:"or"===i.t0?12:20;break;case 4:if(i.t1=a,!i.t1){i.next=10;break}return i.t2=st,i.delegateYield(e(),"t3",8);case 8:i.t4=i.t3,i.t1=(0,i.t2)(i.t4);case 10:return n=i.t1,i.abrupt("break",20);case 12:if(i.t5=a,i.t5){i.next=18;break}return i.t6=st,i.delegateYield(e(),"t7",16);case 16:i.t8=i.t7,i.t5=(0,i.t6)(i.t8);case 18:return n=i.t5,i.abrupt("break",20);case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}}),g)}function st(t){var e=s.boolean(t);return void 0!==e&&e}function ot(t,e){var r="",n="";return void 0!==t&&(r=s.string(t)),void 0!==e&&(n=s.string(e)),r.concat(n)}function lt(t,e,r){var n,a,o,l,h,c,u,d,p,f,g,m,y;return i().wrap((function(v){for(;;)switch(v.prev=v.next){case 0:n={},a={},o=!(!e||!e.tupleStream),Array.isArray(e)||(e=R(e)),0===e.length&&e.push(void 0),l=0;case 6:if(!(l<e.length)){v.next=31;break}h=e[l],c=o?U(r,h):r,u=0;case 10:if(!(u<t.lhs.length)){v.next=28;break}return d=t.lhs[u],v.delegateYield(z(d[0],o?h["@"]:h,c),"t0",13);case 13:if("string"==typeof(p=v.t0)||void 0===p){v.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:p};case 16:if(void 0===p){v.next=25;break}if(f={data:h,exprIndex:u},!a.hasOwnProperty(p)){v.next=24;break}if(a[p].exprIndex===u){v.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:p};case 21:a[p].data=s.append(a[p].data,h),v.next=25;break;case 24:a[p]=f;case 25:u++,v.next=10;break;case 28:l++,v.next=6;break;case 31:v.t1=i().keys(a);case 32:if((v.t2=v.t1()).done){v.next=43;break}return p=v.t2.value,f=a[p],g=f.data,c=r,o&&(m=ht(f.data),g=m["@"],delete m["@"],c=U(r,m)),v.delegateYield(z(t.lhs[f.exprIndex][1],g,c),"t3",39);case 39:void 0!==(y=v.t3)&&(n[p]=y),v.next=32;break;case 43:return v.abrupt("return",n);case 44:case"end":return v.stop()}}),v)}function ht(t){if(!Array.isArray(t))return t;var e={};Object.assign(e,t[0]);for(var r=1;r<t.length;r++)for(var n in t[r])e[n]=s.append(e[n],t[r][n]);return e}function ct(t,e){var r;if(void 0!==t&&!Number.isInteger(t))throw{code:"T2003",stack:(new Error).stack,value:t};if(void 0!==e&&!Number.isInteger(e))throw{code:"T2004",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return r;if(t>e)return r;var n=e-t+1;if(n>1e7)throw{code:"D2014",stack:(new Error).stack,value:n};r=new Array(n);for(var i=t,a=0;i<=e;i++,a++)r[a]=i;return r.sequence=!0,r}function ut(t,e,r){var n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(t.rhs,e,r),"t0",1);case 1:return n=i.t0,r.bind(t.lhs.value,n),i.abrupt("return",n);case 4:case"end":return i.stop()}}),m)}function dt(t,e,r){var n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(t.condition,e,r),"t0",1);case 1:if(a=i.t0,!s.boolean(a)){i.next=7;break}return i.delegateYield(z(t.then,e,r),"t1",4);case 4:n=i.t1,i.next=10;break;case 7:if(void 0===t.else){i.next=10;break}return i.delegateYield(z(t.else,e,r),"t2",9);case 9:n=i.t2;case 10:return i.abrupt("return",n);case 11:case"end":return i.stop()}}),y)}function pt(t,e,r){var n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=Lt(r),s=0;case 2:if(!(s<t.expressions.length)){i.next=8;break}return i.delegateYield(z(t.expressions[s],e,a),"t0",4);case 4:n=i.t0;case 5:s++,i.next=2;break;case 8:return i.abrupt("return",n);case 9:case"end":return i.stop()}}),b)}function ft(t){var e=new Nt.RegexEngine(t.value),r=function r(n,i){var a;e.lastIndex=i||0;var s=e.exec(n);if(null!==s){if(a={match:s[0],start:s.index,end:s.index+s[0].length,groups:[]},s.length>1)for(var o=1;o<s.length;o++)a.groups.push(s[o]);a.next=function(){if(!(e.lastIndex>=n.length)){var i=r(n,e.lastIndex);if(i&&""===i.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return i}}}return a};return r}function gt(t,e,r){return""===t.value?e&&e.outerWrapper?e[0]:e:r.lookup(t.value)}function vt(t,e,r){var a,o,l,h,c;return i().wrap((function(u){for(;;)switch(u.prev=u.next){case 0:return o=e,l=!!e.tupleStream,h=i().mark((function e(a,s){var o,h,c,u,d,p,f,g,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=0,h=0;case 2:if(!(0===o&&h<t.terms.length)){e.next=35;break}return c=t.terms[h],u=a,d=r,l&&(u=a["@"],d=U(r,a)),e.delegateYield(z(c.expression,u,d),"t0",8);case 8:return p=e.t0,u=s,d=r,l&&(u=s["@"],d=U(r,s)),e.delegateYield(z(c.expression,u,d),"t1",13);case 13:if(f=e.t1,g=n(p),v=n(f),"undefined"!==g){e.next=19;break}return o="undefined"===v?0:1,e.abrupt("continue",32);case 19:if("undefined"!==v){e.next=22;break}return o=-1,e.abrupt("continue",32);case 22:if(!("string"!==g&&"number"!==g||"string"!==v&&"number"!==v)){e.next=24;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==g&&"number"!==g?p:f};case 24:if(g===v){e.next=26;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:p,value2:f};case 26:if(p!==f){e.next=30;break}return e.abrupt("continue",32);case 30:o=p<f?-1:1;case 31:!0===c.descending&&(o=-o);case 32:h++,e.next=2;break;case 35:return e.abrupt("return",1===o);case 36:case"end":return e.stop()}}),e)})),c={environment:r,input:e},u.delegateYield(s.sort.apply(c,[o,h]),"t0",5);case 5:return a=u.t0,u.abrupt("return",a);case 7:case"end":return u.stop()}}),w)}function mt(t,e,r){var a=i().mark((function e(a){var s,o,l,h,c,u,d,p,f,g,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==a){e.next=2;break}return e.abrupt("return",void 0);case 2:if(s=r.lookup("clone"),L(s)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(xt(s,[a],null,r),"t0",6);case 6:return o=e.t0,e.delegateYield(z(t.pattern,o,r),"t1",8);case 8:if(void 0===(l=e.t1)){e.next=35;break}Array.isArray(l)||(l=[l]),h=0;case 12:if(!(h<l.length)){e.next=35;break}if(!(c=l[h])||!(c.isPrototypeOf(o)||c instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(z(t.update,c,r),"t2",17);case 17:if(u=e.t2,"undefined"===(d=n(u))){e.next=23;break}if("object"===d&&null!==u&&!Array.isArray(u)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:u};case 22:for(p in u)c[p]=u[p];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(z(t.delete,c,r),"t3",25);case 25:if(void 0===(f=e.t3)){e.next=32;break}if(g=f,Array.isArray(f)||(f=[f]),P(f)){e.next=31;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:g};case 31:for(v=0;v<f.length;v++)"object"===n(c)&&null!==c&&delete c[f[v]];case 32:h++,e.next=12;break;case 35:return e.abrupt("return",o);case 36:case"end":return e.stop()}}),e)}));return It(a,"<(oa):o>")}var yt=l("function($f, $g) { function($x){ $g($f($x)) } }");function bt(t,e,r){var n,a,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(t.lhs,e,r),"t0",1);case 1:if(a=i.t0,"function"!==t.rhs.type){i.next=7;break}return i.delegateYield(wt(t.rhs,e,r,{context:a}),"t1",4);case 4:n=i.t1,i.next=20;break;case 7:return i.delegateYield(z(t.rhs,e,r),"t2",8);case 8:if(s=i.t2,L(s)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:s};case 11:if(!L(a)){i.next=18;break}return i.delegateYield(z(yt,null,r),"t3",13);case 13:return o=i.t3,i.delegateYield(xt(o,[a,s],null,r),"t4",15);case 15:n=i.t4,i.next=20;break;case 18:return i.delegateYield(xt(s,[a],null,r),"t5",19);case 19:n=i.t5;case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}}),x)}function wt(t,e,r,a){var s,o,l,h,c,u;return i().wrap((function(d){for(;;)switch(d.prev=d.next){case 0:return d.delegateYield(z(t.procedure,e,r),"t0",1);case 1:if(void 0!==(o=d.t0)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){d.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:l=[],void 0!==a&&l.push(a.context),h=i().mark((function n(){var a,s;return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(z(t.arguments[c],e,r),"t0",1);case 1:a=n.t0,L(a)?(s=i().mark((function t(){var e,n,s,o=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(e=o.length,n=new Array(e),s=0;s<e;s++)n[s]=o[s];return t.delegateYield(xt(a,n,null,r),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}}),t)})),s.arity=N(a),l.push(s)):l.push(a);case 3:case"end":return n.stop()}}),n)})),c=0;case 8:if(!(c<t.arguments.length)){d.next=13;break}return d.delegateYield(h(),"t1",10);case 10:c++,d.next=8;break;case 13:return u="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,d.prev=14,"object"===n(o)&&(o.token=u,o.position=t.position),d.delegateYield(xt(o,l,e,r),"t2",17);case 17:s=d.t2,d.next=25;break;case 20:throw d.prev=20,d.t3=d.catch(14),d.t3.position||(d.t3.position=t.position),d.t3.token||(d.t3.token=u),d.t3;case 25:return d.abrupt("return",s);case 26:case"end":return d.stop()}}),A,null,[[14,20]])}function xt(t,e,r,n){var a,s,o,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(At(t,e,r,n),"t0",1);case 1:a=i.t0;case 2:if(!D(a)||!0!==a.thunk){i.next=21;break}return i.delegateYield(z(a.body.procedure,a.input,a.environment),"t1",4);case 4:s=i.t1,"variable"===a.body.procedure.type&&(s.token=a.body.procedure.value),s.position=a.body.procedure.position,o=[],l=0;case 9:if(!(l<a.body.arguments.length)){i.next=17;break}return i.t2=o,i.delegateYield(z(a.body.arguments[l],a.input,a.environment),"t3",12);case 12:i.t4=i.t3,i.t2.push.call(i.t2,i.t4);case 14:l++,i.next=9;break;case 17:return i.delegateYield(At(s,o,r,n),"t5",18);case 18:a=i.t5,i.next=2;break;case 21:return i.abrupt("return",a);case 22:case"end":return i.stop()}}),_)}function At(t,e,r,n){var a,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,s=e,t&&(s=St(t.signature,e,r)),!D(t)){i.next=8;break}return i.delegateYield(Et(t,s),"t0",5);case 5:a=i.t0,i.next=24;break;case 8:if(!t||!0!==t._jsonata_function){i.next=16;break}if(o={environment:n,input:r},a=t.implementation.apply(o,s),!F(a)){i.next=14;break}return i.delegateYield(a,"t1",13);case 13:a=i.t1;case 14:i.next=24;break;case 16:if("function"!=typeof t){i.next=23;break}if(a=t.apply(r,s),!F(a)){i.next=21;break}return i.delegateYield(a,"t2",20);case 20:a=i.t2;case 21:i.next=24;break;case 23:throw{code:"T1006",stack:(new Error).stack};case 24:i.next=30;break;case 26:throw i.prev=26,i.t3=i.catch(0),t&&(void 0===i.t3.token&&void 0!==t.token&&(i.t3.token=t.token),i.t3.position=t.position||i.t3.position),i.t3;case 30:return i.abrupt("return",a);case 31:case"end":return i.stop()}}),k,null,[[0,26]])}function _t(t,e,r){var n={_jsonata_lambda:!0,input:e,environment:r,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(n.thunk=!0),n.apply=i().mark((function t(r,a){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(xt(n,a,e,r.environment),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}}),t)})),n}function kt(t,e,r){var n,a,s,o,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=[],s=0;case 2:if(!(s<t.arguments.length)){i.next=15;break}if("operator"!==(o=t.arguments[s]).type||"?"!==o.value){i.next=8;break}a.push(o),i.next=12;break;case 8:return i.t0=a,i.delegateYield(z(o,e,r),"t1",10);case 10:i.t2=i.t1,i.t0.push.call(i.t0,i.t2);case 12:s++,i.next=2;break;case 15:return i.delegateYield(z(t.procedure,e,r),"t3",16);case 16:if(void 0!==(l=i.t3)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){i.next=19;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 19:if(!D(l)){i.next=23;break}n=Mt(l,a),i.next=32;break;case 23:if(!l||!0!==l._jsonata_function){i.next=27;break}n=Tt(l.implementation,a),i.next=32;break;case 27:if("function"!=typeof l){i.next=31;break}n=Tt(l,a),i.next=32;break;case 31:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 32:return i.abrupt("return",n);case 33:case"end":return i.stop()}}),S)}function St(t,e,r){return void 0===t?e:t.validate(e,r)}function Et(t,e){var r,n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=Lt(t.environment),t.arguments.forEach((function(t,r){n.bind(t.value,e[r])})),"function"!=typeof t.body){i.next=7;break}return i.delegateYield(Ct(t.body,n),"t0",4);case 4:r=i.t0,i.next=9;break;case 7:return i.delegateYield(z(t.body,t.input,n),"t1",8);case 8:r=i.t1;case 9:return i.abrupt("return",r);case 10:case"end":return i.stop()}}),E)}function Mt(t,e){var r=Lt(t.environment),n=[];return t.arguments.forEach((function(t,i){var a=e[i];a&&"operator"===a.type&&"?"===a.value?n.push(t):r.bind(t.value,a)})),{_jsonata_lambda:!0,input:t.input,environment:r,arguments:n,body:t.body}}function Tt(t,e){var r=Pt(t),n="function("+(r=r.map((function(t){return"$"+t.trim()}))).join(", ")+"){ _ }",i=l(n);return i.body=t,Mt(i,e)}function Ct(t,e){var r,n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(r=Pt(t),n=r.map((function(t){return e.lookup(t.trim())})),a={environment:e},s=t.apply(a,n),!F(s)){i.next=7;break}return i.delegateYield(s,"t0",6);case 6:s=i.t0;case 7:return i.abrupt("return",s);case 8:case"end":return i.stop()}}),M)}function Pt(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function It(t,e){var r={_jsonata_function:!0,implementation:t};return void 0!==e&&(r.signature=h(e)),r}function Rt(t,e){var r,n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=this.input,void 0!==e&&(r=e,Array.isArray(r)&&!O(r)&&((r=R(r)).outerWrapper=!0)),i.prev=4,n=l(t,!1),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(4),Ft(i.t0),{stack:(new Error).stack,code:"D3120",value:i.t0.message,error:i.t0};case 12:return i.prev=12,i.delegateYield(z(n,r,this.environment),"t1",14);case 14:a=i.t1,i.next=21;break;case 17:throw i.prev=17,i.t2=i.catch(12),Ft(i.t2),{stack:(new Error).stack,code:"D3121",value:i.t2.message,error:i.t2};case 21:return i.abrupt("return",a);case 22:case"end":return i.stop()}}),T,this,[[4,8],[12,17]])}function Ot(t){if(void 0!==t)return JSON.parse(s.string(t))}function Lt(t){var e={};return{bind:function(t,r){e[t]=r},lookup:function(r){var n;return e.hasOwnProperty(r)?n=e[r]:t&&(n=t.lookup(r)),n},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}B.bind("sum",It(s.sum,"<a<n>:n>")),B.bind("count",It(s.count,"<a:n>")),B.bind("max",It(s.max,"<a<n>:n>")),B.bind("min",It(s.min,"<a<n>:n>")),B.bind("average",It(s.average,"<a<n>:n>")),B.bind("string",It(s.string,"<x-b?:s>")),B.bind("substring",It(s.substring,"<s-nn?:s>")),B.bind("substringBefore",It(s.substringBefore,"<s-s:s>")),B.bind("substringAfter",It(s.substringAfter,"<s-s:s>")),B.bind("lowercase",It(s.lowercase,"<s-:s>")),B.bind("uppercase",It(s.uppercase,"<s-:s>")),B.bind("length",It(s.length,"<s-:n>")),B.bind("trim",It(s.trim,"<s-:s>")),B.bind("pad",It(s.pad,"<s-ns?:s>")),B.bind("match",It(s.match,"<s-f<s:o>n?:a<o>>")),B.bind("contains",It(s.contains,"<s-(sf):b>")),B.bind("replace",It(s.replace,"<s-(sf)(sf)n?:s>")),B.bind("split",It(s.split,"<s-(sf)n?:a<s>>")),B.bind("join",It(s.join,"<a<s>s?:s>")),B.bind("formatNumber",It(s.formatNumber,"<n-so?:s>")),B.bind("formatBase",It(s.formatBase,"<n-n?:s>")),B.bind("formatInteger",It(a.formatInteger,"<n-s:s>")),B.bind("parseInteger",It(a.parseInteger,"<s-s:n>")),B.bind("number",It(s.number,"<(nsb)-:n>")),B.bind("floor",It(s.floor,"<n-:n>")),B.bind("ceil",It(s.ceil,"<n-:n>")),B.bind("round",It(s.round,"<n-n?:n>")),B.bind("abs",It(s.abs,"<n-:n>")),B.bind("sqrt",It(s.sqrt,"<n-:n>")),B.bind("power",It(s.power,"<n-n:n>")),B.bind("random",It(s.random,"<:n>")),B.bind("boolean",It(s.boolean,"<x-:b>")),B.bind("not",It(s.not,"<x-:b>")),B.bind("map",It(s.map,"<af>")),B.bind("zip",It(s.zip,"<a+>")),B.bind("filter",It(s.filter,"<af>")),B.bind("single",It(s.single,"<af?>")),B.bind("reduce",It(s.foldLeft,"<afj?:j>")),B.bind("sift",It(s.sift,"<o-f?:o>")),B.bind("keys",It(s.keys,"<x-:a<s>>")),B.bind("lookup",It(s.lookup,"<x-s:x>")),B.bind("append",It(s.append,"<xx:a>")),B.bind("exists",It(s.exists,"<x:b>")),B.bind("spread",It(s.spread,"<x-:a<o>>")),B.bind("merge",It(s.merge,"<a<o>:o>")),B.bind("reverse",It(s.reverse,"<a:a>")),B.bind("each",It(s.each,"<o-f:a>")),B.bind("error",It(s.error,"<s?:x>")),B.bind("assert",It(s.assert,"<bs?:x>")),B.bind("type",It(s.type,"<x:s>")),B.bind("sort",It(s.sort,"<af?:a>")),B.bind("shuffle",It(s.shuffle,"<a:a>")),B.bind("distinct",It(s.distinct,"<x:x>")),B.bind("base64encode",It(s.base64encode,"<s-:s>")),B.bind("base64decode",It(s.base64decode,"<s-:s>")),B.bind("encodeUrlComponent",It(s.encodeUrlComponent,"<s-:s>")),B.bind("encodeUrl",It(s.encodeUrl,"<s-:s>")),B.bind("decodeUrlComponent",It(s.decodeUrlComponent,"<s-:s>")),B.bind("decodeUrl",It(s.decodeUrl,"<s-:s>")),B.bind("eval",It(Rt,"<sx?:x>")),B.bind("toMillis",It(a.toMillis,"<s-s?:n>")),B.bind("fromMillis",It(a.fromMillis,"<n-s?s?:s>")),B.bind("clone",It(Ot,"<(oa)-:o>"));var Dt={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Ft(t){var e=Dt[t.code];if(void 0!==e){var r=e.replace(/\{\{\{([^}]+)}}}/g,(function(){return t[arguments[1]]}));r=r.replace(/\{\{([^}]+)}}/g,(function(){return JSON.stringify(t[arguments[1]])})),t.message=r}}function Nt(t,e){var r,n;try{r=l(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Ft(t),t}var i=Lt(B),s=new Date;return i.bind("now",It((function(t,e){return a.fromMillis(s.getTime(),t,e)}),"<s?s?:s>")),i.bind("millis",It((function(){return s.getTime()}),"<:n>")),e&&e.RegexEngine?Nt.RegexEngine=e.RegexEngine:Nt.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==n){var o={code:"S0500",position:0};throw Ft(o),o}var l,h,c;if(void 0!==e)for(var u in l=Lt(i),e)l.bind(u,e[u]);else l=i;if(l.bind("$",t),s=new Date,l.timestamp=s,Array.isArray(t)&&!O(t)&&((t=R(t)).outerWrapper=!0),"function"==typeof a){l.async=!0;var d=function(t){Ft(t),a(t,null)},p=function t(e){(h=c.next(e)).done?a(null,h.value):h.value.then(t).catch(d)};c=z(r,t,l),(h=c.next()).value.then(p).catch(d)}else try{for(c=z(r,t,l),h=c.next();!h.done;)h=c.next(h.value);return h.value}catch(o){throw Ft(o),o}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,r){var n=It(e,r);i.bind(t,n)},ast:function(){return r},errors:function(){return n}}}return Nt.parser=l,Nt}();e.exports=c},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,r){var n=t("./signature"),i=function(){var t={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},e={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},r=function(r){var n=0,i=r.length,a=function(t,e){return{type:t,value:e,position:n}},s=function(){for(var t,e,a=n,s=0;n<i;){var o=r.charAt(n);if("/"===o&&"\\"!==r.charAt(n-1)&&0===s){if(""===(t=r.substring(a,n)))throw{code:"S0301",stack:(new Error).stack,position:n};for(n++,o=r.charAt(n),a=n;"i"===o||"m"===o;)n++,o=r.charAt(n);return e=r.substring(a,n)+"g",new RegExp(t,e)}"("!==o&&"["!==o&&"{"!==o||"\\"===r.charAt(n-1)||s++,")"!==o&&"]"!==o&&"}"!==o||"\\"===r.charAt(n-1)||s--,n++}throw{code:"S0302",stack:(new Error).stack,position:n}},o=function o(l){if(n>=i)return null;for(var h=r.charAt(n);n<i&&" \t\n\r\v".indexOf(h)>-1;)n++,h=r.charAt(n);if("/"===h&&"*"===r.charAt(n+1)){var c=n;for(n+=2,h=r.charAt(n);"*"!==h||"/"!==r.charAt(n+1);)if(h=r.charAt(++n),n>=i)throw{code:"S0106",stack:(new Error).stack,position:c};return n+=2,h=r.charAt(n),o(l)}if(!0!==l&&"/"===h)return n++,a("regex",s());if("."===h&&"."===r.charAt(n+1))return n+=2,a("operator","..");if(":"===h&&"="===r.charAt(n+1))return n+=2,a("operator",":=");if("!"===h&&"="===r.charAt(n+1))return n+=2,a("operator","!=");if(">"===h&&"="===r.charAt(n+1))return n+=2,a("operator",">=");if("<"===h&&"="===r.charAt(n+1))return n+=2,a("operator","<=");if("*"===h&&"*"===r.charAt(n+1))return n+=2,a("operator","**");if("~"===h&&">"===r.charAt(n+1))return n+=2,a("operator","~>");if(Object.prototype.hasOwnProperty.call(t,h))return n++,a("operator",h);if('"'===h||"'"===h){var u=h;n++;for(var d="";n<i;){if("\\"===(h=r.charAt(n)))if(n++,h=r.charAt(n),Object.prototype.hasOwnProperty.call(e,h))d+=e[h];else{if("u"!==h)throw{code:"S0103",stack:(new Error).stack,position:n,token:h};var p=r.substr(n+1,4);if(!/^[0-9a-fA-F]+$/.test(p))throw{code:"S0104",stack:(new Error).stack,position:n};var f=parseInt(p,16);d+=String.fromCharCode(f),n+=4}else{if(h===u)return n++,a("string",d);d+=h}n++}throw{code:"S0101",stack:(new Error).stack,position:n}}var g,v=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(r.substring(n));if(null!==v){var m=parseFloat(v[0]);if(!isNaN(m)&&isFinite(m))return n+=v[0].length,a("number",m);throw{code:"S0102",stack:(new Error).stack,position:n,token:v[0]}}if("`"===h){n++;var y=r.indexOf("`",n);if(-1!==y)return g=r.substring(n,y),n=y+1,a("name",g);throw n=i,{code:"S0105",stack:(new Error).stack,position:n}}for(var b,w=n;;)if(b=r.charAt(w),w===i||" \t\n\r\v".indexOf(b)>-1||Object.prototype.hasOwnProperty.call(t,b)){if("$"===r.charAt(n))return g=r.substring(n+1,w),n=w,a("variable",g);switch(g=r.substring(n,w),n=w,g){case"or":case"in":case"and":return a("operator",g);case"true":return a("value",!0);case"false":return a("value",!1);case"null":return a("value",null);default:return n===i&&""===g?null:a("name",g)}}else w++};return o},i=function(e,i){var a,s,o={},l=[],h=function(){var t=[];"(end)"!==a.id&&t.push({type:a.type,value:a.value,position:a.position});for(var e=s();null!==e;)t.push(e),e=s();return t},c={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=h(),t.type="error",l.push(t),t;throw t.stack=(new Error).stack,t}},u=function(t,e){var r=o[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(c)).id=r.value=t,r.lbp=e,o[t]=r),r},d=function(t){if(i){t.remaining=h(),l.push(t);var e=o["(error)"];return(a=Object.create(e)).error=t,a.type="(error)",a}throw t.stack=(new Error).stack,t},p=function(t,r){if(t&&a.id!==t){var n={code:"(end)"===a.id?"S0203":"S0202",position:a.position,token:a.value,value:t};return d(n)}var i=s(r);if(null===i)return(a=o["(end)"]).position=e.length,a;var l,h=i.value,c=i.type;switch(c){case"name":case"variable":l=o["(name)"];break;case"operator":if(!(l=o[h]))return d({code:"S0204",stack:(new Error).stack,position:i.position,token:h});break;case"string":case"number":case"value":l=o["(literal)"];break;case"regex":c="regex",l=o["(regex)"];break;default:return d({code:"S0205",stack:(new Error).stack,position:i.position,token:h})}return(a=Object.create(l)).value=h,a.type=c,a.position=i.position,a},f=function(t){var e,r=a;for(p(null,!0),e=r.nud();t<a.lbp;)r=a,p(),e=r.led(e);return e},g=function(t){u(t,0).nud=function(){return this}},v=function(e,r,n){var i=r||t[e],a=u(e,i);return a.led=n||function(t){return this.lhs=t,this.rhs=f(i),this.type="binary",this},a},m=function(t,e,r){var n=u(t,e);return n.led=r,n},y=function(t,e){var r=u(t);return r.nud=e||function(){return this.expression=f(70),this.type="unary",this},r};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),u(":"),u(";"),u(","),u(")"),u("]"),u("}"),u(".."),v("."),v("+"),v("-"),v("*"),v("/"),v("%"),v("="),v("<"),v(">"),v("!="),v("<="),v(">="),v("&"),v("and"),v("or"),v("in"),g("and"),g("or"),g("in"),y("-"),v("~>"),m("(error)",10,(function(t){return this.lhs=t,this.error=a.error,this.remaining=h(),this.type="error",this})),y("*",(function(){return this.type="wildcard",this})),y("**",(function(){return this.type="descendant",this})),y("%",(function(){return this.type="parent",this})),v("(",t["("],(function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==a.id)for(;"operator"===a.type&&"?"===a.id?(this.type="partial",this.arguments.push(a),p("?")):this.arguments.push(f(0)),","===a.id;)p(",");if(p(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach((function(t,e){if("variable"!==t.type)return d({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})})),this.type="lambda","<"===a.id){for(var e=a.position,r=1,i="<";r>0&&"{"!==a.id&&"(end)"!==a.id;){var s=p();">"===s.id?r--:"<"===s.id&&r++,i+=s.value}p(">");try{this.signature=n(i)}catch(t){return t.position=e+t.offset,d(t)}}p("{"),this.body=f(0),p("}")}return this})),y("(",(function(){for(var t=[];")"!==a.id&&(t.push(f(0)),";"===a.id);)p(";");return p(")",!0),this.type="block",this.expressions=t,this})),y("[",(function(){var t=[];if("]"!==a.id)for(;;){var e=f(0);if(".."===a.id){var r={type:"binary",value:"..",position:a.position,lhs:e};p(".."),r.rhs=f(0),e=r}if(t.push(e),","!==a.id)break;p(",")}return p("]",!0),this.expressions=t,this.type="unary",this})),v("[",t["["],(function(e){if("]"===a.id){for(var r=e;r&&"binary"===r.type&&"["===r.value;)r=r.lhs;return r.keepArray=!0,p("]"),e}return this.lhs=e,this.rhs=f(t["]"]),this.type="binary",p("]",!0),this})),v("^",t["^"],(function(t){p("(");for(var e=[];;){var r={descending:!1};if("<"===a.id?p("<"):">"===a.id&&(r.descending=!0,p(">")),r.expression=f(0),e.push(r),","!==a.id)break;p(",")}return p(")"),this.lhs=t,this.rhs=e,this.type="binary",this}));var b=function(t){var e=[];if("}"!==a.id)for(;;){var r=f(0);p(":");var n=f(0);if(e.push([r,n]),","!==a.id)break;p(",")}return p("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};y("{",b),v("{",t["{"],b),m(":=",t[":="],(function(e){return"variable"!==e.type?d({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=f(t[":="]-1),this.type="binary",this)})),v("@",t["@"],(function(e){return this.lhs=e,this.rhs=f(t["@"]),"variable"!==this.rhs.type?d({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)})),v("#",t["#"],(function(e){return this.lhs=e,this.rhs=f(t["#"]),"variable"!==this.rhs.type?d({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)})),v("?",t["?"],(function(t){return this.type="condition",this.condition=t,this.then=f(0),":"===a.id&&(p(":"),this.else=f(0)),this})),y("|",(function(){return this.type="transform",this.pattern=f(0),p("|"),this.update=f(0),","===a.id&&(p(","),this.delete=f(0)),p("|"),this}));var w=function t(e){var r;if("function"!==e.type||e.predicate)if("condition"===e.type)e.then=t(e.then),void 0!==e.else&&(e.else=t(e.else)),r=e;else if("block"===e.type){var n=e.expressions.length;n>0&&(e.expressions[n-1]=t(e.expressions[n-1])),r=e}else r=e;else{var i={type:"lambda",thunk:!0,arguments:[],position:e.position};i.body=e,r=i}return r},x=0,A=0,_=[],k=function t(e,r){switch(e.type){case"name":case"wildcard":r.level--,0===r.level&&(void 0===e.ancestor||(_[r.index].slot.label=e.ancestor.label),e.ancestor=r,e.tuple=!0);break;case"parent":r.level++;break;case"block":e.expressions.length>0&&(e.tuple=!0,r=t(e.expressions[e.expressions.length-1],r));break;case"path":e.tuple=!0;var n=e.steps.length-1;for(r=t(e.steps[n--],r);r.level>0&&n>=0;)r=t(e.steps[n--],r);break;default:throw{code:"S0217",token:e.type,position:e.position}}return r},S=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var r=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&r.push(e.slot),void 0===t.seekingParent?t.seekingParent=r:Array.prototype.push.apply(t.seekingParent,r)}},E=function(t){var e=t.steps.length-1,r=t.steps[e],n=void 0!==r.seekingParent?r.seekingParent:[];"parent"===r.type&&n.push(r.slot);for(var i=0;i<n.length;i++){var a=n[i];for(e=t.steps.length-2;a.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[a]:t.seekingParent.push(a);break}for(var s=t.steps[e--];e>=0&&s.focus&&t.steps[e].focus;)s=t.steps[e--];a=k(s,a)}}},M=function t(e){var r;switch(e.type){case"binary":switch(e.value){case".":var n=t(e.lhs);r="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(r.seekingParent=[n.slot]);var a=t(e.rhs);"function"===a.type&&"path"===a.procedure.type&&1===a.procedure.steps.length&&"name"===a.procedure.steps[0].type&&"function"===r.steps[r.steps.length-1].type&&(r.steps[r.steps.length-1].nextFunction=a.procedure.steps[0].value),"path"===a.type?Array.prototype.push.apply(r.steps,a.steps):(void 0!==a.predicate&&(a.stages=a.predicate,delete a.predicate),r.steps.push(a)),r.steps.filter((function(t){if("number"===t.type||"value"===t.type)throw{code:"S0213",stack:(new Error).stack,position:t.position,value:t.value};return"string"===t.type})).forEach((function(t){t.type="name"})),r.steps.filter((function(t){return!0===t.keepArray})).length>0&&(r.keepSingletonArray=!0);var s=r.steps[0];"unary"===s.type&&"["===s.value&&(s.consarray=!0);var o=r.steps[r.steps.length-1];"unary"===o.type&&"["===o.value&&(o.consarray=!0),E(r);break;case"[":var h=r=t(e.lhs),c="predicate";if("path"===r.type&&(h=r.steps[r.steps.length-1],c="stages"),void 0!==h.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===h[c]&&(h[c]=[]);var u=t(e.rhs);void 0!==u.seekingParent&&(u.seekingParent.forEach((function(t){1===t.level?k(h,t):t.level--})),S(h,u)),h[c].push({type:"filter",expr:u,position:e.position});break;case"{":if(void 0!==(r=t(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};r.group={lhs:e.rhs.map((function(e){return[t(e[0]),t(e[1])]})),position:e.position};break;case"^":"path"!==(r=t(e.lhs)).type&&(r={type:"path",steps:[r]});var d={type:"sort",position:e.position};d.terms=e.rhs.map((function(e){var r=t(e.expression);return S(d,r),{descending:e.descending,expression:r}})),r.steps.push(d),E(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),S(r,r.rhs);break;case"@":if(r=t(e.lhs),h=r,"path"===r.type&&(h=r.steps[r.steps.length-1]),void 0!==h.stages||void 0!==h.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===h.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(h.keepArray=!0),h.focus=e.rhs.value,h.tuple=!0;break;case"#":r=t(e.lhs),h=r,"path"===r.type?h=r.steps[r.steps.length-1]:(r={type:"path",steps:[r]},void 0!==h.predicate&&(h.stages=h.predicate,delete h.predicate)),void 0===h.stages?h.index=e.rhs.value:h.stages.push({type:"index",value:e.rhs.value,position:e.position}),h.tuple=!0;break;case"~>":(r={type:"apply",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs);break;default:(r={type:e.type,value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),S(r,r.lhs),S(r,r.rhs)}break;case"unary":r={type:e.type,value:e.value,position:e.position},"["===e.value?r.expressions=e.expressions.map((function(e){var n=t(e);return S(r,n),n})):"{"===e.value?r.lhs=e.lhs.map((function(e){var n=t(e[0]);S(r,n);var i=t(e[1]);return S(r,i),[n,i]})):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:S(r,r.expression));break;case"function":case"partial":(r={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map((function(e){var n=t(e);return S(r,n),n})),r.procedure=t(e.procedure);break;case"lambda":r={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var p=t(e.body);r.body=w(p);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),S(r,r.condition),r.then=t(e.then),S(r,r.then),void 0!==e.else&&(r.else=t(e.else),S(r,r.else));break;case"transform":(r={type:e.type,position:e.position}).pattern=t(e.pattern),r.update=t(e.update),void 0!==e.delete&&(r.delete=t(e.delete));break;case"block":(r={type:e.type,position:e.position}).expressions=e.expressions.map((function(e){var n=t(e);return S(r,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(r.consarray=!0),n}));break;case"name":r={type:"path",steps:[e]},e.keepArray&&(r.keepSingletonArray=!0);break;case"parent":r={type:"parent",slot:{label:"!"+x++,level:1,index:A++}},_.push(r);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":r=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",r=t(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};r=e}break;case"error":r=e,e.lhs&&(r=t(e.lhs));break;default:var f="S0206";"(end)"===e.id&&(f="S0207");var g={code:f,position:e.position,token:e.value};if(i)return l.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(r.keepArray=!0),r};s=r(e),p();var T=f(0);if("(end)"!==a.id){var C={code:"S0201",position:a.position,token:a.value};d(C)}if("parent"===(T=M(T)).type||void 0!==T.seekingParent)throw{code:"S0217",token:T.type,position:T.position};return l.length>0&&(T.errors=l),T};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,r){function n(t){return n="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},n(t)}var i=t("./utils"),a=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var r=1,a=[],s={},o=s;r<e.length;){var l=e.charAt(r);if(":"===l)break;var h=function(){a.push(s),o=s,s={}},c=function(t,e,r,n){for(var i=1,a=e;a<t.length;)if(a++,(l=t.charAt(a))===n){if(0==--i)break}else l===r&&i++;return a};switch(l){case"s":case"n":case"b":case"l":case"o":s.regex="["+l+"m]",s.type=l,h();break;case"a":s.regex="[asnblfom]",s.type=l,s.array=!0,h();break;case"f":s.regex="f",s.type=l,h();break;case"j":s.regex="[asnblom]",s.type=l,h();break;case"x":s.regex="[asnblfom]",s.type=l,h();break;case"-":o.context=!0,o.contextRegex=new RegExp(o.regex),o.regex+="?";break;case"?":case"+":o.regex+=l;break;case"(":var u=c(e,r,"(",")"),d=e.substring(r+1,u);if(-1!==d.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:d,offset:r};s.regex="["+d+"m]",s.type="("+d+")",r=u,h();break;case"<":if("a"!==o.type&&"f"!==o.type)throw{code:"S0401",stack:(new Error).stack,value:o.type,offset:r};var p=c(e,r,"<",">");o.subtype=e.substring(r+1,p),r=p}r++}var f="^"+a.map((function(t){return"("+t.regex+")"})).join("")+"$",g=new RegExp(f),v=function(t){var e;if(i.isFunction(t))e="f";else switch(n(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},m=function(t,e){for(var r="^",n=0,i=0;i<a.length;i++){r+=a[i].regex;var s=e.match(r);if(null===s)throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1};n=s[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1}};return{definition:e,validate:function(e,r){var n="";e.forEach((function(t){n+=v(t)}));var i=g.exec(n);if(i){var s=[],o=0;return a.forEach((function(n,a){var l=e[o],h=i[a+1];if(""===h)if(n.context&&n.contextRegex){var c=v(r);if(!n.contextRegex.test(c))throw{code:"T0411",stack:(new Error).stack,value:r,index:o+1};s.push(r)}else s.push(l),o++;else h.split("").forEach((function(r){if("a"===n.type){if("m"===r)l=void 0;else{l=e[o];var i=!0;if(void 0!==n.subtype)if("a"!==r&&h!==n.subtype)i=!1;else if("a"===r&&l.length>0){var a=v(l[0]);i=a===n.subtype.charAt(0)&&0===l.filter((function(t){return v(t)!==a})).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:l,index:o+1,type:t[n.subtype]};"a"!==r&&(l=[l])}s.push(l),o++}else s.push(l),o++}))})),s}m(e,n)}}}return e}();e.exports=a},{"./utils":6}],6:[function(t,e,r){function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}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,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(t){return s="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},s(t)}var o=function(){function t(t){var e=!1;if("number"==typeof t&&(e=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:t,stack:(new Error).stack};return e}function e(t){var e=!1;return Array.isArray(t)&&(e=0===t.filter((function(t){return"string"!=typeof t})).length),e}function r(e){var r=!1;return Array.isArray(e)&&(r=0===e.filter((function(e){return!t(e)})).length),r}function i(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function a(t){return!0===t.sequence&&Array.isArray(t)}function o(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function l(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function h(t){return t&&!0===t._jsonata_lambda}var c=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function u(t){return"object"===s(t)&&null!==t&&c in t&&"next"in t&&"function"==typeof t.next}function d(t,e){if(t===e)return!0;if("object"===s(t)&&"object"===s(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(!d(t[r],e[r]))return!1;return!0}var n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(n=n.sort(),i=i.sort(),r=0;r<n.length;r++)if(n[r]!==i[r])return!1;for(r=0;r<n.length;r++){var a=n[r];if(!d(t[a],e[a]))return!1}return!0}return!1}function p(t){var e,r=[],i=n(t);try{for(i.s();!(e=i.n()).done;){var a=e.value;r.push(a)}}catch(t){i.e(t)}finally{i.f()}return r}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:r,createSequence:i,isSequence:a,isFunction:o,isLambda:h,isIterable:u,getFunctionArity:l,isDeepEqual:d,stringToArray:p}}();e.exports=o},{}]},{},[3])(3)}(g9);var v9=g9.exports;const m9=function(t){return t};function y9(t){if(!t)return m9;try{var e=v9(t);return function(t){return e.evaluate(t)}}catch(t){return console.error(t),m9}}function b9(t){var e=P7(t);return null==e?"":String(e)}function w9(t){return Number(P7(t))}function x9(t){return t}function A9(t){return b9(t)}function _9(t){return w9(t)}function k9(t){if(this.param)return t=b9(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function S9(t){var{param:e}=this;if(e){for(let r in e){let[n,i]=r.split("~"),a=!!n,s=!!i;if(n=parseFloat(n),i=parseFloat(i),t=w9(t),a&&!s&&t>=n)return e[r];if(!a&&s&&t<n)return e[r];if(t>=n&&t<i)return e[r]}return e.default}}function E9(t){return w9(t)*Math.PI/180}function M9(){}function T9(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?A9.bind(t):"number"===i?_9.bind(t):x9.bind(e);case"map":return k9.bind(t);case"range":return S9.bind(t);case"radian":return E9.bind(t);case"eval":return function(t){try{return new Function("value","targets",t)}catch(t){return U7(t),M9}}(n).bind(e);default:return x9.bind(e)}}class C9{constructor(t,e){this.owner=e,this.model=t}dispose(){delete this._model,delete this.owner,delete this.evaluator,delete this.accessor,delete this.source}get model(){return this._model}set model(t){var{target:e,property:r,rule:n,param:i,accessor:a}=t;this._model=t,this.evaluator=T9(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=y9(a);const s=e.match(/\[(.*?)\]/);if(s){var[o,l]=s[1].split(":");this.propAccessor=y9(o),this.partAccessor=y9(l)}}get target(){return this.model.target}get property(){return this.model.property}get source(){return this.model.source}get param(){return this.model.param}get ndnsp(){return!!this.model.ndnsp}get partial(){return!!this.model.partial}}function P9(t,e,r,n){n?t.forEach((t=>t[e]={...t[e],...r})):t.forEach((t=>t[e]=r))}function I9(t=!1){(t||void 0!==this.data)&&this.mappings&&this.mappings.forEach((t=>{try{var e,{source:r,target:n,property:i,accessor:a,propAccessor:s,partAccessor:o,ndnsp:l=!1,partial:h=!1}=t;r&&"(self)"!=r?(r.startsWith("#")&&(r=r.substring(1)),e=this.root.findById(r)?.data||{}):e=this.data;var c=a(e);if("(root)"==(n=n.trim())||"(key)"==n){if(null==c)return;let e=Object.keys(c||{}).map((t=>this.root.findOrCreate(t))).filter(Boolean).flat();e.length>0&&e.forEach((e=>{let r=t.evaluator(c[e.get("id")],[e]);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||(e[i]=h?{...e[i],...r}:r)}))}else if(n.startsWith("[")){if(null==c)return;if(c instanceof Array)c.forEach((e=>{let r=s(e);if(r){let n=this.root.findOrCreate(r);if(n){let r=t.evaluator(o(e),n);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||P9(n,i,r,h)}}}));else{if(!(c instanceof Object))throw String("mapping data should be an object to target property-id.("+c+")");{let e=s(c);if(e){let r=this.root.findOrCreate(e);if(r){let e=t.evaluator(o(c),r);!i||"(action)"===i||l&&!e&&0!==e&&!1!==e||P9(r,i,e,h)}}}}}else{let e=this.root.findAll(n,this);if(e.length>0){let r=t.evaluator(c,e);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||P9(e,i,r,h)}}}catch(e){U7(e,this,t)}}))}var R9;function O9(t,e,r,n,i){var{alpha:a=1}=n,s=i.fillStyle;if(t.globalAlpha*=a,s)if("string"==typeof s)t.fillStyle=s,t.fill();else if("object"==typeof s)if("gradient"==s.type){t.translate(r.x,r.y);let n,{width:i,height:a}=e;if("linear"==s.gradientType){let e=3.141592653589793,r=s.rotation;if(r>=.436332&&r<=1.13446||r>=2.00713&&r<=2.70526||r>=3.57792&&r<=4.27606||r>=5.14872&&r<=5.84685){let s=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));s-=s-(i+a)/3,n=t.createLinearGradient(s*Math.cos(r+e),s*Math.sin(r+e),s*Math.cos(r),s*Math.sin(r))}else n=t.createLinearGradient((i-4)/2*Math.cos(r+e),(a-4)/2*Math.sin(r+e),(i-4)/2*Math.cos(r),(a-4)/2*Math.sin(r))}else if("radial"==s.gradientType){let e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));switch(s.center){case"center":default:n=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":n=t.createRadialGradient(-i/2,-a/2,0,-i/2,-a/2,2*e);break;case"right-top":n=t.createRadialGradient(i/2,-a/2,0,i/2,-a/2,2*e);break;case"left-bottom":n=t.createRadialGradient(-i/2,a/2,0,-i/2,a/2,2*e);break;case"right-bottom":n=t.createRadialGradient(i/2,a/2,0,i/2,a/2,2*e)}}s.colorStops.forEach((t=>{if(t.position>=0&&t.position<=1)try{n.addColorStop(t.position,t.color)}catch(e){H7("Invalid Color for colorstop : ",t.color),n.addColorStop(t.position,"#fff")}})),t.fillStyle=n,t.fill(),t.translate(-r.x,-r.y)}else if("pattern"==s.type&&s.image){i.prepareFillIf(!i._pattern_image_origin);var o=i._pattern_image;if(!o)return;let r=0,n=0,a=0,l=0,h=e.left,c=e.top;if(!s.fitPattern){r=s.offsetX,n=s.offsetY;const t=s.width?s.width:o.width,i=s.height?s.height:o.height;switch(s.align){case"center":a=e.width/2-t/2,l=e.height/2-i/2;break;case"left-top":a=0,l=0;break;case"left-bottom":a=0,l=e.height-i;break;case"right-top":a=e.width-t,l=0;break;case"right-bottom":a=e.width-t,l=e.height-i;break;case"left":a=0,l=e.height/2-i/2;break;case"right":a=e.width-t,l=e.height/2-i/2;break;case"top":a=e.width/2-t/2,l=0;break;case"bottom":a=e.width/2-t/2,l=e.height-i}h+=r+a,c+=n+l}t.translate(h,c),s.color&&(t.fillStyle=s.color,t.fill()),s.fitPattern?Math.abs((o.width-e.width)*(o.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(o,"no-repeat"):t.fillStyle=t.createPattern(o,s.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-h,-c)}}function L9(t,e,r){var{strokeStyle:n,lineDash:i,lineWidth:a,lineCap:s,lineJoin:o,alpha:l}=e;if(n&&0!=a){if(s&&(t.lineCap=s),i){var h="round"==s;switch(i){case"solid":i=[0,0];break;case"round-dot":i=h?[0,2*a]:[a,a];break;case"square-dot":i=h?[a,2*a]:[2*a,a];break;case"dash":i=h?[3*a,2.5*a]:[4*a,1.5*a];break;case"dash-dot":i=h?[3*a,3*a,0,3*a]:[4*a,2*a,a,2*a];break;case"long-dash":i=h?[5*a,4*a]:[6*a,3*a];break;case"long-dash-dot":i=h?[5*a,3*a,0,3*a]:[6*a,2*a,a,2*a];break;case"long-dash-dot-dot":i=h?[5*a,2*a,0,2*a,0,2*a]:[6*a,a,a,a,a,a]}t.setLineDash(i)}t.globalAlpha*=l,t.strokeStyle=n,t.lineWidth=a,t.lineJoin=o,t.stroke()}}function D9(t,e,r,n,i,a=0,s=!1,o=!0){a="number"==typeof a?{tl:a,tr:a,br:a,bl:a}:{tl:0,tr:0,br:0,bl:0,...a},t.beginPath(),t.moveTo(e+a.tl,r),t.lineTo(e+n-a.tr,r),t.quadraticCurveTo(e+n,r,e+n,r+a.tr),t.lineTo(e+n,r+i-a.br),t.quadraticCurveTo(e+n,r+i,e+n-a.br,r+i),t.lineTo(e+a.bl,r+i),t.quadraticCurveTo(e,r+i,e,r+i-a.bl),t.lineTo(e,r+a.tl),t.quadraticCurveTo(e,r,e+a.tl,r),t.closePath(),s&&t.fill(),o&&t.stroke()}function F9(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g;let r,n=[];for(;null!==(r=e.exec(t));)r[1]?n.push({text:r[2],bold:!0,italic:!1}):r[3]?n.push({text:r[4],bold:!1,italic:!0}):r[5]&&n.push({text:r[5],bold:!1,italic:!1});return n}function N9(t,e,r,n=0){if(e.text.length<2)return e;let i=2;for(;i<e.text.length;i++){const a=e.text.substring(0,i);if(!(t.measureText(a).width+(i-1)*n<r))break}return{...e,text:e.text.substring(0,i-1)}}function j9(t,e,r,n,i,a=0){const s=String(e).split("\n");return n?[].concat.apply([],s.map((e=>function(t,e,r,n=0){const i=[];let a=[],s=0;return e.forEach((e=>{let o=e.text;for(;o.length>0;){const l=r-s,h=t.measureText(o).width+(o.length-1)*n;if(h<=l)a.push({...e,text:o}),s+=h,o="";else{const r=N9(t,{...e,text:o},l,n);a.push(r),i.push(a),a=[],s=0,o=o.substring(r.text.length)}}})),a.length>0&&i.push(a),i}(t,i?F9(e):[{text:e,bold:!1,italic:!1}],r,a)))):s.map((t=>i?F9(t):[{text:t,bold:!1,italic:!1}]))}function B9(t,e,r,n,i,a,s=0){if(!n)return[];t.save(),t.font=r;var o=j9(t,n,e,!!i,a,s);return t.restore(),o}function z9(t){var{fontFamily:e=i9.FONT_FAMILY,bold:r=i9.BOLD,italic:n=i9.ITALIC,fontSize:i=i9.FONT_SIZE}=t,a=[];return r&&a.push("bold"),n&&a.push("italic"),a.push(i+"px"),a.push(e),a.join(" ")}function W9(t,e){let r=t.bold||e.bold,n=t.italic||e.italic,i=[];return r&&i.push("bold"),n&&i.push("italic"),i.push(t.fontSize+"px"),i.push(t.fontFamily),i.join(" ")}function U9(t,e,r,n){var{alpha:i,fontColor:a=i9.FONT_COLOR,textAlign:s=i9.TEXT_ALIGN,textBaseline:o=i9.TEXT_BASELINE,textBackgroundStyle:l,fontSize:h,lineHeight:c,textWrap:u,textOverflow:d,letterSpacing:p=0}=n;i=void 0!==i?i:1,h||=i9.FONT_SIZE,c||=1.2*h,t.save(),t.beginPath();var{left:f,top:g,width:v,height:m}=e;if(t.font=z9(n),!u&&d){const e=function(t,e,r,n){const i="ellipsis"===t?"…":"",a=e.measureText(i).width;let s=[],o=0;for(let i of r){let r=[];for(let l of i){let i=e.measureText(l.text).width;if(!(o+i<=n-("ellipsis"===t?a:0))){let i=H9(e,l,n-o-("ellipsis"===t?a:0),t);return r.push(i),s.push(r),s}r.push(l),o+=i}s.push(r),o=0}return s}(d,t,r,v);r=e}var y,b=r.length*c;switch(o){case"top":y=g,t.textBaseline="top";break;case"bottom":y=g+m-b+c,t.textBaseline="bottom";break;default:y=g+m/2-b/2+c/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,r.forEach(((e,i)=>{let o=y+i*c,u=function(t,e,r,n=0){return e.reduce(((e,i)=>(t.font=W9(r,i),e+t.measureText(i.text).width+n*(i.text.length-1))),0)}(t,e,n,p),d=f;switch(s){case"left":case"justify":d=f;break;case"right":d=f+v-u;break;case"center":d=f+(v-u)/2}if(l&&(t.fillStyle=l,D9(t,d-4,o-h/2-4,u+8,h+8,4,!0,!1),t.fillStyle=a),"justify"===s&&i<r.length-1&&e.length>1){let r=v-u,i=e.length-1,a=r/i;e.forEach(((e,r)=>{t.font=W9(n,e),t.fillText(e.text,d,o),d+=t.measureText(e.text).width+(r<i?a:0)}))}else e.forEach((e=>{t.font=W9(n,e),[...e.text].forEach((e=>{t.fillText(e,d,o),d+=t.measureText(e).width+p}))}))})),t.restore()}function H9(t,e,r,n){let i="";for(let n=0;n<e.text.length;n++){let a=i+e.text[n];if(t.measureText(a).width>r)break;i=a}return{...e,text:i+("ellipsis"===n?"…":"")}}function G9(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){const a=Math.cos(-n),s=Math.sin(-n);return{x:((t-=r.x)*a-(e-=r.y)*s+r.x)/i.x,y:(t*s+e*a+r.y)/i.y}}function Y9(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){const a=Math.cos(n),s=Math.sin(n);return{x:((t-=r.x)*a-(e-=r.y)*s+r.x)*i.x,y:(t*s+e*a+r.y)*i.y}}function V9(t){var e=t.element,r=t.fillStyle,n=e.style;if(r)if("string"==typeof r)n.backgroundColor=r;else switch(r.type){case"pattern":if(n.backgroundImage="url("+r.image+")",n.backgroundColor="transparent",r.fitPattern?n.backgroundSize="100% 100%":r.width||r.height?n.backgroundSize=`${r.width?r.width+"px":"auto"} ${r.height?r.height+"px":"auto"}`:n.backgroundSize="contain",r.fitPattern)n.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:a,color:s}=r;if(i&&(n.backgroundRepeat="no-repeat"),s&&(n.backgroundColor=s),a)switch(a){case"center":n.backgroundPosition="center center";break;case"left-top":n.backgroundPosition="left top";break;case"left-bottom":n.backgroundPosition="left bottom";break;case"right-top":n.backgroundPosition="right top";break;case"right-bottom":n.backgroundPosition="right bottom";break;case"left":n.backgroundPosition="left center";break;case"right":n.backgroundPosition="right center";break;case"top":n.backgroundPosition="center top";break;case"bottom":n.backgroundPosition="center bottom"}else t||e?n.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete n.backgroundPosition}break;case"gradient":n.background=function(t,e){var r=e.colorStops,n=e.gradientType;if(r instanceof Array&&r.length>0)switch(n){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){var{width:r,height:n}=t.bounds;switch(e){case"center":return[r/2,n/2];case"left-top":return[0,0];case"right-top":return[r,0];case"left-bottom":return[0,n];default:return[r,n]}}(t,e.center||"center").map((t=>t+"px")).join(" ")+","+r.map((t=>`${t.color} ${100*t.position}%`)).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+r.map((t=>`${t.color} ${100*t.position}%`)).join(",")+")"}return""}(t,r)}else n.background="transparent"}R9="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){var r=document.createElement("canvas");return r.width=t,r.height=e,r};const q9={x:1,y:1},X9={x:0,y:0},$9={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function K9(t){var{id:e,scale:r=q9,translate:n=X9,bold:i,italic:a,fontFamily:s="",textAlign:o,textBaseline:l,textOverflow:h,paddingTop:c,paddingBottom:u,paddingLeft:d,paddingRight:p,fontSize:f=i9.FONT_SIZE,lineWidth:g=0,lineHeight:v,lineDash:m}=t.state;u||=0,c||=0,d||=0,p||=0;var y=t.state.class;t.text;var{strokeStyle:b,fillStyle:w,rotation:x=0,fontColor:A,hidden:_}=t,{left:k,top:S,width:E,height:M}=t.bounds,T=t.element;if(T.hidden=_,e&&(T.id=e),y&&(T.className=y),Object.assign(T.style,$9,{fontFamily:s,fontSize:f+"px",width:E+"px",height:M+"px",paddingTop:c+"px",paddingRight:p+"px",paddingBottom:u+"px",paddingLeft:d+"px",border:g+"px",borderColor:b,borderStyle:g>0?m||i9.LINE_DASH:"",color:A,fontWeight:i?"bold":"",fontStyle:a?"italic":"",textAlign:"end"==o?"right":"start"==o?"left":o,verticalAlign:l,lineHeight:void 0===v?"":v+"px",whiteSpace:h?"nowrap":"",overflow:h?"hidden":"",textOverflow:h||""},t.isIn3DSpace()?{}:{left:k+"px",top:S+"px"}),V9(t),function(t){if(t.isShadowable()&&t.state.shadow){var e=t.element,{left:r=0,top:n=0,blurSize:i=0,color:a="transparent"}=t.state.shadow;e.style.boxShadow=`${r}px ${n}px ${i}px ${a}`}}(t),!t.isIn3DSpace()){var C=t.delta(),P=(r&&r.x||1)*C.sx,I=(r&&r.y||1)*C.sy,R=(x||0)+C.theta,O=C.tx||0,L=C.ty||0;T.style.transform=`rotate(${R}rad) translate(${O}px, ${L}px) scale(${P}, ${I}) perspective(1px)`}}var Q9,J9=[];function Z9(){Q9=null;var t=performance.now(),e=(J9=J9.filter((t=>ttt(t)))).reduce(((e,r)=>{let n=t-r.updatedAt;return n>=r.retention?e.kills.push(r):e.next=0==e.next?r.retention-n:Math.min(e.next,r.retention-n),e}),{next:0,kills:[]});e.kills.forEach((t=>{let e=J9.indexOf(t);-1!=e?(J9.splice(e,1),t.removeSelf(!0)):U7("Should not be here. Maybe reentrance problem.")})),e.next>0&&(Q9=setTimeout(ett,Math.max(e.next,500)))}function ttt(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var ett=A7((function(){requestAnimationFrame(Z9)}),500);var rtt=new class{add(t){ttt(t)&&-1==J9.indexOf(t)&&(J9.push(t),t.touch()),this.touch()}remove(t){var e=J9.indexOf(t);e>0&&J9.splice(e,1),this.touch()}touch(){null!==Q9&&(clearTimeout(Q9),Q9=null),ett()}get length(){return J9.length}};const ntt=function(t){return t};function itt(t){var e=t.indexOf("||"),r="",n="";-1!=e&&(r=t,n=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());var i=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter((t=>!!t.trim())),a=i.slice(1);return{defaultValue:n,match:t,originText:r||t,target:i[0],accessor:a.length>0?function(t){return a.reduce(((t,e)=>t?t[e]:void 0),t)}:ntt}}function att(t,e,r){if(t){var n=r||P7,i=String(t),a=(i.match(/#{[^}]*}/gi)||[]).map((t=>itt(t))),s=(i.match(/\${[^}]*}/gi)||[]).map((t=>itt(t)));if(0!=a.length||0!=s.length)return function(){var t=i;return a.forEach((r=>{let i=n(r.accessor(e.getState(r.target)));t=t.replace(r.originText,void 0===i?r.defaultValue||"":i)})),s.forEach((r=>{let i=e.root.findById(r.target),a=n(r.accessor(i&&i.data));t=t.replace(r.originText,void 0===a?r.defaultValue||"":a)})),t}}}const stt=210*Math.PI/180,ott=150*Math.PI/180;var ltt={"data-spread":function(t,e,r){if(t.app.isEditMode){var n=!1;return t.mappings&&t.mappings.forEach((r=>{let i=t.root.findAll(r.target,t);i&&(e.lineWidth=2,i.forEach((r=>{let i=t.center,a=r.center;i=t.transcoordS2C(i.x,i.y,t.rootModel),a=r.transcoordS2C(a.x,a.y,r.rootModel),e.beginPath();const s=e.createLinearGradient(i.x,i.y,a.x,a.y);["#FFA50033","#FFA500"].forEach(((t,e)=>s.addColorStop(e,t))),e.strokeStyle=s,e.fillStyle=s,function(t,e,r,n=10){var i=r.x-e.x,a=r.y-e.y,s=Math.atan2(a,i),o=r.x+n*Math.cos(s+stt),l=r.y+n*Math.sin(s+stt),h=r.x+n*Math.cos(s+ott),c=r.y+n*Math.sin(s+ott);t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(r.x,r.y),t.moveTo(r.x,r.y),t.lineTo(o,l),t.moveTo(r.x,r.y),t.lineTo(h,c),t.stroke()}(e,i,a),n=!0})))})),n}},"bouncing-arrow":function(t,e,r){let{left:n,top:i,width:a}=t.bounds,s=t.state.id,{x:o,y:l}=t.transcoordS2C(n+a/2,i,t.rootModel);const h=2*function(t){const e=100*(1-t)%10;return e<5?e:10-e}(r||0);if(o=Math.max(o,20),l=Math.max(l,20),e.beginPath(),e.moveTo(o-10,l-16+h),e.lineTo(o+10,l-16+h),e.lineTo(o+10,l-8+h),e.lineTo(o+16,l-8+h),e.lineTo(o,l+h),e.lineTo(o-16,l-8+h),e.lineTo(o-10,l-8+h),e.lineTo(o-10,l-16+h),e.lineTo(o-10,l-16+h),e.fillStyle="#FF0000",e.fill(),s){e.beginPath(),e.font="12px Arial";let t=e.measureText(s);e.fillStyle="#FF0000",e.roundRect(o-t.actualBoundingBoxLeft-3+20,l-t.actualBoundingBoxAscent-3-6+h,t.actualBoundingBoxLeft+t.actualBoundingBoxRight+6,t.actualBoundingBoxAscent+t.actualBoundingBoxDescent+6,3),e.fill(),e.fillStyle="white",e.fillText(s,o+20,l-6+h)}return!0},decotag:function(t,e,r){const n=t.decotag;if(n){let{left:r,top:i}=t.bounds,{x:a,y:s}=t.transcoordS2C(r,i,t.rootModel);a=Math.max(a+3,5),s=Math.max(s-8,15),e.font="12px Arial";let o=e.measureText(n);return e.beginPath(),e.fillStyle="#FF0000",e.roundRect(a-o.actualBoundingBoxLeft-3,s-o.actualBoundingBoxAscent-3,o.actualBoundingBoxLeft+o.actualBoundingBoxRight+6,o.actualBoundingBoxAscent+o.actualBoundingBoxDescent+6,3),e.fill(),e.beginPath(),e.fillStyle="white",e.fillText(n,a,s),!0}return!1},anchors:function(t,e,r){if(t.app.isEditMode){var n=!1;return t.anchors&&t.anchors.forEach((r=>{const{name:i,position:a}=r;var{x:s,y:o}=a||{};if(!i)return;var{x:s,y:o}=t.transcoordS2C(s,o,t.rootModel);s+=4,o+=4,e.font="12px Arial";let l=e.measureText(i);e.fillStyle="#FF0000",D9(e,s,o,l.width+6,16,3,!0,!1),e.fillStyle="white",e.fillText(i,s+3,o+13),n=!0})),n}},link:function(t,e,r){var n=!1;if(!t.isLine())return;const{fromEnd:i,toEnd:a}=t;return[i,a].filter(Boolean).forEach((t=>{const{component:r,anchor:i}=t;if(!i)return;const{name:a,position:s}=i||{};if(!a||!s)return;var{x:o,y:l}=s||{},{x:o,y:l}=r.transcoordS2C(o,l,r.rootModel);o+=8,l+=20,e.font="12px Arial";let h=e.measureText(a);e.fillStyle="#FF0000",D9(e,o-h.actualBoundingBoxLeft-4,l-h.actualBoundingBoxAscent-4,h.actualBoundingBoxLeft+h.actualBoundingBoxRight+8,h.actualBoundingBoxAscent+h.actualBoundingBoxDescent+8,4,!0,!1),e.fillStyle="white",e.fillText(a,o,l),n=!0})),n}};function htt(t){return ltt[t]}var ctt={};const utt={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},dtt=[],ptt={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};var ftt=0,gtt={};const vtt=new FinalizationRegistry((t=>{!function(t){ftt--;var e=gtt[t];e||(e=gtt[t]={up:0,down:0}),e.down++}(t)}));class mtt{static get nature(){return utt}static register(t,e){if(!e)return ctt[t];ctt[t]=e}static get residents(){return gtt}static get residentsCount(){return ftt}static registerDecorator(t,e){!function(t,e){ltt[t]=e}(t,e)}constructor(t,e){this._app=e,this._model=t||{},this._state={},this._delta=h7(ptt),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),rtt.add(this),function(t){ftt++;var e=gtt[t];e||(e=gtt[t]={up:0,down:0}),e.up++}(t.type),vtt.register(this,t.type)}created(){}added(t){}removed(t){}async ready(){if(this.state.persistent){const{isViewMode:t,dataStorage:e}=this.app;t&&(this.data=await e.load(this))}}touch(){this.updatedAt=performance.now()}clearCache(...t){!function(t,...e){0==e.length?t.__cache__={}:e.forEach((e=>delete t.__cache__[e]))}(this,...t)}removeSelf(t){t?this.dispose():this.parent&&this.parent.removeComponent(this)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=h7(ptt))}dispose(){this.resetAnimation(),this.disposeMappings(),this.parent&&this.parent.removeComponent(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this.retention&&rtt.touch(),this.clearCache(),delete this._app}get nature(){return this.constructor.nature}get disposed(){return!!this._disposed}isLayer(){return!1}isGroup(){return!1}isContainer(){return!1}isLine(){return!1}isRoot(){return!1}isRootModel(){return!1}is3dish(){return!1}isIn3DSpace(){return!1}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}replaceRefids(t){}get retention(){return Number(this.get("retention"))||0}get hasTextProperty(){return!0}get app(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}get model(){return this._model}get state(){return Object.assign({},this._model,this._state)}get hierarchy(){var t=h7(this._model);return this.volatile.forEach((e=>{delete t[e]})),t}get volatile(){return dtt}get textHidden(){return!!this._textHidden}set textHidden(t){this._textHidden=!!t,this.invalidate()}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});var r={},n={},i=!1,a=(t=h7(t),this);return Object.getOwnPropertyNames(t).forEach((function(e){let s=a._model[e],o=t[e];T6(s,o)||(n[e]=s,r[e]=o,a._model[e]=o,delete a._state[e],i=!0)})),i&&(this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,r.hasOwnProperty("retention")&&rtt.add(this),r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,n),r.hasOwnProperty("mappings")&&this.onchangeMappings(r,n),r.hasOwnProperty("data")&&this.onchangeData(r,n),this.onchange&&this.onchange(r,n),this.trigger("change",r,n)),this}getState(t){return this._state.hasOwnProperty(t)?this._state[t]:this.get(t)}setState(t,e){if("string"==typeof t)return this.setState({[t]:e});var r={},n={},i=!1,a=(t=h7(t),this),s=this.getState("sensitive");return Object.getOwnPropertyNames(t).forEach((function(e){let o=a.getState(e),l=t[e];!s&&T6(o,l)||(n[e]=o,r[e]=l,a._state[e]=l,i=!0)})),i&&(this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,n),r.hasOwnProperty("data")&&this.onchangeData(r,n),this.onchange&&this.onchange(r,n),this.trigger("change",r,n)),this}get root(){return this.isRoot()?this:this.parent&&this.parent.root}get rootModel(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}get parent(){return this._parent}set parent(t){this._parent=t}get anchors(){return this.nature.anchors||[]}findAnchor(t){return this.anchors.find((e=>e.name===t))}isDescendible(t){return!0}getContext(){return this._parent.getContext()}get center(){var t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}set center(t){if(t&&!isNaN(t.x)&&!isNaN(t.y)){var e=this.center;if(Math.round(100*t.x)/100!=Math.round(100*e.x)/100||Math.round(100*t.y)/100!=Math.round(100*e.y)/100){var r=t.x-e.x,n=t.y-e.y;this.path=this.path.map((t=>({x:t.x+r,y:t.y+n})))}}}get location(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}set location(t){const{x:e,y:r,z:n}=t||{};this.center={x:e,y:r},isNaN(n)||this.setState("zPos",Number(n))}get rotate(){const{rotationX:t,rotationY:e,rotation:r}=this.state;return{x:t,y:e,z:-r}}set rotate(t){const{x:e,y:r,z:n}=t;this.setState({rotationX:e,rotationY:r,rotation:-n})}get dimension(){const{width:t,height:e}=this.bounds,{depth:r}=this.state;return{width:t,height:e,depth:r}}set dimension(t){const{width:e,height:r,depth:n}=t,{top:i,left:a}=this.bounds;this.bounds={top:i,left:a,width:e,height:r},this.setState("depth",n)}get bounds(){var t,e,r,n,i=this.path;t=e=i[0].x,r=n=i[0].y;for(let a=1;a<i.length;a++){let s=i[a];s.x<t?t=s.x:s.x>e&&(e=s.x),s.y<r?r=s.y:s.y>n&&(n=s.y)}return{left:t,top:r,width:e-t,height:n-r}}set bounds(t){var e=this.bounds;if(Math.round(100*t.width)/100!=Math.round(100*e.width)/100||Math.round(100*t.height)/100!=Math.round(100*e.height)/100||Math.round(100*t.left)/100!=Math.round(100*e.left)/100||Math.round(100*t.top)/100!=Math.round(100*e.top)/100){var r=0==e.width?1:t.width/e.width,n=0==e.height?1:t.height/e.height;this.path=this.path.map((i=>({x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n})))}}get path(){return U7("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}set path(t){U7("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}get drawPath(){return this.path}outline(t){return function(t,e){var r=t.path.slice();if(r&&r.length){var n=1,i=[];if(t.isLine()||r.push(r[0]),e<=0)return t.transcoordS2T(r[0].x,r[0].y);if(e>=1)return t.transcoordS2T(r[r.length-1].x,r[r.length-1].y);for(;r[n];){let t=r[n-1],e=r[n],a=e.x-t.x,s=e.y-t.y;i.push(Math.sqrt(a*a+s*s)),n++}var a=i.reduce((function(t,e){return t+e}),0);n=0;var s=0;do{s+=i[n++]}while(s/a<e);e=(e-(s-=i[--n])/a)*(a/i[n]);var o=r[n%r.length],l=r[(n+1)%r.length],h=o.x+Math.round((l.x-o.x)*e),c=o.y+Math.round((l.y-o.y)*e);return t.transcoordS2T(h,c)}U7("path should not be empty")}(this,t||0)}get strokeStyle(){return this.get("strokeStyle")}set strokeStyle(t){this.set("strokeStyle",t)}get fillStyle(){return this.getState("fillStyle")}set fillStyle(t){this.setState("fillStyle",t)}get fontColor(){return this.get("fontColor")}set fontColor(t){this.set("fontColor",String(P7(t)))}get rotation(){return this.getState("rotation")}set rotation(t){this.setState("rotation",Number(P7(t)))}contains(t,e){return!1}get mutable(){return this.nature.mutable}get resizable(){return this.nature.resizable&&!this.stuck}adjustResize(t,e,r){if(r){let e=this.bounds,r=e.height/e.width,n=t.width-e.width,i=t.height-e.height;n*r>i?i=n*r:n=i/r;let a=t.left-e.left,s=t.top-e.top;return 0!=a&&0!=s?(s=-i,a=-n):0!=a?a=-n:0!=s&&(s=-i),{left:e.left+a,top:e.top+s,width:e.width+n,height:e.height+i}}return t}get rotatable(){return this.nature.rotatable&&!this.stuck}adjustRotation(t,e){if(e||this.app.rotateStepForced){let e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}get capturable(){return!1!==this.get("capturable")&&(this.app.isEditMode||!this.hidden)}get stuck(){return!!(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))}findFirst(t,...e){if(t(this,...e))return this}findAll(t,...e){return"string"==typeof t?p9(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}capture(t,e,r){if(!this.capturable||r?.(this))return!1;var n=this.transcoordP2S(t,e);return this.contains(n.x,n.y)?this:void 0}prepare(t,e){t(this)}prepareIf(t){t&&this.prepare&&this.prepare((t=>{this.invalidate()}),(t=>{U7(t)}))}get decotag(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}get decorators(){return["decotag","data-spread"]}get reactionDecorators(){return["bouncing-arrow"]}get hidden(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}set hidden(t){this.setState("hidden",t)}draw(t){t.save(),this.prerender(t),this.render(t),this.postrender(t),t.restore()}delta(t,e){if(void 0===e)return t?this._delta[t]:this._delta;this._delta[t]=e}prerender(t){var e=this.rotatePoint,{scale:r,rotation:n,shadow:i,alpha:a}=this.state,s=(r&&r.x||1)*this._delta.sx,o=(r&&r.y||1)*this._delta.sy,l=(n||0)+this._delta.theta,{tx:h=0,ty:c=0}=this._delta,u=(a||1)-this._delta.fade;(h||c)&&t.translate(h,c),(1!=s||1!=o||l)&&(t.translate(e.x,e.y),1==s&&1==o||t.scale(s,o),l&&t.rotate(l),t.translate(-e.x,-e.y)),u&&(t.globalAlpha=u),i&&s9(t,i,this),this.app.isEditMode&&this.hidden&&(t.globalAlpha*=.5)}render(t){}postrender(t){this.drawText(t)}drawText(t){!this.textHidden&&this.text&&this.hasTextProperty&&U9(t,this.textBounds,this.textLines(t),this.state)}drawStroke(t,e){L9(t,e?{...this.state,...e}:this.state)}drawFill(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(O9(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}animate(t){return this._animate&&this._animate.stop(),this._animate=D8(t),this._animate}move({x:t,y:e}){var r=this.path,n=t,i=e;this.path=r.map((t=>({x:t.x+n,y:t.y+i})))}symmetryX(t){"number"!=typeof t&&(t=this.center.x);var{rotation:e}=this.state,r=this.fillStyle;if(this.set("rotation",2*Math.PI-e),r&&"gradient"===r.type&&"linear"===r.gradientType){var n=h7(r);n.rotation=(Math.PI-parseFloat(r.rotation||0))%(2*Math.PI),this.set("fillStyle",n)}this.path=this.path.map((e=>({x:2*t-e.x,y:e.y})))}symmetryY(t){this.symmetryX(),this.set("rotation",(Math.PI+this.model.rotation)%(2*Math.PI)),t&&this.move({x:0,y:2*(t-this.center.y)},!1)}get animation(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){var t=this.state.animation;t&&t.oncreate&&(this._animation=L8(this,t.oncreate))}return this._animation}}effect(t,e){return function(t,e,r){var n=o9[r.type];n&&n(t,e,r)}(this,t,e)}get started(){return!!this.animation?.started}set started(t){this.animation&&(this.animation.started=t)}invalidate(){this.parent&&this.parent.invalidate()}get font(){return z9(this.model)}get lineHeight(){var t=this.get("lineHeight");return t||1.2*this.fontSize}defaultTextSubstitutor(){var t=this.getState("text");return null==t?"":String(t)}get textSubstitutor(){return this._text_substitutor||(this._text_substitutor=att(this.getState("text"),this)||this.defaultTextSubstitutor),this._text_substitutor}get text(){var t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;var r,n,i,a,s,o,l,h,c,u=t.length,d=t.search(/[0-9\-\+#]/),p=d>0?t.substring(0,d):"",f=t.split("").reverse().join(""),g=f.search(/[0-9\-\+#]/),v=u-g,m=t.substring(v,v+1),y=v+("."===m||","===m?1:0),b=g>0?t.substring(y,u):"";if(r=(e="-"===(t=t.substring(d,y)).charAt(0)?-e:+e)<0?e=-e:0,i=(n=t.match(/[^\d\-\+#]/g))&&n[1]&&n[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",s=t[1]&&t[1].lastIndexOf("0"),(!(l=e.split("."))[1]||l[1]&&l[1].length<=s)&&(e=(+e).toFixed(s+1)),h=t[0].split(i),t[0]=h.join(""),(a=t[0]&&t[0].indexOf("0"))>-1)for(;l[0].length<t[0].length-a;)l[0]="0"+l[0];else 0==+l[0]&&(l[0]="");if((e=e.split("."))[0]=l[0],o=h[1]&&h[h.length-1].length){for(f="",v=(c=e[0]).length%o,u=c.length,y=0;y<u;y++)f+=c.charAt(y),!((y-v+1)%o)&&y<u-o&&(f+=i);e[0]=f}return e[1]=t[1]&&e[1]?"."+e[1]:"","0"!==(n=e.join(""))&&""!==n||(r=!1),p+("+"==t[0].substring(0,1)?r?"-":"+":r?"-":"")+n+b}(t,this.textSubstitutor()):this.textSubstitutor()}set text(t){delete this._text_substitutor;var e=P7(t);this.setState("text",null==e?"":String(e))}textLines(t){const{textWrap:e,supportMarkdown:r}=this.state;return B9(t||this.getContext(),this.textBounds.width,this.font,this.text,e,r)}get textBounds(){var{paddingTop:t,paddingLeft:e,paddingRight:r,paddingBottom:n}=this.state;n||=0,t||=0,e||=0,r||=0;var{left:i,top:a,width:s,height:o}=this.bounds;return{left:i+e,top:a+t,width:Math.max(s-e-r,0),height:Math.max(o-t-n,0)}}get textRotation(){return 0}get rotatePoint(){return this.center}trim(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}get value(){var t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}set value(t){var e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}get data(){return this.getState("data")}set data(t){this.setState("data",t),this.touch()}set tap(t){var e=this.model.event?.tap;if(e){const{cx:t,cy:r}=this.center;this.rootModel?._doEventAction(e,this,!0,new CustomEvent("click",{offsetX:t,offsetY:r}))}}get mappings(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}serialize(...t){return JSON.stringify(this.hierarchy,...t)}get controls(){}closeScene(t){this.rootModel.closeScene(t)}}mtt.union=function(t){var e,r,n,i;return t.forEach((t=>{void 0===e?(e=t.left,r=t.top,n=t.left+t.width,i=t.top+t.height):(e=Math.min(t.left,e),r=Math.min(t.top,r),n=Math.max(t.left+t.width,n),i=Math.max(t.top+t.height,i))})),{left:e,top:r,width:n-e,height:i-r}},mtt.transcoordR=G9,mtt.transcoordRR=Y9,mtt.createCanvas=R9,mtt.memoize=Y7,mtt.mixin=W7,mtt.drawText=U9,mtt.font=z9,mtt.textLines=B9,mtt.drawStroke=L9,mtt.drawFill=O9,mtt.reposition=K9,mtt.RetentionManager=rtt,mtt.template=function(t,e,r){var n=A8.imports._.templateSettings||A8;r&&H6(t,e,r)&&(e=void 0),t=b8(t),e=$6({},e,n,l8);var i,a,s=$6({},e.imports,n.imports,l8),o=n6(s),l=function(t,e){return a8(e,(function(e){return t[e]}))}(s,o),h=0,c=e.interpolate||T8,u="__p += '",d=RegExp((e.escape||T8).source+"|"+c.source+"|"+(c===u8?M8:T8).source+"|"+(e.evaluate||T8).source+"|$","g"),p=P8.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(d,(function(e,r,n,s,o,l){return n||(n=s),u+=t.slice(h,l).replace(C8,c8),r&&(i=!0,u+="' +\n__e("+r+") +\n'"),o&&(a=!0,u+="';\n"+o+";\n__p += '"),n&&(u+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),h=l+e.length,e})),u+="';\n";var f=P8.call(e,"variable")&&e.variable;if(f){if(E8.test(f))throw new Error("Invalid `variable` option passed into `_.template`")}else u="with (obj) {\n"+u+"\n}\n";u=(a?u.replace(_8,""):u).replace(k8,"$1").replace(S8,"$1;"),u="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+u+"return __p\n}";var g=i8((function(){return Function(o,p+"return "+u).apply(void 0,l)}));if(g.source=u,r8(g))throw g;return g},mtt.buildSubstitutor=att,Object.assign(mtt.prototype,{drawEffect:function(t){const{effects:e}=this.state;(e||[]).forEach((e=>{this.effect(t,e)}))},prepareFill:function(t,e){var r=this.fillStyle;if(r&&"pattern"==r.type&&r.image){if("string"!=typeof r.image)return this._pattern_image_origin=this._pattern_image=r.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;var n=this;this._pattern_image_origin.onload=function(){if(!r.fitPattern&&!r.width&&!r.height)return n._pattern_image=n._pattern_image_origin,void t(this);let e=r.width||this.width,i=r.height||this.height;r.fitPattern&&(e=n.bounds.width,i=n.bounds.height);let a=R9(e,i);a.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),n._pattern_image=a,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(r.image).substring(0,4)?this._pattern_image_origin.crossOrigin="use-credentials":this._pattern_image_origin.crossOrigin=null,this._pattern_image_origin.src=this.app.url(r.image)}catch(t){e(t)}}else t(this)},prepareFillIf:function(t){t&&this.prepareFill((t=>{this.invalidate()}),(t=>{U7(t)}))},onchangeFill:function(t,e){var r=this.fillStyle;r&&"pattern"!==r.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):r?.image&&this.prepareFillIf(r.image)},drawImage:function(t,e,r,n,i,a){e.complete?t.drawImage(e,r,n,i,a):e.addEventListener("load",(()=>{this.invalidate()}))},mutateBounds:function(t,e){var r=this.bounds,n=this.rotatePoint,i=this.get("rotation"),a=this.get("scale");if(t){var s=t.call(e,r);s&&(r=s)}var{left:o,top:l,width:h,height:c}=r,u=[{x:o,y:l},{x:o+h,y:l+c}],d=(u=u.map((t=>Y9(t.x,t.y,n,i,a))))[0],p=u[1];n={x:(d.x+p.x)/2,y:(d.y+p.y)/2},d=(u=u.map((t=>G9(t.x,t.y,n,i,a))))[0],p=u[1],this.bounds={left:d.x,top:d.y,width:p.x-d.x,height:p.y-d.y}},mutatePath:function(t,e,r){var n=this.path,i=this.rotatePoint;this.get("rotation"),this.get("scale"),t&&(n=t.call(r,n));var a=n.map((t=>this.transcoordS2P(t.x,t.y)));e&&(n=e.call(r,a))&&(a=n);var s,o,l,h,c={x:0,y:0};s=o=(n=a.map((t=>this.transcoordP2S(t.x,t.y,c))))[0].x,l=h=n[0].y;for(let t=1;t<n.length;t++){let e=n[t];e.x<s?s=e.x:e.x>o&&(o=e.x),e.y<l?l=e.y:e.y>h&&(h=e.y)}i={x:(s+o)/2,y:(l+h)/2},i=this.transcoordS2P(i.x,i.y,c),this.path=a.map((t=>this.transcoordP2S(t.x,t.y,i)))},access:function(t){if(t){var e=String(t),r=(e.match(/#{(\S*)}/)||[]).map((t=>itt(t)))[0];if(r)return r.accessor(this.getState(r.target));var n=(e.match(/\${[^}]*}/)||[]).map((t=>itt(t)))[0];if(n){let t=this.root.findById(n.target);return n.accessor(this.getState(t))}return t}},substitute:function(t,e){if(t){var r=String(t),n=e||P7,i=(r.match(/#{(\S*)}/gi)||[]).map((t=>itt(t))),a=(r.match(/\${[^}]*}/gi)||[]).map((t=>itt(t)));if(0==i.length&&0==a.length)return r;var s=r;return i.forEach((t=>{let e=n(t.accessor(this.getState(t.target)));s=s.replace(t.match,void 0===e?"":e)})),a.forEach((t=>{let e=this.root.findById(t.target),r=n(t.accessor(e&&e.data));s=s.replace(t.match,void 0===r?"":r)})),s}},onchangeMappings:function(t,e){this.disposeMappings(),I9.call(this)},onchangeData:function(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),I9.call(this,[!0])},buildMappings:function(){if(this._model.mappings)return!this._model.mappings instanceof Array?(U7("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[])):void(this._mappings=(this._model.mappings||[]).filter((t=>t.rule&&t.target)).map((t=>new C9(t,this))));this._mappings=[]},executeMappings:I9,disposeMappings:function(){this._mappings&&this._mappings.forEach((t=>t.dispose())),delete this._mappings},ondropfile:function(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[r],fitPattern:!0})},transcoordS2P:function(t,e,r){if(!this.parent)return{x:t,y:e};let{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate;let a=Y9(t,e,void 0,n+this._delta.theta,i);return r&&(a.x+=r.x,a.y+=r.y),a}r=r||this.rotatePoint;const{theta:a=0,tx:s=0,ty:o=0,sx:l=1,sy:h=1}=this._delta||{};r={x:r.x+s,y:r.y+o},i={x:i.x*l,y:i.y*h};const c=Y9(t+s,e+o,r,n+a,i);return{x:c.x-(r.x*i.x-r.x),y:c.y-(r.y*i.y-r.y)}},transcoordP2S:function(t,e,r){if(!this.parent)return{x:t,y:e};const{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate;let a=G9(t,e,r,n,i);return r&&(a.x-=r.x/i.x,a.y-=r.y/i.y),a}const a=G9(t,e,r=r||this.rotatePoint,n,i);return{x:a.x+(r.x-r.x/i.x),y:a.y+(r.y-r.y/i.y)}},transcoordS2T:function(t,e,r){r=r||this.rootModel;const n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.push(t);let i=this.transcoordS2P(t,e);return n.forEach((t=>{const{scale:e}=t.model,r=t.bounds;if(e){const n=t.rotatePoint;i.x+=(n.x-r.left)*e.x,i.y+=(n.y-r.top)*e.y}else i.x+=r.left,i.y+=r.top;i=t.transcoordS2P(i.x,i.y)})),i},transcoordT2P:function(t,e,r){r=r||this.rootModel;const n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.splice(0,0,t);let i={x:t,y:e};return n.forEach((t=>{const{scale:e}=t.model;i=t.transcoordP2S(i.x,i.y);const r=t.bounds;if(e){const n=t.rotatePoint;i.x-=(n.x-r.left)/e.x,i.y-=(n.y-r.top)/e.y}else i.x-=r.left,i.y-=r.top})),i},transcoordT2S:function(t,e,r){const n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)},transcoordS2TR:function(t,e,r){r=r||this.rootModel;const n=this.transcoordS2T(t,e,r);return Y9(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)},transcoordS2O:function(t,e,r){const n=this.rootModel,i=this.transcoordS2T(t,e,n);return r.transcoordT2S(i.x,i.y,n)},transcoordC2S:function(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;const{translate:n={x:0,y:0},scale:i={x:1,y:1},rotation:a=0}=r.model;let s=G9(t,e,n,a,i);return n&&(s.x-=n.x/i.x,s.y-=n.y/i.y),r===this?s:this.transcoordT2S(s.x,s.y,r)},transcoordS2C:function(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;let n;n=r!==this?this.transcoordS2T(t,e,r):{x:t,y:e};const{translate:i={x:0,y:0},rotation:a=0,scale:s={x:1,y:1}}=r.model;return n=Y9(n.x,n.y,void 0,a+r._delta.theta,s),i&&(n.x+=i.x,n.y+=i.y),n}}),["rotatePoint","font","lineHeight","retention"].forEach((t=>mtt.memoize(mtt.prototype,t,!1))),["bounds","center","textBounds"].forEach((t=>mtt.memoize(mtt.prototype,t,!0))),mtt.mixin(mtt.prototype,F7.withEvent);class ytt extends mtt{set rotationX(t){this.setState("rotationX",t)}get rotationX(){return this.getState("rotationX")}set rotationY(t){this.setState("rotationY",t)}get rotationY(){return this.getState("rotationY")}set rotationZ(t){this.setState("rotation",t)}get rotationZ(){return this.getState("rotation")}set zPos(t){this.setState("zPos",t)}get zPos(){return this.getState("zPos")}set depth(t){this.setState("depth",t)}get depth(){return this.getState("depth")}postrender(t){this.drawFill(t),this.drawStroke(t),super.postrender(t)}render(t){var e=this.drawPath,{round:r=0}=this.state;if(!(e.length<=1)){t.beginPath();for(var n=0;n<e.length;n++){const l=e[(n-1+e.length)%e.length],h=e[(n+e.length)%e.length],c=e[(n+1)%e.length];if(l.x===h.x&&l.y===h.y)continue;var i=0!==(o=Math.sqrt((l.x-h.x)*(l.x-h.x)+(l.y-h.y)*(l.y-h.y)))?Math.atan2(l.x-h.x,l.y-h.y):0,a=Math.sin(i)*Math.min(r,o/2)+h.x,s=Math.cos(i)*Math.min(r,o/2)+h.y;const u=r>0||0!==o?{x:a,y:s}:h;var o;i=0!==(o=Math.sqrt((c.x-h.x)*(c.x-h.x)+(c.y-h.y)*(c.y-h.y)))?Math.atan2(c.x-h.x,c.y-h.y):0,a=Math.sin(i)*Math.min(r,o/2)+h.x,s=Math.cos(i)*Math.min(r,o/2)+h.y;const d=r>0||0!==o?{x:a,y:s}:h;0==n?t.moveTo(u.x,u.y):t.lineTo(u.x,u.y),r>0&&t.quadraticCurveTo(h.x,h.y,d.x,d.y)}t.closePath()}}}function btt(t,e,r){return Math.max(0,Math.min(t,Math.min(r,e)/2))}var wtt=t=>{var e=class extends t{contains(t,e){var{left:r,top:n,width:i,height:a,lineWidth:s=0}=this.state,o=s/2;return t<Math.max(r+i,r)+o&&t>Math.min(r+i,r)-o&&e<Math.max(n+a,n)+o&&e>Math.min(n+a,n)-o}set path(t){var e=t[0],r=t[2];this.set({left:e.x,top:e.y,width:r.x-e.x,height:r.y-e.y})}get path(){var{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return[{x:t,y:e},{x:t+r,y:e},{x:t+r,y:e+n},{x:t,y:e+n}]}get anchors(){return function(t){var{left:e,top:r,width:n,height:i}=t.bounds,a=e+n/2,s=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:s}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:s}}]}(this)}get bounds(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return{left:t,top:e,width:r,height:n}}set bounds(t){this.set({left:0,top:0,width:0,height:0,...t})}render(t){var{round:e=0}=this.model,{left:r,top:n,width:i,height:a}=this.bounds;t.translate(r,n),t.beginPath(),(e=btt(e,i,a))>0?t.roundRect(0,0,i,a,e):t.rect(0,0,i,a),t.translate(-r,-n)}};return Y7(e.prototype,"path",!1),e};const xtt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"textarea",label:"front-side-template",name:"frontSideTemplate",property:{language:"html"}},{type:"textarea",label:"back-side-template",name:"backSideTemplate",property:{language:"html"}},{type:"textarea",label:"style",name:"style",property:{language:"css"}}],help:"scene/component/info-window"};const Att=20;function _tt(t,e){var r=t.split(/\s+/),n=r.indexOf(e);return-1!=n?r.splice(n,1):r.splice(-1,0,e),r.join(" ")}class ktt extends(wtt(ytt)){static get image(){return ktt._image||(ktt._image=new Image,ktt._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAY1BMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADIAbxiAAAAIHRSTlMA+gPshCwwWFzYCeLRm7QRG6rLeDZI9JOJJDtjb1HAf1sAT80AAAQQSURBVHhe7MCBAAAAAMKw/KkzOMG2BAAAAKeu3lUohIEggO7jQi5qHqpgwML5/6+0F0y02z31FlvMMLKt86QMQ1ined2Evih1hFFjLfRWjgzDOGZ6JSiM00B9EuHALtQxJLiQBmqSBCeSUEuEGzs1BDjSaHxWOKK5Eyz/4SoMV/hp4+vtcPkdwZD/udwevNg7t1xXYRiKmkB7C+ENlPLq8fxHeX+RGjWQ1D45ldcIulBIvCvYJGBEadyTzxAcfY57NBjpLScOO/bzugcTHe7IMwiSLMcdHZhocMcMgTLjjgZM7F1bCJZ2v27ARGzYDwIk2Z+JYGJ/iiwQLMv+JAEThjkmRG64Q0Q+gIiIiIiIiIiIyFy0KRFt0bOJZAWSUigmkQaJaXhENiRnYBEpkZySRSRGcmIWEaQnYhHRSI5mESmQnIJFZIqQmGhiEYEbEnPjGlEGjYTogW/WUkOXENENSqZfEXmDiIiIiIiIiIiIiIiIiIiImq5ETIpRpBpjJCMeKy6Ri0ZS9MQjkmkkJs1YRDokp2MRyZGclkUkQnIiEQltaX3Lzb6yiGTpl2y/avqSAxGgelCOKI+Kc2isL0TUSsZ4EREREREREREREREREREREfnIQzXrNWSRTeNxnlOwIgueIr6AAyE+CpiqMEUK71IDO4E+LluEKYKnKcMUifEsTZgiJZ5lDVNkwJPcqzBFoPF/HplfxL/w6b4EPGv1h18Weya1TL8iIiIeiIiIiIiIiEjkPefxV+5YA9PPHylB+u5aqgZ39H+jKOxrqtu+pkzvr9YbzoZ6w2OFkzcrA3yE4WZlSSyFk54VoA/wR43+FaD+r9w32QdWvgvjp2ty2xq8qHPHmtyPFxfrK3hw1ejERlAlfR/Ame2OTow05d4rOLLSlHtDVhI0uRO01JeZ405op6zgNNXT+bIRfpIgn+AkU4pOxBscohojdCHu4RRzjC5EYwVHqRONDkSnEvK/CB3QSU32IRW3ZPnj9iEVoGCNTLVrh8ia1x+6wq8xvB5mz8pxu7oPwIn9lcR0AiuX1+1KX+BXqdvXzWsAC0NsGjzZsS/2Bd6yRA5RgIHkXNhSD3whASZ8rrB9mItuEAizac0fDlHxDMEwpQfD1tW4y3Hjfy5s9nOHH3uwWA+EqEJBWCjoTL/S5toBB/7hu6zer74NgqSP39zJU+qQX3ix763mHTqvIVRUVprCljlElRkEjBqNYevH8veBJ2xhiyhE8YctmhDFH7ZoQhR/2KIJUfxhiyRE8YctmhDFH7ZoQhR/2OIJUfxhC9Ppf/t1jgJACERRsHGyYRZB0Ujvf0xD8w6kP7y6RZmgf/oTFTtbbzJVxZWo2Nlqw6TVy5GowNl6ssm7v50obamfSxQAAAAAAAsKLM15fb3vpQAAAABJRU5ErkJggg=="),ktt._image}static toggle(t,e,r,n){if(e){var i=t.root.findById(e);i?i._findInfoWindowByComponent(t)?ktt.hide(t,e):ktt.show(t,e,r,n):console.warn("InfoWindow Not Found.",e)}else console.warn("InfoWindow not defined.")}static hide(t,e){if(e){var r=t.root.findById(e);r?r._removeInfoWindow(t):console.warn("InfoWindow Not Found.",e)}}static show(t,e,r,n){if(e){var i=t.root.findById(e);if(i){if(!i._findInfoWindowByComponent(t)){var{frontSideTemplate:a="",backSideTemplate:s=""}=i.model,o=[a,s].filter((t=>String(t).trim()));if(o=o.map((t=>mtt.template(function(t,e,r){return(e||r?['<div class="info-window-btns">',e?'<button class="closable">&#88</button>':"",r?'<button class="flipable">&#8652</button>':"","</div>"]:[]).concat(['<div class="info-window-content">',t,"</div>"]).join("")}(t,!r,2==o.length)))),0!=o.length){var l='\n.flip {\n backface-visibility: hidden;\n border-radius: 7px;\n height: auto;\n font: normal 14px helvetica, arial, san serif;\n position: absolute;\n opacity: 0.9;\n transform-origin: 50% 50% 0px;\n transition: all 2s;\n min-width: 100px;\n min-height: 50px;\n background-color: #3e424e;\n box-shadow: 2px 3px 2px 0px rgba(0,0,0,0.15);\n}\n\n#side-1 {\n transform: rotateY(0deg);\n}\n\n.flip:after {\n content: "";\n display: block;\n position: absolute;\n opacity: 0.9;\n width: 0;\n height: 0;\n}\n\n.flip.arrow-top:after {\n left: 45%;\n top: -17px;\n border-left: 10px solid transparent;\n border-bottom: 18px solid #323b44;\n border-right: 10px solid transparent;\n}\n\n.flip.arrow-right:after {\n left: 100%;\n top: 48%;\n border-top: 10px solid transparent;\n border-left: 18px solid #323b44;\n border-bottom: 10px solid transparent;\n}\n\n.flip.arrow-bottom:after {\n left: 45%;\n top: 100%;\n border-left: 10px solid transparent;\n border-top: 18px solid #323b44;\n border-right: 10px solid transparent;\n}\n\n.flip.arrow-left:after {\n right: 100%;\n top: 48%;\n border-top: 10px solid transparent;\n border-right: 18px solid #323b44;\n border-bottom: 10px solid transparent;\n}\n\n#side-2 {\n transform: rotateY(180deg);\n}\n\n.flip-side-1 {\n transform: rotateY(0deg) !important;\n}\n\n.flip-side-2 {\n transform: rotateY(180deg) !important;\n}\n\n.info-window-btns {\n position: absolute;\n top: -18px;\n right: 5px;\n overflow: hidden;\n}\n\n.info-window-content {\n padding: 10px;\n color: #efefef;\n font-size: 13px;\n line-height: 1.4;\n}\n\n.info-window-btns button {\n width: 40px;\n height: 40px;\n float: right;\n border: 0;\n border-radius: 50%;\n background-color: #2a7da1;\n margin-right: 3px;\n text-align: center;\n cursor: pointer;\n font-size: 35px;\n color: #fff;\n line-height: 0;\n}\n\n.info-window-btns button:hover {\n background-color: #60bb23;\n}\n'+i.get("style"),{left:h,top:c}=t.bounds,{x:u,y:d}=n?t.rootModel.transcoordC2S(n.x,n.y):t.transcoordS2T(h,c);h=u,c=d;var p=document.createElement("span");p.style.position="absolute";var f=document.createElement("style");if(f.type="text/css",f.appendChild(document.createTextNode(l)),p.appendChild(f),o[0]){var g=document.createElement("div");g.id="side-1",g.className="flip",g.style.display="inline-block",g.innerHTML=o[0](t)}if(o[1]){var v=document.createElement("div");v.id="side-2",v.className="flip",v.style.display="inline-block",v.innerHTML=o[1](t)}r9.forEach((function(t){p.addEventListener(t,(function(t){t.stopPropagation()}))})),n9.forEach((function(t){p.addEventListener(t,(function(t){t.stopPropagation()}))}));var m=t.root.model_layer.overlay;if(g&&p.appendChild(g),v&&p.appendChild(v),m.appendChild(p),i._addInfoWindow(t,p,f),g){let r=g.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=_tt(v.className,"flip-side-1"),g.className=_tt(g.className,"flip-side-2")}),!1);let n=g.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),ktt.hide(t,e)}),!1)}if(v){let r=v.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=_tt(v.className,"flip-side-1"),g.className=_tt(g.className,"flip-side-2")}),!1);let n=v.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),ktt.hide(t,e)}),!1)}var y=g.offsetWidth,b=g.offsetHeight;window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;var w=t.rootModel.target.getBoundingClientRect(),x=[];g&&x.push(g),v&&x.push(v);var A={x:h,y:c},_=t.transcoordS2C(A.x,A.y);if(_.x+y/2+w.left<w.right&&_.x-y/2>w.left){if(b+Att<_.y)return p.style.marginLeft=A.x-y/2+"px",p.style.marginTop=A.y-b-Att+"px",void x.forEach((t=>t.className+=" arrow-bottom"));if(_=t.transcoordS2C(A.x,A.y+b+Att),w.bottom>_.y+w.top)return p.style.marginLeft=A.x-y/2+"px",p.style.marginTop=A.y+Att+"px",void x.forEach((t=>t.className+=" arrow-top"))}if((_=t.transcoordS2C(A.x,A.y)).x-(y+Att)>w.left)return p.style.marginLeft=A.x-y-Att+"px",p.style.marginTop=A.y-b/2+"px",void x.forEach((t=>t.className+=" arrow-right"));p.style.marginLeft=A.x+Att+"px",p.style.marginTop=A.y-b/2+"px",x.forEach((t=>t.className+=" arrow-left"))}}}else console.warn("InfoWindow Not Found.",e)}else console.warn("InfoWindow not defined.")}dispose(){this.infoWindows.map((t=>t.component)).forEach((t=>this._removeInfoWindow(t))),super.dispose()}get infoWindows(){return this._windows||(this._windows=[]),this._windows}_findInfoWindowByComponent(t){return this.infoWindows.find((e=>e.component===t))}_addInfoWindow(t,e,r){this._findInfoWindowByComponent(t)||this._windows.push({component:t,window:e,styleElement:r})}_removeInfoWindow(t){var e=this._findInfoWindowByComponent(t);if(!e)return;let r=e.window;r&&r.parentNode.removeChild(r);var n=this.infoWindows.lastIndexOf(e);this.infoWindows.splice(n,1)}render(t){var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),this.drawImage(t,ktt.image,e,r,n,i)}get hasTextProperty(){return!1}get nature(){return xtt}}mtt.register("info-window",ktt);var Stt={};var Ett={list:function(){return{...Stt}},register:function(t,e){Stt[t]=e},unregister:function(t){delete Stt[t]},get:function(t){if(t){var e=Stt[t];return e||U7("Layout Not Found - ",t),e}}},Mtt={reflow:function(t,e){this.drawables(t).filter((t=>t.isHTMLElement())).forEach((t=>t.reposition()))},capturables:function(t){return t.components},drawables:function(t){return t.app&&!t.app.isViewMode?t.components:t.components.filter((t=>!t.hidden))},isStuck:function(t){return!1},ABSOLUTE:!0};Ett.register("html-absolute",Mtt);const Ttt=["run","goto","goto-playlist","link-open","link-move","route-page","start-scenario","run-scenario","export-data","import-data"],Ctt="auto";const Ptt=new WeakMap;function Itt(t){const e=t.root,r=Ptt.get(e);if(!r)return;if(e===t)return r.forEach((t=>Itt(t[0]))),void Ptt.delete(e);const n=r.findIndex((e=>e[0]===t));if(-1===n)return;const i=r[n][1];i.div.parentNode?.removeChild(i.div),i.scene.target=null,i.scene.release?.(),r.splice(n,1)}class Rtt{static hideAll(t){(Ptt.get(t)||[]).forEach((([t])=>Itt(t)))}static hide(t){const e=t.root,r=Ptt.get(e);if(!r)return;const n=r.findIndex((e=>e[0]===t));if(-1===n)return;const i=r[n][1];i.div.style.backgroundColor="transparent",function(t,e){t.style.opacity=1,t.style.transform="scale(1)";let r=+new Date;const n=()=>{const i=Math.min((new Date-r)/200,1);t.style.opacity=1-i,t.style.transform=`scale(${1-i})`,i<1?requestAnimationFrame(n):(t.style.display="none",e&&e())};n()}(i.div,(()=>{Itt(t)}))}static show(t,e,r={}){const{data:n,modal:i=!1,closable:a=!0,minimizable:s=!1,draggable:o=!1,output:l=!0,title:h=""}=r,c=t.app.refProvider;c?.get(e,!0).then((e=>{const c=document.createElement("div"),u=c.style;if(c.setAttribute("popup",""),i){const{width:e,height:r}=t.rootModel.bounds;Object.assign(u,{position:"fixed",zIndex:1,left:0,top:0,width:`${e}px`,height:`${r}px`,overflow:"hidden",backgroundColor:"transparent"})}else Object.assign(u,{position:"absolute",display:"inline-block",overflow:"hidden"});c.innerHTML=h?'\n<div class="popup-wrap">\n <div class="popup-title-bar">\n <div class="popup-title"></div>\n <button class="draggable-1945">&#x2630;</button>\n <button class="minimizable-1945">&#8211;</button>\n <button class="closable-1945">&#88</button>\n </div>\n <div class="popup-content"></div>\n</div>\n':'\n<div class="popup-content">\n <button class="draggable-1945">&#x2630;</button>\n <button class="minimizable-1945">&#8211;</button>\n <button class="closable-1945">&#88</button>\n</div>\n';const d=c.querySelector(".popup-content"),{width:p,height:f}=e.root.model;Object.assign(d.style,{width:`${p}px`,height:`${f}px`});const g=document.createElement("style");g.type="text/css",g.appendChild(document.createTextNode("\n.popup-title-bar {\n display: flex;\n align-items: center;\n top: 0;\n left: 0;\n width: 100%;\n height: 30px;\n background-color: var(--md-sys-color-primary, #f1f1f1);\n color: var(--md-sys-color-on-primary, black);\n padding: 5px;\n box-sizing: border-box;\n border-bottom: 1px solid #ccc;\n}\n\n.popup-title {\n flex: 1;\n text-align: center;\n}\n\nbutton.closable-1945, button.minimizable-1945, button.draggable-1945 {\n position: absolute;\n display: none;\n color: white; \n background-color: black; \n opacity: .3;\n width: 20px;\n height: 20px;\n top: 5px; \n z-index: 1;\n padding: 0;\n margin: 0;\n border: 0px;\n text-align: center;\n cursor: pointer;\n font-size: 12px;\n border-radius: 4px;\n}\n\nbutton.draggable-1945 {\n left: 5px;\n cursor: move;\n}\n\nbutton.minimizable-1945 {\n right: 30px;\n}\n\nbutton.closable-1945 {\n right: 5px;\n}\n\nbutton.closable-1945:hover, button.minimizable-1945:hover, button.draggable-1945:hover {\n opacity: .6; \n}\n")),c.appendChild(g),Ttt.forEach((r=>{e.on(r,((...e)=>{t.trigger(r,...e)}))}));const v=c.querySelector(".popup-content"),m=c.querySelector(".draggable-1945");[...r9,...n9].forEach((t=>{v.addEventListener(t,(e=>{(!m?.isDragging||"mousemove"!==t&&"mouseup"!==t)&&e.stopPropagation()}))})),[...r9,...n9].forEach((t=>{c.addEventListener(t,(e=>{(!m?.isDragging||"mousemove"!==t&&"mouseup"!==t)&&e.stopPropagation()}))})),i&&a&&c.addEventListener("click",(e=>{e.target===c&&Rtt.hide(t)}));if(t.root.model_layer.overlay.appendChild(c),function(t,e,r){const n=t.root;if(n===t)return;Itt(t);let i=Ptt.get(n)||[];i=[...i,[t,{div:e,scene:r}]],Ptt.set(n,i)}(t,c,e),h){c.querySelector(".popup-title-bar .popup-title").textContent=h}if(o&&(!function(t,e,r){let n,i,a,s;function o(o){if(!e.isDragging)return;o.preventDefault(),o.stopPropagation();const l=o.clientX-n,h=o.clientY-i,c=r.rootModel.overlay.style.transform.match(/scale\(([^,]+),\s*([^)]+)\)/),u=c?parseFloat(c[1]):1,d=c?parseFloat(c[2]):u;t.style.left=`${a+l/u}px`,t.style.top=`${s+h/d}px`}function l(t){t.preventDefault(),t.stopPropagation(),e.isDragging=!1,document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",l)}e.isDragging=!1,e.addEventListener("mousedown",(r=>{r.preventDefault(),r.stopPropagation(),e.isDragging=!0,n=r.clientX,i=r.clientY,a=parseInt(t.style.left,10)||0,s=parseInt(t.style.top,10)||0,document.addEventListener("mousemove",o),document.addEventListener("mouseup",l)}))}(i?c.querySelector(".popup-wrap"):c,m,t),h?m&&(m.style.display="block"):(v.addEventListener("mouseenter",(()=>{m&&(m.style.display="block")})),v.addEventListener("mouseleave",(()=>{m&&(m.style.display="none")})))),s){const t=c.querySelector(".minimizable-1945");let e=!1;t.addEventListener("click",(t=>{t.preventDefault(),e=!e;const r=c.querySelector(".popup-wrap");!function(t,e){const r=t.querySelector(".minimizable-1945");e?(r.innerHTML="&#x25A1;",t.style.height="30px",t.style.overflow="hidden"):(r.innerHTML="&#8211;",t.style.height="",t.style.overflow="visible")}(i?r:c,e)})),h?t&&(t.style.display="block"):(v.addEventListener("mouseenter",(()=>{t&&(t.style.display="block")})),v.addEventListener("mouseleave",(()=>{t&&(t.style.display="none")})))}if(a){const t=c.querySelector(".closable-1945");h?t&&(t.style.display="block"):(v.addEventListener("mouseenter",(()=>{t&&(t.style.display="block")})),v.addEventListener("mouseleave",(()=>{t&&(t.style.display="none")})))}c.querySelector(".closable-1945")?.addEventListener("click",(e=>{e.preventDefault(),Rtt.hide(t)})),c.addEventListener("close-scene",(e=>{e.preventDefault(),e.stopPropagation(),Rtt.hide(t),l&&(t.data=e.detail)})),e.target=d,e.data=n||t.data,e.fit("both");const{x:y,y:b}=t.center,w=t.transcoordS2T(y,b,t.rootModel),x=function(t,e,r,n){const{location:i=Ctt,title:a=""}=n||{},s=t.bounds;let o=e.bounds;a&&(o.height+=30);const l=Math.max(s.width/4-o.width/2,20),h=Math.min(3*s.width/4+o.width/2,s.width-20)-o.width,c=Math.max(s.height/4-o.height/2,20)+(a?30:0),u=Math.min(3*s.height/4+o.height/2,s.height-20)-o.height+(a?30:0);switch(i){case Ctt:return{x:r.x<s.width/2?Math.min(h,r.x+20):Math.max(l,r.x-(o.width+20)),y:r.y<s.height/2?Math.min(u,r.y+20+(a?30:0)):Math.max(c,r.y-(o.height+20+(a?30:0)))};case"left-top":return{x:l,y:c};case"right-top":return{x:h,y:c};case"left-bottom":return{x:l,y:u};case"right-bottom":return{x:h,y:u};default:return{x:(s.width-o.width)/2,y:(s.height-o.height+(a?30:0))/2}}}(t.rootModel,e.root,w,r);if(i)if(h){const t=c.querySelector(".popup-wrap");Object.assign(t.style,{position:"absolute",left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${f}px`})}else Object.assign(d.style,{left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${f}px`});else Object.assign(c.style,{left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${h?f+30:f}px`});!function(t,e){t.style.opacity=0,t.style.transform="scale(0)",t.style.display="block";let r=+new Date;const n=()=>{const i=Math.min((new Date-r)/200,1);t.style.opacity=i,t.style.transform=`scale(${i})`,i<1?requestAnimationFrame(n):e&&e()};n()}(c,(()=>{i&&(c.style.backgroundColor="rgba(0,0,0,0.3)")}))}),(t=>{console.error("cannot fetch board: "+e,t)}))}}var Ott={reflow:function(t,e){},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!1},ABSOLUTE:!0};function Ltt(t){var e=t.components.filter((t=>!t.hidden)),r=t.getState("layoutConfig")||{},n=e[r&&r.activeIndex||0];return n&&[n]||[]}Ett.register("absolute",Ott);var Dtt={reflow:function(t){var e=t.bounds,r=t.getState("layoutConfig")||{},n={left:0,top:0,width:e.width,height:e.height};t.forEach(((t,e)=>{let i=e!=(r.activeIndex||0);t.bounds=n,t.setState("rotation",0),t.element&&(t.element.style.visibility=i?"hidden":"visible")}))},capturables:function(t){return Ltt(t)},drawables:function(t){return Ltt(t)},isStuck:function(t){return!0}};function Ftt(t){var e=t.getState("layoutConfig");return e&&e.weight||1}Ett.register("card",Dtt);var Ntt={reflow:function(t){var e=this.drawables(t),r=t.get("padding")||{},n=e.reduce(((t,e)=>t+Ftt(e)),0),i=t.bounds,a=n>0?(i.width-((r.left||0)+(r.right||0)))/n:i.width,s=i.height-((r.top||0)+(r.bottom||0)),o=0;e.forEach((t=>{let e=Ftt(t),n=t.get("margin")||{};t.bounds={left:a*o+(r.left||0)+(n.left||0),top:0+(r.top||0)+(n.top||0),width:e*a-((n.left||0)+(n.right||0)),height:s-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),o+=e}))},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!0}};function jtt(t){var e=t.getState("layoutConfig");return e&&e.weight||1}Ett.register("linear-horizontal",Ntt);var Btt={reflow:function(t){var e=this.drawables(t),r=t.getState("padding")||{},n=e.reduce(((t,e)=>t+jtt(e)),0),i=t.bounds,a=n>0?(i.height-((r.top||0)+(r.bottom||0)))/n:i.height,s=i.width-((r.left||0)+(r.right||0)),o=0;e.forEach((t=>{let e=jtt(t),n=t.getState("margin")||{};t.bounds={left:0+(r.left||0)+(n.left||0),top:a*o+(r.top||0)+(n.top||0),width:s-((n.left||0)+(n.right||0)),height:e*a-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),o+=e}))},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!0}};Ett.register("linear-vertical",Btt);var ztt={reflow:function(t){var e=t.getState("layoutConfig"),r=e&&e.columns||t.getState("columns"),n=e&&e.rows||t.getState("rows"),i=e&&e.widths||t.getState("widths"),a=e&&e.heights||t.getState("heights"),s=i?i.filter(((t,e)=>e<r)).reduce(((t,e)=>t+e),0):r,o=a?a.filter(((t,e)=>e<n)).reduce(((t,e)=>t+e),0):n,l=t.textBounds,h=t.getState("paddingLeft")||0,c=t.getState("paddingTop")||0,u=l.width/s,d=l.height/o,p=0,f=0;t.components.forEach(((t,e)=>{let n=i?i[e%r]:1,s=a?a[Math.floor(e/r)]:1,o=t.colspan||1,l=0;for(;--o>0;)l+=i?i[(e+o)%r]:1;let g=t.rowspan||1,v=0;for(;--g>0;)v+=a?a[Math.floor(e/r)+g]:1;t.bounds={left:h+p,top:c+f,width:u*(n+l),height:d*(s+v)},t.setState("rotation",0),e%r==r-1?(p=0,f+=s*d):p+=n*u}))},capturables:function(t){return t.components.filter((t=>!t.merged))},drawables:function(t){return t.components.filter((t=>!t.merged&&!t.hidden))},isStuck:function(t){return!0},keyNavigate:function(t,e,r){var n=t.getState("layoutConfig"),i=n&&n.columns||t.getState("columns"),a=n&&n.rows||t.getState("rows"),{row:s,column:o}=t.getRowColumn(e);switch(r.code){case"ArrowUp":if(s>0)return t.getAt((s-1)*i+o);break;case"ArrowDown":if(s<a-1)return t.getAt((s+1)*i+o);break;case"ArrowRight":if(o<i-1)return t.getAt(s*i+o+1);break;case"ArrowLeft":if(o>0)return t.getAt(s*i+o-1);break;default:return e}},joinType:!0};Ett.register("table",ztt);const Wtt=new Image;Wtt.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAclBMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0BbqFAAAAJXRSTlMAgAP3VSI6/g9fBk5FavJsMrariSjzPnO1enRRL5SMhmOOWB9keFTE0wAAANxJREFUOMutk9kWgyAMRLFuiLjUtdp9yf//YglVsQXz1HniMPcEMgHGvpX2O0Ypi+EgCL+IAShC+wB7QfubRDT7AFcnUPoLMLiP4PyJbsb55i05AgnR5iaQDsICgtH0cotBWoAP1c7kC6kFxEseCfZfB6gEgbNeBrira2QmH1uVYCXlA3is8UmgUCPIyQJKEmu8QtQJN0e9DPXVpzG2G216c1CqRmcBOdxXk07sWUSPv07zo0amCNQycv+NzmR6cRcwmfbuI7p2nZ/z4be0P83Foz6vIkhfZXr82XgDlZsspIq4peUAAAAASUVORK5CYII=";var Utt=t=>class extends t{postrender(t){super.postrender(t),this.app.isEditMode&&this._focused&&this.showMoveHandle&&this._draw_move_handle(t)}_draw_move_handle(t){var{left:e,top:r,width:n}=this.bounds;t.save(),t.beginPath(),t.globalAlpha=1,t.rect(e+n,r,25,25);t.fillStyle="rgba(235, 235, 235, 1)",t.fill(),t.drawImage(Wtt,e+n+3.75,r+3.75,17.5,17.5),t.closePath(),t.restore()}contains(t,e){var r=super.contains(t,e);if(this.app.isViewMode)return r;if(!r){var{left:n,top:i,width:a,height:s}=this.bounds,o=n+a;this.showMoveHandle&&(r=t<Math.max(o+25,o)&&t>Math.min(o+25,o)&&e<Math.max(i+25,i)&&e>Math.min(i+25,i))}return this._focustd!==r&&(this._focused=r,this.invalidate()),r}};const Htt=[];class Gtt extends(Utt(wtt(mtt))){constructor(t,e){super(t,e),this._components=[]}replaceRefids(t){this.components.forEach((e=>e.replaceRefids(t)))}get showMoveHandle(){return!0}get showOverflow(){return!1}dispose(){this.components.slice().forEach((t=>t.dispose())),super.dispose()}isContainer(){return!0}containable(t){return t.isDescendible(this)}get hasTextProperty(){return!1}get components(){return this._components}get focusible(){return!0}get layout(){return Ett.get(this.get("layout"))||Ott}reflow(){this.layout.reflow(this),this.components&&this.components.forEach((t=>{t.isContainer()&&t.reflow()}))}get hierarchy(){var t=super.hierarchy;return this.components&&(t.components=this.components.map((t=>t.hierarchy))),t}addComponent(t,e=!1){var r=t.parent;if(r){if(this===r)return;r.removeComponent(t,e)}var n=this._components.push(t)-1;t.parent=this,t.added(this),e||this.trigger("add",this,t,n),t.delegate_on(this),e||t.trigger("added",this,t,n),this.root&&this.root.isReady&&t.ready()}removeComponent(t,e=!1){var r=this._components.indexOf(t);-1!=r&&(this._components.splice(r,1),t.parent=null,t.removed(this),e||(this.trigger("remove",this,t),t.trigger("removed",this,t)),t.delegate_off(this))}insertComponentAt(t,e,r=!1){var n=t.parent;n&&n.removeComponent(t,r);var i=this._components.splice(0,e);this._components=i.concat(t,this._components),e=this._components.indexOf(t),t.parent=this,t.added(this),r||this.trigger("add",this,t,e),t.delegate_on(this),r||t.trigger("added",this,t,e)}add(t,e=!1){return t instanceof Array?(t.forEach((t=>{-1==this._components.indexOf(t)&&this.addComponent(t,e)})),this):this.add.call(this,[t],e)}remove(t,e=!1){return t instanceof Array?this._components?(t.forEach((t=>{this.removeComponent(t,e)})),this):this:this.remove.call(this,[t],e)}getAt(t){if(this._components)return this._components[t]}forEach(t,e){this._components&&this._components.forEach(t,e)}traverse(t,e){t.call(e,this),this._components&&this._components.forEach((r=>{r.isContainer()?r.traverse(t,e):t.call(e,r)}))}indexOf(t){return(this._components||Htt).indexOf(t)}size(){return(this._components||Htt).length}moveChildAt(t,e){var r=this.indexOf(e);if(-1!=r){var n=this._components.splice(0,r),i=this._components.splice(1);this._components=n.concat(i),t=Math.max(0,t),t=Math.min(t,this._components.length),n=this._components.splice(0,t),this._components=n.concat(e,this._components)}}moveChildForward(t){var e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this._components[e]=this._components[e+1],this._components[e+1]=t)}moveChildBackward(t){var e=this.indexOf(t);-1!=e&&0!=e&&(this._components[e]=this._components[e-1],this._components[e-1]=t)}moveChildToFront(t){var e=this.indexOf(t);if(-1!=e&&e!=this.size()-1){var r=this._components.splice(0,e),n=this._components.splice(1);this._components=r.concat(n,this._components)}}moveChildToBack(t){var e=this.indexOf(t);if(-1!=e&&0!=e){var r=this._components.splice(0,e),n=this._components.splice(0);this._components=this._components.concat(r,n)}}symmetryX(t){super.symmetryX(t),this.components.map((t=>{t.symmetryX(0)}))}findAll(t,...e){if("string"==typeof t)return p9(t,this,e[0]||this);if("function"==typeof t){var r=[];for(let n=this.components.length-1;n>=0;n--){let i=this.components[n].findAll(t,...e);i&&(r=r.concat(i))}return t(this,...e)&&r.push(this),r}}findFirst(t,...e){if("string"==typeof t)return p9(t,this,e[0])[0];if("function"==typeof t){for(let n=this.components.length-1;n>=0;n--){var r=this.components[n].findFirst(t,...e);if(null!=r)return r}return t(this,...e)?this:null}}findById(t){return this.root.findById(t)}findByRefid(t){return this.root.findByRefid(t)}contains(t,e){var r=super.contains(t,e);if(!r){var{left:n,top:i,width:a,height:s}=this.state;r=t<Math.max(n+a,n)&&t>Math.min(n+a,n)&&e<Math.max(i+s,i)&&e>Math.min(i+s,i)}return r}capture(t,e,r){var n=this.transcoordP2S(t,e);if(!this.contains(n.x,n.y))return!1;var i=this.bounds;n.x-=i.left,n.y-=i.top;var a=this.layout.capturables(this);for(let t=a.length-1;t>=0;t--){var s=a[t].capture(n.x,n.y,r);if(s)return s}return this.capturable&&!r?.(this)&&this}capturePath(t,e){if(e){if(e.indexOf(this)>-1)return!1;for(let t=0;t<e.length;t++)if(!this.containable(e[t]))return!1}var r=[],{left:n,top:i,width:a,height:s}=this.bounds;for(let e=0;e<t.length;e++){let o=this.transcoordP2S(t[e].x,t[e].y);if(o.x<n||o.x>n+a||o.y<i||o.y>i+s)return!1;o.x-=n,o.y-=i,r.push(o)}let o=this.layout.capturables(this);for(let t=o.length-1;t>=0;t--){let n=o[t];if(!n.isContainer())continue;let i=n.capturePath(r,e);if(i)return i}return this.focusible&&this}render(t){var{left:e=0,top:r=0,width:n,height:i}=this.bounds;t.beginPath(),t.rect(e,r,n,i),t.closePath(),this.drawFill(t),this.drawStroke(t)}postrender(t){const e=this.layout.drawables(this);if(e.length>0){var{left:r=0,top:n=0,width:i,height:a}=this.bounds;t.save(),this.showOverflow||(t.beginPath(),t.rect(r,n,i,a),t.clip(),t.closePath());var{top:n,left:r}=this.state;t.translate(r,n),e.forEach((e=>{e.draw(t)})),t.translate(-r,-n),t.restore()}super.postrender(t)}trim(){this.components.forEach((t=>{t.trim()})),super.trim()}}["layout"].forEach((t=>mtt.memoize(Gtt.prototype,t,!1)));class Ytt extends Gtt{constructor(t,e){super(t,e),t.translate=t.translate||{x:0,y:0},this._draw_reserved=!1,this.__draw__=()=>{this._draw_reserved=!1,this.trigger("redraw"),this.reflow(),this.draw()},this.throttle_render=()=>{this._draw_reserved||requestAnimationFrame(this.__draw__),this._draw_reserved=!0}}fitSize(t,e,r,n){if(this.target){if(e){let t=getComputedStyle(this.target);r=r||(t?parseFloat(t.getPropertyValue("width")):this.target.clientWidth),n=n||(t?parseFloat(t.getPropertyValue("height")):this.target.clientHeight)}else r=this.model.width,n=this.model.height;"CANVAS"==t.tagName&&(t.setAttribute("width",r*e9),t.setAttribute("height",n*e9)),t.style.width=r+"px",t.style.height=n+"px"}}resize(){this.fitSize(this.element,!0)}isLayer(){return!0}get showOverflow(){return this.app.isEditMode}get anchors(){}createElement(){var t=mtt.createCanvas(1,1);return t.setAttribute("scene",this.state.type),t.style.position="absolute",t}get target(){return this._target}set target(t){this._target&&this.element&&this._target.removeChild(this.element),this._target=t,t&&(this.element||(this.element=this.createElement()),this.resize(),t.appendChild(this.element))}get canvas(){return this.element}dispose(){super.dispose(),this.target=null,this.element=null}get selected(){return this.root.selected}set selected(t){this.root.selected=t}get hasSameParentForAllSelected(){return this.root.hasSameParentForAllSelected}get focused(){return this.root.focused}set focused(t){this.root.focused=t}getContext(){return this._context2D||(this._context2D=this.canvas&&this.canvas.getContext("2d")),this._context2D}draw(t){this.canvas&&(t=t||this.getContext())&&super.draw(t)}prerender(t){var{translate:e,scale:r={x:1,y:1},rotation:n}=this.model;t.clearRect(0,0,t.canvas.width,t.canvas.height),e&&t.translate(e.x*e9,e.y*e9),t.scale(r.x*e9,r.y*e9),n&&t.rotate(n)}get rotatePoint(){return{x:0,y:0}}contains(t,e){return!1}invalidate(){this.throttle_render()}move(t){var e=this.get("translate")||{x:0,y:0};this.set({translate:{x:e.x+t.x,y:e.y+t.y}})}centerTo(t,e){const r=t.rootModel.transcoordC2S(this.canvas.clientWidth/2,this.canvas.clientHeight/2),{x:n,y:i}=t.center,{x:a,y:s}=t.transcoordP2S(n,i),{x:o,y:l}=t.transcoordS2T(a,s),{x:h,y:c}=t.rootModel.get("translate"),{x:u,y:d}=t.rootModel.get("scale");e?D8({step:function(e){t.rootModel.set({translate:{x:h+(r.x-o)*u*e,y:c+(r.y-l)*d*e}})},duration:1e3,delta:"circ",ease:"in"}).start():t.rootModel.set({translate:{x:h+(r.x-o)*u,y:c+(r.y-l)*d}})}}const Vtt={x:1,y:1},qtt={x:0,y:0};class Xtt extends Ytt{dispose(){super.dispose(),delete this._canvas,delete this._overlay}contains(t,e){return!0}isRootModel(){return!0}get stuck(){return!0}get layout(){return Mtt}get overlay(){if(!this._overlay){var t=document.createElement("div");t.style.position="absolute",t.style.width=0,t.style.height=0,t.style.overflow="initial",t.style["user-select"]="none",t.style["transform-origin"]="top left",this.element&&this.element.appendChild(t),this._overlay=t,this._repositionOverlay()}return this._overlay}createElement(){var t=document.createElement("div");return t.style.position="absolute",t.setAttribute("scene",this.state.type),t.style["user-select"]="none",t.style.overflow="hidden",this._canvas=mtt.createCanvas(1,1),this._canvas.style.position="absolute",t.appendChild(this._canvas),this._overlay&&t.appendChild(this._overlay),t}resize(){if(this.target){var{width:t,height:e,fitMode:r}=this.model;this.root.fitMode?r=this.root.fitMode:r||(r="ratio");try{var n=getComputedStyle(this.target)}catch(t){return void console.error(t,this.target)}var i=n?parseFloat(n.getPropertyValue("width")):this.target.clientWidth,a=n?parseFloat(n.getPropertyValue("height")):this.target.clientHeight;switch(r){case"both":case"ratio":break;case"width":a=e*i/t;break;case"height":i=t*a/e;break;default:i=Math.max(t,i),a=Math.max(e,a)}switch(this.fitSize(this.canvas,!0,i,a),r){case"ratio":case"both":break;case"width":this.element.style.overflowX="hidden",this.element.style.overflowY="auto";break;case"height":this.element.style.overflowX="auto",this.element.style.overflowY="hidden";break;default:this.element.style.overflowX=i>t?"hidden":"auto",this.element.style.overflowY=a>e?"hidden":"auto"}this.fitSize(this.element,!0)}}get canvas(){return this._canvas}get MPP(){var{scale:t={x:1,y:1},unit:e}=this.model;switch(e){case"mm":case"cm":return 1/this.app.PPM/t.x;case"in":return 1/this.app.PPI/t.x;default:return 1/t.x}}capturePath(t,e){var r=this.layout.capturables(this);for(let n=r.length-1;n>=0;n--){let i=r[n];if(!i.isContainer())continue;let a=i.capturePath(t,e);if(a)return a}return!1}get eventMap(){return{"(self)":{"(all)":{change:this._onchanged_all,mouseenter:this._onmouseenter_all,mouseleave:this._onmouseleave_all,click:this._onclick,mousedown:this._onmousedownup,mouseup:this._onmousedownup,touchstart:this._onmousedownup,touchend:this._onmousedownup}}}}closeScene(t){requestAnimationFrame((()=>this.overlay.dispatchEvent(new CustomEvent("close-scene",{bubbles:!0,composed:!0,detail:t}))))}_repositionOverlay(){var t=this._overlay;if(t){var{translate:e=qtt,scale:r=Vtt,rotation:n=0}=this.model,{left:i,top:a,width:s,height:o}=this.bounds;t.style.left=i+"px",t.style.top=a+"px",t.style.transform=`rotate(${n}rad) scale(${r.x}, ${r.y}) perspective(1px)`,t.style.marginLeft=`${e.x}px`,t.style.marginTop=`${e.y}px`}}onchange(t){var e=this._model;delete e.id,delete e.text,delete e.class,this._repositionOverlay()}_onchanged_all(t,e,r){this.invalidate()}_onmouseenter_all(t,e){if(t.stopPropagation(),this.app&&!this.app.isEditMode&&e){var r=e.origin;if(!(r instanceof Xtt)&&r.model.event&&r.model.event.hover&&!r.hidden){var n=r.model.event.hover;n&&this._doEventAction(n,r,!0,t)}}}_onmouseleave_all(t,e){if(t.stopPropagation(),e){var r=e.origin;if(this.app&&!this.app.isEditMode){var n=r.model.event&&r.model.event.hover;n&&this._doEventAction(n,r,!1,t)}}}_onclick(t,e){if(t.stopPropagation(),!this.app.isEditMode&&e){var r=e.origin,n=r.model.event?.tap;n&&this._doEventAction(n,r,!0,t)}}_onmousedownup(t,e){if(t.stopPropagation(),!this.app.isEditMode&&e){var r=e.origin,n=r.model.event?.tap;n&&n.pressed&&this._doMouseDownUpEventAction(n,r,"mousedown"==t.type||"touchstart"==t.type,t)}}_doMouseDownUpEventAction(t,e,r,n){var{pressed:i=!1}=t;i&&(r?function(t){if(!t.hasOwnProperty("_backupShadow")){var e=t.get("shadow");t._backupShadow=e;var{left:r=0,top:n=0}=e||{};t.delta("tx",r),t.delta("ty",n),t.set("shadow",{})}}(e):function(t){t.hasOwnProperty("_backupShadow")&&(t.delta("tx",0),t.delta("ty",0),t.set("shadow",t._backupShadow),delete t._backupShadow)}(e))}_doEventAction(t,e,r,n){var{action:i,target:a,value:s,emphasize:o=!1,restore:l=!1,pressed:h=!1,options:c}=t;if(a&&(a=e.access(a)),s&&(s=e.access(s)),o&&(r?function(t){const{hover:e}=t.state.event||{},{emphasize:r}=e||{};if(t.hasOwnProperty("_backupStrokeStyle"))return;if("__backup_emphasize"in t)return;const{strokeStyle:n,lineWidth:i,fillStyle:a}=t.state;t.__backup_emphasize={strokeStyle:n,lineWidth:i,fillStyle:a},t.setState(r)}(e):l&&function(t){"__backup_emphasize"in t&&(t.setState(t.__backup_emphasize),delete t.__backup_emphasize)}(e)),i)switch(i){case"data-toggle":if(!a)return;(r||l)&&this.root.findAll(a,e).forEach((t=>{t.data=!t.data}));break;case"data-tristate":if(!a)return;(r||l)&&this.root.findAll(a,e).forEach((t=>{let e=Math.round(Math.max(Number(t.data)||0,0));t.data=(e+(r?1:2))%3}));break;case"data-spreading":if(!a)return;if(r){var u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.executeMappings(!0)}))}break;case"data-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.data=u}))}break;case"partial-data-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.data={...t.data,...u}}))}break;case"value-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.value=u}))}break;case"partial-value-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.value={...t.value,...u}}))}break;case"infoWindow":case"info-window":if(!a)return;"click"==n.type||r?ktt.show(e,a,l,{x:n.offsetX,y:n.offsetY}):l&&ktt.hide(e,a);break;case"toggle-info-window":if(!a)return;ktt.toggle(e,a,!1,{x:n.offsetX,y:n.offsetY});break;case"popup":case"modal-popup":if(!a)return;let t=c&&"input"in c?c.input:"(self)",o=!c||(!("output"in c)||c.output);Rtt.show(e,a,{data:t&&this.root.findFirst(t,e)?.data,output:o,modal:"modal-popup"===i});break;case"close-scene":this.closeScene(e.data);break;case"goto":case"goto-playlist":this.trigger(i,a,c,e);break;case"mouse-cursor":r?this.target.style.cursor=a||"auto":l&&(this.target.style.cursor="auto");break;default:this.trigger(i,a,s,e)}}}function $tt(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.from.component===r&&(!e||t.from.anchor===e)))}function Ktt(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.to.component===r&&(!e||t.to.anchor===e)))}Xtt.Popup=Rtt,mtt.register("model-layer",Xtt);var Qtt=t=>class extends t{isConnectable(){return!0}postrender(t){super.postrender(t),this._draw_anchors(t)}_draw_anchors(t){var e=this.anchors||[];t.save(),e.forEach((e=>{var{position:{x:r,y:n},draw:i}=e;if(i){t.beginPath();try{i.call(e,t,this)}catch(t){console.error(t)}t.closePath()}})),t.restore()}contains(t,e){if(n=super.contains(t,e))return n;var r=this.anchors||[];for(let i of r){const r=i.bounds;if(!r)continue;const{left:a,top:s,width:o,height:l}=r;var n;if(n=t<Math.max(a+o,a)&&t>Math.min(a+o,a)&&e<Math.max(s+l,s)&&e>Math.min(s+l,s))return n}return!1}findInOutLines(t){return function(t,e){const r=t.state.refid;return t.root.findAll((t=>!(!t.isLine()||(t.from.component!==r||e&&t.from.anchor!==e)&&(t.to.component!==r||e&&t.to.anchor!==e))))}(this,t)}findOutletLines(t){return $tt(this,t)}findOutletEnds(t){return function(t,e){return $tt(t,e).map((t=>t.toEnd?.component)).filter(Boolean)}(this,t)}findInletLines(t){return Ktt(this,t)}findInletEnds(t){return function(t,e){return Ktt(t,e).map((t=>t.fromEnd?.component)).filter(Boolean)}(this,t)}};const Jtt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}}],help:"scene/component/rect"};var Ztt={ondragmove:function(t,e,r){var{left:n,top:i,width:a,height:s}=r.model,o=(r.transcoordP2S(t.x,t.y).x-n)/(a/2)*100;o=btt(o,a,s),r.set({round:o})}};class tet extends(Qtt(wtt(ytt))){is3dish(){return!0}get controls(){var{left:t,top:e,width:r,round:n,height:i}=this.state;return[{x:t+r/2*((n=null==n?0:btt(n,r,i))/100),y:e,handler:Ztt}]}get nature(){return Jtt}}mtt.register("rect",tet);const eet=[1,2,10,20,50,50,50,50,50,50];class ret extends(wtt(ytt)){render(t){const{lineWidth:e=1,fillStyle:r="lightgray",font:n="15px Arial",left:i,top:a,rotation:s,origin:o,margin:l,width:h,height:c,side:u="bottom",strokeStyle:d="#000000",scale:p=1}=this.state;t.translate(i,a),t.beginPath();const f=Math.round(e/2);t.rect(-f,-f,h+2*f,c+2*f),t.clip(),t.beginPath(),t.rect(0,0,h,c),r&&(t.fillStyle=r,t.fill()),t.lineWidth=e,t.strokeStyle=d,t.stroke(),t.beginPath(),t.font=n;var g="bottom"!==u,v=g?0:c,m=4*c/5,y=2*c/3,b=1*c/2,w=3*c/5;g&&(m=c-m,y=c-y,b=c-b,w=c-1.5*c/5);var x=p*this.app.PPM/this.root.unitScale,A=Math.ceil(o/x),_=this.app.PPM/x,k=_<=1.1?1:eet[Math.round(_)]||100;1!=k&&(A+=(k-A%k)%k);var S=Math.ceil(A*x),E=o+h;for(t.fillStyle=d;S<E;){if(A%10==0){t.moveTo(S-o,b),t.lineTo(S-o,v);let e=(A/10).toString(),r=t.measureText(e);t.fillText(e,S-o-r.width-6,w)}else A%5==0?(t.moveTo(S-o,y),t.lineTo(S-o,v)):(t.moveTo(S-o,m),t.lineTo(S-o,v));A+=k,S=Math.ceil(A*x)}}}mtt.register("ruler",ret);const net=20,iet=20,aet=90*Math.PI/180,set="9px Verdana",oet=20,het="#f4f4f4",cet="#999";function uet(t,e,r){return{left:-t.x,top:-t.y,width:net,height:oet}}function det(t,e,r,n){return{left:net-t.x,top:0-t.y,origin:20-t.x,width:e-net,height:oet}}function pet(t,e,r,n){var i={x:0-t.x+10,y:-t.y+iet+(r-iet)/2},a=mtt.transcoordRR(0-t.x,-t.y+iet,i,aet);return{left:a.x-(r-iet),top:a.y,origin:20-t.y,width:r-iet,height:oet}}function fet(t){var e=t.get("translate");return{left:-e.x,top:-e.y,width:t.canvas.width/e9,height:t.canvas.height/e9}}mtt.register("guide-layer",class extends Ytt{constructor(t,e){super(t,e),this.appScale={x:1,y:1},"disabled"!==t.ruler&&(this.hruler=new ret({left:net,top:0,origin:20,margin:0,height:oet,unit:"m",rotation:0,font:set,fillStyle:het,strokeStyle:cet,capturable:!1}),this.vruler=new ret({left:0,top:0,origin:20,margin:0,height:oet,unit:"m",rotation:aet,font:set,side:"top",fillStyle:het,strokeStyle:cet,capturable:!1}),this.origin_rect=new tet({left:-20,top:-20,width:20,height:20,fillStyle:het,strokeStyle:cet,lineWidth:1}),this.addComponent(this.hruler),this.addComponent(this.vruler),this.addComponent(this.origin_rect)),this.invalidate()}get capturable(){return!1}ready(){if(super.ready(),this.hruler){var t=this.rootModel,e=Object.assign({},t.get("translate"));e.x<net&&(e.x+=net),e.y<iet&&(e.y+=iet);var r=t.get("scale")||{x:1,y:1};this.appScale=r,this.hruler.set("scale",r.x),this.vruler.set("scale",r.y),t.set("translate",e),this.set("translate",e),this.screen_coord=fet(this);var{width:n,height:i}=this.screen_coord;this.hruler.set(det(e,n,0,this.hruler)),this.vruler.set(pet(e,0,i,this.vruler)),this.origin_rect.set(uet(e))}else this.screen_coord=fet(this)}resize(){super.resize(),this.screen_coord=fet(this);var{width:t,height:e}=this.screen_coord;this.hruler&&(this.hruler.set(det(this.model.translate,t,0,this.hruler)),this.vruler.set(pet(this.model.translate,0,e,this.vruler)),this.origin_rect.set(uet(this.model.translate)))}render(t){if(this.guide){t.save();var{x:e,y:r}=this.guide,{top:n,left:i,width:a,height:s}=this.screen_coord;t.beginPath(),t.moveTo(e,n),t.lineTo(e,n+s),t.moveTo(i,r),t.lineTo(i+a,r),t.lineWidth=1,t.strokeStyle="tomato",t.setLineDash([2,3]),t.font="10px tahoma",t.fillStyle="#333";var o=this.transcoordS2C(e,r,this.rootModel);t.textBaseline=o.y>200?"bottom":"top",t.textAlign=o.x>200?"right":"left";var l=o.y>200?-5:5,h=o.x>200?-5:5,c=Math.round(e/this.appScale.x),u=Math.round(r/this.appScale.y);t.fillText(` ${c}, ${u} `,e+h,r+l),t.stroke(),t.restore()}}get guide(){return this._guide}set guide(t){this._guide=t,this.invalidate()}contains(t,e){return!0}get eventMap(){return{"(root)":{"(descendant)":{mousemove:this.onmousemove_child,mouseout:this.onmouseout_child,dragmove:this.onmousemove_child},"model-layer":{change:this.onchange_root_model}},"(self)":{"(descendant)":{mousedown:this.onmousedown_origin}}}}onmousedown_origin(t,e){this.rootModel.set("translate",{x:20,y:20})}onchange_root_model(t,e,r){if(t.scale&&(this.appScale=t.scale,this.hruler&&(this.hruler.set("scale",t.scale.x),this.vruler.set("scale",t.scale.y))),t.translate&&this.set({translate:{x:t.translate.x,y:t.translate.y}}),t.scale||t.translate){if(this.screen_coord=fet(this),this.hruler){var{translate:n}=this.model,{width:i,height:a}=this.screen_coord;this.hruler.set(det(n,i,0,this.hruler)),this.vruler.set(pet(n,0,a,this.vruler)),this.origin_rect.set(uet(n))}this._guide=null}this.invalidate()}onmouseout_child(t){this._guide=null,this.invalidate()}onmousemove_child(t,e){t.target&&"CANVAS"!==t.target.tagName?this.guide=null:this.guide=this.transcoordC2S(t.offsetX,t.offsetY)}});mtt.register("shift-layer",class extends Ytt{ready(){super.ready();var t=this.rootModel.get("translate");this.set("translate",t)}render(t){}contains(t,e){return!(2!=this.app.mode)}get eventMap(){return{"(root)":{"(self)":{keydown:this.onkeydown,keyup:this.onkeyup}}}}onkeydown(t){"Space"===t.code&&void 0===this.before_mode&&(this.before_mode=this.app.mode,this.app.mode=2)}onkeyup(t){"Space"===t.code&&(void 0!==this.before_mode&&(this.app.mode=this.before_mode),delete this.before_mode)}ondragstart(t){this.last_position=this.transcoordC2S(t.offsetX,t.offsetY)}ondragmove(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.rootModel.move({x:e-this.last_position.x,y:r-this.last_position.y},!1),this.last_position=this.transcoordC2S(t.offsetX,t.offsetY)}});class get{constructor(t){this.params=Object.assign({},t)}excute(){}}class vet extends get{execute(){this.params.changes.forEach((t=>t.component.set(t.after)))}static before(t){return t.map((t=>({component:t})))}static after(t,e){e.execute(null,!1)}static around(t,e,r){e.call(r),t.execute(null,!1)}}const met="left",yet="right",bet="center",wet="bottom",xet="middle",Aet=[met,yet,bet,"top",xet,wet];function _et(t){if(this.hasSameParentForAllSelected&&-1!=Aet.indexOf(t)){var e=this.selected.filter((t=>!t.stuck));if(!(e.length<=1)){var r=this.app.commander;vet.around(r,(function(){!function(t,e){var r=JSON.parse(JSON.stringify(e[0].bounds)),n=r.left+r.width,i=r.top+r.height;for(let t=0;t<e.length;t++){let a=e[t].bounds;r.left=a.left>r.left?r.left:a.left,r.top=a.top>r.top?r.top:a.top,n=a.left+a.width>n?a.left+a.width:n,i=a.top+a.height>i?a.top+a.height:i}switch(r.width=n-r.left,r.height=i-r.top,t){case met:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:r.left,top:n.top,width:n.width,height:n.height}}break;case bet:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:r.left+r.width/2-n.width/2,top:n.top,width:n.width,height:n.height}}break;case yet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={left:n-r.width,top:r.top,width:r.width,height:r.height}}break;case"top":for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:n.left,top:r.top,width:n.width,height:n.height}}break;case xet:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:n.left,top:r.top+r.height/2-n.height/2,width:n.width,height:n.height}}break;case wet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={left:r.left,top:i-r.height,width:r.width,height:r.height}}break;default:;}}(t,e)}))}}}const ket="VERTICAL",Eet=[ket,"HORIZONTAL"];function Met(t){if(this.hasSameParentForAllSelected&&-1!=Eet.indexOf(t)){var e=this.selected;if(!(e.length<=1)){var r=this.app.commander;vet.around(r,(function(){!function(t,e){var r=e.filter((t=>!t.stuck)).slice(0);r.sort((function(e,r){let n=e.center,i=r.center;return t===ket?n.y-i.y:n.x-i.x}));var n=r.reduce(((e,r)=>e+(t===ket?r.bounds.height:r.bounds.width)),0),i=r[0].bounds,a=r[r.length-1].bounds,s=((t===ket?a.top+a.height-i.top:a.left+a.width-i.left)-n)/(r.length-1),o=t===ket?i.top+i.height:i.left+i.width;for(let e=1;e<r.length-1;e++){let n=r[e],i=n.bounds;o+=s,t===ket?(i.top=o,o+=i.height):(i.left=o,o+=i.width),n.bounds=i}}(t,e)}))}}}function Tet(t){for(var e=0;t&&!t.isRootModel();)e+=t.get("rotation")||0,t=t.parent;return e%(2*Math.PI)}class Cet extends get{execute(){this.params.changes.forEach((t=>{let{component:e,to_container:r,to_index:n,to_left:i,to_top:a,hint:s}=t,o=function(t){if(t.isRootModel())return t.bounds;var{bounds:e,rotatePoint:r}=t,n=r;return{left:(n=t.transcoordS2T(n.x,n.y)).x-(r.x-e.left),top:n.y-(r.y-e.top),width:e.width,height:e.height}}(e),l=Tet(e);if(e.removeSelf(!r),e.bounds=o,e.set("rotation",l),r){e.set("rotation",function(t,e){return((t.get("rotation")||0)-Tet(e))%(2*Math.PI)}(e,r));let s=function(t,e){if(e.isRootModel())return t.bounds;var{bounds:r,rotatePoint:n}=t,i=e.transcoordT2S(n.x,n.y),a=e.bounds;return{left:i.x-(n.x-r.left)-a.left,top:i.y-(n.y-r.top)-a.top,width:r.width,height:r.height}}(e,r);t.to_left=void 0!==i?i:s.left,t.to_top=void 0!==a?a:s.top,e.bounds={left:t.to_left,top:t.to_top,width:s.width,height:s.height},void 0===n?r.addComponent(e):r.insertComponentAt(e,n)}}))}}function Pet(t,e,r){this.app.commander.execute(new Cet({changes:[{component:t,to_container:e,to_index:r}]}))}function Iet(t){var e=this.selected.filter((t=>!t.stuck));if(!(0==e.length||e[0].isRootModel()||e.length>1&&("forward"==t||"backward"==t))){var r,n=e[0].parent;if("forward"==t){let t=n.indexOf(e[0]);r=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t+1}]}else if("backward"==t){let t=n.indexOf(e[0]);r=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t-1}]}else r=e.filter((t=>t.parent===n)).sort(((e,r)=>{let i=n.indexOf(e)<n.indexOf(r);return"front"==t?i:!i})).map(((e,r)=>(n.indexOf(e),{component:e,to_container:n,to_index:"front"==t?n.components.length-r-1:r})));var i=new Cet({changes:r});this.app.commander.execute(i)}}function Ret(t,e,r,n){var i=mtt.register(t.type);if(!i)return H7("Class not found",t.type),null;r&&(t.refid=r(t.refid)),t.id&&n&&n(t.id)&&delete t.id;var a=new i(t,e);return t.components&&a.isContainer()&&(t.components.forEach((t=>{var i=Ret(t,e,r,n);i&&a.addComponent(i)})),delete t.components),a.created(),a}function Oet(t,e){var r=h7(t.hierarchy);return delete r.id,Ret(r,t.app,e)}var Let=Object.freeze({__proto__:null,compile:Ret,duplicate:Oet,select:p9,match:c9});function Det(t,e,r){t instanceof Array||(t=[t]),r||(r=this.model_layer);var n=[],i=new Map;this.selected=t.map((t=>{try{return Ret(t,r.app,(t=>{const e=this.getNewRefid();return void 0!==t&&i.set(t,e),e}),(t=>(this.indexMap[t]||[])[0]))}catch(t){return console.warn(t),!1}})).filter(Boolean).map((t=>{let{left:a,top:s,width:o,height:l,x:h,y:c,cx:u,cy:d}=e;return t.replaceRefids(i),isNaN(a)||isNaN(s)||isNaN(o)||isNaN(l)||(t.bounds={left:a,top:s,width:o,height:l}),isNaN(h)||isNaN(c)||t.move({x:h,y:c},!1),isNaN(u)||isNaN(d)||(t.center={x:u,y:d}),n.push({component:t,to_container:r}),t})),this.app.commander.execute(new Cet({changes:n}))}function Fet(){var t=[],e=new Map;if(this.selected=this.selected.filter((t=>!t.isRootModel())).map((r=>{let n=Oet(r,(t=>{const r=this.getNewRefid();return void 0!==t&&e.set(t,r),r}));return n.move({x:20,y:20},!1),t.push({component:n,to_container:r.parent}),n})).map((t=>(t.replaceRefids(e),t))),0!=t.length){var r=new Cet({changes:t});this.app.commander.execute(r)}}function Net(){var t=this.selected;this.selected=[];for(var e=null,r=t.filter((t=>!t.isRootModel()&&(t.parent.focusible||t.parent.isGroup()))).map((t=>(e||(e=t.parent),{component:t,to_container:null})));e&&e.isGroup();){let t=[];if(e.components.filter((t=>!r.find((e=>e.component===t)))).forEach((e=>t.push(e))),t.length>1)break;let n=e.parent;t.forEach((t=>r.push({component:t,to_container:n}))),r.push({component:e,to_container:null}),e=n}r.length>0&&this.app.commander.execute(new Cet({changes:r})),e&&e.calculateBounds&&e.calculateBounds()}function jet(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.on(t,e,r);break;case"mode":this.app?.on(t,e,r);break;default:this.on(t,e,r)}}function Bet(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.once(t,e,r);break;case"mode":this.app.once(t,e,r);break;default:this.once(t,e,r)}}function zet(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.off(t,e,r);break;case"mode":this.app?.off(t,e,r);break;default:this.off(t,e,r)}}function Wet(t){var e=this.target_element,r=t||this.fitMode,n=this;function i(t){n.fit(r),document.fullscreen||document.mozFullScreen||document.webkitIsFullScreen||document.msFullscreenElement||["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange"].forEach((t=>document.removeEventListener(t,i)))}["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange"].forEach((t=>document.addEventListener(t,i))),e.requestFullScreen?e.requestFullScreen():e.webkitRequestFullScreen?e.webkitRequestFullScreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen()}var Uet=0;function Het(){var t=this.selected.filter((t=>!t.isRootModel())).map((t=>t.hierarchy));if(0!=t.length)return Uet=0,JSON.stringify(t,null,2)}function Get(){Uet=0;var t=Het.call(this);return Net.call(this),t}function Yet(t){if(t)try{Uet++,Det.call(this,JSON.parse(t),{x:15*Uet,y:15*Uet})}catch(e){U7(e,t)}}var Vet=function(){return{escape:function(t){return t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},parseExtension:t,mimeType:function(e){var r=t(e).toLowerCase();return(n="application/font-woff",i="image/jpeg",{woff:n,woff2:n,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:i,jpeg:i,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"})[r]||"";var n,i},dataAsUrl:function(t,e){return"data:"+e+";base64,"+t},isDataUrl:function(t){return-1!==t.search(/^(data:)/)},canvasToBlob:function(t){return t.toBlob?new Promise((function(e){t.toBlob(e)})):function(t){return new Promise((function(e){for(var r=window.atob(t.toDataURL().split(",")[1]),n=r.length,i=new Uint8Array(n),a=0;a<n;a++)i[a]=r.charCodeAt(a);e(new Blob([i],{type:"image/png"}))}))}(t)},resolveUrl:function(t,e){var r=document.implementation.createHTMLDocument(),n=r.createElement("base");r.head.appendChild(n);var i=r.createElement("a");return r.body.appendChild(i),n.href=e,i.href=t,i.href},getAndEncode:function(t){var e=3e4;ert.impl.options.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());return new Promise((function(r){var n,i=new XMLHttpRequest;if(i.onreadystatechange=s,i.ontimeout=o,i.responseType="blob",i.timeout=e,i.open("GET",t,!0),i.send(),ert.impl.options.imagePlaceholder){var a=ert.impl.options.imagePlaceholder.split(/,/);a&&a[1]&&(n=a[1])}function s(){if(4===i.readyState)if(200===i.status){var e=new FileReader;e.onloadend=function(){var t=e.result.split(/,/)[1];r(t)},e.readAsDataURL(i.response)}else n?r(n):l("cannot fetch resource: "+t+", status: "+i.status)}function o(){n?r(n):l("timeout of "+e+"ms occured while fetching resource: "+t)}function l(t){console.error(t),r("")}}))},uid:function(){var t=0;return function(){return"u"+e()+t++;function e(){return("0000"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}}}(),delay:function(t){return function(e){return new Promise((function(r){setTimeout((function(){r(e)}),t)}))}},asArray:function(t){for(var e=[],r=t.length,n=0;n<r;n++)e.push(t[n]);return e},escapeXhtml:function(t){return t.replace(/#/g,"%23").replace(/\n/g,"%0A")},makeImage:function(t){return new Promise((function(e,r){var n=new Image;n.onload=function(){e(n)},n.onerror=r,n.src=t}))},width:function(t){var r=e(t,"border-left-width"),n=e(t,"border-right-width");return t.scrollWidth+r+n},height:function(t){var r=e(t,"border-top-width"),n=e(t,"border-bottom-width");return t.scrollHeight+r+n}};function t(t){var e=/\.([^\.\/]*?)$/g.exec(t);return e?e[1]:""}function e(t,e){var r=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(r.replace("px",""))}}(),qet=function(){var t=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(t,i,a){return s()?Promise.resolve(t):Promise.resolve(t).then(r).then((function(e){var r=Promise.resolve(t);return e.forEach((function(t){r=r.then((function(e){return n(e,t,i,a)}))})),r}));function s(){return!e(t)}},shouldProcess:e,impl:{readUrls:r,inline:n}};function e(e){return-1!==e.search(t)}function r(e){for(var r,n=[];null!==(r=t.exec(e));)n.push(r[1]);return n.filter((function(t){return!Vet.isDataUrl(t)}))}function n(t,e,r,n){return Promise.resolve(e).then((function(t){return r?Vet.resolveUrl(t,r):t})).then(n||Vet.getAndEncode).then((function(t){return Vet.dataAsUrl(t,Vet.mimeType(e))})).then((function(r){return t.replace(function(t){return new RegExp("(url\\(['\"]?)("+Vet.escape(t)+")(['\"]?\\))","g")}(e),"$1"+r+"$3")}))}}(),Xet=function(){return{resolveAll:function(){return t().then((function(t){return Promise.all(t.map((function(t){return t.resolve()})))})).then((function(t){return t.join("\n")}))},impl:{readAll:t}};function t(){return Promise.resolve(Vet.asArray(document.styleSheets)).then((function(t){var e=[];return t.forEach((function(t){try{Vet.asArray(t.cssRules||[]).forEach(e.push.bind(e))}catch(e){console.log("Error while reading CSS rules from "+t.href,e.toString())}})),e})).then((function(t){return t.filter((function(t){return t.type===CSSRule.FONT_FACE_RULE})).filter((function(t){return qet.shouldProcess(t.style.getPropertyValue("src"))}))})).then((function(e){return e.map(t)}));function t(t){return{resolve:function(){var e=(t.parentStyleSheet||{}).href;return qet.inlineAll(t.cssText,e)},src:function(){return t.style.getPropertyValue("src")}}}}}(),$et=function(){return{inlineAll:function e(r){return r instanceof Element?n(r).then((function(){return r instanceof HTMLImageElement?t(r).inline():Promise.all(Vet.asArray(r.childNodes).map((function(t){return e(t)})))})):Promise.resolve(r);function n(t){var e=t.style.getPropertyValue("background");return e?qet.inlineAll(e).then((function(e){t.style.setProperty("background",e,t.style.getPropertyPriority("background"))})).then((function(){return t})):Promise.resolve(t)}},impl:{newImage:t}};function t(t){return{inline:function(e){return Vet.isDataUrl(t.src)?Promise.resolve():Promise.resolve(t.src).then(e||Vet.getAndEncode).then((function(e){return Vet.dataAsUrl(e,Vet.mimeType(t.src))})).then((function(e){return new Promise((function(r,n){t.onload=r,t.onerror=n,t.src=e}))}))}}}}(),Ket={imagePlaceholder:void 0,cacheBust:!1};function Qet(t,e){return function(t){void 0===t.imagePlaceholder?ert.impl.options.imagePlaceholder=Ket.imagePlaceholder:ert.impl.options.imagePlaceholder=t.imagePlaceholder;void 0===t.cacheBust?ert.impl.options.cacheBust=Ket.cacheBust:ert.impl.options.cacheBust=t.cacheBust}(e=e||{}),Promise.resolve(t).then((function(t){return Zet(t,e.filter,!0)})).then(trt).then((function(t){var{bgcolor:r,width:n,height:i,style:a,sx:s=1,sy:o=1}=e,l=t.style;r&&(l.backgroundColor=r);n&&(l.width=n+"px");i&&(l.height=i+"px");l["margin-left"]="0px",l["margin-top"]="0px",l.transform=`rotate(0rad) translate(0px, 0px) scale(${s}, ${o}) perspective(1px)`,a&&Object.keys(a).forEach((function(t){l[t]=a[t]}));return t})).then((function(r){return function(t,e,r){return Promise.resolve(t).then((function(t){return t.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),(new XMLSerializer).serializeToString(t)})).then(Vet.escapeXhtml).then((function(t){return'<foreignObject x="0" y="0" width="100%" height="100%">'+t+"</foreignObject>"})).then((function(t){return'<svg xmlns="http://www.w3.org/2000/svg" width="'+e+'" height="'+r+'">'+t+"</svg>"})).then((function(t){return"data:image/svg+xml;charset=utf-8,"+t}))}(r,e.width||Vet.width(t),e.height||Vet.height(t))}))}function Jet(t,e){return Qet(t,e).then(Vet.makeImage).then(Vet.delay(100)).then((function(r){var n=function(t){var r=document.createElement("canvas");if(r.width=e.width||Vet.width(t),r.height=e.height||Vet.height(t),e.bgcolor){var n=r.getContext("2d");n.fillStyle=e.bgcolor,n.fillRect(0,0,r.width,r.height)}return r}(t);return n.getContext("2d").drawImage(r,0,0),n}))}function Zet(t,e,r){return r||!e||e(t)?Promise.resolve(t).then((function(t){if(t instanceof HTMLCanvasElement)try{return Vet.makeImage(t.toDataURL())}catch(t){H7(t)}return t.cloneNode(!1)})).then((function(r){return function(t,e,r){var n=t.childNodes;return 0===n.length?Promise.resolve(e):i(e,Vet.asArray(n),r).then((function(){return e}));function i(t,e,r){var n=Promise.resolve();return e.forEach((function(e){n=n.then((function(){return Zet(e,r)})).then((function(e){e&&t.appendChild(e)}))})),n}}(t,r,e)})).then((function(e){return function(t,e){return e instanceof Element?Promise.resolve().then(r).then(n).then(i).then(a).then((function(){return e})):e;function r(){function r(t,e){function r(t,e){Vet.asArray(t).forEach((function(r){e.setProperty(r,t.getPropertyValue(r),t.getPropertyPriority(r))}))}t.cssText?e.cssText=t.cssText:r(t,e)}r(window.getComputedStyle(t),e.style)}function n(){function r(r){var n=window.getComputedStyle(t,r),i=n.getPropertyValue("content");if(""!==i&&"none"!==i){var a=Vet.uid();e.className=e.className+" "+a;var s=document.createElement("style");s.appendChild(o(a,r,n)),e.appendChild(s)}function o(t,e,r){var n="."+t+":"+e,i=r.cssText?a(r):s(r);return document.createTextNode(n+"{"+i+"}");function a(t){var e=t.getPropertyValue("content");return t.cssText+" content: "+e+";"}function s(t){return Vet.asArray(t).map(e).join("; ")+";";function e(e){return e+": "+t.getPropertyValue(e)+(t.getPropertyPriority(e)?" !important":"")}}}}[":before",":after"].forEach((function(t){r(t)}))}function i(){t instanceof HTMLTextAreaElement&&(e.innerHTML=t.value),t instanceof HTMLInputElement&&e.setAttribute("value",t.value)}function a(){e instanceof SVGElement&&(e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e instanceof SVGRectElement&&["width","height"].forEach((function(t){var r=e.getAttribute(t);r&&e.style.setProperty(t,r)})))}}(t,e)})):Promise.resolve()}function trt(t){return $et.inlineAll(t).then((function(){return t}))}var ert={toSvg:Qet,toPng:function(t,e){return Jet(t,e||{}).then((function(t){return t.toDataURL()}))},toJpeg:function(t,e){return Jet(t,e=e||{}).then((function(t){return t.toDataURL("image/jpeg",e.quality||1)}))},toBlob:function(t,e){return Jet(t,e||{}).then(Vet.canvasToBlob)},toPixelData:function(t,e){return Jet(t,e||{}).then((function(e){return e.getContext("2d").getImageData(0,0,Vet.width(t),Vet.height(t)).data}))},impl:{fontFaces:Xet,images:$et,util:Vet,inliner:qet,options:{}}};function rrt(t,e,r,n){var i=this.model_layer,a=i._overlay;return new Promise((function(s,o){if(i){var l=i.get("width"),h=i.get("height");r=r||l,n=n||h;var c=i.get("translate"),u=i.get("scale"),d=Math.min(r/l,n/h);r=l*d,n=h*d,i.set("translate",{x:0,y:0}),i.set("scale",{x:d/e9,y:d/e9});var p=mtt.createCanvas(r,n),f=p.getContext("2d");if(i.draw(f),i.set("translate",c),i.set("scale",u),!a)return s(p.toDataURL(t,e)),void(p=null);ert.toPng(a,{sx:d,sy:d,width:r,height:n}).then((function(i){var a=new Image;a.onload=function(){f.drawImage(a,0,0,r,n),s(p.toDataURL(t,e)),p=null},a.src=i}),(function(r){U7(r),s(p.toDataURL(t,e)),p=null}))}else o("No target model")}))}function nrt(){if(this.hasSameParentForAllSelected){var t=this.selected.filter((t=>!!t.parent&&!t.stuck));if(!(t.length<2)){var e=t[0].parent,r=[],n=t.sort(((t,r)=>e.components.indexOf(t)-e.components.indexOf(r)));n.forEach((t=>{r.push(t.bounds)}));var i=mtt.union(r),a=t[0].transcoordP2S(i.left,i.top);a=t[0].transcoordS2T(a.x,a.y);var s=new Map,o=Ret({type:"group",left:a.x,top:a.y,width:i.width,height:i.height},e.app,(t=>{const e=this.getNewRefid();return void 0!==t&&s.set(t,e),e}));o.replaceRefids(s);var l=[{component:o,to_container:e}];n.forEach((t=>{l.push({component:t,to_container:o})})),this.app.commander.execute(new Cet({changes:l})),this.selected=[o]}}}function irt(){if(0!==this.selected.length){var t=[],e=[];this.selected.forEach((r=>{if(r.isGroup()){var n=r.parent;r.components.forEach((r=>{t.push(r),e.push({component:r,to_container:n})})),e.push({component:r,to_container:null})}})),this.app.commander.execute(new Cet({changes:e})),this.selected=t}}function art(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=mtt.union(e),n=r.left+r.width/2;t.map((t=>{t.symmetryX(n)}))}}function srt(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=mtt.union(e),n=r.top+r.height/2;t.map((t=>{t.symmetryY(n)}))}}function ort(){vet.around(this.app.commander,art,this)}function lrt(){vet.around(this.app.commander,srt,this)}function hrt(t,e,r){var n=this.findAll(t,r);return n.forEach((t=>{t.set(e)})),n}function crt(t){vet.around(this.app.commander,t)}function urt(){return Object.values(this.indexMap).map((t=>t.map((t=>{let{id:e,data:r}=t.model;return{key:e,value:r}})))).flat().sort(((t,e)=>t.key>e.key?1:-1))}const drt="left",prt="right",frt="center",grt="bottom",vrt="middle",mrt=[drt,prt,frt,"top",vrt,grt];function yrt(t){if(this.hasSameParentForAllSelected&&-1!=mrt.indexOf(t)){var e=this.selected.filter((t=>!t.stuck)),r=this.app.commander;vet.around(r,(function(){!function(t,e){const r=e[0].parent,{width:n,height:i}=r.bounds;switch(t){case drt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:0}}break;case frt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:n/2-r.width/2}}break;case prt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:n-r.width}}break;case"top":for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:0}}break;case vrt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:i/2-r.height/2}}break;case grt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:i-r.height}}break;default:;}}(t,e)}))}}function brt(t){t instanceof Array||(t=[t]),this.trigger("addstart",t)}function wrt(){this.trigger("stylepastestart")}function xrt(){this.trigger("stylepastestop")}function Art(){this.trigger("databindpastestart")}function _rt(){this.trigger("databindpastestop")}function krt(t,e,r,n){var i=t.selected,a=n?i.slice(0):[];n&&a.length>0?e=a[0].parent:e.isContainer()||(e=e.parent);var s=e.layout.capturables(e),o=!!e.layout.joinType;if(n&&r.selected.forEach((t=>{a.splice(a.indexOf(t),1)})),r.selected=[],s.forEach((t=>{t.capturable&&function(t,e,r){var n,i,a,s,{sx:o,sy:l,ex:h,ey:c}=e;if(o>h?(n=h,i=o):(n=o,i=h),l>c?(a=c,s=l):(a=l,s=c),r){var u=t.bounds,d=t.transcoordS2TR(u.left,u.top),p=t.transcoordS2TR(u.left+u.width,u.top+u.height),f=d.x,g=p.x,v=d.y,m=p.y,y=Math.min(n,f,i,g),b=Math.max(n,f,i,g),w=Math.min(a,v,s,m),x=Math.max(a,v,s,m);return!(b-y>Math.abs(i-n)+Math.abs(g-f)||x-w>Math.abs(s-a)+Math.abs(m-v))}var A=t.path;if(!A)return error("컴포넌트에 get path가 잘못 구현되어있음.",t),!1;for(let e=0;e<A.length;e++){let r=t.transcoordS2TR(A[e].x,A[e].y);if(n>r.x||i<r.x||a>r.y||s<r.y)return!1}return!0}(t,r,o)&&-1==a.indexOf(t)&&r.selected.push(t)})),a=a.concat(r.selected),i.length!==a.length)t.selected=a;else for(let e=0;e<a.length;e++)if(i[e]!=a[e]){t.selected=a;break}}function Srt(t,e,r,n,i){i||krt(t,e,r,n)}function Ert(t,e){var r=t.components||[];for(let t of r){Ert(t,e);let r=e.indexOf(t);-1!=r&&e.splice(r,1)}}mtt.register("add-layer",class extends Ytt{ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}render(t){var e=this.addbox;if(e){let{sx:r,sy:n,ex:i,ey:a}=e,s=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/s.x,4/s.y]),t.lineWidth=1/s.x,t.strokeStyle="black",t.stroke()}}contains(t,e){return!(3!=this.app.mode)}get eventMap(){return{"(root)":{"(self)":{addstart:this.onaddstart,addstop:this.onaddstop,keydown:this.onkeydown,dragstart:this.ondragstart,dragmove:this.ondragmove,dragend:this.ondragend,mousedown:this.onmousedown,mouseup:this.onmouseup}},"model-layer":{"(self)":{change:this.onchange_root_model}}}}onchange_root_model(t,e,r){t.translate&&this.set("translate",t.translate),t.scale&&this.set("scale",t.scale)}onaddstart(t,e){void 0===this.before_mode&&(this.before_mode=this.app.mode,this.models=t,this.app.mode=3)}onaddstop(){void 0!==this.before_mode&&(this.app.mode=this.before_mode),delete this.before_mode,delete this.addbox,this.invalidate()}onkeydown(t){3!==this.app.mode||"Esc"!=t.code&&"Escape"!=t.code||this.root.trigger("addstop")}ondragstart(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.addbox={sx:e,sy:r}}ondragmove(t){if(3===this.app.mode){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.addbox&&(this.addbox.ex=e,this.addbox.ey=r,this.invalidate())}}ondragend(t,e){if(3!==this.app.mode)return;const{sx:r,sy:n,ex:i,ey:a}=this.addbox;Det.call(this.root,this.models,{left:Math.min(r,i),top:Math.min(n,a),width:Math.abs(i-r),height:Math.abs(a-n)}),this.root.trigger("addstop")}onmousedown(t,e){3===this.app.mode&&(this.downpoint={x:t.offsetX,y:t.offsetY})}onmouseup(t,e){if(this.downpoint.x===t.offsetX&&this.downpoint.y===t.offsetY){var{x:r,y:n}=this.transcoordC2S(t.offsetX,t.offsetY);Det.call(this.root,this.models,{cx:r,cy:n}),this.root.trigger("addstop")}}});mtt.register("selection-layer",class extends Ytt{ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}contains(t,e){return!1}render(t){var e=this.selbox;if(e){let{sx:r,sy:n,ex:i,ey:a}=e,s=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/s.x,4/s.y]),t.lineWidth=1/s.x,t.strokeStyle="black",t.stroke()}}get eventMap(){return{"(root)":{"(self)":{keydown:this.onkeydown}},"model-layer":{"(self)":{change:this.onchange_root_model},"(all)":{dragstart:this.ondragstart_selbox,dragmove:this.ondragmove_selbox,dragend:this.ondragend_selbox,mousedown:this.onmousedown_comp,mouseup:this.onmouseup_comp}}}}onkeydown(t,e){var{origin:r,deliverer:n}=e,i=n.selected;if(1!==i.length)return!1;var a=i[0],s=a.parent;if(!s||s===n)return!1;if("Tab"===t.code){var o=s.layout.capturables(s),l=o.indexOf(a);if(-1==l){if(!s.indexOf(a))return H7("Container not contains [",a,"] as a component"),!1;l=0}var h=o.length;t.shiftKey?l--:l++,a=o[(l+h)%h]}else{if(!s.layout.keyNavigate)return!1;a=s.layout.keyNavigate(s,a,t)||a}n.selected=[a],t.preventDefault()}onchange_root_model(t,e,r){t.translate&&this.set("translate",t.translate),t.scale&&this.set("scale",t.scale)}_pendingDecision(t){this.downpoint={x:t.offsetX,y:t.offsetY}}_selectGroupItem(t,e){var r=this.selected.indexOf(t);let n=t.parent;for(;n.parent.isGroup();)n=n.parent;let i=[],a=!1,s=!1;if(this.selected.forEach((t=>{let e=t.parent;if(t!==n){for(;e.parent&&e.parent.isGroup();)e=e.parent;e===n&&(i.push(t),a=!0)}else s=!0})),a)if(e.shiftKey){if(-1!=r)return void this._pendingDecision(e);i.push(t)}else{if(-1!=r)return void this._pendingDecision(e);i=[t]}else{if(s)return void this._pendingDecision(e);if(e.shiftKey)if(this.selected.length>0){if(-1!=this.selected.indexOf(n))return;i=[...this.selected,n]}else i=[n];else i=[n]}this.selected=i}onmousedown_comp(t,e){var{origin:r}=e;if(this.downpoint=null,t.shiftKey){if(r.parent.isGroup())return void this._selectGroupItem(r,t);if(-1!=this.selected.indexOf(r))return void this._pendingDecision(t);{let t=this.selected.filter((t=>!t.isRootModel()&&!!t.parent)),e=t.length>0&&t[0].parent;e&&e!==r.parent&&(!function(t,e){for(var r=t.parent;r;){let t=e.indexOf(r);-1!=t&&e.splice(t,1),r=r.parent}}(r,t),Ert(r,t)),t.push(r),this.selected=t}}else{if(r.parent.isGroup())return void this._selectGroupItem(r,t);if(-1!=this.selected.indexOf(r))return;this.selected=[r],this.sameParent=!0}}onmouseup_comp(t,e){if(!this.downpoint)return;if(this.downpoint.x!==t.offsetX||this.downpoint.y!==t.offsetY)return;var{origin:r}=e;let n=this.selected.indexOf(r);if(-1==n&&r.parent.isGroup()&&(n=this.selected.indexOf(r.parent)),-1!==n&&t.shiftKey){let t=this.selected.slice();return n>-1&&t.splice(n,1),void(this.selected=t)}r.parent.isGroup()&&(this.selected=[r])}ondragstart_selbox(t,e){var{origin:r}=e;if(r.stuck){var{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);this.selbox={sx:n,sy:i,selected:[]}}}ondragmove_selbox(t,e){var{origin:r}=e;if(r.stuck){var{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);this.selbox&&(this.selbox.ex=n,this.selbox.ey=i,Srt(this,r,this.selbox,t.shiftKey),this.invalidate())}}ondragend_selbox(t,e){var{origin:r}=e;r.stuck&&(this.last_pos=null,this.selbox=null,Srt(this,null,null,!1,!0),this.invalidate())}});class Mrt{constructor(t){this.layer=t}draw(t,e,r){var{left:n,top:i,width:a,height:s}=e.bounds;0!=a&&0!=s&&(t.beginPath(),t.rect(n,i,a,s),t.clip(),t.beginPath(),t.strokeStyle="#f26522",t.lineWidth=4,t.shadowBlur=10,t.shadowColor="black",t.shadowOffsetX=0,t.shadowOffsetY=0,t.rect(n,i,a,s),t.stroke(),t.closePath())}}class Trt{constructor(t){this.layer=t}draw(t,e,r){var n=e.bounds;t.beginPath(),t.rect(n.left-4/r.x,n.top-4/r.y,n.width+8/r.x,n.height+8/r.y),t.setLineDash([3/r.x,4/r.y]),t.lineWidth=1/r.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),t.closePath()}}class Crt{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){let i=r.controls;return!!i&&(i.every(((i,a)=>(Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a,handler:i.handler}),!this.active))),!!this.active)}draw(t,e,r){var n=e.controls;n&&n.forEach(((e,n)=>{t.beginPath(),t.lineWidth=1/r.x,t.ellipse(e.x,e.y,4/r.x,4/r.y,0,0,2*Math.PI,!0),t.fillStyle="#ff5d72",t.fill(),t.strokeStyle="#fff",t.stroke()}))}onevent(t,e){var{handler:r,component:n,index:i}=this.active,a=n.transcoordC2S(e.offsetX,e.offsetY);a=n.transcoordS2P(a.x,a.y),r&&"function"==typeof r[t]&&r[t](a,i,n)}onmousedown(t){this.onevent("onmousedown",t)}ondragstart(t){var e=this.active;e.changes=vet.before([e.component]),this.onevent("ondragstart",t)}ondragmove(t){this.onevent("ondragmove",t)}ondragend(t){this.onevent("ondragend",t);var{component:e,changes:r}=this.active;vet.after(r,e.app.commander),e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}function Prt(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}const Irt=15*Math.PI/180;class Rrt{constructor(t){this.layer=t}reset(){this.active=null,this.created=null}get selected(){return this.layer.selected}contains(t,e,r,n){return!!r.mutable&&(r.path.every(((i,a)=>(Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a}),!this.active))),!!this.active)}startLinkProcess(t,e,r){try{var n=Ret(e,t.app);return t.rootModel.addComponent(n),this.layer.selected=[n],this.active={component:n,index:1},this.ondragstart(r),n}catch(t){console.warn(r)}}draw(t,e,r){if(e.mutable&&!e.stuck){var n=e.path,i=this.active;n.forEach(((n,a)=>{t.beginPath(),t.ellipse(n.x,n.y,4/r.x,4/r.y,0,0,2*Math.PI,!0),t.lineWidth=1/r.x,t.strokeStyle="#656565",t.fillStyle="#fff",i&&i.component===e&&i.index===a&&(t.strokeStyle="#fa7703",i.toFill&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke()}))}}ondblclick(t){var e=this.active.component;if(e.pathExtendable){var r=e.path.slice();r.length<3||(r.splice(this.active.index,1),e.path=r)}}onmousedown(t){this.active.toFill=!0}ondragstart(t){var{index:e,component:r}=this.active;this.created||(this.active.changes=vet.before([r])),0!==e&&e!==r.path.length-1||(this.layer.counterEnd=0===e?r.toEnd||{fromto:"to"}:r.fromEnd||{fromto:"from"})}ondragmove(t){var{component:e,index:r}=this.active||{};const{offsetX:n,offsetY:i}=t;var a,s,o=e.transcoordC2S(n,i);if(o=e.transcoordS2P(o.x,o.y),t.shiftKey){var l=e.path.length,h=e.isLine()&&0==r?e.path[1]:e.path[(r-1+l)%l];h=e.transcoordS2P(h.x,h.y);var c,u=0;if(l>2)e.isLine()?0==r?c=e.path[2]:1!=r&&(c=e.path[r-2]):c=e.path[(r-2+l)%l],c&&(u=Prt(c=e.transcoordS2P(c.x,c.y),h));var d=Math.round((Prt(h,o)-u)/Irt)*Irt+u;o=function(t,e,r){return{x:Math.cos(e)*r+t.x,y:Math.sin(e)*r+t.y}}(h,d,(a=h,s=o,Math.sqrt((s.x-a.x)*(s.x-a.x)+(s.y-a.y)*(s.y-a.y))))}if(0===r||r===e.path.length-1){const t=this.layer.anchorTarget=e.rootModel.capture(n,i,(t=>!t.isConnectable()));if(t){const{x:a,y:s}=t.transcoordC2S(n,i),l=this.layer.get("scale")||{x:1,y:1},h=this.layer.counterEnd,c=(t.anchors||[]).find((r=>{const{name:n,inout:i,multiplicity:o=1/0,position:c,filter:u}=r;if(h){const{anchor:t,fromto:e}=h;if(t&&("out"===t.inout&&"out"===i||"in"===t.inout&&"in"===i))return!1;if("from"===e&&"out"===i||"to"===e&&"in"===i)return!1}else console.error("should not be here.");if(Math.abs(a-c.x)>8/l.x||Math.abs(s-c.y)>8/l.y)return!1;const d=t.findInOutLines(n);return!!d.includes(e)||!(o!==1/0&&d.length>=o)&&(!h||!u||!!u.call(r,h))}));c?0==r?e.from={component:t.get("refid"),anchor:c.name,position:o}:e.to={component:t.get("refid"),anchor:c.name,position:o}:0==r?e.from={position:o}:e.to={position:o}}}e.mutatePath(null,(function(t){t[r]=o}))}ondragend(t){var{component:e,index:r,changes:n}=this.active;if(0===r||r===e.path.length-1){const{offsetX:n,offsetY:i}=t,a=e.rootModel.capture(n,i,(t=>t===e||t.isLine())),{x:s,y:o}=a.transcoordC2S(n,i),l=this.layer.get("scale")||{x:1,y:1},h=(a.anchors||[]).find((t=>t&&Math.abs(s-t.position.x)<=8/l.x&&Math.abs(o-t.position.y)<=8/l.y));h&&(0==r?e.from={component:a.get("refid"),anchor:h.name}:e.to={component:a.get("refid"),anchor:h.name}),this.layer.endLinkProcess()}if(this.created){let t=new Cet({changes:[{component:this.created,to_container:this.created.parent}]});created.app.commander.execute(t)}else vet.after(n,e.app.commander);e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}class Ort{constructor(t){this.layer=t}get active(){return this._active?.component.disposed&&(this._active=null),this._active}set active(t){this._active=t}reset(){this.active=null}contains(t,e,r,n){const i=this.active?.component===r&&this.active?.anchor;this.active=null;const a=this.layer.counterEnd;return(r.isConnectable()&&!r.disposed&&r.anchors||[]).filter((t=>{const{name:e,inout:n,multiplicity:i=1/0,filter:s}=t;if(a){const{anchor:t,fromto:e}=a;if(t&&("out"===t.inout&&"out"===n||"in"===t.inout&&"in"===n))return!1;if("from"===e&&"out"===n||"to"===e&&"in"===n)return!1}else if("in"===n)return!1;return!(i!==1/0&&r.findInOutLines(e).length>=i)&&(!s||!a||!!s.call(t,a))})).every((a=>{const s=i===a.name?2:1;return a&&a.position&&Math.abs(t-a.position.x)<=4*s/n.x&&Math.abs(e-a.position.y)<=4*s/n.y&&(this.active={component:r,anchor:a.name,template:a.template}),!this.active})),!!this.active}draw(t,e,r){if(!e.get("refid")||e.isLine())return;var n=this.active;const i=this.active?.component===e&&this.active?.anchor,a=this.layer.counterEnd;(e.isConnectable()&&!e.disposed&&e.anchors||[]).filter((t=>{const{name:r,inout:n,multiplicity:i=1/0,filter:s}=t;if(a){const{anchor:t,fromto:e}=a;if(t&&("out"===t.inout&&"out"===n||"in"===t.inout&&"in"===n))return!1;if("from"===e&&"out"===n||"to"===e&&"in"===n)return!1}else if("in"===n)return!1;return!(i!==1/0&&e.findInOutLines(r).length>=i)&&(!a||!s||!!s.call(t,a))})).forEach((a=>{const{name:s,position:o}=a,l=i===s?2:1;o&&(t.beginPath(),t.ellipse(o.x,o.y,4*l/r.x,4*l/r.y,0,0,2*Math.PI),t.setLineDash([0,0]),t.lineWidth=1/r.x,t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",n&&n.component===e&&n.anchor===s&&(t.strokeStyle="#fa7703",n.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())}))}onmousedown(t){this.active.focus=!0}ondragstart(t){const{component:e,anchor:r,template:n}=this.active,i=this.layer.transcoordC2S(t.offsetX,t.offsetY);this.layer.startLinkProcess(e,{type:"ortholine",lineWidth:1,strokeStyle:"black",begin:"oval",beginSize:"size9",end:"arrow",endSize:"size9",lineDash:"solid",lineCap:"butt",round:10,...n,from:{component:e.get("refid"),anchor:r,position:i},to:{position:i}},t)}ondragmove(t){}ondragend(t){}}function Lrt(t,e,r){var n,i,{left:a,top:s,width:o,height:l}=t.bounds;switch(e){case 0:n=a,i=s;break;case 1:n=a+o/2,i=s;break;case 2:n=a+o,i=s;break;case 3:n=a+o,i=s+l/2;break;case 4:n=a+o,i=s+l;break;case 5:n=a+o/2,i=s+l;break;case 6:n=a,i=s+l;break;case 7:n=a,i=s+l/2}var h=n,c=i,u=t.transcoordT2S(r.x,r.y);return{dx:u.x-h,dy:u.y-c}}function Drt(t,e,r,n,i,a){var{left:s,top:o,width:l,height:h}=t.bounds,c={left:s,top:o,width:l,height:h};switch(e){case 0:s+=n,o+=i,l-=n,h-=i;break;case 1:o+=i,h-=i;break;case 2:o+=i,l+=n,h-=i;break;case 3:l+=n;break;case 4:l+=n,h+=i;break;case 5:h+=i;break;case 6:s+=n,l-=n,h+=i;break;case 7:s+=n,l-=n}if(t.mutateBounds((function(e){return Math.abs(l)<=.001&&(l=.001),Math.abs(h)<=.001&&(h=.001),t.adjustResize({left:s,top:o,width:l,height:h},c,r)}),this),t.isContainer()&&t.layout.ABSOLUTE&&!t.isGroup()){var u=c.left-s,d=c.top-o;a?t.components.forEach((t=>{t.delta("tx",0),t.delta("ty",0),t.move({x:u,y:d},!1)})):t.components.forEach((t=>{t.delta("tx",u),t.delta("ty",d)}))}else{var p=a&&t.parent;p&&p.isGroup()&&p.calculateBounds()}}function Frt(t,e){var{left:r,top:n,width:i,height:a}=t,s=r+i/2,o=n+a/2,l=r+i,h=n+a;const c=i*e.x>50,u=a*e.y>50;return[{x:r,y:n},c?{x:s,y:n}:null,{x:l,y:n},u?{x:l,y:o}:null,{x:l,y:h},c?{x:s,y:h}:null,{x:r,y:h},u?{x:r,y:o}:null]}class Nrt{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){return!!r.resizable&&(Frt(r.bounds,n).every(((i,a)=>(i&&Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a}),!this.active))),!!this.active)}draw(t,e,r){if(!e.isLine()){var{left:n,top:i,width:a,height:s}=e.bounds;if(t.beginPath(),t.rect(n-4/r.x,i-4/r.y,a+8/r.x,s+8/r.y),t.setLineDash([3/r.x,4/r.y]),t.lineWidth=1/r.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),e.resizable){var o=this.active;Frt(e.bounds,r).forEach(((n,i)=>{n&&(t.beginPath(),t.rect(n.x-4/r.x,n.y-4/r.y,8/r.x,8/r.y),t.setLineDash([0,0]),t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",o&&o.component===e&&o.index===i&&(t.strokeStyle="#fa7703",o.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())}))}}}onmousedown(t){this.active.focus=!0}ondragstart(t){var{component:e}=this.active;this.active.bounds=e.bounds,this.active.boundsList=this.layer.selected.filter((t=>t.resizable)).map((t=>t.bounds))}ondragmove(t){var{component:e,index:r,boundsList:n,bounds:i}=this.active,a=this.layer.transcoordC2S(t.offsetX,t.offsetY);e.bounds=i;var s=Lrt(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],Drt(e,r,t.shiftKey,s.dx,s.dy,!1)}))}ondragend(t){var{component:e,index:r,boundsList:n,bounds:i}=this.active,a=this.layer.transcoordC2S(t.offsetX,t.offsetY);e.bounds=i;var s=Lrt(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],Drt(e,r,t.shiftKey,s.dx,s.dy,!0)})),this.active.component.app.commander.execute(null,!1)}}const jrt=2*Math.PI,Brt=Math.PI/2;function zrt(t,e){var r=t.bounds;return{x:r.left+r.width/2,y:r.top-20/e.y}}class Wrt{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){if(!r.rotatable)return!1;var i=zrt(r,n);return Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r},!0)}draw(t,e,r){if(e.rotatable){t.beginPath();var n=zrt(e,r);t.lineWidth=1.5/r.x,t.moveTo(n.x,n.y+20/r.y),t.lineTo(n.x,n.y),t.strokeStyle="#656565",t.stroke(),t.beginPath(),t.ellipse(n.x,n.y,4/r.x,4/r.y,0,0,jrt,!0),t.stroke(),t.fillStyle="#fff",t.fill();var i=this.active;i&&i.component===e&&(t.strokeStyle="#fa7703",t.stroke(),i.toFill&&(t.fillStyle="#ffb80c",t.fill()))}}onmousedown(t){this.active.toFill=!0}ondragstart(t){var e=this.active;e.component,e.start_rotation=e.component.get("rotation"),e.rotations=this.layer.selected.filter((t=>t.rotatable)).map((t=>t.get("rotation")))}ondragmove(t){var{component:e}=this.active,r=e.transcoordC2S(t.offsetX,t.offsetY);r=e.transcoordS2P(r.x,r.y);var n=e.rotatePoint,i=e.get("rotation")||0,a=Math.atan((n.y-r.y)/(n.x-r.x)),s=(a=n.x>=r.x?a-Brt:Brt+a)-i;this.layer.selected.filter((t=>t.rotatable)).forEach(((e,r)=>{let n=((e.get("rotation")||0)+s)%jrt;e.set("rotation",e.adjustRotation(n,t.shiftKey))}))}ondragend(t){var{component:e,rotations:r}=this.active;e.app.commander.execute(null,!1)}}mtt.register("modeling-layer",class extends Ytt{constructor(t,e){super(t,e),this.pathHandler=new Rrt(this);var r=this.pathHandler,n=new Crt(this),i=new Nrt(this),a=new Wrt(this);this._modelers=[r,n,i,a],this._control_mode_modelers=[n,r,i,a],this.focusOutline=new Mrt(this),this.groupOutline=new Trt(this),this.anchorHandler=new Ort(this),this._reversed_modelers=this._modelers.slice().reverse(),this._control_mode_reverse_modelers=this._control_mode_modelers.slice().reverse(),this.hovered=null,this.hoveredDest=null}get modelers(){return this._control_mode?this._control_mode_modelers:this._modelers}get reversedModelers(){return this._control_mode?this._control_mode_reverse_modelers:this._reversed_modelers}ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}contains(t,e){var r=this.selected.filter((t=>!!t.parent)),n=this.get("scale")||{x:1,y:1};if(this._state_dragging){if(this._counter_end){let r=this.anchorTarget.transcoordT2S(t,e);if(this.anchorHandler.contains(r.x,r.y,this.anchorTarget,n))return!0}return!0}this.modelers.forEach((t=>t.reset()));r=this.selected.filter((t=>!!t.parent));for(let i=0;i<r.length;i++){let a=r[i],s=a.transcoordT2S(t,e);for(let t=0;t<this.modelers.length;t++){let e=this.modelers[t];if(e.contains(s.x,s.y,a,n))return this.currentModeler=e,!0}}if(this.anchorTarget){let r=this.anchorTarget.transcoordT2S(t,e);if(this.anchorHandler.contains(r.x,r.y,this.anchorTarget,n))return this.currentModeler=this.anchorHandler,!0}else this.anchorHandler.reset();return this.currentModeler=null,!1}_componentDrawer(t,e,r,n){let i=[],a=e.parent;if(e.isRootModel())return t.save(),n(t,e,r),void t.restore();for(;a&&!a.isRootModel();)i.push(a),a=a.parent;t.save(),i.reverse().forEach((function(e){let r=e.rotatePoint;t.translate(r.x,r.y);let n=e.get("scale");n&&t.scale(n.x,n.y),t.rotate(e.get("rotation")),t.translate(-r.x,-r.y);let i=e.bounds;t.translate(i.left,i.top)}));let s=e.rotatePoint;t.translate(s.x,s.y);let o=e.get("scale");o&&t.scale(o.x,o.y),t.rotate(e.get("rotation")),t.translate(-s.x,-s.y),n(t,e,r),t.restore()}prerender(t){var{translate:e,scale:r={x:1,y:1},rotation:n}=this.model;t.save(),t.beginPath(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.rect(0,0,t.canvas.width,t.canvas.height),t.fillStyle="black",t.globalAlpha=.5,t.fill(),t.restore(),e&&t.translate(e.x*e9,e.y*e9),t.scale(r.x*e9,r.y*e9),n&&t.rotate(n),t.clearRect(0,0,this.rootModel.get("width"),this.rootModel.get("height"))}render(t){t.beginPath();var e=this.get("scale")||{x:1,y:1},r=this.selected.filter((t=>!!t.parent));if(this.focused&&this._componentDrawer(t,this.focused,e,((t,e,r)=>{this.focusOutline.draw(t,e,r)})),r.length>0&&r[0].parent.isGroup()){let n=r[0].parent;for(;n.parent.isGroup();)n=n.parent;this._componentDrawer(t,n,e,((t,e,r)=>{this.groupOutline.draw(t,e,r)}))}r.forEach((r=>{this._componentDrawer(t,r,e,((t,e,r)=>{this.reversedModelers.forEach((n=>n.draw(t,e,r)))}))})),this.anchorTarget&&this._componentDrawer(t,this.anchorTarget,e,((t,e,r)=>{this.anchorHandler.draw(t,e,r)}))}get anchorTarget(){return this.currentModeler===this.anchorHandler||this.currentModeler===this.pathHandler||this.hovered?.isLine()||(this._anchorTarget=this.hovered),this._anchorTarget}set anchorTarget(t){this._anchorTarget=t}get hovered(){return this._hovered}set hovered(t){this._hovered=t,this.invalidate()}startLinkProcess(t,e,r){this.currentModeler=this.pathHandler,this.processingLink=this.pathHandler.startLinkProcess(t,e,r),this.counterEnd=this.processingLink.fromEnd,this.processingLink.trigger("tag")}set counterEnd(t){this.currentModeler=this.pathHandler,this._counter_end=t}get counterEnd(){return this._counter_end}endLinkProcess(){this.processingLink?.trigger("tagreset"),this.processingLink=null,this._counter_end=null}get eventMap(){return{"model-layer":{"(all)":{change:this.onchange_model,wheel:this.onwheel_scale,drop:this.ondrop},"(descendant)":{mouseenter:this.onmouseenter,mouseleave:this.onmouseleave},"(self)":{dblclick:this.ondblclick_model}},"(root)":{"(self)":{selected:this.onselected,keydown:this.onkeydown,keyup:this.onkeyup}}}}onmouseenter(t,e){this.hovered=e?.origin}onmouseleave(t,e){this.hovered=null}onkeydown(t){"Alt"==t.key&&(this._control_mode=!0,this.invalidate())}onkeyup(t){"Alt"==t.key&&(this._control_mode=!1,this.invalidate())}onselected(t,e){this.invalidate()}onchange_model(t,e,r){var{origin:n,deliverer:i}=r;n===i&&(t.translate&&this.set("translate",t.translate),void 0!==t.rotation&&this.set("rotation",t.rotation),t.scale&&this.set("scale",t.scale)),this.invalidate()}ondblclick_model(t,e){const r=e.origin;r?.root.fit()}ondblclick(t){"function"==typeof this.currentModeler.ondblclick&&this.currentModeler.ondblclick(t),this.invalidate()}onmousedown(t){this.currentModeler.onmousedown(t),this.invalidate()}onmouseup(t){"function"==typeof this.currentModeler.onmouseup&&this.currentModeler.onmouseup(t),this.invalidate()}ondragstart(t){this.currentModeler.ondragstart(t),this._state_dragging=!0}ondragmove(t){this.currentModeler.ondragmove(t),this.invalidate()}ondragend(t){this._state_dragging=!1,this.currentModeler.ondragend(t),this.invalidate()}ondrop(t,e){var{origin:r}=e,n=t.dataTransfer.files;if(n.length<1)return;let i=this.rootModel.transcoordC2S(t.offsetX,t.offsetY),a=this.rootModel;Promise.all(Array.from(n).map((t=>new Promise(((e,r)=>{let n=new FileReader;n.addEventListener("loadend",(t=>{e(n.result)})),["error","abort"].forEach((t=>n.addEventListener(t,(t=>{r(t)})))),n.readAsDataURL(t)}))))).then((e=>{if(t.altKey)return vet.around(this.app.commander,(()=>{r.ondropfile(n,e)})),void(this.selected=[r]);let s=[],o=e.map(((t,e)=>{let r,o=n[e].type,l=n[e].name;return o.startsWith("image/")?(r=Ret({type:o.startsWith("image/gif")?"gif-view":"image-view",top:0,left:0,width:200,height:200,src:t},a.app),s.push(new Promise(((e,n)=>{let i=new Image;i.src=t,i.onload=()=>{r.set({width:i.width,height:i.height}),e()},i.onerror=t=>{n(t)}})))):o.startsWith("audio/")?r=Ret({type:"audio",top:0,left:0,width:100,height:100,src:t},a.app):o.startsWith("vnd.ms-excel/")||/\.xlsx?$/.test(l)?r=Ret({type:"excel",top:0,left:0,width:100,height:100,src:t},a.app):console.log("droped file",n[e]),r&&(r.center=i,i.x+=50,i.y+=50),r})).filter(Boolean).map((t=>({component:t,to_container:a})));o.length>0&&Promise.all(s).then((()=>{this.app.commander.execute(new Cet({changes:o})),this.selected=o.map((t=>t.component))}),(t=>{console.error(t)}))}),(t=>{console.error(t)}))}onwheel_scale(t,e){if(0!=t.deltaY||0!=t.deltaX){var r=e.deliverer;if(t.shiftKey){if(-1!=navigator.userAgent.indexOf("Win"))var n=t.deltaY<0?1:-1;else n=t.deltaX<0?1:-1;t.altKey?vet.around(this.app.commander,(()=>{r.selected.forEach((t=>{let e=t.get("letterSpacing")||i9.LETTER_SPACING;e+=n,t.set("letterSpacing",e)}))})):vet.around(this.app.commander,(()=>{r.selected.forEach((t=>{let e=t.get("fontSize")||i9.FONT_SIZE;e<1&&(e=1),e+=n,t.set("fontSize",e)}))}))}else{n=t.deltaY<0?1:-1;let e=r.get("scale")||{x:1,y:1},i=r.get("translate"),a=t.offsetX,s=t.offsetY,o=r.transcoordC2S(a,s),l=.1*n,h={x:e.x+l,y:e.y+l};if(n<0&&e.x<.2||n>0&&e.x>10)return;r.set("scale",h);let c=r.transcoordC2S(a,s);r.set("translate",{x:i.x+(c.x-o.x)*h.x,y:i.y+(c.y-o.y)*h.y})}}}});class Urt extends Ytt{constructor(t,e){super(t,e),this._anim_alpha=1}animOnTargetChange(t){t!==this._lastTargets&&(this._lastTargets=t,this._anim_alpha=1,this.animate({step:t=>{this._anim_alpha=1-t,this.invalidate()},duration:5e3,delta:"circ",ease:"in"}).start())}decorate(t,e,r){const n=t.decorators;var i=!1;return n.map((t=>"string"==typeof t?htt(t):t)).filter((t=>t&&"function"==typeof t)).map((n=>{const a=n(t,e,1-r);i||=a})),i}render(t){var e=this.decoTargets&&this.decoTargets.filter((t=>t.rootModel));if(!e||0==e.length)return this._animate&&this._animate.stop(),void delete this._animate;t.globalAlpha*=this._anim_alpha;var r=!1;e.forEach((e=>{this.decorate(e,t,1-this._anim_alpha)&&(r=!0)})),r&&this.animOnTargetChange(this.decoTargets)}get decoTargets(){return this._decoTargets}set decoTargets(t){this._decoTargets=t&&t.filter((t=>!t.isLayer())),this.invalidate()}get eventMap(){return{"model-layer":{"(descendant)":{tag:this.ondecotag,tagreset:this.ondecotagreset,mouseenter:this.onmouseenter,mouseleave:this.onmouseleave}}}}onmouseenter(t,e){this._decotagreset(),this._ondecotag(e.origin)}onmouseleave(t,e){this._decotagreset()}ondecotagreset(t){this._decotagreset()}ondecotag(t){this._ondecotag(t.origin)}offdecotag(t,e){this._offdecotag(e.origin)}_ondecotag(t){this.decoTargets&&-1!==this.decoTargets.lastIndexOf(t)||(this.decoTargets=(this.decoTargets||[]).concat(t))}_offdecotag(t){if(this.decoTargets){var e=this.decoTargets.slice();e.splice(this.decoTargets.lastIndexOf(t),1),this.decoTargets=e}}_decotagreset(){this.decoTargets=[]}}mtt.register("decotag-layer",Urt),mtt.register("tag-layer",Urt);mtt.register("reaction-layer",class extends Ytt{constructor(t,e){super(t,e),this._anim_alpha=1}animOnTargetChange(t){t!==this._lastTargets&&(this._lastTargets=t,this._anim_alpha=1,this.animate({step:t=>{this._anim_alpha=1-t,this.invalidate()},duration:1e4,delta:"circ",ease:"inout"}).start())}decorate(t,e,r){const n=t.reactionDecorators;var i=!1;return n.map((t=>"string"==typeof t?htt(t):t)).filter((t=>t&&"function"==typeof t)).map((n=>{const a=n(t,e,1-r);i||=a})),i}render(t){var e=this.targets&&this.targets.filter((t=>t.rootModel));if(!e||0==e.length)return this._animate&&this._animate.stop(),void delete this._animate;t.globalAlpha*=this._anim_alpha;var r=!1;e.forEach((e=>{this.decorate(e,t,1-this._anim_alpha)&&(r=!0)})),r&&this.animOnTargetChange(this.targets)}get targets(){return this._targets}set targets(t){this._targets=t&&t.filter((t=>!t.isLayer())),this.invalidate()}get eventMap(){return{"model-layer":{"(descendant)":{reaction:this.onreaction,reactionreset:this.onreactionreset}}}}onreactionreset(t){this._reactionreset()}onreaction(t){this._onreaction(t.origin)}offreaction(t,e){this._offreaction(e.origin)}_onreaction(t){this.targets&&-1!==this.targets.lastIndexOf(t)||(this.targets=(this.targets||[]).concat(t))}_offreaction(t){if(this.targets){var e=this.targets.slice();e.splice(this.targets.lastIndexOf(t),1),this.targets=e}}_reactionreset(){this.targets=[]}});function Hrt(){var t=arguments,e=t[t.length-1],r=this.event_pump;r.listeners.forEach((n=>{!function(t,e,r,n,i){for(let a in r){let s=r[a];if(c9(a,n.origin,0,t))for(let t in s){let r=s[t];t==n.name&&(n.listener=e,r.apply(e,i))}}}(r.deliverer,n.listener,n.cloned_handlers,e,t)}))}mtt.register("scroll-layer",class extends Ytt{get capturable(){return!0}render(t){const{scrolling:e}=this.state;if(t.save(),t.beginPath(),t.fillStyle="#777",this.vscroller){const{left:r,top:n,width:i,height:a}=this.vscroller;t.globalAlpha="v"==e?1:.3,t.fillRect(r,n,i,a)}if(this.hscroller){const{left:r,top:n,width:i,height:a}=this.hscroller;t.globalAlpha="h"==e?1:.3,t.fillRect(r,n,i,a)}t.stroke(),t.restore()}resize(){super.resize(),this.calcScrollerBounds()}contains(t,e){const r=this.vscroller,n=this.hscroller;return this.setState("scrolling",r&&t>=r.left&&t<=r.left+r.width&&e>=r.top&&e<=r.top+r.height?"v":n&&t>=n.left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height?"h":null),!!this.getState("scrolling")}get eventMap(){return{"(root)":{"model-layer":{change:this.onchangeModelLayer}}}}onchange(t){"scrolling"in t&&this.invalidate()}ondragstart(t,e){this.lastPosition={x:t.offsetX,y:t.offsetY}}ondragmove(t,e){const r=this.root,{clientWidth:n,clientHeight:i}=this.canvas,{width:a,height:s}=this.rootModel.model,{x:o,y:l}={x:t.offsetX,y:t.offsetY},{x:h,y:c}=this._scale,{scrolling:u}=this.state,d=a/n,p=s/i;u&&r.rootModel.move({x:"h"==u?(-o+this.lastPosition.x)*h*d:0,y:"v"==u?(-l+this.lastPosition.y)*c*p:0},!1),this.lastPosition={x:t.offsetX,y:t.offsetY}}ondragend(){delete this.lastPosition,this.setState({scrolling:null})}calcScrollerBounds(){var{clientWidth:t,clientHeight:e}=this.canvas;const{width:r,height:n}=this.rootModel.model,{x:i=1,y:a=1}=this._scale||{},{x:s=0,y:o=0}=this._translate||{},l=r/t,h=n/e;var c={left:-s/i/l,top:e-10,width:t/i/l,height:10};this.hscroller=c.left>1||c.width+c.left<t-1?c:null,c={left:t-10,top:-o/a/h,width:10,height:e/a/h},this.vscroller=c.top>1||c.height+c.top<e-1?c:null,this.invalidate()}onchangeModelLayer(t,e,r){if(t.scale){const{x:e=1,y:r=1}=t?.scale||{};this._scale={x:e,y:r},this.calcScrollerBounds()}if(t.translate){const{x:e=0,y:r=0}=t.translate||{};this._translate={x:e,y:r},this.calcScrollerBounds()}}});class Grt{constructor(t){if(void 0===t.on)throw new Error("Deliverer should be a event handlable object.");this.deliverer=t,this.listeners=[]}start(){this.deliverer.on("(all)",Hrt,{event_pump:this})}stop(){this.deliverer.off("(all)",Hrt)}on(t,e){var r=Object.assign({},e);Object.keys(r).forEach((e=>{if(0==e.indexOf("?")){let n=r[e],i=e.substr(1),a=t.get(i);delete r[e],a?r[a]=n:H7("EventPump#on","variable #{selector} is not evaluated on listener")}})),this.listeners.push({listener:t,handlers:e,cloned_handlers:r})}off(t,e){for(let r=0;r<this.listeners.length;r++){let n=this.listeners[r];n.listener!==t||e&&n.handlers!==e||this.listeners.splice(r,1)}}clear(){this.listeners=[]}dispose(){this.stop(),this.clear()}}class Yrt{constructor(t){this.eventMaps=[],this.root=t,t.eventMap&&this.add(t,t.eventMap)}set root(t){this._root=t}get root(){return this._root}stop(){this.eventMaps.forEach((t=>t.eventPump.stop()))}add(t,e){if(this.root)for(let r in e){let n=e[r];if("(self)"===r&&void 0===t.on)throw new Error("(self) selector not available when deliverer is not a event handlable object.");p9(r,this.root,t).forEach((r=>{var i=new Grt(r);i.on(t,n),i.start(),this.eventMaps.push({eventPump:i,listener:t,handlerMap:e,deliverer:r})}))}}remove(t,e){var r=this.eventMaps.slice(0);for(let n=0;n<r.length;n++){let i=r[n];i.listener!==t||e&&i.handlerMap!==e||(this.eventMaps.splice(n,1),i.eventPump.dispose())}}clear(){this.eventMaps.slice(0).forEach((t=>t.eventPump.dispose())),this.eventMaps=[]}dispose(){this.stop(),this.clear()}}const Vrt=0,qrt=1,Xrt=2,$rt=0,Krt=1,Qrt=2;var Jrt={},Zrt=0;class tnt{constructor(t,e){this._type=e||t.type,this._ctrlKey=t.ctrlKey,this._altKey=t.altKey,this._shiftKey=t.shiftKey,this._metaKey=t.metaKey;var r=function(t){if(t.touches){let e=t.touches[0];if(!e)return Jrt;let r=e.target.getBoundingClientRect();return Jrt={x:t.offsetX||e.clientX-(r.x||r.left),y:t.offsetY||e.clientY-(r.y||r.top)}}return{x:t.offsetX,y:t.offsetY}}(t);if(this._offsetX=r.x,this._offsetY=r.y,"wheel"==t.type)this.deltaX=t.deltaX,this.deltaY=t.deltaY,this.deltaZ=t.deltaZ;else if("drop"==t.type)this.dataTransfer=t.dataTransfer;else if(t.type.match(/^touch/)&&(this._scale=t.scale,this._touches=t.touches,this._changedTouches=t.changedTouches,null==this._scale)){var n=function(t){var e,r,n=0,i=0,a=0;if(1===t.touches.length)return a;Array.from(t.touches).forEach((t=>{e=null!=e?Math.min(t.screenX,e):t.screenX,n=Math.max(t.screenX,n),r=null!=r?Math.min(t.screenY,r):t.screenY,i=Math.max(t.screenY,i)}));var s=n-e||0,o=i-r||0;return Math.sqrt(Math.pow(s,2)+Math.pow(o,2))||0}(t);Zrt>0&&(this._scale=n/Zrt),Zrt=n}}get type(){return this._type}set type(t){this._type=t}get offsetX(){return this._offsetX}get offsetY(){return this._offsetY}get altKey(){return this._altKey}get ctrlKey(){return this._ctrlKey}get shiftKey(){return this._shiftKey}get metaKey(){return this._metaKey}get touches(){return this._touches}get changedTouches(){return this._changedTouches}get scale(){return this._scale}stopPropagation(){this._stop_=!0,this.originalEvent&&"function"==typeof this.originalEvent.stopPropagation&&this.originalEvent.stopPropagation()}isPropagationStopped(){return this._stop_}preventDefault(){this._prevented=!0}isDefaultPrevented(){return this._prevented}}function ent(t,e){return t.capture(e.offsetX,e.offsetY)}function rnt(t,e,r){if(t&&t.app&&(!t.app.isViewMode||!t.hidden)){r instanceof tnt&&e===r.type||(r=new tnt(r,e));var n="on"+e;t[n]&&t[n](r),r.isPropagationStopped()||t.trigger(e,r)}}class nnt{constructor(t,e){this.container=t,this.html_element=e,this.status=Vrt,this.last_target=null,this.gesture_handlers=r9.map((t=>this.gestureHandlerBuilder(t))),this.keyevent_handlers=n9.map((t=>this.keyeventHandlerBuilder(t))),r9.forEach(((t,r)=>e.addEventListener(t,this.gesture_handlers[r])),{passive:!1}),n9.forEach(((t,r)=>e.addEventListener(t,this.keyevent_handlers[r]))),e.ondragover=this.gestureHandlerBuilder("dragover"),e.ondrop=this.gestureHandlerBuilder("drop"),e.tabIndex=1}dispose(){this.last_enter_target&&rnt(this.last_enter_target,"mouseleave",new CustomEvent("mouseleave")),r9.forEach(((t,e)=>this.html_element.removeEventListener(t,this.gesture_handlers[e]))),n9.forEach(((t,e)=>this.html_element.removeEventListener(t,this.keyevent_handlers[e]))),delete this.gesture_handlers,delete this.keyevent_handlers,delete this.last_target}gestureHandlerBuilder(t){var e=this[`on${t}`].bind(this);return t=>{const r=new tnt(t);return e(r),r.isDefaultPrevented()&&t.preventDefault(),!1}}keyeventHandlerBuilder(t){return this[`on${t}`].bind(this)}ondragover(t){return rnt(ent(this.container,t),t.type,t),!1}ondrop(t){return rnt(ent(this.container,t),t.type,t),!1}ondblclick(t){return rnt(ent(this.container,t),t.type,t),this.last_target=null,!1}onkeydown(t){return this.container.trigger(t.type,t),!1}onkeyup(t){return this.container.trigger(t.type,t),!1}onmousemove(t){switch(this.status){case qrt:let r=t.offsetX-this.__dragstart_e.offsetX,n=t.offsetY-this.__dragstart_e.offsetY;if(r*r+n*n<16)break;this.status=Xrt,rnt(this.last_target,"dragstart",this.__dragstart_e),this.__dragmove_e=t,rnt(this.last_target,"dragmove",t);break;case Xrt:this.__dragmove_e=t,rnt(this.last_target,"dragmove",t);break;default:var e=ent(this.container,t);this.last_enter_target!==e&&(this.last_enter_target&&rnt(this.last_enter_target,"mouseleave",t),e&&rnt(e,"mouseenter",t),this.last_enter_target=e),rnt(e,t.type,t),this.last_target=e}return!1}onmousedown(t){if(this.status===Xrt)rnt(this.last_target,"dragend",t),this.last_target=null,this.status=Vrt;else{var e=ent(this.container,t);this.last_target=e,this.status=qrt,this.__dragstart_e=t,rnt(e,t.type,t)}return!1}onmouseup(t){if(this.status===Xrt)rnt(this.last_target,"dragend",t);else{var e=ent(this.container,t);rnt(e,t.type,t),this.last_target===e&&rnt(e,"click",t)}return this.last_target=null,this.status=Vrt,!1}onmouseout(t){var e=ent(this.container,t);if(this.status===Xrt)rnt(this.last_target,"dragend",t);else{if(this.last_target&&this.last_target===e)return;this.last_enter_target&&(rnt(this.last_enter_target,"mouseleave",t),delete this.last_enter_target)}return this.last_target=null,this.status=Vrt,!1}ontouchstart(t){var e=ent(this.container,t);return this.last_target=e,this.status=Krt,this.touchPoints||(this.touchPoints=[]),this.touchPoints.push(t.changedTouches[0]),this.holdTimer=setTimeout((()=>{this.status=$rt,rnt(this.last_target,"hold",t),delete this.holdTimer}),500),rnt(e,t.type,t),!1}ontouchmove(t){if(!t.touches||!t.changedTouches)return rnt(this.last_target,"dragstart",t),rnt(this.last_target,"dragmove",t),!1;var e=ent(this.container,t);switch(this.status){case Krt:Array.from(t.changedTouches).forEach((t=>{var e=this.touchPoints.find((e=>e.identifier===t.identifier));if(e){var r=e.clientX-t.clientX,n=e.clientY-t.clientY;return Math.sqrt(Math.pow(r,2)+Math.pow(n,2))>=16?(this.status=Qrt,void(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer))):void 0}}));break;case Qrt:if(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer),2===t.changedTouches.length&&null!=t.scale&&1!==t.scale&&(t.scale<.9||t.scale>1.1))return rnt(this.last_target,"pinch",t),!1;rnt(this.last_target,"pan",t),e=this.last_target;break;default:this.last_enter_target!==e&&(this.last_enter_target&&rnt(this.last_enter_target,"mouseleave",t),e&&rnt(e,"mouseenter",t),this.last_enter_target=e),this.last_target=e}return rnt(e,"touchmove",t),!1}ontouchend(t){var e=ent(this.container,t);switch(this.status){case Qrt:e=this.last_target;break;case Krt:var r=performance.now(),n=r-this.touchedAt;this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer,rnt(e,n<500?"doubletap":"tap",t),this.touchedAt=r)}rnt(e,"touchend",t);var i=this.touchPoints.findIndex((e=>e.identifier===t.changedTouches[0].identifier));return this.touchPoints.splice(i,1),this.last_target=null,this.status=$rt,!1}onwheel(t){return rnt(ent(this.container,t),t.type,t),!1}}function int(t,e,r,n=0){if(e.length<2)return e;let i=2;for(;i<e.length;i++){const a=e.substring(0,i);if(!(t.measureText(a).width+(a.length-1)*n<r))break}return e.substring(0,i-1)}function ant(t,e,r,n,i=0){const a=String(e).split("\n");return n?[].concat.apply([],a.map((e=>function(t,e,r,n=0){const i=e.split(" "),a=[];let s,o,l=[];for(s=0,o=1;o<=i.length;o++)if(l=i.slice(s,o),t.measureText(l.join(" ")).width+(l.join("").length-1)*n>r){if(o-s==1){const e=int(t,l[0],r,n);a.push([e]),i.splice(s,1,e,l[0].substring(e.length))}else{for(;""==i[o-1];)o++;a.push(i.slice(s,--o))}s=o}return o-s>1&&a.push(l),0==a.length&&a.push([""]),a}(t,e,r,i)))):a.map((t=>t.split(" ")))}var snt={},ont={};const lnt=()=>{};var hnt={register:function(t,e,r){snt[t]=e,r&&(ont[t]=r)},unregister:function(t){delete snt[t],delete ont[t]},get:function(t){return snt[t]},getDisposer:function(t){return ont[t]||lnt}};function cnt(t){if(!t.hasTextProperty||t.textHidden)return;var{text:e="",bold:r=i9.BOLD,italic:n=i9.ITALIC,textWrap:i=i9.TEXT_WRAP,letterSpacing:a=0,fontFamily:s=i9.FONT_FAMILY,fontColor:o=i9.FONT_COLOR,textAlign:l=i9.TEXT_ALIGN,textBaseline:h=i9.TEXT_BASELINE,fontSize:c=i9.FONT_SIZE,lineHeight:u=1.2*c}=t.model,{left:d,top:p,width:f,height:g}=t.textBounds;c||=i9.FONT_SIZE,u||=1.2*c,t.textHidden=!0;var v=document.createElement("textarea");r9.forEach((function(t){v.addEventListener(t,(function(t){t.stopPropagation()}),!0)}));const m=t.transcoordS2C(d,p),{rotation:y,scale:b}=function(t){for(var e=0,r=1,n=t;n;){e+=n.get("rotation")||0;let{x:t,y:i}=n.get("scale")||{x:1,y:1};r*=Math.max(t,i)||1,n=n.parent}return{rotation:e,scale:r}}(t);switch(v.style.position="absolute",v.style.width=f+"px",v.style.height=g+"px",v.style.padding="0",v.value=e,v.style.fontFamily=s,v.style.fontSize=c+"px",v.style.lineHeight=u+"px",v.style.overflow="hidden",v.style.resize="none",v.style.outline="none",v.style.border=0,v.style.backgroundColor="transparent",v.style.display="inline-block",v.style.color=o,r&&(v.style.fontWeight="bold"),n&&(v.style.fontStyle="italic"),l){case"right":case"end":v.style.textAlign="right";break;case"justify":v.style.textAlign="justify";break;case"left":case"start":v.style.textAlign="left";break;default:v.style.textAlign="center"}var w=[r,n,c+"px",s].filter(Boolean).join(" ");function x(e){var r={left:0,top:0},n=u*function(t,e,r,n,i=0){var a,s=t.getContext();return s.save(),s.font=r,a=ant(s,e,n,t.get("textWrap"),i).length,s.restore(),a}(t,e,w,f,a);switch(v.style.height=n+"px",h){case"top":case"hanging":break;case"bottom":case"alphabetic":r.top=g-n;break;default:r.top=g/2-n/2}if(!i){var s=function(t,e,r,n){var i=e.split("\n"),a=n;let s=t.getContext();return s.save(),s.font=r,i.forEach((t=>{let e=s.measureText(t).width;e>a&&(a=e)})),s.restore(),a}(t,e,w,f);switch(v.style.width=s+"px",l){case"right":case"end":r.left=f-s;break;case"left":case"start":break;default:r.left=(f-s)/2}}v.style.marginLeft=r.left+"px",v.style.marginTop=r.top+"px",v.style.transform=`translate(${m.x}px, ${m.y}px) scale(${b}) rotate(${y}rad)`,v.style.transformOrigin=`${-r.left}px ${-r.top}px`}x(e);var A=t.root.target_element;A.appendChild(v),v.select();var _,k=!1;v.addEventListener("keydown",(function(t){t.stopPropagation(),"Escape"!=t.code&&(t.shiftKey||"Enter"!=t.code&&"NumpadEnter"!=t.code)?setTimeout((()=>{x(v.value)})):(k=_.skipUpdate="Escape"==t.code,document.createEvent?v.dispatchEvent(_):v.fireEvent(_.eventType,_))})),document.createEvent?(_=document.createEvent("HTMLEvents")).initEvent("blur",!0,!1):(_=document.createEventObject()).eventType="blur";var S=t.root.selected,E=function(r){t.root.selected=S,t.textHidden=!1,v.removeEventListener("blur",E,!1),v.parentElement&&v.parentElement.removeChild(v),A.focus(),r.skipUpdate||k||t.app.commander.execute(new vet({changes:[{component:t,before:{text:e},after:{text:v.value}}]}))};v.addEventListener("blur",E,!1)}hnt.register("text-editor",{"(root)":{"(self)":{keydown:function(t,e){var{origin:r,deliverer:n}=e,i=n.selected;return!(1!==i.length||!i[0].hasTextProperty)&&(("Enter"==t.code||"NumpadEnter"==t.code)&&(cnt(i[0]),t.preventDefault(),!0))}}},"model-layer":{"(descendant)":{dblclick:function(t,e){cnt(e.origin)}}}});var unt,dnt,pnt,fnt=x7((function(t,e,r){if(t.hasSameParentForAllSelected&&!r){var n=[];e[0].parent.isGroup()?t.focused=e[0].parent:(e.forEach((t=>{t.path.forEach((e=>{n.push(t.transcoordS2T(e.x,e.y))}))})),t.focused=t.capturePath(n,e))}else t.focused=null}),300);hnt.register("move-handler",{"model-layer":{"(descendant)":{dragstart:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected,a=n.selected.filter((t=>!t.stuck));if(i.length!==a.length&&(i=n.selected=a),0!=i.length){var s=i[0].transcoordC2S(t.offsetX,t.offsetY);if(s=i[0].transcoordS2P(s.x,s.y),this.last_pos=s,this.direction=0,n.focused=i[0].parent,t.altKey){var o=[],l=new Map;n.selected=n.selected.filter((t=>!t.isRootModel())).map((t=>{let e=Oet(t,(t=>{const e=n.root.getNewRefid();return void 0!==t&&l.set(t,e),e}));return o.push({component:e,to_container:t.parent}),e})).map((t=>(t.replaceRefids(l),t))),o.forEach((({component:t,to_container:e})=>{e.addComponent(t)})),this.duplicates=n.selected.map((t=>({component:t})))}else this.changes=vet.before(i)}}},dragmove:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected;if(0!=i.length){var{x:a,y:s}=i[0].transcoordC2S(t.offsetX,t.offsetY),o=i[0].transcoordS2P(a,s);t.shiftKey?2==this.direction&&(this.direction=0):this.direction=2;var l=o.x-this.last_pos.x,h=o.y-this.last_pos.y;if(0==this.direction){if(l*l+h*h<25)return;Math.abs(l)>Math.abs(h)?this.direction=3:this.direction=4}3==this.direction?h=0:4==this.direction&&(l=0),i.forEach((t=>{t.move({x:l,y:h},1===i.length)})),this.last_pos=o,fnt(n,i)}}},dragend:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected;if(0!=i.length){var a=i[0].parent,s=n.focused||e.deliverer;if(this.changes&&!s.isGroup())if(n.hasSameParentForAllSelected&&s&&s!==a){var o=this.changes.map((t=>{let{component:e,before:r}=t;return{component:e,to_container:s}}));n.app.commander.execute(new Cet({changes:o}))}else vet.after(this.changes,n.app.commander);else if(this.duplicates){this.duplicates=this.duplicates.map((t=>(t.to_container=s,t)));let t=new Cet({changes:this.duplicates});n.app.commander.execute(t)}i.forEach((t=>{t.parent&&t.parent.calculateBounds&&t.parent.calculateBounds()})),this.last_pos=null,this.changes=null,this.duplicates=null,fnt(n,i,!0)}}}}},"(root)":{"(self)":{keydown:function(t,e){var{origin:r,deliverer:n}=e,i={},a=t.shiftKey?r.rootModel.MPP:1;switch(t.which){case 37:i.x=-a,i.y=0;break;case 38:i.x=0,i.y=-a;break;case 39:i.x=a,i.y=0;break;case 40:i.x=0,i.y=a;break;default:return}var s=n.selected;vet.around(n.app.commander,(function(){s.forEach((t=>{!t.stuck&&t.move(i,!1)}))}))}}}});const gnt=A7((()=>{const{x:t,y:e}=pnt,r=dnt.deref();r&&(r.rootModel.move({x:t-unt.x,y:e-unt.y},!1),unt={x:t,y:e})}),60,{leading:!0,trailing:!0});hnt.register("shift-handler",{"model-layer":{"(all)":{dragstart:function(t,e){unt={x:t.offsetX,y:t.offsetY}},dragmove:function(t,e){dnt=new WeakRef(e.deliverer),pnt={x:t.offsetX,y:t.offsetY},gnt()}}}}),hnt.register("zoom-handler",{"model-layer":{"(all)":{wheel:function(t,e){if(0==t.deltaY&&0==t.deltaX)return;var r=e.deliverer,n=t.deltaY<0?1:-1;let i=r.get("scale")||{x:1,y:1},a=r.get("translate"),s=t.offsetX,o=t.offsetY,l=r.transcoordC2S(s,o),h=.1*n,c={x:i.x+h,y:i.y+h};if(n<0&&i.x<.2||n>0&&i.x>10)return;r.set("scale",c);let u=r.transcoordC2S(s,o);r.set("translate",{x:a.x+(u.x-l.x)*c.x,y:a.y+(u.y-l.y)*c.y})}},"(self)":{dblclick:function(t,e){const r=e.origin;r?.root.fit()}}}});var vnt={},mnt={};function ynt(t){const e={};for(const r in t)t.hasOwnProperty(r)&&void 0!==t[r]&&(e[r]=t[r]);return e}function bnt(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}function wnt(t,e,r,n,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void r(t)}o.done?e(l):Promise.resolve(l).then(n,i)}function xnt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function s(t){wnt(a,n,i,s,o,"next",t)}function o(t){wnt(a,n,i,s,o,"throw",t)}s(void 0)}))}}function Ant(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _nt(t,e){return t.get(bnt(t,e))}function knt(t,e,r){Ant(t,e),e.set(t,r)}function Snt(t,e,r){return t.set(bnt(t,e),r),r}function Ent(t,e,r){return r(bnt(t,e))}function Mnt(t,e){Ant(t,e),e.add(t)}function Tnt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Cnt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Pnt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Cnt(Object(r),!0).forEach((function(e){Tnt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Cnt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Int(t,e,r){e||(e=[]);var n=e.length++;return Object.defineProperty({},"_",{set:function(i){e[n]=i,t.apply(r,e)}})}hnt.register("paste-handler",{"(root)":{"(self)":{stylepastestart:function(t){const{deliverer:e}=t,r=e.app;var n=e.selected;if(n&&n[0]&&n!==e.rootModel){const t=n[0],{fillStyle:e,strokeStyle:i,alpha:a,lineWidth:s,lineDash:o,lineCap:l,lineJoin:h,fontColor:c,fontSize:u,fontFamily:d,bold:p,italic:f,textAlign:g,textBaseline:v,textOverflow:m,paddingTop:y,paddingBottom:b,paddingLeft:w,paddingRight:x}=t.state;vnt=h7({fillStyle:e,strokeStyle:i,alpha:a,lineWidth:s,lineDash:o,lineCap:l,lineJoin:h,fontColor:c,fontSize:u,fontFamily:d,bold:p,italic:f,textAlign:g,textBaseline:v,textOverflow:m,paddingTop:y,paddingBottom:b,paddingLeft:w,paddingRight:x}),r.mode=4}},stylepastestop:function(t){const{deliverer:e}=t,r=e.app;vnt={},4==r.mode&&(r.mode=1)},databindpastestart:function(t){const{deliverer:e}=t,r=e.app;var n=e.selected;if(n&&n[0]&&n!==e.rootModel){const t=n[0],{mappings:e}=t.state;mnt=h7({mappings:e}),r.mode=5}},databindpastestop:function(t){const{deliverer:e}=t,r=e.app;mnt={},5==r.mode&&(r.mode=1)},keydown:function(t,e){const{deliverer:r}=e;"Esc"!=t.code&&"Escape"!=t.code||(4==r.app.mode?r.trigger("stylepastestop"):5==r.app.mode&&r.trigger("databindpastestop"))}}},"model-layer":{"(all)":{click:function(t,e){const{deliverer:r}=e,n=r.app;if(4!=n.mode&&5!=n.mode)return;const i=e.origin;4==n.mode?i===r?r.root.trigger("stylepastestop"):i&&vet.around(n.commander,(()=>{const t=ynt({...i.model,...vnt});i?.set(t)})):i===r?r.root.trigger("databindpastestop"):i&&vet.around(n.commander,(()=>{const t=ynt({...i.model,...mnt});i?.set(t)}))}}}});class Rnt{constructor(t,e,r){Tnt(this,"_delta",{theta:0,tx:0,ty:0,sx:1,sy:1,fade:0}),Tnt(this,"_location",null);const{animations:n,...i}=r;this.overlay=t,this.target=e,this.decorator=i||{},this.animations=[],Array.isArray(n)?this.animations=n.map((t=>("theta"in t&&(t={...t,theta:t.theta*(Math.PI/180)}),L8(this,t)))):n&&("theta"in n&&(n={...n,theta:n.theta*(Math.PI/180)}),this.animations=[L8(this,n)])}delta(t,e){if(void 0===e)return t?this._delta[t]:this._delta;this._delta[t]=e;const{tx:r,ty:n,sx:i,sy:a,theta:s,fade:o}=this._delta;Object.assign(this.element.style,{opacity:1-o,transform:`rotate(${s}rad) translate(${r}px, ${n}px) scale(${i}, ${a}) perspective(1px)`})}get location(){if(this._location)return this._location;const{location:t,size:e}=this.decorator,{left:r,top:n,width:i,height:a}=this.target.bounds;let s;switch(t){case"top-left":s={x:r,y:n-e};break;case"top":s={x:r+(i-e)/2,y:n-e};break;case"top-right":s={x:r+i-e,y:n-e};break;case"bottom-left":s={x:r,y:n+a};break;case"bottom":s={x:r+(i-e)/2,y:n+a};break;case"bottom-right":s={x:r+i-e,y:n+a};break;case"left":s={x:r-e,y:n+(a-e)/2};break;case"right":s={x:r+i,y:n+(a-e)/2};break;default:s={x:r+i/2-e/2,y:n+a/2-e/2}}return this._location=this.target.transcoordS2T(s.x,s.y),this._location}get element(){if(!this._element){const{icon:t,size:e,color:r}=this.decorator,{x:n,y:i}=this.location,a=document.createElement("div");a.setAttribute("scene","animated-icon"),Object.assign(a.style,{position:"absolute",fontVariationSettings:"'FILL' 1",fontFamily:"Material Symbols Outlined",fontSize:e+"px",width:e+"px",height:e+"px",lineHeight:e+"px",padding:0,margin:0,color:r,textAlign:"center",verticalAlign:"middle",left:n+"px",top:i+"px",pointerEvents:"none"}),a.textContent=t,this._element=a}return this._element}touch(){}invalidate(){}start(){this.overlay.appendChild(this.element),this.animations.forEach((t=>t.start()))}stop(){this.overlay.removeChild(this.element),this.animations.forEach((t=>t.stop())),this._location=null}get root(){return this.target.root}get center(){const{size:t}=this.decorator,{x:e,y:r}=this.location;return{x:e+t/2,y:r+t/2}}transcoordS2T(t,e){const{tx:r,ty:n}=this._delta;return{x:t+r,y:e+n}}}class Ont{static getTargetId(t){if(!Ont._targetIdMap.has(t)){const e=`target-${Math.random().toString(36).substring(2,9)}`;Ont._targetIdMap.set(t,e)}return Ont._targetIdMap.get(t)}static getSvgContainer(t){if(!Ont._svgMap.has(t)){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","border-highlighting-container"),e.setAttribute("pointer-events","none"),e.style.overflow="visible",e.style.position="absolute",e.style.top="0",e.style.left="0";const r=document.createElementNS("http://www.w3.org/2000/svg","defs");e.appendChild(r);const n=document.createElementNS("http://www.w3.org/2000/svg","g");n.setAttribute("class","border-highlighting-group"),e.appendChild(n),t.appendChild(e),Ont._svgMap.set(t,e)}return Ont._svgMap.get(t)}constructor(t,e,r){this.overlayRef=new WeakRef(t),this.target=e,this.decorator=r}get element(){const t=this.overlayRef.deref();if(!t)return null;const{distance:e=10,lineWidth:r=2,color:n="red",animation:i=!1,fillStyle:a}=this.decorator||{},{round:s=0,fillStyle:o}=this.target.state,l=this.target.path.map((t=>this.target.transcoordS2T(t.x,t.y))),h=this.createOffsetPath(l,e),c=this.pointsToPathData(h,s),u=Ont.getSvgContainer(t),d=Ont.getTargetId(this.target),p=u.querySelector(".border-highlighting-group"),f=p.querySelector(`[data-target-id="${d}"]`);f&&f.remove();const g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d",c),g.setAttribute("fill","none"),g.setAttribute("stroke-width",r),g.setAttribute("stroke-linejoin","round"),g.setAttribute("pointer-events","none"),g.setAttribute("data-target-id",d);const v=a||o||"rgba(0, 0, 0, 0.5)",m=u.querySelector("defs"),y=this.createFilter(d,v);if(m.appendChild(y),g.setAttribute("filter",`url(#${d}-filter)`),i){const t=u.querySelector("defs"),e=this.createGradient(d,n);t.appendChild(e),g.setAttribute("stroke",`url(#${d})`)}else g.setAttribute("stroke",n);return p.appendChild(g),g}createOffsetPath(t,e){const r=[],n=t.length;for(let i=0;i<n;i++){const a=t[(i-1+n)%n],s=t[i],o=t[(i+1)%n],l=s.x-a.x,h=s.y-a.y,c=o.x-s.x,u=o.y-s.y,d=this.normalize({x:h,y:-l}),p=this.normalize({x:u,y:-c}),f=this.normalize({x:(d.x+p.x)/2,y:(d.y+p.y)/2}),g={x:s.x+f.x*e,y:s.y+f.y*e};r.push(g)}return r}normalize(t){const e=Math.sqrt(t.x*t.x+t.y*t.y);return{x:t.x/e,y:t.y/e}}pointsToPathData(t,e=0){if(t.length<2)return"";let r="";const n=t.length,i=(t,e,r)=>{const n=e.x-t.x,i=e.y-t.y,a=Math.sqrt(n*n+i*i);return{x:t.x+n/a*r,y:t.y+i/a*r}};for(let a=0;a<n;a++){const s=t[a],o=t[(a+1)%n],l=t[(a-1+n)%n],h=Math.sqrt((s.x-l.x)**2+(s.y-l.y)**2),c=Math.sqrt((s.x-o.x)**2+(s.y-o.y)**2),u=Math.min(e,h/2,c/2),d=i(s,l,u),p=i(s,o,u);r+=0===a?`M${d.x},${d.y}`:` L${d.x},${d.y}`,r+=` Q${s.x},${s.y} ${p.x},${p.y}`}return r+=" Z",r}createFilter(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","filter");r.setAttribute("id",`${t}-filter`);const n=document.createElementNS("http://www.w3.org/2000/svg","feFlood");n.setAttribute("flood-color",e),n.setAttribute("result","flood");const i=document.createElementNS("http://www.w3.org/2000/svg","feComposite");i.setAttribute("in","flood"),i.setAttribute("in2","SourceAlpha"),i.setAttribute("operator","in"),i.setAttribute("result","mask");const a=document.createElementNS("http://www.w3.org/2000/svg","feMerge"),s=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");s.setAttribute("in","mask");const o=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");return o.setAttribute("in","SourceGraphic"),a.appendChild(s),a.appendChild(o),r.appendChild(n),r.appendChild(i),r.appendChild(a),r}createGradient(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");r.setAttribute("id",t),r.setAttribute("x1","0%"),r.setAttribute("y1","0%"),r.setAttribute("x2","100%"),r.setAttribute("y2","0%");const n=this.alterColor(e,120),i=this.alterColor(e,240);return r.innerHTML=`\n <stop offset="0%" stop-color="${e}">\n <animate attributeName="stop-color" values="${e};${n};${i};${e}" dur="5s" repeatCount="indefinite" />\n </stop>\n <stop offset="100%" stop-color="${i}">\n <animate attributeName="stop-color" values="${i};${e};${n};${i}" dur="5s" repeatCount="indefinite" />\n </stop>\n `,r}alterColor(t,e){const r=this.convertToHex(t);let n=parseInt(r.substring(1,3),16),i=parseInt(r.substring(3,5),16),a=parseInt(r.substring(5,7),16);const s=this.rgbToHsl(n,i,a);s[0]=(s[0]+e/360)%1;const o=this.hslToRgb(s[0],s[1],s[2]);return`#${o[0].toString(16).padStart(2,"0")}${o[1].toString(16).padStart(2,"0")}${o[2].toString(16).padStart(2,"0")}`}rgbToHsl(t,e,r){t/=255,e/=255,r/=255;let n,i,a=Math.max(t,e,r),s=Math.min(t,e,r),o=(a+s)/2;if(a===s)n=i=0;else{let l=a-s;switch(i=o>.5?l/(2-a-s):l/(a+s),a){case t:n=(e-r)/l+(e<r?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return[n,i,o]}hslToRgb(t,e,r){let n,i,a;if(0===e)n=i=a=r;else{const s=(t,e,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t);let o=r<.5?r*(1+e):r+e-r*e,l=2*r-o;n=s(l,o,t+1/3),i=s(l,o,t),a=s(l,o,t-1/3)}return[Math.round(255*n),Math.round(255*i),Math.round(255*a)]}convertToHex(t){if(/^#([0-9A-F]{6})$/i.test(t))return t;const e=document.createElement("div");e.style.color=t,document.body.appendChild(e);const r=window.getComputedStyle(e).color;document.body.removeChild(e);const n=r.match(/\d+/g);return!n||n.length<3?(console.warn(`Invalid color: ${t}. Defaulting to #FF0000.`),"#FF0000"):`#${n.slice(0,3).map((t=>parseInt(t,10).toString(16).padStart(2,"0"))).join("")}`}start(){const t=this.overlayRef.deref();if(!t)return;const e=Ont.getSvgContainer(t);t.contains(e)||t.appendChild(e);const r=this.element;if(r&&this.decorator.animation){const t=r.getAttribute("data-target-id");if(!t)return;const n=e.querySelector("defs");if(!n)return;const i=n.querySelector(`#${t}`);if(!i)return;requestAnimationFrame((()=>{i.querySelectorAll("animate").forEach((t=>{t.beginElement()}))}))}}stop(){if(!this.element)return;const t=this.overlayRef.deref();if(!t)return;const e=Ont._svgMap.get(t);if(!e)return;const r=e.querySelector(".border-highlighting-group");if(!r)return;const n=e.querySelector("defs");if(!n)return;const i=Ont.getTargetId(this.target),a=r.querySelector(`[data-target-id="${i}"]`);if(a){r.removeChild(a),a.remove();const t=n.querySelector(`#${i}`);t&&(n.removeChild(t),t.remove())}Ont._targetIdMap.delete(this.target),0===r.children.length&&(e.remove(),Ont._svgMap.delete(t))}}Tnt(Ont,"_svgMap",new WeakMap),Tnt(Ont,"_targetIdMap",new WeakMap);class Lnt{static getArrowId(t){if(!Lnt._arrowIdMap.has(t)){const e=`${Math.random().toString(36).substring(2,9)}`;Lnt._arrowIdMap.set(t,e)}return Lnt._arrowIdMap.get(t)}static getSvgContainer(t){if(!Lnt._svgMap.has(t)){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","bouncing-arrow-container"),e.setAttribute("pointer-events","none"),e.style.overflow="visible",e.style.position="absolute",e.style.top="0",e.style.left="0";const r=document.createElementNS("http://www.w3.org/2000/svg","g");r.setAttribute("class","bouncing-arrow-group"),e.appendChild(r),t.appendChild(e),Lnt._svgMap.set(t,e)}return Lnt._svgMap.get(t)}constructor(t,e,r){this.overlayRef=new WeakRef(t),this.target=e,this.decorator=r}get element(){const t=this.overlayRef.deref();if(!t)return null;const e=Lnt.getSvgContainer(t).querySelector(".bouncing-arrow-group"),r=Lnt.getArrowId(this.target),n=e.querySelector(`[data-arrow-id="${r}"]`);n&&n.remove();let{left:i,top:a,width:s}=this.target.bounds,{x:o,y:l}=this.target.transcoordS2T(i+s/2,a);o=Math.max(o,20),l=Math.max(l,20);const{color:h="red",duration:c=5e3,repeat:u=!0}=this.decorator||{},d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("d",this.createArrowPath(o,l)),d.setAttribute("fill",h),d.setAttribute("data-arrow-id",r),d.appendChild(this.createBounceAnimation(r,c,u)),e.appendChild(d);const p=this.createArrowLabel(o,l,h,this.target.state.id,r);return p&&(p.appendChild(this.createBounceAnimation(r,c,u)),e.appendChild(p)),d}createArrowPath(t,e){return`\n M${t-10},${e-16} \n L${t+10},${e-16} \n L${t+10},${e-8} \n L${t+16},${e-8} \n L${t},${e} \n L${t-16},${e-8} \n L${t-10},${e-8} \n Z\n `}createBounceAnimation(t,e,r){const n=document.createElementNS("http://www.w3.org/2000/svg","animateTransform");n.setAttribute("id",t),n.setAttribute("attributeName","transform"),n.setAttribute("type","translate");const i=e||5e3;let a=["0,-10"],s=[0];for(let t=1;t<=20;t++){const e=t/20;let r=Math.pow(e,.5);if(r=Math.min(r,.99).toFixed(3),parseFloat(s[s.length-1])>=parseFloat(r)&&(r=(parseFloat(s[s.length-1])+.01).toFixed(3)),a.push("0,0"),a.push("0,-10"),r>=1){s.push(1),s.push((parseFloat(1)+.01).toFixed(3));break}s.push(r),s.push((parseFloat(r)+.01).toFixed(3))}return s[s.length-1]="1.000",n.setAttribute("values",a.join(";")),n.setAttribute("keyTimes",s.join(";")),n.setAttribute("dur",`${i}ms`),r?n.setAttribute("repeatCount","indefinite"):(n.setAttribute("repeatCount","1"),n.addEventListener("endEvent",(()=>this.stop()))),n}createArrowLabel(t,e,r,n,i){if(!n)return null;const a=document.createElementNS("http://www.w3.org/2000/svg","g");a.setAttribute("data-arrow-label",i);const s=document.createElementNS("http://www.w3.org/2000/svg","rect");s.setAttribute("x",t+20),s.setAttribute("y",e-20),s.setAttribute("width","40"),s.setAttribute("height","20"),s.setAttribute("rx","3"),s.setAttribute("fill",r);const o=document.createElementNS("http://www.w3.org/2000/svg","text");return o.setAttribute("x",t+40),o.setAttribute("y",e-6),o.setAttribute("fill","white"),o.setAttribute("font-size","12px"),o.setAttribute("text-anchor","middle"),o.textContent=n,a.appendChild(s),a.appendChild(o),a}start(){const t=this.overlayRef.deref();if(!t)return;const e=Lnt.getSvgContainer(t),r=this.element;if(!r)return;const n=r.querySelector("animateTransform");n&&n.beginElement();const i=e.querySelector(`[data-arrow-label="${Lnt.getArrowId(this.target)}"]`);if(i){const t=i.querySelector("animateTransform");t&&t.beginElement()}}stop(){const t=this.overlayRef.deref();if(!t)return;const e=Lnt._svgMap.get(t);if(!e)return;const r=e.querySelector(".bouncing-arrow-group");if(!r)return;const n=Lnt.getArrowId(this.target),i=r.querySelector(`[data-arrow-id="${n}"]`),a=r.querySelector(`[data-arrow-label="${n}"]`);i&&(r.removeChild(i),i.remove()),a&&(r.removeChild(a),a.remove()),0===r.children.length&&(e.remove(),Lnt._svgMap.delete(t))}}Tnt(Lnt,"_svgMap",new WeakMap),Tnt(Lnt,"_arrowIdMap",new WeakMap);class Dnt{icon(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new Rnt(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}border(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new Ont(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}bouncing(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new Lnt(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}off(t){if(!this.targets)return;let e=this.targets.slice(),r=this.animators.slice(),n=this.targets.lastIndexOf(t);if(-1==n)return;e.splice(n,1);const i=r.splice(n,1);i[0]?.stop(),this.targets=e,this.animators=r}reset(t){this.animators?.forEach((t=>t.stop())),this.targets=[],this.animators=[]}}hnt.register("animator-handler",{"model-layer":{"(descendant)":{icon:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new Dnt,n.animatorHandler=i),i.icon(r,t)},border:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new Dnt,n.animatorHandler=i),i.border(r,t)},bouncing:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new Dnt,n.animatorHandler=i),i.bouncing(r,t)},animatoroff:function(t){const{origin:e}=t,r=e.root,{animatorHandler:n}=r;n?n.off(e):console.warn("animator-handler not found")},animatorreset:function(t){const{origin:e}=t,r=e.root,{animatorHandler:n}=r;n?.reset()}}}},(function(t){const{animatorHandler:e}=t;e?.reset(),delete t.animatorHandler}));var Fnt=[],Nnt=x7((function(){Fnt.forEach((t=>{t.resize()}))}),100);"undefined"!=typeof window&&window.addEventListener("resize",Nnt);class jnt extends Gtt{constructor(t,e){super(Object.assign({type:"root",scale:{x:1,y:1}},t||{}),e),this._maxRefid=e.isViewMode?1e6:0,t=t||{},this.fitMode=t.model&&t.model.fitMode,this._app=e,this.style=t.style,this.target_element=t.target_element,this.rebuildContentModel(this.model.model),Fnt.push(this)}dispose(){Rtt.hideAll(this),this._app&&this._app.dispose(),super.dispose(),this._disposeAllResources(),this.target_element=null,delete this._refresh_mapping_debouncer;var t=Fnt.indexOf(this);t>=0&&Fnt.splice(t,1),this.refidIndexMap.clear(),this._maxRefid=0}isRoot(){return!0}get app(){return this._app}get target_element(){return this._target_element}set target_element(t){this._ua_event_handler&&(this._ua_event_handler.dispose(),delete this._ua_event_handler),t&&(t.setAttribute("root-element",""),t.style.position="absolute",t.style.cursor="default",t.style.overflow="hidden",this._ua_event_handler=new nnt(this,t)),this.forEach((e=>e.target=t)),this._target_element=t}get unitScale(){switch(this.model_layer&&this.model_layer.get("unit")){case"mm":case"cm":case"in":return this.app.PPM/10;default:return 1}}addTemplate(t,e){var r=this.templateMap[t];r&&U7("Template replaced (duplicated)",t,e,r),this.templateMap[t]=e,delete this.templatePrefixes}removeTemplate(t,e){var r=this.templateMap[t];r!==e?H7("Removing template failed (different)",t,e,r):delete this.templateMap[t],delete this.templatePrefixes}findTemplateFor(t){this.templatePrefixes||(this.templatePrefixes=Object.keys(this.templateMap).sort().reverse());var e=this.templatePrefixes.find((e=>t.startsWith(e)));if(e)return this.templateMap[e]}addIndex(t,e){var r=this.indexMap[t]||[];this.indexMap[t]=[...r,e]}removeIndex(t,e){const r=this.indexMap[t]||[],n=r.indexOf(e);-1==n?H7("Removing index failed (not found)",t,e):(r.splice(n,1),0==r.length&&delete this.indexMap[t])}addRefidIndex(t,e){null==t&&(t=this.getNewRefid(),e.set("refid",t)),this._maxRefid=Math.max(t,this._maxRefid);var r=this.refidIndexMap.get(t);r&&U7("Refid Index replaced (has not to be)",t,e,r),this.refidIndexMap.set(t,e)}removeRefidIndex(t,e){if(null!=t){var r=this.refidIndexMap.get(t);r!==e?U7("Refid Removing index failed (has not to be)",t,e,r):this.refidIndexMap.delete(t)}}getNewRefid(){return this._maxRefid=(this._maxRefid||0)+1,this._maxRefid}async subscribe(t,e){this._app.isViewMode&&t&&this._app&&(e._subscription=await this._app.subscribe(t,e))}async unsubscribe(t,e){e._subscription&&(await e._subscription.unsubscribe(),delete e._subscription)}findById(t){return(this.indexMap[t.replace(/^#/,"")]||[])[0]}findAllById(t){return this.indexMap[t.replace(/^#/,"")]||[]}findByRefid(t){return this.refidIndexMap.get(t)}findOrCreate(t){var e=this.findAllById(t);if(!e&&this.app&&!this.app.isEditMode){let e=this.findTemplateFor(t);if(e){let r=Object.assign(h7(e.hierarchy),{id:t,templatePrefix:""});return component=Ret(r,this.app),this.model_layer.addComponent(component),[component]}}return e}resize(){this.components.forEach((t=>{t.resize&&t.resize()})),this.invalidate()}_disposeAllResources(){this.selected=[],this._focused=null,this._ready=!1,this.eventEngine&&(this.assist_handlers&&this.assist_handlers.forEach((t=>{this.eventEngine.remove(t)})),this.eventEngine.dispose(),delete this.eventEngine),(this.model.handlers||[]).map((t=>{hnt.getDisposer(t).call(null,this)})),this.assist_layers&&this.assist_layers.forEach((t=>{t.dispose(),this.removeComponent(t)})),delete this.assist_layers,this.model_layer&&this.model_layer.dispose(),this.model_layer&&this.removeComponent(this.model_layer),delete this.model_layer,this.indexMap={},this.refidIndexMap=new Map,this.templateMap={}}rebuildContentModel(t){this._disposeAllResources(),this.eventEngine=new Yrt(this),(t=t||{}).type="model-layer",this.model_layer=Ret(t,this.app),this.addComponent(this.model_layer),this.model_layer.target=this.target_element,this.assist_layers=(this.model.layers||[]).map((t=>{var e=Ret(t,this.app);return this.addComponent(e),e.target=this.target_element,e})),this.assist_handlers=(this.model.handlers||[]).map((t=>{var e={};return this.eventEngine.add(e,hnt.get(t)),e})),this._ready=!0,this.traverse((t=>t.ready()))}get root(){return this}get anchors(){}get isReady(){return this._ready}get rootModel(){return this.model_layer}get stuck(){return!0}get data(){return Object.values(this.indexMap).reduce(((t,[e])=>(t[e.model.id]=e.data,t)),{})}set data(t){for(var e in t){var r=this.findOrCreate(e);r&&r.forEach((r=>r.data=t[e]))}}get dataByRefid(){var t={};for(let[e,r]of this.refidIndexMap.entries())t[e]=r.data;return t}set dataByRefid(t){for(var e in t){var r=this.findByRefid(Number(e));r&&(r.data=t[e])}}get values(){return Object.values(this.indexMap).reduce(((t,[e])=>(t[e.model.id]=e.value,t)),{})}set values(t){for(var e in t){var r=this.findOrCreate(e);r&&r.forEach((r=>r.value=t[e]))}}get valuesByRefid(){var t={};for(let[e,r]of this.refidIndexMap.entries())t[e]=r.value;return t}set valuesByRefid(t){for(var e in t){var r=this.findByRefid(Number(e));r&&(r.value=t[e])}}get selected(){return(this._selected||[]).filter((t=>t.parent))}set selected(t){var e=this._selected;if(this._selected=t,!t||t.length<=1)this.hasSameParentForAllSelected=!0;else{let e=t[0].parent;this.hasSameParentForAllSelected=!t.find((t=>t.parent!=e))}this.trigger("selected",t,e)}get focused(){return this._focused}set focused(t){this._focused!==t&&(this._focused=t,this.invalidate())}get style(){return this._style}set style(t){this._style=t,this._compiled_style=t}get hasTextProperty(){return!1}render(){this.components.forEach((t=>t.draw()))}contains(t,e){return!0}capturePath(t,e){return this.model_layer.capturePath(t,e)}invalidate(){this.components.forEach((t=>t.invalidate()))}get eventMap(){return{"(root)":{"(descendant)":{added:this.onadded,removed:this.onremoved,change:this.onchanged}}}}refreshMappings(){if(!this._refresh_mapping_debouncer){if(this.disposed)return;this._refresh_mapping_debouncer=x7((function t(e){e.executeMappings(),e.components&&e.components.forEach((e=>t(e)))}),1e3)}this._refresh_mapping_debouncer(this.model_layer)}_addTraverse(t){t.components&&t.components.forEach((t=>this._addTraverse(t)));var{id:e,refid:r,tag:n,templatePrefix:i}=t.model;this.addRefidIndex(r,t),e&&this.addIndex(e,t),n&&this.subscribe(n,t),i&&this.addTemplate(i,t);var a=C7({},t.eventMap,t.model.eventMap);this.eventEngine.add(t,a)}_removeTraverse(t){t.components&&t.components.forEach((t=>this._removeTraverse(t)));var{id:e,refid:r,tag:n,templatePrefix:i}=t.model;this.removeRefidIndex(r,t),e&&this.removeIndex(e,t),n&&this.unsubscribe(n,t),i&&this.removeTemplate(i,t),this.eventEngine.remove(t)}onadded(t,e){this._addTraverse(e),this.refreshMappings(),this.invalidate()}onremoved(t,e){this._removeTraverse(e),this.invalidate()}onchanged(t,e,r){e.templatePrefix&&this.removeTemplate(e.templatePrefix,r.origin),t.templatePrefix&&this.addTemplate(t.templatePrefix,r.origin),e.id&&this.removeIndex(e.id,r.origin),t.id&&this.addIndex(t.id,r.origin),e.tag&&this.unsubscribe(e.tag,r.origin),t.tag&&this.subscribe(t.tag,r.origin),e.id==t.id&&e.class==t.class||this.refreshMappings()}}Object.assign(jnt.prototype,{fit:function(t){var{width:e,height:r,fitMode:n}=this.model_layer.model,i=this.target_element,a=this.model_layer;if(this.fitMode=t||this.fitMode||n||"ratio",e&&r&&i&&i.clientWidth&&i.clientHeight){switch(this.fitMode){case"center":!function(t,e,r){var n=t.unitScale,{width:i,height:a}=e.model;e.set("scale",{x:n,y:n}),e.set("translate",{x:Math.max((r.clientWidth-i*n)/2,0),y:Math.max((r.clientHeight-a*n)/2,0)})}(this,a,i);break;case"both":!function(t,e,r){var{width:n,height:i}=e.model,a=r.clientWidth,s=r.clientHeight;e.set("scale",{x:a/n,y:s/i}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"width":!function(t,e,r){var n=r.clientWidth/e.get("width");e.set("scale",{x:n,y:n}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"height":!function(t,e,r){var n=r.clientHeight/e.get("height");e.set("scale",{x:n,y:n}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"ratio":!function(t,e,r){var{width:n,height:i}=e.model,a=r.clientWidth,s=r.clientHeight,o=a/n,l=s/i,h=Math.min(o,l);e.set("scale",{x:h,y:h}),e.set("translate",{x:(a-n*h)/2,y:(s-i*h)/2})}(0,a,i);break;default:!function(t,e){var r=t.unitScale;e.set("scale",{x:r,y:r}),e.set("translate",{x:0,y:0})}(this,a)}this.resize()}}}),mtt.memoize(jnt.prototype,"unitScale",!1);var Bnt=13.3,znt=function(t){return void 0!==t&&(Bnt=t),Bnt};const Wnt="$base_url";const Unt=Math.PI/12;class Hnt{constructor(t,e){this._mode=t,this.screen=znt(),this._baseUrl="undefined"!=typeof window?window.location.origin:null,this._refProvider=e,this.isEditMode&&(this._rotateStep=Unt,this._rotateStepForced=!1)}dispose(){this._dataSubscriptionProvider&&this._dataSubscriptionProvider.dispose(),delete this._dataStorage}_calcScreen(){var t={width:screen.width,height:screen.height};this._PPI=function(t,e,r,n){t>0||(t=1),e>0||(e=1),n||(n="d");var i=("d"==n?Math.sqrt(t*t+e*e):"w"==n?t:e)/r;return i>0?Math.round(i):0}(t.width,t.height,this.screen),this._PPM=this._PPI/25.4}subscribe(t,e){return this._dataSubscriptionProvider?.subscribe(t,e)}get refProvider(){return this._refProvider}set dataSubscriptionProvider(t){this._dataSubscriptionProvider=t}get dataSubscriptionProvider(){return this._dataSubscriptionProvider}set commander(t){this._commander=t}get commander(){return this._commander}get screen(){return this._screen}set screen(t){this._screen=t,this._calcScreen()}get DPPX(){return e9}get PPI(){return this._PPI}get PPM(){return this._PPM}get mode(){return this._mode}set mode(t){var e=this._mode;e!==t&&(this._mode=t,this.trigger("mode",t,e))}get isViewMode(){return 0==this._mode}get isEditMode(){return 1==this._mode}get baseUrl(){return this._baseUrl}set baseUrl(t){t&&this._baseUrl!=t&&(this._baseUrl=t)}url(t){try{return(t.includes(Wnt)?new URL(t.replace(Wnt,this.baseUrl),this.baseUrl):new URL(t,location.origin)).href}catch(e){H7(e,t)}}get rotateStep(){return this._rotateStep}set rotateStep(t){this._rotateStep=Number(t)||Unt}get rotateStepForced(){return this._rotateStepForced}set rotateStepForced(t){this._rotateStepForced=!!t}get dataStorage(){return this._dataStorage}set dataStorage(t){this._dataStorage=t}}W7(Hnt.prototype,F7.withEvent);class Gnt{constructor(t,e){!(t=Number(t))||t<=0?(U7("TimeCapsule maxsize should be greater than 0.",t),this.maxsize=10):this.maxsize=t,this.reset(),e&&(this.snapshot(e),this.preserve())}preserve(){this.checkPoint=this.pos}hasUnpreservedChanges(){return this.checkPoint!=this.pos}dispose(){this.reset()}snapshot(t){if(this.q.splice(this.pos+1,this.q.length-(this.pos+1),t),this.q.length>this.maxsize){const t=this.q.splice(0,this.q.length-this.maxsize);this.checkPoint=Math.max(-1,this.checkPoint-t.length)}this.pos=this.q.length-1}forward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.forwardable)return this.q[++this.pos];H7("Not forwardable.")}backward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.backwardable)return this.q[--this.pos];H7("Not backwardable.")}get current(){if(-1!==this.pos)return this.q[this.pos];H7("Non state has been recorded.")}get length(){return this.q.length}get forwardable(){return this.pos<this.q.length-1}get backwardable(){return this.pos>0}get snapshot_taker(){return this._snapshot_taker}set snapshot_taker(t){this._snapshot_taker=t}reset(){this.q=[],this.pos=-1,this.checkPoint=-1}}var Ynt=x7((t=>{t.brake||t.take()}),1e3,{leading:!0,trailing:!1});function Vnt(t){!t.brake&&t.dirty&&Ynt(t)}class qnt{constructor(t,e){this.brake=!1,this.dirty=!1,this.state_holder=t,this.timecapsule=e,this.timecapsule.snapshot_taker=this}dispose(){delete this.state_holder,delete this.timecapsule}touch(){this.dirty=!0,Vnt(this)}take(t){(this.dirty||t)&&(this.timecapsule.snapshot(this.state_holder.state),this.dirty=!1)}get brake(){return this._brake}set brake(t){this._brake=!!t,Vnt(this)}}function Xnt(t,e){var r=e.model_layer.get("scale"),n=e.model_layer.get("translate");if(t){let i=JSON.parse(t);i.scale=r,i.translate=n,e.rebuildContentModel(i)}}class $nt{constructor(t){this.container=t,this.timecapsule=new Gnt(20);var e=this;this.snapshot_taker=new qnt({get state(){let t=e.container.model_layer.hierarchy;return JSON.stringify(t)}},this.timecapsule),this.snapshot_taker.take(!0),this.timecapsule.preserve()}dispose(){this.reset(),this.timecapsule&&this.timecapsule.dispose(),this.snapshot_taker&&this.snapshot_taker.dispose(),delete this.container,delete this.timecapsule,delete this.snapshot_taker}preserve(){this.timecapsule.preserve()}hasUnpreservedChanges(){return this.timecapsule.hasUnpreservedChanges()}execute(t,e){!1!==e&&t&&t.execute(),this.snapshot_taker.touch(),this.trigger("execute",t,!0,!1)}undo(){this.timecapsule.backwardable&&(Xnt(this.timecapsule.backward(),this.container),this.trigger("undo",this.undoable(),this.redoable()))}redo(){this.timecapsule.forwardable&&(Xnt(this.timecapsule.forward(),this.container),this.trigger("redo",this.undoable(),this.redoable()))}undoable(){return this.timecapsule.backwardable}redoable(){return this.timecapsule.forwardable}reset(){this.timecapsule&&this.timecapsule.reset(),this.trigger("command-reset")}}W7($nt.prototype,F7.withEvent);var Knt=0;const Qnt=new FinalizationRegistry((t=>{Knt--}));class Jnt{static get residents(){return Knt}static get residentsCount(){return Knt}constructor(t){this._container=t,this.app=t.app,this._commander=new $nt(this._container),this.app.commander=this._commander,Knt++,Qnt.register(this,Knt)}add(){return Det.apply(this._container,arguments)}duplicate(){return Fet.apply(this._container,arguments)}remove(){return Net.apply(this._container,arguments)}animate(){return D8.apply(this,arguments)}fullscreen(){return Wet.apply(this._container,arguments)}get target(){return this._container.target_element}set target(t){var e;if("string"==typeof t){if(!(e=document.getElementById(t)))throw`target element '${t}' is not exist`;if(e.firstChild)throw`target element '${t}' already has children`}else e=t;e&&e.style&&(e.style.cursor="default"),this._container.target_element=e,this._container.invalidate()}get scale(){return this.root.get("scale")}set scale(t){this.root.set("scale",t)}get translate(){return this.root.get("translate")}set translate(t){this.root.set("translate",t)}get unit(){return this.root.get("unit")||"px"}get PPM(){return this.app.PPM}get PPI(){return this.app.PPI}get DPPX(){return this.app.DPPX}static get DPPX(){return e9}get unitScale(){return this._container.unitScale}get screen(){return this.app.screen}set screen(t){this.app.screen=t,this._container.resize()}resize(){this._container.resize()}release(){this.dispose()}dispose(){this._commander&&this._commander.dispose(),this._container&&this._container.dispose()}get selected(){return this._container.selected.slice()}set selected(t){this._container.selected=t}select(t,...e){return this._container.selected=this.root?.findAll(t,...e),this.selected}get commander(){return this._commander}undo(){this.commander.undo()}undoable(){return this.commander.undoable()}redo(){this.commander.redo()}redoable(){return this.commander.redoable()}preserve(){this.commander.preserve()}hasUnpreservedChanges(){return this.commander.hasUnpreservedChanges()}cut(){return Get.apply(this._container,arguments)}copy(){return Het.apply(this._container,arguments)}paste(){return Yet.apply(this._container,arguments)}undoableChange(){return crt.apply(this._container,arguments)}change(){return hrt.apply(this.root,arguments)}get model(){return this.root.hierarchy}set model(t){this._container.rebuildContentModel(t)}get rootContainer(){return this._container}get root(){return this._container?.model_layer}findAll(){return this.root.findAll.apply(this.root,arguments)}findFirst(){return this.root.findFirst.apply(this.root,arguments)}findById(){return this._container.findById.apply(this._container,arguments)}findAllById(){return this._container.findAllById.apply(this._container,arguments)}serialize(){return this.root.trim(),this.root.serialize.apply(this.root,arguments)}align(){return _et.apply(this._container,arguments)}place(){return yrt.apply(this._container,arguments)}distribute(){return Met.apply(this._container,arguments)}move(){return Pet.apply(this._container,arguments)}zorder(){return Iet.apply(this._container,arguments)}symmetryX(){return ort.apply(this._container,arguments)}symmetryY(){return lrt.apply(this._container,arguments)}on(){return jet.apply(this._container,arguments)}once(){return Bet.apply(this._container,arguments)}off(){return this._container&&zet.apply(this._container,arguments)}centerTo(t,e){return this.root.centerTo(t,e)}get mode(){return this.app.mode}set mode(t){void 0!==t&&(this.app.mode=t)}toDataURL(){return rrt.apply(this._container,arguments)}group(){return nrt.apply(this._container,arguments)}ungroup(){return irt.apply(this._container,arguments)}fit(t){this._container.once("redraw",(()=>this._container.fit(t))),this._container.invalidate()}get fitMode(){return this._container.fitMode}get ids(){return urt.apply(this._container)}get data(){return this._container.data}set data(t){this._container.data=t}get dataByRefid(){return this._container.dataByRefid}set dataByRefid(t){this._container.dataByRefid=t}get values(){return this._container.values}set values(t){this._container.values=t}get valuesByRefid(){return this._container.valuesByRefid}set valuesByRefid(t){this._container.valuesByRefid=t}get baseUrl(){return this.app.baseUrl}set baseUrl(t){this.app.baseUrl=t}startAddMode(){return brt.apply(this._container,arguments)}startStylePasteMode(){return wrt.apply(this._container,arguments)}stopStylePasteMode(){return xrt.apply(this._container,arguments)}startDatabindPasteMode(){return Art.apply(this._container,arguments)}stopDatabindPasteMode(){return _rt.apply(this._container,arguments)}}const Znt=new class{load(t){}save(t,e){}clear(t){}};function tit({target:t,model:e,style:r,layers:n=[],handlers:i=[],mode:a=0,refProvider:s,dataSubscriptionProvider:o,dataStorage:l=Znt,baseUrl:h,fitMode:c}){var u=null;if("string"==typeof t){if(!(u=document.getElementById(t)))throw`target element '${t}' is not exist`;if(u.firstChild)throw`target element '${t}' is not empty`}else u=t;u&&u.style&&(u.style.position="absolute",u.style.cursor="default",u.style.overflow="hidden");var d=new Hnt(a,s);return d.baseUrl=h,d.dataSubscriptionProvider=o,d.dataStorage=l,new Jnt(new jnt({target_element:u,model:e,style:r,layers:n,handlers:i,fitMode:c},d))}
6
+ i=function(){return e};var t,e={},r=Object.prototype,a=r.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",h=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),o=new R(n||[]);return s(a,"_invoke",{value:T(t,r,o)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var f="suspendedStart",g="suspendedYield",v="executing",m="completed",y={};function b(){}function w(){}function x(){}var A={};u(A,l,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(O([])));k&&k!==r&&a.call(k,l)&&(A=k);var S=x.prototype=b.prototype=Object.create(A);function E(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function M(t,e){function r(i,s,o,l){var h=p(t[i],t,s);if("throw"!==h.type){var c=h.arg,u=c.value;return u&&"object"==n(u)&&a.call(u,"__await")?e.resolve(u.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):e.resolve(u).then((function(t){c.value=t,o(c)}),(function(t){return r("throw",t,o,l)}))}l(h.arg)}var i;s(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(a,a):a()}})}function T(e,r,n){var i=f;return function(a,s){if(i===v)throw new Error("Generator is already running");if(i===m){if("throw"===a)throw s;return{value:t,done:!0}}for(n.method=a,n.arg=s;;){var o=n.delegate;if(o){var l=C(o,n);if(l){if(l===y)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var h=p(e,r,n);if("normal"===h.type){if(i=n.done?m:g,h.arg===y)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i=m,n.method="throw",n.arg=h.arg)}}}function C(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var s=a.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function O(e){if(e||""===e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function r(){for(;++i<e.length;)if(a.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return s.next=s}}throw new TypeError(n(e)+" is not iterable")}return w.prototype=x,s(S,"constructor",{value:x,configurable:!0}),s(x,"constructor",{value:w,configurable:!0}),w.displayName=u(x,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,u(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},E(M.prototype),u(M.prototype,h,(function(){return this})),e.AsyncIterator=M,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new M(d(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},E(S),u(S,c,"Generator"),u(S,l,(function(){return this})),u(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=O,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return o.type="throw",o.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),h=a.call(s,"finallyLoc");if(l&&h){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(l){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}var a=t("./datetime"),s=t("./functions"),o=t("./utils"),l=t("./parser"),h=t("./signature"),c=function(){var t=i().mark(z),e=i().mark(W),r=i().mark(H),c=i().mark(G),u=i().mark(Y),d=i().mark(V),p=i().mark(q),f=i().mark(X),g=i().mark(at),v=i().mark(lt),m=i().mark(ut),y=i().mark(dt),b=i().mark(pt),w=i().mark(vt),x=i().mark(bt),A=i().mark(wt),_=i().mark(xt),k=i().mark(At),S=i().mark(kt),E=i().mark(Et),M=i().mark(Ct),T=i().mark(Rt),C=o.isNumeric,P=o.isArrayOfStrings,I=o.isArrayOfNumbers,R=o.createSequence,O=o.isSequence,L=o.isFunction,D=o.isLambda,F=o.isIterable,N=o.getFunctionArity,j=o.isDeepEqual,B=Lt(null);function z(e,r,n){var a,s,o,l;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(s=n.lookup("__evaluate_entry"))&&s(e,r,n),t.t0=e.type,t.next="path"===t.t0?5:"binary"===t.t0?8:"unary"===t.t0?11:"name"===t.t0?14:"string"===t.t0||"number"===t.t0||"value"===t.t0?16:"wildcard"===t.t0?18:"descendant"===t.t0?20:"parent"===t.t0?22:"condition"===t.t0?24:"block"===t.t0?27:"bind"===t.t0?30:"regex"===t.t0?33:"function"===t.t0?35:"variable"===t.t0?38:"lambda"===t.t0?40:"partial"===t.t0?42:"apply"===t.t0?45:"transform"===t.t0?48:50;break;case 5:return t.delegateYield(W(e,r,n),"t1",6);case 6:return a=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(q(e,r,n),"t2",9);case 9:return a=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(X(e,r,n),"t3",12);case 12:return a=t.t3,t.abrupt("break",50);case 14:return a=$(e,r),t.abrupt("break",50);case 16:return a=K(e),t.abrupt("break",50);case 18:return a=Q(e,r),t.abrupt("break",50);case 20:return a=Z(e,r),t.abrupt("break",50);case 22:return a=n.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(dt(e,r,n),"t4",25);case 25:return a=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(pt(e,r,n),"t5",28);case 28:return a=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(ut(e,r,n),"t6",31);case 31:return a=t.t6,t.abrupt("break",50);case 33:return a=ft(e),t.abrupt("break",50);case 35:return t.delegateYield(wt(e,r,n),"t7",36);case 36:return a=t.t7,t.abrupt("break",50);case 38:return a=gt(e,r,n),t.abrupt("break",50);case 40:return a=_t(e,r,n),t.abrupt("break",50);case 42:return t.delegateYield(kt(e,r,n),"t8",43);case 43:return a=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(bt(e,r,n),"t9",46);case 46:return a=t.t9,t.abrupt("break",50);case 48:return a=mt(e,r,n),t.abrupt("break",50);case 50:if(!n.async||null!=a&&"function"==typeof a.then||(a=Promise.resolve(a)),!n.async||"function"!=typeof a.then||!e.nextFunction||"function"!=typeof a[e.nextFunction]){t.next=54;break}t.next=57;break;case 54:return t.next=56,a;case 56:a=t.sent;case 57:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.next=65;break}o=0;case 59:if(!(o<e.predicate.length)){t.next=65;break}return t.delegateYield(V(e.predicate[o].expr,a,n),"t10",61);case 61:a=t.t10;case 62:o++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(lt(e.group,a,n),"t11",67);case 67:a=t.t11;case 68:return(l=n.lookup("__evaluate_exit"))&&l(e,r,n,a),a&&O(a)&&!a.tupleStream&&(e.keepArray&&(a.keepSingleton=!0),0===a.length?a=void 0:1===a.length&&(a=a.keepSingleton?a:a[0])),t.abrupt("return",a);case 72:case"end":return t.stop()}}),t)}function W(t,r,n){var a,s,o,l,h,c;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=Array.isArray(r)&&"variable"!==t.steps[0].type?r:R(r),o=!1,l=void 0,h=0;case 4:if(!(h<t.steps.length)){e.next=25;break}if((c=t.steps[h]).tuple&&(o=!0),0!==h||!c.consarray){e.next=12;break}return e.delegateYield(z(c,a,n),"t0",9);case 9:s=e.t0,e.next=19;break;case 12:if(!o){e.next=17;break}return e.delegateYield(Y(c,a,l,n),"t1",14);case 14:l=e.t1,e.next=19;break;case 17:return e.delegateYield(H(c,a,n,h===t.steps.length-1),"t2",18);case 18:s=e.t2;case 19:if(o||void 0!==s&&0!==s.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===c.focus&&(a=s);case 22:h++,e.next=4;break;case 25:if(o)if(t.tuple)s=l;else for(s=R(),h=0;h<l.length;h++)s.push(l[h]["@"]);if(t.keepSingletonArray&&(Array.isArray(s)&&s.cons&&!s.sequence&&(s=R(s)),s.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(lt(t.group,o?l:s,n),"t3",29);case 29:s=e.t3;case 30:return e.abrupt("return",s);case 31:case"end":return e.stop()}}),e)}function U(t,e){var r=Lt(t);for(var n in e)r.bind(n,e[n]);return r}function H(t,e,n,a){var s,o,l,h,c;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("sort"!==t.type){r.next=7;break}return r.delegateYield(vt(t,e,n),"t0",2);case 2:if(s=r.t0,!t.stages){r.next=6;break}return r.delegateYield(G(t.stages,s,n),"t1",5);case 5:s=r.t1;case 6:return r.abrupt("return",s);case 7:s=R(),o=0;case 9:if(!(o<e.length)){r.next=24;break}return r.delegateYield(z(t,e[o],n),"t2",11);case 11:if(l=r.t2,!t.stages){r.next=20;break}h=0;case 14:if(!(h<t.stages.length)){r.next=20;break}return r.delegateYield(V(t.stages[h].expr,l,n),"t3",16);case 16:l=r.t3;case 17:h++,r.next=14;break;case 20:void 0!==l&&s.push(l);case 21:o++,r.next=9;break;case 24:return c=R(),a&&1===s.length&&Array.isArray(s[0])&&!O(s[0])?c=s[0]:s.forEach((function(t){!Array.isArray(t)||t.cons?c.push(t):t.forEach((function(t){return c.push(t)}))})),r.abrupt("return",c);case 27:case"end":return r.stop()}}),r)}function G(t,e,r){var n,a,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:n=e,a=0;case 2:if(!(a<t.length)){i.next=15;break}s=t[a],i.t0=s.type,i.next="filter"===i.t0?7:"index"===i.t0?10:12;break;case 7:return i.delegateYield(V(s.expr,n,r),"t1",8);case 8:return n=i.t1,i.abrupt("break",12);case 10:for(o=0;o<n.length;o++)n[o][s.value]=o;return i.abrupt("break",12);case 12:a++,i.next=2;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}}),c)}function Y(t,e,r,n){var a,s,o,l,h,c,d,p;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if("sort"!==t.type){i.next=15;break}if(!r){i.next=6;break}return i.delegateYield(vt(t,r,n),"t0",3);case 3:a=i.t0,i.next=11;break;case 6:return i.delegateYield(vt(t,e,n),"t1",7);case 7:for(s=i.t1,(a=R()).tupleStream=!0,o=0;o<s.length;o++)(l={"@":s[o]})[t.index]=o,a.push(l);case 11:if(!t.stages){i.next=14;break}return i.delegateYield(G(t.stages,a,n),"t2",13);case 13:a=i.t2;case 14:return i.abrupt("return",a);case 15:(a=R()).tupleStream=!0,h=n,void 0===r&&(r=e.map((function(t){return{"@":t}}))),c=0;case 20:if(!(c<r.length)){i.next=28;break}return h=U(n,r[c]),i.delegateYield(z(t,r[c]["@"],h),"t3",23);case 23:if(void 0!==(d=i.t3))for(Array.isArray(d)||(d=[d]),p=0;p<d.length;p++)l={},Object.assign(l,r[c]),d.tupleStream?Object.assign(l,d[p]):(t.focus?(l[t.focus]=d[p],l["@"]=r[c]["@"]):l["@"]=d[p],t.index&&(l[t.index]=p),t.ancestor&&(l[t.ancestor.label]=r[c]["@"])),a.push(l);case 25:c++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(G(t.stages,a,n),"t4",30);case 30:a=i.t4;case 31:return i.abrupt("return",a);case 32:case"end":return i.stop()}}),u)}function V(t,e,r){var n,a,o,l,h,c;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=R(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=R(e)),"number"!==t.type){i.next=10;break}(a=Math.floor(t.value))<0&&(a=e.length+a),void 0!==(o=e[a])&&(Array.isArray(o)?n=o:n.push(o)),i.next=23;break;case 10:a=0;case 11:if(!(a<e.length)){i.next=23;break}return o=e[a],l=o,h=r,e.tupleStream&&(l=o["@"],h=U(r,o)),i.delegateYield(z(t,l,h),"t0",17);case 17:c=i.t0,C(c)&&(c=[c]),I(c)?c.forEach((function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===a&&n.push(o)})):s.boolean(c)&&n.push(o);case 20:a++,i.next=11;break;case 23:return i.abrupt("return",n);case 24:case"end":return i.stop()}}),d)}function q(t,e,r){var n,a,s,o,l;return i().wrap((function(h){for(;;)switch(h.prev=h.next){case 0:return h.delegateYield(z(t.lhs,e,r),"t0",1);case 1:if(a=h.t0,s=t.value,o=i().mark((function n(){return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(z(t.rhs,e,r),"t0",1);case 1:return n.abrupt("return",n.t0);case 2:case"end":return n.stop()}}),n)})),"and"!==s&&"or"!==s){h.next=15;break}return h.prev=5,h.delegateYield(at(a,o,s),"t1",7);case 7:return h.abrupt("return",h.t1);case 10:throw h.prev=10,h.t2=h.catch(5),h.t2.position=t.position,h.t2.token=s,h.t2;case 15:return h.delegateYield(o(),"t3",16);case 16:l=h.t3,h.prev=17,h.t4=s,h.next="+"===h.t4||"-"===h.t4||"*"===h.t4||"/"===h.t4||"%"===h.t4?21:"="===h.t4||"!="===h.t4?23:"<"===h.t4||"<="===h.t4||">"===h.t4||">="===h.t4?25:"&"===h.t4?27:".."===h.t4?29:"in"===h.t4?31:33;break;case 21:return n=et(a,l,s),h.abrupt("break",33);case 23:return n=rt(a,l,s),h.abrupt("break",33);case 25:return n=nt(a,l,s),h.abrupt("break",33);case 27:return n=ot(a,l),h.abrupt("break",33);case 29:return n=ct(a,l),h.abrupt("break",33);case 31:return n=it(a,l),h.abrupt("break",33);case 33:h.next=40;break;case 35:throw h.prev=35,h.t5=h.catch(17),h.t5.position=t.position,h.t5.token=s,h.t5;case 40:return h.abrupt("return",n);case 41:case"end":return h.stop()}}),p,null,[[5,10],[17,35]])}function X(t,e,r){var n,a,o,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:i.t0=t.value,i.next="-"===i.t0?3:"["===i.t0?15:"{"===i.t0?27:30;break;case 3:return i.delegateYield(z(t.expression,e,r),"t1",4);case 4:if(void 0!==(n=i.t1)){i.next=9;break}n=void 0,i.next=14;break;case 9:if(!C(n)){i.next=13;break}n=-n,i.next=14;break;case 13:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:n};case 14:return i.abrupt("break",30);case 15:n=[],a=0;case 17:if(!(a<t.expressions.length)){i.next=25;break}return o=t.expressions[a],i.delegateYield(z(o,e,r),"t2",20);case 20:void 0!==(l=i.t2)&&("["===o.value?n.push(l):n=s.append(n,l));case 22:a++,i.next=17;break;case 25:return t.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0}),i.abrupt("break",30);case 27:return i.delegateYield(lt(t,e,r),"t3",28);case 28:return n=i.t3,i.abrupt("break",30);case 30:return i.abrupt("return",n);case 31:case"end":return i.stop()}}),f)}function $(t,e,r){return s.lookup(e,t.value)}function K(t){return t.value}function Q(t,e){var r=R();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null!==e&&"object"===n(e)&&Object.keys(e).forEach((function(t){var n=e[t];Array.isArray(n)?(n=J(n),r=s.append(r,n)):r.push(n)})),r}function J(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach((function(t){J(t,e)})):e.push(t),e}function Z(t,e){var r,n=R();return void 0!==e&&(tt(e,n),r=1===n.length?n[0]:n),r}function tt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?t.forEach((function(t){tt(t,e)})):null!==t&&"object"===n(t)&&Object.keys(t).forEach((function(r){tt(t[r],e)}))}function et(t,e,r){var n;if(void 0!==t&&!C(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!C(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;switch(r){case"+":n=t+e;break;case"-":n=t-e;break;case"*":n=t*e;break;case"/":n=t/e;break;case"%":n=t%e}return n}function rt(t,e,r){var i,a=n(t),s=n(e);if("undefined"===a||"undefined"===s)return!1;switch(r){case"=":i=j(t,e);break;case"!=":i=!j(t,e)}return i}function nt(t,e,r){var i,a=n(t),s=n(e);if("undefined"!==a&&"string"!==a&&"number"!==a||"undefined"!==s&&"string"!==s&&"number"!==s)throw{code:"T2010",stack:(new Error).stack,value:"string"!==a&&"number"!==a?t:e};if("undefined"!==a&&"undefined"!==s){if(a!==s)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(r){case"<":i=t<e;break;case"<=":i=t<=e;break;case">":i=t>e;break;case">=":i=t>=e}return i}}function it(t,e){var r=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var n=0;n<e.length;n++)if(e[n]===t){r=!0;break}return r}function at(t,e,r){var n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=st(t),i.t0=r,i.next="and"===i.t0?4:"or"===i.t0?12:20;break;case 4:if(i.t1=a,!i.t1){i.next=10;break}return i.t2=st,i.delegateYield(e(),"t3",8);case 8:i.t4=i.t3,i.t1=(0,i.t2)(i.t4);case 10:return n=i.t1,i.abrupt("break",20);case 12:if(i.t5=a,i.t5){i.next=18;break}return i.t6=st,i.delegateYield(e(),"t7",16);case 16:i.t8=i.t7,i.t5=(0,i.t6)(i.t8);case 18:return n=i.t5,i.abrupt("break",20);case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}}),g)}function st(t){var e=s.boolean(t);return void 0!==e&&e}function ot(t,e){var r="",n="";return void 0!==t&&(r=s.string(t)),void 0!==e&&(n=s.string(e)),r.concat(n)}function lt(t,e,r){var n,a,o,l,h,c,u,d,p,f,g,m,y;return i().wrap((function(v){for(;;)switch(v.prev=v.next){case 0:n={},a={},o=!(!e||!e.tupleStream),Array.isArray(e)||(e=R(e)),0===e.length&&e.push(void 0),l=0;case 6:if(!(l<e.length)){v.next=31;break}h=e[l],c=o?U(r,h):r,u=0;case 10:if(!(u<t.lhs.length)){v.next=28;break}return d=t.lhs[u],v.delegateYield(z(d[0],o?h["@"]:h,c),"t0",13);case 13:if("string"==typeof(p=v.t0)||void 0===p){v.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:p};case 16:if(void 0===p){v.next=25;break}if(f={data:h,exprIndex:u},!a.hasOwnProperty(p)){v.next=24;break}if(a[p].exprIndex===u){v.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:p};case 21:a[p].data=s.append(a[p].data,h),v.next=25;break;case 24:a[p]=f;case 25:u++,v.next=10;break;case 28:l++,v.next=6;break;case 31:v.t1=i().keys(a);case 32:if((v.t2=v.t1()).done){v.next=43;break}return p=v.t2.value,f=a[p],g=f.data,c=r,o&&(m=ht(f.data),g=m["@"],delete m["@"],c=U(r,m)),v.delegateYield(z(t.lhs[f.exprIndex][1],g,c),"t3",39);case 39:void 0!==(y=v.t3)&&(n[p]=y),v.next=32;break;case 43:return v.abrupt("return",n);case 44:case"end":return v.stop()}}),v)}function ht(t){if(!Array.isArray(t))return t;var e={};Object.assign(e,t[0]);for(var r=1;r<t.length;r++)for(var n in t[r])e[n]=s.append(e[n],t[r][n]);return e}function ct(t,e){var r;if(void 0!==t&&!Number.isInteger(t))throw{code:"T2003",stack:(new Error).stack,value:t};if(void 0!==e&&!Number.isInteger(e))throw{code:"T2004",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return r;if(t>e)return r;var n=e-t+1;if(n>1e7)throw{code:"D2014",stack:(new Error).stack,value:n};r=new Array(n);for(var i=t,a=0;i<=e;i++,a++)r[a]=i;return r.sequence=!0,r}function ut(t,e,r){var n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(t.rhs,e,r),"t0",1);case 1:return n=i.t0,r.bind(t.lhs.value,n),i.abrupt("return",n);case 4:case"end":return i.stop()}}),m)}function dt(t,e,r){var n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(t.condition,e,r),"t0",1);case 1:if(a=i.t0,!s.boolean(a)){i.next=7;break}return i.delegateYield(z(t.then,e,r),"t1",4);case 4:n=i.t1,i.next=10;break;case 7:if(void 0===t.else){i.next=10;break}return i.delegateYield(z(t.else,e,r),"t2",9);case 9:n=i.t2;case 10:return i.abrupt("return",n);case 11:case"end":return i.stop()}}),y)}function pt(t,e,r){var n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=Lt(r),s=0;case 2:if(!(s<t.expressions.length)){i.next=8;break}return i.delegateYield(z(t.expressions[s],e,a),"t0",4);case 4:n=i.t0;case 5:s++,i.next=2;break;case 8:return i.abrupt("return",n);case 9:case"end":return i.stop()}}),b)}function ft(t){var e=new Nt.RegexEngine(t.value),r=function r(n,i){var a;e.lastIndex=i||0;var s=e.exec(n);if(null!==s){if(a={match:s[0],start:s.index,end:s.index+s[0].length,groups:[]},s.length>1)for(var o=1;o<s.length;o++)a.groups.push(s[o]);a.next=function(){if(!(e.lastIndex>=n.length)){var i=r(n,e.lastIndex);if(i&&""===i.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return i}}}return a};return r}function gt(t,e,r){return""===t.value?e&&e.outerWrapper?e[0]:e:r.lookup(t.value)}function vt(t,e,r){var a,o,l,h,c;return i().wrap((function(u){for(;;)switch(u.prev=u.next){case 0:return o=e,l=!!e.tupleStream,h=i().mark((function e(a,s){var o,h,c,u,d,p,f,g,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=0,h=0;case 2:if(!(0===o&&h<t.terms.length)){e.next=35;break}return c=t.terms[h],u=a,d=r,l&&(u=a["@"],d=U(r,a)),e.delegateYield(z(c.expression,u,d),"t0",8);case 8:return p=e.t0,u=s,d=r,l&&(u=s["@"],d=U(r,s)),e.delegateYield(z(c.expression,u,d),"t1",13);case 13:if(f=e.t1,g=n(p),v=n(f),"undefined"!==g){e.next=19;break}return o="undefined"===v?0:1,e.abrupt("continue",32);case 19:if("undefined"!==v){e.next=22;break}return o=-1,e.abrupt("continue",32);case 22:if(!("string"!==g&&"number"!==g||"string"!==v&&"number"!==v)){e.next=24;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==g&&"number"!==g?p:f};case 24:if(g===v){e.next=26;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:p,value2:f};case 26:if(p!==f){e.next=30;break}return e.abrupt("continue",32);case 30:o=p<f?-1:1;case 31:!0===c.descending&&(o=-o);case 32:h++,e.next=2;break;case 35:return e.abrupt("return",1===o);case 36:case"end":return e.stop()}}),e)})),c={environment:r,input:e},u.delegateYield(s.sort.apply(c,[o,h]),"t0",5);case 5:return a=u.t0,u.abrupt("return",a);case 7:case"end":return u.stop()}}),w)}function mt(t,e,r){var a=i().mark((function e(a){var s,o,l,h,c,u,d,p,f,g,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==a){e.next=2;break}return e.abrupt("return",void 0);case 2:if(s=r.lookup("clone"),L(s)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(xt(s,[a],null,r),"t0",6);case 6:return o=e.t0,e.delegateYield(z(t.pattern,o,r),"t1",8);case 8:if(void 0===(l=e.t1)){e.next=35;break}Array.isArray(l)||(l=[l]),h=0;case 12:if(!(h<l.length)){e.next=35;break}if(!(c=l[h])||!(c.isPrototypeOf(o)||c instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(z(t.update,c,r),"t2",17);case 17:if(u=e.t2,"undefined"===(d=n(u))){e.next=23;break}if("object"===d&&null!==u&&!Array.isArray(u)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:u};case 22:for(p in u)c[p]=u[p];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(z(t.delete,c,r),"t3",25);case 25:if(void 0===(f=e.t3)){e.next=32;break}if(g=f,Array.isArray(f)||(f=[f]),P(f)){e.next=31;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:g};case 31:for(v=0;v<f.length;v++)"object"===n(c)&&null!==c&&delete c[f[v]];case 32:h++,e.next=12;break;case 35:return e.abrupt("return",o);case 36:case"end":return e.stop()}}),e)}));return It(a,"<(oa):o>")}var yt=l("function($f, $g) { function($x){ $g($f($x)) } }");function bt(t,e,r){var n,a,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(t.lhs,e,r),"t0",1);case 1:if(a=i.t0,"function"!==t.rhs.type){i.next=7;break}return i.delegateYield(wt(t.rhs,e,r,{context:a}),"t1",4);case 4:n=i.t1,i.next=20;break;case 7:return i.delegateYield(z(t.rhs,e,r),"t2",8);case 8:if(s=i.t2,L(s)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:s};case 11:if(!L(a)){i.next=18;break}return i.delegateYield(z(yt,null,r),"t3",13);case 13:return o=i.t3,i.delegateYield(xt(o,[a,s],null,r),"t4",15);case 15:n=i.t4,i.next=20;break;case 18:return i.delegateYield(xt(s,[a],null,r),"t5",19);case 19:n=i.t5;case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}}),x)}function wt(t,e,r,a){var s,o,l,h,c,u;return i().wrap((function(d){for(;;)switch(d.prev=d.next){case 0:return d.delegateYield(z(t.procedure,e,r),"t0",1);case 1:if(void 0!==(o=d.t0)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){d.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:l=[],void 0!==a&&l.push(a.context),h=i().mark((function n(){var a,s;return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(z(t.arguments[c],e,r),"t0",1);case 1:a=n.t0,L(a)?(s=i().mark((function t(){var e,n,s,o=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(e=o.length,n=new Array(e),s=0;s<e;s++)n[s]=o[s];return t.delegateYield(xt(a,n,null,r),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}}),t)})),s.arity=N(a),l.push(s)):l.push(a);case 3:case"end":return n.stop()}}),n)})),c=0;case 8:if(!(c<t.arguments.length)){d.next=13;break}return d.delegateYield(h(),"t1",10);case 10:c++,d.next=8;break;case 13:return u="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,d.prev=14,"object"===n(o)&&(o.token=u,o.position=t.position),d.delegateYield(xt(o,l,e,r),"t2",17);case 17:s=d.t2,d.next=25;break;case 20:throw d.prev=20,d.t3=d.catch(14),d.t3.position||(d.t3.position=t.position),d.t3.token||(d.t3.token=u),d.t3;case 25:return d.abrupt("return",s);case 26:case"end":return d.stop()}}),A,null,[[14,20]])}function xt(t,e,r,n){var a,s,o,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(At(t,e,r,n),"t0",1);case 1:a=i.t0;case 2:if(!D(a)||!0!==a.thunk){i.next=21;break}return i.delegateYield(z(a.body.procedure,a.input,a.environment),"t1",4);case 4:s=i.t1,"variable"===a.body.procedure.type&&(s.token=a.body.procedure.value),s.position=a.body.procedure.position,o=[],l=0;case 9:if(!(l<a.body.arguments.length)){i.next=17;break}return i.t2=o,i.delegateYield(z(a.body.arguments[l],a.input,a.environment),"t3",12);case 12:i.t4=i.t3,i.t2.push.call(i.t2,i.t4);case 14:l++,i.next=9;break;case 17:return i.delegateYield(At(s,o,r,n),"t5",18);case 18:a=i.t5,i.next=2;break;case 21:return i.abrupt("return",a);case 22:case"end":return i.stop()}}),_)}function At(t,e,r,n){var a,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,s=e,t&&(s=St(t.signature,e,r)),!D(t)){i.next=8;break}return i.delegateYield(Et(t,s),"t0",5);case 5:a=i.t0,i.next=24;break;case 8:if(!t||!0!==t._jsonata_function){i.next=16;break}if(o={environment:n,input:r},a=t.implementation.apply(o,s),!F(a)){i.next=14;break}return i.delegateYield(a,"t1",13);case 13:a=i.t1;case 14:i.next=24;break;case 16:if("function"!=typeof t){i.next=23;break}if(a=t.apply(r,s),!F(a)){i.next=21;break}return i.delegateYield(a,"t2",20);case 20:a=i.t2;case 21:i.next=24;break;case 23:throw{code:"T1006",stack:(new Error).stack};case 24:i.next=30;break;case 26:throw i.prev=26,i.t3=i.catch(0),t&&(void 0===i.t3.token&&void 0!==t.token&&(i.t3.token=t.token),i.t3.position=t.position||i.t3.position),i.t3;case 30:return i.abrupt("return",a);case 31:case"end":return i.stop()}}),k,null,[[0,26]])}function _t(t,e,r){var n={_jsonata_lambda:!0,input:e,environment:r,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(n.thunk=!0),n.apply=i().mark((function t(r,a){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(xt(n,a,e,r.environment),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}}),t)})),n}function kt(t,e,r){var n,a,s,o,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=[],s=0;case 2:if(!(s<t.arguments.length)){i.next=15;break}if("operator"!==(o=t.arguments[s]).type||"?"!==o.value){i.next=8;break}a.push(o),i.next=12;break;case 8:return i.t0=a,i.delegateYield(z(o,e,r),"t1",10);case 10:i.t2=i.t1,i.t0.push.call(i.t0,i.t2);case 12:s++,i.next=2;break;case 15:return i.delegateYield(z(t.procedure,e,r),"t3",16);case 16:if(void 0!==(l=i.t3)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){i.next=19;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 19:if(!D(l)){i.next=23;break}n=Mt(l,a),i.next=32;break;case 23:if(!l||!0!==l._jsonata_function){i.next=27;break}n=Tt(l.implementation,a),i.next=32;break;case 27:if("function"!=typeof l){i.next=31;break}n=Tt(l,a),i.next=32;break;case 31:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 32:return i.abrupt("return",n);case 33:case"end":return i.stop()}}),S)}function St(t,e,r){return void 0===t?e:t.validate(e,r)}function Et(t,e){var r,n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=Lt(t.environment),t.arguments.forEach((function(t,r){n.bind(t.value,e[r])})),"function"!=typeof t.body){i.next=7;break}return i.delegateYield(Ct(t.body,n),"t0",4);case 4:r=i.t0,i.next=9;break;case 7:return i.delegateYield(z(t.body,t.input,n),"t1",8);case 8:r=i.t1;case 9:return i.abrupt("return",r);case 10:case"end":return i.stop()}}),E)}function Mt(t,e){var r=Lt(t.environment),n=[];return t.arguments.forEach((function(t,i){var a=e[i];a&&"operator"===a.type&&"?"===a.value?n.push(t):r.bind(t.value,a)})),{_jsonata_lambda:!0,input:t.input,environment:r,arguments:n,body:t.body}}function Tt(t,e){var r=Pt(t),n="function("+(r=r.map((function(t){return"$"+t.trim()}))).join(", ")+"){ _ }",i=l(n);return i.body=t,Mt(i,e)}function Ct(t,e){var r,n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(r=Pt(t),n=r.map((function(t){return e.lookup(t.trim())})),a={environment:e},s=t.apply(a,n),!F(s)){i.next=7;break}return i.delegateYield(s,"t0",6);case 6:s=i.t0;case 7:return i.abrupt("return",s);case 8:case"end":return i.stop()}}),M)}function Pt(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function It(t,e){var r={_jsonata_function:!0,implementation:t};return void 0!==e&&(r.signature=h(e)),r}function Rt(t,e){var r,n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=this.input,void 0!==e&&(r=e,Array.isArray(r)&&!O(r)&&((r=R(r)).outerWrapper=!0)),i.prev=4,n=l(t,!1),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(4),Ft(i.t0),{stack:(new Error).stack,code:"D3120",value:i.t0.message,error:i.t0};case 12:return i.prev=12,i.delegateYield(z(n,r,this.environment),"t1",14);case 14:a=i.t1,i.next=21;break;case 17:throw i.prev=17,i.t2=i.catch(12),Ft(i.t2),{stack:(new Error).stack,code:"D3121",value:i.t2.message,error:i.t2};case 21:return i.abrupt("return",a);case 22:case"end":return i.stop()}}),T,this,[[4,8],[12,17]])}function Ot(t){if(void 0!==t)return JSON.parse(s.string(t))}function Lt(t){var e={};return{bind:function(t,r){e[t]=r},lookup:function(r){var n;return e.hasOwnProperty(r)?n=e[r]:t&&(n=t.lookup(r)),n},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}B.bind("sum",It(s.sum,"<a<n>:n>")),B.bind("count",It(s.count,"<a:n>")),B.bind("max",It(s.max,"<a<n>:n>")),B.bind("min",It(s.min,"<a<n>:n>")),B.bind("average",It(s.average,"<a<n>:n>")),B.bind("string",It(s.string,"<x-b?:s>")),B.bind("substring",It(s.substring,"<s-nn?:s>")),B.bind("substringBefore",It(s.substringBefore,"<s-s:s>")),B.bind("substringAfter",It(s.substringAfter,"<s-s:s>")),B.bind("lowercase",It(s.lowercase,"<s-:s>")),B.bind("uppercase",It(s.uppercase,"<s-:s>")),B.bind("length",It(s.length,"<s-:n>")),B.bind("trim",It(s.trim,"<s-:s>")),B.bind("pad",It(s.pad,"<s-ns?:s>")),B.bind("match",It(s.match,"<s-f<s:o>n?:a<o>>")),B.bind("contains",It(s.contains,"<s-(sf):b>")),B.bind("replace",It(s.replace,"<s-(sf)(sf)n?:s>")),B.bind("split",It(s.split,"<s-(sf)n?:a<s>>")),B.bind("join",It(s.join,"<a<s>s?:s>")),B.bind("formatNumber",It(s.formatNumber,"<n-so?:s>")),B.bind("formatBase",It(s.formatBase,"<n-n?:s>")),B.bind("formatInteger",It(a.formatInteger,"<n-s:s>")),B.bind("parseInteger",It(a.parseInteger,"<s-s:n>")),B.bind("number",It(s.number,"<(nsb)-:n>")),B.bind("floor",It(s.floor,"<n-:n>")),B.bind("ceil",It(s.ceil,"<n-:n>")),B.bind("round",It(s.round,"<n-n?:n>")),B.bind("abs",It(s.abs,"<n-:n>")),B.bind("sqrt",It(s.sqrt,"<n-:n>")),B.bind("power",It(s.power,"<n-n:n>")),B.bind("random",It(s.random,"<:n>")),B.bind("boolean",It(s.boolean,"<x-:b>")),B.bind("not",It(s.not,"<x-:b>")),B.bind("map",It(s.map,"<af>")),B.bind("zip",It(s.zip,"<a+>")),B.bind("filter",It(s.filter,"<af>")),B.bind("single",It(s.single,"<af?>")),B.bind("reduce",It(s.foldLeft,"<afj?:j>")),B.bind("sift",It(s.sift,"<o-f?:o>")),B.bind("keys",It(s.keys,"<x-:a<s>>")),B.bind("lookup",It(s.lookup,"<x-s:x>")),B.bind("append",It(s.append,"<xx:a>")),B.bind("exists",It(s.exists,"<x:b>")),B.bind("spread",It(s.spread,"<x-:a<o>>")),B.bind("merge",It(s.merge,"<a<o>:o>")),B.bind("reverse",It(s.reverse,"<a:a>")),B.bind("each",It(s.each,"<o-f:a>")),B.bind("error",It(s.error,"<s?:x>")),B.bind("assert",It(s.assert,"<bs?:x>")),B.bind("type",It(s.type,"<x:s>")),B.bind("sort",It(s.sort,"<af?:a>")),B.bind("shuffle",It(s.shuffle,"<a:a>")),B.bind("distinct",It(s.distinct,"<x:x>")),B.bind("base64encode",It(s.base64encode,"<s-:s>")),B.bind("base64decode",It(s.base64decode,"<s-:s>")),B.bind("encodeUrlComponent",It(s.encodeUrlComponent,"<s-:s>")),B.bind("encodeUrl",It(s.encodeUrl,"<s-:s>")),B.bind("decodeUrlComponent",It(s.decodeUrlComponent,"<s-:s>")),B.bind("decodeUrl",It(s.decodeUrl,"<s-:s>")),B.bind("eval",It(Rt,"<sx?:x>")),B.bind("toMillis",It(a.toMillis,"<s-s?:n>")),B.bind("fromMillis",It(a.fromMillis,"<n-s?s?:s>")),B.bind("clone",It(Ot,"<(oa)-:o>"));var Dt={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Ft(t){var e=Dt[t.code];if(void 0!==e){var r=e.replace(/\{\{\{([^}]+)}}}/g,(function(){return t[arguments[1]]}));r=r.replace(/\{\{([^}]+)}}/g,(function(){return JSON.stringify(t[arguments[1]])})),t.message=r}}function Nt(t,e){var r,n;try{r=l(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Ft(t),t}var i=Lt(B),s=new Date;return i.bind("now",It((function(t,e){return a.fromMillis(s.getTime(),t,e)}),"<s?s?:s>")),i.bind("millis",It((function(){return s.getTime()}),"<:n>")),e&&e.RegexEngine?Nt.RegexEngine=e.RegexEngine:Nt.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==n){var o={code:"S0500",position:0};throw Ft(o),o}var l,h,c;if(void 0!==e)for(var u in l=Lt(i),e)l.bind(u,e[u]);else l=i;if(l.bind("$",t),s=new Date,l.timestamp=s,Array.isArray(t)&&!O(t)&&((t=R(t)).outerWrapper=!0),"function"==typeof a){l.async=!0;var d=function(t){Ft(t),a(t,null)},p=function t(e){(h=c.next(e)).done?a(null,h.value):h.value.then(t).catch(d)};c=z(r,t,l),(h=c.next()).value.then(p).catch(d)}else try{for(c=z(r,t,l),h=c.next();!h.done;)h=c.next(h.value);return h.value}catch(o){throw Ft(o),o}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,r){var n=It(e,r);i.bind(t,n)},ast:function(){return r},errors:function(){return n}}}return Nt.parser=l,Nt}();e.exports=c},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,r){var n=t("./signature"),i=function(){var t={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},e={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},r=function(r){var n=0,i=r.length,a=function(t,e){return{type:t,value:e,position:n}},s=function(){for(var t,e,a=n,s=0;n<i;){var o=r.charAt(n);if("/"===o&&"\\"!==r.charAt(n-1)&&0===s){if(""===(t=r.substring(a,n)))throw{code:"S0301",stack:(new Error).stack,position:n};for(n++,o=r.charAt(n),a=n;"i"===o||"m"===o;)n++,o=r.charAt(n);return e=r.substring(a,n)+"g",new RegExp(t,e)}"("!==o&&"["!==o&&"{"!==o||"\\"===r.charAt(n-1)||s++,")"!==o&&"]"!==o&&"}"!==o||"\\"===r.charAt(n-1)||s--,n++}throw{code:"S0302",stack:(new Error).stack,position:n}},o=function o(l){if(n>=i)return null;for(var h=r.charAt(n);n<i&&" \t\n\r\v".indexOf(h)>-1;)n++,h=r.charAt(n);if("/"===h&&"*"===r.charAt(n+1)){var c=n;for(n+=2,h=r.charAt(n);"*"!==h||"/"!==r.charAt(n+1);)if(h=r.charAt(++n),n>=i)throw{code:"S0106",stack:(new Error).stack,position:c};return n+=2,h=r.charAt(n),o(l)}if(!0!==l&&"/"===h)return n++,a("regex",s());if("."===h&&"."===r.charAt(n+1))return n+=2,a("operator","..");if(":"===h&&"="===r.charAt(n+1))return n+=2,a("operator",":=");if("!"===h&&"="===r.charAt(n+1))return n+=2,a("operator","!=");if(">"===h&&"="===r.charAt(n+1))return n+=2,a("operator",">=");if("<"===h&&"="===r.charAt(n+1))return n+=2,a("operator","<=");if("*"===h&&"*"===r.charAt(n+1))return n+=2,a("operator","**");if("~"===h&&">"===r.charAt(n+1))return n+=2,a("operator","~>");if(Object.prototype.hasOwnProperty.call(t,h))return n++,a("operator",h);if('"'===h||"'"===h){var u=h;n++;for(var d="";n<i;){if("\\"===(h=r.charAt(n)))if(n++,h=r.charAt(n),Object.prototype.hasOwnProperty.call(e,h))d+=e[h];else{if("u"!==h)throw{code:"S0103",stack:(new Error).stack,position:n,token:h};var p=r.substr(n+1,4);if(!/^[0-9a-fA-F]+$/.test(p))throw{code:"S0104",stack:(new Error).stack,position:n};var f=parseInt(p,16);d+=String.fromCharCode(f),n+=4}else{if(h===u)return n++,a("string",d);d+=h}n++}throw{code:"S0101",stack:(new Error).stack,position:n}}var g,v=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(r.substring(n));if(null!==v){var m=parseFloat(v[0]);if(!isNaN(m)&&isFinite(m))return n+=v[0].length,a("number",m);throw{code:"S0102",stack:(new Error).stack,position:n,token:v[0]}}if("`"===h){n++;var y=r.indexOf("`",n);if(-1!==y)return g=r.substring(n,y),n=y+1,a("name",g);throw n=i,{code:"S0105",stack:(new Error).stack,position:n}}for(var b,w=n;;)if(b=r.charAt(w),w===i||" \t\n\r\v".indexOf(b)>-1||Object.prototype.hasOwnProperty.call(t,b)){if("$"===r.charAt(n))return g=r.substring(n+1,w),n=w,a("variable",g);switch(g=r.substring(n,w),n=w,g){case"or":case"in":case"and":return a("operator",g);case"true":return a("value",!0);case"false":return a("value",!1);case"null":return a("value",null);default:return n===i&&""===g?null:a("name",g)}}else w++};return o},i=function(e,i){var a,s,o={},l=[],h=function(){var t=[];"(end)"!==a.id&&t.push({type:a.type,value:a.value,position:a.position});for(var e=s();null!==e;)t.push(e),e=s();return t},c={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=h(),t.type="error",l.push(t),t;throw t.stack=(new Error).stack,t}},u=function(t,e){var r=o[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(c)).id=r.value=t,r.lbp=e,o[t]=r),r},d=function(t){if(i){t.remaining=h(),l.push(t);var e=o["(error)"];return(a=Object.create(e)).error=t,a.type="(error)",a}throw t.stack=(new Error).stack,t},p=function(t,r){if(t&&a.id!==t){var n={code:"(end)"===a.id?"S0203":"S0202",position:a.position,token:a.value,value:t};return d(n)}var i=s(r);if(null===i)return(a=o["(end)"]).position=e.length,a;var l,h=i.value,c=i.type;switch(c){case"name":case"variable":l=o["(name)"];break;case"operator":if(!(l=o[h]))return d({code:"S0204",stack:(new Error).stack,position:i.position,token:h});break;case"string":case"number":case"value":l=o["(literal)"];break;case"regex":c="regex",l=o["(regex)"];break;default:return d({code:"S0205",stack:(new Error).stack,position:i.position,token:h})}return(a=Object.create(l)).value=h,a.type=c,a.position=i.position,a},f=function(t){var e,r=a;for(p(null,!0),e=r.nud();t<a.lbp;)r=a,p(),e=r.led(e);return e},g=function(t){u(t,0).nud=function(){return this}},v=function(e,r,n){var i=r||t[e],a=u(e,i);return a.led=n||function(t){return this.lhs=t,this.rhs=f(i),this.type="binary",this},a},m=function(t,e,r){var n=u(t,e);return n.led=r,n},y=function(t,e){var r=u(t);return r.nud=e||function(){return this.expression=f(70),this.type="unary",this},r};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),u(":"),u(";"),u(","),u(")"),u("]"),u("}"),u(".."),v("."),v("+"),v("-"),v("*"),v("/"),v("%"),v("="),v("<"),v(">"),v("!="),v("<="),v(">="),v("&"),v("and"),v("or"),v("in"),g("and"),g("or"),g("in"),y("-"),v("~>"),m("(error)",10,(function(t){return this.lhs=t,this.error=a.error,this.remaining=h(),this.type="error",this})),y("*",(function(){return this.type="wildcard",this})),y("**",(function(){return this.type="descendant",this})),y("%",(function(){return this.type="parent",this})),v("(",t["("],(function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==a.id)for(;"operator"===a.type&&"?"===a.id?(this.type="partial",this.arguments.push(a),p("?")):this.arguments.push(f(0)),","===a.id;)p(",");if(p(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach((function(t,e){if("variable"!==t.type)return d({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})})),this.type="lambda","<"===a.id){for(var e=a.position,r=1,i="<";r>0&&"{"!==a.id&&"(end)"!==a.id;){var s=p();">"===s.id?r--:"<"===s.id&&r++,i+=s.value}p(">");try{this.signature=n(i)}catch(t){return t.position=e+t.offset,d(t)}}p("{"),this.body=f(0),p("}")}return this})),y("(",(function(){for(var t=[];")"!==a.id&&(t.push(f(0)),";"===a.id);)p(";");return p(")",!0),this.type="block",this.expressions=t,this})),y("[",(function(){var t=[];if("]"!==a.id)for(;;){var e=f(0);if(".."===a.id){var r={type:"binary",value:"..",position:a.position,lhs:e};p(".."),r.rhs=f(0),e=r}if(t.push(e),","!==a.id)break;p(",")}return p("]",!0),this.expressions=t,this.type="unary",this})),v("[",t["["],(function(e){if("]"===a.id){for(var r=e;r&&"binary"===r.type&&"["===r.value;)r=r.lhs;return r.keepArray=!0,p("]"),e}return this.lhs=e,this.rhs=f(t["]"]),this.type="binary",p("]",!0),this})),v("^",t["^"],(function(t){p("(");for(var e=[];;){var r={descending:!1};if("<"===a.id?p("<"):">"===a.id&&(r.descending=!0,p(">")),r.expression=f(0),e.push(r),","!==a.id)break;p(",")}return p(")"),this.lhs=t,this.rhs=e,this.type="binary",this}));var b=function(t){var e=[];if("}"!==a.id)for(;;){var r=f(0);p(":");var n=f(0);if(e.push([r,n]),","!==a.id)break;p(",")}return p("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};y("{",b),v("{",t["{"],b),m(":=",t[":="],(function(e){return"variable"!==e.type?d({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=f(t[":="]-1),this.type="binary",this)})),v("@",t["@"],(function(e){return this.lhs=e,this.rhs=f(t["@"]),"variable"!==this.rhs.type?d({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)})),v("#",t["#"],(function(e){return this.lhs=e,this.rhs=f(t["#"]),"variable"!==this.rhs.type?d({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)})),v("?",t["?"],(function(t){return this.type="condition",this.condition=t,this.then=f(0),":"===a.id&&(p(":"),this.else=f(0)),this})),y("|",(function(){return this.type="transform",this.pattern=f(0),p("|"),this.update=f(0),","===a.id&&(p(","),this.delete=f(0)),p("|"),this}));var w=function t(e){var r;if("function"!==e.type||e.predicate)if("condition"===e.type)e.then=t(e.then),void 0!==e.else&&(e.else=t(e.else)),r=e;else if("block"===e.type){var n=e.expressions.length;n>0&&(e.expressions[n-1]=t(e.expressions[n-1])),r=e}else r=e;else{var i={type:"lambda",thunk:!0,arguments:[],position:e.position};i.body=e,r=i}return r},x=0,A=0,_=[],k=function t(e,r){switch(e.type){case"name":case"wildcard":r.level--,0===r.level&&(void 0===e.ancestor||(_[r.index].slot.label=e.ancestor.label),e.ancestor=r,e.tuple=!0);break;case"parent":r.level++;break;case"block":e.expressions.length>0&&(e.tuple=!0,r=t(e.expressions[e.expressions.length-1],r));break;case"path":e.tuple=!0;var n=e.steps.length-1;for(r=t(e.steps[n--],r);r.level>0&&n>=0;)r=t(e.steps[n--],r);break;default:throw{code:"S0217",token:e.type,position:e.position}}return r},S=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var r=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&r.push(e.slot),void 0===t.seekingParent?t.seekingParent=r:Array.prototype.push.apply(t.seekingParent,r)}},E=function(t){var e=t.steps.length-1,r=t.steps[e],n=void 0!==r.seekingParent?r.seekingParent:[];"parent"===r.type&&n.push(r.slot);for(var i=0;i<n.length;i++){var a=n[i];for(e=t.steps.length-2;a.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[a]:t.seekingParent.push(a);break}for(var s=t.steps[e--];e>=0&&s.focus&&t.steps[e].focus;)s=t.steps[e--];a=k(s,a)}}},M=function t(e){var r;switch(e.type){case"binary":switch(e.value){case".":var n=t(e.lhs);r="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(r.seekingParent=[n.slot]);var a=t(e.rhs);"function"===a.type&&"path"===a.procedure.type&&1===a.procedure.steps.length&&"name"===a.procedure.steps[0].type&&"function"===r.steps[r.steps.length-1].type&&(r.steps[r.steps.length-1].nextFunction=a.procedure.steps[0].value),"path"===a.type?Array.prototype.push.apply(r.steps,a.steps):(void 0!==a.predicate&&(a.stages=a.predicate,delete a.predicate),r.steps.push(a)),r.steps.filter((function(t){if("number"===t.type||"value"===t.type)throw{code:"S0213",stack:(new Error).stack,position:t.position,value:t.value};return"string"===t.type})).forEach((function(t){t.type="name"})),r.steps.filter((function(t){return!0===t.keepArray})).length>0&&(r.keepSingletonArray=!0);var s=r.steps[0];"unary"===s.type&&"["===s.value&&(s.consarray=!0);var o=r.steps[r.steps.length-1];"unary"===o.type&&"["===o.value&&(o.consarray=!0),E(r);break;case"[":var h=r=t(e.lhs),c="predicate";if("path"===r.type&&(h=r.steps[r.steps.length-1],c="stages"),void 0!==h.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===h[c]&&(h[c]=[]);var u=t(e.rhs);void 0!==u.seekingParent&&(u.seekingParent.forEach((function(t){1===t.level?k(h,t):t.level--})),S(h,u)),h[c].push({type:"filter",expr:u,position:e.position});break;case"{":if(void 0!==(r=t(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};r.group={lhs:e.rhs.map((function(e){return[t(e[0]),t(e[1])]})),position:e.position};break;case"^":"path"!==(r=t(e.lhs)).type&&(r={type:"path",steps:[r]});var d={type:"sort",position:e.position};d.terms=e.rhs.map((function(e){var r=t(e.expression);return S(d,r),{descending:e.descending,expression:r}})),r.steps.push(d),E(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),S(r,r.rhs);break;case"@":if(r=t(e.lhs),h=r,"path"===r.type&&(h=r.steps[r.steps.length-1]),void 0!==h.stages||void 0!==h.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===h.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(h.keepArray=!0),h.focus=e.rhs.value,h.tuple=!0;break;case"#":r=t(e.lhs),h=r,"path"===r.type?h=r.steps[r.steps.length-1]:(r={type:"path",steps:[r]},void 0!==h.predicate&&(h.stages=h.predicate,delete h.predicate)),void 0===h.stages?h.index=e.rhs.value:h.stages.push({type:"index",value:e.rhs.value,position:e.position}),h.tuple=!0;break;case"~>":(r={type:"apply",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs);break;default:(r={type:e.type,value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),S(r,r.lhs),S(r,r.rhs)}break;case"unary":r={type:e.type,value:e.value,position:e.position},"["===e.value?r.expressions=e.expressions.map((function(e){var n=t(e);return S(r,n),n})):"{"===e.value?r.lhs=e.lhs.map((function(e){var n=t(e[0]);S(r,n);var i=t(e[1]);return S(r,i),[n,i]})):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:S(r,r.expression));break;case"function":case"partial":(r={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map((function(e){var n=t(e);return S(r,n),n})),r.procedure=t(e.procedure);break;case"lambda":r={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var p=t(e.body);r.body=w(p);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),S(r,r.condition),r.then=t(e.then),S(r,r.then),void 0!==e.else&&(r.else=t(e.else),S(r,r.else));break;case"transform":(r={type:e.type,position:e.position}).pattern=t(e.pattern),r.update=t(e.update),void 0!==e.delete&&(r.delete=t(e.delete));break;case"block":(r={type:e.type,position:e.position}).expressions=e.expressions.map((function(e){var n=t(e);return S(r,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(r.consarray=!0),n}));break;case"name":r={type:"path",steps:[e]},e.keepArray&&(r.keepSingletonArray=!0);break;case"parent":r={type:"parent",slot:{label:"!"+x++,level:1,index:A++}},_.push(r);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":r=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",r=t(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};r=e}break;case"error":r=e,e.lhs&&(r=t(e.lhs));break;default:var f="S0206";"(end)"===e.id&&(f="S0207");var g={code:f,position:e.position,token:e.value};if(i)return l.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(r.keepArray=!0),r};s=r(e),p();var T=f(0);if("(end)"!==a.id){var C={code:"S0201",position:a.position,token:a.value};d(C)}if("parent"===(T=M(T)).type||void 0!==T.seekingParent)throw{code:"S0217",token:T.type,position:T.position};return l.length>0&&(T.errors=l),T};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,r){function n(t){return n="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},n(t)}var i=t("./utils"),a=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var r=1,a=[],s={},o=s;r<e.length;){var l=e.charAt(r);if(":"===l)break;var h=function(){a.push(s),o=s,s={}},c=function(t,e,r,n){for(var i=1,a=e;a<t.length;)if(a++,(l=t.charAt(a))===n){if(0==--i)break}else l===r&&i++;return a};switch(l){case"s":case"n":case"b":case"l":case"o":s.regex="["+l+"m]",s.type=l,h();break;case"a":s.regex="[asnblfom]",s.type=l,s.array=!0,h();break;case"f":s.regex="f",s.type=l,h();break;case"j":s.regex="[asnblom]",s.type=l,h();break;case"x":s.regex="[asnblfom]",s.type=l,h();break;case"-":o.context=!0,o.contextRegex=new RegExp(o.regex),o.regex+="?";break;case"?":case"+":o.regex+=l;break;case"(":var u=c(e,r,"(",")"),d=e.substring(r+1,u);if(-1!==d.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:d,offset:r};s.regex="["+d+"m]",s.type="("+d+")",r=u,h();break;case"<":if("a"!==o.type&&"f"!==o.type)throw{code:"S0401",stack:(new Error).stack,value:o.type,offset:r};var p=c(e,r,"<",">");o.subtype=e.substring(r+1,p),r=p}r++}var f="^"+a.map((function(t){return"("+t.regex+")"})).join("")+"$",g=new RegExp(f),v=function(t){var e;if(i.isFunction(t))e="f";else switch(n(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},m=function(t,e){for(var r="^",n=0,i=0;i<a.length;i++){r+=a[i].regex;var s=e.match(r);if(null===s)throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1};n=s[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1}};return{definition:e,validate:function(e,r){var n="";e.forEach((function(t){n+=v(t)}));var i=g.exec(n);if(i){var s=[],o=0;return a.forEach((function(n,a){var l=e[o],h=i[a+1];if(""===h)if(n.context&&n.contextRegex){var c=v(r);if(!n.contextRegex.test(c))throw{code:"T0411",stack:(new Error).stack,value:r,index:o+1};s.push(r)}else s.push(l),o++;else h.split("").forEach((function(r){if("a"===n.type){if("m"===r)l=void 0;else{l=e[o];var i=!0;if(void 0!==n.subtype)if("a"!==r&&h!==n.subtype)i=!1;else if("a"===r&&l.length>0){var a=v(l[0]);i=a===n.subtype.charAt(0)&&0===l.filter((function(t){return v(t)!==a})).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:l,index:o+1,type:t[n.subtype]};"a"!==r&&(l=[l])}s.push(l),o++}else s.push(l),o++}))})),s}m(e,n)}}}return e}();e.exports=a},{"./utils":6}],6:[function(t,e,r){function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}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,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(t){return s="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},s(t)}var o=function(){function t(t){var e=!1;if("number"==typeof t&&(e=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:t,stack:(new Error).stack};return e}function e(t){var e=!1;return Array.isArray(t)&&(e=0===t.filter((function(t){return"string"!=typeof t})).length),e}function r(e){var r=!1;return Array.isArray(e)&&(r=0===e.filter((function(e){return!t(e)})).length),r}function i(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function a(t){return!0===t.sequence&&Array.isArray(t)}function o(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function l(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function h(t){return t&&!0===t._jsonata_lambda}var c=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function u(t){return"object"===s(t)&&null!==t&&c in t&&"next"in t&&"function"==typeof t.next}function d(t,e){if(t===e)return!0;if("object"===s(t)&&"object"===s(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(!d(t[r],e[r]))return!1;return!0}var n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(n=n.sort(),i=i.sort(),r=0;r<n.length;r++)if(n[r]!==i[r])return!1;for(r=0;r<n.length;r++){var a=n[r];if(!d(t[a],e[a]))return!1}return!0}return!1}function p(t){var e,r=[],i=n(t);try{for(i.s();!(e=i.n()).done;){var a=e.value;r.push(a)}}catch(t){i.e(t)}finally{i.f()}return r}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:r,createSequence:i,isSequence:a,isFunction:o,isLambda:h,isIterable:u,getFunctionArity:l,isDeepEqual:d,stringToArray:p}}();e.exports=o},{}]},{},[3])(3)}(g9);var v9=g9.exports;const m9=function(t){return t};function y9(t){if(!t)return m9;try{var e=v9(t);return function(t){return e.evaluate(t)}}catch(t){return console.error(t),m9}}function b9(t){var e=P7(t);return null==e?"":String(e)}function w9(t){return Number(P7(t))}function x9(t){return t}function A9(t){return b9(t)}function _9(t){return w9(t)}function k9(t){if(this.param)return t=b9(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function S9(t){var{param:e}=this;if(e){for(let r in e){let[n,i]=r.split("~"),a=!!n,s=!!i;if(n=parseFloat(n),i=parseFloat(i),t=w9(t),a&&!s&&t>=n)return e[r];if(!a&&s&&t<n)return e[r];if(t>=n&&t<i)return e[r]}return e.default}}function E9(t){return w9(t)*Math.PI/180}function M9(){}function T9(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?A9.bind(t):"number"===i?_9.bind(t):x9.bind(e);case"map":return k9.bind(t);case"range":return S9.bind(t);case"radian":return E9.bind(t);case"eval":return function(t){try{return new Function("value","targets",t)}catch(t){return U7(t),M9}}(n).bind(e);default:return x9.bind(e)}}class C9{constructor(t,e){this.owner=e,this.model=t}dispose(){delete this._model,delete this.owner,delete this.evaluator,delete this.accessor,delete this.source}get model(){return this._model}set model(t){var{target:e,property:r,rule:n,param:i,accessor:a}=t;this._model=t,this.evaluator=T9(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=y9(a);const s=e.match(/\[(.*?)\]/);if(s){var[o,l]=s[1].split(":");this.propAccessor=y9(o),this.partAccessor=y9(l)}}get target(){return this.model.target}get property(){return this.model.property}get source(){return this.model.source}get param(){return this.model.param}get ndnsp(){return!!this.model.ndnsp}get partial(){return!!this.model.partial}}function P9(t,e,r,n){n?t.forEach((t=>t[e]={...t[e],...r})):t.forEach((t=>t[e]=r))}function I9(t=!1){(t||void 0!==this.data)&&this.mappings&&this.mappings.forEach((t=>{try{var e,{source:r,target:n,property:i,accessor:a,propAccessor:s,partAccessor:o,ndnsp:l=!1,partial:h=!1}=t;r&&"(self)"!=r?(r.startsWith("#")&&(r=r.substring(1)),e=this.root.findById(r)?.data||{}):e=this.data;var c=a(e);if("(root)"==(n=n.trim())||"(key)"==n){if(null==c)return;let e=Object.keys(c||{}).map((t=>this.root.findOrCreate(t))).filter(Boolean).flat();e.length>0&&e.forEach((e=>{let r=t.evaluator(c[e.get("id")],[e]);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||(e[i]=h?{...e[i],...r}:r)}))}else if(n.startsWith("[")){if(null==c)return;if(c instanceof Array)c.forEach((e=>{let r=s(e);if(r){let n=this.root.findOrCreate(r);if(n){let r=t.evaluator(o(e),n);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||P9(n,i,r,h)}}}));else{if(!(c instanceof Object))throw String("mapping data should be an object to target property-id.("+c+")");{let e=s(c);if(e){let r=this.root.findOrCreate(e);if(r){let e=t.evaluator(o(c),r);!i||"(action)"===i||l&&!e&&0!==e&&!1!==e||P9(r,i,e,h)}}}}}else{let e=this.root.findAll(n,this);if(e.length>0){let r=t.evaluator(c,e);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||P9(e,i,r,h)}}}catch(e){U7(e,this,t)}}))}var R9;function O9(t,e,r,n,i){var{alpha:a=1}=n,s=i.fillStyle;if(t.globalAlpha*=a,s)if("string"==typeof s)t.fillStyle=s,t.fill();else if("object"==typeof s)if("gradient"==s.type){t.translate(r.x,r.y);let n,{width:i,height:a}=e;if("linear"==s.gradientType){let e=3.141592653589793,r=s.rotation;if(r>=.436332&&r<=1.13446||r>=2.00713&&r<=2.70526||r>=3.57792&&r<=4.27606||r>=5.14872&&r<=5.84685){let s=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));s-=s-(i+a)/3,n=t.createLinearGradient(s*Math.cos(r+e),s*Math.sin(r+e),s*Math.cos(r),s*Math.sin(r))}else n=t.createLinearGradient((i-4)/2*Math.cos(r+e),(a-4)/2*Math.sin(r+e),(i-4)/2*Math.cos(r),(a-4)/2*Math.sin(r))}else if("radial"==s.gradientType){let e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));switch(s.center){case"center":default:n=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":n=t.createRadialGradient(-i/2,-a/2,0,-i/2,-a/2,2*e);break;case"right-top":n=t.createRadialGradient(i/2,-a/2,0,i/2,-a/2,2*e);break;case"left-bottom":n=t.createRadialGradient(-i/2,a/2,0,-i/2,a/2,2*e);break;case"right-bottom":n=t.createRadialGradient(i/2,a/2,0,i/2,a/2,2*e)}}s.colorStops.forEach((t=>{if(t.position>=0&&t.position<=1)try{n.addColorStop(t.position,t.color)}catch(e){H7("Invalid Color for colorstop : ",t.color),n.addColorStop(t.position,"#fff")}})),t.fillStyle=n,t.fill(),t.translate(-r.x,-r.y)}else if("pattern"==s.type&&s.image){i.prepareFillIf(!i._pattern_image_origin);var o=i._pattern_image;if(!o)return;let r=0,n=0,a=0,l=0,h=e.left,c=e.top;if(!s.fitPattern){r=s.offsetX,n=s.offsetY;const t=s.width?s.width:o.width,i=s.height?s.height:o.height;switch(s.align){case"center":a=e.width/2-t/2,l=e.height/2-i/2;break;case"left-top":a=0,l=0;break;case"left-bottom":a=0,l=e.height-i;break;case"right-top":a=e.width-t,l=0;break;case"right-bottom":a=e.width-t,l=e.height-i;break;case"left":a=0,l=e.height/2-i/2;break;case"right":a=e.width-t,l=e.height/2-i/2;break;case"top":a=e.width/2-t/2,l=0;break;case"bottom":a=e.width/2-t/2,l=e.height-i}h+=r+a,c+=n+l}t.translate(h,c),s.color&&(t.fillStyle=s.color,t.fill()),s.fitPattern?Math.abs((o.width-e.width)*(o.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(o,"no-repeat"):t.fillStyle=t.createPattern(o,s.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-h,-c)}}function L9(t,e,r){var{strokeStyle:n,lineDash:i,lineWidth:a,lineCap:s,lineJoin:o,alpha:l}=e;if(n&&0!=a){if(s&&(t.lineCap=s),i){var h="round"==s;switch(i){case"solid":i=[0,0];break;case"round-dot":i=h?[0,2*a]:[a,a];break;case"square-dot":i=h?[a,2*a]:[2*a,a];break;case"dash":i=h?[3*a,2.5*a]:[4*a,1.5*a];break;case"dash-dot":i=h?[3*a,3*a,0,3*a]:[4*a,2*a,a,2*a];break;case"long-dash":i=h?[5*a,4*a]:[6*a,3*a];break;case"long-dash-dot":i=h?[5*a,3*a,0,3*a]:[6*a,2*a,a,2*a];break;case"long-dash-dot-dot":i=h?[5*a,2*a,0,2*a,0,2*a]:[6*a,a,a,a,a,a]}t.setLineDash(i)}t.globalAlpha*=l,t.strokeStyle=n,t.lineWidth=a,t.lineJoin=o,t.stroke()}}function D9(t,e,r,n,i,a=0,s=!1,o=!0){a="number"==typeof a?{tl:a,tr:a,br:a,bl:a}:{tl:0,tr:0,br:0,bl:0,...a},t.beginPath(),t.moveTo(e+a.tl,r),t.lineTo(e+n-a.tr,r),t.quadraticCurveTo(e+n,r,e+n,r+a.tr),t.lineTo(e+n,r+i-a.br),t.quadraticCurveTo(e+n,r+i,e+n-a.br,r+i),t.lineTo(e+a.bl,r+i),t.quadraticCurveTo(e,r+i,e,r+i-a.bl),t.lineTo(e,r+a.tl),t.quadraticCurveTo(e,r,e+a.tl,r),t.closePath(),s&&t.fill(),o&&t.stroke()}function F9(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g;let r,n=[];for(;null!==(r=e.exec(t));)r[1]?n.push({text:r[2],bold:!0,italic:!1}):r[3]?n.push({text:r[4],bold:!1,italic:!0}):r[5]&&n.push({text:r[5],bold:!1,italic:!1});return n}function N9(t,e,r,n=0){if(e.text.length<2)return e;let i=2;for(;i<e.text.length;i++){const a=e.text.substring(0,i);if(!(t.measureText(a).width+(i-1)*n<r))break}return{...e,text:e.text.substring(0,i-1)}}function j9(t,e,r,n,i,a=0){const s=String(e).split("\n");return n?[].concat.apply([],s.map((e=>function(t,e,r,n=0){const i=[];let a=[],s=0;return e.forEach((e=>{let o=e.text;for(;o.length>0;){const l=r-s,h=t.measureText(o).width+(o.length-1)*n;if(h<=l)a.push({...e,text:o}),s+=h,o="";else{const r=N9(t,{...e,text:o},l,n);a.push(r),i.push(a),a=[],s=0,o=o.substring(r.text.length)}}})),a.length>0&&i.push(a),i}(t,i?F9(e):[{text:e,bold:!1,italic:!1}],r,a)))):s.map((t=>i?F9(t):[{text:t,bold:!1,italic:!1}]))}function B9(t,e,r,n,i,a,s=0){if(!n)return[];t.save(),t.font=r;var o=j9(t,n,e,!!i,a,s);return t.restore(),o}function z9(t){var{fontFamily:e=i9.FONT_FAMILY,bold:r=i9.BOLD,italic:n=i9.ITALIC,fontSize:i=i9.FONT_SIZE}=t,a=[];return r&&a.push("bold"),n&&a.push("italic"),a.push(i+"px"),a.push(e),a.join(" ")}function W9(t,e){let r=t.bold||e.bold,n=t.italic||e.italic,i=[];return r&&i.push("bold"),n&&i.push("italic"),i.push(t.fontSize+"px"),i.push(t.fontFamily),i.join(" ")}function U9(t,e,r,n){var{alpha:i,fontColor:a=i9.FONT_COLOR,textAlign:s=i9.TEXT_ALIGN,textBaseline:o=i9.TEXT_BASELINE,textBackgroundStyle:l,fontSize:h,lineHeight:c,textWrap:u,textOverflow:d,letterSpacing:p=0}=n;i=void 0!==i?i:1,h||=i9.FONT_SIZE,c||=1.2*h,t.save(),t.beginPath();var{left:f,top:g,width:v,height:m}=e;if(t.font=z9(n),!u&&d){const e=function(t,e,r,n){const i="ellipsis"===t?"…":"",a=e.measureText(i).width;let s=[],o=0;for(let i of r){let r=[];for(let l of i){let i=e.measureText(l.text).width;if(!(o+i<=n-("ellipsis"===t?a:0))){let i=H9(e,l,n-o-("ellipsis"===t?a:0),t);return r.push(i),s.push(r),s}r.push(l),o+=i}s.push(r),o=0}return s}(d,t,r,v);r=e}var y,b=r.length*c;switch(o){case"top":y=g,t.textBaseline="top";break;case"bottom":y=g+m-b+c,t.textBaseline="bottom";break;default:y=g+m/2-b/2+c/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,r.forEach(((e,i)=>{let o=y+i*c,u=function(t,e,r,n=0){return e.reduce(((e,i)=>(t.font=W9(r,i),e+t.measureText(i.text).width+n*(i.text.length-1))),0)}(t,e,n,p),d=f;switch(s){case"left":case"justify":d=f;break;case"right":d=f+v-u;break;case"center":d=f+(v-u)/2}if(l&&(t.fillStyle=l,D9(t,d-4,o-h/2-4,u+8,h+8,4,!0,!1),t.fillStyle=a),"justify"===s&&i<r.length-1&&e.length>1){let r=v-u,i=e.length-1,a=r/i;e.forEach(((e,r)=>{t.font=W9(n,e),t.fillText(e.text,d,o),d+=t.measureText(e.text).width+(r<i?a:0)}))}else e.forEach((e=>{t.font=W9(n,e),[...e.text].forEach((e=>{t.fillText(e,d,o),d+=t.measureText(e).width+p}))}))})),t.restore()}function H9(t,e,r,n){let i="";for(let n=0;n<e.text.length;n++){let a=i+e.text[n];if(t.measureText(a).width>r)break;i=a}return{...e,text:i+("ellipsis"===n?"…":"")}}function G9(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){const a=Math.cos(-n),s=Math.sin(-n);return{x:((t-=r.x)*a-(e-=r.y)*s+r.x)/i.x,y:(t*s+e*a+r.y)/i.y}}function Y9(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){const a=Math.cos(n),s=Math.sin(n);return{x:((t-=r.x)*a-(e-=r.y)*s+r.x)*i.x,y:(t*s+e*a+r.y)*i.y}}function V9(t){var e=t.element,r=t.fillStyle,n=e.style;if(r)if("string"==typeof r)n.backgroundColor=r;else switch(r.type){case"pattern":if(n.backgroundImage="url("+r.image+")",n.backgroundColor="transparent",r.fitPattern?n.backgroundSize="100% 100%":r.width||r.height?n.backgroundSize=`${r.width?r.width+"px":"auto"} ${r.height?r.height+"px":"auto"}`:n.backgroundSize="contain",r.fitPattern)n.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:a,color:s}=r;if(i&&(n.backgroundRepeat="no-repeat"),s&&(n.backgroundColor=s),a)switch(a){case"center":n.backgroundPosition="center center";break;case"left-top":n.backgroundPosition="left top";break;case"left-bottom":n.backgroundPosition="left bottom";break;case"right-top":n.backgroundPosition="right top";break;case"right-bottom":n.backgroundPosition="right bottom";break;case"left":n.backgroundPosition="left center";break;case"right":n.backgroundPosition="right center";break;case"top":n.backgroundPosition="center top";break;case"bottom":n.backgroundPosition="center bottom"}else t||e?n.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete n.backgroundPosition}break;case"gradient":n.background=function(t,e){var r=e.colorStops,n=e.gradientType;if(r instanceof Array&&r.length>0)switch(n){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){var{width:r,height:n}=t.bounds;switch(e){case"center":return[r/2,n/2];case"left-top":return[0,0];case"right-top":return[r,0];case"left-bottom":return[0,n];default:return[r,n]}}(t,e.center||"center").map((t=>t+"px")).join(" ")+","+r.map((t=>`${t.color} ${100*t.position}%`)).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+r.map((t=>`${t.color} ${100*t.position}%`)).join(",")+")"}return""}(t,r)}else n.background="transparent"}R9="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){var r=document.createElement("canvas");return r.width=t,r.height=e,r};const q9={x:1,y:1},X9={x:0,y:0},$9={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function K9(t){var{id:e,scale:r=q9,translate:n=X9,bold:i,italic:a,fontFamily:s="",textAlign:o,textBaseline:l,textOverflow:h,paddingTop:c,paddingBottom:u,paddingLeft:d,paddingRight:p,fontSize:f=i9.FONT_SIZE,lineWidth:g=0,lineHeight:v,lineDash:m}=t.state;u||=0,c||=0,d||=0,p||=0;var y=t.state.class;t.text;var{strokeStyle:b,fillStyle:w,rotation:x=0,fontColor:A,hidden:_}=t,{left:k,top:S,width:E,height:M}=t.bounds,T=t.element;if(T.hidden=_,e&&(T.id=e),y&&(T.className=y),Object.assign(T.style,$9,{fontFamily:s,fontSize:f+"px",width:E+"px",height:M+"px",paddingTop:c+"px",paddingRight:p+"px",paddingBottom:u+"px",paddingLeft:d+"px",border:g+"px",borderColor:b,borderStyle:g>0?m||i9.LINE_DASH:"",color:A,fontWeight:i?"bold":"",fontStyle:a?"italic":"",textAlign:"end"==o?"right":"start"==o?"left":o,verticalAlign:l,lineHeight:void 0===v?"":v+"px",whiteSpace:h?"nowrap":"",overflow:h?"hidden":"",textOverflow:h||""},t.isIn3DSpace()?{}:{left:k+"px",top:S+"px"}),V9(t),function(t){if(t.isShadowable()&&t.state.shadow){var e=t.element,{left:r=0,top:n=0,blurSize:i=0,color:a="transparent"}=t.state.shadow;e.style.boxShadow=`${r}px ${n}px ${i}px ${a}`}}(t),!t.isIn3DSpace()){var C=t.delta(),P=(r&&r.x||1)*C.sx,I=(r&&r.y||1)*C.sy,R=(x||0)+C.theta,O=C.tx||0,L=C.ty||0;T.style.transform=`rotate(${R}rad) translate(${O}px, ${L}px) scale(${P}, ${I}) perspective(1px)`}}var Q9,J9=[];function Z9(){Q9=null;var t=performance.now(),e=(J9=J9.filter((t=>ttt(t)))).reduce(((e,r)=>{let n=t-r.updatedAt;return n>=r.retention?e.kills.push(r):e.next=0==e.next?r.retention-n:Math.min(e.next,r.retention-n),e}),{next:0,kills:[]});e.kills.forEach((t=>{let e=J9.indexOf(t);-1!=e?(J9.splice(e,1),t.removeSelf(!0)):U7("Should not be here. Maybe reentrance problem.")})),e.next>0&&(Q9=setTimeout(ett,Math.max(e.next,500)))}function ttt(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var ett=A7((function(){requestAnimationFrame(Z9)}),500);var rtt=new class{add(t){ttt(t)&&-1==J9.indexOf(t)&&(J9.push(t),t.touch()),this.touch()}remove(t){var e=J9.indexOf(t);e>0&&J9.splice(e,1),this.touch()}touch(){null!==Q9&&(clearTimeout(Q9),Q9=null),ett()}get length(){return J9.length}};const ntt=function(t){return t};function itt(t){var e=t.indexOf("||"),r="",n="";-1!=e&&(r=t,n=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());var i=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter((t=>!!t.trim())),a=i.slice(1);return{defaultValue:n,match:t,originText:r||t,target:i[0],accessor:a.length>0?function(t){return a.reduce(((t,e)=>t?t[e]:void 0),t)}:ntt}}function att(t,e,r){if(t){var n=r||P7,i=String(t),a=(i.match(/#{[^}]*}/gi)||[]).map((t=>itt(t))),s=(i.match(/\${[^}]*}/gi)||[]).map((t=>itt(t)));if(0!=a.length||0!=s.length)return function(){var t=i;return a.forEach((r=>{let i=n(r.accessor(e.getState(r.target)));t=t.replace(r.originText,void 0===i?r.defaultValue||"":i)})),s.forEach((r=>{let i=e.root.findById(r.target),a=n(r.accessor(i&&i.data));t=t.replace(r.originText,void 0===a?r.defaultValue||"":a)})),t}}}const stt=210*Math.PI/180,ott=150*Math.PI/180;var ltt={"data-spread":function(t,e,r){if(t.app.isEditMode){var n=!1;return t.mappings&&t.mappings.forEach((r=>{let i=t.root.findAll(r.target,t);i&&(e.lineWidth=2,i.forEach((r=>{let i=t.center,a=r.center;i=t.transcoordS2C(i.x,i.y,t.rootModel),a=r.transcoordS2C(a.x,a.y,r.rootModel),e.beginPath();const s=e.createLinearGradient(i.x,i.y,a.x,a.y);["#FFA50033","#FFA500"].forEach(((t,e)=>s.addColorStop(e,t))),e.strokeStyle=s,e.fillStyle=s,function(t,e,r,n=10){var i=r.x-e.x,a=r.y-e.y,s=Math.atan2(a,i),o=r.x+n*Math.cos(s+stt),l=r.y+n*Math.sin(s+stt),h=r.x+n*Math.cos(s+ott),c=r.y+n*Math.sin(s+ott);t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(r.x,r.y),t.moveTo(r.x,r.y),t.lineTo(o,l),t.moveTo(r.x,r.y),t.lineTo(h,c),t.stroke()}(e,i,a),n=!0})))})),n}},"bouncing-arrow":function(t,e,r){let{left:n,top:i,width:a}=t.bounds,s=t.state.id,{x:o,y:l}=t.transcoordS2C(n+a/2,i,t.rootModel);const h=2*function(t){const e=100*(1-t)%10;return e<5?e:10-e}(r||0);if(o=Math.max(o,20),l=Math.max(l,20),e.beginPath(),e.moveTo(o-10,l-16+h),e.lineTo(o+10,l-16+h),e.lineTo(o+10,l-8+h),e.lineTo(o+16,l-8+h),e.lineTo(o,l+h),e.lineTo(o-16,l-8+h),e.lineTo(o-10,l-8+h),e.lineTo(o-10,l-16+h),e.lineTo(o-10,l-16+h),e.fillStyle="#FF0000",e.fill(),s){e.beginPath(),e.font="12px Arial";let t=e.measureText(s);e.fillStyle="#FF0000",e.roundRect(o-t.actualBoundingBoxLeft-3+20,l-t.actualBoundingBoxAscent-3-6+h,t.actualBoundingBoxLeft+t.actualBoundingBoxRight+6,t.actualBoundingBoxAscent+t.actualBoundingBoxDescent+6,3),e.fill(),e.fillStyle="white",e.fillText(s,o+20,l-6+h)}return!0},decotag:function(t,e,r){const n=t.decotag;if(n){let{left:r,top:i}=t.bounds,{x:a,y:s}=t.transcoordS2C(r,i,t.rootModel);a=Math.max(a+3,5),s=Math.max(s-8,15),e.font="12px Arial";let o=e.measureText(n);return e.beginPath(),e.fillStyle="#FF0000",e.roundRect(a-o.actualBoundingBoxLeft-3,s-o.actualBoundingBoxAscent-3,o.actualBoundingBoxLeft+o.actualBoundingBoxRight+6,o.actualBoundingBoxAscent+o.actualBoundingBoxDescent+6,3),e.fill(),e.beginPath(),e.fillStyle="white",e.fillText(n,a,s),!0}return!1},anchors:function(t,e,r){if(t.app.isEditMode){var n=!1;return t.anchors&&t.anchors.forEach((r=>{const{name:i,position:a}=r;var{x:s,y:o}=a||{};if(!i)return;var{x:s,y:o}=t.transcoordS2C(s,o,t.rootModel);s+=4,o+=4,e.font="12px Arial";let l=e.measureText(i);e.fillStyle="#FF0000",D9(e,s,o,l.width+6,16,3,!0,!1),e.fillStyle="white",e.fillText(i,s+3,o+13),n=!0})),n}},link:function(t,e,r){var n=!1;if(!t.isLine())return;const{fromEnd:i,toEnd:a}=t;return[i,a].filter(Boolean).forEach((t=>{const{component:r,anchor:i}=t;if(!i)return;const{name:a,position:s}=i||{};if(!a||!s)return;var{x:o,y:l}=s||{},{x:o,y:l}=r.transcoordS2C(o,l,r.rootModel);o+=8,l+=20,e.font="12px Arial";let h=e.measureText(a);e.fillStyle="#FF0000",D9(e,o-h.actualBoundingBoxLeft-4,l-h.actualBoundingBoxAscent-4,h.actualBoundingBoxLeft+h.actualBoundingBoxRight+8,h.actualBoundingBoxAscent+h.actualBoundingBoxDescent+8,4,!0,!1),e.fillStyle="white",e.fillText(a,o,l),n=!0})),n}};function htt(t){return ltt[t]}var ctt={};const utt={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},dtt=[],ptt={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};var ftt=0,gtt={};const vtt=new FinalizationRegistry((t=>{!function(t){ftt--;var e=gtt[t];e||(e=gtt[t]={up:0,down:0}),e.down++}(t)}));class mtt{static get nature(){return utt}static register(t,e){if(!e)return ctt[t];ctt[t]=e}static get residents(){return gtt}static get residentsCount(){return ftt}static registerDecorator(t,e){!function(t,e){ltt[t]=e}(t,e)}constructor(t,e){this._app=e,this._model=t||{},this._state={},this._delta=h7(ptt),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),rtt.add(this),function(t){ftt++;var e=gtt[t];e||(e=gtt[t]={up:0,down:0}),e.up++}(t.type),vtt.register(this,t.type)}created(){}added(t){}removed(t){}async ready(){if(this.state.persistent){const{isViewMode:t,dataStorage:e}=this.app;t&&(this.data=await e.load(this))}}touch(){this.updatedAt=performance.now()}clearCache(...t){!function(t,...e){0==e.length?t.__cache__={}:e.forEach((e=>delete t.__cache__[e]))}(this,...t)}removeSelf(t){t?this.dispose():this.parent&&this.parent.removeComponent(this)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=h7(ptt))}dispose(){this.resetAnimation(),this.disposeMappings(),this.parent&&this.parent.removeComponent(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this.retention&&rtt.touch(),this.clearCache(),delete this._app}get nature(){return this.constructor.nature}get disposed(){return!!this._disposed}isLayer(){return!1}isGroup(){return!1}isContainer(){return!1}isLine(){return!1}isRoot(){return!1}isRootModel(){return!1}is3dish(){return!1}isIn3DSpace(){return!1}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}replaceRefids(t){}get retention(){return Number(this.get("retention"))||0}get hasTextProperty(){return!0}get app(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}get model(){return this._model}get state(){return Object.assign({},this._model,this._state)}get hierarchy(){var t=h7(this._model);return this.volatile.forEach((e=>{delete t[e]})),t}get volatile(){return dtt}get textHidden(){return!!this._textHidden}set textHidden(t){this._textHidden=!!t,this.invalidate()}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});var r={},n={},i=!1,a=(t=h7(t),this);return Object.getOwnPropertyNames(t).forEach((function(e){let s=a._model[e],o=t[e];T6(s,o)||(n[e]=s,r[e]=o,a._model[e]=o,delete a._state[e],i=!0)})),i&&(this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,r.hasOwnProperty("retention")&&rtt.add(this),r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,n),r.hasOwnProperty("mappings")&&this.onchangeMappings(r,n),r.hasOwnProperty("data")&&this.onchangeData(r,n),this.onchange&&this.onchange(r,n),this.trigger("change",r,n)),this}getState(t){return this._state.hasOwnProperty(t)?this._state[t]:this.get(t)}setState(t,e){if("string"==typeof t)return this.setState({[t]:e});var r={},n={},i=!1,a=(t=h7(t),this),s=this.getState("sensitive");return Object.getOwnPropertyNames(t).forEach((function(e){let o=a.getState(e),l=t[e];!s&&T6(o,l)||(n[e]=o,r[e]=l,a._state[e]=l,i=!0)})),i&&(this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,n),r.hasOwnProperty("data")&&this.onchangeData(r,n),this.onchange&&this.onchange(r,n),this.trigger("change",r,n)),this}get root(){return this.isRoot()?this:this.parent&&this.parent.root}get rootModel(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}get parent(){return this._parent}set parent(t){this._parent=t}get anchors(){return this.nature.anchors||[]}findAnchor(t){return this.anchors.find((e=>e.name===t))}isDescendible(t){return!0}getContext(){return this._parent.getContext()}get center(){var t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}set center(t){if(t&&!isNaN(t.x)&&!isNaN(t.y)){var e=this.center;if(Math.round(100*t.x)/100!=Math.round(100*e.x)/100||Math.round(100*t.y)/100!=Math.round(100*e.y)/100){var r=t.x-e.x,n=t.y-e.y;this.path=this.path.map((t=>({x:t.x+r,y:t.y+n})))}}}get location(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}set location(t){const{x:e,y:r,z:n}=t||{};this.center={x:e,y:r},isNaN(n)||this.setState("zPos",Number(n))}get rotate(){const{rotationX:t,rotationY:e,rotation:r}=this.state;return{x:t,y:e,z:-r}}set rotate(t){const{x:e,y:r,z:n}=t;this.setState({rotationX:e,rotationY:r,rotation:-n})}get dimension(){const{width:t,height:e}=this.bounds,{depth:r}=this.state;return{width:t,height:e,depth:r}}set dimension(t){const{width:e,height:r,depth:n}=t,{top:i,left:a}=this.bounds;this.bounds={top:i,left:a,width:e,height:r},this.setState("depth",n)}get bounds(){var t,e,r,n,i=this.path;t=e=i[0].x,r=n=i[0].y;for(let a=1;a<i.length;a++){let s=i[a];s.x<t?t=s.x:s.x>e&&(e=s.x),s.y<r?r=s.y:s.y>n&&(n=s.y)}return{left:t,top:r,width:e-t,height:n-r}}set bounds(t){var e=this.bounds;if(Math.round(100*t.width)/100!=Math.round(100*e.width)/100||Math.round(100*t.height)/100!=Math.round(100*e.height)/100||Math.round(100*t.left)/100!=Math.round(100*e.left)/100||Math.round(100*t.top)/100!=Math.round(100*e.top)/100){var r=0==e.width?1:t.width/e.width,n=0==e.height?1:t.height/e.height;this.path=this.path.map((i=>({x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n})))}}get path(){return U7("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}set path(t){U7("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}get drawPath(){return this.path}outline(t){return function(t,e){var r=t.path.slice();if(r&&r.length){var n=1,i=[];if(t.isLine()||r.push(r[0]),e<=0)return t.transcoordS2T(r[0].x,r[0].y);if(e>=1)return t.transcoordS2T(r[r.length-1].x,r[r.length-1].y);for(;r[n];){let t=r[n-1],e=r[n],a=e.x-t.x,s=e.y-t.y;i.push(Math.sqrt(a*a+s*s)),n++}var a=i.reduce((function(t,e){return t+e}),0);n=0;var s=0;do{s+=i[n++]}while(s/a<e);e=(e-(s-=i[--n])/a)*(a/i[n]);var o=r[n%r.length],l=r[(n+1)%r.length],h=o.x+Math.round((l.x-o.x)*e),c=o.y+Math.round((l.y-o.y)*e);return t.transcoordS2T(h,c)}U7("path should not be empty")}(this,t||0)}get strokeStyle(){return this.get("strokeStyle")}set strokeStyle(t){this.set("strokeStyle",t)}get fillStyle(){return this.getState("fillStyle")}set fillStyle(t){this.setState("fillStyle",t)}get fontColor(){return this.get("fontColor")}set fontColor(t){this.set("fontColor",String(P7(t)))}get rotation(){return this.getState("rotation")}set rotation(t){this.setState("rotation",Number(P7(t)))}contains(t,e){return!1}get mutable(){return this.nature.mutable}get resizable(){return this.nature.resizable&&!this.stuck}adjustResize(t,e,r){if(r){let e=this.bounds,r=e.height/e.width,n=t.width-e.width,i=t.height-e.height;n*r>i?i=n*r:n=i/r;let a=t.left-e.left,s=t.top-e.top;return 0!=a&&0!=s?(s=-i,a=-n):0!=a?a=-n:0!=s&&(s=-i),{left:e.left+a,top:e.top+s,width:e.width+n,height:e.height+i}}return t}get rotatable(){return this.nature.rotatable&&!this.stuck}adjustRotation(t,e){if(e||this.app.rotateStepForced){let e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}get capturable(){return!1!==this.get("capturable")&&(this.app.isEditMode||!this.hidden)}get stuck(){return!!(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))}findFirst(t,...e){if(t(this,...e))return this}findAll(t,...e){return"string"==typeof t?p9(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}capture(t,e,r){if(!this.capturable||r?.(this))return!1;var n=this.transcoordP2S(t,e);return this.contains(n.x,n.y)?this:void 0}prepare(t,e){t(this)}prepareIf(t){t&&this.prepare&&this.prepare((t=>{this.invalidate()}),(t=>{U7(t)}))}get decotag(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}get decorators(){return["decotag","data-spread"]}get reactionDecorators(){return["bouncing-arrow"]}get hidden(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}set hidden(t){this.setState("hidden",t)}draw(t){t.save(),this.prerender(t),this.render(t),this.postrender(t),t.restore()}delta(t,e){if(void 0===e)return t?this._delta[t]:this._delta;this._delta[t]=e}prerender(t){var e=this.rotatePoint,{scale:r,rotation:n,shadow:i,alpha:a}=this.state,s=(r&&r.x||1)*this._delta.sx,o=(r&&r.y||1)*this._delta.sy,l=(n||0)+this._delta.theta,{tx:h=0,ty:c=0}=this._delta,u=(a||1)-this._delta.fade;(h||c)&&t.translate(h,c),(1!=s||1!=o||l)&&(t.translate(e.x,e.y),1==s&&1==o||t.scale(s,o),l&&t.rotate(l),t.translate(-e.x,-e.y)),u&&(t.globalAlpha=u),i&&s9(t,i,this),this.app.isEditMode&&this.hidden&&(t.globalAlpha*=.5)}render(t){}postrender(t){this.drawText(t)}drawText(t){!this.textHidden&&this.text&&this.hasTextProperty&&U9(t,this.textBounds,this.textLines(t),this.state)}drawStroke(t,e){L9(t,e?{...this.state,...e}:this.state)}drawFill(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(O9(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}animate(t){return this._animate&&this._animate.stop(),this._animate=D8(t),this._animate}move({x:t,y:e}){var r=this.path,n=t,i=e;this.path=r.map((t=>({x:t.x+n,y:t.y+i})))}symmetryX(t){"number"!=typeof t&&(t=this.center.x);var{rotation:e}=this.state,r=this.fillStyle;if(this.set("rotation",2*Math.PI-e),r&&"gradient"===r.type&&"linear"===r.gradientType){var n=h7(r);n.rotation=(Math.PI-parseFloat(r.rotation||0))%(2*Math.PI),this.set("fillStyle",n)}this.path=this.path.map((e=>({x:2*t-e.x,y:e.y})))}symmetryY(t){this.symmetryX(),this.set("rotation",(Math.PI+this.model.rotation)%(2*Math.PI)),t&&this.move({x:0,y:2*(t-this.center.y)},!1)}get animation(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){var t=this.state.animation;t&&t.oncreate&&(this._animation=L8(this,t.oncreate))}return this._animation}}effect(t,e){return function(t,e,r){var n=o9[r.type];n&&n(t,e,r)}(this,t,e)}get started(){return!!this.animation?.started}set started(t){this.animation&&(this.animation.started=t)}invalidate(){this.parent&&this.parent.invalidate()}get font(){return z9(this.model)}get lineHeight(){var t=this.get("lineHeight");return t||1.2*this.fontSize}defaultTextSubstitutor(){var t=this.getState("text");return null==t?"":String(t)}get textSubstitutor(){return this._text_substitutor||(this._text_substitutor=att(this.getState("text"),this)||this.defaultTextSubstitutor),this._text_substitutor}get text(){var t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;var r,n,i,a,s,o,l,h,c,u=t.length,d=t.search(/[0-9\-\+#]/),p=d>0?t.substring(0,d):"",f=t.split("").reverse().join(""),g=f.search(/[0-9\-\+#]/),v=u-g,m=t.substring(v,v+1),y=v+("."===m||","===m?1:0),b=g>0?t.substring(y,u):"";if(r=(e="-"===(t=t.substring(d,y)).charAt(0)?-e:+e)<0?e=-e:0,i=(n=t.match(/[^\d\-\+#]/g))&&n[1]&&n[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",s=t[1]&&t[1].lastIndexOf("0"),(!(l=e.split("."))[1]||l[1]&&l[1].length<=s)&&(e=(+e).toFixed(s+1)),h=t[0].split(i),t[0]=h.join(""),(a=t[0]&&t[0].indexOf("0"))>-1)for(;l[0].length<t[0].length-a;)l[0]="0"+l[0];else 0==+l[0]&&(l[0]="");if((e=e.split("."))[0]=l[0],o=h[1]&&h[h.length-1].length){for(f="",v=(c=e[0]).length%o,u=c.length,y=0;y<u;y++)f+=c.charAt(y),!((y-v+1)%o)&&y<u-o&&(f+=i);e[0]=f}return e[1]=t[1]&&e[1]?"."+e[1]:"","0"!==(n=e.join(""))&&""!==n||(r=!1),p+("+"==t[0].substring(0,1)?r?"-":"+":r?"-":"")+n+b}(t,this.textSubstitutor()):this.textSubstitutor()}set text(t){delete this._text_substitutor;var e=P7(t);this.setState("text",null==e?"":String(e))}textLines(t){const{textWrap:e,supportMarkdown:r}=this.state;return B9(t||this.getContext(),this.textBounds.width,this.font,this.text,e,r)}get textBounds(){var{paddingTop:t,paddingLeft:e,paddingRight:r,paddingBottom:n}=this.state;n||=0,t||=0,e||=0,r||=0;var{left:i,top:a,width:s,height:o}=this.bounds;return{left:i+e,top:a+t,width:Math.max(s-e-r,0),height:Math.max(o-t-n,0)}}get textRotation(){return 0}get rotatePoint(){return this.center}trim(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}get value(){var t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}set value(t){var e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}get data(){return this.getState("data")}set data(t){this.setState("data",t),this.touch()}set tap(t){var e=this.model.event?.tap;if(e){const{cx:t,cy:r}=this.center;this.rootModel?._doEventAction(e,this,!0,new CustomEvent("click",{offsetX:t,offsetY:r}))}}get mappings(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}serialize(...t){return JSON.stringify(this.hierarchy,...t)}get controls(){}closeScene(t){this.rootModel.closeScene(t)}}mtt.union=function(t){var e,r,n,i;return t.forEach((t=>{void 0===e?(e=t.left,r=t.top,n=t.left+t.width,i=t.top+t.height):(e=Math.min(t.left,e),r=Math.min(t.top,r),n=Math.max(t.left+t.width,n),i=Math.max(t.top+t.height,i))})),{left:e,top:r,width:n-e,height:i-r}},mtt.transcoordR=G9,mtt.transcoordRR=Y9,mtt.createCanvas=R9,mtt.memoize=Y7,mtt.mixin=W7,mtt.drawText=U9,mtt.font=z9,mtt.textLines=B9,mtt.drawStroke=L9,mtt.drawFill=O9,mtt.reposition=K9,mtt.RetentionManager=rtt,mtt.template=function(t,e,r){var n=A8.imports._.templateSettings||A8;r&&H6(t,e,r)&&(e=void 0),t=b8(t),e=$6({},e,n,l8);var i,a,s=$6({},e.imports,n.imports,l8),o=n6(s),l=function(t,e){return a8(e,(function(e){return t[e]}))}(s,o),h=0,c=e.interpolate||T8,u="__p += '",d=RegExp((e.escape||T8).source+"|"+c.source+"|"+(c===u8?M8:T8).source+"|"+(e.evaluate||T8).source+"|$","g"),p=P8.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(d,(function(e,r,n,s,o,l){return n||(n=s),u+=t.slice(h,l).replace(C8,c8),r&&(i=!0,u+="' +\n__e("+r+") +\n'"),o&&(a=!0,u+="';\n"+o+";\n__p += '"),n&&(u+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),h=l+e.length,e})),u+="';\n";var f=P8.call(e,"variable")&&e.variable;if(f){if(E8.test(f))throw new Error("Invalid `variable` option passed into `_.template`")}else u="with (obj) {\n"+u+"\n}\n";u=(a?u.replace(_8,""):u).replace(k8,"$1").replace(S8,"$1;"),u="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+u+"return __p\n}";var g=i8((function(){return Function(o,p+"return "+u).apply(void 0,l)}));if(g.source=u,r8(g))throw g;return g},mtt.buildSubstitutor=att,Object.assign(mtt.prototype,{drawEffect:function(t){const{effects:e}=this.state;(e||[]).forEach((e=>{this.effect(t,e)}))},prepareFill:function(t,e){var r=this.fillStyle;if(r&&"pattern"==r.type&&r.image){if("string"!=typeof r.image)return this._pattern_image_origin=this._pattern_image=r.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;var n=this;this._pattern_image_origin.onload=function(){if(!r.fitPattern&&!r.width&&!r.height)return n._pattern_image=n._pattern_image_origin,void t(this);let e=r.width||this.width,i=r.height||this.height;r.fitPattern&&(e=n.bounds.width,i=n.bounds.height);let a=R9(e,i);a.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),n._pattern_image=a,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(r.image).substring(0,4)?this._pattern_image_origin.crossOrigin="use-credentials":this._pattern_image_origin.crossOrigin=null,this._pattern_image_origin.src=this.app.url(r.image)}catch(t){e(t)}}else t(this)},prepareFillIf:function(t){t&&this.prepareFill((t=>{this.invalidate()}),(t=>{U7(t)}))},onchangeFill:function(t,e){var r=this.fillStyle;r&&"pattern"!==r.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):r?.image&&this.prepareFillIf(r.image)},drawImage:function(t,e,r,n,i,a){e.complete?t.drawImage(e,r,n,i,a):e.addEventListener("load",(()=>{this.invalidate()}))},mutateBounds:function(t,e){var r=this.bounds,n=this.rotatePoint,i=this.get("rotation"),a=this.get("scale");if(t){var s=t.call(e,r);s&&(r=s)}var{left:o,top:l,width:h,height:c}=r,u=[{x:o,y:l},{x:o+h,y:l+c}],d=(u=u.map((t=>Y9(t.x,t.y,n,i,a))))[0],p=u[1];n={x:(d.x+p.x)/2,y:(d.y+p.y)/2},d=(u=u.map((t=>G9(t.x,t.y,n,i,a))))[0],p=u[1],this.bounds={left:d.x,top:d.y,width:p.x-d.x,height:p.y-d.y}},mutatePath:function(t,e,r){var n=this.path,i=this.rotatePoint;this.get("rotation"),this.get("scale"),t&&(n=t.call(r,n));var a=n.map((t=>this.transcoordS2P(t.x,t.y)));e&&(n=e.call(r,a))&&(a=n);var s,o,l,h,c={x:0,y:0};s=o=(n=a.map((t=>this.transcoordP2S(t.x,t.y,c))))[0].x,l=h=n[0].y;for(let t=1;t<n.length;t++){let e=n[t];e.x<s?s=e.x:e.x>o&&(o=e.x),e.y<l?l=e.y:e.y>h&&(h=e.y)}i={x:(s+o)/2,y:(l+h)/2},i=this.transcoordS2P(i.x,i.y,c),this.path=a.map((t=>this.transcoordP2S(t.x,t.y,i)))},access:function(t){if(t){var e=String(t),r=(e.match(/#{(\S*)}/)||[]).map((t=>itt(t)))[0];if(r)return r.accessor(this.getState(r.target));var n=(e.match(/\${[^}]*}/)||[]).map((t=>itt(t)))[0];if(n){let t=this.root.findById(n.target);return n.accessor(this.getState(t))}return t}},substitute:function(t,e){if(t){var r=String(t),n=e||P7,i=(r.match(/#{(\S*)}/gi)||[]).map((t=>itt(t))),a=(r.match(/\${[^}]*}/gi)||[]).map((t=>itt(t)));if(0==i.length&&0==a.length)return r;var s=r;return i.forEach((t=>{let e=n(t.accessor(this.getState(t.target)));s=s.replace(t.match,void 0===e?"":e)})),a.forEach((t=>{let e=this.root.findById(t.target),r=n(t.accessor(e&&e.data));s=s.replace(t.match,void 0===r?"":r)})),s}},onchangeMappings:function(t,e){this.disposeMappings(),I9.call(this)},onchangeData:function(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),I9.call(this,[!0])},buildMappings:function(){if(this._model.mappings)return!this._model.mappings instanceof Array?(U7("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[])):void(this._mappings=(this._model.mappings||[]).filter((t=>t.rule&&t.target)).map((t=>new C9(t,this))));this._mappings=[]},executeMappings:I9,disposeMappings:function(){this._mappings&&this._mappings.forEach((t=>t.dispose())),delete this._mappings},ondropfile:function(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[r],fitPattern:!0})},transcoordS2P:function(t,e,r){if(!this.parent)return{x:t,y:e};let{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate;let a=Y9(t,e,void 0,n+this._delta.theta,i);return r&&(a.x+=r.x,a.y+=r.y),a}r=r||this.rotatePoint;const{theta:a=0,tx:s=0,ty:o=0,sx:l=1,sy:h=1}=this._delta||{};r={x:r.x+s,y:r.y+o},i={x:i.x*l,y:i.y*h};const c=Y9(t+s,e+o,r,n+a,i);return{x:c.x-(r.x*i.x-r.x),y:c.y-(r.y*i.y-r.y)}},transcoordP2S:function(t,e,r){if(!this.parent)return{x:t,y:e};const{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate;let a=G9(t,e,r,n,i);return r&&(a.x-=r.x/i.x,a.y-=r.y/i.y),a}const a=G9(t,e,r=r||this.rotatePoint,n,i);return{x:a.x+(r.x-r.x/i.x),y:a.y+(r.y-r.y/i.y)}},transcoordS2T:function(t,e,r){r=r||this.rootModel;const n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.push(t);let i=this.transcoordS2P(t,e);return n.forEach((t=>{const{scale:e}=t.model,r=t.bounds;if(e){const n=t.rotatePoint;i.x+=(n.x-r.left)*e.x,i.y+=(n.y-r.top)*e.y}else i.x+=r.left,i.y+=r.top;i=t.transcoordS2P(i.x,i.y)})),i},transcoordT2P:function(t,e,r){r=r||this.rootModel;const n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.splice(0,0,t);let i={x:t,y:e};return n.forEach((t=>{const{scale:e}=t.model;i=t.transcoordP2S(i.x,i.y);const r=t.bounds;if(e){const n=t.rotatePoint;i.x-=(n.x-r.left)/e.x,i.y-=(n.y-r.top)/e.y}else i.x-=r.left,i.y-=r.top})),i},transcoordT2S:function(t,e,r){const n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)},transcoordS2TR:function(t,e,r){r=r||this.rootModel;const n=this.transcoordS2T(t,e,r);return Y9(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)},transcoordS2O:function(t,e,r){const n=this.rootModel,i=this.transcoordS2T(t,e,n);return r.transcoordT2S(i.x,i.y,n)},transcoordC2S:function(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;const{translate:n={x:0,y:0},scale:i={x:1,y:1},rotation:a=0}=r.model;let s=G9(t,e,n,a,i);return n&&(s.x-=n.x/i.x,s.y-=n.y/i.y),r===this?s:this.transcoordT2S(s.x,s.y,r)},transcoordS2C:function(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;let n;n=r!==this?this.transcoordS2T(t,e,r):{x:t,y:e};const{translate:i={x:0,y:0},rotation:a=0,scale:s={x:1,y:1}}=r.model;return n=Y9(n.x,n.y,void 0,a+r._delta.theta,s),i&&(n.x+=i.x,n.y+=i.y),n}}),["rotatePoint","font","lineHeight","retention"].forEach((t=>mtt.memoize(mtt.prototype,t,!1))),["bounds","center","textBounds"].forEach((t=>mtt.memoize(mtt.prototype,t,!0))),mtt.mixin(mtt.prototype,F7.withEvent);class ytt extends mtt{set rotationX(t){this.setState("rotationX",t)}get rotationX(){return this.getState("rotationX")}set rotationY(t){this.setState("rotationY",t)}get rotationY(){return this.getState("rotationY")}set rotationZ(t){this.setState("rotation",t)}get rotationZ(){return this.getState("rotation")}set zPos(t){this.setState("zPos",t)}get zPos(){return this.getState("zPos")}set depth(t){this.setState("depth",t)}get depth(){return this.getState("depth")}postrender(t){this.drawFill(t),this.drawStroke(t),super.postrender(t)}render(t){var e=this.drawPath,{round:r=0}=this.state;if(!(e.length<=1)){t.beginPath();for(var n=0;n<e.length;n++){const l=e[(n-1+e.length)%e.length],h=e[(n+e.length)%e.length],c=e[(n+1)%e.length];if(l.x===h.x&&l.y===h.y)continue;var i=0!==(o=Math.sqrt((l.x-h.x)*(l.x-h.x)+(l.y-h.y)*(l.y-h.y)))?Math.atan2(l.x-h.x,l.y-h.y):0,a=Math.sin(i)*Math.min(r,o/2)+h.x,s=Math.cos(i)*Math.min(r,o/2)+h.y;const u=r>0||0!==o?{x:a,y:s}:h;var o;i=0!==(o=Math.sqrt((c.x-h.x)*(c.x-h.x)+(c.y-h.y)*(c.y-h.y)))?Math.atan2(c.x-h.x,c.y-h.y):0,a=Math.sin(i)*Math.min(r,o/2)+h.x,s=Math.cos(i)*Math.min(r,o/2)+h.y;const d=r>0||0!==o?{x:a,y:s}:h;0==n?t.moveTo(u.x,u.y):t.lineTo(u.x,u.y),r>0&&t.quadraticCurveTo(h.x,h.y,d.x,d.y)}t.closePath()}}}function btt(t,e,r){return Math.max(0,Math.min(t,Math.min(r,e)/2))}var wtt=t=>{var e=class extends t{contains(t,e){var{left:r,top:n,width:i,height:a,lineWidth:s=0}=this.state,o=s/2;return t<Math.max(r+i,r)+o&&t>Math.min(r+i,r)-o&&e<Math.max(n+a,n)+o&&e>Math.min(n+a,n)-o}set path(t){var e=t[0],r=t[2];this.set({left:e.x,top:e.y,width:r.x-e.x,height:r.y-e.y})}get path(){var{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return[{x:t,y:e},{x:t+r,y:e},{x:t+r,y:e+n},{x:t,y:e+n}]}get anchors(){return function(t){var{left:e,top:r,width:n,height:i}=t.bounds,a=e+n/2,s=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:s}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:s}}]}(this)}get bounds(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return{left:t,top:e,width:r,height:n}}set bounds(t){this.set({left:0,top:0,width:0,height:0,...t})}render(t){var{round:e=0}=this.model,{left:r,top:n,width:i,height:a}=this.bounds;t.translate(r,n),t.beginPath(),(e=btt(e,i,a))>0?t.roundRect(0,0,i,a,e):t.rect(0,0,i,a),t.translate(-r,-n)}};return Y7(e.prototype,"path",!1),e};const xtt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"textarea",label:"front-side-template",name:"frontSideTemplate",property:{language:"html"}},{type:"textarea",label:"back-side-template",name:"backSideTemplate",property:{language:"html"}},{type:"textarea",label:"style",name:"style",property:{language:"css"}}],help:"scene/component/info-window"};const Att=20;function _tt(t,e){var r=t.split(/\s+/),n=r.indexOf(e);return-1!=n?r.splice(n,1):r.splice(-1,0,e),r.join(" ")}class ktt extends(wtt(ytt)){static get image(){return ktt._image||(ktt._image=new Image,ktt._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAY1BMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADIAbxiAAAAIHRSTlMA+gPshCwwWFzYCeLRm7QRG6rLeDZI9JOJJDtjb1HAf1sAT80AAAQQSURBVHhe7MCBAAAAAMKw/KkzOMG2BAAAAKeu3lUohIEggO7jQi5qHqpgwML5/6+0F0y02z31FlvMMLKt86QMQ1ined2Evih1hFFjLfRWjgzDOGZ6JSiM00B9EuHALtQxJLiQBmqSBCeSUEuEGzs1BDjSaHxWOKK5Eyz/4SoMV/hp4+vtcPkdwZD/udwevNg7t1xXYRiKmkB7C+ENlPLq8fxHeX+RGjWQ1D45ldcIulBIvCvYJGBEadyTzxAcfY57NBjpLScOO/bzugcTHe7IMwiSLMcdHZhocMcMgTLjjgZM7F1bCJZ2v27ARGzYDwIk2Z+JYGJ/iiwQLMv+JAEThjkmRG64Q0Q+gIiIiIiIiIiIyFy0KRFt0bOJZAWSUigmkQaJaXhENiRnYBEpkZySRSRGcmIWEaQnYhHRSI5mESmQnIJFZIqQmGhiEYEbEnPjGlEGjYTogW/WUkOXENENSqZfEXmDiIiIiIiIiIiIiIiIiIiImq5ETIpRpBpjJCMeKy6Ri0ZS9MQjkmkkJs1YRDokp2MRyZGclkUkQnIiEQltaX3Lzb6yiGTpl2y/avqSAxGgelCOKI+Kc2isL0TUSsZ4EREREREREREREREREREREfnIQzXrNWSRTeNxnlOwIgueIr6AAyE+CpiqMEUK71IDO4E+LluEKYKnKcMUifEsTZgiJZ5lDVNkwJPcqzBFoPF/HplfxL/w6b4EPGv1h18Weya1TL8iIiIeiIiIiIiIiEjkPefxV+5YA9PPHylB+u5aqgZ39H+jKOxrqtu+pkzvr9YbzoZ6w2OFkzcrA3yE4WZlSSyFk54VoA/wR43+FaD+r9w32QdWvgvjp2ty2xq8qHPHmtyPFxfrK3hw1ejERlAlfR/Ame2OTow05d4rOLLSlHtDVhI0uRO01JeZ405op6zgNNXT+bIRfpIgn+AkU4pOxBscohojdCHu4RRzjC5EYwVHqRONDkSnEvK/CB3QSU32IRW3ZPnj9iEVoGCNTLVrh8ia1x+6wq8xvB5mz8pxu7oPwIn9lcR0AiuX1+1KX+BXqdvXzWsAC0NsGjzZsS/2Bd6yRA5RgIHkXNhSD3whASZ8rrB9mItuEAizac0fDlHxDMEwpQfD1tW4y3Hjfy5s9nOHH3uwWA+EqEJBWCjoTL/S5toBB/7hu6zer74NgqSP39zJU+qQX3ix763mHTqvIVRUVprCljlElRkEjBqNYevH8veBJ2xhiyhE8YctmhDFH7ZoQhR/2KIJUfxhiyRE8YctmhDFH7ZoQhR/2OIJUfxhC9Ppf/t1jgJACERRsHGyYRZB0Ujvf0xD8w6kP7y6RZmgf/oTFTtbbzJVxZWo2Nlqw6TVy5GowNl6ssm7v50obamfSxQAAAAAAAsKLM15fb3vpQAAAABJRU5ErkJggg=="),ktt._image}static toggle(t,e,r,n){if(e){var i=t.root.findById(e);i?i._findInfoWindowByComponent(t)?ktt.hide(t,e):ktt.show(t,e,r,n):console.warn("InfoWindow Not Found.",e)}else console.warn("InfoWindow not defined.")}static hide(t,e){if(e){var r=t.root.findById(e);r?r._removeInfoWindow(t):console.warn("InfoWindow Not Found.",e)}}static show(t,e,r,n){if(e){var i=t.root.findById(e);if(i){if(!i._findInfoWindowByComponent(t)){var{frontSideTemplate:a="",backSideTemplate:s=""}=i.model,o=[a,s].filter((t=>String(t).trim()));if(o=o.map((t=>mtt.template(function(t,e,r){return(e||r?['<div class="info-window-btns">',e?'<button class="closable">&#88</button>':"",r?'<button class="flipable">&#8652</button>':"","</div>"]:[]).concat(['<div class="info-window-content">',t,"</div>"]).join("")}(t,!r,2==o.length)))),0!=o.length){var l='\n.flip {\n backface-visibility: hidden;\n border-radius: 7px;\n height: auto;\n font: normal 14px helvetica, arial, san serif;\n position: absolute;\n opacity: 0.9;\n transform-origin: 50% 50% 0px;\n transition: all 2s;\n min-width: 100px;\n min-height: 50px;\n background-color: #3e424e;\n box-shadow: 2px 3px 2px 0px rgba(0,0,0,0.15);\n}\n\n#side-1 {\n transform: rotateY(0deg);\n}\n\n.flip:after {\n content: "";\n display: block;\n position: absolute;\n opacity: 0.9;\n width: 0;\n height: 0;\n}\n\n.flip.arrow-top:after {\n left: 45%;\n top: -17px;\n border-left: 10px solid transparent;\n border-bottom: 18px solid #323b44;\n border-right: 10px solid transparent;\n}\n\n.flip.arrow-right:after {\n left: 100%;\n top: 48%;\n border-top: 10px solid transparent;\n border-left: 18px solid #323b44;\n border-bottom: 10px solid transparent;\n}\n\n.flip.arrow-bottom:after {\n left: 45%;\n top: 100%;\n border-left: 10px solid transparent;\n border-top: 18px solid #323b44;\n border-right: 10px solid transparent;\n}\n\n.flip.arrow-left:after {\n right: 100%;\n top: 48%;\n border-top: 10px solid transparent;\n border-right: 18px solid #323b44;\n border-bottom: 10px solid transparent;\n}\n\n#side-2 {\n transform: rotateY(180deg);\n}\n\n.flip-side-1 {\n transform: rotateY(0deg) !important;\n}\n\n.flip-side-2 {\n transform: rotateY(180deg) !important;\n}\n\n.info-window-btns {\n position: absolute;\n top: -18px;\n right: 5px;\n overflow: hidden;\n}\n\n.info-window-content {\n padding: 10px;\n color: #efefef;\n font-size: 13px;\n line-height: 1.4;\n}\n\n.info-window-btns button {\n width: 40px;\n height: 40px;\n float: right;\n border: 0;\n border-radius: 50%;\n background-color: #2a7da1;\n margin-right: 3px;\n text-align: center;\n cursor: pointer;\n font-size: 35px;\n color: #fff;\n line-height: 0;\n}\n\n.info-window-btns button:hover {\n background-color: #60bb23;\n}\n'+i.get("style"),{left:h,top:c}=t.bounds,{x:u,y:d}=n?t.rootModel.transcoordC2S(n.x,n.y):t.transcoordS2T(h,c);h=u,c=d;var p=document.createElement("span");p.style.position="absolute";var f=document.createElement("style");if(f.type="text/css",f.appendChild(document.createTextNode(l)),p.appendChild(f),o[0]){var g=document.createElement("div");g.id="side-1",g.className="flip",g.style.display="inline-block",g.innerHTML=o[0](t)}if(o[1]){var v=document.createElement("div");v.id="side-2",v.className="flip",v.style.display="inline-block",v.innerHTML=o[1](t)}r9.forEach((function(t){p.addEventListener(t,(function(t){t.stopPropagation()}))})),n9.forEach((function(t){p.addEventListener(t,(function(t){t.stopPropagation()}))}));var m=t.root.model_layer.overlay;if(g&&p.appendChild(g),v&&p.appendChild(v),m.appendChild(p),i._addInfoWindow(t,p,f),g){let r=g.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=_tt(v.className,"flip-side-1"),g.className=_tt(g.className,"flip-side-2")}),!1);let n=g.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),ktt.hide(t,e)}),!1)}if(v){let r=v.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=_tt(v.className,"flip-side-1"),g.className=_tt(g.className,"flip-side-2")}),!1);let n=v.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),ktt.hide(t,e)}),!1)}var y=g.offsetWidth,b=g.offsetHeight;window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;var w=t.rootModel.target.getBoundingClientRect(),x=[];g&&x.push(g),v&&x.push(v);var A={x:h,y:c},_=t.transcoordS2C(A.x,A.y);if(_.x+y/2+w.left<w.right&&_.x-y/2>w.left){if(b+Att<_.y)return p.style.marginLeft=A.x-y/2+"px",p.style.marginTop=A.y-b-Att+"px",void x.forEach((t=>t.className+=" arrow-bottom"));if(_=t.transcoordS2C(A.x,A.y+b+Att),w.bottom>_.y+w.top)return p.style.marginLeft=A.x-y/2+"px",p.style.marginTop=A.y+Att+"px",void x.forEach((t=>t.className+=" arrow-top"))}if((_=t.transcoordS2C(A.x,A.y)).x-(y+Att)>w.left)return p.style.marginLeft=A.x-y-Att+"px",p.style.marginTop=A.y-b/2+"px",void x.forEach((t=>t.className+=" arrow-right"));p.style.marginLeft=A.x+Att+"px",p.style.marginTop=A.y-b/2+"px",x.forEach((t=>t.className+=" arrow-left"))}}}else console.warn("InfoWindow Not Found.",e)}else console.warn("InfoWindow not defined.")}dispose(){this.infoWindows.map((t=>t.component)).forEach((t=>this._removeInfoWindow(t))),super.dispose()}get infoWindows(){return this._windows||(this._windows=[]),this._windows}_findInfoWindowByComponent(t){return this.infoWindows.find((e=>e.component===t))}_addInfoWindow(t,e,r){this._findInfoWindowByComponent(t)||this._windows.push({component:t,window:e,styleElement:r})}_removeInfoWindow(t){var e=this._findInfoWindowByComponent(t);if(!e)return;let r=e.window;r&&r.parentNode.removeChild(r);var n=this.infoWindows.lastIndexOf(e);this.infoWindows.splice(n,1)}render(t){var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),this.drawImage(t,ktt.image,e,r,n,i)}get hasTextProperty(){return!1}get nature(){return xtt}}mtt.register("info-window",ktt);var Stt={};var Ett={list:function(){return{...Stt}},register:function(t,e){Stt[t]=e},unregister:function(t){delete Stt[t]},get:function(t){if(t){var e=Stt[t];return e||U7("Layout Not Found - ",t),e}}},Mtt={reflow:function(t,e){this.drawables(t).filter((t=>t.isHTMLElement())).forEach((t=>t.reposition()))},capturables:function(t){return t.components},drawables:function(t){return t.app&&!t.app.isViewMode?t.components:t.components.filter((t=>!t.hidden))},isStuck:function(t){return!1},ABSOLUTE:!0};Ett.register("html-absolute",Mtt);const Ttt=["run","goto","goto-playlist","link-open","link-move","route-page","start-scenario","run-scenario","export-data","import-data"],Ctt="auto";const Ptt=new WeakMap;function Itt(t){const e=t.root,r=Ptt.get(e);if(!r)return;if(e===t)return r.forEach((t=>Itt(t[0]))),void Ptt.delete(e);const n=r.findIndex((e=>e[0]===t));if(-1===n)return;const i=r[n][1];i.div.parentNode?.removeChild(i.div),i.scene.target=null,i.scene.release?.(),r.splice(n,1)}class Rtt{static hideAll(t){(Ptt.get(t)||[]).forEach((([t])=>Itt(t)))}static hide(t){const e=t.root,r=Ptt.get(e);if(!r)return;const n=r.findIndex((e=>e[0]===t));if(-1===n)return;const i=r[n][1];i.div.style.backgroundColor="transparent",function(t,e){t.style.opacity=1,t.style.transform="scale(1)";let r=+new Date;const n=()=>{const i=Math.min((new Date-r)/200,1);t.style.opacity=1-i,t.style.transform=`scale(${1-i})`,i<1?requestAnimationFrame(n):(t.style.display="none",e&&e())};n()}(i.div,(()=>{Itt(t)}))}static show(t,e,r={}){const{data:n,modal:i=!1,closable:a=!0,minimizable:s=!1,draggable:o=!1,output:l=!0,title:h=""}=r,c=t.app.refProvider;c?.get(e,!0).then((e=>{const c=document.createElement("div"),u=c.style;if(c.setAttribute("popup",""),i){const{width:e,height:r}=t.rootModel.bounds;Object.assign(u,{position:"fixed",zIndex:1,left:0,top:0,width:`${e}px`,height:`${r}px`,overflow:"hidden",backgroundColor:"transparent"})}else Object.assign(u,{position:"absolute",display:"inline-block",overflow:"hidden"});c.innerHTML=h?'\n<div class="popup-wrap">\n <div class="popup-title-bar">\n <div class="popup-title"></div>\n <button class="draggable-1945">&#x2630;</button>\n <button class="minimizable-1945">&#8211;</button>\n <button class="closable-1945">&#88</button>\n </div>\n <div class="popup-content"></div>\n</div>\n':'\n<div class="popup-content">\n <button class="draggable-1945">&#x2630;</button>\n <button class="minimizable-1945">&#8211;</button>\n <button class="closable-1945">&#88</button>\n</div>\n';const d=c.querySelector(".popup-content"),{width:p,height:f}=e.root.model;Object.assign(d.style,{width:`${p}px`,height:`${f}px`});const g=document.createElement("style");g.type="text/css",g.appendChild(document.createTextNode("\n.popup-title-bar {\n display: flex;\n align-items: center;\n top: 0;\n left: 0;\n width: 100%;\n height: 30px;\n background-color: var(--md-sys-color-primary, #f1f1f1);\n color: var(--md-sys-color-on-primary, black);\n padding: 5px;\n box-sizing: border-box;\n border-bottom: 1px solid #ccc;\n}\n\n.popup-title {\n flex: 1;\n text-align: center;\n}\n\nbutton.closable-1945, button.minimizable-1945, button.draggable-1945 {\n position: absolute;\n display: none;\n color: white; \n background-color: black; \n opacity: .3;\n width: 20px;\n height: 20px;\n top: 5px; \n z-index: 1;\n padding: 0;\n margin: 0;\n border: 0px;\n text-align: center;\n cursor: pointer;\n font-size: 12px;\n border-radius: 4px;\n}\n\nbutton.draggable-1945 {\n left: 5px;\n cursor: move;\n}\n\nbutton.minimizable-1945 {\n right: 30px;\n}\n\nbutton.closable-1945 {\n right: 5px;\n}\n\nbutton.closable-1945:hover, button.minimizable-1945:hover, button.draggable-1945:hover {\n opacity: .6; \n}\n")),c.appendChild(g),Ttt.forEach((r=>{e.on(r,((...e)=>{t.trigger(r,...e)}))}));const v=c.querySelector(".popup-content"),m=c.querySelector(".draggable-1945");[...r9,...n9].forEach((t=>{v.addEventListener(t,(e=>{(!m?.isDragging||"mousemove"!==t&&"mouseup"!==t)&&e.stopPropagation()}))})),[...r9,...n9].forEach((t=>{c.addEventListener(t,(e=>{(!m?.isDragging||"mousemove"!==t&&"mouseup"!==t)&&e.stopPropagation()}))})),i&&a&&c.addEventListener("click",(e=>{e.target===c&&Rtt.hide(t)}));if(t.root.model_layer.overlay.appendChild(c),function(t,e,r){const n=t.root;if(n===t)return;Itt(t);let i=Ptt.get(n)||[];i=[...i,[t,{div:e,scene:r}]],Ptt.set(n,i)}(t,c,e),h){c.querySelector(".popup-title-bar .popup-title").textContent=h}if(o&&(!function(t,e,r){let n,i,a,s;function o(o){if(!e.isDragging)return;o.preventDefault(),o.stopPropagation();const l=o.clientX-n,h=o.clientY-i,c=r.rootModel.overlay.style.transform.match(/scale\(([^,]+),\s*([^)]+)\)/),u=c?parseFloat(c[1]):1,d=c?parseFloat(c[2]):u;t.style.left=`${a+l/u}px`,t.style.top=`${s+h/d}px`}function l(t){t.preventDefault(),t.stopPropagation(),e.isDragging=!1,document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",l)}e.isDragging=!1,e.addEventListener("mousedown",(r=>{r.preventDefault(),r.stopPropagation(),e.isDragging=!0,n=r.clientX,i=r.clientY,a=parseInt(t.style.left,10)||0,s=parseInt(t.style.top,10)||0,document.addEventListener("mousemove",o),document.addEventListener("mouseup",l)}))}(i?c.querySelector(".popup-wrap"):c,m,t),h?m&&(m.style.display="block"):(v.addEventListener("mouseenter",(()=>{m&&(m.style.display="block")})),v.addEventListener("mouseleave",(()=>{m&&(m.style.display="none")})))),s){const t=c.querySelector(".minimizable-1945");let e=!1;t.addEventListener("click",(t=>{t.preventDefault(),e=!e;const r=c.querySelector(".popup-wrap");!function(t,e){const r=t.querySelector(".minimizable-1945");e?(r.innerHTML="&#x25A1;",t.style.height="30px",t.style.overflow="hidden"):(r.innerHTML="&#8211;",t.style.height="",t.style.overflow="visible")}(i?r:c,e)})),h?t&&(t.style.display="block"):(v.addEventListener("mouseenter",(()=>{t&&(t.style.display="block")})),v.addEventListener("mouseleave",(()=>{t&&(t.style.display="none")})))}if(a){const t=c.querySelector(".closable-1945");h?t&&(t.style.display="block"):(v.addEventListener("mouseenter",(()=>{t&&(t.style.display="block")})),v.addEventListener("mouseleave",(()=>{t&&(t.style.display="none")})))}c.querySelector(".closable-1945")?.addEventListener("click",(e=>{e.preventDefault(),Rtt.hide(t)})),c.addEventListener("close-scene",(e=>{e.preventDefault(),e.stopPropagation(),Rtt.hide(t),l&&(t.data=e.detail)})),e.target=d,e.data=n||t.data,e.fit("both");const{x:y,y:b}=t.center,w=t.transcoordS2T(y,b,t.rootModel),x=function(t,e,r,n){const{location:i=Ctt,title:a=""}=n||{},s=t.bounds;let o=e.bounds;a&&(o.height+=30);const l=Math.max(s.width/4-o.width/2,20),h=Math.min(3*s.width/4+o.width/2,s.width-20)-o.width,c=Math.max(s.height/4-o.height/2,20)+(a?30:0),u=Math.min(3*s.height/4+o.height/2,s.height-20)-o.height+(a?30:0);switch(i){case Ctt:return{x:r.x<s.width/2?Math.min(h,r.x+20):Math.max(l,r.x-(o.width+20)),y:r.y<s.height/2?Math.min(u,r.y+20+(a?30:0)):Math.max(c,r.y-(o.height+20+(a?30:0)))};case"left-top":return{x:l,y:c};case"right-top":return{x:h,y:c};case"left-bottom":return{x:l,y:u};case"right-bottom":return{x:h,y:u};default:return{x:(s.width-o.width)/2,y:(s.height-o.height+(a?30:0))/2}}}(t.rootModel,e.root,w,r);if(i)if(h){const t=c.querySelector(".popup-wrap");Object.assign(t.style,{position:"absolute",left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${f}px`})}else Object.assign(d.style,{left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${f}px`});else Object.assign(c.style,{left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${h?f+30:f}px`});!function(t,e){t.style.opacity=0,t.style.transform="scale(0)",t.style.display="block";let r=+new Date;const n=()=>{const i=Math.min((new Date-r)/200,1);t.style.opacity=i,t.style.transform=`scale(${i})`,i<1?requestAnimationFrame(n):e&&e()};n()}(c,(()=>{i&&(c.style.backgroundColor="rgba(0,0,0,0.3)")}))}),(t=>{console.error("cannot fetch board: "+e,t)}))}}var Ott={reflow:function(t,e){},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!1},ABSOLUTE:!0};function Ltt(t){var e=t.components.filter((t=>!t.hidden)),r=t.getState("layoutConfig")||{},n=e[r&&r.activeIndex||0];return n&&[n]||[]}Ett.register("absolute",Ott);var Dtt={reflow:function(t){var e=t.bounds,r=t.getState("layoutConfig")||{},n={left:0,top:0,width:e.width,height:e.height};t.forEach(((t,e)=>{let i=e!=(r.activeIndex||0);t.bounds=n,t.setState("rotation",0),t.element&&(t.element.style.visibility=i?"hidden":"visible")}))},capturables:function(t){return Ltt(t)},drawables:function(t){return Ltt(t)},isStuck:function(t){return!0}};function Ftt(t){var e=t.getState("layoutConfig");return e&&e.weight||1}Ett.register("card",Dtt);var Ntt={reflow:function(t){var e=this.drawables(t),r=t.get("padding")||{},n=e.reduce(((t,e)=>t+Ftt(e)),0),i=t.bounds,a=n>0?(i.width-((r.left||0)+(r.right||0)))/n:i.width,s=i.height-((r.top||0)+(r.bottom||0)),o=0;e.forEach((t=>{let e=Ftt(t),n=t.get("margin")||{};t.bounds={left:a*o+(r.left||0)+(n.left||0),top:0+(r.top||0)+(n.top||0),width:e*a-((n.left||0)+(n.right||0)),height:s-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),o+=e}))},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!0}};function jtt(t){var e=t.getState("layoutConfig");return e&&e.weight||1}Ett.register("linear-horizontal",Ntt);var Btt={reflow:function(t){var e=this.drawables(t),r=t.getState("padding")||{},n=e.reduce(((t,e)=>t+jtt(e)),0),i=t.bounds,a=n>0?(i.height-((r.top||0)+(r.bottom||0)))/n:i.height,s=i.width-((r.left||0)+(r.right||0)),o=0;e.forEach((t=>{let e=jtt(t),n=t.getState("margin")||{};t.bounds={left:0+(r.left||0)+(n.left||0),top:a*o+(r.top||0)+(n.top||0),width:s-((n.left||0)+(n.right||0)),height:e*a-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),o+=e}))},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!0}};Ett.register("linear-vertical",Btt);var ztt={reflow:function(t){var e=t.getState("layoutConfig"),r=e&&e.columns||t.getState("columns"),n=e&&e.rows||t.getState("rows"),i=e&&e.widths||t.getState("widths"),a=e&&e.heights||t.getState("heights"),s=i?i.filter(((t,e)=>e<r)).reduce(((t,e)=>t+e),0):r,o=a?a.filter(((t,e)=>e<n)).reduce(((t,e)=>t+e),0):n,l=t.textBounds,h=t.getState("paddingLeft")||0,c=t.getState("paddingTop")||0,u=l.width/s,d=l.height/o,p=0,f=0;t.components.forEach(((t,e)=>{let n=i?i[e%r]:1,s=a?a[Math.floor(e/r)]:1,o=t.colspan||1,l=0;for(;--o>0;)l+=i?i[(e+o)%r]:1;let g=t.rowspan||1,v=0;for(;--g>0;)v+=a?a[Math.floor(e/r)+g]:1;t.bounds={left:h+p,top:c+f,width:u*(n+l),height:d*(s+v)},t.setState("rotation",0),e%r==r-1?(p=0,f+=s*d):p+=n*u}))},capturables:function(t){return t.components.filter((t=>!t.merged))},drawables:function(t){return t.components.filter((t=>!t.merged&&!t.hidden))},isStuck:function(t){return!0},keyNavigate:function(t,e,r){var n=t.getState("layoutConfig"),i=n&&n.columns||t.getState("columns"),a=n&&n.rows||t.getState("rows"),{row:s,column:o}=t.getRowColumn(e);switch(r.code){case"ArrowUp":if(s>0)return t.getAt((s-1)*i+o);break;case"ArrowDown":if(s<a-1)return t.getAt((s+1)*i+o);break;case"ArrowRight":if(o<i-1)return t.getAt(s*i+o+1);break;case"ArrowLeft":if(o>0)return t.getAt(s*i+o-1);break;default:return e}},joinType:!0};Ett.register("table",ztt);const Wtt=new Image;Wtt.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAclBMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0BbqFAAAAJXRSTlMAgAP3VSI6/g9fBk5FavJsMrariSjzPnO1enRRL5SMhmOOWB9keFTE0wAAANxJREFUOMutk9kWgyAMRLFuiLjUtdp9yf//YglVsQXz1HniMPcEMgHGvpX2O0Ypi+EgCL+IAShC+wB7QfubRDT7AFcnUPoLMLiP4PyJbsb55i05AgnR5iaQDsICgtH0cotBWoAP1c7kC6kFxEseCfZfB6gEgbNeBrira2QmH1uVYCXlA3is8UmgUCPIyQJKEmu8QtQJN0e9DPXVpzG2G216c1CqRmcBOdxXk07sWUSPv07zo0amCNQycv+NzmR6cRcwmfbuI7p2nZ/z4be0P83Foz6vIkhfZXr82XgDlZsspIq4peUAAAAASUVORK5CYII=";var Utt=t=>class extends t{postrender(t){super.postrender(t),this.app.isEditMode&&this._focused&&this.showMoveHandle&&this._draw_move_handle(t)}_draw_move_handle(t){var{left:e,top:r,width:n}=this.bounds;t.save(),t.beginPath(),t.globalAlpha=1,t.rect(e+n,r,25,25);t.fillStyle="rgba(235, 235, 235, 1)",t.fill(),t.drawImage(Wtt,e+n+3.75,r+3.75,17.5,17.5),t.closePath(),t.restore()}contains(t,e){var r=super.contains(t,e);if(this.app.isViewMode)return r;if(!r){var{left:n,top:i,width:a,height:s}=this.bounds,o=n+a;this.showMoveHandle&&(r=t<Math.max(o+25,o)&&t>Math.min(o+25,o)&&e<Math.max(i+25,i)&&e>Math.min(i+25,i))}return this._focustd!==r&&(this._focused=r,this.invalidate()),r}};const Htt=[];class Gtt extends(Utt(wtt(mtt))){constructor(t,e){super(t,e),this._components=[]}replaceRefids(t){this.components.forEach((e=>e.replaceRefids(t)))}get showMoveHandle(){return!0}get showOverflow(){return!1}dispose(){this.components.slice().forEach((t=>t.dispose())),super.dispose()}isContainer(){return!0}containable(t){return t.isDescendible(this)}get hasTextProperty(){return!1}get components(){return this._components}get focusible(){return!0}get layout(){return Ett.get(this.get("layout"))||Ott}reflow(){this.layout.reflow(this),this.components&&this.components.forEach((t=>{t.isContainer()&&t.reflow()}))}get hierarchy(){var t=super.hierarchy;return this.components&&(t.components=this.components.map((t=>t.hierarchy))),t}addComponent(t,e=!1){var r=t.parent;if(r){if(this===r)return;r.removeComponent(t,e)}var n=this._components.push(t)-1;t.parent=this,t.added(this),e||this.trigger("add",this,t,n),t.delegate_on(this),e||t.trigger("added",this,t,n),this.root&&this.root.isReady&&t.ready()}removeComponent(t,e=!1){var r=this._components.indexOf(t);-1!=r&&(this._components.splice(r,1),t.parent=null,t.removed(this),e||(this.trigger("remove",this,t),t.trigger("removed",this,t)),t.delegate_off(this))}insertComponentAt(t,e,r=!1){var n=t.parent;n&&n.removeComponent(t,r);var i=this._components.splice(0,e);this._components=i.concat(t,this._components),e=this._components.indexOf(t),t.parent=this,t.added(this),r||this.trigger("add",this,t,e),t.delegate_on(this),r||t.trigger("added",this,t,e)}add(t,e=!1){return t instanceof Array?(t.forEach((t=>{-1==this._components.indexOf(t)&&this.addComponent(t,e)})),this):this.add.call(this,[t],e)}remove(t,e=!1){return t instanceof Array?this._components?(t.forEach((t=>{this.removeComponent(t,e)})),this):this:this.remove.call(this,[t],e)}getAt(t){if(this._components)return this._components[t]}forEach(t,e){this._components&&this._components.forEach(t,e)}traverse(t,e){t.call(e,this),this._components&&this._components.forEach((r=>{r.isContainer()?r.traverse(t,e):t.call(e,r)}))}indexOf(t){return(this._components||Htt).indexOf(t)}size(){return(this._components||Htt).length}moveChildAt(t,e){var r=this.indexOf(e);if(-1!=r){var n=this._components.splice(0,r),i=this._components.splice(1);this._components=n.concat(i),t=Math.max(0,t),t=Math.min(t,this._components.length),n=this._components.splice(0,t),this._components=n.concat(e,this._components)}}moveChildForward(t){var e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this._components[e]=this._components[e+1],this._components[e+1]=t)}moveChildBackward(t){var e=this.indexOf(t);-1!=e&&0!=e&&(this._components[e]=this._components[e-1],this._components[e-1]=t)}moveChildToFront(t){var e=this.indexOf(t);if(-1!=e&&e!=this.size()-1){var r=this._components.splice(0,e),n=this._components.splice(1);this._components=r.concat(n,this._components)}}moveChildToBack(t){var e=this.indexOf(t);if(-1!=e&&0!=e){var r=this._components.splice(0,e),n=this._components.splice(0);this._components=this._components.concat(r,n)}}symmetryX(t){super.symmetryX(t),this.components.map((t=>{t.symmetryX(0)}))}findAll(t,...e){if("string"==typeof t)return p9(t,this,e[0]||this);if("function"==typeof t){var r=[];for(let n=this.components.length-1;n>=0;n--){let i=this.components[n].findAll(t,...e);i&&(r=r.concat(i))}return t(this,...e)&&r.push(this),r}}findFirst(t,...e){if("string"==typeof t)return p9(t,this,e[0])[0];if("function"==typeof t){for(let n=this.components.length-1;n>=0;n--){var r=this.components[n].findFirst(t,...e);if(null!=r)return r}return t(this,...e)?this:null}}findById(t){return this.root.findById(t)}findByRefid(t){return this.root.findByRefid(t)}contains(t,e){var r=super.contains(t,e);if(!r){var{left:n,top:i,width:a,height:s}=this.state;r=t<Math.max(n+a,n)&&t>Math.min(n+a,n)&&e<Math.max(i+s,i)&&e>Math.min(i+s,i)}return r}capture(t,e,r){var n=this.transcoordP2S(t,e);if(!this.contains(n.x,n.y))return!1;var i=this.bounds;n.x-=i.left,n.y-=i.top;var a=this.layout.capturables(this);for(let t=a.length-1;t>=0;t--){var s=a[t].capture(n.x,n.y,r);if(s)return s}return this.capturable&&!r?.(this)&&this}capturePath(t,e){if(e){if(e.indexOf(this)>-1)return!1;for(let t=0;t<e.length;t++)if(!this.containable(e[t]))return!1}var r=[],{left:n,top:i,width:a,height:s}=this.bounds;for(let e=0;e<t.length;e++){let o=this.transcoordP2S(t[e].x,t[e].y);if(o.x<n||o.x>n+a||o.y<i||o.y>i+s)return!1;o.x-=n,o.y-=i,r.push(o)}let o=this.layout.capturables(this);for(let t=o.length-1;t>=0;t--){let n=o[t];if(!n.isContainer())continue;let i=n.capturePath(r,e);if(i)return i}return this.focusible&&this}render(t){var{left:e=0,top:r=0,width:n,height:i}=this.bounds;t.beginPath(),t.rect(e,r,n,i),t.closePath(),this.drawFill(t),this.drawStroke(t)}postrender(t){const e=this.layout.drawables(this);if(e.length>0){var{left:r=0,top:n=0,width:i,height:a}=this.bounds;t.save(),this.showOverflow||(t.beginPath(),t.rect(r,n,i,a),t.clip(),t.closePath());var{top:n,left:r}=this.state;t.translate(r,n),e.forEach((e=>{e.draw(t)})),t.translate(-r,-n),t.restore()}super.postrender(t)}trim(){this.components.forEach((t=>{t.trim()})),super.trim()}}["layout"].forEach((t=>mtt.memoize(Gtt.prototype,t,!1)));class Ytt extends Gtt{constructor(t,e){super(t,e),t.translate=t.translate||{x:0,y:0},this._draw_reserved=!1,this.__draw__=()=>{this._draw_reserved=!1,this.trigger("redraw"),this.reflow(),this.draw()},this.throttle_render=()=>{this._draw_reserved||requestAnimationFrame(this.__draw__),this._draw_reserved=!0}}fitSize(t,e,r,n){if(this.target){if(e){let t=getComputedStyle(this.target);r=r||(t?parseFloat(t.getPropertyValue("width")):this.target.clientWidth),n=n||(t?parseFloat(t.getPropertyValue("height")):this.target.clientHeight)}else r=this.model.width,n=this.model.height;"CANVAS"==t.tagName&&(t.setAttribute("width",r*e9),t.setAttribute("height",n*e9)),t.style.width=r+"px",t.style.height=n+"px"}}resize(){this.fitSize(this.element,!0)}isLayer(){return!0}get showOverflow(){return this.app.isEditMode}get anchors(){}createElement(){var t=mtt.createCanvas(1,1);return t.setAttribute("scene",this.state.type),t.style.position="absolute",t}get target(){return this._target}set target(t){this._target&&this.element&&this._target.removeChild(this.element),this._target=t,t&&(this.element||(this.element=this.createElement()),this.resize(),t.appendChild(this.element))}get canvas(){return this.element}dispose(){super.dispose(),this.target=null,this.element=null}get selected(){return this.root.selected}set selected(t){this.root.selected=t}get hasSameParentForAllSelected(){return this.root.hasSameParentForAllSelected}get focused(){return this.root.focused}set focused(t){this.root.focused=t}getContext(){return this._context2D||(this._context2D=this.canvas&&this.canvas.getContext("2d")),this._context2D}draw(t){this.canvas&&(t=t||this.getContext())&&super.draw(t)}prerender(t){var{translate:e,scale:r={x:1,y:1},rotation:n}=this.model;t.clearRect(0,0,t.canvas.width,t.canvas.height),e&&t.translate(e.x*e9,e.y*e9),t.scale(r.x*e9,r.y*e9),n&&t.rotate(n)}get rotatePoint(){return{x:0,y:0}}contains(t,e){return!1}invalidate(){this.throttle_render()}move(t){var e=this.get("translate")||{x:0,y:0};this.set({translate:{x:e.x+t.x,y:e.y+t.y}})}centerTo(t,e){const r=t.rootModel.transcoordC2S(this.canvas.clientWidth/2,this.canvas.clientHeight/2),{x:n,y:i}=t.center,{x:a,y:s}=t.transcoordP2S(n,i),{x:o,y:l}=t.transcoordS2T(a,s),{x:h,y:c}=t.rootModel.get("translate"),{x:u,y:d}=t.rootModel.get("scale");e?D8({step:function(e){t.rootModel.set({translate:{x:h+(r.x-o)*u*e,y:c+(r.y-l)*d*e}})},duration:1e3,delta:"circ",ease:"in"}).start():t.rootModel.set({translate:{x:h+(r.x-o)*u,y:c+(r.y-l)*d}})}}const Vtt={x:1,y:1},qtt={x:0,y:0};class Xtt extends Ytt{dispose(){super.dispose(),delete this._canvas,delete this._overlay}contains(t,e){return!0}isRootModel(){return!0}get stuck(){return!0}get layout(){return Mtt}get overlay(){if(!this._overlay){var t=document.createElement("div");t.style.position="absolute",t.style.width=0,t.style.height=0,t.style.overflow="initial",t.style["user-select"]="none",t.style["transform-origin"]="top left",this.element&&this.element.appendChild(t),this._overlay=t,this._repositionOverlay()}return this._overlay}createElement(){var t=document.createElement("div");return t.style.position="absolute",t.setAttribute("scene",this.state.type),t.style["user-select"]="none",t.style.overflow="hidden",this._canvas=mtt.createCanvas(1,1),this._canvas.style.position="absolute",t.appendChild(this._canvas),this._overlay&&t.appendChild(this._overlay),t}resize(){if(this.target){var{width:t,height:e,fitMode:r}=this.model;this.root.fitMode?r=this.root.fitMode:r||(r="ratio");try{var n=getComputedStyle(this.target)}catch(t){return void console.error(t,this.target)}var i=n?parseFloat(n.getPropertyValue("width")):this.target.clientWidth,a=n?parseFloat(n.getPropertyValue("height")):this.target.clientHeight;switch(r){case"both":case"ratio":break;case"width":a=e*i/t;break;case"height":i=t*a/e;break;default:i=Math.max(t,i),a=Math.max(e,a)}switch(this.fitSize(this.canvas,!0,i,a),r){case"ratio":case"both":break;case"width":this.element.style.overflowX="hidden",this.element.style.overflowY="auto";break;case"height":this.element.style.overflowX="auto",this.element.style.overflowY="hidden";break;default:this.element.style.overflowX=i>t?"hidden":"auto",this.element.style.overflowY=a>e?"hidden":"auto"}this.fitSize(this.element,!0)}}get canvas(){return this._canvas}get MPP(){var{scale:t={x:1,y:1},unit:e}=this.model;switch(e){case"mm":case"cm":return 1/this.app.PPM/t.x;case"in":return 1/this.app.PPI/t.x;default:return 1/t.x}}capturePath(t,e){var r=this.layout.capturables(this);for(let n=r.length-1;n>=0;n--){let i=r[n];if(!i.isContainer())continue;let a=i.capturePath(t,e);if(a)return a}return!1}get eventMap(){return{"(self)":{"(all)":{change:this._onchanged_all,mouseenter:this._onmouseenter_all,mouseleave:this._onmouseleave_all,click:this._onclick,mousedown:this._onmousedownup,mouseup:this._onmousedownup,touchstart:this._onmousedownup,touchend:this._onmousedownup}}}}closeScene(t){requestAnimationFrame((()=>this.overlay.dispatchEvent(new CustomEvent("close-scene",{bubbles:!0,composed:!0,detail:t}))))}_repositionOverlay(){var t=this._overlay;if(t){var{translate:e=qtt,scale:r=Vtt,rotation:n=0}=this.model,{left:i,top:a,width:s,height:o}=this.bounds;t.style.left=i+"px",t.style.top=a+"px",t.style.transform=`rotate(${n}rad) scale(${r.x}, ${r.y}) perspective(1px)`,t.style.marginLeft=`${e.x}px`,t.style.marginTop=`${e.y}px`}}onchange(t){var e=this._model;delete e.id,delete e.text,delete e.class,this._repositionOverlay()}_onchanged_all(t,e,r){this.invalidate()}_onmouseenter_all(t,e){if(t.stopPropagation(),this.app&&!this.app.isEditMode&&e){var r=e.origin;if(!(r instanceof Xtt)&&r.model.event&&r.model.event.hover&&!r.hidden){var n=r.model.event.hover;n&&this._doEventAction(n,r,!0,t)}}}_onmouseleave_all(t,e){if(t.stopPropagation(),e){var r=e.origin;if(this.app&&!this.app.isEditMode){var n=r.model.event&&r.model.event.hover;n&&this._doEventAction(n,r,!1,t)}}}_onclick(t,e){if(t.stopPropagation(),!this.app.isEditMode&&e){var r=e.origin,n=r.model.event?.tap;n&&this._doEventAction(n,r,!0,t)}}_onmousedownup(t,e){if(t.stopPropagation(),!this.app.isEditMode&&e){var r=e.origin,n=r.model.event?.tap;n&&n.pressed&&this._doMouseDownUpEventAction(n,r,"mousedown"==t.type||"touchstart"==t.type,t)}}_doMouseDownUpEventAction(t,e,r,n){var{pressed:i=!1}=t;i&&(r?function(t){if(!t.hasOwnProperty("_backupShadow")){var e=t.get("shadow");t._backupShadow=e;var{left:r=0,top:n=0}=e||{};t.delta("tx",r),t.delta("ty",n),t.set("shadow",{})}}(e):function(t){t.hasOwnProperty("_backupShadow")&&(t.delta("tx",0),t.delta("ty",0),t.set("shadow",t._backupShadow),delete t._backupShadow)}(e))}_doEventAction(t,e,r,n){var{action:i,target:a,value:s,emphasize:o=!1,restore:l=!1,pressed:h=!1,options:c}=t;if(a&&(a=e.access(a)),s&&(s=e.access(s)),o&&(r?function(t){const{hover:e}=t.state.event||{},{emphasize:r}=e||{};if(t.hasOwnProperty("_backupStrokeStyle"))return;if("__backup_emphasize"in t)return;const{strokeStyle:n,lineWidth:i,fillStyle:a}=t.state;t.__backup_emphasize={strokeStyle:n,lineWidth:i,fillStyle:a},t.setState(r)}(e):l&&function(t){"__backup_emphasize"in t&&(t.setState(t.__backup_emphasize),delete t.__backup_emphasize)}(e)),i)switch(i){case"data-toggle":if(!a)return;(r||l)&&this.root.findAll(a,e).forEach((t=>{t.data=!t.data}));break;case"data-tristate":if(!a)return;(r||l)&&this.root.findAll(a,e).forEach((t=>{let e=Math.round(Math.max(Number(t.data)||0,0));t.data=(e+(r?1:2))%3}));break;case"data-spreading":if(!a)return;if(r){var u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.executeMappings(!0)}))}break;case"data-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.data=u}))}break;case"partial-data-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.data={...t.data,...u}}))}break;case"value-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.value=u}))}break;case"partial-value-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.value={...t.value,...u}}))}break;case"infoWindow":case"info-window":if(!a)return;"click"==n.type||r?ktt.show(e,a,l,{x:n.offsetX,y:n.offsetY}):l&&ktt.hide(e,a);break;case"toggle-info-window":if(!a)return;ktt.toggle(e,a,!1,{x:n.offsetX,y:n.offsetY});break;case"popup":case"modal-popup":if(!a)return;let t=c&&"input"in c?c.input:"(self)",o=!c||(!("output"in c)||c.output);Rtt.show(e,a,{data:t&&this.root.findFirst(t,e)?.data,output:o,modal:"modal-popup"===i});break;case"close-scene":this.closeScene(e.data);break;case"goto":case"goto-playlist":this.trigger(i,a,c,e);break;case"mouse-cursor":r?this.target.style.cursor=a||"auto":l&&(this.target.style.cursor="auto");break;default:this.trigger(i,a,s,e)}}}function $tt(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.from.component===r&&(!e||t.from.anchor===e)))}function Ktt(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.to.component===r&&(!e||t.to.anchor===e)))}Xtt.Popup=Rtt,mtt.register("model-layer",Xtt);var Qtt=t=>class extends t{isConnectable(){return!0}postrender(t){super.postrender(t),this._draw_anchors(t)}_draw_anchors(t){var e=this.anchors||[];t.save(),e.forEach((e=>{var{position:{x:r,y:n},draw:i}=e;if(i){t.beginPath();try{i.call(e,t,this)}catch(t){console.error(t)}t.closePath()}})),t.restore()}contains(t,e){if(n=super.contains(t,e))return n;var r=this.anchors||[];for(let i of r){const r=i.bounds;if(!r)continue;const{left:a,top:s,width:o,height:l}=r;var n;if(n=t<Math.max(a+o,a)&&t>Math.min(a+o,a)&&e<Math.max(s+l,s)&&e>Math.min(s+l,s))return n}return!1}findInOutLines(t){return function(t,e){const r=t.state.refid;return t.root.findAll((t=>!(!t.isLine()||(t.from.component!==r||e&&t.from.anchor!==e)&&(t.to.component!==r||e&&t.to.anchor!==e))))}(this,t)}findOutletLines(t){return $tt(this,t)}findOutletEnds(t){return function(t,e){return $tt(t,e).map((t=>t.toEnd?.component)).filter(Boolean)}(this,t)}findInletLines(t){return Ktt(this,t)}findInletEnds(t){return function(t,e){return Ktt(t,e).map((t=>t.fromEnd?.component)).filter(Boolean)}(this,t)}};const Jtt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}}],help:"scene/component/rect"};var Ztt={ondragmove:function(t,e,r){var{left:n,top:i,width:a,height:s}=r.model,o=(r.transcoordP2S(t.x,t.y).x-n)/(a/2)*100;o=btt(o,a,s),r.set({round:o})}};class tet extends(Qtt(wtt(ytt))){is3dish(){return!0}get controls(){var{left:t,top:e,width:r,round:n,height:i}=this.state;return[{x:t+r/2*((n=null==n?0:btt(n,r,i))/100),y:e,handler:Ztt}]}get nature(){return Jtt}}mtt.register("rect",tet);const eet=[1,2,10,20,50,50,50,50,50,50];class ret extends(wtt(ytt)){render(t){const{lineWidth:e=1,fillStyle:r="lightgray",font:n="15px Arial",left:i,top:a,rotation:s,origin:o,margin:l,width:h,height:c,side:u="bottom",strokeStyle:d="#000000",scale:p=1}=this.state;t.translate(i,a),t.beginPath();const f=Math.round(e/2);t.rect(-f,-f,h+2*f,c+2*f),t.clip(),t.beginPath(),t.rect(0,0,h,c),r&&(t.fillStyle=r,t.fill()),t.lineWidth=e,t.strokeStyle=d,t.stroke(),t.beginPath(),t.font=n;var g="bottom"!==u,v=g?0:c,m=4*c/5,y=2*c/3,b=1*c/2,w=3*c/5;g&&(m=c-m,y=c-y,b=c-b,w=c-1.5*c/5);var x=p*this.app.PPM/this.root.unitScale,A=Math.ceil(o/x),_=this.app.PPM/x,k=_<=1.1?1:eet[Math.round(_)]||100;1!=k&&(A+=(k-A%k)%k);var S=Math.ceil(A*x),E=o+h;for(t.fillStyle=d;S<E;){if(A%10==0){t.moveTo(S-o,b),t.lineTo(S-o,v);let e=(A/10).toString(),r=t.measureText(e);t.fillText(e,S-o-r.width-6,w)}else A%5==0?(t.moveTo(S-o,y),t.lineTo(S-o,v)):(t.moveTo(S-o,m),t.lineTo(S-o,v));A+=k,S=Math.ceil(A*x)}}}mtt.register("ruler",ret);const net=20,iet=20,aet=90*Math.PI/180,set="9px Verdana",oet=20,het="#f4f4f4",cet="#999";function uet(t,e,r){return{left:-t.x,top:-t.y,width:net,height:oet}}function det(t,e,r,n){return{left:net-t.x,top:0-t.y,origin:20-t.x,width:e-net,height:oet}}function pet(t,e,r,n){var i={x:0-t.x+10,y:-t.y+iet+(r-iet)/2},a=mtt.transcoordRR(0-t.x,-t.y+iet,i,aet);return{left:a.x-(r-iet),top:a.y,origin:20-t.y,width:r-iet,height:oet}}function fet(t){var e=t.get("translate");return{left:-e.x,top:-e.y,width:t.canvas.width/e9,height:t.canvas.height/e9}}mtt.register("guide-layer",class extends Ytt{constructor(t,e){super(t,e),this.appScale={x:1,y:1},"disabled"!==t.ruler&&(this.hruler=new ret({left:net,top:0,origin:20,margin:0,height:oet,unit:"m",rotation:0,font:set,fillStyle:het,strokeStyle:cet,capturable:!1}),this.vruler=new ret({left:0,top:0,origin:20,margin:0,height:oet,unit:"m",rotation:aet,font:set,side:"top",fillStyle:het,strokeStyle:cet,capturable:!1}),this.origin_rect=new tet({left:-20,top:-20,width:20,height:20,fillStyle:het,strokeStyle:cet,lineWidth:1}),this.addComponent(this.hruler),this.addComponent(this.vruler),this.addComponent(this.origin_rect)),this.invalidate()}get capturable(){return!1}ready(){if(super.ready(),this.hruler){var t=this.rootModel,e=Object.assign({},t.get("translate"));e.x<net&&(e.x+=net),e.y<iet&&(e.y+=iet);var r=t.get("scale")||{x:1,y:1};this.appScale=r,this.hruler.set("scale",r.x),this.vruler.set("scale",r.y),t.set("translate",e),this.set("translate",e),this.screen_coord=fet(this);var{width:n,height:i}=this.screen_coord;this.hruler.set(det(e,n,0,this.hruler)),this.vruler.set(pet(e,0,i,this.vruler)),this.origin_rect.set(uet(e))}else this.screen_coord=fet(this)}resize(){super.resize(),this.screen_coord=fet(this);var{width:t,height:e}=this.screen_coord;this.hruler&&(this.hruler.set(det(this.model.translate,t,0,this.hruler)),this.vruler.set(pet(this.model.translate,0,e,this.vruler)),this.origin_rect.set(uet(this.model.translate)))}render(t){if(this.guide){t.save();var{x:e,y:r}=this.guide,{top:n,left:i,width:a,height:s}=this.screen_coord;t.beginPath(),t.moveTo(e,n),t.lineTo(e,n+s),t.moveTo(i,r),t.lineTo(i+a,r),t.lineWidth=1,t.strokeStyle="tomato",t.setLineDash([2,3]),t.font="10px tahoma",t.fillStyle="#333";var o=this.transcoordS2C(e,r,this.rootModel);t.textBaseline=o.y>200?"bottom":"top",t.textAlign=o.x>200?"right":"left";var l=o.y>200?-5:5,h=o.x>200?-5:5,c=Math.round(e/this.appScale.x),u=Math.round(r/this.appScale.y);t.fillText(` ${c}, ${u} `,e+h,r+l),t.stroke(),t.restore()}}get guide(){return this._guide}set guide(t){this._guide=t,this.invalidate()}contains(t,e){return!0}get eventMap(){return{"(root)":{"(descendant)":{mousemove:this.onmousemove_child,mouseout:this.onmouseout_child,dragmove:this.onmousemove_child},"model-layer":{change:this.onchange_root_model}},"(self)":{"(descendant)":{mousedown:this.onmousedown_origin}}}}onmousedown_origin(t,e){this.rootModel.set("translate",{x:20,y:20})}onchange_root_model(t,e,r){if(t.scale&&(this.appScale=t.scale,this.hruler&&(this.hruler.set("scale",t.scale.x),this.vruler.set("scale",t.scale.y))),t.translate&&this.set({translate:{x:t.translate.x,y:t.translate.y}}),t.scale||t.translate){if(this.screen_coord=fet(this),this.hruler){var{translate:n}=this.model,{width:i,height:a}=this.screen_coord;this.hruler.set(det(n,i,0,this.hruler)),this.vruler.set(pet(n,0,a,this.vruler)),this.origin_rect.set(uet(n))}this._guide=null}this.invalidate()}onmouseout_child(t){this._guide=null,this.invalidate()}onmousemove_child(t,e){t.target&&"CANVAS"!==t.target.tagName?this.guide=null:this.guide=this.transcoordC2S(t.offsetX,t.offsetY)}});mtt.register("shift-layer",class extends Ytt{ready(){super.ready();var t=this.rootModel.get("translate");this.set("translate",t)}render(t){}contains(t,e){return!(2!=this.app.mode)}get eventMap(){return{"(root)":{"(self)":{keydown:this.onkeydown,keyup:this.onkeyup}}}}onkeydown(t){"Space"===t.code&&void 0===this.before_mode&&(this.before_mode=this.app.mode,this.app.mode=2)}onkeyup(t){"Space"===t.code&&(void 0!==this.before_mode&&(this.app.mode=this.before_mode),delete this.before_mode)}ondragstart(t){this.last_position=this.transcoordC2S(t.offsetX,t.offsetY)}ondragmove(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.rootModel.move({x:e-this.last_position.x,y:r-this.last_position.y},!1),this.last_position=this.transcoordC2S(t.offsetX,t.offsetY)}});class get{constructor(t){this.params=Object.assign({},t)}excute(){}}class vet extends get{execute(){this.params.changes.forEach((t=>t.component.set(t.after)))}static before(t){return t.map((t=>({component:t})))}static after(t,e){e.execute(null,!1)}static around(t,e,r){e.call(r),t.execute(null,!1)}}const met="left",yet="right",bet="center",wet="bottom",xet="middle",Aet=[met,yet,bet,"top",xet,wet];function _et(t){if(this.hasSameParentForAllSelected&&-1!=Aet.indexOf(t)){var e=this.selected.filter((t=>!t.stuck));if(!(e.length<=1)){var r=this.app.commander;vet.around(r,(function(){!function(t,e){var r=JSON.parse(JSON.stringify(e[0].bounds)),n=r.left+r.width,i=r.top+r.height;for(let t=0;t<e.length;t++){let a=e[t].bounds;r.left=a.left>r.left?r.left:a.left,r.top=a.top>r.top?r.top:a.top,n=a.left+a.width>n?a.left+a.width:n,i=a.top+a.height>i?a.top+a.height:i}switch(r.width=n-r.left,r.height=i-r.top,t){case met:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:r.left,top:n.top,width:n.width,height:n.height}}break;case bet:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:r.left+r.width/2-n.width/2,top:n.top,width:n.width,height:n.height}}break;case yet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={left:n-r.width,top:r.top,width:r.width,height:r.height}}break;case"top":for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:n.left,top:r.top,width:n.width,height:n.height}}break;case xet:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:n.left,top:r.top+r.height/2-n.height/2,width:n.width,height:n.height}}break;case wet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={left:r.left,top:i-r.height,width:r.width,height:r.height}}break;default:;}}(t,e)}))}}}const ket="VERTICAL",Eet=[ket,"HORIZONTAL"];function Met(t){if(this.hasSameParentForAllSelected&&-1!=Eet.indexOf(t)){var e=this.selected;if(!(e.length<=1)){var r=this.app.commander;vet.around(r,(function(){!function(t,e){var r=e.filter((t=>!t.stuck)).slice(0);r.sort((function(e,r){let n=e.center,i=r.center;return t===ket?n.y-i.y:n.x-i.x}));var n=r.reduce(((e,r)=>e+(t===ket?r.bounds.height:r.bounds.width)),0),i=r[0].bounds,a=r[r.length-1].bounds,s=((t===ket?a.top+a.height-i.top:a.left+a.width-i.left)-n)/(r.length-1),o=t===ket?i.top+i.height:i.left+i.width;for(let e=1;e<r.length-1;e++){let n=r[e],i=n.bounds;o+=s,t===ket?(i.top=o,o+=i.height):(i.left=o,o+=i.width),n.bounds=i}}(t,e)}))}}}function Tet(t){for(var e=0;t&&!t.isRootModel();)e+=t.get("rotation")||0,t=t.parent;return e%(2*Math.PI)}class Cet extends get{execute(){this.params.changes.forEach((t=>{let{component:e,to_container:r,to_index:n,to_left:i,to_top:a,hint:s}=t,o=function(t){if(t.isRootModel())return t.bounds;var{bounds:e,rotatePoint:r}=t,n=r;return{left:(n=t.transcoordS2T(n.x,n.y)).x-(r.x-e.left),top:n.y-(r.y-e.top),width:e.width,height:e.height}}(e),l=Tet(e);if(e.removeSelf(!r),e.bounds=o,e.set("rotation",l),r){e.set("rotation",function(t,e){return((t.get("rotation")||0)-Tet(e))%(2*Math.PI)}(e,r));let s=function(t,e){if(e.isRootModel())return t.bounds;var{bounds:r,rotatePoint:n}=t,i=e.transcoordT2S(n.x,n.y),a=e.bounds;return{left:i.x-(n.x-r.left)-a.left,top:i.y-(n.y-r.top)-a.top,width:r.width,height:r.height}}(e,r);t.to_left=void 0!==i?i:s.left,t.to_top=void 0!==a?a:s.top,e.bounds={left:t.to_left,top:t.to_top,width:s.width,height:s.height},void 0===n?r.addComponent(e):r.insertComponentAt(e,n)}}))}}function Pet(t,e,r){this.app.commander.execute(new Cet({changes:[{component:t,to_container:e,to_index:r}]}))}function Iet(t){var e=this.selected.filter((t=>!t.stuck));if(!(0==e.length||e[0].isRootModel()||e.length>1&&("forward"==t||"backward"==t))){var r,n=e[0].parent;if("forward"==t){let t=n.indexOf(e[0]);r=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t+1}]}else if("backward"==t){let t=n.indexOf(e[0]);r=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t-1}]}else r=e.filter((t=>t.parent===n)).sort(((e,r)=>{let i=n.indexOf(e)<n.indexOf(r);return"front"==t?i:!i})).map(((e,r)=>(n.indexOf(e),{component:e,to_container:n,to_index:"front"==t?n.components.length-r-1:r})));var i=new Cet({changes:r});this.app.commander.execute(i)}}function Ret(t,e,r,n){var i=mtt.register(t.type);if(!i)return H7("Class not found",t.type),null;r&&(t.refid=r(t.refid)),t.id&&n&&n(t.id)&&delete t.id;var a=new i(t,e);return t.components&&a.isContainer()&&(t.components.forEach((t=>{var i=Ret(t,e,r,n);i&&a.addComponent(i)})),delete t.components),a.created(),a}function Oet(t,e){var r=h7(t.hierarchy);return delete r.id,Ret(r,t.app,e)}var Let=Object.freeze({__proto__:null,compile:Ret,duplicate:Oet,select:p9,match:c9});function Det(t,e,r){t instanceof Array||(t=[t]),r||(r=this.model_layer);var n=[],i=new Map;this.selected=t.map((t=>{try{return Ret(t,r.app,(t=>{const e=this.getNewRefid();return void 0!==t&&i.set(t,e),e}),(t=>(this.indexMap[t]||[])[0]))}catch(t){return console.warn(t),!1}})).filter(Boolean).map((t=>{let{left:a,top:s,width:o,height:l,x:h,y:c,cx:u,cy:d}=e;return t.replaceRefids(i),isNaN(a)||isNaN(s)||isNaN(o)||isNaN(l)||(t.bounds={left:a,top:s,width:o,height:l}),isNaN(h)||isNaN(c)||t.move({x:h,y:c},!1),isNaN(u)||isNaN(d)||(t.center={x:u,y:d}),n.push({component:t,to_container:r}),t})),this.app.commander.execute(new Cet({changes:n}))}function Fet(){var t=[],e=new Map;if(this.selected=this.selected.filter((t=>!t.isRootModel())).map((r=>{let n=Oet(r,(t=>{const r=this.getNewRefid();return void 0!==t&&e.set(t,r),r}));return n.move({x:20,y:20},!1),t.push({component:n,to_container:r.parent}),n})).map((t=>(t.replaceRefids(e),t))),0!=t.length){var r=new Cet({changes:t});this.app.commander.execute(r)}}function Net(){var t=this.selected;this.selected=[];for(var e=null,r=t.filter((t=>!t.isRootModel()&&(t.parent.focusible||t.parent.isGroup()))).map((t=>(e||(e=t.parent),{component:t,to_container:null})));e&&e.isGroup();){let t=[];if(e.components.filter((t=>!r.find((e=>e.component===t)))).forEach((e=>t.push(e))),t.length>1)break;let n=e.parent;t.forEach((t=>r.push({component:t,to_container:n}))),r.push({component:e,to_container:null}),e=n}r.length>0&&this.app.commander.execute(new Cet({changes:r})),e&&e.calculateBounds&&e.calculateBounds()}function jet(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.on(t,e,r);break;case"mode":this.app?.on(t,e,r);break;default:this.on(t,e,r)}}function Bet(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.once(t,e,r);break;case"mode":this.app.once(t,e,r);break;default:this.once(t,e,r)}}function zet(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.off(t,e,r);break;case"mode":this.app?.off(t,e,r);break;default:this.off(t,e,r)}}function Wet(t){var e=this.target_element,r=t||this.fitMode,n=this;function i(t){n.fit(r),document.fullscreen||document.mozFullScreen||document.webkitIsFullScreen||document.msFullscreenElement||["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange"].forEach((t=>document.removeEventListener(t,i)))}["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange"].forEach((t=>document.addEventListener(t,i))),e.requestFullScreen?e.requestFullScreen():e.webkitRequestFullScreen?e.webkitRequestFullScreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen()}var Uet=0;function Het(){var t=this.selected.filter((t=>!t.isRootModel())).map((t=>t.hierarchy));if(0!=t.length)return Uet=0,JSON.stringify(t,null,2)}function Get(){Uet=0;var t=Het.call(this);return Net.call(this),t}function Yet(t){if(t)try{Uet++,Det.call(this,JSON.parse(t),{x:15*Uet,y:15*Uet})}catch(e){U7(e,t)}}var Vet=function(){return{escape:function(t){return t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},parseExtension:t,mimeType:function(e){var r=t(e).toLowerCase();return(n="application/font-woff",i="image/jpeg",{woff:n,woff2:n,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:i,jpeg:i,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"})[r]||"";var n,i},dataAsUrl:function(t,e){return"data:"+e+";base64,"+t},isDataUrl:function(t){return-1!==t.search(/^(data:)/)},canvasToBlob:function(t){return t.toBlob?new Promise((function(e){t.toBlob(e)})):function(t){return new Promise((function(e){for(var r=window.atob(t.toDataURL().split(",")[1]),n=r.length,i=new Uint8Array(n),a=0;a<n;a++)i[a]=r.charCodeAt(a);e(new Blob([i],{type:"image/png"}))}))}(t)},resolveUrl:function(t,e){var r=document.implementation.createHTMLDocument(),n=r.createElement("base");r.head.appendChild(n);var i=r.createElement("a");return r.body.appendChild(i),n.href=e,i.href=t,i.href},getAndEncode:function(t){var e=3e4;ert.impl.options.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());return new Promise((function(r){var n,i=new XMLHttpRequest;if(i.onreadystatechange=s,i.ontimeout=o,i.responseType="blob",i.timeout=e,i.open("GET",t,!0),i.send(),ert.impl.options.imagePlaceholder){var a=ert.impl.options.imagePlaceholder.split(/,/);a&&a[1]&&(n=a[1])}function s(){if(4===i.readyState)if(200===i.status){var e=new FileReader;e.onloadend=function(){var t=e.result.split(/,/)[1];r(t)},e.readAsDataURL(i.response)}else n?r(n):l("cannot fetch resource: "+t+", status: "+i.status)}function o(){n?r(n):l("timeout of "+e+"ms occured while fetching resource: "+t)}function l(t){console.error(t),r("")}}))},uid:function(){var t=0;return function(){return"u"+e()+t++;function e(){return("0000"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}}}(),delay:function(t){return function(e){return new Promise((function(r){setTimeout((function(){r(e)}),t)}))}},asArray:function(t){for(var e=[],r=t.length,n=0;n<r;n++)e.push(t[n]);return e},escapeXhtml:function(t){return t.replace(/#/g,"%23").replace(/\n/g,"%0A")},makeImage:function(t){return new Promise((function(e,r){var n=new Image;n.onload=function(){e(n)},n.onerror=r,n.src=t}))},width:function(t){var r=e(t,"border-left-width"),n=e(t,"border-right-width");return t.scrollWidth+r+n},height:function(t){var r=e(t,"border-top-width"),n=e(t,"border-bottom-width");return t.scrollHeight+r+n}};function t(t){var e=/\.([^\.\/]*?)$/g.exec(t);return e?e[1]:""}function e(t,e){var r=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(r.replace("px",""))}}(),qet=function(){var t=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(t,i,a){return s()?Promise.resolve(t):Promise.resolve(t).then(r).then((function(e){var r=Promise.resolve(t);return e.forEach((function(t){r=r.then((function(e){return n(e,t,i,a)}))})),r}));function s(){return!e(t)}},shouldProcess:e,impl:{readUrls:r,inline:n}};function e(e){return-1!==e.search(t)}function r(e){for(var r,n=[];null!==(r=t.exec(e));)n.push(r[1]);return n.filter((function(t){return!Vet.isDataUrl(t)}))}function n(t,e,r,n){return Promise.resolve(e).then((function(t){return r?Vet.resolveUrl(t,r):t})).then(n||Vet.getAndEncode).then((function(t){return Vet.dataAsUrl(t,Vet.mimeType(e))})).then((function(r){return t.replace(function(t){return new RegExp("(url\\(['\"]?)("+Vet.escape(t)+")(['\"]?\\))","g")}(e),"$1"+r+"$3")}))}}(),Xet=function(){return{resolveAll:function(){return t().then((function(t){return Promise.all(t.map((function(t){return t.resolve()})))})).then((function(t){return t.join("\n")}))},impl:{readAll:t}};function t(){return Promise.resolve(Vet.asArray(document.styleSheets)).then((function(t){var e=[];return t.forEach((function(t){try{Vet.asArray(t.cssRules||[]).forEach(e.push.bind(e))}catch(e){console.log("Error while reading CSS rules from "+t.href,e.toString())}})),e})).then((function(t){return t.filter((function(t){return t.type===CSSRule.FONT_FACE_RULE})).filter((function(t){return qet.shouldProcess(t.style.getPropertyValue("src"))}))})).then((function(e){return e.map(t)}));function t(t){return{resolve:function(){var e=(t.parentStyleSheet||{}).href;return qet.inlineAll(t.cssText,e)},src:function(){return t.style.getPropertyValue("src")}}}}}(),$et=function(){return{inlineAll:function e(r){return r instanceof Element?n(r).then((function(){return r instanceof HTMLImageElement?t(r).inline():Promise.all(Vet.asArray(r.childNodes).map((function(t){return e(t)})))})):Promise.resolve(r);function n(t){var e=t.style.getPropertyValue("background");return e?qet.inlineAll(e).then((function(e){t.style.setProperty("background",e,t.style.getPropertyPriority("background"))})).then((function(){return t})):Promise.resolve(t)}},impl:{newImage:t}};function t(t){return{inline:function(e){return Vet.isDataUrl(t.src)?Promise.resolve():Promise.resolve(t.src).then(e||Vet.getAndEncode).then((function(e){return Vet.dataAsUrl(e,Vet.mimeType(t.src))})).then((function(e){return new Promise((function(r,n){t.onload=r,t.onerror=n,t.src=e}))}))}}}}(),Ket={imagePlaceholder:void 0,cacheBust:!1};function Qet(t,e){return function(t){void 0===t.imagePlaceholder?ert.impl.options.imagePlaceholder=Ket.imagePlaceholder:ert.impl.options.imagePlaceholder=t.imagePlaceholder;void 0===t.cacheBust?ert.impl.options.cacheBust=Ket.cacheBust:ert.impl.options.cacheBust=t.cacheBust}(e=e||{}),Promise.resolve(t).then((function(t){return Zet(t,e.filter,!0)})).then(trt).then((function(t){var{bgcolor:r,width:n,height:i,style:a,sx:s=1,sy:o=1}=e,l=t.style;r&&(l.backgroundColor=r);n&&(l.width=n+"px");i&&(l.height=i+"px");l["margin-left"]="0px",l["margin-top"]="0px",l.transform=`rotate(0rad) translate(0px, 0px) scale(${s}, ${o}) perspective(1px)`,a&&Object.keys(a).forEach((function(t){l[t]=a[t]}));return t})).then((function(r){return function(t,e,r){return Promise.resolve(t).then((function(t){return t.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),(new XMLSerializer).serializeToString(t)})).then(Vet.escapeXhtml).then((function(t){return'<foreignObject x="0" y="0" width="100%" height="100%">'+t+"</foreignObject>"})).then((function(t){return'<svg xmlns="http://www.w3.org/2000/svg" width="'+e+'" height="'+r+'">'+t+"</svg>"})).then((function(t){return"data:image/svg+xml;charset=utf-8,"+t}))}(r,e.width||Vet.width(t),e.height||Vet.height(t))}))}function Jet(t,e){return Qet(t,e).then(Vet.makeImage).then(Vet.delay(100)).then((function(r){var n=function(t){var r=document.createElement("canvas");if(r.width=e.width||Vet.width(t),r.height=e.height||Vet.height(t),e.bgcolor){var n=r.getContext("2d");n.fillStyle=e.bgcolor,n.fillRect(0,0,r.width,r.height)}return r}(t);return n.getContext("2d").drawImage(r,0,0),n}))}function Zet(t,e,r){return r||!e||e(t)?Promise.resolve(t).then((function(t){if(t instanceof HTMLCanvasElement)try{return Vet.makeImage(t.toDataURL())}catch(t){H7(t)}return t.cloneNode(!1)})).then((function(r){return function(t,e,r){var n=t.childNodes;return 0===n.length?Promise.resolve(e):i(e,Vet.asArray(n),r).then((function(){return e}));function i(t,e,r){var n=Promise.resolve();return e.forEach((function(e){n=n.then((function(){return Zet(e,r)})).then((function(e){e&&t.appendChild(e)}))})),n}}(t,r,e)})).then((function(e){return function(t,e){return e instanceof Element?Promise.resolve().then(r).then(n).then(i).then(a).then((function(){return e})):e;function r(){function r(t,e){function r(t,e){Vet.asArray(t).forEach((function(r){e.setProperty(r,t.getPropertyValue(r),t.getPropertyPriority(r))}))}t.cssText?e.cssText=t.cssText:r(t,e)}r(window.getComputedStyle(t),e.style)}function n(){function r(r){var n=window.getComputedStyle(t,r),i=n.getPropertyValue("content");if(""!==i&&"none"!==i){var a=Vet.uid();e.className=e.className+" "+a;var s=document.createElement("style");s.appendChild(o(a,r,n)),e.appendChild(s)}function o(t,e,r){var n="."+t+":"+e,i=r.cssText?a(r):s(r);return document.createTextNode(n+"{"+i+"}");function a(t){var e=t.getPropertyValue("content");return t.cssText+" content: "+e+";"}function s(t){return Vet.asArray(t).map(e).join("; ")+";";function e(e){return e+": "+t.getPropertyValue(e)+(t.getPropertyPriority(e)?" !important":"")}}}}[":before",":after"].forEach((function(t){r(t)}))}function i(){t instanceof HTMLTextAreaElement&&(e.innerHTML=t.value),t instanceof HTMLInputElement&&e.setAttribute("value",t.value)}function a(){e instanceof SVGElement&&(e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e instanceof SVGRectElement&&["width","height"].forEach((function(t){var r=e.getAttribute(t);r&&e.style.setProperty(t,r)})))}}(t,e)})):Promise.resolve()}function trt(t){return $et.inlineAll(t).then((function(){return t}))}var ert={toSvg:Qet,toPng:function(t,e){return Jet(t,e||{}).then((function(t){return t.toDataURL()}))},toJpeg:function(t,e){return Jet(t,e=e||{}).then((function(t){return t.toDataURL("image/jpeg",e.quality||1)}))},toBlob:function(t,e){return Jet(t,e||{}).then(Vet.canvasToBlob)},toPixelData:function(t,e){return Jet(t,e||{}).then((function(e){return e.getContext("2d").getImageData(0,0,Vet.width(t),Vet.height(t)).data}))},impl:{fontFaces:Xet,images:$et,util:Vet,inliner:qet,options:{}}};function rrt(t,e,r,n){var i=this.model_layer,a=i._overlay;return new Promise((function(s,o){if(i){var l=i.get("width"),h=i.get("height");r=r||l,n=n||h;var c=i.get("translate"),u=i.get("scale"),d=Math.min(r/l,n/h);r=l*d,n=h*d,i.set("translate",{x:0,y:0}),i.set("scale",{x:d/e9,y:d/e9});var p=mtt.createCanvas(r,n),f=p.getContext("2d");if(i.draw(f),i.set("translate",c),i.set("scale",u),!a)return s(p.toDataURL(t,e)),void(p=null);ert.toPng(a,{sx:d,sy:d,width:r,height:n}).then((function(i){var a=new Image;a.onload=function(){f.drawImage(a,0,0,r,n),s(p.toDataURL(t,e)),p=null},a.src=i}),(function(r){U7(r),s(p.toDataURL(t,e)),p=null}))}else o("No target model")}))}function nrt(){if(this.hasSameParentForAllSelected){var t=this.selected.filter((t=>!!t.parent&&!t.stuck));if(!(t.length<2)){var e=t[0].parent,r=[],n=t.sort(((t,r)=>e.components.indexOf(t)-e.components.indexOf(r)));n.forEach((t=>{r.push(t.bounds)}));var i=mtt.union(r),a=t[0].transcoordP2S(i.left,i.top);a=t[0].transcoordS2T(a.x,a.y);var s=new Map,o=Ret({type:"group",left:a.x,top:a.y,width:i.width,height:i.height},e.app,(t=>{const e=this.getNewRefid();return void 0!==t&&s.set(t,e),e}));o.replaceRefids(s);var l=[{component:o,to_container:e}];n.forEach((t=>{l.push({component:t,to_container:o})})),this.app.commander.execute(new Cet({changes:l})),this.selected=[o]}}}function irt(){if(0!==this.selected.length){var t=[],e=[];this.selected.forEach((r=>{if(r.isGroup()){var n=r.parent;r.components.forEach((r=>{t.push(r),e.push({component:r,to_container:n})})),e.push({component:r,to_container:null})}})),this.app.commander.execute(new Cet({changes:e})),this.selected=t}}function art(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=mtt.union(e),n=r.left+r.width/2;t.map((t=>{t.symmetryX(n)}))}}function srt(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=mtt.union(e),n=r.top+r.height/2;t.map((t=>{t.symmetryY(n)}))}}function ort(){vet.around(this.app.commander,art,this)}function lrt(){vet.around(this.app.commander,srt,this)}function hrt(t,e,r){var n=this.findAll(t,r);return n.forEach((t=>{t.set(e)})),n}function crt(t){vet.around(this.app.commander,t)}function urt(){return Object.values(this.indexMap).map((t=>t.map((t=>{let{id:e,data:r}=t.model;return{key:e,value:r}})))).flat().sort(((t,e)=>t.key>e.key?1:-1))}const drt="left",prt="right",frt="center",grt="bottom",vrt="middle",mrt=[drt,prt,frt,"top",vrt,grt];function yrt(t){if(this.hasSameParentForAllSelected&&-1!=mrt.indexOf(t)){var e=this.selected.filter((t=>!t.stuck)),r=this.app.commander;vet.around(r,(function(){!function(t,e){const r=e[0].parent,{width:n,height:i}=r.bounds;switch(t){case drt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:0}}break;case frt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:n/2-r.width/2}}break;case prt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:n-r.width}}break;case"top":for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:0}}break;case vrt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:i/2-r.height/2}}break;case grt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:i-r.height}}break;default:;}}(t,e)}))}}function brt(t){t instanceof Array||(t=[t]),this.trigger("addstart",t)}function wrt(){this.trigger("stylepastestart")}function xrt(){this.trigger("stylepastestop")}function Art(){this.trigger("databindpastestart")}function _rt(){this.trigger("databindpastestop")}function krt(t,e,r,n){var i=t.selected,a=n?i.slice(0):[];n&&a.length>0?e=a[0].parent:e.isContainer()||(e=e.parent);var s=e.layout.capturables(e),o=!!e.layout.joinType;if(n&&r.selected.forEach((t=>{a.splice(a.indexOf(t),1)})),r.selected=[],s.forEach((t=>{t.capturable&&function(t,e,r){var n,i,a,s,{sx:o,sy:l,ex:h,ey:c}=e;if(o>h?(n=h,i=o):(n=o,i=h),l>c?(a=c,s=l):(a=l,s=c),r){var u=t.bounds,d=t.transcoordS2TR(u.left,u.top),p=t.transcoordS2TR(u.left+u.width,u.top+u.height),f=d.x,g=p.x,v=d.y,m=p.y,y=Math.min(n,f,i,g),b=Math.max(n,f,i,g),w=Math.min(a,v,s,m),x=Math.max(a,v,s,m);return!(b-y>Math.abs(i-n)+Math.abs(g-f)||x-w>Math.abs(s-a)+Math.abs(m-v))}var A=t.path;if(!A)return error("컴포넌트에 get path가 잘못 구현되어있음.",t),!1;for(let e=0;e<A.length;e++){let r=t.transcoordS2TR(A[e].x,A[e].y);if(n>r.x||i<r.x||a>r.y||s<r.y)return!1}return!0}(t,r,o)&&-1==a.indexOf(t)&&r.selected.push(t)})),a=a.concat(r.selected),i.length!==a.length)t.selected=a;else for(let e=0;e<a.length;e++)if(i[e]!=a[e]){t.selected=a;break}}function Srt(t,e,r,n,i){i||krt(t,e,r,n)}function Ert(t,e){var r=t.components||[];for(let t of r){Ert(t,e);let r=e.indexOf(t);-1!=r&&e.splice(r,1)}}mtt.register("add-layer",class extends Ytt{ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}render(t){var e=this.addbox;if(e){let{sx:r,sy:n,ex:i,ey:a}=e,s=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/s.x,4/s.y]),t.lineWidth=1/s.x,t.strokeStyle="black",t.stroke()}}contains(t,e){return!(3!=this.app.mode)}get eventMap(){return{"(root)":{"(self)":{addstart:this.onaddstart,addstop:this.onaddstop,keydown:this.onkeydown,dragstart:this.ondragstart,dragmove:this.ondragmove,dragend:this.ondragend,mousedown:this.onmousedown,mouseup:this.onmouseup}},"model-layer":{"(self)":{change:this.onchange_root_model}}}}onchange_root_model(t,e,r){t.translate&&this.set("translate",t.translate),t.scale&&this.set("scale",t.scale)}onaddstart(t,e){void 0===this.before_mode&&(this.before_mode=this.app.mode,this.models=t,this.app.mode=3)}onaddstop(){void 0!==this.before_mode&&(this.app.mode=this.before_mode),delete this.before_mode,delete this.addbox,this.invalidate()}onkeydown(t){3!==this.app.mode||"Esc"!=t.code&&"Escape"!=t.code||this.root.trigger("addstop")}ondragstart(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.addbox={sx:e,sy:r}}ondragmove(t){if(3===this.app.mode){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.addbox&&(this.addbox.ex=e,this.addbox.ey=r,this.invalidate())}}ondragend(t,e){if(3!==this.app.mode)return;const{sx:r,sy:n,ex:i,ey:a}=this.addbox;Det.call(this.root,this.models,{left:Math.min(r,i),top:Math.min(n,a),width:Math.abs(i-r),height:Math.abs(a-n)}),this.root.trigger("addstop")}onmousedown(t,e){3===this.app.mode&&(this.downpoint={x:t.offsetX,y:t.offsetY})}onmouseup(t,e){if(this.downpoint.x===t.offsetX&&this.downpoint.y===t.offsetY){var{x:r,y:n}=this.transcoordC2S(t.offsetX,t.offsetY);Det.call(this.root,this.models,{cx:r,cy:n}),this.root.trigger("addstop")}}});mtt.register("selection-layer",class extends Ytt{ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}contains(t,e){return!1}render(t){var e=this.selbox;if(e){let{sx:r,sy:n,ex:i,ey:a}=e,s=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/s.x,4/s.y]),t.lineWidth=1/s.x,t.strokeStyle="black",t.stroke()}}get eventMap(){return{"(root)":{"(self)":{keydown:this.onkeydown}},"model-layer":{"(self)":{change:this.onchange_root_model},"(all)":{dragstart:this.ondragstart_selbox,dragmove:this.ondragmove_selbox,dragend:this.ondragend_selbox,mousedown:this.onmousedown_comp,mouseup:this.onmouseup_comp}}}}onkeydown(t,e){var{origin:r,deliverer:n}=e,i=n.selected;if(1!==i.length)return!1;var a=i[0],s=a.parent;if(!s||s===n)return!1;if("Tab"===t.code){var o=s.layout.capturables(s),l=o.indexOf(a);if(-1==l){if(!s.indexOf(a))return H7("Container not contains [",a,"] as a component"),!1;l=0}var h=o.length;t.shiftKey?l--:l++,a=o[(l+h)%h]}else{if(!s.layout.keyNavigate)return!1;a=s.layout.keyNavigate(s,a,t)||a}n.selected=[a],t.preventDefault()}onchange_root_model(t,e,r){t.translate&&this.set("translate",t.translate),t.scale&&this.set("scale",t.scale)}_pendingDecision(t){this.downpoint={x:t.offsetX,y:t.offsetY}}_selectGroupItem(t,e){var r=this.selected.indexOf(t);let n=t.parent;for(;n.parent.isGroup();)n=n.parent;let i=[],a=!1,s=!1;if(this.selected.forEach((t=>{let e=t.parent;if(t!==n){for(;e.parent&&e.parent.isGroup();)e=e.parent;e===n&&(i.push(t),a=!0)}else s=!0})),a)if(e.shiftKey){if(-1!=r)return void this._pendingDecision(e);i.push(t)}else{if(-1!=r)return void this._pendingDecision(e);i=[t]}else{if(s)return void this._pendingDecision(e);if(e.shiftKey)if(this.selected.length>0){if(-1!=this.selected.indexOf(n))return;i=[...this.selected,n]}else i=[n];else i=[n]}this.selected=i}onmousedown_comp(t,e){var{origin:r}=e;if(this.downpoint=null,t.shiftKey){if(r.parent.isGroup())return void this._selectGroupItem(r,t);if(-1!=this.selected.indexOf(r))return void this._pendingDecision(t);{let t=this.selected.filter((t=>!t.isRootModel()&&!!t.parent)),e=t.length>0&&t[0].parent;e&&e!==r.parent&&(!function(t,e){for(var r=t.parent;r;){let t=e.indexOf(r);-1!=t&&e.splice(t,1),r=r.parent}}(r,t),Ert(r,t)),t.push(r),this.selected=t}}else{if(r.parent.isGroup())return void this._selectGroupItem(r,t);if(-1!=this.selected.indexOf(r))return;this.selected=[r],this.sameParent=!0}}onmouseup_comp(t,e){if(!this.downpoint)return;if(this.downpoint.x!==t.offsetX||this.downpoint.y!==t.offsetY)return;var{origin:r}=e;let n=this.selected.indexOf(r);if(-1==n&&r.parent.isGroup()&&(n=this.selected.indexOf(r.parent)),-1!==n&&t.shiftKey){let t=this.selected.slice();return n>-1&&t.splice(n,1),void(this.selected=t)}r.parent.isGroup()&&(this.selected=[r])}ondragstart_selbox(t,e){var{origin:r}=e;if(r.stuck){var{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);this.selbox={sx:n,sy:i,selected:[]}}}ondragmove_selbox(t,e){var{origin:r}=e;if(r.stuck){var{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);this.selbox&&(this.selbox.ex=n,this.selbox.ey=i,Srt(this,r,this.selbox,t.shiftKey),this.invalidate())}}ondragend_selbox(t,e){var{origin:r}=e;r.stuck&&(this.last_pos=null,this.selbox=null,Srt(this,null,null,!1,!0),this.invalidate())}});class Mrt{constructor(t){this.layer=t}draw(t,e,r){var{left:n,top:i,width:a,height:s}=e.bounds;0!=a&&0!=s&&(t.beginPath(),t.rect(n,i,a,s),t.clip(),t.beginPath(),t.strokeStyle="#f26522",t.lineWidth=4,t.shadowBlur=10,t.shadowColor="black",t.shadowOffsetX=0,t.shadowOffsetY=0,t.rect(n,i,a,s),t.stroke(),t.closePath())}}class Trt{constructor(t){this.layer=t}draw(t,e,r){var n=e.bounds;t.beginPath(),t.rect(n.left-4/r.x,n.top-4/r.y,n.width+8/r.x,n.height+8/r.y),t.setLineDash([3/r.x,4/r.y]),t.lineWidth=1/r.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),t.closePath()}}class Crt{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){let i=r.controls;return!!i&&(i.every(((i,a)=>(Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a,handler:i.handler}),!this.active))),!!this.active)}draw(t,e,r){var n=e.controls;n&&n.forEach(((e,n)=>{t.beginPath(),t.lineWidth=1/r.x,t.ellipse(e.x,e.y,4/r.x,4/r.y,0,0,2*Math.PI,!0),t.fillStyle="#ff5d72",t.fill(),t.strokeStyle="#fff",t.stroke()}))}onevent(t,e){var{handler:r,component:n,index:i}=this.active,a=n.transcoordC2S(e.offsetX,e.offsetY);a=n.transcoordS2P(a.x,a.y),r&&"function"==typeof r[t]&&r[t](a,i,n)}onmousedown(t){this.onevent("onmousedown",t)}ondragstart(t){var e=this.active;e.changes=vet.before([e.component]),this.onevent("ondragstart",t)}ondragmove(t){this.onevent("ondragmove",t)}ondragend(t){this.onevent("ondragend",t);var{component:e,changes:r}=this.active;vet.after(r,e.app.commander),e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}function Prt(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}const Irt=15*Math.PI/180;class Rrt{constructor(t){this.layer=t}reset(){this.active=null,this.created=null}get selected(){return this.layer.selected}contains(t,e,r,n){return!!r.mutable&&(r.path.every(((i,a)=>(Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a}),!this.active))),!!this.active)}startLinkProcess(t,e,r){try{var n=Ret(e,t.app);return t.rootModel.addComponent(n),this.layer.selected=[n],this.active={component:n,index:1},this.ondragstart(r),n}catch(t){console.warn(r)}}draw(t,e,r){if(e.mutable&&!e.stuck){var n=e.path,i=this.active;n.forEach(((n,a)=>{t.beginPath(),t.ellipse(n.x,n.y,4/r.x,4/r.y,0,0,2*Math.PI,!0),t.lineWidth=1/r.x,t.strokeStyle="#656565",t.fillStyle="#fff",i&&i.component===e&&i.index===a&&(t.strokeStyle="#fa7703",i.toFill&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke()}))}}ondblclick(t){var e=this.active.component;if(e.pathExtendable){var r=e.path.slice();r.length<3||(r.splice(this.active.index,1),e.path=r)}}onmousedown(t){this.active.toFill=!0}ondragstart(t){var{index:e,component:r}=this.active;this.created||(this.active.changes=vet.before([r])),0!==e&&e!==r.path.length-1||(this.layer.counterEnd=0===e?r.toEnd||{fromto:"to"}:r.fromEnd||{fromto:"from"})}ondragmove(t){var{component:e,index:r}=this.active||{};const{offsetX:n,offsetY:i}=t;var a,s,o=e.transcoordC2S(n,i);if(o=e.transcoordS2P(o.x,o.y),t.shiftKey){var l=e.path.length,h=e.isLine()&&0==r?e.path[1]:e.path[(r-1+l)%l];h=e.transcoordS2P(h.x,h.y);var c,u=0;if(l>2)e.isLine()?0==r?c=e.path[2]:1!=r&&(c=e.path[r-2]):c=e.path[(r-2+l)%l],c&&(u=Prt(c=e.transcoordS2P(c.x,c.y),h));var d=Math.round((Prt(h,o)-u)/Irt)*Irt+u;o=function(t,e,r){return{x:Math.cos(e)*r+t.x,y:Math.sin(e)*r+t.y}}(h,d,(a=h,s=o,Math.sqrt((s.x-a.x)*(s.x-a.x)+(s.y-a.y)*(s.y-a.y))))}if(0===r||r===e.path.length-1){const t=this.layer.anchorTarget=e.rootModel.capture(n,i,(t=>!t.isConnectable()));if(t){const{x:a,y:s}=t.transcoordC2S(n,i),l=this.layer.get("scale")||{x:1,y:1},h=this.layer.counterEnd,c=(t.anchors||[]).find((r=>{const{name:n,inout:i,multiplicity:o=1/0,position:c,filter:u}=r;if(h){const{anchor:t,fromto:e}=h;if(t&&("out"===t.inout&&"out"===i||"in"===t.inout&&"in"===i))return!1;if("from"===e&&"out"===i||"to"===e&&"in"===i)return!1}else console.error("should not be here.");if(Math.abs(a-c.x)>8/l.x||Math.abs(s-c.y)>8/l.y)return!1;const d=t.findInOutLines(n);return!!d.includes(e)||!(o!==1/0&&d.length>=o)&&(!h||!u||!!u.call(r,h))}));c?0==r?e.from={component:t.get("refid"),anchor:c.name,position:o}:e.to={component:t.get("refid"),anchor:c.name,position:o}:0==r?e.from={position:o}:e.to={position:o}}}e.mutatePath(null,(function(t){t[r]=o}))}ondragend(t){var{component:e,index:r,changes:n}=this.active;if(0===r||r===e.path.length-1){const{offsetX:n,offsetY:i}=t,a=e.rootModel.capture(n,i,(t=>t===e||t.isLine())),{x:s,y:o}=a.transcoordC2S(n,i),l=this.layer.get("scale")||{x:1,y:1},h=(a.anchors||[]).find((t=>t&&Math.abs(s-t.position.x)<=8/l.x&&Math.abs(o-t.position.y)<=8/l.y));h&&(0==r?e.from={component:a.get("refid"),anchor:h.name}:e.to={component:a.get("refid"),anchor:h.name}),this.layer.endLinkProcess()}if(this.created){let t=new Cet({changes:[{component:this.created,to_container:this.created.parent}]});created.app.commander.execute(t)}else vet.after(n,e.app.commander);e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}class Ort{constructor(t){this.layer=t}get active(){return this._active?.component.disposed&&(this._active=null),this._active}set active(t){this._active=t}reset(){this.active=null}contains(t,e,r,n){const i=this.active?.component===r&&this.active?.anchor;this.active=null;const a=this.layer.counterEnd;return(r.isConnectable()&&!r.disposed&&r.anchors||[]).filter((t=>{const{name:e,inout:n,multiplicity:i=1/0,filter:s}=t;if(a){const{anchor:t,fromto:e}=a;if(t&&("out"===t.inout&&"out"===n||"in"===t.inout&&"in"===n))return!1;if("from"===e&&"out"===n||"to"===e&&"in"===n)return!1}else if("in"===n)return!1;return!(i!==1/0&&r.findInOutLines(e).length>=i)&&(!s||!a||!!s.call(t,a))})).every((a=>{const s=i===a.name?2:1;return a&&a.position&&Math.abs(t-a.position.x)<=4*s/n.x&&Math.abs(e-a.position.y)<=4*s/n.y&&(this.active={component:r,anchor:a.name,template:a.template}),!this.active})),!!this.active}draw(t,e,r){if(!e.get("refid")||e.isLine())return;var n=this.active;const i=this.active?.component===e&&this.active?.anchor,a=this.layer.counterEnd;(e.isConnectable()&&!e.disposed&&e.anchors||[]).filter((t=>{const{name:r,inout:n,multiplicity:i=1/0,filter:s}=t;if(a){const{anchor:t,fromto:e}=a;if(t&&("out"===t.inout&&"out"===n||"in"===t.inout&&"in"===n))return!1;if("from"===e&&"out"===n||"to"===e&&"in"===n)return!1}else if("in"===n)return!1;return!(i!==1/0&&e.findInOutLines(r).length>=i)&&(!a||!s||!!s.call(t,a))})).forEach((a=>{const{name:s,position:o}=a,l=i===s?2:1;o&&(t.beginPath(),t.ellipse(o.x,o.y,4*l/r.x,4*l/r.y,0,0,2*Math.PI),t.setLineDash([0,0]),t.lineWidth=1/r.x,t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",n&&n.component===e&&n.anchor===s&&(t.strokeStyle="#fa7703",n.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())}))}onmousedown(t){this.active.focus=!0}ondragstart(t){const{component:e,anchor:r,template:n}=this.active,i=this.layer.transcoordC2S(t.offsetX,t.offsetY);this.layer.startLinkProcess(e,{type:"ortholine",lineWidth:1,strokeStyle:"black",begin:"oval",beginSize:"size9",end:"arrow",endSize:"size9",lineDash:"solid",lineCap:"butt",round:10,...n,from:{component:e.get("refid"),anchor:r,position:i},to:{position:i}},t)}ondragmove(t){}ondragend(t){}}function Lrt(t,e,r){var n,i,{left:a,top:s,width:o,height:l}=t.bounds;switch(e){case 0:n=a,i=s;break;case 1:n=a+o/2,i=s;break;case 2:n=a+o,i=s;break;case 3:n=a+o,i=s+l/2;break;case 4:n=a+o,i=s+l;break;case 5:n=a+o/2,i=s+l;break;case 6:n=a,i=s+l;break;case 7:n=a,i=s+l/2}var h=n,c=i,u=t.transcoordT2S(r.x,r.y);return{dx:u.x-h,dy:u.y-c}}function Drt(t,e,r,n,i,a){var{left:s,top:o,width:l,height:h}=t.bounds,c={left:s,top:o,width:l,height:h};switch(e){case 0:s+=n,o+=i,l-=n,h-=i;break;case 1:o+=i,h-=i;break;case 2:o+=i,l+=n,h-=i;break;case 3:l+=n;break;case 4:l+=n,h+=i;break;case 5:h+=i;break;case 6:s+=n,l-=n,h+=i;break;case 7:s+=n,l-=n}if(t.mutateBounds((function(e){return Math.abs(l)<=.001&&(l=.001),Math.abs(h)<=.001&&(h=.001),t.adjustResize({left:s,top:o,width:l,height:h},c,r)}),this),t.isContainer()&&t.layout.ABSOLUTE&&!t.isGroup()){var u=c.left-s,d=c.top-o;a?t.components.forEach((t=>{t.delta("tx",0),t.delta("ty",0),t.move({x:u,y:d},!1)})):t.components.forEach((t=>{t.delta("tx",u),t.delta("ty",d)}))}else{var p=a&&t.parent;p&&p.isGroup()&&p.calculateBounds()}}function Frt(t,e){var{left:r,top:n,width:i,height:a}=t,s=r+i/2,o=n+a/2,l=r+i,h=n+a;const c=i*e.x>50,u=a*e.y>50;return[{x:r,y:n},c?{x:s,y:n}:null,{x:l,y:n},u?{x:l,y:o}:null,{x:l,y:h},c?{x:s,y:h}:null,{x:r,y:h},u?{x:r,y:o}:null]}class Nrt{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){return!!r.resizable&&(Frt(r.bounds,n).every(((i,a)=>(i&&Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a}),!this.active))),!!this.active)}draw(t,e,r){if(!e.isLine()){var{left:n,top:i,width:a,height:s}=e.bounds;if(t.beginPath(),t.rect(n-4/r.x,i-4/r.y,a+8/r.x,s+8/r.y),t.setLineDash([3/r.x,4/r.y]),t.lineWidth=1/r.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),e.resizable){var o=this.active;Frt(e.bounds,r).forEach(((n,i)=>{n&&(t.beginPath(),t.rect(n.x-4/r.x,n.y-4/r.y,8/r.x,8/r.y),t.setLineDash([0,0]),t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",o&&o.component===e&&o.index===i&&(t.strokeStyle="#fa7703",o.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())}))}}}onmousedown(t){this.active.focus=!0}ondragstart(t){var{component:e}=this.active;this.active.bounds=e.bounds,this.active.boundsList=this.layer.selected.filter((t=>t.resizable)).map((t=>t.bounds))}ondragmove(t){var{component:e,index:r,boundsList:n,bounds:i}=this.active,a=this.layer.transcoordC2S(t.offsetX,t.offsetY);e.bounds=i;var s=Lrt(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],Drt(e,r,t.shiftKey,s.dx,s.dy,!1)}))}ondragend(t){var{component:e,index:r,boundsList:n,bounds:i}=this.active,a=this.layer.transcoordC2S(t.offsetX,t.offsetY);e.bounds=i;var s=Lrt(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],Drt(e,r,t.shiftKey,s.dx,s.dy,!0)})),this.active.component.app.commander.execute(null,!1)}}const jrt=2*Math.PI,Brt=Math.PI/2;function zrt(t,e){var r=t.bounds;return{x:r.left+r.width/2,y:r.top-20/e.y}}class Wrt{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){if(!r.rotatable)return!1;var i=zrt(r,n);return Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r},!0)}draw(t,e,r){if(e.rotatable){t.beginPath();var n=zrt(e,r);t.lineWidth=1.5/r.x,t.moveTo(n.x,n.y+20/r.y),t.lineTo(n.x,n.y),t.strokeStyle="#656565",t.stroke(),t.beginPath(),t.ellipse(n.x,n.y,4/r.x,4/r.y,0,0,jrt,!0),t.stroke(),t.fillStyle="#fff",t.fill();var i=this.active;i&&i.component===e&&(t.strokeStyle="#fa7703",t.stroke(),i.toFill&&(t.fillStyle="#ffb80c",t.fill()))}}onmousedown(t){this.active.toFill=!0}ondragstart(t){var e=this.active;e.component,e.start_rotation=e.component.get("rotation"),e.rotations=this.layer.selected.filter((t=>t.rotatable)).map((t=>t.get("rotation")))}ondragmove(t){var{component:e}=this.active,r=e.transcoordC2S(t.offsetX,t.offsetY);r=e.transcoordS2P(r.x,r.y);var n=e.rotatePoint,i=e.get("rotation")||0,a=Math.atan((n.y-r.y)/(n.x-r.x)),s=(a=n.x>=r.x?a-Brt:Brt+a)-i;this.layer.selected.filter((t=>t.rotatable)).forEach(((e,r)=>{let n=((e.get("rotation")||0)+s)%jrt;e.set("rotation",e.adjustRotation(n,t.shiftKey))}))}ondragend(t){var{component:e,rotations:r}=this.active;e.app.commander.execute(null,!1)}}mtt.register("modeling-layer",class extends Ytt{constructor(t,e){super(t,e),this.pathHandler=new Rrt(this);var r=this.pathHandler,n=new Crt(this),i=new Nrt(this),a=new Wrt(this);this._modelers=[r,n,i,a],this._control_mode_modelers=[n,r,i,a],this.focusOutline=new Mrt(this),this.groupOutline=new Trt(this),this.anchorHandler=new Ort(this),this._reversed_modelers=this._modelers.slice().reverse(),this._control_mode_reverse_modelers=this._control_mode_modelers.slice().reverse(),this.hovered=null,this.hoveredDest=null}get modelers(){return this._control_mode?this._control_mode_modelers:this._modelers}get reversedModelers(){return this._control_mode?this._control_mode_reverse_modelers:this._reversed_modelers}ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}contains(t,e){var r=this.selected.filter((t=>!!t.parent)),n=this.get("scale")||{x:1,y:1};if(this._state_dragging){if(this._counter_end){let r=this.anchorTarget.transcoordT2S(t,e);if(this.anchorHandler.contains(r.x,r.y,this.anchorTarget,n))return!0}return!0}this.modelers.forEach((t=>t.reset()));r=this.selected.filter((t=>!!t.parent));for(let i=0;i<r.length;i++){let a=r[i],s=a.transcoordT2S(t,e);for(let t=0;t<this.modelers.length;t++){let e=this.modelers[t];if(e.contains(s.x,s.y,a,n))return this.currentModeler=e,!0}}if(this.anchorTarget){let r=this.anchorTarget.transcoordT2S(t,e);if(this.anchorHandler.contains(r.x,r.y,this.anchorTarget,n))return this.currentModeler=this.anchorHandler,!0}else this.anchorHandler.reset();return this.currentModeler=null,!1}_componentDrawer(t,e,r,n){let i=[],a=e.parent;if(e.isRootModel())return t.save(),n(t,e,r),void t.restore();for(;a&&!a.isRootModel();)i.push(a),a=a.parent;t.save(),i.reverse().forEach((function(e){let r=e.rotatePoint;t.translate(r.x,r.y);let n=e.get("scale");n&&t.scale(n.x,n.y),t.rotate(e.get("rotation")),t.translate(-r.x,-r.y);let i=e.bounds;t.translate(i.left,i.top)}));let s=e.rotatePoint;t.translate(s.x,s.y);let o=e.get("scale");o&&t.scale(o.x,o.y),t.rotate(e.get("rotation")),t.translate(-s.x,-s.y),n(t,e,r),t.restore()}prerender(t){var{translate:e,scale:r={x:1,y:1},rotation:n}=this.model;t.save(),t.beginPath(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.rect(0,0,t.canvas.width,t.canvas.height),t.fillStyle="black",t.globalAlpha=.5,t.fill(),t.restore(),e&&t.translate(e.x*e9,e.y*e9),t.scale(r.x*e9,r.y*e9),n&&t.rotate(n),t.clearRect(0,0,this.rootModel.get("width"),this.rootModel.get("height"))}render(t){t.beginPath();var e=this.get("scale")||{x:1,y:1},r=this.selected.filter((t=>!!t.parent));if(this.focused&&this._componentDrawer(t,this.focused,e,((t,e,r)=>{this.focusOutline.draw(t,e,r)})),r.length>0&&r[0].parent.isGroup()){let n=r[0].parent;for(;n.parent.isGroup();)n=n.parent;this._componentDrawer(t,n,e,((t,e,r)=>{this.groupOutline.draw(t,e,r)}))}r.forEach((r=>{this._componentDrawer(t,r,e,((t,e,r)=>{this.reversedModelers.forEach((n=>n.draw(t,e,r)))}))})),this.anchorTarget&&this._componentDrawer(t,this.anchorTarget,e,((t,e,r)=>{this.anchorHandler.draw(t,e,r)}))}get anchorTarget(){return this.currentModeler===this.anchorHandler||this.currentModeler===this.pathHandler||this.hovered?.isLine()||(this._anchorTarget=this.hovered),this._anchorTarget}set anchorTarget(t){this._anchorTarget=t}get hovered(){return this._hovered}set hovered(t){this._hovered=t,this.invalidate()}startLinkProcess(t,e,r){this.currentModeler=this.pathHandler,this.processingLink=this.pathHandler.startLinkProcess(t,e,r),this.counterEnd=this.processingLink.fromEnd,this.processingLink.trigger("tag")}set counterEnd(t){this.currentModeler=this.pathHandler,this._counter_end=t}get counterEnd(){return this._counter_end}endLinkProcess(){this.processingLink?.trigger("tagreset"),this.processingLink=null,this._counter_end=null}get eventMap(){return{"model-layer":{"(all)":{change:this.onchange_model,wheel:this.onwheel_scale,drop:this.ondrop},"(descendant)":{mouseenter:this.onmouseenter,mouseleave:this.onmouseleave},"(self)":{dblclick:this.ondblclick_model}},"(root)":{"(self)":{selected:this.onselected,keydown:this.onkeydown,keyup:this.onkeyup}}}}onmouseenter(t,e){this.hovered=e?.origin}onmouseleave(t,e){this.hovered=null}onkeydown(t){"Alt"==t.key&&(this._control_mode=!0,this.invalidate())}onkeyup(t){"Alt"==t.key&&(this._control_mode=!1,this.invalidate())}onselected(t,e){this.invalidate()}onchange_model(t,e,r){var{origin:n,deliverer:i}=r;n===i&&(t.translate&&this.set("translate",t.translate),void 0!==t.rotation&&this.set("rotation",t.rotation),t.scale&&this.set("scale",t.scale)),this.invalidate()}ondblclick_model(t,e){const r=e.origin;r?.root.fit()}ondblclick(t){"function"==typeof this.currentModeler.ondblclick&&this.currentModeler.ondblclick(t),this.invalidate()}onmousedown(t){this.currentModeler.onmousedown(t),this.invalidate()}onmouseup(t){"function"==typeof this.currentModeler.onmouseup&&this.currentModeler.onmouseup(t),this.invalidate()}ondragstart(t){this.currentModeler.ondragstart(t),this._state_dragging=!0}ondragmove(t){this.currentModeler.ondragmove(t),this.invalidate()}ondragend(t){this._state_dragging=!1,this.currentModeler.ondragend(t),this.invalidate()}ondrop(t,e){var{origin:r}=e,n=t.dataTransfer.files;if(n.length<1)return;let i=this.rootModel.transcoordC2S(t.offsetX,t.offsetY),a=this.rootModel;Promise.all(Array.from(n).map((t=>new Promise(((e,r)=>{let n=new FileReader;n.addEventListener("loadend",(t=>{e(n.result)})),["error","abort"].forEach((t=>n.addEventListener(t,(t=>{r(t)})))),n.readAsDataURL(t)}))))).then((e=>{if(t.altKey)return vet.around(this.app.commander,(()=>{r.ondropfile(n,e)})),void(this.selected=[r]);let s=[],o=e.map(((t,e)=>{let r,o=n[e].type,l=n[e].name;return o.startsWith("image/")?(r=Ret({type:o.startsWith("image/gif")?"gif-view":"image-view",top:0,left:0,width:200,height:200,src:t},a.app),s.push(new Promise(((e,n)=>{let i=new Image;i.src=t,i.onload=()=>{r.set({width:i.width,height:i.height}),e()},i.onerror=t=>{n(t)}})))):o.startsWith("audio/")?r=Ret({type:"audio",top:0,left:0,width:100,height:100,src:t},a.app):o.startsWith("vnd.ms-excel/")||/\.xlsx?$/.test(l)?r=Ret({type:"excel",top:0,left:0,width:100,height:100,src:t},a.app):console.log("droped file",n[e]),r&&(r.center=i,i.x+=50,i.y+=50),r})).filter(Boolean).map((t=>({component:t,to_container:a})));o.length>0&&Promise.all(s).then((()=>{this.app.commander.execute(new Cet({changes:o})),this.selected=o.map((t=>t.component))}),(t=>{console.error(t)}))}),(t=>{console.error(t)}))}onwheel_scale(t,e){if(0!=t.deltaY||0!=t.deltaX){var r=e.deliverer;if(t.shiftKey){if(-1!=navigator.userAgent.indexOf("Win"))var n=t.deltaY<0?1:-1;else n=t.deltaX<0?1:-1;t.altKey?vet.around(this.app.commander,(()=>{r.selected.forEach((t=>{let e=t.get("letterSpacing")||i9.LETTER_SPACING;e+=n,t.set("letterSpacing",e)}))})):vet.around(this.app.commander,(()=>{r.selected.forEach((t=>{let e=t.get("fontSize")||i9.FONT_SIZE;e<1&&(e=1),e+=n,t.set("fontSize",e)}))}))}else{n=t.deltaY<0?1:-1;let e=r.get("scale")||{x:1,y:1},i=r.get("translate"),a=t.offsetX,s=t.offsetY,o=r.transcoordC2S(a,s),l=.1*n,h={x:e.x+l,y:e.y+l};if(n<0&&e.x<.2||n>0&&e.x>10)return;r.set("scale",h);let c=r.transcoordC2S(a,s);r.set("translate",{x:i.x+(c.x-o.x)*h.x,y:i.y+(c.y-o.y)*h.y})}}}});class Urt extends Ytt{constructor(t,e){super(t,e),this._anim_alpha=1}animOnTargetChange(t){t!==this._lastTargets&&(this._lastTargets=t,this._anim_alpha=1,this.animate({step:t=>{this._anim_alpha=1-t,this.invalidate()},duration:5e3,delta:"circ",ease:"in"}).start())}decorate(t,e,r){const n=t.decorators;var i=!1;return n.map((t=>"string"==typeof t?htt(t):t)).filter((t=>t&&"function"==typeof t)).map((n=>{const a=n(t,e,1-r);i||=a})),i}render(t){var e=this.decoTargets&&this.decoTargets.filter((t=>t.rootModel));if(!e||0==e.length)return this._animate&&this._animate.stop(),void delete this._animate;t.globalAlpha*=this._anim_alpha;var r=!1;e.forEach((e=>{this.decorate(e,t,1-this._anim_alpha)&&(r=!0)})),r&&this.animOnTargetChange(this.decoTargets)}get decoTargets(){return this._decoTargets}set decoTargets(t){this._decoTargets=t&&t.filter((t=>!t.isLayer())),this.invalidate()}get eventMap(){return{"model-layer":{"(descendant)":{tag:this.ondecotag,tagreset:this.ondecotagreset,mouseenter:this.onmouseenter,mouseleave:this.onmouseleave}}}}onmouseenter(t,e){this._decotagreset(),this._ondecotag(e.origin)}onmouseleave(t,e){this._decotagreset()}ondecotagreset(t){this._decotagreset()}ondecotag(t){this._ondecotag(t.origin)}offdecotag(t,e){this._offdecotag(e.origin)}_ondecotag(t){this.decoTargets&&-1!==this.decoTargets.lastIndexOf(t)||(this.decoTargets=(this.decoTargets||[]).concat(t))}_offdecotag(t){if(this.decoTargets){var e=this.decoTargets.slice();e.splice(this.decoTargets.lastIndexOf(t),1),this.decoTargets=e}}_decotagreset(){this.decoTargets=[]}}mtt.register("decotag-layer",Urt),mtt.register("tag-layer",Urt);mtt.register("reaction-layer",class extends Ytt{constructor(t,e){super(t,e),this._anim_alpha=1}animOnTargetChange(t){t!==this._lastTargets&&(this._lastTargets=t,this._anim_alpha=1,this.animate({step:t=>{this._anim_alpha=1-t,this.invalidate()},duration:1e4,delta:"circ",ease:"inout"}).start())}decorate(t,e,r){const n=t.reactionDecorators;var i=!1;return n.map((t=>"string"==typeof t?htt(t):t)).filter((t=>t&&"function"==typeof t)).map((n=>{const a=n(t,e,1-r);i||=a})),i}render(t){var e=this.targets&&this.targets.filter((t=>t.rootModel));if(!e||0==e.length)return this._animate&&this._animate.stop(),void delete this._animate;t.globalAlpha*=this._anim_alpha;var r=!1;e.forEach((e=>{this.decorate(e,t,1-this._anim_alpha)&&(r=!0)})),r&&this.animOnTargetChange(this.targets)}get targets(){return this._targets}set targets(t){this._targets=t&&t.filter((t=>!t.isLayer())),this.invalidate()}get eventMap(){return{"model-layer":{"(descendant)":{reaction:this.onreaction,reactionreset:this.onreactionreset}}}}onreactionreset(t){this._reactionreset()}onreaction(t){this._onreaction(t.origin)}offreaction(t,e){this._offreaction(e.origin)}_onreaction(t){this.targets&&-1!==this.targets.lastIndexOf(t)||(this.targets=(this.targets||[]).concat(t))}_offreaction(t){if(this.targets){var e=this.targets.slice();e.splice(this.targets.lastIndexOf(t),1),this.targets=e}}_reactionreset(){this.targets=[]}});function Hrt(){var t=arguments,e=t[t.length-1],r=this.event_pump;r.listeners.forEach((n=>{!function(t,e,r,n,i){for(let a in r){let s=r[a];if(c9(a,n.origin,0,t))for(let t in s){let r=s[t];t==n.name&&(n.listener=e,r.apply(e,i))}}}(r.deliverer,n.listener,n.cloned_handlers,e,t)}))}mtt.register("scroll-layer",class extends Ytt{get capturable(){return!0}render(t){const{scrolling:e}=this.state;if(t.save(),t.beginPath(),t.fillStyle="#777",this.vscroller){const{left:r,top:n,width:i,height:a}=this.vscroller;t.globalAlpha="v"==e?1:.3,t.fillRect(r,n,i,a)}if(this.hscroller){const{left:r,top:n,width:i,height:a}=this.hscroller;t.globalAlpha="h"==e?1:.3,t.fillRect(r,n,i,a)}t.stroke(),t.restore()}resize(){super.resize(),this.calcScrollerBounds()}contains(t,e){const r=this.vscroller,n=this.hscroller;return this.setState("scrolling",r&&t>=r.left&&t<=r.left+r.width&&e>=r.top&&e<=r.top+r.height?"v":n&&t>=n.left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height?"h":null),!!this.getState("scrolling")}get eventMap(){return{"(root)":{"model-layer":{change:this.onchangeModelLayer}}}}onchange(t){"scrolling"in t&&this.invalidate()}ondragstart(t,e){this.lastPosition={x:t.offsetX,y:t.offsetY}}ondragmove(t,e){const r=this.root,{clientWidth:n,clientHeight:i}=this.canvas,{width:a,height:s}=this.rootModel.model,{x:o,y:l}={x:t.offsetX,y:t.offsetY},{x:h,y:c}=this._scale,{scrolling:u}=this.state,d=a/n,p=s/i;u&&r.rootModel.move({x:"h"==u?(-o+this.lastPosition.x)*h*d:0,y:"v"==u?(-l+this.lastPosition.y)*c*p:0},!1),this.lastPosition={x:t.offsetX,y:t.offsetY}}ondragend(){delete this.lastPosition,this.setState({scrolling:null})}calcScrollerBounds(){var{clientWidth:t,clientHeight:e}=this.canvas;const{width:r,height:n}=this.rootModel.model,{x:i=1,y:a=1}=this._scale||{},{x:s=0,y:o=0}=this._translate||{},l=r/t,h=n/e;var c={left:-s/i/l,top:e-10,width:t/i/l,height:10};this.hscroller=c.left>1||c.width+c.left<t-1?c:null,c={left:t-10,top:-o/a/h,width:10,height:e/a/h},this.vscroller=c.top>1||c.height+c.top<e-1?c:null,this.invalidate()}onchangeModelLayer(t,e,r){if(t.scale){const{x:e=1,y:r=1}=t?.scale||{};this._scale={x:e,y:r},this.calcScrollerBounds()}if(t.translate){const{x:e=0,y:r=0}=t.translate||{};this._translate={x:e,y:r},this.calcScrollerBounds()}}});class Grt{constructor(t){if(void 0===t.on)throw new Error("Deliverer should be a event handlable object.");this.deliverer=t,this.listeners=[]}start(){this.deliverer.on("(all)",Hrt,{event_pump:this})}stop(){this.deliverer.off("(all)",Hrt)}on(t,e){var r=Object.assign({},e);Object.keys(r).forEach((e=>{if(0==e.indexOf("?")){let n=r[e],i=e.substr(1),a=t.get(i);delete r[e],a?r[a]=n:H7("EventPump#on","variable #{selector} is not evaluated on listener")}})),this.listeners.push({listener:t,handlers:e,cloned_handlers:r})}off(t,e){for(let r=0;r<this.listeners.length;r++){let n=this.listeners[r];n.listener!==t||e&&n.handlers!==e||this.listeners.splice(r,1)}}clear(){this.listeners=[]}dispose(){this.stop(),this.clear()}}class Yrt{constructor(t){this.eventMaps=[],this.root=t,t.eventMap&&this.add(t,t.eventMap)}set root(t){this._root=t}get root(){return this._root}stop(){this.eventMaps.forEach((t=>t.eventPump.stop()))}add(t,e){if(this.root)for(let r in e){let n=e[r];if("(self)"===r&&void 0===t.on)throw new Error("(self) selector not available when deliverer is not a event handlable object.");p9(r,this.root,t).forEach((r=>{var i=new Grt(r);i.on(t,n),i.start(),this.eventMaps.push({eventPump:i,listener:t,handlerMap:e,deliverer:r})}))}}remove(t,e){var r=this.eventMaps.slice(0);for(let n=0;n<r.length;n++){let i=r[n];i.listener!==t||e&&i.handlerMap!==e||(this.eventMaps.splice(n,1),i.eventPump.dispose())}}clear(){this.eventMaps.slice(0).forEach((t=>t.eventPump.dispose())),this.eventMaps=[]}dispose(){this.stop(),this.clear()}}const Vrt=0,qrt=1,Xrt=2,$rt=0,Krt=1,Qrt=2;var Jrt={},Zrt=0;class tnt{constructor(t,e){this._type=e||t.type,this._ctrlKey=t.ctrlKey,this._altKey=t.altKey,this._shiftKey=t.shiftKey,this._metaKey=t.metaKey;var r=function(t){if(t.touches){let e=t.touches[0];if(!e)return Jrt;let r=e.target.getBoundingClientRect();return Jrt={x:t.offsetX||e.clientX-(r.x||r.left),y:t.offsetY||e.clientY-(r.y||r.top)}}return{x:t.offsetX,y:t.offsetY}}(t);if(this._offsetX=r.x,this._offsetY=r.y,"wheel"==t.type)this.deltaX=t.deltaX,this.deltaY=t.deltaY,this.deltaZ=t.deltaZ;else if("drop"==t.type)this.dataTransfer=t.dataTransfer;else if(t.type.match(/^touch/)&&(this._scale=t.scale,this._touches=t.touches,this._changedTouches=t.changedTouches,null==this._scale)){var n=function(t){var e,r,n=0,i=0,a=0;if(1===t.touches.length)return a;Array.from(t.touches).forEach((t=>{e=null!=e?Math.min(t.screenX,e):t.screenX,n=Math.max(t.screenX,n),r=null!=r?Math.min(t.screenY,r):t.screenY,i=Math.max(t.screenY,i)}));var s=n-e||0,o=i-r||0;return Math.sqrt(Math.pow(s,2)+Math.pow(o,2))||0}(t);Zrt>0&&(this._scale=n/Zrt),Zrt=n}}get type(){return this._type}set type(t){this._type=t}get offsetX(){return this._offsetX}get offsetY(){return this._offsetY}get altKey(){return this._altKey}get ctrlKey(){return this._ctrlKey}get shiftKey(){return this._shiftKey}get metaKey(){return this._metaKey}get touches(){return this._touches}get changedTouches(){return this._changedTouches}get scale(){return this._scale}stopPropagation(){this._stop_=!0,this.originalEvent&&"function"==typeof this.originalEvent.stopPropagation&&this.originalEvent.stopPropagation()}isPropagationStopped(){return this._stop_}preventDefault(){this._prevented=!0}isDefaultPrevented(){return this._prevented}}function ent(t,e){return t.capture(e.offsetX,e.offsetY)}function rnt(t,e,r){if(t&&t.app&&(!t.app.isViewMode||!t.hidden)){r instanceof tnt&&e===r.type||(r=new tnt(r,e));var n="on"+e;t[n]&&t[n](r),r.isPropagationStopped()||t.trigger(e,r)}}class nnt{constructor(t,e){this.container=t,this.html_element=e,this.status=Vrt,this.last_target=null,this.gesture_handlers=r9.map((t=>this.gestureHandlerBuilder(t))),this.keyevent_handlers=n9.map((t=>this.keyeventHandlerBuilder(t))),r9.forEach(((t,r)=>e.addEventListener(t,this.gesture_handlers[r])),{passive:!1}),n9.forEach(((t,r)=>e.addEventListener(t,this.keyevent_handlers[r]))),e.ondragover=this.gestureHandlerBuilder("dragover"),e.ondrop=this.gestureHandlerBuilder("drop"),e.tabIndex=1}dispose(){this.last_enter_target&&rnt(this.last_enter_target,"mouseleave",new CustomEvent("mouseleave")),r9.forEach(((t,e)=>this.html_element.removeEventListener(t,this.gesture_handlers[e]))),n9.forEach(((t,e)=>this.html_element.removeEventListener(t,this.keyevent_handlers[e]))),delete this.gesture_handlers,delete this.keyevent_handlers,delete this.last_target}gestureHandlerBuilder(t){var e=this[`on${t}`].bind(this);return t=>{const r=new tnt(t);return e(r),r.isDefaultPrevented()&&t.preventDefault(),!1}}keyeventHandlerBuilder(t){return this[`on${t}`].bind(this)}ondragover(t){return rnt(ent(this.container,t),t.type,t),!1}ondrop(t){return rnt(ent(this.container,t),t.type,t),!1}ondblclick(t){return rnt(ent(this.container,t),t.type,t),this.last_target=null,!1}onkeydown(t){return this.container.trigger(t.type,t),!1}onkeyup(t){return this.container.trigger(t.type,t),!1}onmousemove(t){switch(this.status){case qrt:let r=t.offsetX-this.__dragstart_e.offsetX,n=t.offsetY-this.__dragstart_e.offsetY;if(r*r+n*n<16)break;this.status=Xrt,rnt(this.last_target,"dragstart",this.__dragstart_e),this.__dragmove_e=t,rnt(this.last_target,"dragmove",t);break;case Xrt:this.__dragmove_e=t,rnt(this.last_target,"dragmove",t);break;default:var e=ent(this.container,t);this.last_enter_target!==e&&(this.last_enter_target&&rnt(this.last_enter_target,"mouseleave",t),e&&rnt(e,"mouseenter",t),this.last_enter_target=e),rnt(e,t.type,t),this.last_target=e}return!1}onmousedown(t){if(this.status===Xrt)rnt(this.last_target,"dragend",t),this.last_target=null,this.status=Vrt;else{var e=ent(this.container,t);this.last_target=e,this.status=qrt,this.__dragstart_e=t,rnt(e,t.type,t)}return!1}onmouseup(t){if(this.status===Xrt)rnt(this.last_target,"dragend",t);else{var e=ent(this.container,t);rnt(e,t.type,t),this.last_target===e&&rnt(e,"click",t)}return this.last_target=null,this.status=Vrt,!1}onmouseout(t){var e=ent(this.container,t);if(this.status===Xrt)rnt(this.last_target,"dragend",t);else{if(this.last_target&&this.last_target===e)return;this.last_enter_target&&(rnt(this.last_enter_target,"mouseleave",t),delete this.last_enter_target)}return this.last_target=null,this.status=Vrt,!1}ontouchstart(t){var e=ent(this.container,t);return this.last_target=e,this.status=Krt,this.touchPoints||(this.touchPoints=[]),this.touchPoints.push(t.changedTouches[0]),this.holdTimer=setTimeout((()=>{this.status=$rt,rnt(this.last_target,"hold",t),delete this.holdTimer}),500),rnt(e,t.type,t),!1}ontouchmove(t){if(!t.touches||!t.changedTouches)return rnt(this.last_target,"dragstart",t),rnt(this.last_target,"dragmove",t),!1;var e=ent(this.container,t);switch(this.status){case Krt:Array.from(t.changedTouches).forEach((t=>{var e=this.touchPoints.find((e=>e.identifier===t.identifier));if(e){var r=e.clientX-t.clientX,n=e.clientY-t.clientY;return Math.sqrt(Math.pow(r,2)+Math.pow(n,2))>=16?(this.status=Qrt,void(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer))):void 0}}));break;case Qrt:if(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer),2===t.changedTouches.length&&null!=t.scale&&1!==t.scale&&(t.scale<.9||t.scale>1.1))return rnt(this.last_target,"pinch",t),!1;rnt(this.last_target,"pan",t),e=this.last_target;break;default:this.last_enter_target!==e&&(this.last_enter_target&&rnt(this.last_enter_target,"mouseleave",t),e&&rnt(e,"mouseenter",t),this.last_enter_target=e),this.last_target=e}return rnt(e,"touchmove",t),!1}ontouchend(t){var e=ent(this.container,t);switch(this.status){case Qrt:e=this.last_target;break;case Krt:var r=performance.now(),n=r-this.touchedAt;this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer,rnt(e,n<500?"doubletap":"tap",t),this.touchedAt=r)}rnt(e,"touchend",t);var i=this.touchPoints.findIndex((e=>e.identifier===t.changedTouches[0].identifier));return this.touchPoints.splice(i,1),this.last_target=null,this.status=$rt,!1}onwheel(t){return rnt(ent(this.container,t),t.type,t),!1}}function int(t,e,r,n=0){if(e.length<2)return e;let i=2;for(;i<e.length;i++){const a=e.substring(0,i);if(!(t.measureText(a).width+(a.length-1)*n<r))break}return e.substring(0,i-1)}function ant(t,e,r,n,i=0){const a=String(e).split("\n");return n?[].concat.apply([],a.map((e=>function(t,e,r,n=0){const i=e.split(" "),a=[];let s,o,l=[];for(s=0,o=1;o<=i.length;o++)if(l=i.slice(s,o),t.measureText(l.join(" ")).width+(l.join("").length-1)*n>r){if(o-s==1){const e=int(t,l[0],r,n);a.push([e]),i.splice(s,1,e,l[0].substring(e.length))}else{for(;""==i[o-1];)o++;a.push(i.slice(s,--o))}s=o}return o-s>1&&a.push(l),0==a.length&&a.push([""]),a}(t,e,r,i)))):a.map((t=>t.split(" ")))}var snt={},ont={};const lnt=()=>{};var hnt={register:function(t,e,r){snt[t]=e,r&&(ont[t]=r)},unregister:function(t){delete snt[t],delete ont[t]},get:function(t){return snt[t]},getDisposer:function(t){return ont[t]||lnt}};function cnt(t){if(!t.hasTextProperty||t.textHidden)return;var{text:e="",bold:r=i9.BOLD,italic:n=i9.ITALIC,textWrap:i=i9.TEXT_WRAP,letterSpacing:a=0,fontFamily:s=i9.FONT_FAMILY,fontColor:o=i9.FONT_COLOR,textAlign:l=i9.TEXT_ALIGN,textBaseline:h=i9.TEXT_BASELINE,fontSize:c=i9.FONT_SIZE,lineHeight:u=1.2*c}=t.model,{left:d,top:p,width:f,height:g}=t.textBounds;c||=i9.FONT_SIZE,u||=1.2*c,t.textHidden=!0;var v=document.createElement("textarea");r9.forEach((function(t){v.addEventListener(t,(function(t){t.stopPropagation()}),!0)}));const m=t.transcoordS2C(d,p),{rotation:y,scale:b}=function(t){for(var e=0,r=1,n=t;n;){e+=n.get("rotation")||0;let{x:t,y:i}=n.get("scale")||{x:1,y:1};r*=Math.max(t,i)||1,n=n.parent}return{rotation:e,scale:r}}(t);switch(v.style.position="absolute",v.style.width=f+"px",v.style.height=g+"px",v.style.padding="0",v.value=e,v.style.fontFamily=s,v.style.fontSize=c+"px",v.style.lineHeight=u+"px",v.style.overflow="hidden",v.style.resize="none",v.style.outline="none",v.style.border=0,v.style.backgroundColor="transparent",v.style.display="inline-block",v.style.color=o,r&&(v.style.fontWeight="bold"),n&&(v.style.fontStyle="italic"),l){case"right":case"end":v.style.textAlign="right";break;case"justify":v.style.textAlign="justify";break;case"left":case"start":v.style.textAlign="left";break;default:v.style.textAlign="center"}var w=[r,n,c+"px",s].filter(Boolean).join(" ");function x(e){var r={left:0,top:0},n=u*function(t,e,r,n,i=0){var a,s=t.getContext();return s.save(),s.font=r,a=ant(s,e,n,t.get("textWrap"),i).length,s.restore(),a}(t,e,w,f,a);switch(v.style.height=n+"px",h){case"top":case"hanging":break;case"bottom":case"alphabetic":r.top=g-n;break;default:r.top=g/2-n/2}if(!i){var s=function(t,e,r,n){var i=e.split("\n"),a=n;let s=t.getContext();return s.save(),s.font=r,i.forEach((t=>{let e=s.measureText(t).width;e>a&&(a=e)})),s.restore(),a}(t,e,w,f);switch(v.style.width=s+"px",l){case"right":case"end":r.left=f-s;break;case"left":case"start":break;default:r.left=(f-s)/2}}v.style.marginLeft=r.left+"px",v.style.marginTop=r.top+"px",v.style.transform=`translate(${m.x}px, ${m.y}px) scale(${b}) rotate(${y}rad)`,v.style.transformOrigin=`${-r.left}px ${-r.top}px`}x(e);var A=t.root.target_element;A.appendChild(v),v.select();var _,k=!1;v.addEventListener("keydown",(function(t){t.stopPropagation(),"Escape"!=t.code&&(t.shiftKey||"Enter"!=t.code&&"NumpadEnter"!=t.code)?setTimeout((()=>{x(v.value)})):(k=_.skipUpdate="Escape"==t.code,document.createEvent?v.dispatchEvent(_):v.fireEvent(_.eventType,_))})),document.createEvent?(_=document.createEvent("HTMLEvents")).initEvent("blur",!0,!1):(_=document.createEventObject()).eventType="blur";var S=t.root.selected,E=function(r){t.root.selected=S,t.textHidden=!1,v.removeEventListener("blur",E,!1),v.parentElement&&v.parentElement.removeChild(v),A.focus(),r.skipUpdate||k||t.app.commander.execute(new vet({changes:[{component:t,before:{text:e},after:{text:v.value}}]}))};v.addEventListener("blur",E,!1)}hnt.register("text-editor",{"(root)":{"(self)":{keydown:function(t,e){var{origin:r,deliverer:n}=e,i=n.selected;return!(1!==i.length||!i[0].hasTextProperty)&&(("Enter"==t.code||"NumpadEnter"==t.code)&&(cnt(i[0]),t.preventDefault(),!0))}}},"model-layer":{"(descendant)":{dblclick:function(t,e){cnt(e.origin)}}}});var unt,dnt,pnt,fnt=x7((function(t,e,r){if(t.hasSameParentForAllSelected&&!r){var n=[];e[0].parent.isGroup()?t.focused=e[0].parent:(e.forEach((t=>{t.path.forEach((e=>{n.push(t.transcoordS2T(e.x,e.y))}))})),t.focused=t.capturePath(n,e))}else t.focused=null}),300);hnt.register("move-handler",{"model-layer":{"(descendant)":{dragstart:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected,a=n.selected.filter((t=>!t.stuck));if(i.length!==a.length&&(i=n.selected=a),0!=i.length){var s=i[0].transcoordC2S(t.offsetX,t.offsetY);if(s=i[0].transcoordS2P(s.x,s.y),this.last_pos=s,this.direction=0,n.focused=i[0].parent,t.altKey){var o=[],l=new Map;n.selected=n.selected.filter((t=>!t.isRootModel())).map((t=>{let e=Oet(t,(t=>{const e=n.root.getNewRefid();return void 0!==t&&l.set(t,e),e}));return o.push({component:e,to_container:t.parent}),e})).map((t=>(t.replaceRefids(l),t))),o.forEach((({component:t,to_container:e})=>{e.addComponent(t)})),this.duplicates=n.selected.map((t=>({component:t})))}else this.changes=vet.before(i)}}},dragmove:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected;if(0!=i.length){var{x:a,y:s}=i[0].transcoordC2S(t.offsetX,t.offsetY),o=i[0].transcoordS2P(a,s);t.shiftKey?2==this.direction&&(this.direction=0):this.direction=2;var l=o.x-this.last_pos.x,h=o.y-this.last_pos.y;if(0==this.direction){if(l*l+h*h<25)return;Math.abs(l)>Math.abs(h)?this.direction=3:this.direction=4}3==this.direction?h=0:4==this.direction&&(l=0),i.forEach((t=>{t.move({x:l,y:h},1===i.length)})),this.last_pos=o,fnt(n,i)}}},dragend:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected;if(0!=i.length){var a=i[0].parent,s=n.focused||e.deliverer;if(this.changes&&!s.isGroup())if(n.hasSameParentForAllSelected&&s&&s!==a){var o=this.changes.map((t=>{let{component:e,before:r}=t;return{component:e,to_container:s}}));n.app.commander.execute(new Cet({changes:o}))}else vet.after(this.changes,n.app.commander);else if(this.duplicates){this.duplicates=this.duplicates.map((t=>(t.to_container=s,t)));let t=new Cet({changes:this.duplicates});n.app.commander.execute(t)}i.forEach((t=>{t.parent&&t.parent.calculateBounds&&t.parent.calculateBounds()})),this.last_pos=null,this.changes=null,this.duplicates=null,fnt(n,i,!0)}}}}},"(root)":{"(self)":{keydown:function(t,e){var{origin:r,deliverer:n}=e,i={},a=t.shiftKey?r.rootModel.MPP:1;switch(t.which){case 37:i.x=-a,i.y=0;break;case 38:i.x=0,i.y=-a;break;case 39:i.x=a,i.y=0;break;case 40:i.x=0,i.y=a;break;default:return}var s=n.selected;vet.around(n.app.commander,(function(){s.forEach((t=>{!t.stuck&&t.move(i,!1)}))}))}}}});const gnt=A7((()=>{const{x:t,y:e}=pnt,r=dnt.deref();r&&(r.rootModel.move({x:t-unt.x,y:e-unt.y},!1),unt={x:t,y:e})}),60,{leading:!0,trailing:!0});hnt.register("shift-handler",{"model-layer":{"(all)":{dragstart:function(t,e){unt={x:t.offsetX,y:t.offsetY}},dragmove:function(t,e){dnt=new WeakRef(e.deliverer),pnt={x:t.offsetX,y:t.offsetY},gnt()}}}}),hnt.register("zoom-handler",{"model-layer":{"(all)":{wheel:function(t,e){if(0==t.deltaY&&0==t.deltaX)return;var r=e.deliverer,n=t.deltaY<0?1:-1;let i=r.get("scale")||{x:1,y:1},a=r.get("translate"),s=t.offsetX,o=t.offsetY,l=r.transcoordC2S(s,o),h=.1*n,c={x:i.x+h,y:i.y+h};if(n<0&&i.x<.2||n>0&&i.x>10)return;r.set("scale",c);let u=r.transcoordC2S(s,o);r.set("translate",{x:a.x+(u.x-l.x)*c.x,y:a.y+(u.y-l.y)*c.y})}},"(self)":{dblclick:function(t,e){const r=e.origin;r?.root.fit()}}}});var vnt={},mnt={};function ynt(t){const e={};for(const r in t)t.hasOwnProperty(r)&&void 0!==t[r]&&(e[r]=t[r]);return e}function bnt(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}function wnt(t,e,r,n,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void r(t)}o.done?e(l):Promise.resolve(l).then(n,i)}function xnt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function s(t){wnt(a,n,i,s,o,"next",t)}function o(t){wnt(a,n,i,s,o,"throw",t)}s(void 0)}))}}function Ant(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _nt(t,e){return t.get(bnt(t,e))}function knt(t,e,r){Ant(t,e),e.set(t,r)}function Snt(t,e,r){return t.set(bnt(t,e),r),r}function Ent(t,e,r){return r(bnt(t,e))}function Mnt(t,e){Ant(t,e),e.add(t)}function Tnt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Cnt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Pnt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Cnt(Object(r),!0).forEach((function(e){Tnt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Cnt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Int(t,e,r){e||(e=[]);var n=e.length++;return Object.defineProperty({},"_",{set:function(i){e[n]=i,t.apply(r,e)}})}hnt.register("paste-handler",{"(root)":{"(self)":{stylepastestart:function(t){const{deliverer:e}=t,r=e.app;var n=e.selected;if(n&&n[0]&&n!==e.rootModel){const t=n[0],{fillStyle:e,strokeStyle:i,alpha:a,lineWidth:s,lineDash:o,lineCap:l,lineJoin:h,fontColor:c,fontSize:u,fontFamily:d,bold:p,italic:f,textAlign:g,textBaseline:v,textOverflow:m,paddingTop:y,paddingBottom:b,paddingLeft:w,paddingRight:x}=t.state;vnt=h7({fillStyle:e,strokeStyle:i,alpha:a,lineWidth:s,lineDash:o,lineCap:l,lineJoin:h,fontColor:c,fontSize:u,fontFamily:d,bold:p,italic:f,textAlign:g,textBaseline:v,textOverflow:m,paddingTop:y,paddingBottom:b,paddingLeft:w,paddingRight:x}),r.mode=4}},stylepastestop:function(t){const{deliverer:e}=t,r=e.app;vnt={},4==r.mode&&(r.mode=1)},databindpastestart:function(t){const{deliverer:e}=t,r=e.app;var n=e.selected;if(n&&n[0]&&n!==e.rootModel){const t=n[0],{mappings:e}=t.state;mnt=h7({mappings:e}),r.mode=5}},databindpastestop:function(t){const{deliverer:e}=t,r=e.app;mnt={},5==r.mode&&(r.mode=1)},keydown:function(t,e){const{deliverer:r}=e;"Esc"!=t.code&&"Escape"!=t.code||(4==r.app.mode?r.trigger("stylepastestop"):5==r.app.mode&&r.trigger("databindpastestop"))}}},"model-layer":{"(all)":{click:function(t,e){const{deliverer:r}=e,n=r.app;if(4!=n.mode&&5!=n.mode)return;const i=e.origin;4==n.mode?i===r?r.root.trigger("stylepastestop"):i&&vet.around(n.commander,(()=>{const t=ynt({...i.model,...vnt});i?.set(t)})):i===r?r.root.trigger("databindpastestop"):i&&vet.around(n.commander,(()=>{const t=ynt({...i.model,...mnt});i?.set(t)}))}}}});class Rnt{constructor(t,e,r){Tnt(this,"_delta",{theta:0,tx:0,ty:0,sx:1,sy:1,fade:0}),Tnt(this,"_location",null);const{animations:n,...i}=r;this.overlay=t,this.target=e,this.decorator=i||{},this.animations=[],Array.isArray(n)?this.animations=n.map((t=>("theta"in t&&(t={...t,theta:t.theta*(Math.PI/180)}),L8(this,t)))):n&&("theta"in n&&(n={...n,theta:n.theta*(Math.PI/180)}),this.animations=[L8(this,n)])}delta(t,e){if(void 0===e)return t?this._delta[t]:this._delta;this._delta[t]=e;const{tx:r,ty:n,sx:i,sy:a,theta:s,fade:o}=this._delta;Object.assign(this.element.style,{opacity:1-o,transform:`rotate(${s}rad) translate(${r}px, ${n}px) scale(${i}, ${a}) perspective(1px)`})}get location(){if(this._location)return this._location;const{location:t,size:e}=this.decorator,{left:r,top:n,width:i,height:a}=this.target.bounds;let s;switch(t){case"top-left":s={x:r,y:n-e};break;case"top":s={x:r+(i-e)/2,y:n-e};break;case"top-right":s={x:r+i-e,y:n-e};break;case"bottom-left":s={x:r,y:n+a};break;case"bottom":s={x:r+(i-e)/2,y:n+a};break;case"bottom-right":s={x:r+i-e,y:n+a};break;case"left":s={x:r-e,y:n+(a-e)/2};break;case"right":s={x:r+i,y:n+(a-e)/2};break;default:s={x:r+i/2-e/2,y:n+a/2-e/2}}return this._location=this.target.transcoordS2T(s.x,s.y),this._location}get element(){if(!this._element){const{icon:t,size:e,color:r}=this.decorator,{x:n,y:i}=this.location,a=document.createElement("div");a.setAttribute("scene","animated-icon"),Object.assign(a.style,{position:"absolute",fontVariationSettings:"'FILL' 1",fontFamily:"Material Symbols Outlined",fontSize:e+"px",width:e+"px",height:e+"px",lineHeight:e+"px",padding:0,margin:0,color:r,textAlign:"center",verticalAlign:"middle",left:n+"px",top:i+"px",pointerEvents:"none"}),a.textContent=t,this._element=a}return this._element}touch(){}invalidate(){}start(){this.overlay.appendChild(this.element),this.animations.forEach((t=>t.start()))}stop(){this.overlay.removeChild(this.element),this.animations.forEach((t=>t.stop())),this._location=null}get root(){return this.target.root}get center(){const{size:t}=this.decorator,{x:e,y:r}=this.location;return{x:e+t/2,y:r+t/2}}transcoordS2T(t,e){const{tx:r,ty:n}=this._delta;return{x:t+r,y:e+n}}}class Ont{static getTargetId(t){if(!Ont._targetIdMap.has(t)){const e=`target-${Math.random().toString(36).substring(2,9)}`;Ont._targetIdMap.set(t,e)}return Ont._targetIdMap.get(t)}static getSvgContainer(t){if(!Ont._svgMap.has(t)){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","border-highlighting-container"),e.setAttribute("pointer-events","none"),e.style.overflow="visible",e.style.position="absolute",e.style.top="0",e.style.left="0";const r=document.createElementNS("http://www.w3.org/2000/svg","defs");e.appendChild(r);const n=document.createElementNS("http://www.w3.org/2000/svg","g");n.setAttribute("class","border-highlighting-group"),e.appendChild(n),t.appendChild(e),Ont._svgMap.set(t,e)}return Ont._svgMap.get(t)}constructor(t,e,r){this.overlayRef=new WeakRef(t),this.target=e,this.decorator=r}get element(){const t=this.overlayRef.deref();if(!t)return null;const{distance:e=10,lineWidth:r=2,color:n="red",animation:i=!1,fillStyle:a}=this.decorator||{},{round:s=0,fillStyle:o}=this.target.state,l=this.target.path.map((t=>this.target.transcoordS2T(t.x,t.y))),h=this.createOffsetPath(l,e),c=this.pointsToPathData(h,s),u=Ont.getSvgContainer(t),d=Ont.getTargetId(this.target),p=u.querySelector(".border-highlighting-group"),f=p.querySelector(`[data-target-id="${d}"]`);f&&f.remove();const g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d",c),g.setAttribute("fill","none"),g.setAttribute("stroke-width",r),g.setAttribute("stroke-linejoin","round"),g.setAttribute("pointer-events","none"),g.setAttribute("data-target-id",d);const v=a||o||"rgba(0, 0, 0, 0.5)",m=u.querySelector("defs"),y=this.createFilter(d,v);if(m.appendChild(y),g.setAttribute("filter",`url(#${d}-filter)`),i){const t=u.querySelector("defs"),e=this.createGradient(d,n);t.appendChild(e),g.setAttribute("stroke",`url(#${d})`)}else g.setAttribute("stroke",n);return p.appendChild(g),g}createOffsetPath(t,e){const r=[],n=t.length;for(let i=0;i<n;i++){const a=t[(i-1+n)%n],s=t[i],o=t[(i+1)%n],l=s.x-a.x,h=s.y-a.y,c=o.x-s.x,u=o.y-s.y,d=this.normalize({x:h,y:-l}),p=this.normalize({x:u,y:-c}),f=this.normalize({x:(d.x+p.x)/2,y:(d.y+p.y)/2}),g={x:s.x+f.x*e,y:s.y+f.y*e};r.push(g)}return r}normalize(t){const e=Math.sqrt(t.x*t.x+t.y*t.y);return{x:t.x/e,y:t.y/e}}pointsToPathData(t,e=0){if(t.length<2)return"";let r="";const n=t.length,i=(t,e,r)=>{const n=e.x-t.x,i=e.y-t.y,a=Math.sqrt(n*n+i*i);return{x:t.x+n/a*r,y:t.y+i/a*r}};for(let a=0;a<n;a++){const s=t[a],o=t[(a+1)%n],l=t[(a-1+n)%n],h=Math.sqrt((s.x-l.x)**2+(s.y-l.y)**2),c=Math.sqrt((s.x-o.x)**2+(s.y-o.y)**2),u=Math.min(e,h/2,c/2),d=i(s,l,u),p=i(s,o,u);r+=0===a?`M${d.x},${d.y}`:` L${d.x},${d.y}`,r+=` Q${s.x},${s.y} ${p.x},${p.y}`}return r+=" Z",r}createFilter(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","filter");r.setAttribute("id",`${t}-filter`);const n=document.createElementNS("http://www.w3.org/2000/svg","feFlood");n.setAttribute("flood-color",e),n.setAttribute("result","flood");const i=document.createElementNS("http://www.w3.org/2000/svg","feComposite");i.setAttribute("in","flood"),i.setAttribute("in2","SourceAlpha"),i.setAttribute("operator","in"),i.setAttribute("result","mask");const a=document.createElementNS("http://www.w3.org/2000/svg","feMerge"),s=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");s.setAttribute("in","mask");const o=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");return o.setAttribute("in","SourceGraphic"),a.appendChild(s),a.appendChild(o),r.appendChild(n),r.appendChild(i),r.appendChild(a),r}createGradient(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");r.setAttribute("id",t),r.setAttribute("x1","0%"),r.setAttribute("y1","0%"),r.setAttribute("x2","100%"),r.setAttribute("y2","0%");const n=this.alterColor(e,120),i=this.alterColor(e,240);return r.innerHTML=`\n <stop offset="0%" stop-color="${e}">\n <animate attributeName="stop-color" values="${e};${n};${i};${e}" dur="5s" repeatCount="indefinite" />\n </stop>\n <stop offset="100%" stop-color="${i}">\n <animate attributeName="stop-color" values="${i};${e};${n};${i}" dur="5s" repeatCount="indefinite" />\n </stop>\n `,r}alterColor(t,e){const r=this.convertToHex(t);let n=parseInt(r.substring(1,3),16),i=parseInt(r.substring(3,5),16),a=parseInt(r.substring(5,7),16);const s=this.rgbToHsl(n,i,a);s[0]=(s[0]+e/360)%1;const o=this.hslToRgb(s[0],s[1],s[2]);return`#${o[0].toString(16).padStart(2,"0")}${o[1].toString(16).padStart(2,"0")}${o[2].toString(16).padStart(2,"0")}`}rgbToHsl(t,e,r){t/=255,e/=255,r/=255;let n,i,a=Math.max(t,e,r),s=Math.min(t,e,r),o=(a+s)/2;if(a===s)n=i=0;else{let l=a-s;switch(i=o>.5?l/(2-a-s):l/(a+s),a){case t:n=(e-r)/l+(e<r?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return[n,i,o]}hslToRgb(t,e,r){let n,i,a;if(0===e)n=i=a=r;else{const s=(t,e,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t);let o=r<.5?r*(1+e):r+e-r*e,l=2*r-o;n=s(l,o,t+1/3),i=s(l,o,t),a=s(l,o,t-1/3)}return[Math.round(255*n),Math.round(255*i),Math.round(255*a)]}convertToHex(t){if(/^#([0-9A-F]{6})$/i.test(t))return t;const e=document.createElement("div");e.style.color=t,document.body.appendChild(e);const r=window.getComputedStyle(e).color;document.body.removeChild(e);const n=r.match(/\d+/g);return!n||n.length<3?(console.warn(`Invalid color: ${t}. Defaulting to #FF0000.`),"#FF0000"):`#${n.slice(0,3).map((t=>parseInt(t,10).toString(16).padStart(2,"0"))).join("")}`}start(){const t=this.overlayRef.deref();if(!t)return;const e=Ont.getSvgContainer(t);t.contains(e)||t.appendChild(e);const r=this.element;if(r&&this.decorator.animation){const t=r.getAttribute("data-target-id");if(!t)return;const n=e.querySelector("defs");if(!n)return;const i=n.querySelector(`#${t}`);if(!i)return;requestAnimationFrame((()=>{i.querySelectorAll("animate").forEach((t=>{t.beginElement()}))}))}}stop(){if(!this.element)return;const t=this.overlayRef.deref();if(!t)return;const e=Ont._svgMap.get(t);if(!e)return;const r=e.querySelector(".border-highlighting-group");if(!r)return;const n=e.querySelector("defs");if(!n)return;const i=Ont.getTargetId(this.target),a=r.querySelector(`[data-target-id="${i}"]`);if(a){r.removeChild(a),a.remove();const t=n.querySelector(`#${i}`);t&&(n.removeChild(t),t.remove())}Ont._targetIdMap.delete(this.target),0===r.children.length&&(e.remove(),Ont._svgMap.delete(t))}}Tnt(Ont,"_svgMap",new WeakMap),Tnt(Ont,"_targetIdMap",new WeakMap);class Lnt{static getArrowId(t){if(!Lnt._arrowIdMap.has(t)){const e=`${Math.random().toString(36).substring(2,9)}`;Lnt._arrowIdMap.set(t,e)}return Lnt._arrowIdMap.get(t)}static getSvgContainer(t){if(!Lnt._svgMap.has(t)){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","bouncing-arrow-container"),e.setAttribute("pointer-events","none"),e.style.overflow="visible",e.style.position="absolute",e.style.top="0",e.style.left="0";const r=document.createElementNS("http://www.w3.org/2000/svg","g");r.setAttribute("class","bouncing-arrow-group"),e.appendChild(r),t.appendChild(e),Lnt._svgMap.set(t,e)}return Lnt._svgMap.get(t)}constructor(t,e,r){this.overlayRef=new WeakRef(t),this.target=e,this.decorator=r}get element(){const t=this.overlayRef.deref();if(!t)return null;const e=Lnt.getSvgContainer(t).querySelector(".bouncing-arrow-group"),r=Lnt.getArrowId(this.target),n=e.querySelector(`[data-arrow-id="${r}"]`);n&&n.remove();let{left:i,top:a,width:s}=this.target.bounds,{x:o,y:l}=this.target.transcoordS2T(i+s/2,a);o=Math.max(o,20),l=Math.max(l,20);const{color:h="red",duration:c=5e3,repeat:u=!0}=this.decorator||{},d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("d",this.createArrowPath(o,l)),d.setAttribute("fill",h),d.setAttribute("data-arrow-id",r),d.appendChild(this.createBounceAnimation(r,c,u)),e.appendChild(d);const p=this.createArrowLabel(o,l,h,this.target.state.id,r);return p&&(p.appendChild(this.createBounceAnimation(r,c,u)),e.appendChild(p)),d}createArrowPath(t,e){return`\n M${t-10},${e-16} \n L${t+10},${e-16} \n L${t+10},${e-8} \n L${t+16},${e-8} \n L${t},${e} \n L${t-16},${e-8} \n L${t-10},${e-8} \n Z\n `}createBounceAnimation(t,e,r){const n=document.createElementNS("http://www.w3.org/2000/svg","animateTransform");n.setAttribute("id",t),n.setAttribute("attributeName","transform"),n.setAttribute("type","translate");const i=e||5e3;let a=["0,-10"],s=[0];for(let t=1;t<=20;t++){const e=t/20;let r=Math.pow(e,.5);if(r=Math.min(r,.99).toFixed(3),parseFloat(s[s.length-1])>=parseFloat(r)&&(r=(parseFloat(s[s.length-1])+.01).toFixed(3)),a.push("0,0"),a.push("0,-10"),r>=1){s.push(1),s.push((parseFloat(1)+.01).toFixed(3));break}s.push(r),s.push((parseFloat(r)+.01).toFixed(3))}return s[s.length-1]="1.000",n.setAttribute("values",a.join(";")),n.setAttribute("keyTimes",s.join(";")),n.setAttribute("dur",`${i}ms`),r?n.setAttribute("repeatCount","indefinite"):(n.setAttribute("repeatCount","1"),n.addEventListener("endEvent",(()=>this.stop()))),n}createArrowLabel(t,e,r,n,i){if(!n)return null;const a=document.createElementNS("http://www.w3.org/2000/svg","g");a.setAttribute("data-arrow-label",i);const s=document.createElementNS("http://www.w3.org/2000/svg","rect");s.setAttribute("x",t+20),s.setAttribute("y",e-20),s.setAttribute("width","40"),s.setAttribute("height","20"),s.setAttribute("rx","3"),s.setAttribute("fill",r);const o=document.createElementNS("http://www.w3.org/2000/svg","text");return o.setAttribute("x",t+40),o.setAttribute("y",e-6),o.setAttribute("fill","white"),o.setAttribute("font-size","12px"),o.setAttribute("text-anchor","middle"),o.textContent=n,a.appendChild(s),a.appendChild(o),a}start(){const t=this.overlayRef.deref();if(!t)return;const e=Lnt.getSvgContainer(t),r=this.element;if(!r)return;const n=r.querySelector("animateTransform");n&&n.beginElement();const i=e.querySelector(`[data-arrow-label="${Lnt.getArrowId(this.target)}"]`);if(i){const t=i.querySelector("animateTransform");t&&t.beginElement()}}stop(){const t=this.overlayRef.deref();if(!t)return;const e=Lnt._svgMap.get(t);if(!e)return;const r=e.querySelector(".bouncing-arrow-group");if(!r)return;const n=Lnt.getArrowId(this.target),i=r.querySelector(`[data-arrow-id="${n}"]`),a=r.querySelector(`[data-arrow-label="${n}"]`);i&&(r.removeChild(i),i.remove()),a&&(r.removeChild(a),a.remove()),0===r.children.length&&(e.remove(),Lnt._svgMap.delete(t))}}Tnt(Lnt,"_svgMap",new WeakMap),Tnt(Lnt,"_arrowIdMap",new WeakMap);class Dnt{icon(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new Rnt(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}border(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new Ont(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}bouncing(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new Lnt(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}off(t){if(!this.targets)return;let e=this.targets.slice(),r=this.animators.slice(),n=this.targets.lastIndexOf(t);if(-1==n)return;e.splice(n,1);const i=r.splice(n,1);i[0]?.stop(),this.targets=e,this.animators=r}reset(t){this.animators?.forEach((t=>t.stop())),this.targets=[],this.animators=[]}}function Fnt(t){const{origin:e}=t,r=e.root,{animatorHandler:n}=r;n?.reset()}hnt.register("animator-handler",{"model-layer":{"(descendant)":{icon:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new Dnt,n.animatorHandler=i),i.icon(r,t)},border:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new Dnt,n.animatorHandler=i),i.border(r,t)},bouncing:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new Dnt,n.animatorHandler=i),i.bouncing(r,t)},animatoroff:function(t){const{origin:e}=t,r=e.root,{animatorHandler:n}=r;n?n.off(e):console.warn("animator-handler not found")},animatorreset:Fnt},"(self)":{animatorreset:Fnt}}},(function(t){const{animatorHandler:e}=t;e?.reset(),delete t.animatorHandler}));var Nnt=[],jnt=x7((function(){Nnt.forEach((t=>{t.resize()}))}),100);"undefined"!=typeof window&&window.addEventListener("resize",jnt);class Bnt extends Gtt{constructor(t,e){super(Object.assign({type:"root",scale:{x:1,y:1}},t||{}),e),this._maxRefid=e.isViewMode?1e6:0,t=t||{},this.fitMode=t.model&&t.model.fitMode,this._app=e,this.style=t.style,this.target_element=t.target_element,this.rebuildContentModel(this.model.model),Nnt.push(this)}dispose(){Rtt.hideAll(this),this._app&&this._app.dispose(),super.dispose(),this._disposeAllResources(),this.target_element=null,delete this._refresh_mapping_debouncer;var t=Nnt.indexOf(this);t>=0&&Nnt.splice(t,1),this.refidIndexMap.clear(),this._maxRefid=0}isRoot(){return!0}get app(){return this._app}get target_element(){return this._target_element}set target_element(t){this._ua_event_handler&&(this._ua_event_handler.dispose(),delete this._ua_event_handler),t&&(t.setAttribute("root-element",""),t.style.position="absolute",t.style.cursor="default",t.style.overflow="hidden",this._ua_event_handler=new nnt(this,t)),this.forEach((e=>e.target=t)),this._target_element=t}get unitScale(){switch(this.model_layer&&this.model_layer.get("unit")){case"mm":case"cm":case"in":return this.app.PPM/10;default:return 1}}addTemplate(t,e){var r=this.templateMap[t];r&&U7("Template replaced (duplicated)",t,e,r),this.templateMap[t]=e,delete this.templatePrefixes}removeTemplate(t,e){var r=this.templateMap[t];r!==e?H7("Removing template failed (different)",t,e,r):delete this.templateMap[t],delete this.templatePrefixes}findTemplateFor(t){this.templatePrefixes||(this.templatePrefixes=Object.keys(this.templateMap).sort().reverse());var e=this.templatePrefixes.find((e=>t.startsWith(e)));if(e)return this.templateMap[e]}addIndex(t,e){var r=this.indexMap[t]||[];this.indexMap[t]=[...r,e]}removeIndex(t,e){const r=this.indexMap[t]||[],n=r.indexOf(e);-1==n?H7("Removing index failed (not found)",t,e):(r.splice(n,1),0==r.length&&delete this.indexMap[t])}addRefidIndex(t,e){null==t&&(t=this.getNewRefid(),e.set("refid",t)),this._maxRefid=Math.max(t,this._maxRefid);var r=this.refidIndexMap.get(t);r&&U7("Refid Index replaced (has not to be)",t,e,r),this.refidIndexMap.set(t,e)}removeRefidIndex(t,e){if(null!=t){var r=this.refidIndexMap.get(t);r!==e?U7("Refid Removing index failed (has not to be)",t,e,r):this.refidIndexMap.delete(t)}}getNewRefid(){return this._maxRefid=(this._maxRefid||0)+1,this._maxRefid}async subscribe(t,e){this._app.isViewMode&&t&&this._app&&(e._subscription=await this._app.subscribe(t,e))}async unsubscribe(t,e){e._subscription&&(await e._subscription.unsubscribe(),delete e._subscription)}findById(t){return(this.indexMap[t.replace(/^#/,"")]||[])[0]}findAllById(t){return this.indexMap[t.replace(/^#/,"")]||[]}findByRefid(t){return this.refidIndexMap.get(t)}findOrCreate(t){var e=this.findAllById(t);if(!e&&this.app&&!this.app.isEditMode){let e=this.findTemplateFor(t);if(e){let r=Object.assign(h7(e.hierarchy),{id:t,templatePrefix:""});return component=Ret(r,this.app),this.model_layer.addComponent(component),[component]}}return e}resize(){this.components.forEach((t=>{t.resize&&t.resize()})),this.invalidate()}_disposeAllResources(){this.selected=[],this._focused=null,this._ready=!1,this.eventEngine&&(this.assist_handlers&&this.assist_handlers.forEach((t=>{this.eventEngine.remove(t)})),this.eventEngine.dispose(),delete this.eventEngine),(this.model.handlers||[]).map((t=>{hnt.getDisposer(t).call(null,this)})),this.assist_layers&&this.assist_layers.forEach((t=>{t.dispose(),this.removeComponent(t)})),delete this.assist_layers,this.model_layer&&this.model_layer.dispose(),this.model_layer&&this.removeComponent(this.model_layer),delete this.model_layer,this.indexMap={},this.refidIndexMap=new Map,this.templateMap={}}rebuildContentModel(t){this._disposeAllResources(),this.eventEngine=new Yrt(this),(t=t||{}).type="model-layer",this.model_layer=Ret(t,this.app),this.addComponent(this.model_layer),this.model_layer.target=this.target_element,this.assist_layers=(this.model.layers||[]).map((t=>{var e=Ret(t,this.app);return this.addComponent(e),e.target=this.target_element,e})),this.assist_handlers=(this.model.handlers||[]).map((t=>{var e={};return this.eventEngine.add(e,hnt.get(t)),e})),this._ready=!0,this.traverse((t=>t.ready()))}get root(){return this}get anchors(){}get isReady(){return this._ready}get rootModel(){return this.model_layer}get stuck(){return!0}get data(){return Object.values(this.indexMap).reduce(((t,[e])=>(t[e.model.id]=e.data,t)),{})}set data(t){for(var e in t){var r=this.findOrCreate(e);r&&r.forEach((r=>r.data=t[e]))}}get dataByRefid(){var t={};for(let[e,r]of this.refidIndexMap.entries())t[e]=r.data;return t}set dataByRefid(t){for(var e in t){var r=this.findByRefid(Number(e));r&&(r.data=t[e])}}get values(){return Object.values(this.indexMap).reduce(((t,[e])=>(t[e.model.id]=e.value,t)),{})}set values(t){for(var e in t){var r=this.findOrCreate(e);r&&r.forEach((r=>r.value=t[e]))}}get valuesByRefid(){var t={};for(let[e,r]of this.refidIndexMap.entries())t[e]=r.value;return t}set valuesByRefid(t){for(var e in t){var r=this.findByRefid(Number(e));r&&(r.value=t[e])}}get selected(){return(this._selected||[]).filter((t=>t.parent))}set selected(t){var e=this._selected;if(this._selected=t,!t||t.length<=1)this.hasSameParentForAllSelected=!0;else{let e=t[0].parent;this.hasSameParentForAllSelected=!t.find((t=>t.parent!=e))}this.trigger("selected",t,e)}get focused(){return this._focused}set focused(t){this._focused!==t&&(this._focused=t,this.invalidate())}get style(){return this._style}set style(t){this._style=t,this._compiled_style=t}get hasTextProperty(){return!1}render(){this.components.forEach((t=>t.draw()))}contains(t,e){return!0}capturePath(t,e){return this.model_layer.capturePath(t,e)}invalidate(){this.components.forEach((t=>t.invalidate()))}get eventMap(){return{"(root)":{"(descendant)":{added:this.onadded,removed:this.onremoved,change:this.onchanged}}}}refreshMappings(){if(!this._refresh_mapping_debouncer){if(this.disposed)return;this._refresh_mapping_debouncer=x7((function t(e){e.executeMappings(),e.components&&e.components.forEach((e=>t(e)))}),1e3)}this._refresh_mapping_debouncer(this.model_layer)}_addTraverse(t){t.components&&t.components.forEach((t=>this._addTraverse(t)));var{id:e,refid:r,tag:n,templatePrefix:i}=t.model;this.addRefidIndex(r,t),e&&this.addIndex(e,t),n&&this.subscribe(n,t),i&&this.addTemplate(i,t);var a=C7({},t.eventMap,t.model.eventMap);this.eventEngine.add(t,a)}_removeTraverse(t){t.components&&t.components.forEach((t=>this._removeTraverse(t)));var{id:e,refid:r,tag:n,templatePrefix:i}=t.model;this.removeRefidIndex(r,t),e&&this.removeIndex(e,t),n&&this.unsubscribe(n,t),i&&this.removeTemplate(i,t),this.eventEngine.remove(t)}onadded(t,e){this._addTraverse(e),this.refreshMappings(),this.invalidate()}onremoved(t,e){this._removeTraverse(e),this.invalidate()}onchanged(t,e,r){e.templatePrefix&&this.removeTemplate(e.templatePrefix,r.origin),t.templatePrefix&&this.addTemplate(t.templatePrefix,r.origin),e.id&&this.removeIndex(e.id,r.origin),t.id&&this.addIndex(t.id,r.origin),e.tag&&this.unsubscribe(e.tag,r.origin),t.tag&&this.subscribe(t.tag,r.origin),e.id==t.id&&e.class==t.class||this.refreshMappings()}}Object.assign(Bnt.prototype,{fit:function(t){var{width:e,height:r,fitMode:n}=this.model_layer.model,i=this.target_element,a=this.model_layer;if(this.fitMode=t||this.fitMode||n||"ratio",e&&r&&i&&i.clientWidth&&i.clientHeight){switch(this.fitMode){case"center":!function(t,e,r){var n=t.unitScale,{width:i,height:a}=e.model;e.set("scale",{x:n,y:n}),e.set("translate",{x:Math.max((r.clientWidth-i*n)/2,0),y:Math.max((r.clientHeight-a*n)/2,0)})}(this,a,i);break;case"both":!function(t,e,r){var{width:n,height:i}=e.model,a=r.clientWidth,s=r.clientHeight;e.set("scale",{x:a/n,y:s/i}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"width":!function(t,e,r){var n=r.clientWidth/e.get("width");e.set("scale",{x:n,y:n}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"height":!function(t,e,r){var n=r.clientHeight/e.get("height");e.set("scale",{x:n,y:n}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"ratio":!function(t,e,r){var{width:n,height:i}=e.model,a=r.clientWidth,s=r.clientHeight,o=a/n,l=s/i,h=Math.min(o,l);e.set("scale",{x:h,y:h}),e.set("translate",{x:(a-n*h)/2,y:(s-i*h)/2})}(0,a,i);break;default:!function(t,e){var r=t.unitScale;e.set("scale",{x:r,y:r}),e.set("translate",{x:0,y:0})}(this,a)}this.resize()}}}),mtt.memoize(Bnt.prototype,"unitScale",!1);var znt=13.3,Wnt=function(t){return void 0!==t&&(znt=t),znt};const Unt="$base_url";const Hnt=Math.PI/12;class Gnt{constructor(t,e){this._mode=t,this.screen=Wnt(),this._baseUrl="undefined"!=typeof window?window.location.origin:null,this._refProvider=e,this.isEditMode&&(this._rotateStep=Hnt,this._rotateStepForced=!1)}dispose(){this._dataSubscriptionProvider&&this._dataSubscriptionProvider.dispose(),delete this._dataStorage}_calcScreen(){var t={width:screen.width,height:screen.height};this._PPI=function(t,e,r,n){t>0||(t=1),e>0||(e=1),n||(n="d");var i=("d"==n?Math.sqrt(t*t+e*e):"w"==n?t:e)/r;return i>0?Math.round(i):0}(t.width,t.height,this.screen),this._PPM=this._PPI/25.4}subscribe(t,e){return this._dataSubscriptionProvider?.subscribe(t,e)}get refProvider(){return this._refProvider}set dataSubscriptionProvider(t){this._dataSubscriptionProvider=t}get dataSubscriptionProvider(){return this._dataSubscriptionProvider}set commander(t){this._commander=t}get commander(){return this._commander}get screen(){return this._screen}set screen(t){this._screen=t,this._calcScreen()}get DPPX(){return e9}get PPI(){return this._PPI}get PPM(){return this._PPM}get mode(){return this._mode}set mode(t){var e=this._mode;e!==t&&(this._mode=t,this.trigger("mode",t,e))}get isViewMode(){return 0==this._mode}get isEditMode(){return 1==this._mode}get baseUrl(){return this._baseUrl}set baseUrl(t){t&&this._baseUrl!=t&&(this._baseUrl=t)}url(t){try{return(t.includes(Unt)?new URL(t.replace(Unt,this.baseUrl),this.baseUrl):new URL(t,location.origin)).href}catch(e){H7(e,t)}}get rotateStep(){return this._rotateStep}set rotateStep(t){this._rotateStep=Number(t)||Hnt}get rotateStepForced(){return this._rotateStepForced}set rotateStepForced(t){this._rotateStepForced=!!t}get dataStorage(){return this._dataStorage}set dataStorage(t){this._dataStorage=t}}W7(Gnt.prototype,F7.withEvent);class Ynt{constructor(t,e){!(t=Number(t))||t<=0?(U7("TimeCapsule maxsize should be greater than 0.",t),this.maxsize=10):this.maxsize=t,this.reset(),e&&(this.snapshot(e),this.preserve())}preserve(){this.checkPoint=this.pos}hasUnpreservedChanges(){return this.checkPoint!=this.pos}dispose(){this.reset()}snapshot(t){if(this.q.splice(this.pos+1,this.q.length-(this.pos+1),t),this.q.length>this.maxsize){const t=this.q.splice(0,this.q.length-this.maxsize);this.checkPoint=Math.max(-1,this.checkPoint-t.length)}this.pos=this.q.length-1}forward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.forwardable)return this.q[++this.pos];H7("Not forwardable.")}backward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.backwardable)return this.q[--this.pos];H7("Not backwardable.")}get current(){if(-1!==this.pos)return this.q[this.pos];H7("Non state has been recorded.")}get length(){return this.q.length}get forwardable(){return this.pos<this.q.length-1}get backwardable(){return this.pos>0}get snapshot_taker(){return this._snapshot_taker}set snapshot_taker(t){this._snapshot_taker=t}reset(){this.q=[],this.pos=-1,this.checkPoint=-1}}var Vnt=x7((t=>{t.brake||t.take()}),1e3,{leading:!0,trailing:!1});function qnt(t){!t.brake&&t.dirty&&Vnt(t)}class Xnt{constructor(t,e){this.brake=!1,this.dirty=!1,this.state_holder=t,this.timecapsule=e,this.timecapsule.snapshot_taker=this}dispose(){delete this.state_holder,delete this.timecapsule}touch(){this.dirty=!0,qnt(this)}take(t){(this.dirty||t)&&(this.timecapsule.snapshot(this.state_holder.state),this.dirty=!1)}get brake(){return this._brake}set brake(t){this._brake=!!t,qnt(this)}}function $nt(t,e){var r=e.model_layer.get("scale"),n=e.model_layer.get("translate");if(t){let i=JSON.parse(t);i.scale=r,i.translate=n,e.rebuildContentModel(i)}}class Knt{constructor(t){this.container=t,this.timecapsule=new Ynt(20);var e=this;this.snapshot_taker=new Xnt({get state(){let t=e.container.model_layer.hierarchy;return JSON.stringify(t)}},this.timecapsule),this.snapshot_taker.take(!0),this.timecapsule.preserve()}dispose(){this.reset(),this.timecapsule&&this.timecapsule.dispose(),this.snapshot_taker&&this.snapshot_taker.dispose(),delete this.container,delete this.timecapsule,delete this.snapshot_taker}preserve(){this.timecapsule.preserve()}hasUnpreservedChanges(){return this.timecapsule.hasUnpreservedChanges()}execute(t,e){!1!==e&&t&&t.execute(),this.snapshot_taker.touch(),this.trigger("execute",t,!0,!1)}undo(){this.timecapsule.backwardable&&($nt(this.timecapsule.backward(),this.container),this.trigger("undo",this.undoable(),this.redoable()))}redo(){this.timecapsule.forwardable&&($nt(this.timecapsule.forward(),this.container),this.trigger("redo",this.undoable(),this.redoable()))}undoable(){return this.timecapsule.backwardable}redoable(){return this.timecapsule.forwardable}reset(){this.timecapsule&&this.timecapsule.reset(),this.trigger("command-reset")}}W7(Knt.prototype,F7.withEvent);var Qnt=0;const Jnt=new FinalizationRegistry((t=>{Qnt--}));class Znt{static get residents(){return Qnt}static get residentsCount(){return Qnt}constructor(t){this._container=t,this.app=t.app,this._commander=new Knt(this._container),this.app.commander=this._commander,Qnt++,Jnt.register(this,Qnt)}add(){return Det.apply(this._container,arguments)}duplicate(){return Fet.apply(this._container,arguments)}remove(){return Net.apply(this._container,arguments)}animate(){return D8.apply(this,arguments)}fullscreen(){return Wet.apply(this._container,arguments)}get target(){return this._container.target_element}set target(t){var e;if("string"==typeof t){if(!(e=document.getElementById(t)))throw`target element '${t}' is not exist`;if(e.firstChild)throw`target element '${t}' already has children`}else e=t;e&&e.style&&(e.style.cursor="default"),this._container.target_element=e,this._container.invalidate()}get scale(){return this.root.get("scale")}set scale(t){this.root.set("scale",t)}get translate(){return this.root.get("translate")}set translate(t){this.root.set("translate",t)}get unit(){return this.root.get("unit")||"px"}get PPM(){return this.app.PPM}get PPI(){return this.app.PPI}get DPPX(){return this.app.DPPX}static get DPPX(){return e9}get unitScale(){return this._container.unitScale}get screen(){return this.app.screen}set screen(t){this.app.screen=t,this._container.resize()}resize(){this._container.resize()}release(){this.dispose()}dispose(){this._commander&&this._commander.dispose(),this._container&&this._container.dispose()}get selected(){return this._container.selected.slice()}set selected(t){this._container.selected=t}select(t,...e){return this._container.selected=this.root?.findAll(t,...e),this.selected}get commander(){return this._commander}undo(){this.commander.undo()}undoable(){return this.commander.undoable()}redo(){this.commander.redo()}redoable(){return this.commander.redoable()}preserve(){this.commander.preserve()}hasUnpreservedChanges(){return this.commander.hasUnpreservedChanges()}cut(){return Get.apply(this._container,arguments)}copy(){return Het.apply(this._container,arguments)}paste(){return Yet.apply(this._container,arguments)}undoableChange(){return crt.apply(this._container,arguments)}change(){return hrt.apply(this.root,arguments)}get model(){return this.root.hierarchy}set model(t){this._container.rebuildContentModel(t)}get rootContainer(){return this._container}get root(){return this._container?.model_layer}findAll(){return this.root.findAll.apply(this.root,arguments)}findFirst(){return this.root.findFirst.apply(this.root,arguments)}findById(){return this._container.findById.apply(this._container,arguments)}findAllById(){return this._container.findAllById.apply(this._container,arguments)}serialize(){return this.root.trim(),this.root.serialize.apply(this.root,arguments)}align(){return _et.apply(this._container,arguments)}place(){return yrt.apply(this._container,arguments)}distribute(){return Met.apply(this._container,arguments)}move(){return Pet.apply(this._container,arguments)}zorder(){return Iet.apply(this._container,arguments)}symmetryX(){return ort.apply(this._container,arguments)}symmetryY(){return lrt.apply(this._container,arguments)}on(){return jet.apply(this._container,arguments)}once(){return Bet.apply(this._container,arguments)}off(){return this._container&&zet.apply(this._container,arguments)}centerTo(t,e){return this.root.centerTo(t,e)}get mode(){return this.app.mode}set mode(t){void 0!==t&&(this.app.mode=t)}toDataURL(){return rrt.apply(this._container,arguments)}group(){return nrt.apply(this._container,arguments)}ungroup(){return irt.apply(this._container,arguments)}fit(t){this._container.once("redraw",(()=>this._container.fit(t))),this._container.invalidate()}get fitMode(){return this._container.fitMode}get ids(){return urt.apply(this._container)}get data(){return this._container.data}set data(t){this._container.data=t}get dataByRefid(){return this._container.dataByRefid}set dataByRefid(t){this._container.dataByRefid=t}get values(){return this._container.values}set values(t){this._container.values=t}get valuesByRefid(){return this._container.valuesByRefid}set valuesByRefid(t){this._container.valuesByRefid=t}get baseUrl(){return this.app.baseUrl}set baseUrl(t){this.app.baseUrl=t}startAddMode(){return brt.apply(this._container,arguments)}startStylePasteMode(){return wrt.apply(this._container,arguments)}stopStylePasteMode(){return xrt.apply(this._container,arguments)}startDatabindPasteMode(){return Art.apply(this._container,arguments)}stopDatabindPasteMode(){return _rt.apply(this._container,arguments)}}const tit=new class{load(t){}save(t,e){}clear(t){}};function eit({target:t,model:e,style:r,layers:n=[],handlers:i=[],mode:a=0,refProvider:s,dataSubscriptionProvider:o,dataStorage:l=tit,baseUrl:h,fitMode:c}){var u=null;if("string"==typeof t){if(!(u=document.getElementById(t)))throw`target element '${t}' is not exist`;if(u.firstChild)throw`target element '${t}' is not empty`}else u=t;u&&u.style&&(u.style.position="absolute",u.style.cursor="default",u.style.overflow="hidden");var d=new Gnt(a,s);return d.baseUrl=h,d.dataSubscriptionProvider=o,d.dataStorage=l,new Znt(new Bnt({target_element:u,model:e,style:r,layers:n,handlers:i,fitMode:c},d))}
7
7
  /**
8
8
  * @license
9
9
  * Copyright 2019 Google LLC
10
10
  * SPDX-License-Identifier: BSD-3-Clause
11
- */var eit=globalThis,rit=eit.ShadowRoot&&(void 0===eit.ShadyCSS||eit.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,nit=Symbol(),iit=new WeakMap;class ait{constructor(t,e,r){if(this._$cssResult$=!0,r!==nit)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){var t=this.o,e=this.t;if(rit&&void 0===t){var r=void 0!==e&&1===e.length;r&&(t=iit.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&iit.set(e,t))}return t}toString(){return this.cssText}}var sit,oit,lit,hit,cit=rit?t=>t:t=>t instanceof CSSStyleSheet?(t=>{var e="";for(var r of t.cssRules)e+=r.cssText;return(t=>new ait("string"==typeof t?t:t+"",void 0,nit))(e)})(t):t,{is:uit,defineProperty:dit,getOwnPropertyDescriptor:pit,getOwnPropertyNames:fit,getOwnPropertySymbols:git,getPrototypeOf:vit}=Object,mit=globalThis,yit=mit.trustedTypes,bit=yit?yit.emptyScript:"",wit=mit.reactiveElementPolyfillSupport,xit=(t,e)=>t,Ait={toAttribute(t,e){switch(e){case Boolean:t=t?bit:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){var r=t;switch(e){case Boolean:r=null!==t;break;case Number:r=null===t?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch(t){r=null}}return r}},_it=(t,e)=>!uit(t,e),kit={attribute:!0,type:String,converter:Ait,reflect:!1,hasChanged:_it};null!==(sit=Symbol.metadata)&&void 0!==sit||(Symbol.metadata=Symbol("metadata")),null!==(oit=mit.litPropertyMetadata)&&void 0!==oit||(mit.litPropertyMetadata=new WeakMap);class Sit extends HTMLElement{static addInitializer(t){var e;this._$Ei(),(null!==(e=this.l)&&void 0!==e?e:this.l=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:kit;if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){var r=Symbol(),n=this.getPropertyDescriptor(t,r,e);void 0!==n&&dit(this.prototype,t,n)}}static getPropertyDescriptor(t,e,r){var n,{get:i,set:a}=null!==(n=pit(this.prototype,t))&&void 0!==n?n:{get(){return this[e]},set(t){this[e]=t}};return{get(){return null==i?void 0:i.call(this)},set(e){var n=null==i?void 0:i.call(this);a.call(this,e),this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){var e;return null!==(e=this.elementProperties.get(t))&&void 0!==e?e:kit}static _$Ei(){if(!this.hasOwnProperty(xit("elementProperties"))){var t=vit(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}}static finalize(){if(!this.hasOwnProperty(xit("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(xit("properties"))){var t=this.properties,e=[...fit(t),...git(t)];for(var r of e)this.createProperty(r,t[r])}var n=this[Symbol.metadata];if(null!==n){var i=litPropertyMetadata.get(n);if(void 0!==i)for(var[a,s]of i)this.elementProperties.set(a,s)}for(var[o,l]of(this._$Eh=new Map,this.elementProperties)){var h=this._$Eu(o,l);void 0!==h&&this._$Eh.set(h,o)}this.elementStyles=this.finalizeStyles(this.styles)}}static finalizeStyles(t){var e=[];if(Array.isArray(t)){var r=new Set(t.flat(1/0).reverse());for(var n of r)e.unshift(cit(n))}else void 0!==t&&e.push(cit(t));return e}static _$Eu(t,e){var r=e.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,r;(null!==(e=this._$EO)&&void 0!==e?e:this._$EO=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&(null===(r=t.hostConnected)||void 0===r||r.call(t))}removeController(t){var e;null===(e=this._$EO)||void 0===e||e.delete(t)}_$E_(){var t=new Map,e=this.constructor.elementProperties;for(var r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){var t,e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(rit)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(var r of e){var n=document.createElement("style"),i=eit.litNonce;void 0!==i&&n.setAttribute("nonce",i),n.textContent=r.cssText,t.appendChild(n)}})(e,this.constructor.elementStyles),e}connectedCallback(){var t,e;null!==(t=this.renderRoot)&&void 0!==t||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$EO)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$EO)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$EC(t,e){var r=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,r);if(void 0!==n&&!0===r.reflect){var i,a=(void 0!==(null===(i=r.converter)||void 0===i?void 0:i.toAttribute)?r.converter:Ait).toAttribute(e,r.type);this._$Em=t,null==a?this.removeAttribute(n):this.setAttribute(n,a),this._$Em=null}}_$AK(t,e){var r=this.constructor,n=r._$Eh.get(t);if(void 0!==n&&this._$Em!==n){var i,a=r.getPropertyOptions(n),s="function"==typeof a.converter?{fromAttribute:a.converter}:void 0!==(null===(i=a.converter)||void 0===i?void 0:i.fromAttribute)?a.converter:Ait;this._$Em=n,this[n]=s.fromAttribute(e,a.type),this._$Em=null}}requestUpdate(t,e,r){if(void 0!==t){var n;if(null!=r||(r=this.constructor.getPropertyOptions(t)),!(null!==(n=r.hasChanged)&&void 0!==n?n:_it)(this[t],e))return;this.P(t,e,r)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,e,r){var n;this._$AL.has(t)||this._$AL.set(t,e),!0===r.reflect&&this._$Em!==t&&(null!==(n=this._$Ej)&&void 0!==n?n:this._$Ej=new Set).add(t)}_$ET(){var t=this;return xnt((function*(){t.isUpdatePending=!0;try{yield t._$ES}catch(e){Promise.reject(e)}var e=t.scheduleUpdate();return null!=e&&(yield e),!t.isUpdatePending}))()}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(this.isUpdatePending){if(!this.hasUpdated){var t;if(null!==(t=this.renderRoot)&&void 0!==t||(this.renderRoot=this.createRenderRoot()),this._$Ep){for(var[e,r]of this._$Ep)this[e]=r;this._$Ep=void 0}var n=this.constructor.elementProperties;if(n.size>0)for(var[i,a]of n)!0!==a.wrapped||this._$AL.has(i)||void 0===this[i]||this.P(i,this[i],a)}var s=!1,o=this._$AL;try{var l;(s=this.shouldUpdate(o))?(this.willUpdate(o),null!==(l=this._$EO)&&void 0!==l&&l.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(o)):this._$EU()}catch(o){throw s=!1,this._$EU(),o}s&&this._$AE(o)}}willUpdate(t){}_$AE(t){var e;null!==(e=this._$EO)&&void 0!==e&&e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach((t=>this._$EC(t,this[t])))),this._$EU()}updated(t){}firstUpdated(t){}}Sit.elementStyles=[],Sit.shadowRootOptions={mode:"open"},Sit[xit("elementProperties")]=new Map,Sit[xit("finalized")]=new Map,null!=wit&&wit({ReactiveElement:Sit}),(null!==(lit=mit.reactiveElementVersions)&&void 0!==lit?lit:mit.reactiveElementVersions=[]).push("2.0.4");
11
+ */var rit=globalThis,nit=rit.ShadowRoot&&(void 0===rit.ShadyCSS||rit.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,iit=Symbol(),ait=new WeakMap;class sit{constructor(t,e,r){if(this._$cssResult$=!0,r!==iit)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){var t=this.o,e=this.t;if(nit&&void 0===t){var r=void 0!==e&&1===e.length;r&&(t=ait.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&ait.set(e,t))}return t}toString(){return this.cssText}}var oit,lit,hit,cit,uit=nit?t=>t:t=>t instanceof CSSStyleSheet?(t=>{var e="";for(var r of t.cssRules)e+=r.cssText;return(t=>new sit("string"==typeof t?t:t+"",void 0,iit))(e)})(t):t,{is:dit,defineProperty:pit,getOwnPropertyDescriptor:fit,getOwnPropertyNames:git,getOwnPropertySymbols:vit,getPrototypeOf:mit}=Object,yit=globalThis,bit=yit.trustedTypes,wit=bit?bit.emptyScript:"",xit=yit.reactiveElementPolyfillSupport,Ait=(t,e)=>t,_it={toAttribute(t,e){switch(e){case Boolean:t=t?wit:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){var r=t;switch(e){case Boolean:r=null!==t;break;case Number:r=null===t?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch(t){r=null}}return r}},kit=(t,e)=>!dit(t,e),Sit={attribute:!0,type:String,converter:_it,reflect:!1,hasChanged:kit};null!==(oit=Symbol.metadata)&&void 0!==oit||(Symbol.metadata=Symbol("metadata")),null!==(lit=yit.litPropertyMetadata)&&void 0!==lit||(yit.litPropertyMetadata=new WeakMap);class Eit extends HTMLElement{static addInitializer(t){var e;this._$Ei(),(null!==(e=this.l)&&void 0!==e?e:this.l=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Sit;if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){var r=Symbol(),n=this.getPropertyDescriptor(t,r,e);void 0!==n&&pit(this.prototype,t,n)}}static getPropertyDescriptor(t,e,r){var n,{get:i,set:a}=null!==(n=fit(this.prototype,t))&&void 0!==n?n:{get(){return this[e]},set(t){this[e]=t}};return{get(){return null==i?void 0:i.call(this)},set(e){var n=null==i?void 0:i.call(this);a.call(this,e),this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){var e;return null!==(e=this.elementProperties.get(t))&&void 0!==e?e:Sit}static _$Ei(){if(!this.hasOwnProperty(Ait("elementProperties"))){var t=mit(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}}static finalize(){if(!this.hasOwnProperty(Ait("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ait("properties"))){var t=this.properties,e=[...git(t),...vit(t)];for(var r of e)this.createProperty(r,t[r])}var n=this[Symbol.metadata];if(null!==n){var i=litPropertyMetadata.get(n);if(void 0!==i)for(var[a,s]of i)this.elementProperties.set(a,s)}for(var[o,l]of(this._$Eh=new Map,this.elementProperties)){var h=this._$Eu(o,l);void 0!==h&&this._$Eh.set(h,o)}this.elementStyles=this.finalizeStyles(this.styles)}}static finalizeStyles(t){var e=[];if(Array.isArray(t)){var r=new Set(t.flat(1/0).reverse());for(var n of r)e.unshift(uit(n))}else void 0!==t&&e.push(uit(t));return e}static _$Eu(t,e){var r=e.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,r;(null!==(e=this._$EO)&&void 0!==e?e:this._$EO=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&(null===(r=t.hostConnected)||void 0===r||r.call(t))}removeController(t){var e;null===(e=this._$EO)||void 0===e||e.delete(t)}_$E_(){var t=new Map,e=this.constructor.elementProperties;for(var r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){var t,e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(nit)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(var r of e){var n=document.createElement("style"),i=rit.litNonce;void 0!==i&&n.setAttribute("nonce",i),n.textContent=r.cssText,t.appendChild(n)}})(e,this.constructor.elementStyles),e}connectedCallback(){var t,e;null!==(t=this.renderRoot)&&void 0!==t||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$EO)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$EO)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$EC(t,e){var r=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,r);if(void 0!==n&&!0===r.reflect){var i,a=(void 0!==(null===(i=r.converter)||void 0===i?void 0:i.toAttribute)?r.converter:_it).toAttribute(e,r.type);this._$Em=t,null==a?this.removeAttribute(n):this.setAttribute(n,a),this._$Em=null}}_$AK(t,e){var r=this.constructor,n=r._$Eh.get(t);if(void 0!==n&&this._$Em!==n){var i,a=r.getPropertyOptions(n),s="function"==typeof a.converter?{fromAttribute:a.converter}:void 0!==(null===(i=a.converter)||void 0===i?void 0:i.fromAttribute)?a.converter:_it;this._$Em=n,this[n]=s.fromAttribute(e,a.type),this._$Em=null}}requestUpdate(t,e,r){if(void 0!==t){var n;if(null!=r||(r=this.constructor.getPropertyOptions(t)),!(null!==(n=r.hasChanged)&&void 0!==n?n:kit)(this[t],e))return;this.P(t,e,r)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,e,r){var n;this._$AL.has(t)||this._$AL.set(t,e),!0===r.reflect&&this._$Em!==t&&(null!==(n=this._$Ej)&&void 0!==n?n:this._$Ej=new Set).add(t)}_$ET(){var t=this;return xnt((function*(){t.isUpdatePending=!0;try{yield t._$ES}catch(e){Promise.reject(e)}var e=t.scheduleUpdate();return null!=e&&(yield e),!t.isUpdatePending}))()}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(this.isUpdatePending){if(!this.hasUpdated){var t;if(null!==(t=this.renderRoot)&&void 0!==t||(this.renderRoot=this.createRenderRoot()),this._$Ep){for(var[e,r]of this._$Ep)this[e]=r;this._$Ep=void 0}var n=this.constructor.elementProperties;if(n.size>0)for(var[i,a]of n)!0!==a.wrapped||this._$AL.has(i)||void 0===this[i]||this.P(i,this[i],a)}var s=!1,o=this._$AL;try{var l;(s=this.shouldUpdate(o))?(this.willUpdate(o),null!==(l=this._$EO)&&void 0!==l&&l.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(o)):this._$EU()}catch(o){throw s=!1,this._$EU(),o}s&&this._$AE(o)}}willUpdate(t){}_$AE(t){var e;null!==(e=this._$EO)&&void 0!==e&&e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach((t=>this._$EC(t,this[t])))),this._$EU()}updated(t){}firstUpdated(t){}}Eit.elementStyles=[],Eit.shadowRootOptions={mode:"open"},Eit[Ait("elementProperties")]=new Map,Eit[Ait("finalized")]=new Map,null!=xit&&xit({ReactiveElement:Eit}),(null!==(hit=yit.reactiveElementVersions)&&void 0!==hit?hit:yit.reactiveElementVersions=[]).push("2.0.4");
12
12
  /**
13
13
  * @license
14
14
  * Copyright 2017 Google LLC
15
15
  * SPDX-License-Identifier: BSD-3-Clause
16
16
  */
17
- var Eit=globalThis,Mit=Eit.trustedTypes,Tit=Mit?Mit.createPolicy("lit-html",{createHTML:t=>t}):void 0,Cit="$lit$",Pit="lit$".concat(Math.random().toFixed(9).slice(2),"$"),Iit="?"+Pit,Rit="<".concat(Iit,">"),Oit=document,Lit=()=>Oit.createComment(""),Dit=t=>null===t||"object"!=typeof t&&"function"!=typeof t,Fit=Array.isArray,Nit="[ \t\n\f\r]",jit=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Bit=/-->/g,zit=/>/g,Wit=RegExp(">|".concat(Nit,"(?:([^\\s\"'>=/]+)(").concat(Nit,"*=").concat(Nit,"*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)"),"g"),Uit=/'/g,Hit=/"/g,Git=/^(?:script|style|textarea|title)$/i,Yit=(t=>function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return{_$litType$:t,strings:e,values:n}})(1),Vit=Symbol.for("lit-noChange"),qit=Symbol.for("lit-nothing"),Xit=new WeakMap,$it=Oit.createTreeWalker(Oit,129);function Kit(t,e){if(!Fit(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Tit?Tit.createHTML(e):e}var Qit=(t,e)=>{for(var r,n=t.length-1,i=[],a=2===e?"<svg>":3===e?"<math>":"",s=jit,o=0;o<n;o++){for(var l=t[o],h=void 0,c=void 0,u=-1,d=0;d<l.length&&(s.lastIndex=d,null!==(c=s.exec(l)));)d=s.lastIndex,s===jit?"!--"===c[1]?s=Bit:void 0!==c[1]?s=zit:void 0!==c[2]?(Git.test(c[2])&&(r=RegExp("</"+c[2],"g")),s=Wit):void 0!==c[3]&&(s=Wit):s===Wit?">"===c[0]?(s=null!=r?r:jit,u=-1):void 0===c[1]?u=-2:(u=s.lastIndex-c[2].length,h=c[1],s=void 0===c[3]?Wit:'"'===c[3]?Hit:Uit):s===Hit||s===Uit?s=Wit:s===Bit||s===zit?s=jit:(s=Wit,r=void 0);var p=s===Wit&&t[o+1].startsWith("/>")?" ":"";a+=s===jit?l+Rit:u>=0?(i.push(h),l.slice(0,u)+Cit+l.slice(u)+Pit+p):l+Pit+(-2===u?o:p)}return[Kit(t,a+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class Jit{constructor(t,e){var r,{strings:n,_$litType$:i}=t;this.parts=[];var a=0,s=0,o=n.length-1,l=this.parts,[h,c]=Qit(n,i);if(this.el=Jit.createElement(h,e),$it.currentNode=this.el.content,2===i||3===i){var u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;null!==(r=$it.nextNode())&&l.length<o;){if(1===r.nodeType){if(r.hasAttributes())for(var d of r.getAttributeNames())if(d.endsWith(Cit)){var p=c[s++],f=r.getAttribute(d).split(Pit),g=/([.?@])?(.*)/.exec(p);l.push({type:1,index:a,name:g[2],strings:f,ctor:"."===g[1]?nat:"?"===g[1]?iat:"@"===g[1]?aat:rat}),r.removeAttribute(d)}else d.startsWith(Pit)&&(l.push({type:6,index:a}),r.removeAttribute(d));if(Git.test(r.tagName)){var v=r.textContent.split(Pit),m=v.length-1;if(m>0){r.textContent=Mit?Mit.emptyScript:"";for(var y=0;y<m;y++)r.append(v[y],Lit()),$it.nextNode(),l.push({type:2,index:++a});r.append(v[m],Lit())}}}else if(8===r.nodeType)if(r.data===Iit)l.push({type:2,index:a});else for(var b=-1;-1!==(b=r.data.indexOf(Pit,b+1));)l.push({type:7,index:a}),b+=Pit.length-1;a++}}static createElement(t,e){var r=Oit.createElement("template");return r.innerHTML=t,r}}function Zit(t,e){var r,n,i,a,s,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,l=arguments.length>3?arguments[3]:void 0;if(e===Vit)return e;var h=void 0!==l?null===(r=o._$Co)||void 0===r?void 0:r[l]:o._$Cl,c=Dit(e)?void 0:e._$litDirective$;return(null===(n=h)||void 0===n?void 0:n.constructor)!==c&&(null!==(i=h)&&void 0!==i&&null!==(a=i._$AO)&&void 0!==a&&a.call(i,!1),void 0===c?h=void 0:(h=new c(t))._$AT(t,o,l),void 0!==l?(null!==(s=o._$Co)&&void 0!==s?s:o._$Co=[])[l]=h:o._$Cl=h),void 0!==h&&(e=Zit(t,h._$AS(t,e.values),h,l)),e}class tat{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e,{el:{content:r},parts:n}=this._$AD,i=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:Oit).importNode(r,!0);$it.currentNode=i;for(var a=$it.nextNode(),s=0,o=0,l=n[0];void 0!==l;){var h;if(s===l.index){var c=void 0;2===l.type?c=new eat(a,a.nextSibling,this,t):1===l.type?c=new l.ctor(a,l.name,l.strings,this,t):6===l.type&&(c=new sat(a,this,t)),this._$AV.push(c),l=n[++o]}s!==(null===(h=l)||void 0===h?void 0:h.index)&&(a=$it.nextNode(),s++)}return $it.currentNode=Oit,i}p(t){var e=0;for(var r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}class eat{get _$AU(){var t,e;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cv}constructor(t,e,r,n){var i;this.type=2,this._$AH=qit,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=n,this._$Cv=null===(i=null==n?void 0:n.isConnected)||void 0===i||i}get parentNode(){var t,e=this._$AA.parentNode,r=this._$AM;return void 0!==r&&11===(null===(t=e)||void 0===t?void 0:t.nodeType)&&(e=r.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t){t=Zit(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this),Dit(t)?t===qit||null==t||""===t?(this._$AH!==qit&&this._$AR(),this._$AH=qit):t!==this._$AH&&t!==Vit&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>Fit(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==qit&&Dit(this._$AH)?this._$AA.nextSibling.data=t:this.T(Oit.createTextNode(t)),this._$AH=t}$(t){var e,{values:r,_$litType$:n}=t,i="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=Jit.createElement(Kit(n.h,n.h[0]),this.options)),n);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.p(r);else{var a=new tat(i,this),s=a.u(this.options);a.p(r),this.T(s),this._$AH=a}}_$AC(t){var e=Xit.get(t.strings);return void 0===e&&Xit.set(t.strings,e=new Jit(t)),e}k(t){Fit(this._$AH)||(this._$AH=[],this._$AR());var e,r=this._$AH,n=0;for(var i of t)n===r.length?r.push(e=new eat(this.O(Lit()),this.O(Lit()),this,this.options)):e=r[n],e._$AI(i),n++;n<r.length&&(this._$AR(e&&e._$AB.nextSibling,n),r.length=n)}_$AR(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._$AA.nextSibling,e=arguments.length>1?arguments[1]:void 0;for(null===(r=this._$AP)||void 0===r||r.call(this,!1,!0,e);t&&t!==this._$AB;){var r,n=t.nextSibling;t.remove(),t=n}}setConnected(t){var e;void 0===this._$AM&&(this._$Cv=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class rat{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,n,i){this.type=1,this._$AH=qit,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=i,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=qit}_$AI(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,i=this.strings,a=!1;if(void 0===i)t=Zit(this,t,e,0),(a=!Dit(t)||t!==this._$AH&&t!==Vit)&&(this._$AH=t);else{var s,o,l=t;for(t=i[0],s=0;s<i.length-1;s++)(o=Zit(this,l[r+s],e,s))===Vit&&(o=this._$AH[s]),a||(a=!Dit(o)||o!==this._$AH[s]),o===qit?t=qit:t!==qit&&(t+=(null!=o?o:"")+i[s+1]),this._$AH[s]=o}a&&!n&&this.j(t)}j(t){t===qit?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class nat extends rat{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===qit?void 0:t}}class iat extends rat{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==qit)}}class aat extends rat{constructor(t,e,r,n,i){super(t,e,r,n,i),this.type=5}_$AI(t){var e;if((t=null!==(e=Zit(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,0))&&void 0!==e?e:qit)!==Vit){var r=this._$AH,n=t===qit&&r!==qit||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,i=t!==qit&&(r===qit||n);n&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}}handleEvent(t){var e,r;"function"==typeof this._$AH?this._$AH.call(null!==(e=null===(r=this.options)||void 0===r?void 0:r.host)&&void 0!==e?e:this.element,t):this._$AH.handleEvent(t)}}class sat{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Zit(this,t)}}var oat=Eit.litHtmlPolyfillSupport;null!=oat&&oat(Jit,eat),(null!==(hit=Eit.litHtmlVersions)&&void 0!==hit?hit:Eit.litHtmlVersions=[]).push("3.2.1");var lat,hat,cat=(t,e,r)=>{var n,i=null!==(n=null==r?void 0:r.renderBefore)&&void 0!==n?n:e,a=i._$litPart$;if(void 0===a){var s,o=null!==(s=null==r?void 0:r.renderBefore)&&void 0!==s?s:null;i._$litPart$=a=new eat(e.insertBefore(Lit(),o),o,void 0,null!=r?r:{})}return a._$AI(t),a};
17
+ var Mit=globalThis,Tit=Mit.trustedTypes,Cit=Tit?Tit.createPolicy("lit-html",{createHTML:t=>t}):void 0,Pit="$lit$",Iit="lit$".concat(Math.random().toFixed(9).slice(2),"$"),Rit="?"+Iit,Oit="<".concat(Rit,">"),Lit=document,Dit=()=>Lit.createComment(""),Fit=t=>null===t||"object"!=typeof t&&"function"!=typeof t,Nit=Array.isArray,jit="[ \t\n\f\r]",Bit=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,zit=/-->/g,Wit=/>/g,Uit=RegExp(">|".concat(jit,"(?:([^\\s\"'>=/]+)(").concat(jit,"*=").concat(jit,"*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)"),"g"),Hit=/'/g,Git=/"/g,Yit=/^(?:script|style|textarea|title)$/i,Vit=(t=>function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return{_$litType$:t,strings:e,values:n}})(1),qit=Symbol.for("lit-noChange"),Xit=Symbol.for("lit-nothing"),$it=new WeakMap,Kit=Lit.createTreeWalker(Lit,129);function Qit(t,e){if(!Nit(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Cit?Cit.createHTML(e):e}var Jit=(t,e)=>{for(var r,n=t.length-1,i=[],a=2===e?"<svg>":3===e?"<math>":"",s=Bit,o=0;o<n;o++){for(var l=t[o],h=void 0,c=void 0,u=-1,d=0;d<l.length&&(s.lastIndex=d,null!==(c=s.exec(l)));)d=s.lastIndex,s===Bit?"!--"===c[1]?s=zit:void 0!==c[1]?s=Wit:void 0!==c[2]?(Yit.test(c[2])&&(r=RegExp("</"+c[2],"g")),s=Uit):void 0!==c[3]&&(s=Uit):s===Uit?">"===c[0]?(s=null!=r?r:Bit,u=-1):void 0===c[1]?u=-2:(u=s.lastIndex-c[2].length,h=c[1],s=void 0===c[3]?Uit:'"'===c[3]?Git:Hit):s===Git||s===Hit?s=Uit:s===zit||s===Wit?s=Bit:(s=Uit,r=void 0);var p=s===Uit&&t[o+1].startsWith("/>")?" ":"";a+=s===Bit?l+Oit:u>=0?(i.push(h),l.slice(0,u)+Pit+l.slice(u)+Iit+p):l+Iit+(-2===u?o:p)}return[Qit(t,a+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class Zit{constructor(t,e){var r,{strings:n,_$litType$:i}=t;this.parts=[];var a=0,s=0,o=n.length-1,l=this.parts,[h,c]=Jit(n,i);if(this.el=Zit.createElement(h,e),Kit.currentNode=this.el.content,2===i||3===i){var u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;null!==(r=Kit.nextNode())&&l.length<o;){if(1===r.nodeType){if(r.hasAttributes())for(var d of r.getAttributeNames())if(d.endsWith(Pit)){var p=c[s++],f=r.getAttribute(d).split(Iit),g=/([.?@])?(.*)/.exec(p);l.push({type:1,index:a,name:g[2],strings:f,ctor:"."===g[1]?iat:"?"===g[1]?aat:"@"===g[1]?sat:nat}),r.removeAttribute(d)}else d.startsWith(Iit)&&(l.push({type:6,index:a}),r.removeAttribute(d));if(Yit.test(r.tagName)){var v=r.textContent.split(Iit),m=v.length-1;if(m>0){r.textContent=Tit?Tit.emptyScript:"";for(var y=0;y<m;y++)r.append(v[y],Dit()),Kit.nextNode(),l.push({type:2,index:++a});r.append(v[m],Dit())}}}else if(8===r.nodeType)if(r.data===Rit)l.push({type:2,index:a});else for(var b=-1;-1!==(b=r.data.indexOf(Iit,b+1));)l.push({type:7,index:a}),b+=Iit.length-1;a++}}static createElement(t,e){var r=Lit.createElement("template");return r.innerHTML=t,r}}function tat(t,e){var r,n,i,a,s,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,l=arguments.length>3?arguments[3]:void 0;if(e===qit)return e;var h=void 0!==l?null===(r=o._$Co)||void 0===r?void 0:r[l]:o._$Cl,c=Fit(e)?void 0:e._$litDirective$;return(null===(n=h)||void 0===n?void 0:n.constructor)!==c&&(null!==(i=h)&&void 0!==i&&null!==(a=i._$AO)&&void 0!==a&&a.call(i,!1),void 0===c?h=void 0:(h=new c(t))._$AT(t,o,l),void 0!==l?(null!==(s=o._$Co)&&void 0!==s?s:o._$Co=[])[l]=h:o._$Cl=h),void 0!==h&&(e=tat(t,h._$AS(t,e.values),h,l)),e}class eat{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e,{el:{content:r},parts:n}=this._$AD,i=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:Lit).importNode(r,!0);Kit.currentNode=i;for(var a=Kit.nextNode(),s=0,o=0,l=n[0];void 0!==l;){var h;if(s===l.index){var c=void 0;2===l.type?c=new rat(a,a.nextSibling,this,t):1===l.type?c=new l.ctor(a,l.name,l.strings,this,t):6===l.type&&(c=new oat(a,this,t)),this._$AV.push(c),l=n[++o]}s!==(null===(h=l)||void 0===h?void 0:h.index)&&(a=Kit.nextNode(),s++)}return Kit.currentNode=Lit,i}p(t){var e=0;for(var r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}class rat{get _$AU(){var t,e;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cv}constructor(t,e,r,n){var i;this.type=2,this._$AH=Xit,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=n,this._$Cv=null===(i=null==n?void 0:n.isConnected)||void 0===i||i}get parentNode(){var t,e=this._$AA.parentNode,r=this._$AM;return void 0!==r&&11===(null===(t=e)||void 0===t?void 0:t.nodeType)&&(e=r.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t){t=tat(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this),Fit(t)?t===Xit||null==t||""===t?(this._$AH!==Xit&&this._$AR(),this._$AH=Xit):t!==this._$AH&&t!==qit&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>Nit(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==Xit&&Fit(this._$AH)?this._$AA.nextSibling.data=t:this.T(Lit.createTextNode(t)),this._$AH=t}$(t){var e,{values:r,_$litType$:n}=t,i="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=Zit.createElement(Qit(n.h,n.h[0]),this.options)),n);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.p(r);else{var a=new eat(i,this),s=a.u(this.options);a.p(r),this.T(s),this._$AH=a}}_$AC(t){var e=$it.get(t.strings);return void 0===e&&$it.set(t.strings,e=new Zit(t)),e}k(t){Nit(this._$AH)||(this._$AH=[],this._$AR());var e,r=this._$AH,n=0;for(var i of t)n===r.length?r.push(e=new rat(this.O(Dit()),this.O(Dit()),this,this.options)):e=r[n],e._$AI(i),n++;n<r.length&&(this._$AR(e&&e._$AB.nextSibling,n),r.length=n)}_$AR(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._$AA.nextSibling,e=arguments.length>1?arguments[1]:void 0;for(null===(r=this._$AP)||void 0===r||r.call(this,!1,!0,e);t&&t!==this._$AB;){var r,n=t.nextSibling;t.remove(),t=n}}setConnected(t){var e;void 0===this._$AM&&(this._$Cv=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class nat{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,n,i){this.type=1,this._$AH=Xit,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=i,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=Xit}_$AI(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,i=this.strings,a=!1;if(void 0===i)t=tat(this,t,e,0),(a=!Fit(t)||t!==this._$AH&&t!==qit)&&(this._$AH=t);else{var s,o,l=t;for(t=i[0],s=0;s<i.length-1;s++)(o=tat(this,l[r+s],e,s))===qit&&(o=this._$AH[s]),a||(a=!Fit(o)||o!==this._$AH[s]),o===Xit?t=Xit:t!==Xit&&(t+=(null!=o?o:"")+i[s+1]),this._$AH[s]=o}a&&!n&&this.j(t)}j(t){t===Xit?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class iat extends nat{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Xit?void 0:t}}class aat extends nat{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Xit)}}class sat extends nat{constructor(t,e,r,n,i){super(t,e,r,n,i),this.type=5}_$AI(t){var e;if((t=null!==(e=tat(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,0))&&void 0!==e?e:Xit)!==qit){var r=this._$AH,n=t===Xit&&r!==Xit||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,i=t!==Xit&&(r===Xit||n);n&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}}handleEvent(t){var e,r;"function"==typeof this._$AH?this._$AH.call(null!==(e=null===(r=this.options)||void 0===r?void 0:r.host)&&void 0!==e?e:this.element,t):this._$AH.handleEvent(t)}}class oat{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){tat(this,t)}}var lat=Mit.litHtmlPolyfillSupport;null!=lat&&lat(Zit,rat),(null!==(cit=Mit.litHtmlVersions)&&void 0!==cit?cit:Mit.litHtmlVersions=[]).push("3.2.1");var hat,cat,uat=(t,e,r)=>{var n,i=null!==(n=null==r?void 0:r.renderBefore)&&void 0!==n?n:e,a=i._$litPart$;if(void 0===a){var s,o=null!==(s=null==r?void 0:r.renderBefore)&&void 0!==s?s:null;i._$litPart$=a=new rat(e.insertBefore(Dit(),o),o,void 0,null!=r?r:{})}return a._$AI(t),a};
18
18
  /**
19
19
  * @license
20
20
  * Copyright 2017 Google LLC
21
21
  * SPDX-License-Identifier: BSD-3-Clause
22
22
  */
23
- class uat extends Sit{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e,r=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=r.firstChild),r}update(t){var e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=cat(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return Vit}}uat._$litElement$=!0,uat.finalized=!0,null===(lat=globalThis.litElementHydrateSupport)||void 0===lat||lat.call(globalThis,{LitElement:uat});var dat=globalThis.litElementPolyfillSupport;null==dat||dat({LitElement:uat}),(null!==(hat=globalThis.litElementVersions)&&void 0!==hat?hat:globalThis.litElementVersions=[]).push("4.1.1");const pat=["mousemove","mouseup","mousedown","mouseout","wheel","tap","click","touchstart","touchmove","touchend","mouseenter","mouseleave","dragstart","dragmove","dragend","dblclick"];var fat=t=>class extends t{isHTMLElement(){return!0}isShadowable(){return!0}get element(){return this._element}set element(t){this._element=t}get tagName(){return this.get("type")}setElementProperties(t){throw new Error("Not Implemented Yet")}createElement(){this.element=document.createElement(this.tagName),this.element&&(this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.root.model_layer.overlay.appendChild(this.element),pat.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),n9.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),this.oncreate_element&&this.oncreate_element(this.element))}userInputEventHandler(t){rnt(this,t.type,t),t.stopPropagation()}reposition(){this.element&&K9(this)}disposeElement(){var t=this.element;t&&t.parentElement&&t.parentElement.removeChild(t),delete this.element}ready(){super.ready(),!this.element&&this.createElement(),this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.root.model_layer.overlay.appendChild(this.element),this.setElementProperties(this.element),this.reposition()}dispose(){this.disposeElement(this),super.dispose()}get hasTextProperty(){return!0}get textHidden(){return!0}get hidden(){return super.hidden}set hidden(t){super.hidden=t,this.element.style.display=t?"none":"block"}onchange(t,e){this.element&&this.setElementProperties(this.element),this.reposition()}isDescendible(t){return t.isHTMLElement()}};const gat={x:1,y:1},vat={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"},mat={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"layout",label:"layout",name:"layoutOption"},{type:"checkbox",label:"closable",name:"closable"},{type:"checkbox",label:"draggable",name:"draggable"},{type:"checkbox",label:"minimizable",name:"minimizable"},{type:"checkbox",label:"minimized",name:"minimized"}],help:"scene/component/container"};class yat extends(fat(Gtt)){get tagName(){return"div"}get nature(){return mat}setElementProperties(t){}get layout(){return Ett.get(this.get("layout"))||Mtt}reposition(){if(this.element){var t=this,{id:e,class:r,scale:n=gat}=t.state,{rotation:i=0,hidden:a}=t,{left:s,top:o,width:l,height:h}=t.bounds,c=l/2,u=h/2,d=t.element;d.hidden=a,e&&(d.id=e),r&&(d.className=r),Object.assign(d.style,vat,{left:s+"px",top:o+"px",width:"0px",height:"0px",backgroundColor:"transparent"});var p=t.delta(),f=(n&&n.x||1)*p.sx,g=(n&&n.y||1)*p.sy,v=(i||0)+p.theta,m=p.tx||0,y=p.ty||0;d.style.transform=`translate(${m+c}px, ${y+u}px) rotate(${v}rad) translate(${-c}px, ${-u}px) scale(${f}, ${g}) perspective(1px)`}}set path(t){const{minimized:e}=this.state;var r=t[0],n=t[2];e?this.set({left:r.x,top:r.y,width:n.x-r.x}):this.set({left:r.x,top:r.y,width:n.x-r.x,height:n.y-r.y})}get path(){var{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return[{x:t,y:e},{x:t+r,y:e},{x:t+r,y:e+n},{x:t,y:e+n}]}get bounds(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return{left:t,top:e,width:r,height:n}}set bounds(t){const{minimized:e}=this.state,{left:r=0,top:n=0,width:i=0,height:a=0}=t;e?this.set({left:r,top:n,width:i}):this.set({left:r,top:n,width:i,height:a})}onchange(t,e){super.onchange(t,e),("draggable"in t||"minimizable"in t||"closable"in t||"minimized"in t)&&this.onchangeButtons(),"minimized"in t&&this.onchangeMinimized()}createElement(){super.createElement(),this.onchangeButtons(),this.onchangeMinimized()}onchangeButtons(){const{draggable:t,minimizable:e,closable:r,minimized:n}=this.state;cat(Yit`
23
+ class dat extends Eit{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e,r=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=r.firstChild),r}update(t){var e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=uat(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return qit}}dat._$litElement$=!0,dat.finalized=!0,null===(hat=globalThis.litElementHydrateSupport)||void 0===hat||hat.call(globalThis,{LitElement:dat});var pat=globalThis.litElementPolyfillSupport;null==pat||pat({LitElement:dat}),(null!==(cat=globalThis.litElementVersions)&&void 0!==cat?cat:globalThis.litElementVersions=[]).push("4.1.1");const fat=["mousemove","mouseup","mousedown","mouseout","wheel","tap","click","touchstart","touchmove","touchend","mouseenter","mouseleave","dragstart","dragmove","dragend","dblclick"];var gat=t=>class extends t{isHTMLElement(){return!0}isShadowable(){return!0}get element(){return this._element}set element(t){this._element=t}get tagName(){return this.get("type")}setElementProperties(t){throw new Error("Not Implemented Yet")}createElement(){this.element=document.createElement(this.tagName),this.element&&(this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.root.model_layer.overlay.appendChild(this.element),fat.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),n9.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),this.oncreate_element&&this.oncreate_element(this.element))}userInputEventHandler(t){rnt(this,t.type,t),t.stopPropagation()}reposition(){this.element&&K9(this)}disposeElement(){var t=this.element;t&&t.parentElement&&t.parentElement.removeChild(t),delete this.element}ready(){super.ready(),!this.element&&this.createElement(),this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.root.model_layer.overlay.appendChild(this.element),this.setElementProperties(this.element),this.reposition()}dispose(){this.disposeElement(this),super.dispose()}get hasTextProperty(){return!0}get textHidden(){return!0}get hidden(){return super.hidden}set hidden(t){super.hidden=t,this.element.style.display=t?"none":"block"}onchange(t,e){this.element&&this.setElementProperties(this.element),this.reposition()}isDescendible(t){return t.isHTMLElement()}};const vat={x:1,y:1},mat={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"},yat={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"layout",label:"layout",name:"layoutOption"},{type:"checkbox",label:"closable",name:"closable"},{type:"checkbox",label:"draggable",name:"draggable"},{type:"checkbox",label:"minimizable",name:"minimizable"},{type:"checkbox",label:"minimized",name:"minimized"}],help:"scene/component/container"};class bat extends(gat(Gtt)){get tagName(){return"div"}get nature(){return yat}setElementProperties(t){}get layout(){return Ett.get(this.get("layout"))||Mtt}reposition(){if(this.element){var t=this,{id:e,class:r,scale:n=vat}=t.state,{rotation:i=0,hidden:a}=t,{left:s,top:o,width:l,height:h}=t.bounds,c=l/2,u=h/2,d=t.element;d.hidden=a,e&&(d.id=e),r&&(d.className=r),Object.assign(d.style,mat,{left:s+"px",top:o+"px",width:"0px",height:"0px",backgroundColor:"transparent"});var p=t.delta(),f=(n&&n.x||1)*p.sx,g=(n&&n.y||1)*p.sy,v=(i||0)+p.theta,m=p.tx||0,y=p.ty||0;d.style.transform=`translate(${m+c}px, ${y+u}px) rotate(${v}rad) translate(${-c}px, ${-u}px) scale(${f}, ${g}) perspective(1px)`}}set path(t){const{minimized:e}=this.state;var r=t[0],n=t[2];e?this.set({left:r.x,top:r.y,width:n.x-r.x}):this.set({left:r.x,top:r.y,width:n.x-r.x,height:n.y-r.y})}get path(){var{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return[{x:t,y:e},{x:t+r,y:e},{x:t+r,y:e+n},{x:t,y:e+n}]}get bounds(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return{left:t,top:e,width:r,height:n}}set bounds(t){const{minimized:e}=this.state,{left:r=0,top:n=0,width:i=0,height:a=0}=t;e?this.set({left:r,top:n,width:i}):this.set({left:r,top:n,width:i,height:a})}onchange(t,e){super.onchange(t,e),("draggable"in t||"minimizable"in t||"closable"in t||"minimized"in t)&&this.onchangeButtons(),"minimized"in t&&this.onchangeMinimized()}createElement(){super.createElement(),this.onchangeButtons(),this.onchangeMinimized()}onchangeButtons(){const{draggable:t,minimizable:e,closable:r,minimized:n}=this.state;uat(Vit`
24
24
  <style>
25
25
  .buttons {
26
26
  position: absolute;
@@ -35,13 +35,13 @@ class uat extends Sit{constructor(){super(...arguments),this.renderOptions={host
35
35
  }
36
36
  </style>
37
37
  <div class="buttons">
38
- ${t?Yit`<button class="draggable" @mousedown=${this.startDragging.bind(this)}>&#x2630;</button>`:qit}
39
- ${e?Yit`<button class="minimizable" @click=${this.toggleMinimizable.bind(this)}>
40
- ${n?Yit`&#x25A1;`:Yit`&#8211;`}
41
- </button>`:qit}
42
- ${r?Yit`<button class="closable" @click=${this.closeContainer.bind(this)}>&#88;</button>`:qit}
38
+ ${t?Vit`<button class="draggable" @mousedown=${this.startDragging.bind(this)}>&#x2630;</button>`:Xit}
39
+ ${e?Vit`<button class="minimizable" @click=${this.toggleMinimizable.bind(this)}>
40
+ ${n?Vit`&#x25A1;`:Vit`&#8211;`}
41
+ </button>`:Xit}
42
+ ${r?Vit`<button class="closable" @click=${this.closeContainer.bind(this)}>&#88;</button>`:Xit}
43
43
  </div>
44
- `,this.element)}startDragging(t){t.preventDefault(),t.stopPropagation();let e=t.clientX,r=t.clientY;const{left:n,top:i}=this.bounds,a=this.rootModel.overlay.style.transform.match(/scale\(([^,]+),\s*([^)]+)\)/),s=a?parseFloat(a[1]):1,o=a?parseFloat(a[2]):s,l=t=>{t.preventDefault(),t.stopPropagation();const a=(t.clientX-e)/s,l=(t.clientY-r)/o;this.setState({left:n+a,top:i+l})},h=t=>{t.preventDefault(),t.stopPropagation(),this.element.removeEventListener("mousemove",l),this.element.removeEventListener("mouseup",h),document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",h)};this.element.addEventListener("mousemove",l),this.element.addEventListener("mouseup",h),document.addEventListener("mousemove",l),document.addEventListener("mouseup",h)}toggleMinimizable(){const{minimized:t}=this.state;this.setState("minimized",!t)}onchangeMinimized(){const{minimized:t}=this.state;t?this.setState("height",20):this.setState("height",this.get("height"))}closeContainer(){this.setState("hidden",!0)}}mtt.register("container",yat);const bat=Math.sqrt(3),wat=2;function xat(t,e,r,n,i){var a,s,o,l,h=5+i,c=r.x,u=r.y,d=n.x,p=n.y;if(Math.abs(c-d)>h&&Math.abs(u-p)>h){var f=(p-u)/(d-c),g=u-f*c;if(Math.abs(e-(f*t+g))>h)return!1}return c>d?(s=c,a=d):(s=d,a=c),u>p?(l=u,o=p):(l=p,o=u),!(s+5<t)&&(!(a-5>t)&&(!(l+5<e)&&!(o-5>e)))}function Aat(t,e,r,n=2){for(let i=0;i<r.length-1;i++)if(xat(t,e,r[i],r[i+1],n))return!0;return!1}function _at(t,e,r,n){if("arrow"!=t.slice(-5))return r;var i=Math.atan2(n.y-r.y,n.x-r.x),a=1.5*e;return{x:r.x+Math.cos(i)*a,y:r.y+Math.sin(i)*a}}function kat(t,e,r){var{lineWidth:n=wat,strokeStyle:i="#000000",lineCap:a=!1,alpha:s=1,begin:o="none",end:l="none",beginSize:h="size5",endSize:c="size5"}=r;if(("none"!=o||"none"!=l)&&(n=Number(n)||wat,t.lineCap=a,t.lineWidth=n,t.strokeStyle=i,t.fillStyle=i,t.globalAlpha*=s,"none"!=o&&Sat(t,e[0],e[1],n,o,Eat(h,n)),"none"!=l)){let r=e.length;Sat(t,e[r-1],e[r-2],n,l,Eat(c,n))}}function Sat(t,e,r,n,i,a){var{x:s,y:o}=e,l=Math.atan2(r.y-o,r.x-s);switch(t.beginPath(),t.translate(s,o),t.rotate(l),i){case"oval":t.ellipse(0,0,a.X,a.Y,0,0,2*Math.PI),t.fill();break;case"diamond":t.moveTo(-a.X,0),t.lineTo(0,-a.Y),t.lineTo(a.X,0),t.lineTo(0,a.Y),t.fill();break;case"arrow":t.moveTo(0,0),t.lineTo(bat*a.X,-a.Y),t.lineTo(bat*a.X,a.Y),t.fill();break;case"sharp-arrow":t.moveTo(0,0),t.lineTo(bat*a.X,-a.Y),t.lineTo(-a.X/1.5+bat*a.X,0),t.lineTo(bat*a.X,a.Y),t.fill();break;case"open-arrow":t.moveTo(bat*a.X+n,-a.Y),t.lineTo(n,0),t.lineTo(bat*a.X+n,a.Y),t.stroke()}t.rotate(-l),t.translate(-s,-o),t.closePath()}function Eat(t,e){let r={};switch(e*=1.2,t){case"size1":r.X=e,r.Y=e;break;case"size2":r.X=1.5*e,r.Y=e;break;case"size3":r.X=2*e,r.Y=e;break;case"size4":r.X=e,r.Y=1.5*e;break;case"size5":default:r.X=1.5*e,r.Y=1.5*e;break;case"size6":r.X=2*e,r.Y=1.5*e;break;case"size7":r.X=e,r.Y=2*e;break;case"size8":r.X=1.5*e,r.Y=2*e;break;case"size9":r.X=2*e,r.Y=2*e}return r}const Mat="N",Tat="S",Cat="E",Pat="W";class Iat{constructor({component:t,anchor:e,position:r,self:n}){this.component=t,this._anchorName=e,this._position=r,this.self=n}get position(){const t=this.anchor;if(t){var{position:e}=t;const r=this.component.transcoordS2T(e.x,e.y);return this.self.transcoordT2P(r.x,r.y)}return this._position}set position({x:t,y:e}){this._position={x:t,y:e}}get anchor(){return this.component?.findAnchor(this._anchorName)}get direction(){const t=this.component.bounds,e=this.anchor;if(!e)return Cat;const r=e.position;return r.y<=t.top?Mat:r.y>=t.top+t.height?Tat:r.x<=t.left?Pat:Cat}get boundaryPosition(){const t=this.anchor;if(t){var{position:e}=t,r=0,n=0;switch(this.direction){case Tat:n=20;break;case Mat:n=-20;break;case Pat:r=-20;break;default:r=20}e={x:e.x+r,y:e.y+n};const i=this.component.transcoordS2T(e.x,e.y);return this.self.transcoordT2P(i.x,i.y)}}}class Rat extends mtt{isLine(){return!0}replaceRefids(t){["from","to"].forEach((e=>{const r=this.get(e);if(r?.component){const n=t.get(r.component)||r.component;this.set(e,{...r,component:n})}}))}get fromEnd(){if(this.parent&&!this._fromEnd){const{component:t,anchor:e,position:r}=this.getState("from")||{};if(!t)return;const n=this.root?.findByRefid(t);if(!n)return;this._fromEnd=new Iat({component:n,fromto:"from",anchor:e,position:r,self:this})}return this._fromEnd}get from(){return this.getState("from")}set from(t){delete this._fromEnd,this.set("from",t)}get toEnd(){if(this.parent&&!this._toEnd){const{component:t,anchor:e,position:r}=this.getState("to")||{};if(!t)return;const n=this.root?.findByRefid(t);if(!n)return;this._toEnd=new Iat({component:n,fromto:"to",anchor:e,position:r,self:this})}return this._toEnd}get to(){return this.getState("to")}set to(t){delete this._toEnd,this.set("to",t)}move({x:t,y:e},r){r&&(this.from={position:this._fromEnd?.position||this.getState("from")?.position||{x:0,y:0}},this.to={position:this._toEnd?.position||this.getState("to")?.position||{x:0,y:0}}),super.move({x:t,y:e},r)}render(t){var{begin:e="none",end:r="none",lineWidth:n,round:i=0}=this.state,a=this.drawPath;kat(t,a,this.state),t.beginPath();var s=_at(e,n,a[0],a[1]),o=_at(r,n,a[a.length-1],a[a.length-2]);a=[s,...a.slice(1,-1),o];var l={x:s.x,y:s.y};t.moveTo(s.x,s.y);for(var h=1;h<a.length;h++){const e=l;l=a[h];const r=a[h+1];if(e.x===l.x&&e.y===l.y)continue;if(!r){t.lineTo(l.x,l.y);break}var c=0!==(p=Math.sqrt((e.x-l.x)*(e.x-l.x)+(e.y-l.y)*(e.y-l.y)))?Math.atan2(e.x-l.x,e.y-l.y):0,u=Math.sin(c)*Math.min(i,p/2)+l.x,d=Math.cos(c)*Math.min(i,p/2)+l.y;const n=i>0||0!==p?{x:u,y:d}:l;var p;c=0!==(p=Math.sqrt((r.x-l.x)*(r.x-l.x)+(r.y-l.y)*(r.y-l.y)))?Math.atan2(r.x-l.x,r.y-l.y):0,u=Math.sin(c)*Math.min(i,p/2)+l.x,d=Math.cos(c)*Math.min(i,p/2)+l.y;const s=i>0||0!==p?{x:u,y:d}:l;t.lineTo(n.x,n.y),i>0&&t.quadraticCurveTo(l.x,l.y,s.x,s.y)}this.drawStroke(t)}contains(t,e){var{lineWidth:r}=this.state;return Aat(t,e,this.drawPath,r)}get resizable(){return!1}get mutable(){return!0}get rotatable(){return!1}get path(){const{from:t,to:e}=this.state;var{x1:r,y1:n,x2:i,y2:a}=this.state;return[this.fromEnd?.position||t?.position||{x:r,y:n},this.toEnd?.position||e?.position||{x:i,y:a}]}set path(t){const[e,r]=t,{from:n,to:i}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...n,position:e},to:{...i,position:r}})}get textBounds(){var t,e,r=this.drawPath,n=0;for(let o=1;o<r.length;o++){var i=r[o-1],a=r[o],s=(i.x-a.x)*(i.x-a.x)+(i.y-a.y)*(i.y-a.y);s>n&&(n=Math.ceil(s),t=i,e=a)}var{paddingTop:o,paddingLeft:l,paddingRight:h,paddingBottom:c}=this.state;return c||=0,o||=0,l||=0,h||=0,{left:Math.min(t.x,e.x)+l,top:Math.min(t.y,e.y)+o,width:Math.max(Math.abs(t.x-e.x)-l-h,0),height:Math.max(Math.abs(t.y-e.y)-o-c,0)}}get decorators(){return["decotag"]}}Rat.getTipNeckPos=_at,Rat.containedInPath=Aat,Rat.drawEndTips=kat,mtt.register("line",Rat);const Oat={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"angle",label:"start-angle",name:"startAngle",property:"startAngle"},{type:"angle",label:"end-angle",name:"endAngle",property:"endAngle"}],"value-property":"text"};class Lat extends(Qtt(ytt)){is3dish(){return!0}render(t){var{cx:e,cy:r,rx:n,ry:i,startAngle:a,endAngle:s,anticlockwise:o}=this.state;t.beginPath(),t.ellipse(e,r,Math.abs(n),Math.abs(i),0,a||0,s||2*Math.PI,o),void 0!==a&&void 0!==s&&(t.lineTo(e,r),t.closePath())}get path(){var{cx:t,cy:e,rx:r,ry:n}=this.state;return[{x:t-r,y:e-n},{x:t+r,y:e-n},{x:t+r,y:e+n},{x:t-r,y:e+n}]}set path(t){var e=t[0],r=t[2];this.set({cx:e.x+(r.x-e.x)/2,cy:e.y+(r.y-e.y)/2,rx:(r.x-e.x)/2,ry:(r.y-e.y)/2})}contains(t,e){var{cx:r,cy:n,rx:i,ry:a}=this.state,s=(t-r)/(2*i-.5),o=(e-n)/(2*a-.5);return s*s+o*o<.25}outline(t){return function(t,e){var{cx:r,cy:n,rx:i,ry:a}=t.model,s=2*Math.PI*e,o=r+i*Math.cos(s),l=n+a*Math.sin(s);return t.transcoordS2T(o,l)}(this,t)}get anchors(){return function(t){var{left:e,top:r,width:n,height:i}=t.bounds,a=e+n/2,s=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:s}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:s}}]}(this)}get nature(){return Oat}}mtt.memoize(Lat.prototype,"path",!1),mtt.register("ellipse",Lat);var Dat={ondragstart:function(t,e,r){r.mutatePath(null,(function(r){r.splice(e+1,0,t)}))},ondragmove:function(t,e,r){r.mutatePath(null,(function(r){r[e+1]=t}))},ondragend:function(t,e,r){}};const Fat={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polygon"};class Nat extends ytt{is3dish(){return!0}get mutable(){return!0}get pathExtendable(){return!0}get path(){return this.state.path}set path(t){this.set("path",t)}contains(t,e){var r=this.state.path,n=!1;return r.forEach(((i,a)=>{let s=(a+r.length+1)%r.length,o=i.x,l=i.y,h=r[s].x,c=r[s].y;l>e!=c>e&&t<(h-o)*(e-l)/(c-l)+o&&(n=!n)})),n}get controls(){var t=this.path;return t.map(((e,r)=>{let n=t[r+1>=t.length?0:r+1];return{x:(e.x+n.x)/2,y:(e.y+n.y)/2,handler:Dat}}))}get nature(){return Fat}}mtt.memoize(Nat.prototype,"controls",!1),mtt.register("polygon",Nat);var jat={ondragstart:function(t,e,r){r.mutatePath(null,(function(r){r.splice(e,0,t)}))},ondragmove:function(t,e,r){r.mutatePath(null,(function(r){r[e]=t}))},ondragend:function(t,e,r){}};const Bat={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polyline"};class zat extends Rat{get pathExtendable(){return!0}get path(){const{from:t,to:e}=this.state,{path:r}=this.state;return[this.fromEnd?.position||t?.position||r[0],...r.slice(1,-1),this.toEnd?.position||e?.position||r[r.length-1]]}set path(t){const{from:e,to:r}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...e,position:t[0]},to:{...r,position:t[t.length-1]},path:t})}get controls(){var t=this.path,e=[];for(let r=0;r<t.length-1;r++){let n=t[r],i=t[r+1];0==r&&e.push({x:n.x,y:n.y,handler:jat}),e.push({x:(n.x+i.x)/2,y:(n.y+i.y)/2,handler:jat}),r==t.length-2&&e.push({x:i.x,y:i.y,handler:jat})}return e}get nature(){return Bat}}mtt.register("polyline",zat);const Wat={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/ortholine"};class Uat extends Rat{get pathExtendable(){return!1}get drawPath(){const t=this.path[0],e=this.path[1],{component:r,direction:n,boundaryPosition:i=t}=this.fromEnd||{},{component:a,direction:s,boundaryPosition:o=e}=this.toEnd||{};var l=[i,o],h=[];i&&h.push(i);var c=r?.bounds;if(c){var u=r.transcoordS2T(c.left,c.top);u=this.transcoordT2P(u.x,u.y),c={...c,left:u.x,top:u.y}}var d=c?{left:c.left-20,top:c.top-20,width:c.width+40,height:c.height+40}:{left:i.x,top:i.y,width:0,height:0};c=c||d;var p=a?.bounds;if(p){u=a.transcoordS2T(p.left,p.top);u=this.transcoordT2P(u.x,u.y),p={...p,left:u.x,top:u.y}}var f=p?{left:p.left-20,top:p.top-20,width:p.width+40,height:p.height+40}:{left:o.x,top:o.y,width:0,height:0};p=p||f;var g=[d,f];const v=d.left>f.left?f.left:d.left,m=d.top>f.top?f.top:d.top;var y,b,w,x,A,_,k,S,E,M,T={left:v,top:m,width:d.left+d.width>f.left+f.width?d.left+d.width-v:f.left+f.width-v,height:d.top+d.height>f.top+f.height?d.top+d.height-m:f.top+f.height-m},C=0,P=0;c.left+c.width<p.left?(x=0,A=1,E=n,M=s,y=(c.left+c.width+p.left)/2,C=p.left-y):p.left+p.width<c.left&&(x=1,A=0,E=s,M=n,y=(c.left+p.width+p.left)/2,C=c.left-y),c.top+c.height<p.top?(w=0,_=1,k=n,S=s,b=(c.top+c.height+p.top)/2,P=p.top-b):p.top+p.height<c.top&&(w=1,_=0,k=s,S=n,b=(c.top+p.height+p.top)/2,P=c.top-b);var I=[];if(y&&C>P){switch(M){case Pat:switch(E){case Cat:I.push({x:y,y:l[x].y}),I.push({x:y,y:l[A].y});break;case Pat:var R=g[x].top+g[x].height/2>l[A].y?Math.min(g[x].top,l[A].y):Math.max(g[x].top+g[x].height,l[A].y);I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:l[A].y});break;case Mat:case Tat:R=E===Tat?Math.max(l[x].y,l[A].y):Math.min(l[x].y,l[A].y);I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:l[A].y});break;default:return this.path}break;case Cat:switch(E){case Cat:var O=R=l[x].y<l[A].y?Math.min(g[A].top,l[x].y):Math.max(g[A].top+g[A].height,l[x].y);break;case Pat:O=R=void 0!==b?b:l[x].y<l[A].y?T.top-.5*C:T.top+T.height+.5*C;break;case Tat:O=R=void 0!==b?Math.max(b,l[x].y):T.top+T.height;break;case Mat:O=R=b?Math.min(b,g[x].top):T.top;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;case Tat:switch(E){case Cat:R=l[x].y,O=l[x].y>l[A].y?l[x].y:g[A].top+g[A].height;break;case Pat:O=R=b?Math.max(b,g[A].top+g[A].height):T.top+T.height;break;case Tat:O=R=T.top+T.height;break;case Mat:R=b?Math.min(b,g[x].top):g[x].top,O=b?Math.max(b,g[A].top+g[A].height):g[A].top+g[A].height;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;case Mat:switch(E){case Cat:R=l[x].y,O=l[x].y<l[A].y?l[x].y:g[A].top;break;case Pat:O=R=b?Math.min(b,g[A].top):T.top;break;case Tat:R=void 0!==b?Math.max(b,l[x].y):l[x].y,O=void 0!==b?Math.min(b,l[A].y):l[A].y;break;case Mat:O=R=T.top;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;default:return this.path}h.push(...0===x?I:I.reverse())}else if(b){switch(S){case Mat:switch(k){case Tat:I.push({x:l[w].x,y:b}),I.push({x:l[_].x,y:b});break;case Mat:var L=g[w].left+g[w].width/2>l[_].x?Math.min(g[w].left,l[_].x):Math.max(g[w].left+g[w].width,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;case Pat:L=Math.min(l[w].x,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;case Cat:L=Math.max(l[w].x,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;default:return this.path}break;case Tat:switch(k){case Pat:var D=L=T.left;break;case Cat:D=L=void 0!==y?Math.max(y,l[w].x):T.left+T.width;break;case Mat:D=L=void 0!==y?y:l[w].x<l[_].x?T.left-.5*P:T.left+T.width+.5*P;break;case Tat:L=l[w].x,D=l[w].x<l[_].x?Math.min(g[_].left,l[w].x):Math.max(g[_].left+g[_].width,l[w].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;case Cat:switch(k){case Pat:L=void 0!==y?Math.min(y,l[w].x):l[w].x,D=void 0!==y?Math.max(y,l[_].x):l[_].x;break;case Cat:D=L=T.left+T.width;break;case Mat:D=L=void 0!==y?Math.max(y,l[_].x):T.left+T.width;break;case Tat:L=l[w].x,D=Math.max(g[_].left+g[_].width,l[w].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;case Pat:switch(k){case Pat:D=L=T.left;break;case Cat:L=void 0!==y?Math.max(y,l[w].x):l[w].x,D=void 0!==y?Math.min(y,l[_].x):l[_].x;break;case Mat:D=L=T.left;break;case Tat:L=l[w].x<l[_].x?Math.min(g[_].left,l[w].x):l[w].x,D=Math.min(L,l[_].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;default:return this.path}h.push(...0===w?I:I.reverse())}else switch(n){case Mat:switch(s){case Mat:var F=T.top;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Tat:var N=T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:T.top+T.height}),h.push({x:l[1].x,y:T.top+T.height});break;case Cat:N=l[1].y<l[0].y&&l[1].x<l[0].x?l[0].x:T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;case Pat:N=T.left;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;default:return this.path}break;case Tat:switch(s){case Mat:N=T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:T.top}),h.push({x:l[1].x,y:T.top});break;case Tat:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Cat:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Pat:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;default:return this.path}break;case Pat:switch(s){case Mat:N=l[0].x>l[1].x&&l[0].y<l[1].y?l[1].x:T.left,F=l[0].x>l[1].x&&l[0].y<l[1].y?l[1].y:Math.min(T.top,l[0].y);h.push({x:N,y:l[0].y}),h.push({x:N,y:F}),h.push({x:l[1].x,y:F});break;case Tat:N=T.left,F=Math.max(T.top+T.height,l[0].y);h.push({x:N,y:l[0].y}),h.push({x:N,y:F}),h.push({x:l[1].x,y:F});break;case Cat:N=T.left+T.width;h.push({x:l[0].x,y:T.top}),h.push({x:N,y:T.top}),h.push({x:N,y:l[1].y});break;case Pat:N=T.left;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;default:return this.path}break;case Cat:switch(s){case Mat:F=l[0].y<l[1].y&&l[0].x<l[1].x?l[0].y:T.top;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Tat:F=l[0].y>l[1].y&&l[0].x<l[1].x?l[0].y:T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Cat:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Pat:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;default:return this.path}break;default:return this.path}return o&&h.push(o),[t,...h,e].filter(((t,e,r)=>{if(0===e)return!0;const n=r[e-1];return t.x!==n.x||t.y!==n.y})).filter(((t,e,r)=>{if(0===e||e>=r.length-1)return!0;const n=r[e-1],i=r[e+1];return!(t.x===n.x&&t.x===i.x||t.y===n.y&&t.y===i.y)}))}get nature(){return Wat}}mtt.register("ortholine",Uat);const Hat={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"image-src",name:"src",property:{displayField:"id",displayFullUrl:!0,baseUrlAlias:"$base_url",defaultStorage:"scene-image",storageFilters:{type:Array,value:[{name:"category",value:"image"}]},useUpload:!0}},{type:"select",label:"cross-origin",name:"crossOrigin",property:{options:["","anonymous","use-credentials"]}}],"value-property":"src",help:"scene/component/image-view"};class Gat extends(wtt(ytt)){static get noimage(){return Gat.NOIMAGE||(Gat.NOIMAGE=new Image,Gat.NOIMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABIBAMAAAD7Se1QAAAAIVBMVEUAAABHcEwBAQEREREBAQEEBAQGBgYLCwsDAwMDAwMICAi6HF9tAAAAC3RSTlNNAEAERiMYCS41Eac10lYAAAEgSURBVHhe7dY9asQwEAXgh7DNertNiJy48pIitY3SB7bYdk0ukL1BDDmA9gZecoH4pmFQ3MQayUMguPBrNPD4wD9TCMvJmt3M/AtYwXOlXiWgqADVCUBD46MAnGhMBaCiUQmAm8VA/Eh/eWl9Fn5WcxD+OLuRrUYJDKLluwH2InACUgkoACSdADxQc50Bytadb9RkM0CT13TcvlCT1HFg8UTHvasuUVACCa3El6u2UdD8LFTlKhUFFgA+d3dj10aABkUN72N3jAADCrJq7PIIsPidcxBoTHIIAjMFmyCwmGYIAA1P9gFgfCANAOsDSccCDW+uLDB+kLGg94OkZoAGkwsDDAe2DOg5oPxAg03rBR88OHpBz4N8UVeHFSwma74BTW6Ge4rIRa4AAAAASUVORK5CYII="),Gat.NOIMAGE}dispose(){super.dispose(),this._offcanvas=null,this._image=null}render(t){var{left:e,top:r,width:n,height:i,isGray:a=!1,alpha:s=1,src:o}=this.state;if(this.prepareIf(!this._image&&o),t.beginPath(),t.globalAlpha*=s,this._image&&this._image.complete)if(a&&this._offcanvas)t.drawImage(this._offcanvas,e,r,n,i);else try{t.drawImage(this._image,e,r,n,i)}catch(a){t.drawImage(Gat.noimage,e,r,n,i)}else!this.app.isViewMode&&t.drawImage(Gat.noimage,e,r,n,i)}get nature(){return Hat}get hasTextProperty(){return!1}ready(){super.ready(),this.prepareIf(!this._image&&this.state.src)}prepare(t,e){var{src:r,crossOrigin:n}=this.state;if(r){this._image=new Image;try{n&&(this._image.crossOrigin=n),this._image.src=this.app.url(r)||""}catch(t){return void e(t)}this._image.onload=()=>{if(this.get("isGray")){let t=this._image.width,e=this._image.height;this._offcanvas=mtt.createCanvas(t,e);let r=this._offcanvas.getContext("2d");r.drawImage(this._image,0,0);let n=function(t,e,r){try{var n=t.getImageData(0,0,e,r)}catch(t){return U7("Get Image Data Error: "+t.message),null}var i=n.data;for(let t=0;t<e*r*4;t+=4){let e=i[t],r=i[t+1],a=i[t+2],s=parseInt((e+r+a)/3);n.data[t]=s,n.data[t+1]=s,n.data[t+2]=s}return n}(r,t,e);r.putImageData(n,0,0)}t(this)},this._image.onerror=t=>{this._image&&!this._image.currentSrc&&(this._image=null),e(t)}}else t(this)}get src(){return this.get("src")}set src(t){this.set("src",t)}onchange(t,e){(t.hasOwnProperty("src")||t.hasOwnProperty("isGray"))&&(this._offcanvas=null,this._image=null,this.prepareIf(t.src))}ondropfile(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void(this.src=e[r])}}mtt.register("image-view",Gat);class Yat extends(fat(wtt(mtt))){is3dish(){return!0}prerender(){}}var Vat={},qat={},Xat={};Object.defineProperty(Xat,"__esModule",{value:!0});var $at=function(){function t(){}return t.bitsToNum=function(t){return t.reduce((function(t,e){return 2*t+e}),0)},t.byteToBitArr=function(t){for(var e=[],r=7;r>=0;r--)e.push(!!(t&1<<r));return e},t.lzwDecode=function(t,e){for(var r,n,i=0,a=function(t){for(var r=0,n=0;n<t;n++)e.charCodeAt(i>>3)&1<<(7&i)&&(r|=1<<n),i++;return r},s=[],o=1<<t,l=o+1,h=t+1,c=[],u=function(){c=[],h=t+1;for(var e=0;e<o;e++)c[e]=[e];c[o]=[],c[l]=null};;)if(n=r,(r=a(h))!==o){if(r===l)break;if(r<c.length)n!==o&&c.push(c[n].concat(c[r][0]));else{if(r!==c.length)throw new Error("Invalid LZW code.");c.push(c[n].concat(c[n][0]))}s.push.apply(s,c[r]),c.length===1<<h&&h<12&&h++}else u();return s},t}();Xat.SuperGifUtils=$at,Object.defineProperty(qat,"__esModule",{value:!0});var Kat=Xat,Qat=function(){function t(t,e){this.stream=t,this.handler=e}return t.prototype.parseCT=function(t){for(var e=[],r=0;r<t;r++)e.push(this.stream.readBytes(3));return e},t.prototype.readSubBlocks=function(){var t,e;e="";do{t=this.stream.readByte(),e+=this.stream.read(t)}while(0!==t);return e},t.prototype.parseHeader=function(){var t={};if(t.sig=this.stream.read(3),t.ver=this.stream.read(3),"GIF"!==t.sig)throw new Error("Not a GIF file.");t.width=this.stream.readUnsigned(),t.height=this.stream.readUnsigned();var e=Kat.SuperGifUtils.byteToBitArr(this.stream.readByte());t.gctFlag=e.shift(),t.colorRes=Kat.SuperGifUtils.bitsToNum(e.splice(0,3)),t.sorted=e.shift(),t.gctSize=Kat.SuperGifUtils.bitsToNum(e.splice(0,3)),t.bgColor=this.stream.readByte(),t.pixelAspectRatio=this.stream.readByte(),t.gctFlag&&(t.gct=this.parseCT(1<<t.gctSize+1)),this.handler.hdr&&this.handler.hdr(t)},t.prototype.parseExt=function(t){var e=this;switch(t.label=this.stream.readByte(),t.label){case 249:t.extType="gce",function(t){e.stream.readByte();var r=Kat.SuperGifUtils.byteToBitArr(e.stream.readByte());t.reserved=r.splice(0,3),t.disposalMethod=Kat.SuperGifUtils.bitsToNum(r.splice(0,3)),t.userInput=r.shift(),t.transparencyGiven=r.shift(),t.delayTime=e.stream.readUnsigned(),t.transparencyIndex=e.stream.readByte(),t.terminator=e.stream.readByte(),e.handler.gce&&e.handler.gce(t)}(t);break;case 254:t.extType="com",function(t){t.comment=e.readSubBlocks(),e.handler.com&&e.handler.com(t)}(t);break;case 1:t.extType="pte",function(t){e.stream.readByte(),t.ptHeader=e.stream.readBytes(12),t.ptData=e.readSubBlocks(),e.handler.pte&&e.handler.pte(t)}(t);break;case 255:t.extType="app",function(t){e.stream.readByte(),t.identifier=e.stream.read(8),t.authCode=e.stream.read(3),"NETSCAPE"===t.identifier?function(t){e.stream.readByte(),t.unknown=e.stream.readByte(),t.iterations=e.stream.readUnsigned(),t.terminator=e.stream.readByte(),e.handler.app&&e.handler.app.NETSCAPE&&e.handler.app.NETSCAPE(t)}(t):function(t){t.appData=e.readSubBlocks(),e.handler.app&&e.handler.app[t.identifier]&&e.handler.app[t.identifier](t)}(t)}(t);break;default:t.extType="unknown",function(t){t.data=e.readSubBlocks(),e.handler.unknown&&e.handler.unknown(t)}(t)}},t.prototype.parseImg=function(t){t.leftPos=this.stream.readUnsigned(),t.topPos=this.stream.readUnsigned(),t.width=this.stream.readUnsigned(),t.height=this.stream.readUnsigned();var e=Kat.SuperGifUtils.byteToBitArr(this.stream.readByte());t.lctFlag=e.shift(),t.interlaced=e.shift(),t.sorted=e.shift(),t.reserved=e.splice(0,2),t.lctSize=Kat.SuperGifUtils.bitsToNum(e.splice(0,3)),t.lctFlag&&(t.lct=this.parseCT(1<<t.lctSize+1)),t.lzwMinCodeSize=this.stream.readByte();var r=this.readSubBlocks();t.pixels=Kat.SuperGifUtils.lzwDecode(t.lzwMinCodeSize,r),t.interlaced&&(t.pixels=function(t,e){for(var r=new Array(t.length),n=t.length/e,i=function(n,i){var a=t.slice(i*e,(i+1)*e);r.splice.apply(r,[n*e,e].concat(a))},a=[0,4,2,1],s=[8,8,4,2],o=0,l=0;l<4;l++)for(var h=a[l];h<n;h+=s[l])i(h,o),o++;return r}(t.pixels,t.width)),this.handler.img&&this.handler.img(t)},t.prototype.parseBlock=function(){var t={};switch(t.sentinel=this.stream.readByte(),String.fromCharCode(t.sentinel)){case"!":t.type="ext",this.parseExt(t);break;case",":t.type="img",this.parseImg(t);break;case";":t.type="eof",this.handler.eof&&this.handler.eof(t);break;default:throw new Error("Unknown block: 0x"+t.sentinel.toString(16))}"eof"!==t.type&&setTimeout(this.parseBlock.bind(this),0)},t.prototype.parse=function(){this.parseHeader(),setTimeout(this.parseBlock.bind(this),0)},t}();qat.SuperGifParser=Qat;var Jat={};Object.defineProperty(Jat,"__esModule",{value:!0});var Zat=function(){function t(t){this.data=t,this.position=0}return t.prototype.readByte=function(){if(this.position>=this.data.length)throw new Error("Attempted to read past end of stream.");return this.data instanceof Uint8Array?this.data[this.position++]:255&this.data.charCodeAt(this.position++)},t.prototype.readBytes=function(t){for(var e=[],r=0;r<t;r++)e.push(this.readByte());return e},t.prototype.read=function(t){for(var e="",r=0;r<t;r++)e+=String.fromCharCode(this.readByte());return e},t.prototype.readUnsigned=function(){var t=this.readBytes(2);return(t[1]<<8)+t[0]},t}();Jat.SuperGifStream=Zat,Object.defineProperty(Vat,"__esModule",{value:!0});var tst=qat,est=Jat,rst=function(){function t(t,e){var r=this;for(var n in this.gifImgElement=t,this.options={autoPlay:!0},this.loading=!1,this.ready=!1,this.transparency=null,this.delay=null,this.disposalMethod=null,this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,this.playing=!0,this.forward=!0,this.ctxScaled=!1,this.frames=[],this.frameOffsets=[],this.initialized=!1,this.currentFrameIndex=-1,this.iterationCount=0,this.stepping=!1,this.handler={hdr:this.withProgress(this.doHdr.bind(this)),gce:this.withProgress(this.doGCE.bind(this)),com:this.withProgress(this.doNothing.bind(this)),app:{NETSCAPE:this.withProgress(this.doNothing.bind(this))},img:this.withProgress(this.doImg.bind(this)),eof:function(){r.pushFrame(),r.canvas.width=r.hdr.width*r.getCanvasScale(),r.canvas.height=r.hdr.height*r.getCanvasScale(),r.playerInit(),r.loading=!1,r.ready=!0,r.loadCallback&&r.loadCallback(r.gifImgElement)}},e)this.options[n]=e[n];this.onEndListener=e.onEnd,this.loopDelay=e.loopDelay||0,this.overrideLoopMode=null!=e.loopMode?e.loopMode:"auto",this.drawWhileLoading=null==e.drawWhileLoading||e.drawWhileLoading}return t.prototype.init=function(){var t=this.gifImgElement.parentNode,e=document.createElement("div");this.canvas=document.createElement("canvas"),this.canvasContext=this.canvas.getContext("2d"),this.tmpCanvas=document.createElement("canvas"),e.className=this.options.enclosingClass||"super-gif",e.appendChild(this.canvas),t&&(t.insertBefore(e,this.gifImgElement),t.removeChild(this.gifImgElement)),this.initialized=!0},t.prototype.loadSetup=function(t){return!this.loading&&(t&&(this.loadCallback=t),this.loading=!0,this.frames=[],this.clear(),this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,!0)},t.prototype.completeLoop=function(){this.onEndListener&&this.onEndListener(this.gifImgElement),this.iterationCount++,!1!==this.overrideLoopMode||this.iterationCount<0?this.doStep():(this.stepping=!1,this.playing=!1)},t.prototype.doStep=function(){if(this.stepping=this.playing,this.stepping){this.stepFrame(1);var t=10*this.frames[this.currentFrameIndex].delay;t||(t=100),0===this.getNextFrameNo()?(t+=this.loopDelay,setTimeout(this.completeLoop.bind(this),t)):setTimeout(this.doStep.bind(this),t)}},t.prototype.step=function(){this.stepping||setTimeout(this.doStep.bind(this),0)},t.prototype.putFrame=function(){var t;this.currentFrameIndex=parseInt(this.currentFrameIndex.toString(),10),this.currentFrameIndex>this.frames.length-1&&(this.currentFrameIndex=0),this.currentFrameIndex<0&&(this.currentFrameIndex=0),t=this.frameOffsets[this.currentFrameIndex],this.tmpCanvas.getContext("2d").putImageData(this.frames[this.currentFrameIndex].data,t.x,t.y),this.canvasContext.globalCompositeOperation="copy",this.canvasContext.drawImage(this.tmpCanvas,0,0)},t.prototype.playerInit=function(){this.loadErrorCause||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.options.autoPlay?this.step():(this.currentFrameIndex=0,this.putFrame()))},t.prototype.clear=function(){this.transparency=null,this.delay=null,this.lastDisposalMethod=this.disposalMethod,this.disposalMethod=null,this.frame=null},t.prototype.parseStream=function(t){try{new tst.SuperGifParser(t,this.handler).parse()}catch(t){this.handleError("parse")}},t.prototype.setSizes=function(t,e){this.canvas.width=t*this.getCanvasScale(),this.canvas.height=e*this.getCanvasScale(),this.tmpCanvas.width=t,this.tmpCanvas.height=e,this.tmpCanvas.style.width=t+"px",this.tmpCanvas.style.height=e+"px",this.tmpCanvas.getContext("2d").setTransform(1,0,0,1,0,0)},t.prototype.drawError=function(){this.canvasContext.fillStyle="black",this.canvasContext.fillRect(0,0,this.hdr.width,this.hdr.height),this.canvasContext.strokeStyle="red",this.canvasContext.lineWidth=3,this.canvasContext.moveTo(0,0),this.canvasContext.lineTo(this.hdr.width,this.hdr.height),this.canvasContext.moveTo(0,this.hdr.height),this.canvasContext.lineTo(this.hdr.width,0),this.canvasContext.stroke()},t.prototype.handleError=function(t){this.loadErrorCause=t,this.hdr={width:this.gifImgElement.width,height:this.gifImgElement.height},this.frames=[],this.drawError()},t.prototype.doHdr=function(t){this.hdr=t,this.setSizes(this.hdr.width,this.hdr.height)},t.prototype.doGCE=function(t){this.pushFrame(),this.clear(),this.transparency=t.transparencyGiven?t.transparencyIndex:null,this.delay=t.delayTime,this.disposalMethod=t.disposalMethod},t.prototype.pushFrame=function(){this.frame&&(this.frames.push({data:this.frame.getImageData(0,0,this.hdr.width,this.hdr.height),delay:this.delay}),this.frameOffsets.push({x:0,y:0}))},t.prototype.doImg=function(t){var e=this;this.frame||(this.frame=this.tmpCanvas.getContext("2d"));var r=this.frames.length,n=t.lctFlag?t.lct:this.hdr.gct;r>0&&(3===this.lastDisposalMethod?null!==this.disposalRestoreFromIdx?this.frame.putImageData(frames[this.disposalRestoreFromIdx].data,0,0):this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height):this.disposalRestoreFromIdx=r-1,2===this.lastDisposalMethod&&this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height));var i=this.frame.getImageData(t.leftPos,t.topPos,t.width,t.height);t.pixels.forEach((function(t,r){t!==e.transparency&&(i.data[4*r+0]=n[t][0],i.data[4*r+1]=n[t][1],i.data[4*r+2]=n[t][2],i.data[4*r+3]=255)})),this.frame.putImageData(i,t.leftPos,t.topPos),this.ctxScaled||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.ctxScaled=!0),this.drawWhileLoading&&(this.canvasContext.drawImage(this.tmpCanvas,0,0),this.drawWhileLoading=this.options.autoPlay),this.lastImg=t},t.prototype.doNothing=function(){},t.prototype.withProgress=function(t){return function(e){t(e)}},t.prototype.getNextFrameNo=function(){var t=this.forward?1:-1;return(this.currentFrameIndex+t+this.frames.length)%this.frames.length},t.prototype.stepFrame=function(t){this.currentFrameIndex=this.currentFrameIndex+t,this.putFrame()},t.prototype.getCanvasScale=function(){return this.options.maxWidth&&this.hdr&&this.hdr.width>this.options.maxWidth?this.options.maxWidth/this.hdr.width:window.devicePixelRatio||1},t.prototype.play=function(){this.playing=!0,this.step()},t.prototype.pause=function(){this.playing=!1},t.prototype.isPlaying=function(){return this.playing},t.prototype.getCanvas=function(){return this.canvas},t.prototype.isLoading=function(){return this.loading},t.prototype.isReady=function(){return this.ready},t.prototype.isAutoPlay=function(){return this.options.autoPlay},t.prototype.getLength=function(){return this.frames.length},t.prototype.getCurrentFrame=function(){return this.currentFrameIndex},t.prototype.moveTo=function(t){this.currentFrameIndex=t,this.putFrame()},t.prototype.loadURL=function(t,e){var r=this;if(this.loadSetup(e)){var n=new XMLHttpRequest;n.open("GET",t,!0),"overrideMimeType"in n?n.overrideMimeType("text/plain; charset=x-user-defined"):"responseType"in n?n.responseType="arraybuffer":n.setRequestHeader("Accept-Charset","x-user-defined"),n.onloadstart=function(){r.initialized||r.init()},n.onload=function(){if(200===n.status){var t=n.response;t.toString().indexOf("ArrayBuffer")>0&&(t=new Uint8Array(t));var e=new est.SuperGifStream(t);setTimeout((function(){r.parseStream(e)}),0)}else r.handleError("xhr - response")},n.onerror=function(){r.handleError("xhr")},n.send()}},t.prototype.load=function(t){this.loadURL(this.gifImgElement.src,t)},t}(),nst=Vat.SuperGif=rst;const ist={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"src",name:"src"},{type:"checkbox",label:"play",name:"play"}],"value-property":"src",help:"scene/component/gif-view"};class ast extends Yat{async oncreate_element(t){var{src:e,play:r}=this.state;this.onchangesrc(e),this.onchangeplay(r)}buildImg(){var t=this.element;t.innerHTML="";var e=document.createElement("img");return e.style.width="100%",e.style.height="100%",t.appendChild(e),e}onchange(t,e){super.onchange(t,e),"src"in t&&this.onchangesrc(t.src),"play"in t&&this.onchangeplay(t.play)}setElementProperties(t){}onchangeplay(t){var e=this._superGif;e&&e.isReady()&&(t?e.play():e.pause())}onchangesrc(t){var e=this.buildImg();t||(t="data:image/gif;base64,R0lGODlhYABIAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKio+Pj5iYmKCgoKampqurq66urrCwsLGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrOzs7S0tLa2tre3t7m5ubu7u7+/v8DAwMHBwcPDw8XFxcfHx8vLy8/Pz9LS0tXV1dfX193d3eTk5Onp6fj4+Pz8/P7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v///////////////////////////////////////////////////////////////////////////////yH5BAkAAPUAIf47R2VuZXJhdGVkIGJ5IGpzZ2lmIChodHRwczovL2dpdGh1Yi5jb20vYW50aW1hdHRlcjE1L2pzZ2lmLykALAAAAABgAEgAAAj+AGcJHEiwoMGDCBMqXMiwocOHECNKnEixosWLGDNq3Mixo8ePIEOKHEmypMmR9VKqXMmypcuXMGPKnJkSIs2bOHPqZGlzp8+fQOv1DEq0KMyhRpMmRaq0KVCmTqPmhCq1qkyqLrFRSyYwGTVsVo1iZXmNa8Fk18ISHasSm1mDycCq/ck2JTWF1ObSfTjz7cFken3WFbow8M7BDA3rHOwXruKpfGXeTZg3qDVrUge7RRg3KLZjx+Q2HVyvLNy0QaMJjBaVdD2tZr2K/mmNIObRkR+n9AsYt0Pddg1WXppb8bWDx1CLLW74GcJnSl3TtDY8Zu2Et4tKl7n52eyWnxXvhl7+26jqrspbnlfIWjtz2gWPZV95neH8veU9NxZYfbfD3kFt99J6Bnmn0mQO9XfYezrVxxlmx0GUXIAM4hSeffsxBN1TFd5E4Ef3QZbfTg6CNJ5gHXJ3TEntLThiTh+KFCJNAqZU4kgAitjQTheepOBMNcZI0oQ6JpbTjSZtiNN2PZ400IxHpdiSc07G911M0iFZZYtAStnWilUeBGVLrlEZpmM0elmPlmfO8iOZXl4DZpsGEYmll2bSWWCXLwJXVY1+urhjoGEBSuiSah6K36CKtpZoo4s9CimielZq6aWYZqrpppx26umnoIZ6UkAAOw=="),e.src=t,e.setAttribute("rel:animated_src",t),e.setAttribute("rel:auto_play",0),this._superGif=new nst(e,{autoPlay:!1}),this._superGif.init();for(const t of this.element.children)t.style.width="100%",t.style.height="100%";var r=this._superGif.getCanvas();r.style.width="100%",r.style.height="100%",this._superGif.load((()=>{setTimeout((()=>{this._superGif.moveTo(0),this.play&&this._superGif.play()}),100)}))}ondropfile(t,e){for(let r=0;r<t.length;r++)if(/\.gif$/.test(t[r].name))return void(this.src=e[r])}get src(){return this.getState("src")}set src(t){this.set("src",t)}get play(){return this.getState("play")}set play(t){this.setState("play",t)}get nature(){return ist}get tagName(){return"div"}}mtt.register("gif-view",ast);const sst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"attachment-selector",label:"src",name:"src",property:{category:"audio"}},{type:"checkbox",label:"started",name:"started"},{type:"checkbox",label:"loop",name:"loop"}],"value-property":"src",help:"scene/component/audio"};class ost extends(wtt(ytt)){static get image(){return ost.IMAGE||(ost.IMAGE=new Image,ost.IMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAMAAAC3Ycb+AAAAP1BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACzJYIvAAAAFHRSTlMA8BAwgNBgQKB/wCBwUJDg37CvXyUlBK8AABFYSURBVHja7NsBkqIwFIThTiAQgyBq3/+sm6p1tnamZkaTMhJJf1f4S/JeEIiIiIiIiIiIiIiIiEhD7Hg4BH84TpAKjJ4f3NFCtjVd+InXz2RTs+FXlxGylYHfcVfIJmb+YFWSLUyGVJKKBJJKUo+Rd6w63l/qzLuCkryO5fe0l2xk5mMWbe+v0fNBRqf7S3je6CipQ2ACr+dWcYEpzBFS1plpguatsnomMgdIQSOTuQ5SjmE6/UgK8szgdJIUM/FG41YlFmYJ2kkKsY5ZzAwBurHDk3WGeRY0bvYrGa1+rqNI22f7dS32ZnUK1GMr0eSK3mEc9dhKMxp+ZTo8kT2emOXS5LQ1kCxbJBocSd2k5PaIjMVzjWcdJPk9ooBnmzx1t5XbIxqBKpJ4NGTgzwKiGpK4do72gb+ZUMIYtCPm9WCPMsYTE5k2hq2ZvzujlCE1iRmwf3dvmRyKsT0T7b9I7HEPCpqCiqT2IIqaT1pI0noQZdlFC8l/PbYPAnRORT56VBEE6FXkb49agmByKhJ71BME6FsvEntUFQTdqekisUdlQWCXhovEHtUFAWbTapHYo8YgmFybO3vsUWcQYGmxSOxRbRAMprkisUfFQVKmrX18sxt7VB0ENjT1xir2qDxIwkFi3v89e+xRfxAMzfzzIfZ4hyAYDR9zwVuLPd4jCDrTwoLYGb5LEFi3/+E3rweR6urX20c/Fvls2Pvwm9mDSGIPhv8YPyGf3/eo9Ye7O8B2FIShAAooakEttex/rbODad5/yTHIAjqn505IQPv+Xz06dz+4VXORHEZcgAcB8updM8F6e25jBzwIkE07l+x8amMnPDp6nsNJ+BoZ7Q6F8egqAda9VEuRNlZjBzwYkMskdXR73okd8GBAJiKYjBcZKKqG9OiKDbgdfxJ5VhsBPDiQZhaouD3p4hfw4EAmwxisz3MSHwAPEmQ1TB1N+SmXWoAHC7JbZsWl/IxLLcCDBplNo3lrfMLsmwAPGmShAxX5/1vOEzjEz3iyfQ/hI36W4TctsUesOAifPdrQg8M++KYl95iCBkjI1r8634betBAPHZDTPFAmD3zLiHgogVTziMsahz0eIh5aIGHGRSJ2mFtHPR4iHhQIP2UvWGMf8wk74qEIEib7rLjPiBfxiAcCwp8V+Nae3uMdRhAPDIR/J5f/Q2DTcC+hIB7qIGEq3Ti9bx+sryMeAAgS70OK8G2kBD8L8QBAoLWU3g3vUVIc6D0txAMAsY+4jBWowXHO64gHBGKfYJ2T5qY1BxcL98BB+PQ+XiS9xxh9EQ8ChA6C5UXWIUoE9MBB8LVHQoS7ib8/dRn3sAcJ6bQRSdH96RDxIEH4QEX+AHF4LxHEAwUh12xyr1V8lwjiQYDYF8kuf1jluUQQDwrEvkhW8Wc6LhHUgwfhi4QPlHm7LRHawx4kpE191Dq8lgjhAYDQa1cftYrPEiE8OJDb40uqyzdQCA8WhAzL4G/PT4c3WrgHD2IfllGl53V37zsgHg5ApPNvVvq4Fn4spx4oiH1W3CwtEV+PDhEPJyBSkVX4aa7emkM83ICEKWpGM7wdvYCCeDgCEYpcwhLxczhEPFyBCEUWnRL5T6X59SBASBF+9l28TL5F7uEORCZyCUvEx+S7yT0cgoRVb9JaXLR1qUdfgksQ0fTbgmhFB20d8HAKEha14+F8f1sHPNyCiL6EqK+n20/rgIdjkFC0Ho1s6Gndvcc9ICkr/ey8/rHO6vp9KawL8DAFOV6l9Fyub7IbflsCag1qRfVsXWvxHjxIejU+BHZV6uvHD1XiEb++Bw8i+dNd+Wv0eCQmhcPhRPwUUt2DB5G1sfa1aeyzAuyJj9x2HjyIdKzIKw5SI14ieFtvo3kIQERj3lVhkUOnRD7AnjV5369QkAOJZeCH+Jh41xOLs73dQwAifY6dpxCCbjTDzLf1Bm1Y93tAIDOWXcLPvrHyr2hVoEAceEAgDQzB4jetk0/c2OXRHB48EJCpa4dgpYh2ETxtrshz7zx4ICCzfuTSDn8p/EOS9OTjwgMB+cABP3yWYuOPIofs33LigYCULlpZNXJppVU30Vf14kGAUCLijf1D71lN9FW9eFiA9KgZ8FPpPUsSnufGA+8hvAg2Kpz0nrX//qp+PIgpC3i6xJRITOye9fn1VT15ICCrVlQG5rywo0H8x965bVkNwmCYQ2kR6Gmb939WXV65dFnI/tPdjPBfO7XMN4EkTUJtqZp4sCJ1+8jwkhMu0KpMxFXFA8hlVfQSMxGH5mDK1VKV8QCyvTVtUiYyo7V358VStfGoAEFMhGYhEwloxZy9WKo2Hjwg5iSOvFDXeUYd33+PuVfHgwnEBWLocDJp+IIa2fyvperjwQRiXCKGosyXqoA+YfsIELuYu4HAt+msMknfDK4jfQJIzOZ2IPAQWJtFOhQKivR2IDZ6Awis7V0iLxqBI7uEZo19dakTogLSwKvf8yk8Jq6CGK0GKvWlatG7b7kkUU/Lo1gdXWn7/4E0j0qeJDpqN/ABqQcgJgdqURb4chjQktIugDS6wFFiz3JgaJj7AGJmholAe9YKhoZLJ0Ca6smjwJ4VwVN96gVIE5GM71kHaGKxGyAtRDaB2NBhLVmpHyANRKzDO28W7FS3HQFpaIWa8TrfCXQwegJSL5k+8M9UJ+pm9QTEnCIZrR0MDQeQ9ua0iCcYQaBTV0CqNXQW/yiyYG7W1heQanPaCkciBXuH1BkQJzHcDQxmpgGkPatl4WkbCXO/bW9AqlNg4H0PPMi6A1IxkQmOZ8D0ousNSMVEEuyreTAQ6Q7IRJeCX2YZQHhv6SrBOmpkM+YUzN0BqSRQCupmTeCP9wdkhiOREwtEzgGEsWcF9BhK9R8fQDiN7A8DiR0CKXQlj/q9IM8OgXjIzcKBlAHkD6FulgNzJwPIHwpo8mQAkX3LiPq9dKUMAQk9AqmcqmjuBAJCPQIpA4guIAsKJA0gnwNy3A4kDyBIHCEPxAwgf8gPILqA5AFEF5CxZX0lIHYc6rqADLf380BmFMgxgIzUyf8MJKLTRelKHgKy9wgkjfS7LiA0gKgC8vQn3HUA4RQ5LKPIAQciWbqIEg0YkLNDIHYUyqkCsmKN5vg3+W0AYTRATaPY+uu1IwS6UMGAlO6AFPjSCQMStaNh53cdcPG7Hx1Uupo+rx+Bltn1BuTAj5BptEV/bHAAwbnJMICwRmtUDOSEA8s4Rmtw3nITGD6TwUNoG0Ca7xi2YKSPj2eKXQFxQWKA2QbGMWEMMGseOb7C7T47uJS1JyAzVbTjqZdU3zbHzMXWS+qp4Fgn8Ahy/QCRGqQcwU1vGnN7fylboWn8Bzg//hyjxltvdcl45bwFfYKzFyBy11UU9BnjuoqfWizVlQXulpzBTNbaB5Aid+VRrkBFB630AMS9BC8FK2ggE7u/FGy1kvfcB9TKQufX5uUXNWl3EjvWCi4k/u9A3Ddq1CpTIQGe6VN1qd8ArcvDQNw3S41Kn6qQmOq5e7pRr+8fAYLiIJtFrrvYRMYL0q06vj8EZLXUriJzRY8H1xEagOCK7gkghRg6RQYO0I6aWPwIEAru80AiMWSdzAeuDXUKyr+WqpAID8hMHC1Ct8F4mUsQ6W8pJMICki0JHCBczAFdBl38G3VE6ErQhhWlih4LWrCSLpaqjggHiGe9mVjRY0YPoelyqcqIcIDEe97rqJFFH7FcLlUZEQ6Qg5plvZiBFNhtri1VFREGEC/Eg4nZoU5vqi1VFREGkIXDQ8xAIhzoT/WlKiLCAFIYPOQMxOPdjfWlKiLCADJRm3YGj+pDE2xktmmpaogwgMz8d8GrumZ4xzpbvinqISJ+hiTWm7wEqoJdI9JEV9JChAEkS3xCZzKecLcgN6YwlRBhAGmweTsblg6qKMM7Vmh321UQ4QAp1VfwhqVJIh+Wm03W0qV0EOEAybXtivkCmWrKeH2EZ/xBaSBCV2L9Re+LYSqJJIxDu1ew07U0EGEBcTtmHty4JuPtQhvLh1BAhK7Uvvq0GK484QZST0GvvFDqeSJ1IA0r2mfDljvqBoJ//rVsq7yZCA6kXgVkJ2f4ijIGMjOfMVsCBBORB2Jy+sM6ijNvaBUqmw/cStZ8EiKciHwp6Rp++88qmxXQeTUxDiJWJ9wSISvBicgXW+dypn1PqWTznlwgwdZdfiLHr5OELEAEASKvJFRE5JCPKbh8OxHdQKJU0crEzRXrJ/IEkFms6tGyrUw9kQeALFRXvK2iSzsRAAi6BLxM+60xdsqJAEBuXMAMxDLVp+gmAgC57/UT4qvVj3TVRCAgSAYL91aXtyNLzUQAIFhAiP8m0/NHOp+ILiBtPFKrs6bgSOcT0QTEB8nO3QR1yKslggKRf+m11UB0HOl8IlqAeCvauXuo8HnfIqIDyCw6G8XMcGiplMingMzCnbuHFp/3LSLPA4nUpqm5YkWNzwsQeQxIDsKjH5wVSU5qJPIJIIt4jjpqNBAekQeBfJOeHWS81FQoo4/I7UDcS3wUh0liTzLqiEgDqddx4ZHDrNZAACIAEMw88HPYWb0GAhABgEDmgf9Vb5oNBCByOxD3uqWYbCHVBgIQuRlIsbfwMEG5gQBE7gSyHMDsOayrxJvHBRC5B0hOxJH1nK4SlUE6QOR+IG6ju3iYQEqDdIDIzUDyZu/jMRHpS/OiRG4FkiPRfTw8kbrvIAJEACAIDpyHC1/GQHhEbgKSXwTyqIeEur6kixEBgABHOTr7YSX1MSFAhA0E307wUU76Y0KACAsI/tvCRzkF+iIuL0AEAYLbR2QOfvhKJ/obRESBxNt5rPSFXN4f7dyNdqMgEIbhAXWwJErT/e7/Wreb5HTT07QVgWSAeW5g7b4n8qOSUCRPEId4HP93SXp5dDNGRJFcQTxihSH+NW1Bb1cXKpIryJAwnG/zhl8ZcSP6jiKZghwRaaWLnP/AkcSKKJIniEcUs8QfjFLdEmRvkSxB4lfn0QN6DY+lshQpHiT96Dlr6r5hxRUpHST9ZEY71X7DOmOZQVZLsd5Q8wzrPxYYJDiKNqOBG1ZCkZKzrNXu6lHvkjChSFqQsdTPg45ApXtYaUXKr9TNuPcvqO2pVMkitFXAL2a79/qr3HQvVSTXUtofCl79RDXh5CDpw3pwu6+9kRlvtiI5VtPhmHLltT4EKVQkfb8pcOHrXqk6nBAksUjgpKtuYsskaxGKYT0+84uYgziE4YQgMdx0m8PRfis2MbL33PMXoVjD6PEunI4HSjDjStiJP08vQk9hZzQ7oH/geoLYCUBDW4rf4FqCDFt7THUO6B+4jiDn2XNTW7zf4hqCMND4BOsGyw+yAmh0x+QeFh7EeqD5Ce8nLDrI8NpbDyIWHIQNruo4GyAPlhrEzuixBxHLDDJMnfYgYolBricHNfjIdgMWF+Qyu+pkgX4HCwuymL57ELGkIHZG7z2IWE6Q5VV7vGMhQewbtMcZiwhyHj26ne9+xs8PcvDQHnFFqCD7Au0RW4TK+fOKqw4eoOcqYqgU53HR3/5uShFPCfKey9hFDyJO/vAi7RDZnp7X5igyUH72xSDW1E2Pn4tMRCQgR8vLwbgii4gcmLvqQcSPGtIPX3M08wn6I4qYQ94cM/Yw9Xxhmw+X/59wHrtMlX1AmIkzdyaaAnLg1Nnw8WGYSk40X/BOh4+El6LMSBnN2Cd0tPq4w/LJXGrMbCX06PZ2dcM65yzlNertShSHf3SzRAyPM332IcSAHUKPi8EHmXU0l8Uglmni0yipDoi16s+jJKejhywLooz68yiMEcHr2qM4h81CJ++VPJfTu5UwBpv4Pp9DJSi6MJx0bvUwiw4ewgT8zNR0LHUL+OccOpY/3ElzyGKD5pBlMJpDlsOkMythRoNbXh95PJsdA67MrMtAEYbjeDqNo+7oKqWUUkoppZRSSimllFJKFfMXp4vmSjB8n6sAAAAASUVORK5CYII="),ost.IMAGE}dispose(){super.dispose(),this.started=!1,delete this._audio}ready(){super.ready(),this._audio=new Audio,this._audio.addEventListener("canplay",(()=>{this.started&&this._audio.play()}));var{src:t="",loop:e=!1,started:r=!1}=this.state;this.onchangeSrc(t),this.onchangeLoop(e),this.onchangeStarted(r)}render(t){var{left:e,top:r,width:n,height:i,src:a}=this.state;t.beginPath(),this.drawImage(t,ost.image,e,r,n,i)}get nature(){return sst}get hasTextProperty(){return!1}get src(){return this.get("src")}set src(t){this.set("src",t)}get started(){return!!this.get("started")}set started(t){this.set("started",t)}start(){this._audio&&(this._audio.classList.add("active"),this._audio.play())}pause(){this._audio&&(this._audio.classList.remove("active"),this._audio.pause())}onchangeSrc(t){try{"data"!==String(t).substring(0,4)?this._audio.crossOrigin="use-credentials":this._audio.crossOrigin=null,this._audio.src="string"==typeof t?this.app.url(t):t}catch(t){return void console.error(t)}}onchangeStarted(t){const e=this._audio;t?4==e.readyState&&e.play():e.pause()}onchangeLoop(t){this._audio.loop=t}onchange(t,e){"src"in t&&this.onchangeSrc(t.src),"started"in t&&this.onchangeStarted(t.started),"loop"in t&&this.onchangeLoop(t.loop)}ondblclick(t){this.started=!this.started}ondropfile(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("audio/"))return void(this.src=e[r])}}mtt.register("audio",ost);class lst extends(wtt(mtt)){is3dish(){return!0}}mtt.register("text",lst);const hst=["refid","left","top","width","height","rotation","animation"];class cst extends yat{isGroup(){return!0}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});var r=hst.reduce(((e,r)=>(t.hasOwnProperty(r)&&(e[r]=t[r]),e)),{});return super.set(r)}capture(t,e,r){var n=super.capture(t,e,r);if(n!==this)return n}set bounds(t){if(this.__MUTATING__)super.bounds=t;else{var e=this.bounds,r=t.width/e.width,n=t.height/e.height;this.path=this.path.map((i=>({x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n}))),this.components&&this.components.forEach((t=>{if(t.mutable)t.mutatePath(null,(function(t){return t.map((function(t){return{x:t.x*r,y:t.y*n}}))}));else{let e=t.bounds,i=t.center,a={x:i.x*(1-r),y:i.y*(1-n)},s=e.width*(1-r),o=e.height*(1-n),l=-(a.x-s/2),h=-(a.y-o/2);t.bounds={left:e.left+l,top:e.top+h,width:e.width*r,height:e.height*n}}}))}}get focusible(){return!1}get bounds(){return super.bounds}get hasTextProperty(){return!1}isIdentifiable(){return!1}calculateBounds(){this.clearCache(),this.__MUTATING__=!0,this.mutateBounds((function(t){var e=mtt.union(this.components.map((t=>t.bounds)));return this.components.forEach((t=>{let r=t.bounds;t.bounds={left:r.left-e.left,top:r.top-e.top,width:r.width,height:r.height}})),{left:t.left+e.left,top:t.top+e.top,width:e.width,height:e.height}}),this),this.__MUTATING__=!1,this.parent.isGroup()&&this.parent.calculateBounds()}render(t){}postrender(t){var{top:e,left:r,scale:n}=this.state;t.translate(r,e),this.layout.drawables(this).forEach((e=>{e.draw(t)})),t.translate(-r,-e)}}mtt.register("group",cst);const ust={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"id-input",label:"ref",name:"ref"},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio"]}}],"value-property":"ref",help:"scene/component/local-ref"};class dst extends(wtt(ytt)){get ref(){var t=this.getState("ref");return t&&"string"==typeof t?this.root.findById(t):null}set ref(t){this.setState("ref",t)}get refScale(){let t=this.ref.bounds,e=this.bounds,r=e.width/t.width,n=e.height/t.height;return"both"===this.model.fit?{x:r,y:n}:{x:Math.min(r,n),y:Math.min(r,n)}}draw(t){this._drawing||(this._drawing=!0,super.draw(t),this._drawing=!1)}prerender(t){if(super.prerender(t),this.ref){let e=this.ref.center,r=this.center,n=this.refScale;t.translate(r.x,r.y),t.scale(n.x,n.y),t.translate(-e.x,-e.y)}}postrender(t){if(this.ref)return this.ref.postrender(t);super.postrender(t)}render(t){if(this.ref)return this.ref.render(t);this.state;var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),t.rect(e,r,n,i)}get nature(){return ust}get hasTextProperty(){return!1}}mtt.memoize(dst.prototype,"ref",!1),mtt.memoize(dst.prototype,"refScale",!1),mtt.register("local-ref",dst);class pst extends(fat(Gtt)){render(t){}is3dish(){return!0}get layout(){return Ett.get(this.get("layout"))||Mtt}}const fst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"scene-number",name:"ref",placeholder:"SCENE-1"},{type:"number",label:"round",name:"round",property:{min:0}},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio","width","height","none"]}},{type:"select",label:"mode",name:"mode",property:{options:["view","interaction"]}}],"value-property":"ref",help:"scene/component/global-ref"};class gst extends pst{dispose(){this._releaseRef(),super.dispose()}get nature(){return fst}get hasTextProperty(){return!1}get tagName(){return"div"}setElementProperties(t){var{mode:e="view",round:r=0}=this.state;t.style.pointerEvents="view"==e?"none":"inherit",t.style.borderRadius=r+"px"}ready(){super.ready(),this.fetchRef()}reposition(){if(!this.element)return;super.reposition();let t=this._element_bounds,{offsetWidth:e,offsetHeight:r}=this.element;if(this._element_bounds={offsetWidth:e,offsetHeight:r},(!t||t.offsetWidth!=e||t.offsetHeight!=r)&&this.ref&&this.root.target_element){let{fit:t="ratio"}=this.state;this.ref.fit(t)}}async fetchRef(){this._releaseRef();var{ref:t,fit:e="ratio"}=this.state;if(t){var r=this.app.refProvider;if(r&&t)try{this.__ref=await r.get(t,!0),this.__ref.target=this.element,this.__ref.fit(e),this.__ref.data=this.data}catch(t){U7(t)}}}get ref(){return this.__ref}set ref(t){this.setState("ref",t)}_releaseRef(){this.__ref&&this.__ref.release&&this.__ref.release(),delete this.__ref}onchange(t,e,r){super.onchange(t,e,r),"ref"in t&&this.fetchRef(),"fit"in t&&this.ref&&requestAnimationFrame((()=>{let{fit:t}=this.state;this.ref.fit(t)})),"data"in t&&this.ref&&requestAnimationFrame((()=>{this.ref.data=t.data}))}}mtt.register("global-ref",gst);const vst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"board",name:"board"},{type:"checkbox",label:"modal",name:"modal"},{type:"checkbox",label:"closable",name:"closable"},{type:"checkbox",label:"draggable",name:"draggable"},{type:"checkbox",label:"minimizable",name:"minimizable"},{type:"checkbox",label:"show",name:"show"},{type:"select",label:"location",name:"location",property:{options:["center","left-top","right-top","left-bottom","right-bottom","auto"]}},{type:"string",label:"title",name:"text"},{type:"data",label:"value",name:"value"}],help:"scene/component/popup"};class mst extends(wtt(ytt)){static get image(){return mst._image||(mst._image=new Image,mst._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAMAAABG8BK2AAADJmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNy4xLWMwMDAgNzkuZGFiYWNiYiwgMjAyMS8wNC8xNC0wMDozOTo0NCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIzLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RkM4QzQxNUMzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RkM4QzQxNUQzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpENjlENTQ3RjMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpENjlENTQ4MDMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsiUYSQAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAA51BMVEVHcEwzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzOguTm2AAAATHRSTlMARhB73r9B7YLrsqdE+0cq9Avzeg31eQx4aQ+Ks6aUd5DsYKixEX1w8vyT2VjoZ3YezY/cCEDvl+QTvRwJ0ifwK/5T/aw6+IuFuCImAcS6MQAAAeJJREFUWMPt2FlX2zAQhuHJYmOSFhIggbC0QNn3rS1dKXSH9///Hi58CJLxKIpEWi6YO8c5z4lG/nxGEXmu/1OVLGnhrFaSVQYg1SZetTTvUibqeFZ9QlfmvRWoV1VmCaCRzroXPpsuAjTV7gLUfPahBqD1OQMW/fazAWTKvQRI/ZgUSJR7U8CM/dHZ+/2VcatWdvdEZAaYUhiAwkerJXt0rnzXwdRKmHfDM0fHD5kxjTFyVLzVfvvirn7+cDJWjhy7c7XlYuwc6Urvu2tRhRypyhwAf1sKY+TIxfQA+H39q5wxc+RgVrcBduTmZTlj5khnDgH4IzKpMGaOVCbvyyvRGTNHGtPrKypjXirM5jb910I4k69oQeKY+77EMAcALEsck/+W6f71tyCma/ZFROTrJVwMy7wmf3bv6/MX+Dgkkysblvxps/dhOKZb6IvrTakzXXuPApnpYneDGOeKvJlaSXcDmA7AicQyW84VeTOnY+NdiWcG1uiZksFEHdyAlsJEjEkmkwGNsKHNZCJGSKtVTYC1tO022mnjwUBrMdXg8dreuOBhv7D/62/8lGZ1wLxXyZKOm+iUHIQintyny0TkaATHjYgcjeAoFpEje9R/nGPqIx2aw3NU9odCQI6e6x/VLY32cKQXVBnkAAAAAElFTkSuQmCC"),mst._image}ready(){super.ready(),this.show&&this.onchangeShow(!0)}render(t){var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),this.drawImage(t,mst.image,e,r,n,i)}onchange(t,e){"value"in t?this.show?this.onchangeShow(!0):this.show=!0:"show"in t&&this.onchangeShow(this.show)}onchangeShow(t){!this.app.isEditMode&&this.getState("board")&&(t?Rtt.show(this,this.getState("board"),{location:this.getState("location"),modal:this.getState("modal"),closable:this.getState("closable")||!1,draggable:this.getState("draggable")||!1,minimizable:this.getState("minimizable")||!1,title:this.text,data:this.value}):Rtt.hide(this))}get board(){return this.getState("board")}set board(t){this.set("board",t)}get show(){return this.getState("show")}set show(t){this.setState("show",t)}get started(){return this.getState("show")}set started(t){this.setState("show",t)}get value(){return this.getState("value")}set value(t){this.setState("value",t)}get hasTextProperty(){return!1}get nature(){return vst}}mtt.register("popup",mst);class yst extends mtt{render(t){var{path:e=[]}=this.state;if(!(e.length<=1)){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let r=1;r<e.length;r++)t.lineTo(e[r].x,e[r].y);t.closePath(),this.drawStroke(t)}}get path(){return this.model.path}set path(t){this.set("path",t)}contains(t,e){var r=this.state.path,n=!1;return r.forEach(((i,a)=>{let s=(a+r.length+1)%r.length,o=i.x,l=i.y,h=r[s].x,c=r[s].y;l>e!=c>e&&t<(h-o)*(e-l)/(c-l)+o&&(n=!n)})),n}}mtt.register("path",yst);const bst={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/triangle"};class wst extends ytt{contains(t,e){var{x1:r,y1:n,x2:i,y2:a,x3:s,y3:o}=this.state,l=[r,n,i,a,s,o],h=!1;for(let r=0;r<l.length;r+=2){let n=(r+2)%l.length,i=l[r],a=l[r+1],s=l[n+1];a>e!=s>e&&t<(l[n]-i)*(e-a)/(s-a)+i&&(h=!h)}return h}get mutable(){return!0}get path(){var{x1:t,y1:e,x2:r,y2:n,x3:i,y3:a}=this.state;return[{x:t,y:e},{x:r,y:n},{x:i,y:a}]}set path(t){this.set({x1:t[0].x,y1:t[0].y,x2:t[1].x,y2:t[1].y,x3:t[2].x,y3:t[2].y})}get nature(){return bst}}mtt.memoize(wst.prototype,"path",!1),mtt.register("triangle",wst);const xst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"}],help:"scene/component/donut"};var Ast={ondragmove:function(t,e,r){r.controls;var{cx:n,rx:i}=r.model;i=Math.abs(i);var a=(r.transcoordP2S(t.x,t.y).x-n)/i*100;a=a>=100||a<=-100?100:Math.abs(a),r.set({ratio:a})}};class _st extends Lat{is3dish(){return!1}render(t){var{ratio:e=50,cx:r,cy:n,rx:i,ry:a,startAngle:s,endAngle:o,anticlockwise:l}=this.state;i=Math.abs(i),a=Math.abs(a),t.beginPath(),t.ellipse(r,n,i,a,0,s||0,o||2*Math.PI,l),t.moveTo(r+i/100*e,n),t.ellipse(r,n,i/100*e,a/100*e,0,s||0,o||2*Math.PI,!0)}contains(t,e){var{cx:r,cy:n,rx:i,ry:a,ratio:s}=this.state,o=(t-r)/(2*(i=Math.abs(i))-.5),l=(e-n)/(2*(a=Math.abs(a))-.5),h=(t-r)/(i/100*s*2-.5),c=(e-n)/(a/100*s*2-.5),u=!1;return o*o+l*l<.25&&h*h+c*c>.25&&(u=!u),u}get controls(){var{cx:t,cy:e,rx:r,ratio:n}=this.state;return[{x:t+(r=Math.abs(r))/100*n,y:e,handler:Ast}]}get nature(){return xst}}mtt.memoize(_st.prototype,"controls",!1),mtt.register("donut",_st);const kst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"},{type:"number",label:"wing",name:"wing",property:"wing"}],help:"scene/component/star"};var Sst,Est,Mst,Tst,Cst,Pst,Ist,Rst,Ost,Lst,Dst,Fst,Nst,jst={ondragmove:function(t,e,r){r.controls;var{cy:n,ry:i}=r.model,a=(r.transcoordP2S(t.x,t.y).y-n)/i*100+100;a>=100?a=100:a<=0&&(a=0),r.set({ratio:a})}};class Bst extends Lat{is3dish(){return!1}render(t){var{ratio:e=30,wing:r=5,cx:n,cy:i,rx:a,ry:s,startAngle:o,endAngle:l,anticlockwise:h}=this.state;if(r<3)return;const c=1.5707963267948966;var u=2*Math.PI/r,d=a-e/100*a,p=s-e/100*s;t.save(),t.beginPath(),t.translate(n,i),t.moveTo(a*Math.cos(-c),s*Math.sin(-c)),t.lineTo((a-d)*(Math.cos(u-c)+Math.cos(0-c))/2,(s-p)*(Math.sin(u-c)+Math.sin(0-c))/2);for(var f=1;f<r;f++)t.lineTo(a*Math.cos(u*f-c),s*Math.sin(u*f-c)),t.lineTo((a-d)*(Math.cos(u*(f+1)-c)+Math.cos(u*f-c))/2,(s-p)*(Math.sin(u*(f+1)-c)+Math.sin(u*f-c))/2);t.closePath(),t.restore()}get controls(){var{cx:t,cy:e,ry:r,ratio:n}=this.state;return[{x:t,y:e-r+r*(n/100),handler:jst}]}get nature(){return kst}}mtt.memoize(Bst.prototype,"controls",!1),mtt.register("star",Bst);
44
+ `,this.element)}startDragging(t){t.preventDefault(),t.stopPropagation();let e=t.clientX,r=t.clientY;const{left:n,top:i}=this.bounds,a=this.rootModel.overlay.style.transform.match(/scale\(([^,]+),\s*([^)]+)\)/),s=a?parseFloat(a[1]):1,o=a?parseFloat(a[2]):s,l=t=>{t.preventDefault(),t.stopPropagation();const a=(t.clientX-e)/s,l=(t.clientY-r)/o;this.setState({left:n+a,top:i+l})},h=t=>{t.preventDefault(),t.stopPropagation(),this.element.removeEventListener("mousemove",l),this.element.removeEventListener("mouseup",h),document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",h)};this.element.addEventListener("mousemove",l),this.element.addEventListener("mouseup",h),document.addEventListener("mousemove",l),document.addEventListener("mouseup",h)}toggleMinimizable(){const{minimized:t}=this.state;this.setState("minimized",!t)}onchangeMinimized(){const{minimized:t}=this.state;t?this.setState("height",20):this.setState("height",this.get("height"))}closeContainer(){this.setState("hidden",!0)}}mtt.register("container",bat);const wat=Math.sqrt(3),xat=2;function Aat(t,e,r,n,i){var a,s,o,l,h=5+i,c=r.x,u=r.y,d=n.x,p=n.y;if(Math.abs(c-d)>h&&Math.abs(u-p)>h){var f=(p-u)/(d-c),g=u-f*c;if(Math.abs(e-(f*t+g))>h)return!1}return c>d?(s=c,a=d):(s=d,a=c),u>p?(l=u,o=p):(l=p,o=u),!(s+5<t)&&(!(a-5>t)&&(!(l+5<e)&&!(o-5>e)))}function _at(t,e,r,n=2){for(let i=0;i<r.length-1;i++)if(Aat(t,e,r[i],r[i+1],n))return!0;return!1}function kat(t,e,r,n){if("arrow"!=t.slice(-5))return r;var i=Math.atan2(n.y-r.y,n.x-r.x),a=1.5*e;return{x:r.x+Math.cos(i)*a,y:r.y+Math.sin(i)*a}}function Sat(t,e,r){var{lineWidth:n=xat,strokeStyle:i="#000000",lineCap:a=!1,alpha:s=1,begin:o="none",end:l="none",beginSize:h="size5",endSize:c="size5"}=r;if(("none"!=o||"none"!=l)&&(n=Number(n)||xat,t.lineCap=a,t.lineWidth=n,t.strokeStyle=i,t.fillStyle=i,t.globalAlpha*=s,"none"!=o&&Eat(t,e[0],e[1],n,o,Mat(h,n)),"none"!=l)){let r=e.length;Eat(t,e[r-1],e[r-2],n,l,Mat(c,n))}}function Eat(t,e,r,n,i,a){var{x:s,y:o}=e,l=Math.atan2(r.y-o,r.x-s);switch(t.beginPath(),t.translate(s,o),t.rotate(l),i){case"oval":t.ellipse(0,0,a.X,a.Y,0,0,2*Math.PI),t.fill();break;case"diamond":t.moveTo(-a.X,0),t.lineTo(0,-a.Y),t.lineTo(a.X,0),t.lineTo(0,a.Y),t.fill();break;case"arrow":t.moveTo(0,0),t.lineTo(wat*a.X,-a.Y),t.lineTo(wat*a.X,a.Y),t.fill();break;case"sharp-arrow":t.moveTo(0,0),t.lineTo(wat*a.X,-a.Y),t.lineTo(-a.X/1.5+wat*a.X,0),t.lineTo(wat*a.X,a.Y),t.fill();break;case"open-arrow":t.moveTo(wat*a.X+n,-a.Y),t.lineTo(n,0),t.lineTo(wat*a.X+n,a.Y),t.stroke()}t.rotate(-l),t.translate(-s,-o),t.closePath()}function Mat(t,e){let r={};switch(e*=1.2,t){case"size1":r.X=e,r.Y=e;break;case"size2":r.X=1.5*e,r.Y=e;break;case"size3":r.X=2*e,r.Y=e;break;case"size4":r.X=e,r.Y=1.5*e;break;case"size5":default:r.X=1.5*e,r.Y=1.5*e;break;case"size6":r.X=2*e,r.Y=1.5*e;break;case"size7":r.X=e,r.Y=2*e;break;case"size8":r.X=1.5*e,r.Y=2*e;break;case"size9":r.X=2*e,r.Y=2*e}return r}const Tat="N",Cat="S",Pat="E",Iat="W";class Rat{constructor({component:t,anchor:e,position:r,self:n}){this.component=t,this._anchorName=e,this._position=r,this.self=n}get position(){const t=this.anchor;if(t){var{position:e}=t;const r=this.component.transcoordS2T(e.x,e.y);return this.self.transcoordT2P(r.x,r.y)}return this._position}set position({x:t,y:e}){this._position={x:t,y:e}}get anchor(){return this.component?.findAnchor(this._anchorName)}get direction(){const t=this.component.bounds,e=this.anchor;if(!e)return Pat;const r=e.position;return r.y<=t.top?Tat:r.y>=t.top+t.height?Cat:r.x<=t.left?Iat:Pat}get boundaryPosition(){const t=this.anchor;if(t){var{position:e}=t,r=0,n=0;switch(this.direction){case Cat:n=20;break;case Tat:n=-20;break;case Iat:r=-20;break;default:r=20}e={x:e.x+r,y:e.y+n};const i=this.component.transcoordS2T(e.x,e.y);return this.self.transcoordT2P(i.x,i.y)}}}class Oat extends mtt{isLine(){return!0}replaceRefids(t){["from","to"].forEach((e=>{const r=this.get(e);if(r?.component){const n=t.get(r.component)||r.component;this.set(e,{...r,component:n})}}))}get fromEnd(){if(this.parent&&!this._fromEnd){const{component:t,anchor:e,position:r}=this.getState("from")||{};if(!t)return;const n=this.root?.findByRefid(t);if(!n)return;this._fromEnd=new Rat({component:n,fromto:"from",anchor:e,position:r,self:this})}return this._fromEnd}get from(){return this.getState("from")}set from(t){delete this._fromEnd,this.set("from",t)}get toEnd(){if(this.parent&&!this._toEnd){const{component:t,anchor:e,position:r}=this.getState("to")||{};if(!t)return;const n=this.root?.findByRefid(t);if(!n)return;this._toEnd=new Rat({component:n,fromto:"to",anchor:e,position:r,self:this})}return this._toEnd}get to(){return this.getState("to")}set to(t){delete this._toEnd,this.set("to",t)}move({x:t,y:e},r){r&&(this.from={position:this._fromEnd?.position||this.getState("from")?.position||{x:0,y:0}},this.to={position:this._toEnd?.position||this.getState("to")?.position||{x:0,y:0}}),super.move({x:t,y:e},r)}render(t){var{begin:e="none",end:r="none",lineWidth:n,round:i=0}=this.state,a=this.drawPath;Sat(t,a,this.state),t.beginPath();var s=kat(e,n,a[0],a[1]),o=kat(r,n,a[a.length-1],a[a.length-2]);a=[s,...a.slice(1,-1),o];var l={x:s.x,y:s.y};t.moveTo(s.x,s.y);for(var h=1;h<a.length;h++){const e=l;l=a[h];const r=a[h+1];if(e.x===l.x&&e.y===l.y)continue;if(!r){t.lineTo(l.x,l.y);break}var c=0!==(p=Math.sqrt((e.x-l.x)*(e.x-l.x)+(e.y-l.y)*(e.y-l.y)))?Math.atan2(e.x-l.x,e.y-l.y):0,u=Math.sin(c)*Math.min(i,p/2)+l.x,d=Math.cos(c)*Math.min(i,p/2)+l.y;const n=i>0||0!==p?{x:u,y:d}:l;var p;c=0!==(p=Math.sqrt((r.x-l.x)*(r.x-l.x)+(r.y-l.y)*(r.y-l.y)))?Math.atan2(r.x-l.x,r.y-l.y):0,u=Math.sin(c)*Math.min(i,p/2)+l.x,d=Math.cos(c)*Math.min(i,p/2)+l.y;const s=i>0||0!==p?{x:u,y:d}:l;t.lineTo(n.x,n.y),i>0&&t.quadraticCurveTo(l.x,l.y,s.x,s.y)}this.drawStroke(t)}contains(t,e){var{lineWidth:r}=this.state;return _at(t,e,this.drawPath,r)}get resizable(){return!1}get mutable(){return!0}get rotatable(){return!1}get path(){const{from:t,to:e}=this.state;var{x1:r,y1:n,x2:i,y2:a}=this.state;return[this.fromEnd?.position||t?.position||{x:r,y:n},this.toEnd?.position||e?.position||{x:i,y:a}]}set path(t){const[e,r]=t,{from:n,to:i}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...n,position:e},to:{...i,position:r}})}get textBounds(){var t,e,r=this.drawPath,n=0;for(let o=1;o<r.length;o++){var i=r[o-1],a=r[o],s=(i.x-a.x)*(i.x-a.x)+(i.y-a.y)*(i.y-a.y);s>n&&(n=Math.ceil(s),t=i,e=a)}var{paddingTop:o,paddingLeft:l,paddingRight:h,paddingBottom:c}=this.state;return c||=0,o||=0,l||=0,h||=0,{left:Math.min(t.x,e.x)+l,top:Math.min(t.y,e.y)+o,width:Math.max(Math.abs(t.x-e.x)-l-h,0),height:Math.max(Math.abs(t.y-e.y)-o-c,0)}}get decorators(){return["decotag"]}}Oat.getTipNeckPos=kat,Oat.containedInPath=_at,Oat.drawEndTips=Sat,mtt.register("line",Oat);const Lat={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"angle",label:"start-angle",name:"startAngle",property:"startAngle"},{type:"angle",label:"end-angle",name:"endAngle",property:"endAngle"}],"value-property":"text"};class Dat extends(Qtt(ytt)){is3dish(){return!0}render(t){var{cx:e,cy:r,rx:n,ry:i,startAngle:a,endAngle:s,anticlockwise:o}=this.state;t.beginPath(),t.ellipse(e,r,Math.abs(n),Math.abs(i),0,a||0,s||2*Math.PI,o),void 0!==a&&void 0!==s&&(t.lineTo(e,r),t.closePath())}get path(){var{cx:t,cy:e,rx:r,ry:n}=this.state;return[{x:t-r,y:e-n},{x:t+r,y:e-n},{x:t+r,y:e+n},{x:t-r,y:e+n}]}set path(t){var e=t[0],r=t[2];this.set({cx:e.x+(r.x-e.x)/2,cy:e.y+(r.y-e.y)/2,rx:(r.x-e.x)/2,ry:(r.y-e.y)/2})}contains(t,e){var{cx:r,cy:n,rx:i,ry:a}=this.state,s=(t-r)/(2*i-.5),o=(e-n)/(2*a-.5);return s*s+o*o<.25}outline(t){return function(t,e){var{cx:r,cy:n,rx:i,ry:a}=t.model,s=2*Math.PI*e,o=r+i*Math.cos(s),l=n+a*Math.sin(s);return t.transcoordS2T(o,l)}(this,t)}get anchors(){return function(t){var{left:e,top:r,width:n,height:i}=t.bounds,a=e+n/2,s=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:s}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:s}}]}(this)}get nature(){return Lat}}mtt.memoize(Dat.prototype,"path",!1),mtt.register("ellipse",Dat);var Fat={ondragstart:function(t,e,r){r.mutatePath(null,(function(r){r.splice(e+1,0,t)}))},ondragmove:function(t,e,r){r.mutatePath(null,(function(r){r[e+1]=t}))},ondragend:function(t,e,r){}};const Nat={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polygon"};class jat extends ytt{is3dish(){return!0}get mutable(){return!0}get pathExtendable(){return!0}get path(){return this.state.path}set path(t){this.set("path",t)}contains(t,e){var r=this.state.path,n=!1;return r.forEach(((i,a)=>{let s=(a+r.length+1)%r.length,o=i.x,l=i.y,h=r[s].x,c=r[s].y;l>e!=c>e&&t<(h-o)*(e-l)/(c-l)+o&&(n=!n)})),n}get controls(){var t=this.path;return t.map(((e,r)=>{let n=t[r+1>=t.length?0:r+1];return{x:(e.x+n.x)/2,y:(e.y+n.y)/2,handler:Fat}}))}get nature(){return Nat}}mtt.memoize(jat.prototype,"controls",!1),mtt.register("polygon",jat);var Bat={ondragstart:function(t,e,r){r.mutatePath(null,(function(r){r.splice(e,0,t)}))},ondragmove:function(t,e,r){r.mutatePath(null,(function(r){r[e]=t}))},ondragend:function(t,e,r){}};const zat={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polyline"};class Wat extends Oat{get pathExtendable(){return!0}get path(){const{from:t,to:e}=this.state,{path:r}=this.state;return[this.fromEnd?.position||t?.position||r[0],...r.slice(1,-1),this.toEnd?.position||e?.position||r[r.length-1]]}set path(t){const{from:e,to:r}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...e,position:t[0]},to:{...r,position:t[t.length-1]},path:t})}get controls(){var t=this.path,e=[];for(let r=0;r<t.length-1;r++){let n=t[r],i=t[r+1];0==r&&e.push({x:n.x,y:n.y,handler:Bat}),e.push({x:(n.x+i.x)/2,y:(n.y+i.y)/2,handler:Bat}),r==t.length-2&&e.push({x:i.x,y:i.y,handler:Bat})}return e}get nature(){return zat}}mtt.register("polyline",Wat);const Uat={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/ortholine"};class Hat extends Oat{get pathExtendable(){return!1}get drawPath(){const t=this.path[0],e=this.path[1],{component:r,direction:n,boundaryPosition:i=t}=this.fromEnd||{},{component:a,direction:s,boundaryPosition:o=e}=this.toEnd||{};var l=[i,o],h=[];i&&h.push(i);var c=r?.bounds;if(c){var u=r.transcoordS2T(c.left,c.top);u=this.transcoordT2P(u.x,u.y),c={...c,left:u.x,top:u.y}}var d=c?{left:c.left-20,top:c.top-20,width:c.width+40,height:c.height+40}:{left:i.x,top:i.y,width:0,height:0};c=c||d;var p=a?.bounds;if(p){u=a.transcoordS2T(p.left,p.top);u=this.transcoordT2P(u.x,u.y),p={...p,left:u.x,top:u.y}}var f=p?{left:p.left-20,top:p.top-20,width:p.width+40,height:p.height+40}:{left:o.x,top:o.y,width:0,height:0};p=p||f;var g=[d,f];const v=d.left>f.left?f.left:d.left,m=d.top>f.top?f.top:d.top;var y,b,w,x,A,_,k,S,E,M,T={left:v,top:m,width:d.left+d.width>f.left+f.width?d.left+d.width-v:f.left+f.width-v,height:d.top+d.height>f.top+f.height?d.top+d.height-m:f.top+f.height-m},C=0,P=0;c.left+c.width<p.left?(x=0,A=1,E=n,M=s,y=(c.left+c.width+p.left)/2,C=p.left-y):p.left+p.width<c.left&&(x=1,A=0,E=s,M=n,y=(c.left+p.width+p.left)/2,C=c.left-y),c.top+c.height<p.top?(w=0,_=1,k=n,S=s,b=(c.top+c.height+p.top)/2,P=p.top-b):p.top+p.height<c.top&&(w=1,_=0,k=s,S=n,b=(c.top+p.height+p.top)/2,P=c.top-b);var I=[];if(y&&C>P){switch(M){case Iat:switch(E){case Pat:I.push({x:y,y:l[x].y}),I.push({x:y,y:l[A].y});break;case Iat:var R=g[x].top+g[x].height/2>l[A].y?Math.min(g[x].top,l[A].y):Math.max(g[x].top+g[x].height,l[A].y);I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:l[A].y});break;case Tat:case Cat:R=E===Cat?Math.max(l[x].y,l[A].y):Math.min(l[x].y,l[A].y);I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:l[A].y});break;default:return this.path}break;case Pat:switch(E){case Pat:var O=R=l[x].y<l[A].y?Math.min(g[A].top,l[x].y):Math.max(g[A].top+g[A].height,l[x].y);break;case Iat:O=R=void 0!==b?b:l[x].y<l[A].y?T.top-.5*C:T.top+T.height+.5*C;break;case Cat:O=R=void 0!==b?Math.max(b,l[x].y):T.top+T.height;break;case Tat:O=R=b?Math.min(b,g[x].top):T.top;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;case Cat:switch(E){case Pat:R=l[x].y,O=l[x].y>l[A].y?l[x].y:g[A].top+g[A].height;break;case Iat:O=R=b?Math.max(b,g[A].top+g[A].height):T.top+T.height;break;case Cat:O=R=T.top+T.height;break;case Tat:R=b?Math.min(b,g[x].top):g[x].top,O=b?Math.max(b,g[A].top+g[A].height):g[A].top+g[A].height;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;case Tat:switch(E){case Pat:R=l[x].y,O=l[x].y<l[A].y?l[x].y:g[A].top;break;case Iat:O=R=b?Math.min(b,g[A].top):T.top;break;case Cat:R=void 0!==b?Math.max(b,l[x].y):l[x].y,O=void 0!==b?Math.min(b,l[A].y):l[A].y;break;case Tat:O=R=T.top;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;default:return this.path}h.push(...0===x?I:I.reverse())}else if(b){switch(S){case Tat:switch(k){case Cat:I.push({x:l[w].x,y:b}),I.push({x:l[_].x,y:b});break;case Tat:var L=g[w].left+g[w].width/2>l[_].x?Math.min(g[w].left,l[_].x):Math.max(g[w].left+g[w].width,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;case Iat:L=Math.min(l[w].x,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;case Pat:L=Math.max(l[w].x,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;default:return this.path}break;case Cat:switch(k){case Iat:var D=L=T.left;break;case Pat:D=L=void 0!==y?Math.max(y,l[w].x):T.left+T.width;break;case Tat:D=L=void 0!==y?y:l[w].x<l[_].x?T.left-.5*P:T.left+T.width+.5*P;break;case Cat:L=l[w].x,D=l[w].x<l[_].x?Math.min(g[_].left,l[w].x):Math.max(g[_].left+g[_].width,l[w].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;case Pat:switch(k){case Iat:L=void 0!==y?Math.min(y,l[w].x):l[w].x,D=void 0!==y?Math.max(y,l[_].x):l[_].x;break;case Pat:D=L=T.left+T.width;break;case Tat:D=L=void 0!==y?Math.max(y,l[_].x):T.left+T.width;break;case Cat:L=l[w].x,D=Math.max(g[_].left+g[_].width,l[w].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;case Iat:switch(k){case Iat:D=L=T.left;break;case Pat:L=void 0!==y?Math.max(y,l[w].x):l[w].x,D=void 0!==y?Math.min(y,l[_].x):l[_].x;break;case Tat:D=L=T.left;break;case Cat:L=l[w].x<l[_].x?Math.min(g[_].left,l[w].x):l[w].x,D=Math.min(L,l[_].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;default:return this.path}h.push(...0===w?I:I.reverse())}else switch(n){case Tat:switch(s){case Tat:var F=T.top;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Cat:var N=T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:T.top+T.height}),h.push({x:l[1].x,y:T.top+T.height});break;case Pat:N=l[1].y<l[0].y&&l[1].x<l[0].x?l[0].x:T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;case Iat:N=T.left;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;default:return this.path}break;case Cat:switch(s){case Tat:N=T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:T.top}),h.push({x:l[1].x,y:T.top});break;case Cat:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Pat:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Iat:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;default:return this.path}break;case Iat:switch(s){case Tat:N=l[0].x>l[1].x&&l[0].y<l[1].y?l[1].x:T.left,F=l[0].x>l[1].x&&l[0].y<l[1].y?l[1].y:Math.min(T.top,l[0].y);h.push({x:N,y:l[0].y}),h.push({x:N,y:F}),h.push({x:l[1].x,y:F});break;case Cat:N=T.left,F=Math.max(T.top+T.height,l[0].y);h.push({x:N,y:l[0].y}),h.push({x:N,y:F}),h.push({x:l[1].x,y:F});break;case Pat:N=T.left+T.width;h.push({x:l[0].x,y:T.top}),h.push({x:N,y:T.top}),h.push({x:N,y:l[1].y});break;case Iat:N=T.left;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;default:return this.path}break;case Pat:switch(s){case Tat:F=l[0].y<l[1].y&&l[0].x<l[1].x?l[0].y:T.top;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Cat:F=l[0].y>l[1].y&&l[0].x<l[1].x?l[0].y:T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Pat:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case Iat:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;default:return this.path}break;default:return this.path}return o&&h.push(o),[t,...h,e].filter(((t,e,r)=>{if(0===e)return!0;const n=r[e-1];return t.x!==n.x||t.y!==n.y})).filter(((t,e,r)=>{if(0===e||e>=r.length-1)return!0;const n=r[e-1],i=r[e+1];return!(t.x===n.x&&t.x===i.x||t.y===n.y&&t.y===i.y)}))}get nature(){return Uat}}mtt.register("ortholine",Hat);const Gat={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"image-src",name:"src",property:{displayField:"id",displayFullUrl:!0,baseUrlAlias:"$base_url",defaultStorage:"scene-image",storageFilters:{type:Array,value:[{name:"category",value:"image"}]},useUpload:!0}},{type:"select",label:"cross-origin",name:"crossOrigin",property:{options:["","anonymous","use-credentials"]}}],"value-property":"src",help:"scene/component/image-view"};class Yat extends(wtt(ytt)){static get noimage(){return Yat.NOIMAGE||(Yat.NOIMAGE=new Image,Yat.NOIMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABIBAMAAAD7Se1QAAAAIVBMVEUAAABHcEwBAQEREREBAQEEBAQGBgYLCwsDAwMDAwMICAi6HF9tAAAAC3RSTlNNAEAERiMYCS41Eac10lYAAAEgSURBVHhe7dY9asQwEAXgh7DNertNiJy48pIitY3SB7bYdk0ukL1BDDmA9gZecoH4pmFQ3MQayUMguPBrNPD4wD9TCMvJmt3M/AtYwXOlXiWgqADVCUBD46MAnGhMBaCiUQmAm8VA/Eh/eWl9Fn5WcxD+OLuRrUYJDKLluwH2InACUgkoACSdADxQc50Bytadb9RkM0CT13TcvlCT1HFg8UTHvasuUVACCa3El6u2UdD8LFTlKhUFFgA+d3dj10aABkUN72N3jAADCrJq7PIIsPidcxBoTHIIAjMFmyCwmGYIAA1P9gFgfCANAOsDSccCDW+uLDB+kLGg94OkZoAGkwsDDAe2DOg5oPxAg03rBR88OHpBz4N8UVeHFSwma74BTW6Ge4rIRa4AAAAASUVORK5CYII="),Yat.NOIMAGE}dispose(){super.dispose(),this._offcanvas=null,this._image=null}render(t){var{left:e,top:r,width:n,height:i,isGray:a=!1,alpha:s=1,src:o}=this.state;if(this.prepareIf(!this._image&&o),t.beginPath(),t.globalAlpha*=s,this._image&&this._image.complete)if(a&&this._offcanvas)t.drawImage(this._offcanvas,e,r,n,i);else try{t.drawImage(this._image,e,r,n,i)}catch(a){t.drawImage(Yat.noimage,e,r,n,i)}else!this.app.isViewMode&&t.drawImage(Yat.noimage,e,r,n,i)}get nature(){return Gat}get hasTextProperty(){return!1}ready(){super.ready(),this.prepareIf(!this._image&&this.state.src)}prepare(t,e){var{src:r,crossOrigin:n}=this.state;if(r){this._image=new Image;try{n&&(this._image.crossOrigin=n),this._image.src=this.app.url(r)||""}catch(t){return void e(t)}this._image.onload=()=>{if(this.get("isGray")){let t=this._image.width,e=this._image.height;this._offcanvas=mtt.createCanvas(t,e);let r=this._offcanvas.getContext("2d");r.drawImage(this._image,0,0);let n=function(t,e,r){try{var n=t.getImageData(0,0,e,r)}catch(t){return U7("Get Image Data Error: "+t.message),null}var i=n.data;for(let t=0;t<e*r*4;t+=4){let e=i[t],r=i[t+1],a=i[t+2],s=parseInt((e+r+a)/3);n.data[t]=s,n.data[t+1]=s,n.data[t+2]=s}return n}(r,t,e);r.putImageData(n,0,0)}t(this)},this._image.onerror=t=>{this._image&&!this._image.currentSrc&&(this._image=null),e(t)}}else t(this)}get src(){return this.get("src")}set src(t){this.set("src",t)}onchange(t,e){(t.hasOwnProperty("src")||t.hasOwnProperty("isGray"))&&(this._offcanvas=null,this._image=null,this.prepareIf(t.src))}ondropfile(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void(this.src=e[r])}}mtt.register("image-view",Yat);class Vat extends(gat(wtt(mtt))){is3dish(){return!0}prerender(){}}var qat={},Xat={},$at={};Object.defineProperty($at,"__esModule",{value:!0});var Kat=function(){function t(){}return t.bitsToNum=function(t){return t.reduce((function(t,e){return 2*t+e}),0)},t.byteToBitArr=function(t){for(var e=[],r=7;r>=0;r--)e.push(!!(t&1<<r));return e},t.lzwDecode=function(t,e){for(var r,n,i=0,a=function(t){for(var r=0,n=0;n<t;n++)e.charCodeAt(i>>3)&1<<(7&i)&&(r|=1<<n),i++;return r},s=[],o=1<<t,l=o+1,h=t+1,c=[],u=function(){c=[],h=t+1;for(var e=0;e<o;e++)c[e]=[e];c[o]=[],c[l]=null};;)if(n=r,(r=a(h))!==o){if(r===l)break;if(r<c.length)n!==o&&c.push(c[n].concat(c[r][0]));else{if(r!==c.length)throw new Error("Invalid LZW code.");c.push(c[n].concat(c[n][0]))}s.push.apply(s,c[r]),c.length===1<<h&&h<12&&h++}else u();return s},t}();$at.SuperGifUtils=Kat,Object.defineProperty(Xat,"__esModule",{value:!0});var Qat=$at,Jat=function(){function t(t,e){this.stream=t,this.handler=e}return t.prototype.parseCT=function(t){for(var e=[],r=0;r<t;r++)e.push(this.stream.readBytes(3));return e},t.prototype.readSubBlocks=function(){var t,e;e="";do{t=this.stream.readByte(),e+=this.stream.read(t)}while(0!==t);return e},t.prototype.parseHeader=function(){var t={};if(t.sig=this.stream.read(3),t.ver=this.stream.read(3),"GIF"!==t.sig)throw new Error("Not a GIF file.");t.width=this.stream.readUnsigned(),t.height=this.stream.readUnsigned();var e=Qat.SuperGifUtils.byteToBitArr(this.stream.readByte());t.gctFlag=e.shift(),t.colorRes=Qat.SuperGifUtils.bitsToNum(e.splice(0,3)),t.sorted=e.shift(),t.gctSize=Qat.SuperGifUtils.bitsToNum(e.splice(0,3)),t.bgColor=this.stream.readByte(),t.pixelAspectRatio=this.stream.readByte(),t.gctFlag&&(t.gct=this.parseCT(1<<t.gctSize+1)),this.handler.hdr&&this.handler.hdr(t)},t.prototype.parseExt=function(t){var e=this;switch(t.label=this.stream.readByte(),t.label){case 249:t.extType="gce",function(t){e.stream.readByte();var r=Qat.SuperGifUtils.byteToBitArr(e.stream.readByte());t.reserved=r.splice(0,3),t.disposalMethod=Qat.SuperGifUtils.bitsToNum(r.splice(0,3)),t.userInput=r.shift(),t.transparencyGiven=r.shift(),t.delayTime=e.stream.readUnsigned(),t.transparencyIndex=e.stream.readByte(),t.terminator=e.stream.readByte(),e.handler.gce&&e.handler.gce(t)}(t);break;case 254:t.extType="com",function(t){t.comment=e.readSubBlocks(),e.handler.com&&e.handler.com(t)}(t);break;case 1:t.extType="pte",function(t){e.stream.readByte(),t.ptHeader=e.stream.readBytes(12),t.ptData=e.readSubBlocks(),e.handler.pte&&e.handler.pte(t)}(t);break;case 255:t.extType="app",function(t){e.stream.readByte(),t.identifier=e.stream.read(8),t.authCode=e.stream.read(3),"NETSCAPE"===t.identifier?function(t){e.stream.readByte(),t.unknown=e.stream.readByte(),t.iterations=e.stream.readUnsigned(),t.terminator=e.stream.readByte(),e.handler.app&&e.handler.app.NETSCAPE&&e.handler.app.NETSCAPE(t)}(t):function(t){t.appData=e.readSubBlocks(),e.handler.app&&e.handler.app[t.identifier]&&e.handler.app[t.identifier](t)}(t)}(t);break;default:t.extType="unknown",function(t){t.data=e.readSubBlocks(),e.handler.unknown&&e.handler.unknown(t)}(t)}},t.prototype.parseImg=function(t){t.leftPos=this.stream.readUnsigned(),t.topPos=this.stream.readUnsigned(),t.width=this.stream.readUnsigned(),t.height=this.stream.readUnsigned();var e=Qat.SuperGifUtils.byteToBitArr(this.stream.readByte());t.lctFlag=e.shift(),t.interlaced=e.shift(),t.sorted=e.shift(),t.reserved=e.splice(0,2),t.lctSize=Qat.SuperGifUtils.bitsToNum(e.splice(0,3)),t.lctFlag&&(t.lct=this.parseCT(1<<t.lctSize+1)),t.lzwMinCodeSize=this.stream.readByte();var r=this.readSubBlocks();t.pixels=Qat.SuperGifUtils.lzwDecode(t.lzwMinCodeSize,r),t.interlaced&&(t.pixels=function(t,e){for(var r=new Array(t.length),n=t.length/e,i=function(n,i){var a=t.slice(i*e,(i+1)*e);r.splice.apply(r,[n*e,e].concat(a))},a=[0,4,2,1],s=[8,8,4,2],o=0,l=0;l<4;l++)for(var h=a[l];h<n;h+=s[l])i(h,o),o++;return r}(t.pixels,t.width)),this.handler.img&&this.handler.img(t)},t.prototype.parseBlock=function(){var t={};switch(t.sentinel=this.stream.readByte(),String.fromCharCode(t.sentinel)){case"!":t.type="ext",this.parseExt(t);break;case",":t.type="img",this.parseImg(t);break;case";":t.type="eof",this.handler.eof&&this.handler.eof(t);break;default:throw new Error("Unknown block: 0x"+t.sentinel.toString(16))}"eof"!==t.type&&setTimeout(this.parseBlock.bind(this),0)},t.prototype.parse=function(){this.parseHeader(),setTimeout(this.parseBlock.bind(this),0)},t}();Xat.SuperGifParser=Jat;var Zat={};Object.defineProperty(Zat,"__esModule",{value:!0});var tst=function(){function t(t){this.data=t,this.position=0}return t.prototype.readByte=function(){if(this.position>=this.data.length)throw new Error("Attempted to read past end of stream.");return this.data instanceof Uint8Array?this.data[this.position++]:255&this.data.charCodeAt(this.position++)},t.prototype.readBytes=function(t){for(var e=[],r=0;r<t;r++)e.push(this.readByte());return e},t.prototype.read=function(t){for(var e="",r=0;r<t;r++)e+=String.fromCharCode(this.readByte());return e},t.prototype.readUnsigned=function(){var t=this.readBytes(2);return(t[1]<<8)+t[0]},t}();Zat.SuperGifStream=tst,Object.defineProperty(qat,"__esModule",{value:!0});var est=Xat,rst=Zat,nst=function(){function t(t,e){var r=this;for(var n in this.gifImgElement=t,this.options={autoPlay:!0},this.loading=!1,this.ready=!1,this.transparency=null,this.delay=null,this.disposalMethod=null,this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,this.playing=!0,this.forward=!0,this.ctxScaled=!1,this.frames=[],this.frameOffsets=[],this.initialized=!1,this.currentFrameIndex=-1,this.iterationCount=0,this.stepping=!1,this.handler={hdr:this.withProgress(this.doHdr.bind(this)),gce:this.withProgress(this.doGCE.bind(this)),com:this.withProgress(this.doNothing.bind(this)),app:{NETSCAPE:this.withProgress(this.doNothing.bind(this))},img:this.withProgress(this.doImg.bind(this)),eof:function(){r.pushFrame(),r.canvas.width=r.hdr.width*r.getCanvasScale(),r.canvas.height=r.hdr.height*r.getCanvasScale(),r.playerInit(),r.loading=!1,r.ready=!0,r.loadCallback&&r.loadCallback(r.gifImgElement)}},e)this.options[n]=e[n];this.onEndListener=e.onEnd,this.loopDelay=e.loopDelay||0,this.overrideLoopMode=null!=e.loopMode?e.loopMode:"auto",this.drawWhileLoading=null==e.drawWhileLoading||e.drawWhileLoading}return t.prototype.init=function(){var t=this.gifImgElement.parentNode,e=document.createElement("div");this.canvas=document.createElement("canvas"),this.canvasContext=this.canvas.getContext("2d"),this.tmpCanvas=document.createElement("canvas"),e.className=this.options.enclosingClass||"super-gif",e.appendChild(this.canvas),t&&(t.insertBefore(e,this.gifImgElement),t.removeChild(this.gifImgElement)),this.initialized=!0},t.prototype.loadSetup=function(t){return!this.loading&&(t&&(this.loadCallback=t),this.loading=!0,this.frames=[],this.clear(),this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,!0)},t.prototype.completeLoop=function(){this.onEndListener&&this.onEndListener(this.gifImgElement),this.iterationCount++,!1!==this.overrideLoopMode||this.iterationCount<0?this.doStep():(this.stepping=!1,this.playing=!1)},t.prototype.doStep=function(){if(this.stepping=this.playing,this.stepping){this.stepFrame(1);var t=10*this.frames[this.currentFrameIndex].delay;t||(t=100),0===this.getNextFrameNo()?(t+=this.loopDelay,setTimeout(this.completeLoop.bind(this),t)):setTimeout(this.doStep.bind(this),t)}},t.prototype.step=function(){this.stepping||setTimeout(this.doStep.bind(this),0)},t.prototype.putFrame=function(){var t;this.currentFrameIndex=parseInt(this.currentFrameIndex.toString(),10),this.currentFrameIndex>this.frames.length-1&&(this.currentFrameIndex=0),this.currentFrameIndex<0&&(this.currentFrameIndex=0),t=this.frameOffsets[this.currentFrameIndex],this.tmpCanvas.getContext("2d").putImageData(this.frames[this.currentFrameIndex].data,t.x,t.y),this.canvasContext.globalCompositeOperation="copy",this.canvasContext.drawImage(this.tmpCanvas,0,0)},t.prototype.playerInit=function(){this.loadErrorCause||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.options.autoPlay?this.step():(this.currentFrameIndex=0,this.putFrame()))},t.prototype.clear=function(){this.transparency=null,this.delay=null,this.lastDisposalMethod=this.disposalMethod,this.disposalMethod=null,this.frame=null},t.prototype.parseStream=function(t){try{new est.SuperGifParser(t,this.handler).parse()}catch(t){this.handleError("parse")}},t.prototype.setSizes=function(t,e){this.canvas.width=t*this.getCanvasScale(),this.canvas.height=e*this.getCanvasScale(),this.tmpCanvas.width=t,this.tmpCanvas.height=e,this.tmpCanvas.style.width=t+"px",this.tmpCanvas.style.height=e+"px",this.tmpCanvas.getContext("2d").setTransform(1,0,0,1,0,0)},t.prototype.drawError=function(){this.canvasContext.fillStyle="black",this.canvasContext.fillRect(0,0,this.hdr.width,this.hdr.height),this.canvasContext.strokeStyle="red",this.canvasContext.lineWidth=3,this.canvasContext.moveTo(0,0),this.canvasContext.lineTo(this.hdr.width,this.hdr.height),this.canvasContext.moveTo(0,this.hdr.height),this.canvasContext.lineTo(this.hdr.width,0),this.canvasContext.stroke()},t.prototype.handleError=function(t){this.loadErrorCause=t,this.hdr={width:this.gifImgElement.width,height:this.gifImgElement.height},this.frames=[],this.drawError()},t.prototype.doHdr=function(t){this.hdr=t,this.setSizes(this.hdr.width,this.hdr.height)},t.prototype.doGCE=function(t){this.pushFrame(),this.clear(),this.transparency=t.transparencyGiven?t.transparencyIndex:null,this.delay=t.delayTime,this.disposalMethod=t.disposalMethod},t.prototype.pushFrame=function(){this.frame&&(this.frames.push({data:this.frame.getImageData(0,0,this.hdr.width,this.hdr.height),delay:this.delay}),this.frameOffsets.push({x:0,y:0}))},t.prototype.doImg=function(t){var e=this;this.frame||(this.frame=this.tmpCanvas.getContext("2d"));var r=this.frames.length,n=t.lctFlag?t.lct:this.hdr.gct;r>0&&(3===this.lastDisposalMethod?null!==this.disposalRestoreFromIdx?this.frame.putImageData(frames[this.disposalRestoreFromIdx].data,0,0):this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height):this.disposalRestoreFromIdx=r-1,2===this.lastDisposalMethod&&this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height));var i=this.frame.getImageData(t.leftPos,t.topPos,t.width,t.height);t.pixels.forEach((function(t,r){t!==e.transparency&&(i.data[4*r+0]=n[t][0],i.data[4*r+1]=n[t][1],i.data[4*r+2]=n[t][2],i.data[4*r+3]=255)})),this.frame.putImageData(i,t.leftPos,t.topPos),this.ctxScaled||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.ctxScaled=!0),this.drawWhileLoading&&(this.canvasContext.drawImage(this.tmpCanvas,0,0),this.drawWhileLoading=this.options.autoPlay),this.lastImg=t},t.prototype.doNothing=function(){},t.prototype.withProgress=function(t){return function(e){t(e)}},t.prototype.getNextFrameNo=function(){var t=this.forward?1:-1;return(this.currentFrameIndex+t+this.frames.length)%this.frames.length},t.prototype.stepFrame=function(t){this.currentFrameIndex=this.currentFrameIndex+t,this.putFrame()},t.prototype.getCanvasScale=function(){return this.options.maxWidth&&this.hdr&&this.hdr.width>this.options.maxWidth?this.options.maxWidth/this.hdr.width:window.devicePixelRatio||1},t.prototype.play=function(){this.playing=!0,this.step()},t.prototype.pause=function(){this.playing=!1},t.prototype.isPlaying=function(){return this.playing},t.prototype.getCanvas=function(){return this.canvas},t.prototype.isLoading=function(){return this.loading},t.prototype.isReady=function(){return this.ready},t.prototype.isAutoPlay=function(){return this.options.autoPlay},t.prototype.getLength=function(){return this.frames.length},t.prototype.getCurrentFrame=function(){return this.currentFrameIndex},t.prototype.moveTo=function(t){this.currentFrameIndex=t,this.putFrame()},t.prototype.loadURL=function(t,e){var r=this;if(this.loadSetup(e)){var n=new XMLHttpRequest;n.open("GET",t,!0),"overrideMimeType"in n?n.overrideMimeType("text/plain; charset=x-user-defined"):"responseType"in n?n.responseType="arraybuffer":n.setRequestHeader("Accept-Charset","x-user-defined"),n.onloadstart=function(){r.initialized||r.init()},n.onload=function(){if(200===n.status){var t=n.response;t.toString().indexOf("ArrayBuffer")>0&&(t=new Uint8Array(t));var e=new rst.SuperGifStream(t);setTimeout((function(){r.parseStream(e)}),0)}else r.handleError("xhr - response")},n.onerror=function(){r.handleError("xhr")},n.send()}},t.prototype.load=function(t){this.loadURL(this.gifImgElement.src,t)},t}(),ist=qat.SuperGif=nst;const ast={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"src",name:"src"},{type:"checkbox",label:"play",name:"play"}],"value-property":"src",help:"scene/component/gif-view"};class sst extends Vat{async oncreate_element(t){var{src:e,play:r}=this.state;this.onchangesrc(e),this.onchangeplay(r)}buildImg(){var t=this.element;t.innerHTML="";var e=document.createElement("img");return e.style.width="100%",e.style.height="100%",t.appendChild(e),e}onchange(t,e){super.onchange(t,e),"src"in t&&this.onchangesrc(t.src),"play"in t&&this.onchangeplay(t.play)}setElementProperties(t){}onchangeplay(t){var e=this._superGif;e&&e.isReady()&&(t?e.play():e.pause())}onchangesrc(t){var e=this.buildImg();t||(t="data:image/gif;base64,R0lGODlhYABIAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKio+Pj5iYmKCgoKampqurq66urrCwsLGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrOzs7S0tLa2tre3t7m5ubu7u7+/v8DAwMHBwcPDw8XFxcfHx8vLy8/Pz9LS0tXV1dfX193d3eTk5Onp6fj4+Pz8/P7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v///////////////////////////////////////////////////////////////////////////////yH5BAkAAPUAIf47R2VuZXJhdGVkIGJ5IGpzZ2lmIChodHRwczovL2dpdGh1Yi5jb20vYW50aW1hdHRlcjE1L2pzZ2lmLykALAAAAABgAEgAAAj+AGcJHEiwoMGDCBMqXMiwocOHECNKnEixosWLGDNq3Mixo8ePIEOKHEmypMmR9VKqXMmypcuXMGPKnJkSIs2bOHPqZGlzp8+fQOv1DEq0KMyhRpMmRaq0KVCmTqPmhCq1qkyqLrFRSyYwGTVsVo1iZXmNa8Fk18ISHasSm1mDycCq/ck2JTWF1ObSfTjz7cFken3WFbow8M7BDA3rHOwXruKpfGXeTZg3qDVrUge7RRg3KLZjx+Q2HVyvLNy0QaMJjBaVdD2tZr2K/mmNIObRkR+n9AsYt0Pddg1WXppb8bWDx1CLLW74GcJnSl3TtDY8Zu2Et4tKl7n52eyWnxXvhl7+26jqrspbnlfIWjtz2gWPZV95neH8veU9NxZYfbfD3kFt99J6Bnmn0mQO9XfYezrVxxlmx0GUXIAM4hSeffsxBN1TFd5E4Ef3QZbfTg6CNJ5gHXJ3TEntLThiTh+KFCJNAqZU4kgAitjQTheepOBMNcZI0oQ6JpbTjSZtiNN2PZ400IxHpdiSc07G911M0iFZZYtAStnWilUeBGVLrlEZpmM0elmPlmfO8iOZXl4DZpsGEYmll2bSWWCXLwJXVY1+urhjoGEBSuiSah6K36CKtpZoo4s9CimielZq6aWYZqrpppx26umnoIZ6UkAAOw=="),e.src=t,e.setAttribute("rel:animated_src",t),e.setAttribute("rel:auto_play",0),this._superGif=new ist(e,{autoPlay:!1}),this._superGif.init();for(const t of this.element.children)t.style.width="100%",t.style.height="100%";var r=this._superGif.getCanvas();r.style.width="100%",r.style.height="100%",this._superGif.load((()=>{setTimeout((()=>{this._superGif.moveTo(0),this.play&&this._superGif.play()}),100)}))}ondropfile(t,e){for(let r=0;r<t.length;r++)if(/\.gif$/.test(t[r].name))return void(this.src=e[r])}get src(){return this.getState("src")}set src(t){this.set("src",t)}get play(){return this.getState("play")}set play(t){this.setState("play",t)}get nature(){return ast}get tagName(){return"div"}}mtt.register("gif-view",sst);const ost={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"attachment-selector",label:"src",name:"src",property:{category:"audio"}},{type:"checkbox",label:"started",name:"started"},{type:"checkbox",label:"loop",name:"loop"}],"value-property":"src",help:"scene/component/audio"};class lst extends(wtt(ytt)){static get image(){return lst.IMAGE||(lst.IMAGE=new Image,lst.IMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAMAAAC3Ycb+AAAAP1BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACzJYIvAAAAFHRSTlMA8BAwgNBgQKB/wCBwUJDg37CvXyUlBK8AABFYSURBVHja7NsBkqIwFIThTiAQgyBq3/+sm6p1tnamZkaTMhJJf1f4S/JeEIiIiIiIiIiIiIiIiEhD7Hg4BH84TpAKjJ4f3NFCtjVd+InXz2RTs+FXlxGylYHfcVfIJmb+YFWSLUyGVJKKBJJKUo+Rd6w63l/qzLuCkryO5fe0l2xk5mMWbe+v0fNBRqf7S3je6CipQ2ACr+dWcYEpzBFS1plpguatsnomMgdIQSOTuQ5SjmE6/UgK8szgdJIUM/FG41YlFmYJ2kkKsY5ZzAwBurHDk3WGeRY0bvYrGa1+rqNI22f7dS32ZnUK1GMr0eSK3mEc9dhKMxp+ZTo8kT2emOXS5LQ1kCxbJBocSd2k5PaIjMVzjWcdJPk9ooBnmzx1t5XbIxqBKpJ4NGTgzwKiGpK4do72gb+ZUMIYtCPm9WCPMsYTE5k2hq2ZvzujlCE1iRmwf3dvmRyKsT0T7b9I7HEPCpqCiqT2IIqaT1pI0noQZdlFC8l/PbYPAnRORT56VBEE6FXkb49agmByKhJ71BME6FsvEntUFQTdqekisUdlQWCXhovEHtUFAWbTapHYo8YgmFybO3vsUWcQYGmxSOxRbRAMprkisUfFQVKmrX18sxt7VB0ENjT1xir2qDxIwkFi3v89e+xRfxAMzfzzIfZ4hyAYDR9zwVuLPd4jCDrTwoLYGb5LEFi3/+E3rweR6urX20c/Fvls2Pvwm9mDSGIPhv8YPyGf3/eo9Ye7O8B2FIShAAooakEttex/rbODad5/yTHIAjqn505IQPv+Xz06dz+4VXORHEZcgAcB8updM8F6e25jBzwIkE07l+x8amMnPDp6nsNJ+BoZ7Q6F8egqAda9VEuRNlZjBzwYkMskdXR73okd8GBAJiKYjBcZKKqG9OiKDbgdfxJ5VhsBPDiQZhaouD3p4hfw4EAmwxisz3MSHwAPEmQ1TB1N+SmXWoAHC7JbZsWl/IxLLcCDBplNo3lrfMLsmwAPGmShAxX5/1vOEzjEz3iyfQ/hI36W4TctsUesOAifPdrQg8M++KYl95iCBkjI1r8634betBAPHZDTPFAmD3zLiHgogVTziMsahz0eIh5aIGHGRSJ2mFtHPR4iHhQIP2UvWGMf8wk74qEIEib7rLjPiBfxiAcCwp8V+Nae3uMdRhAPDIR/J5f/Q2DTcC+hIB7qIGEq3Ti9bx+sryMeAAgS70OK8G2kBD8L8QBAoLWU3g3vUVIc6D0txAMAsY+4jBWowXHO64gHBGKfYJ2T5qY1BxcL98BB+PQ+XiS9xxh9EQ8ChA6C5UXWIUoE9MBB8LVHQoS7ib8/dRn3sAcJ6bQRSdH96RDxIEH4QEX+AHF4LxHEAwUh12xyr1V8lwjiQYDYF8kuf1jluUQQDwrEvkhW8Wc6LhHUgwfhi4QPlHm7LRHawx4kpE191Dq8lgjhAYDQa1cftYrPEiE8OJDb40uqyzdQCA8WhAzL4G/PT4c3WrgHD2IfllGl53V37zsgHg5ApPNvVvq4Fn4spx4oiH1W3CwtEV+PDhEPJyBSkVX4aa7emkM83ICEKWpGM7wdvYCCeDgCEYpcwhLxczhEPFyBCEUWnRL5T6X59SBASBF+9l28TL5F7uEORCZyCUvEx+S7yT0cgoRVb9JaXLR1qUdfgksQ0fTbgmhFB20d8HAKEha14+F8f1sHPNyCiL6EqK+n20/rgIdjkFC0Ho1s6Gndvcc9ICkr/ey8/rHO6vp9KawL8DAFOV6l9Fyub7IbflsCag1qRfVsXWvxHjxIejU+BHZV6uvHD1XiEb++Bw8i+dNd+Wv0eCQmhcPhRPwUUt2DB5G1sfa1aeyzAuyJj9x2HjyIdKzIKw5SI14ieFtvo3kIQERj3lVhkUOnRD7AnjV5369QkAOJZeCH+Jh41xOLs73dQwAifY6dpxCCbjTDzLf1Bm1Y93tAIDOWXcLPvrHyr2hVoEAceEAgDQzB4jetk0/c2OXRHB48EJCpa4dgpYh2ETxtrshz7zx4ICCzfuTSDn8p/EOS9OTjwgMB+cABP3yWYuOPIofs33LigYCULlpZNXJppVU30Vf14kGAUCLijf1D71lN9FW9eFiA9KgZ8FPpPUsSnufGA+8hvAg2Kpz0nrX//qp+PIgpC3i6xJRITOye9fn1VT15ICCrVlQG5rywo0H8x965bVkNwmCYQ2kR6Gmb939WXV65dFnI/tPdjPBfO7XMN4EkTUJtqZp4sCJ1+8jwkhMu0KpMxFXFA8hlVfQSMxGH5mDK1VKV8QCyvTVtUiYyo7V358VStfGoAEFMhGYhEwloxZy9WKo2Hjwg5iSOvFDXeUYd33+PuVfHgwnEBWLocDJp+IIa2fyvperjwQRiXCKGosyXqoA+YfsIELuYu4HAt+msMknfDK4jfQJIzOZ2IPAQWJtFOhQKivR2IDZ6Awis7V0iLxqBI7uEZo19dakTogLSwKvf8yk8Jq6CGK0GKvWlatG7b7kkUU/Lo1gdXWn7/4E0j0qeJDpqN/ABqQcgJgdqURb4chjQktIugDS6wFFiz3JgaJj7AGJmholAe9YKhoZLJ0Ca6smjwJ4VwVN96gVIE5GM71kHaGKxGyAtRDaB2NBhLVmpHyANRKzDO28W7FS3HQFpaIWa8TrfCXQwegJSL5k+8M9UJ+pm9QTEnCIZrR0MDQeQ9ua0iCcYQaBTV0CqNXQW/yiyYG7W1heQanPaCkciBXuH1BkQJzHcDQxmpgGkPatl4WkbCXO/bW9AqlNg4H0PPMi6A1IxkQmOZ8D0ousNSMVEEuyreTAQ6Q7IRJeCX2YZQHhv6SrBOmpkM+YUzN0BqSRQCupmTeCP9wdkhiOREwtEzgGEsWcF9BhK9R8fQDiN7A8DiR0CKXQlj/q9IM8OgXjIzcKBlAHkD6FulgNzJwPIHwpo8mQAkX3LiPq9dKUMAQk9AqmcqmjuBAJCPQIpA4guIAsKJA0gnwNy3A4kDyBIHCEPxAwgf8gPILqA5AFEF5CxZX0lIHYc6rqADLf380BmFMgxgIzUyf8MJKLTRelKHgKy9wgkjfS7LiA0gKgC8vQn3HUA4RQ5LKPIAQciWbqIEg0YkLNDIHYUyqkCsmKN5vg3+W0AYTRATaPY+uu1IwS6UMGAlO6AFPjSCQMStaNh53cdcPG7Hx1Uupo+rx+Bltn1BuTAj5BptEV/bHAAwbnJMICwRmtUDOSEA8s4Rmtw3nITGD6TwUNoG0Ca7xi2YKSPj2eKXQFxQWKA2QbGMWEMMGseOb7C7T47uJS1JyAzVbTjqZdU3zbHzMXWS+qp4Fgn8Ahy/QCRGqQcwU1vGnN7fylboWn8Bzg//hyjxltvdcl45bwFfYKzFyBy11UU9BnjuoqfWizVlQXulpzBTNbaB5Aid+VRrkBFB630AMS9BC8FK2ggE7u/FGy1kvfcB9TKQufX5uUXNWl3EjvWCi4k/u9A3Ddq1CpTIQGe6VN1qd8ArcvDQNw3S41Kn6qQmOq5e7pRr+8fAYLiIJtFrrvYRMYL0q06vj8EZLXUriJzRY8H1xEagOCK7gkghRg6RQYO0I6aWPwIEAru80AiMWSdzAeuDXUKyr+WqpAID8hMHC1Ct8F4mUsQ6W8pJMICki0JHCBczAFdBl38G3VE6ErQhhWlih4LWrCSLpaqjggHiGe9mVjRY0YPoelyqcqIcIDEe97rqJFFH7FcLlUZEQ6Qg5plvZiBFNhtri1VFREGEC/Eg4nZoU5vqi1VFREGkIXDQ8xAIhzoT/WlKiLCAFIYPOQMxOPdjfWlKiLCADJRm3YGj+pDE2xktmmpaogwgMz8d8GrumZ4xzpbvinqISJ+hiTWm7wEqoJdI9JEV9JChAEkS3xCZzKecLcgN6YwlRBhAGmweTsblg6qKMM7Vmh321UQ4QAp1VfwhqVJIh+Wm03W0qV0EOEAybXtivkCmWrKeH2EZ/xBaSBCV2L9Re+LYSqJJIxDu1ew07U0EGEBcTtmHty4JuPtQhvLh1BAhK7Uvvq0GK484QZST0GvvFDqeSJ1IA0r2mfDljvqBoJ//rVsq7yZCA6kXgVkJ2f4ijIGMjOfMVsCBBORB2Jy+sM6ijNvaBUqmw/cStZ8EiKciHwp6Rp++88qmxXQeTUxDiJWJ9wSISvBicgXW+dypn1PqWTznlwgwdZdfiLHr5OELEAEASKvJFRE5JCPKbh8OxHdQKJU0crEzRXrJ/IEkFms6tGyrUw9kQeALFRXvK2iSzsRAAi6BLxM+60xdsqJAEBuXMAMxDLVp+gmAgC57/UT4qvVj3TVRCAgSAYL91aXtyNLzUQAIFhAiP8m0/NHOp+ILiBtPFKrs6bgSOcT0QTEB8nO3QR1yKslggKRf+m11UB0HOl8IlqAeCvauXuo8HnfIqIDyCw6G8XMcGiplMingMzCnbuHFp/3LSLPA4nUpqm5YkWNzwsQeQxIDsKjH5wVSU5qJPIJIIt4jjpqNBAekQeBfJOeHWS81FQoo4/I7UDcS3wUh0liTzLqiEgDqddx4ZHDrNZAACIAEMw88HPYWb0GAhABgEDmgf9Vb5oNBCByOxD3uqWYbCHVBgIQuRlIsbfwMEG5gQBE7gSyHMDsOayrxJvHBRC5B0hOxJH1nK4SlUE6QOR+IG6ju3iYQEqDdIDIzUDyZu/jMRHpS/OiRG4FkiPRfTw8kbrvIAJEACAIDpyHC1/GQHhEbgKSXwTyqIeEur6kixEBgABHOTr7YSX1MSFAhA0E307wUU76Y0KACAsI/tvCRzkF+iIuL0AEAYLbR2QOfvhKJ/obRESBxNt5rPSFXN4f7dyNdqMgEIbhAXWwJErT/e7/Wreb5HTT07QVgWSAeW5g7b4n8qOSUCRPEId4HP93SXp5dDNGRJFcQTxihSH+NW1Bb1cXKpIryJAwnG/zhl8ZcSP6jiKZghwRaaWLnP/AkcSKKJIniEcUs8QfjFLdEmRvkSxB4lfn0QN6DY+lshQpHiT96Dlr6r5hxRUpHST9ZEY71X7DOmOZQVZLsd5Q8wzrPxYYJDiKNqOBG1ZCkZKzrNXu6lHvkjChSFqQsdTPg45ApXtYaUXKr9TNuPcvqO2pVMkitFXAL2a79/qr3HQvVSTXUtofCl79RDXh5CDpw3pwu6+9kRlvtiI5VtPhmHLltT4EKVQkfb8pcOHrXqk6nBAksUjgpKtuYsskaxGKYT0+84uYgziE4YQgMdx0m8PRfis2MbL33PMXoVjD6PEunI4HSjDjStiJP08vQk9hZzQ7oH/geoLYCUBDW4rf4FqCDFt7THUO6B+4jiDn2XNTW7zf4hqCMND4BOsGyw+yAmh0x+QeFh7EeqD5Ce8nLDrI8NpbDyIWHIQNruo4GyAPlhrEzuixBxHLDDJMnfYgYolBricHNfjIdgMWF+Qyu+pkgX4HCwuymL57ELGkIHZG7z2IWE6Q5VV7vGMhQewbtMcZiwhyHj26ne9+xs8PcvDQHnFFqCD7Au0RW4TK+fOKqw4eoOcqYqgU53HR3/5uShFPCfKey9hFDyJO/vAi7RDZnp7X5igyUH72xSDW1E2Pn4tMRCQgR8vLwbgii4gcmLvqQcSPGtIPX3M08wn6I4qYQ94cM/Yw9Xxhmw+X/59wHrtMlX1AmIkzdyaaAnLg1Nnw8WGYSk40X/BOh4+El6LMSBnN2Cd0tPq4w/LJXGrMbCX06PZ2dcM65yzlNertShSHf3SzRAyPM332IcSAHUKPi8EHmXU0l8Uglmni0yipDoi16s+jJKejhywLooz68yiMEcHr2qM4h81CJ++VPJfTu5UwBpv4Pp9DJSi6MJx0bvUwiw4ewgT8zNR0LHUL+OccOpY/3ElzyGKD5pBlMJpDlsOkMythRoNbXh95PJsdA67MrMtAEYbjeDqNo+7oKqWUUkoppZRSSimllFJKFfMXp4vmSjB8n6sAAAAASUVORK5CYII="),lst.IMAGE}dispose(){super.dispose(),this.started=!1,delete this._audio}ready(){super.ready(),this._audio=new Audio,this._audio.addEventListener("canplay",(()=>{this.started&&this._audio.play()}));var{src:t="",loop:e=!1,started:r=!1}=this.state;this.onchangeSrc(t),this.onchangeLoop(e),this.onchangeStarted(r)}render(t){var{left:e,top:r,width:n,height:i,src:a}=this.state;t.beginPath(),this.drawImage(t,lst.image,e,r,n,i)}get nature(){return ost}get hasTextProperty(){return!1}get src(){return this.get("src")}set src(t){this.set("src",t)}get started(){return!!this.get("started")}set started(t){this.set("started",t)}start(){this._audio&&(this._audio.classList.add("active"),this._audio.play())}pause(){this._audio&&(this._audio.classList.remove("active"),this._audio.pause())}onchangeSrc(t){try{"data"!==String(t).substring(0,4)?this._audio.crossOrigin="use-credentials":this._audio.crossOrigin=null,this._audio.src="string"==typeof t?this.app.url(t):t}catch(t){return void console.error(t)}}onchangeStarted(t){const e=this._audio;t?4==e.readyState&&e.play():e.pause()}onchangeLoop(t){this._audio.loop=t}onchange(t,e){"src"in t&&this.onchangeSrc(t.src),"started"in t&&this.onchangeStarted(t.started),"loop"in t&&this.onchangeLoop(t.loop)}ondblclick(t){this.started=!this.started}ondropfile(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("audio/"))return void(this.src=e[r])}}mtt.register("audio",lst);class hst extends(wtt(mtt)){is3dish(){return!0}}mtt.register("text",hst);const cst=["refid","left","top","width","height","rotation","animation"];class ust extends bat{isGroup(){return!0}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});var r=cst.reduce(((e,r)=>(t.hasOwnProperty(r)&&(e[r]=t[r]),e)),{});return super.set(r)}capture(t,e,r){var n=super.capture(t,e,r);if(n!==this)return n}set bounds(t){if(this.__MUTATING__)super.bounds=t;else{var e=this.bounds,r=t.width/e.width,n=t.height/e.height;this.path=this.path.map((i=>({x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n}))),this.components&&this.components.forEach((t=>{if(t.mutable)t.mutatePath(null,(function(t){return t.map((function(t){return{x:t.x*r,y:t.y*n}}))}));else{let e=t.bounds,i=t.center,a={x:i.x*(1-r),y:i.y*(1-n)},s=e.width*(1-r),o=e.height*(1-n),l=-(a.x-s/2),h=-(a.y-o/2);t.bounds={left:e.left+l,top:e.top+h,width:e.width*r,height:e.height*n}}}))}}get focusible(){return!1}get bounds(){return super.bounds}get hasTextProperty(){return!1}isIdentifiable(){return!1}calculateBounds(){this.clearCache(),this.__MUTATING__=!0,this.mutateBounds((function(t){var e=mtt.union(this.components.map((t=>t.bounds)));return this.components.forEach((t=>{let r=t.bounds;t.bounds={left:r.left-e.left,top:r.top-e.top,width:r.width,height:r.height}})),{left:t.left+e.left,top:t.top+e.top,width:e.width,height:e.height}}),this),this.__MUTATING__=!1,this.parent.isGroup()&&this.parent.calculateBounds()}render(t){}postrender(t){var{top:e,left:r,scale:n}=this.state;t.translate(r,e),this.layout.drawables(this).forEach((e=>{e.draw(t)})),t.translate(-r,-e)}}mtt.register("group",ust);const dst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"id-input",label:"ref",name:"ref"},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio"]}}],"value-property":"ref",help:"scene/component/local-ref"};class pst extends(wtt(ytt)){get ref(){var t=this.getState("ref");return t&&"string"==typeof t?this.root.findById(t):null}set ref(t){this.setState("ref",t)}get refScale(){let t=this.ref.bounds,e=this.bounds,r=e.width/t.width,n=e.height/t.height;return"both"===this.model.fit?{x:r,y:n}:{x:Math.min(r,n),y:Math.min(r,n)}}draw(t){this._drawing||(this._drawing=!0,super.draw(t),this._drawing=!1)}prerender(t){if(super.prerender(t),this.ref){let e=this.ref.center,r=this.center,n=this.refScale;t.translate(r.x,r.y),t.scale(n.x,n.y),t.translate(-e.x,-e.y)}}postrender(t){if(this.ref)return this.ref.postrender(t);super.postrender(t)}render(t){if(this.ref)return this.ref.render(t);this.state;var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),t.rect(e,r,n,i)}get nature(){return dst}get hasTextProperty(){return!1}}mtt.memoize(pst.prototype,"ref",!1),mtt.memoize(pst.prototype,"refScale",!1),mtt.register("local-ref",pst);class fst extends(gat(Gtt)){render(t){}is3dish(){return!0}get layout(){return Ett.get(this.get("layout"))||Mtt}}const gst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"scene-number",name:"ref",placeholder:"SCENE-1"},{type:"number",label:"round",name:"round",property:{min:0}},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio","width","height","none"]}},{type:"select",label:"mode",name:"mode",property:{options:["view","interaction"]}}],"value-property":"ref",help:"scene/component/global-ref"};class vst extends fst{dispose(){this._releaseRef(),super.dispose()}get nature(){return gst}get hasTextProperty(){return!1}get tagName(){return"div"}setElementProperties(t){var{mode:e="view",round:r=0}=this.state;t.style.pointerEvents="view"==e?"none":"inherit",t.style.borderRadius=r+"px"}ready(){super.ready(),this.fetchRef()}reposition(){if(!this.element)return;super.reposition();let t=this._element_bounds,{offsetWidth:e,offsetHeight:r}=this.element;if(this._element_bounds={offsetWidth:e,offsetHeight:r},(!t||t.offsetWidth!=e||t.offsetHeight!=r)&&this.ref&&this.root.target_element){let{fit:t="ratio"}=this.state;this.ref.fit(t)}}async fetchRef(){this._releaseRef();var{ref:t,fit:e="ratio"}=this.state;if(t){var r=this.app.refProvider;if(r&&t)try{this.__ref=await r.get(t,!0),this.__ref.target=this.element,this.__ref.fit(e),this.__ref.data=this.data}catch(t){U7(t)}}}get ref(){return this.__ref}set ref(t){this.setState("ref",t)}_releaseRef(){this.__ref&&this.__ref.release&&this.__ref.release(),delete this.__ref}onchange(t,e,r){super.onchange(t,e,r),"ref"in t&&this.fetchRef(),"fit"in t&&this.ref&&requestAnimationFrame((()=>{let{fit:t}=this.state;this.ref.fit(t)})),"data"in t&&this.ref&&requestAnimationFrame((()=>{this.ref.data=t.data}))}}mtt.register("global-ref",vst);const mst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"board",name:"board"},{type:"checkbox",label:"modal",name:"modal"},{type:"checkbox",label:"closable",name:"closable"},{type:"checkbox",label:"draggable",name:"draggable"},{type:"checkbox",label:"minimizable",name:"minimizable"},{type:"checkbox",label:"show",name:"show"},{type:"select",label:"location",name:"location",property:{options:["center","left-top","right-top","left-bottom","right-bottom","auto"]}},{type:"string",label:"title",name:"text"},{type:"data",label:"value",name:"value"}],help:"scene/component/popup"};class yst extends(wtt(ytt)){static get image(){return yst._image||(yst._image=new Image,yst._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAMAAABG8BK2AAADJmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNy4xLWMwMDAgNzkuZGFiYWNiYiwgMjAyMS8wNC8xNC0wMDozOTo0NCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIzLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RkM4QzQxNUMzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RkM4QzQxNUQzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpENjlENTQ3RjMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpENjlENTQ4MDMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsiUYSQAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAA51BMVEVHcEwzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzOguTm2AAAATHRSTlMARhB73r9B7YLrsqdE+0cq9Avzeg31eQx4aQ+Ks6aUd5DsYKixEX1w8vyT2VjoZ3YezY/cCEDvl+QTvRwJ0ifwK/5T/aw6+IuFuCImAcS6MQAAAeJJREFUWMPt2FlX2zAQhuHJYmOSFhIggbC0QNn3rS1dKXSH9///Hi58CJLxKIpEWi6YO8c5z4lG/nxGEXmu/1OVLGnhrFaSVQYg1SZetTTvUibqeFZ9QlfmvRWoV1VmCaCRzroXPpsuAjTV7gLUfPahBqD1OQMW/fazAWTKvQRI/ZgUSJR7U8CM/dHZ+/2VcatWdvdEZAaYUhiAwkerJXt0rnzXwdRKmHfDM0fHD5kxjTFyVLzVfvvirn7+cDJWjhy7c7XlYuwc6Urvu2tRhRypyhwAf1sKY+TIxfQA+H39q5wxc+RgVrcBduTmZTlj5khnDgH4IzKpMGaOVCbvyyvRGTNHGtPrKypjXirM5jb910I4k69oQeKY+77EMAcALEsck/+W6f71tyCma/ZFROTrJVwMy7wmf3bv6/MX+Dgkkysblvxps/dhOKZb6IvrTakzXXuPApnpYneDGOeKvJlaSXcDmA7AicQyW84VeTOnY+NdiWcG1uiZksFEHdyAlsJEjEkmkwGNsKHNZCJGSKtVTYC1tO022mnjwUBrMdXg8dreuOBhv7D/62/8lGZ1wLxXyZKOm+iUHIQintyny0TkaATHjYgcjeAoFpEje9R/nGPqIx2aw3NU9odCQI6e6x/VLY32cKQXVBnkAAAAAElFTkSuQmCC"),yst._image}ready(){super.ready(),this.show&&this.onchangeShow(!0)}render(t){var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),this.drawImage(t,yst.image,e,r,n,i)}onchange(t,e){"value"in t?this.show?this.onchangeShow(!0):this.show=!0:"show"in t&&this.onchangeShow(this.show)}onchangeShow(t){!this.app.isEditMode&&this.getState("board")&&(t?Rtt.show(this,this.getState("board"),{location:this.getState("location"),modal:this.getState("modal"),closable:this.getState("closable")||!1,draggable:this.getState("draggable")||!1,minimizable:this.getState("minimizable")||!1,title:this.text,data:this.value}):Rtt.hide(this))}get board(){return this.getState("board")}set board(t){this.set("board",t)}get show(){return this.getState("show")}set show(t){this.setState("show",t)}get started(){return this.getState("show")}set started(t){this.setState("show",t)}get value(){return this.getState("value")}set value(t){this.setState("value",t)}get hasTextProperty(){return!1}get nature(){return mst}}mtt.register("popup",yst);class bst extends mtt{render(t){var{path:e=[]}=this.state;if(!(e.length<=1)){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let r=1;r<e.length;r++)t.lineTo(e[r].x,e[r].y);t.closePath(),this.drawStroke(t)}}get path(){return this.model.path}set path(t){this.set("path",t)}contains(t,e){var r=this.state.path,n=!1;return r.forEach(((i,a)=>{let s=(a+r.length+1)%r.length,o=i.x,l=i.y,h=r[s].x,c=r[s].y;l>e!=c>e&&t<(h-o)*(e-l)/(c-l)+o&&(n=!n)})),n}}mtt.register("path",bst);const wst={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/triangle"};class xst extends ytt{contains(t,e){var{x1:r,y1:n,x2:i,y2:a,x3:s,y3:o}=this.state,l=[r,n,i,a,s,o],h=!1;for(let r=0;r<l.length;r+=2){let n=(r+2)%l.length,i=l[r],a=l[r+1],s=l[n+1];a>e!=s>e&&t<(l[n]-i)*(e-a)/(s-a)+i&&(h=!h)}return h}get mutable(){return!0}get path(){var{x1:t,y1:e,x2:r,y2:n,x3:i,y3:a}=this.state;return[{x:t,y:e},{x:r,y:n},{x:i,y:a}]}set path(t){this.set({x1:t[0].x,y1:t[0].y,x2:t[1].x,y2:t[1].y,x3:t[2].x,y3:t[2].y})}get nature(){return wst}}mtt.memoize(xst.prototype,"path",!1),mtt.register("triangle",xst);const Ast={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"}],help:"scene/component/donut"};var _st={ondragmove:function(t,e,r){r.controls;var{cx:n,rx:i}=r.model;i=Math.abs(i);var a=(r.transcoordP2S(t.x,t.y).x-n)/i*100;a=a>=100||a<=-100?100:Math.abs(a),r.set({ratio:a})}};class kst extends Dat{is3dish(){return!1}render(t){var{ratio:e=50,cx:r,cy:n,rx:i,ry:a,startAngle:s,endAngle:o,anticlockwise:l}=this.state;i=Math.abs(i),a=Math.abs(a),t.beginPath(),t.ellipse(r,n,i,a,0,s||0,o||2*Math.PI,l),t.moveTo(r+i/100*e,n),t.ellipse(r,n,i/100*e,a/100*e,0,s||0,o||2*Math.PI,!0)}contains(t,e){var{cx:r,cy:n,rx:i,ry:a,ratio:s}=this.state,o=(t-r)/(2*(i=Math.abs(i))-.5),l=(e-n)/(2*(a=Math.abs(a))-.5),h=(t-r)/(i/100*s*2-.5),c=(e-n)/(a/100*s*2-.5),u=!1;return o*o+l*l<.25&&h*h+c*c>.25&&(u=!u),u}get controls(){var{cx:t,cy:e,rx:r,ratio:n}=this.state;return[{x:t+(r=Math.abs(r))/100*n,y:e,handler:_st}]}get nature(){return Ast}}mtt.memoize(kst.prototype,"controls",!1),mtt.register("donut",kst);const Sst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"},{type:"number",label:"wing",name:"wing",property:"wing"}],help:"scene/component/star"};var Est,Mst,Tst,Cst,Pst,Ist,Rst,Ost,Lst,Dst,Fst,Nst,jst,Bst={ondragmove:function(t,e,r){r.controls;var{cy:n,ry:i}=r.model,a=(r.transcoordP2S(t.x,t.y).y-n)/i*100+100;a>=100?a=100:a<=0&&(a=0),r.set({ratio:a})}};class zst extends Dat{is3dish(){return!1}render(t){var{ratio:e=30,wing:r=5,cx:n,cy:i,rx:a,ry:s,startAngle:o,endAngle:l,anticlockwise:h}=this.state;if(r<3)return;const c=1.5707963267948966;var u=2*Math.PI/r,d=a-e/100*a,p=s-e/100*s;t.save(),t.beginPath(),t.translate(n,i),t.moveTo(a*Math.cos(-c),s*Math.sin(-c)),t.lineTo((a-d)*(Math.cos(u-c)+Math.cos(0-c))/2,(s-p)*(Math.sin(u-c)+Math.sin(0-c))/2);for(var f=1;f<r;f++)t.lineTo(a*Math.cos(u*f-c),s*Math.sin(u*f-c)),t.lineTo((a-d)*(Math.cos(u*(f+1)-c)+Math.cos(u*f-c))/2,(s-p)*(Math.sin(u*(f+1)-c)+Math.sin(u*f-c))/2);t.closePath(),t.restore()}get controls(){var{cx:t,cy:e,ry:r,ratio:n}=this.state;return[{x:t,y:e-r+r*(n/100),handler:Bst}]}get nature(){return Sst}}mtt.memoize(zst.prototype,"controls",!1),mtt.register("star",zst);
45
45
  /**
46
46
  * @licstart The following is the entire license notice for the
47
47
  * JavaScript code in this page
@@ -62,4 +62,4 @@ class uat extends Sit{constructor(){super(...arguments),this.renderOptions={host
62
62
  *
63
63
  * @licend The above is the entire license notice for the
64
64
  * JavaScript code in this page
65
- */var zst={d:(t,e)=>{for(var r in e)zst.o(e,r)&&!zst.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},Wst=globalThis.pdfjsLib={};zst.d(Wst,{AbortException:()=>Zot,AnnotationEditorLayer:()=>qxt,AnnotationEditorParamsType:()=>rot,AnnotationEditorType:()=>eot,AnnotationEditorUIManager:()=>cct,AnnotationLayer:()=>Ymt,AnnotationMode:()=>tot,ColorPicker:()=>xbt,DOMSVGFactory:()=>pvt,DrawLayer:()=>aAt,FeatureTest:()=>nlt,GlobalWorkerOptions:()=>$pt,ImageKind:()=>cot,InvalidPDFException:()=>$ot,MissingPDFException:()=>Kot,OPS:()=>Dot,OutputScale:()=>Olt,PDFDataRangeTransport:()=>Sgt,PDFDateString:()=>Elt,PDFWorker:()=>Ngt,PasswordResponses:()=>Fot,PermissionFlag:()=>not,PixelsPerInch:()=>plt,RenderingCancelledException:()=>mlt,TextLayer:()=>rgt,TouchManager:()=>hut,UnexpectedResponseException:()=>Qot,Util:()=>alt,VerbosityLevel:()=>Lot,XfaLayer:()=>fvt,build:()=>lvt,createValidAbsoluteUrl:()=>Got,fetchData:()=>flt,getDocument:()=>xgt,getFilenameFromUrl:()=>wlt,getPdfFilenameFromUrl:()=>xlt,getXfaPageViewport:()=>Tlt,isDataScheme:()=>ylt,isPdfFile:()=>blt,noContextMenu:()=>klt,normalizeUnicode:()=>clt,setLayerDimensions:()=>Rlt,shadow:()=>Yot,stopEvent:()=>Slt,version:()=>ovt});var Ust=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),Hst=[1,0,0,1,0,0],Gst=[.001,0,0,.001,0,0],Yst=1.35,Vst=1,qst=2,Xst=4,$st=16,Kst=32,Qst=64,Jst=128,Zst=256,tot={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},eot={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},rot={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},not={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},iot=0,aot=1,sot=2,oot=3,lot=3,hot=4,cot={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},uot=1,dot=2,pot=3,fot=4,got=5,vot=6,mot=7,yot=8,bot=9,wot=10,xot=11,Aot=12,_ot=13,kot=14,Sot=15,Eot=16,Mot=17,Tot=20,Cot=1,Pot=2,Iot=3,Rot=4,Oot=5,Lot={ERRORS:0,WARNINGS:1,INFOS:5},Dot={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},Fot={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Not=Lot.WARNINGS;function jot(t){Number.isInteger(t)&&(Not=t)}function Bot(){return Not}function zot(t){Not>=Lot.INFOS&&console.log("Info: ".concat(t))}function Wot(t){Not>=Lot.WARNINGS&&console.log("Warning: ".concat(t))}function Uot(t){throw new Error(t)}function Hot(t,e){t||Uot(e)}function Got(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!t)return null;try{if(r&&"string"==typeof t){if(r.addDefaultProtocol&&t.startsWith("www.")){var n=t.match(/\./g);(null==n?void 0:n.length)>=2&&(t="http://".concat(t))}if(r.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch(t){}}var i=e?new URL(t,e):new URL(t);if(function(t){switch(null==t?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch(t){}return null}function Yot(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!0,writable:!1}),r}var Vot=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class qot extends Vot{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Xot extends Vot{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class $ot extends Vot{constructor(t){super(t,"InvalidPDFException")}}class Kot extends Vot{constructor(t){super(t,"MissingPDFException")}}class Qot extends Vot{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class Jot extends Vot{constructor(t){super(t,"FormatError")}}class Zot extends Vot{constructor(t){super(t,"AbortException")}}function tlt(t){"object"==typeof t&&void 0!==(null==t?void 0:t.length)||Uot("Invalid argument for bytesToString");var e=t.length,r=8192;if(e<r)return String.fromCharCode.apply(null,t);for(var n=[],i=0;i<e;i+=r){var a=Math.min(i+r,e),s=t.subarray(i,a);n.push(String.fromCharCode.apply(null,s))}return n.join("")}function elt(t){"string"!=typeof t&&Uot("Invalid argument for stringToBytes");for(var e=t.length,r=new Uint8Array(e),n=0;n<e;++n)r[n]=255&t.charCodeAt(n);return r}function rlt(t){var e=Object.create(null);for(var[r,n]of t)e[r]=n;return e}class nlt{static get isLittleEndian(){return Yot(this,"isLittleEndian",((t=new Uint8Array(4))[0]=1,1===new Uint32Array(t.buffer,0,1)[0]));var t}static get isEvalSupported(){return Yot(this,"isEvalSupported",function(){try{return new Function(""),!0}catch(t){return!1}}())}static get isOffscreenCanvasSupported(){return Yot(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Yot(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){var t,e;return"undefined"!=typeof navigator&&"string"==typeof(null===(t=navigator)||void 0===t?void 0:t.platform)?Yot(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof(null===(e=navigator)||void 0===e?void 0:e.userAgent)&&navigator.userAgent.includes("Firefox")}):Yot(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return Yot(this,"isCSSRoundSupported",null===(t=globalThis.CSS)||void 0===t||null===(e=t.supports)||void 0===e?void 0:e.call(t,"width: round(1.5px, 1px)"))}}var ilt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class alt{static makeHexColor(t,e,r){return"#".concat(ilt[t]).concat(ilt[e]).concat(ilt[r])}static scaleMinMax(t,e){var r;t[0]?(t[0]<0&&(r=e[0],e[0]=e[2],e[2]=r),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(r=e[1],e[1]=e[3],e[3]=r),e[1]*=t[3],e[3]*=t[3]):(r=e[0],e[0]=e[1],e[1]=r,r=e[2],e[2]=e[3],e[3]=r,t[1]<0&&(r=e[1],e[1]=e[3],e[3]=r),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(r=e[0],e[0]=e[2],e[2]=r),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){var r=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/r,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/r]}static getAxialAlignedBoundingBox(t,e){var r=this.applyTransform(t,e),n=this.applyTransform(t.slice(2,4),e),i=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(r[0],n[0],i[0],a[0]),Math.min(r[1],n[1],i[1],a[1]),Math.max(r[0],n[0],i[0],a[0]),Math.max(r[1],n[1],i[1],a[1])]}static inverseTransform(t){var e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){var e=[t[0],t[2],t[1],t[3]],r=t[0]*e[0]+t[1]*e[2],n=t[0]*e[1]+t[1]*e[3],i=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],s=(r+a)/2,o=Math.sqrt(Math.pow(r+a,2)-4*(r*a-i*n))/2,l=s+o||1,h=s-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){var e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){var r=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(r>n)return null;var i=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return i>a?null:[r,i,n,a]}static bezierBoundingBox(t,e,r,n,i,a,s,o,l){return l?(l[0]=Math.min(l[0],t,s),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,s),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,s),Math.min(e,o),Math.max(t,s),Math.max(e,o)],bnt(alt,this,olt).call(this,t,r,i,s,e,n,a,o,3*(3*(r-i)-t+s),6*(t-2*r+i),3*(r-t),l),bnt(alt,this,olt).call(this,t,r,i,s,e,n,a,o,3*(3*(n-a)-e+o),6*(e-2*n+a),3*(n-e),l),l}}function slt(t,e,r,n,i,a,s,o,l,h){if(!(l<=0||l>=1)){var c=1-l,u=l*l,d=u*l,p=c*(c*(c*t+3*l*e)+3*u*r)+d*n,f=c*(c*(c*i+3*l*a)+3*u*s)+d*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],f),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],f)}}function olt(t,e,r,n,i,a,s,o,l,h,c,u){if(Math.abs(l)<1e-12)Math.abs(h)>=1e-12&&bnt(Sst,this,slt).call(this,t,e,r,n,i,a,s,o,-c/h,u);else{var d=Math.pow(h,2)-4*c*l;if(!(d<0)){var p=Math.sqrt(d),f=2*l;bnt(Sst,this,slt).call(this,t,e,r,n,i,a,s,o,(-h+p)/f,u),bnt(Sst,this,slt).call(this,t,e,r,n,i,a,s,o,(-h-p)/f,u)}}}Sst=alt;var llt=null,hlt=null;function clt(t){return llt||(llt=/([\xA0\xB5\u037E\u0EB3\u2000-\u200A\u202F\u2126\uFB00-\uFB04\uFB06\uFB20-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBA1\uFBA4-\uFBA9\uFBAE-\uFBB1\uFBD3-\uFBDC\uFBDE-\uFBE7\uFBEA-\uFBF8\uFBFC\uFBFD\uFC00-\uFC5D\uFC64-\uFCF1\uFCF5-\uFD3D\uFD88\uFDF4\uFDFA\uFDFB\uFE71\uFE77\uFE79\uFE7B\uFE7D]+)|(\uFB05+)/g,hlt=new Map([["ſt","ſt"]])),t.replaceAll(llt,((t,e,r)=>e?e.normalize("NFKC"):hlt.get(r)))}var ult="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return new Promise((e=>{e(t(...r))}))});var dlt="http://www.w3.org/2000/svg";class plt{}function flt(t){return glt.apply(this,arguments)}function glt(){return glt=xnt((function*(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";if(_lt(t,document.baseURI)){var r=yield fetch(t);if(!r.ok)throw new Error(r.statusText);switch(e){case"arraybuffer":return r.arrayBuffer();case"blob":return r.blob();case"json":return r.json()}return r.text()}return new Promise(((r,n)=>{var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(200!==i.status&&0!==i.status)n(new Error(i.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void r(i.response)}r(i.responseText)}},i.send(null)}))})),glt.apply(this,arguments)}Est=plt,Tnt(plt,"CSS",96),Tnt(plt,"PDF",72),Tnt(plt,"PDF_TO_CSS_UNITS",Est.CSS/Est.PDF);class vlt{constructor(t){var{viewBox:e,userUnit:r,scale:n,rotation:i,offsetX:a=0,offsetY:s=0,dontFlip:o=!1}=t;this.viewBox=e,this.userUnit=r,this.scale=n,this.rotation=i,this.offsetX=a,this.offsetY=s,n*=r;var l,h,c,u,d,p,f,g,v=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch((i%=360)<0&&(i+=360),i){case 180:l=-1,h=0,c=0,u=1;break;case 90:l=0,h=1,c=1,u=0;break;case 270:l=0,h=-1,c=-1,u=0;break;case 0:l=1,h=0,c=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(c=-c,u=-u),0===l?(d=Math.abs(m-e[1])*n+a,p=Math.abs(v-e[0])*n+s,f=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(d=Math.abs(v-e[0])*n+a,p=Math.abs(m-e[1])*n+s,f=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,h*n,c*n,u*n,d-l*n*v-c*n*m,p-h*n*v-u*n*m],this.width=f,this.height=g}get rawDims(){var{userUnit:t,viewBox:e}=this,r=e.map((e=>e*t));return Yot(this,"rawDims",{pageWidth:r[2]-r[0],pageHeight:r[3]-r[1],pageX:r[0],pageY:r[1]})}clone(){var{scale:t=this.scale,rotation:e=this.rotation,offsetX:r=this.offsetX,offsetY:n=this.offsetY,dontFlip:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new vlt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:r,offsetY:n,dontFlip:i})}convertToViewportPoint(t,e){return alt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){var e=alt.applyTransform([t[0],t[1]],this.transform),r=alt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],r[0],r[1]]}convertToPdfPoint(t,e){return alt.applyInverseTransform([t,e],this.transform)}}class mlt extends Vot{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;super(t,"RenderingCancelledException"),this.extraDelay=e}}function ylt(t){for(var e=t.length,r=0;r<e&&""===t[r].trim();)r++;return"data:"===t.substring(r,r+5).toLowerCase()}function blt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function wlt(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function xlt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"document.pdf";if("string"!=typeof t)return e;if(ylt(t))return Wot('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;var r=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t),i=r.exec(n[1])||r.exec(n[2])||r.exec(n[3]);if(i&&(i=i[0]).includes("%"))try{i=r.exec(decodeURIComponent(i))[0]}catch(t){}return i||e}class Alt{constructor(){Tnt(this,"started",Object.create(null)),Tnt(this,"times",[])}time(t){t in this.started&&Wot("Timer is already running for ".concat(t)),this.started[t]=Date.now()}timeEnd(t){t in this.started||Wot("Timer has not been started for ".concat(t)),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){var t=[],e=0;for(var{name:r}of this.times)e=Math.max(r.length,e);for(var{name:n,start:i,end:a}of this.times)t.push("".concat(n.padEnd(e)," ").concat(a-i,"ms\n"));return t.join("")}}function _lt(t,e){try{var{protocol:r}=e?new URL(t,e):new URL(t);return"http:"===r||"https:"===r}catch(t){return!1}}function klt(t){t.preventDefault()}function Slt(t){t.preventDefault(),t.stopPropagation()}class Elt{static toDateObject(t){if(!t||"string"!=typeof t)return null;bnt(Elt,this,Mlt)._||(Mlt._=bnt(Elt,this,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?")));var e=bnt(Elt,this,Mlt)._.exec(t);if(!e)return null;var r=parseInt(e[1],10),n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;var i=parseInt(e[3],10);i=i>=1&&i<=31?i:1;var a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;var s=parseInt(e[5],10);s=s>=0&&s<=59?s:0;var o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;var l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;var c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(a+=h,s+=c):"+"===l&&(a-=h,s-=c),new Date(Date.UTC(r,n,i,a,s,o))}}var Mlt={_:void 0};function Tlt(t,e){var{scale:r=1,rotation:n=0}=e,{width:i,height:a}=t.attributes.style,s=[0,0,parseInt(i),parseInt(a)];return new vlt({viewBox:s,userUnit:1,scale:r,rotation:n})}function Clt(t){if(t.startsWith("#")){var e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(Wot('Not a valid color format: "'.concat(t,'"')),[0,0,0])}function Plt(t){var{a:e,b:r,c:n,d:i,e:a,f:s}=t.getTransform();return[e,r,n,i,a,s]}function Ilt(t){var{a:e,b:r,c:n,d:i,e:a,f:s}=t.getTransform().invertSelf();return[e,r,n,i,a,s]}function Rlt(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(e instanceof vlt){var{pageWidth:i,pageHeight:a}=e.rawDims,{style:s}=t,o=nlt.isCSSRoundSupported,l="var(--scale-factor) * ".concat(i,"px"),h="var(--scale-factor) * ".concat(a,"px"),c=o?"round(down, ".concat(l,", var(--scale-round-x, 1px))"):"calc(".concat(l,")"),u=o?"round(down, ".concat(h,", var(--scale-round-y, 1px))"):"calc(".concat(h,")");r&&e.rotation%180!=0?(s.width=u,s.height=c):(s.width=c,s.height=u)}n&&t.setAttribute("data-main-rotation",e.rotation)}class Olt{constructor(){var t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}var Llt=new WeakMap,Dlt=new WeakMap,Flt=new WeakMap,Nlt=new WeakMap,jlt=new WeakMap,Blt=new WeakSet;class zlt{constructor(t){Mnt(this,Blt),knt(this,Llt,null),knt(this,Dlt,null),knt(this,Flt,void 0),knt(this,Nlt,null),knt(this,jlt,null),Snt(Flt,this,t),qlt._||(qlt._=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){var t=Snt(Llt,this,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");var e=_nt(Flt,this)._uiManager._signal;t.addEventListener("contextmenu",klt,{signal:e}),t.addEventListener("pointerdown",Wlt,{signal:e});var r=Snt(Nlt,this,document.createElement("div"));r.className="buttons",t.append(r);var n=_nt(Flt,this).toolbarPosition;if(n){var{style:i}=t,a="ltr"===_nt(Flt,this)._uiManager.direction?1-n[0]:n[0];i.insetInlineEnd="".concat(100*a,"%"),i.top="calc(".concat(100*n[1],"% + var(--editor-toolbar-vert-offset))")}return bnt(Blt,this,Ylt).call(this),t}get div(){return _nt(Llt,this)}hide(){var t;_nt(Llt,this).classList.add("hidden"),null===(t=_nt(Dlt,this))||void 0===t||t.hideDropdown()}show(){var t;_nt(Llt,this).classList.remove("hidden"),null===(t=_nt(jlt,this))||void 0===t||t.shown()}addAltText(t){var e=this;return xnt((function*(){var r=yield t.render();bnt(Blt,e,Glt).call(e,r),_nt(Nlt,e).prepend(r,Ent(Blt,e,Vlt)),Snt(jlt,e,t)}))()}addColorPicker(t){Snt(Dlt,this,t);var e=t.renderButton();bnt(Blt,this,Glt).call(this,e),_nt(Nlt,this).prepend(e,Ent(Blt,this,Vlt))}remove(){var t;_nt(Llt,this).remove(),null===(t=_nt(Dlt,this))||void 0===t||t.destroy(),Snt(Dlt,this,null)}}function Wlt(t){t.stopPropagation()}function Ult(t){_nt(Flt,this)._focusEventsAllowed=!1,Slt(t)}function Hlt(t){_nt(Flt,this)._focusEventsAllowed=!0,Slt(t)}function Glt(t){var e=_nt(Flt,this)._uiManager._signal;t.addEventListener("focusin",bnt(Blt,this,Ult).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",bnt(Blt,this,Hlt).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",klt,{signal:e})}function Ylt(){var{editorType:t,_uiManager:e}=_nt(Flt,this),r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",qlt._[t]),bnt(Blt,this,Glt).call(this,r),r.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),_nt(Nlt,this).append(r)}function Vlt(t){var e=document.createElement("div");return e.className="divider",e}var qlt={_:null},Xlt=new WeakMap,$lt=new WeakMap,Klt=new WeakMap,Qlt=new WeakSet;class Jlt{constructor(t){Mnt(this,Qlt),knt(this,Xlt,null),knt(this,$lt,null),knt(this,Klt,void 0),Snt(Klt,this,t)}show(t,e,r){var[n,i]=bnt(Qlt,this,tht).call(this,e,r),{style:a}=_nt($lt,this)||Snt($lt,this,bnt(Qlt,this,Zlt).call(this));t.append(_nt($lt,this)),a.insetInlineEnd="".concat(100*n,"%"),a.top="calc(".concat(100*i,"% + var(--editor-toolbar-vert-offset))")}hide(){_nt($lt,this).remove()}}function Zlt(){var t=Snt($lt,this,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",klt,{signal:_nt(Klt,this)._signal});var e=Snt(Xlt,this,document.createElement("div"));return e.className="buttons",t.append(e),bnt(Qlt,this,eht).call(this),t}function tht(t,e){var r=0,n=0;for(var i of t){var a=i.y+i.height;if(!(a<r)){var s=i.x+(e?i.width:0);a>r?(n=s,r=a):e?s>n&&(n=s):s<n&&(n=s)}}return[e?1-n:n,r]}function eht(){var t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");var e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");var r=_nt(Klt,this)._signal;t.addEventListener("contextmenu",klt,{signal:r}),t.addEventListener("click",(()=>{_nt(Klt,this).highlightSelection("floating_button")}),{signal:r}),_nt(Xlt,this).append(t)}function rht(t,e,r){for(var n of r)e.addEventListener(n,t[n].bind(t))}var nht=new WeakMap;class iht{constructor(){knt(this,nht,0)}get id(){var t,e;return"".concat("pdfjs_internal_editor_").concat((Snt(nht,this,(t=_nt(nht,this),e=t++,t)),e))}}var aht=new WeakMap,sht=new WeakMap,oht=new WeakMap,lht=new WeakSet;class hht{constructor(){Mnt(this,lht),knt(this,aht,function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();var t=new Uint8Array(32);return crypto.getRandomValues(t),tlt(t)}()),knt(this,sht,0),knt(this,oht,null)}static get _isSVGFittingCanvas(){var t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',Yot(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}getFromFile(t){var e=this;return xnt((function*(){var{lastModified:r,name:n,size:i,type:a}=t;return bnt(lht,e,cht).call(e,"".concat(r,"_").concat(n,"_").concat(i,"_").concat(a),t)}))()}getFromUrl(t){var e=this;return xnt((function*(){return bnt(lht,e,cht).call(e,t,t)}))()}getFromBlob(t,e){var r=this;return xnt((function*(){var n=yield e;return bnt(lht,r,cht).call(r,t,n)}))()}getFromId(t){var e=this;return xnt((function*(){_nt(oht,e)||Snt(oht,e,new Map);var r=_nt(oht,e).get(t);if(!r)return null;if(r.bitmap)return r.refCounter+=1,r;if(r.file)return e.getFromFile(r.file);if(r.blobPromise){var{blobPromise:n}=r;return delete r.blobPromise,e.getFromBlob(r.id,n)}return e.getFromUrl(r.url)}))()}getFromCanvas(t,e){var r,n,i;_nt(oht,this)||Snt(oht,this,new Map);var a=_nt(oht,this).get(t);if(null!==(i=a)&&void 0!==i&&i.bitmap)return a.refCounter+=1,a;var s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),a={bitmap:s.transferToImageBitmap(),id:"image_".concat(_nt(aht,this),"_").concat((Snt(sht,this,(r=_nt(sht,this),n=r++,r)),n)),refCounter:1,isSvg:!1},_nt(oht,this).set(t,a),_nt(oht,this).set(a.id,a),a}getSvgUrl(t){var e=_nt(oht,this).get(t);return null!=e&&e.isSvg?e.svgUrl:null}deleteId(t){var e;_nt(oht,this)||Snt(oht,this,new Map);var r=_nt(oht,this).get(t);if(r&&(r.refCounter-=1,0===r.refCounter)){var{bitmap:n}=r;if(!r.url&&!r.file){var i=new OffscreenCanvas(n.width,n.height);i.getContext("bitmaprenderer").transferFromImageBitmap(n),r.blobPromise=i.convertToBlob()}null===(e=n.close)||void 0===e||e.call(n),r.bitmap=null}}isValidId(t){return t.startsWith("image_".concat(_nt(aht,this),"_"))}}function cht(t,e){return uht.apply(this,arguments)}function uht(){return uht=xnt((function*(t,e){var r;_nt(oht,this)||Snt(oht,this,new Map);var n=_nt(oht,this).get(t);if(null===n)return null;if(null!==(r=n)&&void 0!==r&&r.bitmap)return n.refCounter+=1,n;try{var i,a,s;if(n||(n={bitmap:null,id:"image_".concat(_nt(aht,this),"_").concat((Snt(sht,this,(i=_nt(sht,this),a=i++,i)),a)),refCounter:0,isSvg:!1}),"string"==typeof e?(n.url=e,s=yield flt(e,"blob")):e instanceof File?s=n.file=e:e instanceof Blob&&(s=e),"image/svg+xml"===s.type){var o=Mst._isSVGFittingCanvas,l=new FileReader,h=new Image,c=new Promise(((t,e)=>{h.onload=()=>{n.bitmap=h,n.isSvg=!0,t()},l.onload=xnt((function*(){var t=n.svgUrl=l.result;h.src=(yield o)?"".concat(t,"#svgView(preserveAspectRatio(none))"):t})),h.onerror=l.onerror=e}));l.readAsDataURL(s),yield c}else n.bitmap=yield createImageBitmap(s);n.refCounter=1}catch(t){Wot(t),n=null}return _nt(oht,this).set(t,n),n&&_nt(oht,this).set(n.id,n),n})),uht.apply(this,arguments)}Mst=hht;var dht=new WeakMap,pht=new WeakMap,fht=new WeakMap,ght=new WeakMap;class vht{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:128;knt(this,dht,[]),knt(this,pht,!1),knt(this,fht,void 0),knt(this,ght,-1),Snt(fht,this,t)}add(t){var{cmd:e,undo:r,post:n,mustExec:i,type:a=NaN,overwriteIfSameType:s=!1,keepUndo:o=!1}=t;if(i&&e(),!_nt(pht,this)){var l={cmd:e,undo:r,post:n,type:a};if(-1===_nt(ght,this))return _nt(dht,this).length>0&&(_nt(dht,this).length=0),Snt(ght,this,0),void _nt(dht,this).push(l);if(s&&_nt(dht,this)[_nt(ght,this)].type===a)return o&&(l.undo=_nt(dht,this)[_nt(ght,this)].undo),void(_nt(dht,this)[_nt(ght,this)]=l);var h=_nt(ght,this)+1;h===_nt(fht,this)?_nt(dht,this).splice(0,1):(Snt(ght,this,h),h<_nt(dht,this).length&&_nt(dht,this).splice(h)),_nt(dht,this).push(l)}}undo(){if(-1!==_nt(ght,this)){Snt(pht,this,!0);var{undo:t,post:e}=_nt(dht,this)[_nt(ght,this)];t(),null==e||e(),Snt(pht,this,!1),Snt(ght,this,_nt(ght,this)-1)}}redo(){if(_nt(ght,this)<_nt(dht,this).length-1){Snt(ght,this,_nt(ght,this)+1),Snt(pht,this,!0);var{cmd:t,post:e}=_nt(dht,this)[_nt(ght,this)];t(),null==e||e(),Snt(pht,this,!1)}}hasSomethingToUndo(){return-1!==_nt(ght,this)}hasSomethingToRedo(){return _nt(ght,this)<_nt(dht,this).length-1}cleanType(t){if(-1!==_nt(ght,this)){for(var e=_nt(ght,this);e>=0;e--)if(_nt(dht,this)[e].type!==t)return _nt(dht,this).splice(e+1,_nt(ght,this)-e),void Snt(ght,this,e);_nt(dht,this).length=0,Snt(ght,this,-1)}}destroy(){Snt(dht,this,null)}}var mht=new WeakSet;class yht{constructor(t){Mnt(this,mht),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;var{isMac:e}=nlt.platform;for(var[r,n,i={}]of t)for(var a of r){var s=a.startsWith("mac+");e&&s?(this.callbacks.set(a.slice(4),{callback:n,options:i}),this.allKeys.add(a.split("+").at(-1))):e||s||(this.callbacks.set(a,{callback:n,options:i}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(this.allKeys.has(e.key)){var r=this.callbacks.get(bnt(mht,this,bht).call(this,e));if(r){var{callback:n,options:{bubbles:i=!1,args:a=[],checker:s=null}}=r;s&&!s(t,e)||(n.bind(t,...a,e)(),i||Slt(e))}}}}function bht(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);var e=this.buffer.join("+");return this.buffer.length=0,e}class wht{get _colors(){var t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){var e=document.createElement("span");for(var r of(e.style.visibility="hidden",document.body.append(e),t.keys())){e.style.color=r;var n=window.getComputedStyle(e).color;t.set(r,Clt(n))}e.remove()}(t),Yot(this,"_colors",t)}convert(t){var e=Clt(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(var[r,n]of this._colors)if(n.every(((t,r)=>t===e[r])))return wht._colorsMapping.get(r);return e}getHexCode(t){var e=this._colors.get(t);return e?alt.makeHexColor(...e):t}}Tnt(wht,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));var xht=new WeakMap,Aht=new WeakMap,_ht=new WeakMap,kht=new WeakMap,Sht=new WeakMap,Eht=new WeakMap,Mht=new WeakMap,Tht=new WeakMap,Cht=new WeakMap,Pht=new WeakMap,Iht=new WeakMap,Rht=new WeakMap,Oht=new WeakMap,Lht=new WeakMap,Dht=new WeakMap,Fht=new WeakMap,Nht=new WeakMap,jht=new WeakMap,Bht=new WeakMap,zht=new WeakMap,Wht=new WeakMap,Uht=new WeakMap,Hht=new WeakMap,Ght=new WeakMap,Yht=new WeakMap,Vht=new WeakMap,qht=new WeakMap,Xht=new WeakMap,$ht=new WeakMap,Kht=new WeakMap,Qht=new WeakMap,Jht=new WeakMap,Zht=new WeakMap,tct=new WeakMap,ect=new WeakMap,rct=new WeakMap,nct=new WeakMap,ict=new WeakMap,act=new WeakMap,sct=new WeakMap,oct=new WeakMap,lct=new WeakMap,hct=new WeakSet;class cct{static get _keyboardManager(){var t=cct.prototype,e=t=>_nt(sct,t).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),r=(t,e)=>{var{target:r}=e;if(r instanceof HTMLInputElement){var{type:n}=r;return"text"!==n&&"number"!==n}return!0},n=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return Yot(this,"_keyboardManager",new yht([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:r}],[["ctrl+z","mac+meta+z"],t.undo,{checker:r}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:r}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:r}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,e)=>{var{target:r}=e;return!(r instanceof HTMLButtonElement)&&_nt(sct,t).contains(r)&&!t.isEnterHandled}}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,e)=>{var{target:r}=e;return!(r instanceof HTMLButtonElement)&&_nt(sct,t).contains(document.activeElement)}}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}]]))}constructor(t,e,r,n,i,a,s,o,l,h,c,u,d){Mnt(this,hct),knt(this,xht,new AbortController),knt(this,Aht,null),knt(this,_ht,new Map),knt(this,kht,new Map),knt(this,Sht,null),knt(this,Eht,null),knt(this,Mht,null),knt(this,Tht,new vht),knt(this,Cht,null),knt(this,Pht,null),knt(this,Iht,0),knt(this,Rht,new Set),knt(this,Oht,null),knt(this,Lht,null),knt(this,Dht,new Set),Tnt(this,"_editorUndoBar",null),knt(this,Fht,!1),knt(this,Nht,!1),knt(this,jht,!1),knt(this,Bht,null),knt(this,zht,null),knt(this,Wht,null),knt(this,Uht,null),knt(this,Hht,!1),knt(this,Ght,null),knt(this,Yht,new iht),knt(this,Vht,!1),knt(this,qht,!1),knt(this,Xht,null),knt(this,$ht,null),knt(this,Kht,null),knt(this,Qht,null),knt(this,Jht,eot.NONE),knt(this,Zht,new Set),knt(this,tct,null),knt(this,ect,null),knt(this,rct,null),knt(this,nct,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),knt(this,ict,[0,0]),knt(this,act,null),knt(this,sct,null),knt(this,oct,null),knt(this,lct,null);var p=this._signal=_nt(xht,this).signal;Snt(sct,this,t),Snt(oct,this,e),Snt(Sht,this,r),this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:p}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),n._on("setpreference",this.onSetPreference.bind(this),{signal:p}),n._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),bnt(hct,this,vct).call(this),bnt(hct,this,_ct).call(this),bnt(hct,this,bct).call(this),Snt(Eht,this,i.annotationStorage),Snt(Bht,this,i.filterFactory),Snt(ect,this,a),Snt(Uht,this,s||null),Snt(Fht,this,o),Snt(Nht,this,l),Snt(jht,this,h),Snt(Qht,this,c||null),this.viewParameters={realScale:plt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=u||null,this._supportsPinchToZoom=!1!==d}destroy(){var t,e,r,n,i;for(var a of(null===(t=_nt(lct,this))||void 0===t||t.resolve(),Snt(lct,this,null),null===(e=_nt(xht,this))||void 0===e||e.abort(),Snt(xht,this,null),this._signal=null,_nt(kht,this).values()))a.destroy();_nt(kht,this).clear(),_nt(_ht,this).clear(),_nt(Dht,this).clear(),Snt(Aht,this,null),_nt(Zht,this).clear(),_nt(Tht,this).destroy(),null===(r=_nt(Sht,this))||void 0===r||r.destroy(),null===(n=_nt(Ght,this))||void 0===n||n.hide(),Snt(Ght,this,null),_nt(zht,this)&&(clearTimeout(_nt(zht,this)),Snt(zht,this,null)),_nt(act,this)&&(clearTimeout(_nt(act,this)),Snt(act,this,null)),null===(i=this._editorUndoBar)||void 0===i||i.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return _nt(Qht,this)}get useNewAltTextFlow(){return _nt(Nht,this)}get useNewAltTextWhenAddingImage(){return _nt(jht,this)}get hcmFilter(){return Yot(this,"hcmFilter",_nt(ect,this)?_nt(Bht,this).addHCMFilter(_nt(ect,this).foreground,_nt(ect,this).background):"none")}get direction(){return Yot(this,"direction",getComputedStyle(_nt(sct,this)).direction)}get highlightColors(){return Yot(this,"highlightColors",_nt(Uht,this)?new Map(_nt(Uht,this).split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return Yot(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),Snt(Pht,this,t)}setMainHighlightColorPicker(t){Snt(Kht,this,t)}editAltText(t){var e,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null===(e=_nt(Sht,this))||void 0===e||e.editAltText(this,t,r)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference(t){var{name:e,value:r}=t;if("enableNewAltTextWhenAddingImage"===e)Snt(jht,this,r)}onPageChanging(t){var{pageNumber:e}=t;Snt(Iht,this,e-1)}focusMainContainer(){_nt(sct,this).focus()}findParent(t,e){for(var r of _nt(kht,this).values()){var{x:n,y:i,width:a,height:s}=r.div.getBoundingClientRect();if(t>=n&&t<=n+a&&e>=i&&e<=i+s)return r}return null}disableUserSelect(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];_nt(oct,this).classList.toggle("noUserSelect",t)}addShouldRescale(t){_nt(Dht,this).add(t)}removeShouldRescale(t){_nt(Dht,this).delete(t)}onScaleChanging(t){var e,{scale:r}=t;for(var n of(this.commitOrRemove(),this.viewParameters.realScale=r*plt.PDF_TO_CSS_UNITS,_nt(Dht,this)))n.onScaleChanging();null===(e=_nt(Pht,this))||void 0===e||e.onScaleChanging()}onRotationChanging(t){var{pagesRotation:e}=t;this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=document.getSelection();if(e&&!e.isCollapsed){var{anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:a}=e,s=e.toString(),o=bnt(hct,this,uct).call(this,e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(l){e.empty();var h=bnt(hct,this,dct).call(this,o),c=_nt(Jht,this)===eot.NONE,u=()=>{null==h||h.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:a,text:s}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(eot.HIGHLIGHT,u):u()}}}addToAnnotationStorage(t){t.isEmpty()||!_nt(Eht,this)||_nt(Eht,this).has(t.id)||_nt(Eht,this).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,_nt(Hht,this)&&(Snt(Hht,this,!1),bnt(hct,this,gct).call(this,"main_toolbar")),this.hasSelection){var{activeElement:t}=document;for(var e of _nt(Zht,this))if(e.div.contains(t)){Snt($ht,this,[e,t]),e._focusEventsAllowed=!1;break}}}focus(){if(_nt($ht,this)){var[t,e]=_nt($ht,this);Snt($ht,this,null),e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}}addEditListeners(){bnt(hct,this,bct).call(this),bnt(hct,this,xct).call(this)}removeEditListeners(){bnt(hct,this,wct).call(this),bnt(hct,this,Act).call(this)}dragOver(t){for(var{type:e}of t.dataTransfer.items)for(var r of _nt(Lht,this))if(r.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(var e of t.dataTransfer.items)for(var r of _nt(Lht,this))if(r.isHandlingMimeForPasting(e.type))return r.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null===(e=_nt(Aht,this))||void 0===e||e.commitOrRemove(),this.hasSelection){var r=[];for(var n of _nt(Zht,this)){var i=n.serialize(!0);i&&r.push(i)}0!==r.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(r))}}cut(t){this.copy(t),this.delete()}paste(t){var e=this;return xnt((function*(){t.preventDefault();var{clipboardData:r}=t;for(var n of r.items)for(var i of _nt(Lht,e))if(i.isHandlingMimeForPasting(n.type))return void i.paste(n,e.currentLayer);var a=r.getData("application/pdfjs");if(a){try{a=JSON.parse(a)}catch(t){return void Wot('paste: "'.concat(t.message,'".'))}if(Array.isArray(a)){e.unselectAll();var s=e.currentLayer;try{var o=[];for(var l of a){var h=yield s.deserialize(l);if(!h)return;o.push(h)}e.addCommands({cmd:()=>{for(var t of o)bnt(hct,e,Cct).call(e,t);bnt(hct,e,Rct).call(e,o)},undo:()=>{for(var t of o)t.remove()},mustExec:!0})}catch(t){Wot('paste: "'.concat(t.message,'".'))}}}}))()}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),_nt(Jht,this)===eot.NONE||this.isEditorHandlingKeyboard||cct._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,_nt(Hht,this)&&(Snt(Hht,this,!1),bnt(hct,this,gct).call(this,"main_toolbar")))}onEditingAction(t){var{name:e}=t;switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(t){t?(bnt(hct,this,mct).call(this),bnt(hct,this,xct).call(this),bnt(hct,this,kct).call(this,{isEditing:_nt(Jht,this)!==eot.NONE,isEmpty:bnt(hct,this,Ict).call(this),hasSomethingToUndo:_nt(Tht,this).hasSomethingToUndo(),hasSomethingToRedo:_nt(Tht,this).hasSomethingToRedo(),hasSelectedEditor:!1})):(bnt(hct,this,yct).call(this),bnt(hct,this,Act).call(this),bnt(hct,this,kct).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!_nt(Lht,this))for(var e of(Snt(Lht,this,t),_nt(Lht,this)))bnt(hct,this,Sct).call(this,e.defaultPropertiesToUpdate)}getId(){return _nt(Yht,this).id}get currentLayer(){return _nt(kht,this).get(_nt(Iht,this))}getLayer(t){return _nt(kht,this).get(t)}get currentPageIndex(){return _nt(Iht,this)}addLayer(t){_nt(kht,this).set(t.pageIndex,t),_nt(Vht,this)?t.enable():t.disable()}removeLayer(t){_nt(kht,this).delete(t.pageIndex)}updateMode(t){var e=arguments,r=this;return xnt((function*(){var n=e.length>1&&void 0!==e[1]?e[1]:null,i=e.length>2&&void 0!==e[2]&&e[2];if(_nt(Jht,r)!==t&&(!_nt(lct,r)||(yield _nt(lct,r).promise,_nt(lct,r)))){var a;if(Snt(lct,r,Promise.withResolvers()),Snt(Jht,r,t),t===eot.NONE)return r.setEditingState(!1),bnt(hct,r,Tct).call(r),null===(a=r._editorUndoBar)||void 0===a||a.hide(),void _nt(lct,r).resolve();for(var s of(r.setEditingState(!0),yield bnt(hct,r,Ect).call(r),r.unselectAll(),_nt(kht,r).values()))s.updateMode(t);if(!n)return i&&r.addNewEditorFromKeyboard(),void _nt(lct,r).resolve();for(var o of _nt(_ht,r).values())o.annotationElementId===n?(r.setSelected(o),o.enterInEditMode()):o.unselect();_nt(lct,r).resolve()}}))()}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==_nt(Jht,this)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var r;if(_nt(Lht,this)){switch(t){case rot.CREATE:return void this.currentLayer.addNewEditor();case rot.HIGHLIGHT_DEFAULT_COLOR:null===(r=_nt(Kht,this))||void 0===r||r.updateColor(e);break;case rot.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(_nt(rct,this)||Snt(rct,this,new Map)).set(t,e),this.showAllEditors("highlight",e)}for(var n of _nt(Zht,this))n.updateParams(t,e);for(var i of _nt(Lht,this))i.updateDefaultParams(t,e)}}showAllEditors(t,e){var r,n;for(var i of _nt(_ht,this).values())i.editorType===t&&i.show(e);(null===(r=null===(n=_nt(rct,this))||void 0===n?void 0:n.get(rot.HIGHLIGHT_SHOW_ALL))||void 0===r||r)!==e&&bnt(hct,this,Sct).call(this,[[rot.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(_nt(qht,this)!==t)for(var e of(Snt(qht,this,t),_nt(kht,this).values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}getEditors(t){var e=[];for(var r of _nt(_ht,this).values())r.pageIndex===t&&e.push(r);return e}getEditor(t){return _nt(_ht,this).get(t)}addEditor(t){_nt(_ht,this).set(t.id,t)}removeEditor(t){var e;(t.div.contains(document.activeElement)&&(_nt(zht,this)&&clearTimeout(_nt(zht,this)),Snt(zht,this,setTimeout((()=>{this.focusMainContainer(),Snt(zht,this,null)}),0))),_nt(_ht,this).delete(t.id),this.unselect(t),t.annotationElementId&&_nt(Rht,this).has(t.annotationElementId))||(null===(e=_nt(Eht,this))||void 0===e||e.remove(t.id))}addDeletedAnnotationElement(t){_nt(Rht,this).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return _nt(Rht,this).has(t)}removeDeletedAnnotationElement(t){_nt(Rht,this).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){_nt(Aht,this)!==t&&(Snt(Aht,this,t),t&&bnt(hct,this,Sct).call(this,t.propertiesToUpdate))}updateUI(t){Ent(hct,this,Pct)===t&&bnt(hct,this,Sct).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){bnt(hct,this,Sct).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(_nt(Zht,this).has(t))return _nt(Zht,this).delete(t),t.unselect(),void bnt(hct,this,kct).call(this,{hasSelectedEditor:this.hasSelection});_nt(Zht,this).add(t),t.select(),bnt(hct,this,Sct).call(this,t.propertiesToUpdate),bnt(hct,this,kct).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;for(var r of(null===(e=_nt(Pht,this))||void 0===e||e.commitOrRemove(),_nt(Zht,this)))r!==t&&r.unselect();_nt(Zht,this).clear(),_nt(Zht,this).add(t),t.select(),bnt(hct,this,Sct).call(this,t.propertiesToUpdate),bnt(hct,this,kct).call(this,{hasSelectedEditor:!0})}isSelected(t){return _nt(Zht,this).has(t)}get firstSelectedEditor(){return _nt(Zht,this).values().next().value}unselect(t){t.unselect(),_nt(Zht,this).delete(t),bnt(hct,this,kct).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==_nt(Zht,this).size}get isEnterHandled(){return 1===_nt(Zht,this).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;_nt(Tht,this).undo(),bnt(hct,this,kct).call(this,{hasSomethingToUndo:_nt(Tht,this).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:bnt(hct,this,Ict).call(this)}),null===(t=this._editorUndoBar)||void 0===t||t.hide()}redo(){_nt(Tht,this).redo(),bnt(hct,this,kct).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:_nt(Tht,this).hasSomethingToRedo(),isEmpty:bnt(hct,this,Ict).call(this)})}addCommands(t){_nt(Tht,this).add(t),bnt(hct,this,kct).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:bnt(hct,this,Ict).call(this)})}cleanUndoStack(t){_nt(Tht,this).cleanType(t)}delete(){var t;this.commitOrRemove();var e=null===(t=this.currentLayer)||void 0===t?void 0:t.endDrawingSession(!0);if(this.hasSelection||e){var r=e?[e]:[..._nt(Zht,this)],n=()=>{for(var t of r)bnt(hct,this,Cct).call(this,t)};this.addCommands({cmd:()=>{var t;for(var e of(null===(t=this._editorUndoBar)||void 0===t||t.show(n,1===r.length?r[0].editorType:r.length),r))e.remove()},undo:n,mustExec:!0})}}commitOrRemove(){var t;null===(t=_nt(Aht,this))||void 0===t||t.commitOrRemove()}hasSomethingToControl(){return _nt(Aht,this)||this.hasSelection}selectAll(){for(var t of _nt(Zht,this))t.commit();bnt(hct,this,Rct).call(this,_nt(_ht,this).values())}unselectAll(){var t;if((!_nt(Aht,this)||(_nt(Aht,this).commitOrRemove(),_nt(Jht,this)===eot.NONE))&&(null===(t=_nt(Pht,this))||void 0===t||!t.commitOrRemove())&&this.hasSelection){for(var e of _nt(Zht,this))e.unselect();_nt(Zht,this).clear(),bnt(hct,this,kct).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||this.commitOrRemove(),this.hasSelection){_nt(ict,this)[0]+=t,_nt(ict,this)[1]+=e;var[r,n]=_nt(ict,this),i=[..._nt(Zht,this)];for(var a of(_nt(act,this)&&clearTimeout(_nt(act,this)),Snt(act,this,setTimeout((()=>{Snt(act,this,null),_nt(ict,this)[0]=_nt(ict,this)[1]=0,this.addCommands({cmd:()=>{for(var t of i)_nt(_ht,this).has(t.id)&&t.translateInPage(r,n)},undo:()=>{for(var t of i)_nt(_ht,this).has(t.id)&&t.translateInPage(-r,-n)},mustExec:!1})}),1e3)),i))a.translateInPage(t,e)}}setUpDragSession(){if(this.hasSelection)for(var t of(this.disableUserSelect(!0),Snt(Oht,this,new Map),_nt(Zht,this)))_nt(Oht,this).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!_nt(Oht,this))return!1;this.disableUserSelect(!1);var t=_nt(Oht,this);Snt(Oht,this,null);var e=!1;for(var[{x:r,y:n,pageIndex:i},a]of t)a.newX=r,a.newY=n,a.newPageIndex=i,e||(e=r!==a.savedX||n!==a.savedY||i!==a.savedPageIndex);if(!e)return!1;var s=(t,e,r,n)=>{if(_nt(_ht,this).has(t.id)){var i=_nt(kht,this).get(n);i?t._setParentAndPosition(i,e,r):(t.pageIndex=n,t.x=e,t.y=r)}};return this.addCommands({cmd:()=>{for(var[e,{newX:r,newY:n,newPageIndex:i}]of t)s(e,r,n,i)},undo:()=>{for(var[e,{savedX:r,savedY:n,savedPageIndex:i}]of t)s(e,r,n,i)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(_nt(Oht,this))for(var r of _nt(Oht,this).keys())r.drag(t,e)}rebuild(t){if(null===t.parent){var e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return(null===(t=this.getActive())||void 0===t?void 0:t.shouldGetKeyboardEvents())||1===_nt(Zht,this).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return _nt(Aht,this)===t}getActive(){return _nt(Aht,this)}getMode(){return _nt(Jht,this)}get imageManager(){return Yot(this,"imageManager",new hht)}getSelectionBoxes(t){if(!t)return null;for(var e=document.getSelection(),r=0,n=e.rangeCount;r<n;r++)if(!t.contains(e.getRangeAt(r).commonAncestorContainer))return null;var i,{x:a,y:s,width:o,height:l}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":i=(t,e,r,n)=>({x:(e-s)/l,y:1-(t+r-a)/o,width:n/l,height:r/o});break;case"180":i=(t,e,r,n)=>({x:1-(t+r-a)/o,y:1-(e+n-s)/l,width:r/o,height:n/l});break;case"270":i=(t,e,r,n)=>({x:1-(e+n-s)/l,y:(t-a)/o,width:n/l,height:r/o});break;default:i=(t,e,r,n)=>({x:(t-a)/o,y:(e-s)/l,width:r/o,height:n/l})}for(var h=[],c=0,u=e.rangeCount;c<u;c++){var d=e.getRangeAt(c);if(!d.collapsed)for(var{x:p,y:f,width:g,height:v}of d.getClientRects())0!==g&&0!==v&&h.push(i(p,f,g,v))}return 0===h.length?null:h}addChangedExistingAnnotation(t){var{annotationElementId:e,id:r}=t;(_nt(Mht,this)||Snt(Mht,this,new Map)).set(e,r)}removeChangedExistingAnnotation(t){var e,{annotationElementId:r}=t;null===(e=_nt(Mht,this))||void 0===e||e.delete(r)}renderAnnotationElement(t){var e,r=null===(e=_nt(Mht,this))||void 0===e?void 0:e.get(t.data.id);if(r){var n=_nt(Eht,this).getRawValue(r);n&&(_nt(Jht,this)!==eot.NONE||n.hasBeenModified)&&n.renderAnnotationElement(t)}}}function uct(t){var{anchorNode:e}=t;return e.nodeType===Node.TEXT_NODE?e.parentElement:e}function dct(t){var{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(var r of _nt(kht,this).values())if(r.hasTextLayer(t))return r;return null}function pct(){var t=document.getSelection();if(t&&!t.isCollapsed){var e=bnt(hct,this,uct).call(this,t).closest(".textLayer"),r=this.getSelectionBoxes(e);r&&(_nt(Ght,this)||Snt(Ght,this,new Jlt(this)),_nt(Ght,this).show(e,r,"ltr"===this.direction))}}function fct(){var t,e=document.getSelection();if(e&&!e.isCollapsed){var{anchorNode:r}=e;if(r!==_nt(tct,this)){var n,i=bnt(hct,this,uct).call(this,e).closest(".textLayer");if(i){if(null===(t=_nt(Ght,this))||void 0===t||t.hide(),Snt(tct,this,r),bnt(hct,this,kct).call(this,{hasSelectedText:!0}),(_nt(Jht,this)===eot.HIGHLIGHT||_nt(Jht,this)===eot.NONE)&&(_nt(Jht,this)===eot.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),Snt(Hht,this,this.isShiftKeyDown),!this.isShiftKeyDown)){var a=_nt(Jht,this)===eot.HIGHLIGHT?bnt(hct,this,dct).call(this,i):null;null==a||a.toggleDrawing();var s=new AbortController,o=this.combinedSignal(s),l=t=>{"pointerup"===t.type&&0!==t.button||(s.abort(),null==a||a.toggleDrawing(!0),"pointerup"===t.type&&bnt(hct,this,gct).call(this,"main_toolbar"))};window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})}}else _nt(tct,this)&&(null===(n=_nt(Ght,this))||void 0===n||n.hide(),Snt(tct,this,null),bnt(hct,this,kct).call(this,{hasSelectedText:!1}))}}else{var h;_nt(tct,this)&&(null===(h=_nt(Ght,this))||void 0===h||h.hide(),Snt(tct,this,null),bnt(hct,this,kct).call(this,{hasSelectedText:!1}))}}function gct(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";_nt(Jht,this)===eot.HIGHLIGHT?this.highlightSelection(t):_nt(Fht,this)&&bnt(hct,this,pct).call(this)}function vct(){document.addEventListener("selectionchange",bnt(hct,this,fct).bind(this),{signal:this._signal})}function mct(){if(!_nt(Wht,this)){Snt(Wht,this,new AbortController);var t=this.combinedSignal(_nt(Wht,this));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}}function yct(){var t;null===(t=_nt(Wht,this))||void 0===t||t.abort(),Snt(Wht,this,null)}function bct(){if(!_nt(Xht,this)){Snt(Xht,this,new AbortController);var t=this.combinedSignal(_nt(Xht,this));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}}function wct(){var t;null===(t=_nt(Xht,this))||void 0===t||t.abort(),Snt(Xht,this,null)}function xct(){if(!_nt(Cht,this)){Snt(Cht,this,new AbortController);var t=this.combinedSignal(_nt(Cht,this));document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}}function Act(){var t;null===(t=_nt(Cht,this))||void 0===t||t.abort(),Snt(Cht,this,null)}function _ct(){var t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}function kct(t){var e=Object.entries(t).some((t=>{var[e,r]=t;return _nt(nct,this)[e]!==r}));e&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(_nt(nct,this),t)}),_nt(Jht,this)===eot.HIGHLIGHT&&!1===t.hasSelectedEditor&&bnt(hct,this,Sct).call(this,[[rot.HIGHLIGHT_FREE,!0]]))}function Sct(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}function Ect(){return Mct.apply(this,arguments)}function Mct(){return(Mct=xnt((function*(){if(!_nt(Vht,this)){Snt(Vht,this,!0);var t=[];for(var e of _nt(kht,this).values())t.push(e.enable());for(var r of(yield Promise.all(t),_nt(_ht,this).values()))r.enable()}}))).apply(this,arguments)}function Tct(){if(this.unselectAll(),_nt(Vht,this)){for(var t of(Snt(Vht,this,!1),_nt(kht,this).values()))t.disable();for(var e of _nt(_ht,this).values())e.disable()}}function Cct(t){var e=_nt(kht,this).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}function Pct(t){var e=null;for(e of _nt(Zht,t));return e}function Ict(){if(0===_nt(_ht,this).size)return!0;if(1===_nt(_ht,this).size)for(var t of _nt(_ht,this).values())return t.isEmpty();return!1}function Rct(t){for(var e of _nt(Zht,this))e.unselect();for(var r of(_nt(Zht,this).clear(),t))r.isEmpty()||(_nt(Zht,this).add(r),r.select());bnt(hct,this,kct).call(this,{hasSelectedEditor:this.hasSelection})}Tnt(cct,"TRANSLATE_SMALL",1),Tnt(cct,"TRANSLATE_BIG",10);var Oct=new WeakMap,Lct=new WeakMap,Dct=new WeakMap,Fct=new WeakMap,Nct=new WeakMap,jct=new WeakMap,Bct=new WeakMap,zct=new WeakMap,Wct=new WeakMap,Uct=new WeakMap,Hct=new WeakMap,Gct=new WeakMap,Yct=new WeakSet;class Vct{constructor(t){Mnt(this,Yct),knt(this,Oct,null),knt(this,Lct,!1),knt(this,Dct,null),knt(this,Fct,null),knt(this,Nct,null),knt(this,jct,null),knt(this,Bct,!1),knt(this,zct,null),knt(this,Wct,null),knt(this,Uct,null),knt(this,Hct,null),knt(this,Gct,!1),Snt(Wct,this,t),Snt(Gct,this,t._uiManager.useNewAltTextFlow),Kct._||(Kct._=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){var e;null!==(e=Vct._l10n)&&void 0!==e||(Vct._l10n=t)}render(){var t=this;return xnt((function*(){var e=Snt(Dct,t,document.createElement("button"));e.className="altText",e.tabIndex="0";var r=Snt(Fct,t,document.createElement("span"));e.append(r),_nt(Gct,t)?(e.classList.add("new"),e.setAttribute("data-l10n-id",Kct._.missing),r.setAttribute("data-l10n-id",Kct._["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));var n=_nt(Wct,t)._uiManager._signal;e.addEventListener("contextmenu",klt,{signal:n}),e.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:n});var i=e=>{e.preventDefault(),_nt(Wct,t)._uiManager.editAltText(_nt(Wct,t)),_nt(Gct,t)&&_nt(Wct,t)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:Ent(Yct,t,qct)}})};return e.addEventListener("click",i,{capture:!0,signal:n}),e.addEventListener("keydown",(r=>{r.target===e&&"Enter"===r.key&&(Snt(Bct,t,!0),i(r))}),{signal:n}),yield bnt(Yct,t,Xct).call(t),e}))()}finish(){_nt(Dct,this)&&(_nt(Dct,this).focus({focusVisible:_nt(Bct,this)}),Snt(Bct,this,!1))}isEmpty(){return _nt(Gct,this)?null===_nt(Oct,this):!_nt(Oct,this)&&!_nt(Lct,this)}hasData(){return _nt(Gct,this)?null!==_nt(Oct,this)||!!_nt(Uct,this):this.isEmpty()}get guessedText(){return _nt(Uct,this)}setGuessedText(t){var e=this;return xnt((function*(){null===_nt(Oct,e)&&(Snt(Uct,e,t),Snt(Hct,e,yield Vct._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),bnt(Yct,e,Xct).call(e))}))()}toggleAltTextBadge(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!_nt(Gct,this)||_nt(Oct,this))return null===(t=_nt(zct,this))||void 0===t||t.remove(),void Snt(zct,this,null);if(!_nt(zct,this)){var r=Snt(zct,this,document.createElement("div"));r.className="noAltTextBadge",_nt(Wct,this).div.append(r)}_nt(zct,this).classList.toggle("hidden",!e)}serialize(t){var e=_nt(Oct,this);return t||_nt(Uct,this)!==e||(e=_nt(Hct,this)),{altText:e,decorative:_nt(Lct,this),guessedText:_nt(Uct,this),textWithDisclaimer:_nt(Hct,this)}}get data(){return{altText:_nt(Oct,this),decorative:_nt(Lct,this)}}set data(t){var{altText:e,decorative:r,guessedText:n,textWithDisclaimer:i,cancel:a=!1}=t;n&&(Snt(Uct,this,n),Snt(Hct,this,i)),_nt(Oct,this)===e&&_nt(Lct,this)===r||(a||(Snt(Oct,this,e),Snt(Lct,this,r)),bnt(Yct,this,Xct).call(this))}toggle(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];_nt(Dct,this)&&(!t&&_nt(jct,this)&&(clearTimeout(_nt(jct,this)),Snt(jct,this,null)),_nt(Dct,this).disabled=!t)}shown(){_nt(Wct,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:Ent(Yct,this,qct)}})}destroy(){var t,e;null===(t=_nt(Dct,this))||void 0===t||t.remove(),Snt(Dct,this,null),Snt(Fct,this,null),Snt(Nct,this,null),null===(e=_nt(zct,this))||void 0===e||e.remove(),Snt(zct,this,null)}}function qct(t){return(_nt(Oct,t)?"added":null===_nt(Oct,t)&&t.guessedText&&"review")||"missing"}function Xct(){return $ct.apply(this,arguments)}function $ct(){return($ct=xnt((function*(){var t=_nt(Dct,this);if(t){if(_nt(Gct,this)){var e,r;if(t.classList.toggle("done",!!_nt(Oct,this)),t.setAttribute("data-l10n-id",Kct._[Ent(Yct,this,qct)]),null===(e=_nt(Fct,this))||void 0===e||e.setAttribute("data-l10n-id",Kct._["".concat(Ent(Yct,this,qct),"-label")]),!_nt(Oct,this))return void(null===(r=_nt(Nct,this))||void 0===r||r.remove())}else{var n;if(!_nt(Oct,this)&&!_nt(Lct,this))return t.classList.remove("done"),void(null===(n=_nt(Nct,this))||void 0===n||n.remove());t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}var i=_nt(Nct,this);if(!i){Snt(Nct,this,i=document.createElement("span")),i.className="tooltip",i.setAttribute("role","tooltip"),i.id="alt-text-tooltip-".concat(_nt(Wct,this).id);var a=_nt(Wct,this)._uiManager._signal;a.addEventListener("abort",(()=>{clearTimeout(_nt(jct,this)),Snt(jct,this,null)}),{once:!0}),t.addEventListener("mouseenter",(()=>{Snt(jct,this,setTimeout((()=>{Snt(jct,this,null),_nt(Nct,this).classList.add("show"),_nt(Wct,this)._reportTelemetry({action:"alt_text_tooltip"})}),100))}),{signal:a}),t.addEventListener("mouseleave",(()=>{var t;_nt(jct,this)&&(clearTimeout(_nt(jct,this)),Snt(jct,this,null)),null===(t=_nt(Nct,this))||void 0===t||t.classList.remove("show")}),{signal:a})}_nt(Lct,this)?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=_nt(Oct,this)),i.parentNode||t.append(i);var s=_nt(Wct,this).getImageForAltText();null==s||s.setAttribute("aria-describedby",i.id)}}))).apply(this,arguments)}var Kct={_:null};Tnt(Vct,"_l10n",null);var Qct=new WeakMap,Jct=new WeakMap,Zct=new WeakMap,tut=new WeakMap,eut=new WeakMap,rut=new WeakMap,nut=new WeakMap,iut=new WeakMap,aut=new WeakMap,sut=new WeakMap,out=new WeakMap,lut=new WeakSet;class hut{constructor(t){var{container:e,isPinchingDisabled:r=null,isPinchingStopped:n=null,onPinchStart:i=null,onPinching:a=null,onPinchEnd:s=null,signal:o}=t;Mnt(this,lut),knt(this,Qct,void 0),knt(this,Jct,!1),knt(this,Zct,null),knt(this,tut,void 0),knt(this,eut,void 0),knt(this,rut,void 0),knt(this,nut,void 0),knt(this,iut,void 0),knt(this,aut,null),knt(this,sut,void 0),knt(this,out,null),Snt(Qct,this,e),Snt(Zct,this,n),Snt(tut,this,r),Snt(eut,this,i),Snt(rut,this,a),Snt(nut,this,s),Snt(sut,this,new AbortController),Snt(iut,this,AbortSignal.any([o,_nt(sut,this).signal])),e.addEventListener("touchstart",bnt(lut,this,cut).bind(this),{passive:!1,signal:_nt(iut,this)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Yot(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}destroy(){var t;null===(t=_nt(sut,this))||void 0===t||t.abort(),Snt(sut,this,null)}}function cut(t){var e,r;if(!(null!==(e=_nt(tut,this))&&void 0!==e&&e.call(this)||t.touches.length<2)){if(!_nt(out,this)){var n;Snt(out,this,new AbortController);var i=AbortSignal.any([_nt(iut,this),_nt(out,this).signal]),a=_nt(Qct,this),s={signal:i,passive:!1};a.addEventListener("touchmove",bnt(lut,this,uut).bind(this),s),a.addEventListener("touchend",bnt(lut,this,dut).bind(this),s),a.addEventListener("touchcancel",bnt(lut,this,dut).bind(this),s),null===(n=_nt(eut,this))||void 0===n||n.call(this)}if(Slt(t),2!==t.touches.length||null!==(r=_nt(Zct,this))&&void 0!==r&&r.call(this))Snt(aut,this,null);else{var[o,l]=t.touches;o.identifier>l.identifier&&([o,l]=[l,o]),Snt(aut,this,{touch0X:o.screenX,touch0Y:o.screenY,touch1X:l.screenX,touch1Y:l.screenY})}}}function uut(t){var e;if(_nt(aut,this)&&2===t.touches.length){var[r,n]=t.touches;r.identifier>n.identifier&&([r,n]=[n,r]);var{screenX:i,screenY:a}=r,{screenX:s,screenY:o}=n,l=_nt(aut,this),{touch0X:h,touch0Y:c,touch1X:u,touch1Y:d}=l,p=u-h,f=d-c,g=s-i,v=o-a,m=Math.hypot(g,v)||1,y=Math.hypot(p,f)||1;if(_nt(Jct,this)||!(Math.abs(y-m)<=Tst.MIN_TOUCH_DISTANCE_TO_PINCH))if(l.touch0X=i,l.touch0Y=a,l.touch1X=s,l.touch1Y=o,t.preventDefault(),_nt(Jct,this)){var b=[(i+s)/2,(a+o)/2];null===(e=_nt(rut,this))||void 0===e||e.call(this,b,y,m)}else Snt(Jct,this,!0)}}function dut(t){var e;_nt(out,this).abort(),Snt(out,this,null),null===(e=_nt(nut,this))||void 0===e||e.call(this),_nt(aut,this)&&(t.preventDefault(),Snt(aut,this,null),Snt(Jct,this,!1))}Tst=hut;var put=new WeakMap,fut=new WeakMap,gut=new WeakMap,vut=new WeakMap,mut=new WeakMap,yut=new WeakMap,but=new WeakMap,wut=new WeakMap,xut=new WeakMap,Aut=new WeakMap,_ut=new WeakMap,kut=new WeakMap,Sut=new WeakMap,Eut=new WeakMap,Mut=new WeakMap,Tut=new WeakMap,Cut=new WeakMap,Put=new WeakMap,Iut=new WeakMap,Rut=new WeakMap,Out=new WeakMap,Lut=new WeakMap,Dut=new WeakMap,Fut=new WeakMap,Nut=new WeakSet;class jut{static get _resizerKeyboardManager(){var t=jut.prototype._resizeWithKeyboard,e=cct.TRANSLATE_SMALL,r=cct.TRANSLATE_BIG;return Yot(this,"_resizerKeyboardManager",new yht([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-r,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[r,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-r]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,r]}],[["Escape","mac+Escape"],jut.prototype._stopResizingWithKeyboard]]))}constructor(t){Mnt(this,Nut),knt(this,put,null),knt(this,fut,null),knt(this,gut,null),knt(this,vut,!1),knt(this,mut,null),knt(this,yut,""),knt(this,but,!1),knt(this,wut,null),knt(this,xut,null),knt(this,Aut,null),knt(this,_ut,null),knt(this,kut,""),knt(this,Sut,!1),knt(this,Eut,null),knt(this,Mut,!1),knt(this,Tut,!1),knt(this,Cut,!1),knt(this,Put,null),knt(this,Iut,0),knt(this,Rut,0),knt(this,Out,null),knt(this,Lut,null),Tnt(this,"_editToolbar",null),Tnt(this,"_initialOptions",Object.create(null)),Tnt(this,"_initialData",null),Tnt(this,"_isVisible",!0),Tnt(this,"_uiManager",null),Tnt(this,"_focusEventsAllowed",!0),knt(this,Dut,!1),knt(this,Fut,jut._zIndex++),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;var{rotation:e,rawDims:{pageWidth:r,pageHeight:n,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,n],this.pageTranslation=[i,a];var[s,o]=this.parentDimensions;this.x=t.x/s,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Yot(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){var e=new idt({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){var r;if(null!==(r=jut._l10n)&&void 0!==r||(jut._l10n=t),jut._l10nResizer||(jut._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),-1===jut._borderLineWidth){var n=getComputedStyle(document.documentElement);jut._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Uot("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return _nt(Dut,this)}set _isDraggable(t){var e;Snt(Dut,this,t),null===(e=this.div)||void 0===e||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){var[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=_nt(Fut,this)}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):bnt(Nut,this,ndt).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(_nt(Sut,this)?Snt(Sut,this,!1):this.parent.setSelected(this))}focusout(t){var e;if(this._focusEventsAllowed&&this.isAttachedToDOM){var r=t.relatedTarget;null!=r&&r.closest("#".concat(this.id))||(t.preventDefault(),null!==(e=this.parent)&&void 0!==e&&e.isMultipleSelection||this.commitOrRemove())}}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,r,n){var[i,a]=this.parentDimensions;[r,n]=this.screenToPageTranslation(r,n),this.x=(t+r)/i,this.y=(e+n)/a,this.fixAndSetPosition()}translate(t,e){bnt(Nut,this,But).call(this,this.parentDimensions,t,e)}translateInPage(t,e){_nt(Eut,this)||Snt(Eut,this,[this.x,this.y,this.width,this.height]),bnt(Nut,this,But).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){_nt(Eut,this)||Snt(Eut,this,[this.x,this.y,this.width,this.height]);var{div:r,parentDimensions:[n,i]}=this;if(this.x+=t/n,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){var{x:a,y:s}=this.div.getBoundingClientRect();this.parent.findNewParent(this,a,s)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}var{x:o,y:l}=this,[h,c]=this.getBaseTranslation();o+=h,l+=c;var{style:u}=r;u.left="".concat((100*o).toFixed(2),"%"),u.top="".concat((100*l).toFixed(2),"%"),this._onTranslating(o,l),r.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!_nt(Eut,this)&&(_nt(Eut,this)[0]!==this.x||_nt(Eut,this)[1]!==this.y)}get _hasBeenResized(){return!!_nt(Eut,this)&&(_nt(Eut,this)[2]!==this.width||_nt(Eut,this)[3]!==this.height)}getBaseTranslation(){var[t,e]=this.parentDimensions,{_borderLineWidth:r}=jut,n=r/t,i=r/e;switch(this.rotation){case 90:return[-n,i];case 180:return[n,i];case 270:return[n,-i];default:return[-n,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.rotation,{div:{style:e},pageDimensions:[r,n]}=this,{x:i,y:a,width:s,height:o}=this;if(s*=r,o*=n,i*=r,a*=n,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(r-s,i)),a=Math.max(0,Math.min(n-o,a));break;case 90:i=Math.max(0,Math.min(r-o,i)),a=Math.min(n,Math.max(s,a));break;case 180:i=Math.min(r,Math.max(s,i)),a=Math.min(n,Math.max(o,a));break;case 270:i=Math.min(r,Math.max(o,i)),a=Math.max(0,Math.min(n-s,a))}this.x=i/=r,this.y=a/=n;var[l,h]=this.getBaseTranslation();i+=l,a+=h,e.left="".concat((100*i).toFixed(2),"%"),e.top="".concat((100*a).toFixed(2),"%"),this.moveInDOM()}screenToPageTranslation(t,e){return zut.call(jut,t,e,this.parentRotation)}pageTranslationToScreen(t,e){return zut.call(jut,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){var{parentScale:t,pageDimensions:[e,r]}=this;return[e*t,r*t]}setDims(t,e){var[r,n]=this.parentDimensions,{style:i}=this.div;i.width="".concat((100*t/r).toFixed(2),"%"),_nt(but,this)||(i.height="".concat((100*e/n).toFixed(2),"%"))}fixDims(){var{style:t}=this.div,{height:e,width:r}=t,n=r.endsWith("%"),i=!_nt(but,this)&&e.endsWith("%");if(!n||!i){var[a,s]=this.parentDimensions;n||(t.width="".concat((100*parseFloat(r)/a).toFixed(2),"%")),_nt(but,this)||i||(t.height="".concat((100*parseFloat(e)/s).toFixed(2),"%"))}}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(1e4*t)/1e4}_onResizing(){}altTextFinish(){var t;null===(t=_nt(gut,this))||void 0===t||t.finish()}addEditToolbar(){var t=this;return xnt((function*(){return t._editToolbar||_nt(Tut,t)||(t._editToolbar=new zlt(t),t.div.append(t._editToolbar.render()),_nt(gut,t)&&(yield t._editToolbar.addAltText(_nt(gut,t)))),t._editToolbar}))()}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,null===(t=_nt(gut,this))||void 0===t||t.destroy())}addContainer(t){var e,r=null===(e=this._editToolbar)||void 0===e?void 0:e.div;r?r.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}addAltTextButton(){var t=this;return xnt((function*(){_nt(gut,t)||(Vct.initialize(jut._l10n),Snt(gut,t,new Vct(t)),_nt(put,t)&&(_nt(gut,t).data=_nt(put,t),Snt(put,t,null)),yield t.addEditToolbar())}))()}get altTextData(){var t;return null===(t=_nt(gut,this))||void 0===t?void 0:t.data}set altTextData(t){_nt(gut,this)&&(_nt(gut,this).data=t)}get guessedAltText(){var t;return null===(t=_nt(gut,this))||void 0===t?void 0:t.guessedText}setGuessedAltText(t){var e=this;return xnt((function*(){var r;yield null===(r=_nt(gut,e))||void 0===r?void 0:r.setGuessedText(t)}))()}serializeAltText(t){var e;return null===(e=_nt(gut,this))||void 0===e?void 0:e.serialize(t)}hasAltText(){return!!_nt(gut,this)&&!_nt(gut,this).isEmpty()}hasAltTextData(){var t,e;return null!==(t=null===(e=_nt(gut,this))||void 0===e?void 0:e.hasData())&&void 0!==t&&t}render(){var t;this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=_nt(vut,this)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),bnt(Nut,this,Jut).call(this);var[e,r]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth="".concat((100*r/e).toFixed(2),"%"),this.div.style.maxHeight="".concat((100*e/r).toFixed(2),"%"));var[n,i]=this.getInitialTranslation();return this.translate(n,i),rht(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(_nt(Lut,this)||Snt(Lut,this,new hut({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:bnt(Nut,this,qut).bind(this),onPinching:bnt(Nut,this,Xut).bind(this),onPinchEnd:bnt(Nut,this,$ut).bind(this),signal:this._uiManager._signal}))),null===(t=this._uiManager._editorUndoBar)||void 0===t||t.hide(),this.div}pointerdown(t){var{isMac:e}=nlt.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(Snt(Sut,this,!0),this._isDraggable?bnt(Nut,this,Qut).call(this,t):bnt(Nut,this,Kut).call(this,t))}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){_nt(Put,this)&&clearTimeout(_nt(Put,this)),Snt(Put,this,setTimeout((()=>{var t;Snt(Put,this,null),null===(t=this.parent)||void 0===t||t.moveEditorInDOM(this)}),0))}_setParentAndPosition(t,e,r){t.changeParent(this),this.x=e,this.y=r,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.rotation,n=this.parentScale,[i,a]=this.pageDimensions,[s,o]=this.pageTranslation,l=t/n,h=e/n,c=this.x*i,u=this.y*a,d=this.width*i,p=this.height*a;switch(r){case 0:return[c+l+s,a-u-h-p+o,c+l+d+s,a-u-h+o];case 90:return[c+h+s,a-u+l+o,c+h+p+s,a-u+l+d+o];case 180:return[c-l-d+s,a-u+h+o,c-l+s,a-u+h+p+o];case 270:return[c-h-p+s,a-u-l-d+o,c-h+s,a-u-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){var[r,n,i,a]=t,s=i-r,o=a-n;switch(this.rotation){case 0:return[r,e-a,s,o];case 90:return[r,e-n,o,s];case 180:return[i,e-n,s,o];case 270:return[i,e-a,o,s];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){Snt(Tut,this,!0)}disableEditMode(){Snt(Tut,this,!1)}isInEditMode(){return _nt(Tut,this)}shouldGetKeyboardEvents(){return _nt(Cut,this)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){var{top:t,left:e,bottom:r,right:n}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return e<a&&n>0&&t<i&&r>0}rebuild(){bnt(Nut,this,Jut).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:(null===(t=this._initialData)||void 0===t?void 0:t.popupRef)||""}}serialize(){Uot("An editor must be serializable")}static deserialize(t,e,r){var n=this;return xnt((function*(){var i=new n.prototype.constructor({parent:e,id:e.getNextId(),uiManager:r});i.rotation=t.rotation,Snt(put,i,t.accessibilityData);var[a,s]=i.pageDimensions,[o,l,h,c]=i.getRectInCurrentCoords(t.rect,s);return i.x=o/a,i.y=l/s,i.width=h/a,i.height=c/s,i}))()}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){var t,e;if(null===(t=_nt(_ut,this))||void 0===t||t.abort(),Snt(_ut,this,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),_nt(Put,this)&&(clearTimeout(_nt(Put,this)),Snt(Put,this,null)),bnt(Nut,this,ndt).call(this),this.removeEditToolbar(),_nt(Out,this)){for(var r of _nt(Out,this).values())clearTimeout(r);Snt(Out,this,null)}this.parent=null,null===(e=_nt(Lut,this))||void 0===e||e.destroy(),Snt(Lut,this,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(bnt(Nut,this,Uut).call(this),_nt(wut,this).classList.remove("hidden"),rht(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(this.isResizable&&t.target===this.div&&"Enter"===t.key){this._uiManager.setSelected(this),Snt(Aut,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});var e=_nt(wut,this).children;if(!_nt(fut,this)){Snt(fut,this,Array.from(e));var r=bnt(Nut,this,Zut).bind(this),n=bnt(Nut,this,tdt).bind(this),i=this._uiManager._signal;for(var a of _nt(fut,this)){var s=a.getAttribute("data-resizer-name");a.setAttribute("role","spinbutton"),a.addEventListener("keydown",r,{signal:i}),a.addEventListener("blur",n,{signal:i}),a.addEventListener("focus",bnt(Nut,this,edt).bind(this,s),{signal:i}),a.setAttribute("data-l10n-id",jut._l10nResizer[s])}}var o=_nt(fut,this)[0],l=0;for(var h of e){if(h===o)break;l++}var c=(360-this.rotation+this.parentRotation)%360/90*(_nt(fut,this).length/4);if(c!==l){if(c<l)for(var u=0;u<l-c;u++)_nt(wut,this).append(_nt(wut,this).firstChild);else if(c>l)for(var d=0;d<c-l;d++)_nt(wut,this).firstChild.before(_nt(wut,this).lastChild);var p=0;for(var f of e){var g=_nt(fut,this)[p++].getAttribute("data-resizer-name");f.setAttribute("data-l10n-id",jut._l10nResizer[g])}}bnt(Nut,this,rdt).call(this,0),Snt(Cut,this,!0),_nt(wut,this).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}}_resizeWithKeyboard(t,e){_nt(Cut,this)&&bnt(Nut,this,Vut).call(this,_nt(kut,this),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){bnt(Nut,this,ndt).call(this),this.div.focus()}select(){var t,e,r;this.makeResizable(),null===(t=this.div)||void 0===t||t.classList.add("selectedEditor"),this._editToolbar?(null===(e=this._editToolbar)||void 0===e||e.show(),null===(r=_nt(gut,this))||void 0===r||r.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{var t,e;null!==(t=this.div)&&void 0!==t&&t.classList.contains("selectedEditor")&&(null===(e=this._editToolbar)||void 0===e||e.show())}))}unselect(){var t,e,r,n,i;null===(t=_nt(wut,this))||void 0===t||t.classList.add("hidden"),null===(e=this.div)||void 0===e||e.classList.remove("selectedEditor"),null!==(r=this.div)&&void 0!==r&&r.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null===(n=this._editToolbar)||void 0===n||n.hide(),null===(i=_nt(gut,this))||void 0===i||i.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return _nt(Mut,this)}set isEditing(t){Snt(Mut,this,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){Snt(but,this,!0);var r=t/e,{style:n}=this.div;n.aspectRatio=r,n.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){_nt(Out,this)||Snt(Out,this,new Map);var{action:e}=t,r=_nt(Out,this).get(e);return r&&clearTimeout(r),r=setTimeout((()=>{this._reportTelemetry(t),_nt(Out,this).delete(e),0===_nt(Out,this).size&&Snt(Out,this,null)}),jut._telemetryTimeout),void _nt(Out,this).set(e,r)}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),Snt(vut,this,!1)}disable(){this.div&&(this.div.tabIndex=-1),Snt(vut,this,!0)}renderAnnotationElement(t){var e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){var r=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),r.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){var{firstChild:e}=t.container;"DIV"===(null==e?void 0:e.nodeName)&&e.classList.contains("annotationContent")&&e.remove()}}function But(t,e,r){var[n,i]=t;[e,r]=this.screenToPageTranslation(e,r),this.x+=e/n,this.y+=r/i,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}function zut(t,e,r){switch(r){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}function Wut(t){switch(t){case 90:var[e,r]=this.pageDimensions;return[0,-e/r,r/e,0];case 180:return[-1,0,0,-1];case 270:var[n,i]=this.pageDimensions;return[0,n/i,-i/n,0];default:return[1,0,0,1]}}function Uut(){if(!_nt(wut,this)){Snt(wut,this,document.createElement("div")),_nt(wut,this).classList.add("resizers");var t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(var r of t){var n=document.createElement("div");_nt(wut,this).append(n),n.classList.add("resizer",r),n.setAttribute("data-resizer-name",r),n.addEventListener("pointerdown",bnt(Nut,this,Hut).bind(this,r),{signal:e}),n.addEventListener("contextmenu",klt,{signal:e}),n.tabIndex=-1}this.div.prepend(_nt(wut,this))}}function Hut(t,e){var r;e.preventDefault();var{isMac:n}=nlt.platform;if(!(0!==e.button||e.ctrlKey&&n)){null===(r=_nt(gut,this))||void 0===r||r.toggle(!1);var i=this._isDraggable;this._isDraggable=!1,Snt(xut,this,[e.screenX,e.screenY]);var a=new AbortController,s=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",bnt(Nut,this,Vut).bind(this,t),{passive:!0,capture:!0,signal:s}),window.addEventListener("touchmove",Slt,{passive:!1,signal:s}),window.addEventListener("contextmenu",klt,{signal:s}),Snt(Aut,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});var o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;var h=()=>{var t;a.abort(),this.parent.togglePointerEvents(!0),null===(t=_nt(gut,this))||void 0===t||t.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,bnt(Nut,this,Yut).call(this)};window.addEventListener("pointerup",h,{signal:s}),window.addEventListener("blur",h,{signal:s})}}function Gut(t,e,r,n){this.width=r,this.height=n,this.x=t,this.y=e;var[i,a]=this.parentDimensions;this.setDims(i*r,a*n),this.fixAndSetPosition(),this._onResized()}function Yut(){if(_nt(Aut,this)){var{savedX:t,savedY:e,savedWidth:r,savedHeight:n}=_nt(Aut,this);Snt(Aut,this,null);var i=this.x,a=this.y,s=this.width,o=this.height;i===t&&a===e&&s===r&&o===n||this.addCommands({cmd:bnt(Nut,this,Gut).bind(this,i,a,s,o),undo:bnt(Nut,this,Gut).bind(this,t,e,r,n),mustExec:!0})}}function Vut(t,e){var r,n,[i,a]=this.parentDimensions,s=this.x,o=this.y,l=this.width,h=this.height,c=Cst.MIN_SIZE/i,u=Cst.MIN_SIZE/a,d=bnt(Nut,this,Wut).call(this,this.rotation),p=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],f=bnt(Nut,this,Wut).call(this,360-this.rotation),g=!1,v=!1;switch(t){case"topLeft":g=!0,r=(t,e)=>[0,0],n=(t,e)=>[t,e];break;case"topMiddle":r=(t,e)=>[t/2,0],n=(t,e)=>[t/2,e];break;case"topRight":g=!0,r=(t,e)=>[t,0],n=(t,e)=>[0,e];break;case"middleRight":v=!0,r=(t,e)=>[t,e/2],n=(t,e)=>[0,e/2];break;case"bottomRight":g=!0,r=(t,e)=>[t,e],n=(t,e)=>[0,0];break;case"bottomMiddle":r=(t,e)=>[t/2,e],n=(t,e)=>[t/2,0];break;case"bottomLeft":g=!0,r=(t,e)=>[0,e],n=(t,e)=>[t,0];break;case"middleLeft":v=!0,r=(t,e)=>[0,e/2],n=(t,e)=>[t,e/2]}var m,y,b=r(l,h),w=n(l,h),x=p(...w),A=Cst._round(s+x[0]),_=Cst._round(o+x[1]),k=1,S=1;if(e.fromKeyboard)({deltaX:m,deltaY:y}=e);else{var{screenX:E,screenY:M}=e,[T,C]=_nt(xut,this);[m,y]=this.screenToPageTranslation(E-T,M-C),_nt(xut,this)[0]=E,_nt(xut,this)[1]=M}if([m,y]=((t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e])(m/i,y/a),g){var P=Math.hypot(l,h);k=S=Math.max(Math.min(Math.hypot(w[0]-b[0]-m,w[1]-b[1]-y)/P,1/l,1/h),c/l,u/h)}else v?k=Math.max(c,Math.min(1,Math.abs(w[0]-b[0]-m)))/l:S=Math.max(u,Math.min(1,Math.abs(w[1]-b[1]-y)))/h;var I=Cst._round(l*k),R=Cst._round(h*S),O=A-(x=p(...n(I,R)))[0],L=_-x[1];_nt(Eut,this)||Snt(Eut,this,[this.x,this.y,this.width,this.height]),this.width=I,this.height=R,this.x=O,this.y=L,this.setDims(i*I,a*R),this.fixAndSetPosition(),this._onResizing()}function qut(){var t;Snt(Aut,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),null===(t=_nt(gut,this))||void 0===t||t.toggle(!1),this.parent.togglePointerEvents(!1)}function Xut(t,e,r){var n=r/e*.7+1-.7;if(1!==n){var i=bnt(Nut,this,Wut).call(this,this.rotation),a=(t,e)=>[i[0]*t+i[2]*e,i[1]*t+i[3]*e],[s,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,u=this.height,d=Cst.MIN_SIZE/s,p=Cst.MIN_SIZE/o;n=Math.max(Math.min(n,1/c,1/u),d/c,p/u);var f=Cst._round(c*n),g=Cst._round(u*n);if(f!==c||g!==u){_nt(Eut,this)||Snt(Eut,this,[l,h,c,u]);var v=a(c/2,u/2),m=Cst._round(l+v[0]),y=Cst._round(h+v[1]),b=a(f/2,g/2);this.x=m-b[0],this.y=y-b[1],this.width=f,this.height=g,this.setDims(s*f,o*g),this.fixAndSetPosition(),this._onResizing()}}}function $ut(){var t;null===(t=_nt(gut,this))||void 0===t||t.toggle(!0),this.parent.togglePointerEvents(!0),bnt(Nut,this,Yut).call(this)}function Kut(t){var{isMac:e}=nlt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}function Qut(t){var{isSelected:e}=this;this._uiManager.setUpDragSession();var r=!1,n=new AbortController,i=this._uiManager.combinedSignal(n),a={capture:!0,passive:!1,signal:i},s=t=>{n.abort(),Snt(mut,this,null),Snt(Sut,this,!1),this._uiManager.endDragSession()||bnt(Nut,this,Kut).call(this,t),r&&this._onStopDragging()};e&&(Snt(Iut,this,t.clientX),Snt(Rut,this,t.clientY),Snt(mut,this,t.pointerId),Snt(yut,this,t.pointerType),window.addEventListener("pointermove",(t=>{r||(r=!0,this._onStartDragging());var{clientX:e,clientY:n,pointerId:i}=t;if(i===_nt(mut,this)){var[a,s]=this.screenToPageTranslation(e-_nt(Iut,this),n-_nt(Rut,this));Snt(Iut,this,e),Snt(Rut,this,n),this._uiManager.dragSelectedEditors(a,s)}else Slt(t)}),a),window.addEventListener("touchmove",Slt,a),window.addEventListener("pointerdown",(t=>{t.pointerType===_nt(yut,this)&&(_nt(Lut,this)||t.isPrimary)&&s(t),Slt(t)}),a));var o=t=>{_nt(mut,this)&&_nt(mut,this)!==t.pointerId?Slt(t):s(t)};window.addEventListener("pointerup",o,{signal:i}),window.addEventListener("blur",o,{signal:i})}function Jut(){if(!_nt(_ut,this)&&this.div){Snt(_ut,this,new AbortController);var t=this._uiManager.combinedSignal(_nt(_ut,this));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}}function Zut(t){Cst._resizerKeyboardManager.exec(this,t)}function tdt(t){var e;_nt(Cut,this)&&(null===(e=t.relatedTarget)||void 0===e?void 0:e.parentNode)!==_nt(wut,this)&&bnt(Nut,this,ndt).call(this)}function edt(t){Snt(kut,this,_nt(Cut,this)?t:"")}function rdt(t){if(_nt(fut,this))for(var e of _nt(fut,this))e.tabIndex=t}function ndt(){Snt(Cut,this,!1),bnt(Nut,this,rdt).call(this,-1),bnt(Nut,this,Yut).call(this)}Cst=jut,Tnt(jut,"_l10n",null),Tnt(jut,"_l10nResizer",null),Tnt(jut,"_borderLineWidth",-1),Tnt(jut,"_colorManager",new wht),Tnt(jut,"_zIndex",1),Tnt(jut,"_telemetryTimeout",1e3);class idt extends jut{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}var adt=3285377520,sdt=4294901760,odt=65535;class ldt{constructor(t){this.h1=t?4294967295&t:adt,this.h2=t?4294967295&t:adt}update(t){var e,r;if("string"==typeof t){e=new Uint8Array(2*t.length),r=0;for(var n=0,i=t.length;n<i;n++){var a=t.charCodeAt(n);a<=255?e[r++]=a:(e[r++]=a>>>8,e[r++]=255&a)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");r=(e=t.slice()).byteLength}for(var s=r>>2,o=r-4*s,l=new Uint32Array(e.buffer,0,s),h=0,c=0,u=this.h1,d=this.h2,p=3432918353,f=461845907,g=11601,v=13715,m=0;m<s;m++)1&m?u=5*(u=(u^=h=(h=(h=(h=l[m])*p&sdt|h*g&odt)<<15|h>>>17)*f&sdt|h*v&odt)<<13|u>>>19)+3864292196:d=5*(d=(d^=c=(c=(c=(c=l[m])*p&sdt|c*g&odt)<<15|c>>>17)*f&sdt|c*v&odt)<<13|d>>>19)+3864292196;switch(h=0,o){case 3:h^=e[4*s+2]<<16;case 2:h^=e[4*s+1]<<8;case 1:h=(h=(h=(h^=e[4*s])*p&sdt|h*g&odt)<<15|h>>>17)*f&sdt|h*v&odt,1&s?u^=h:d^=h}this.h1=u,this.h2=d}hexdigest(){var t=this.h1,e=this.h2;return t=3981806797*(t^=e>>>1)&sdt|36045*t&odt,t=444984403*(t^=(e=4283543511*e&sdt|(2950163797*(e<<16|t>>>16)&sdt)>>>16)>>>1)&sdt|60499*t&odt,((t^=(e=3301882366*e&sdt|(3120437893*(e<<16|t>>>16)&sdt)>>>16)>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}var hdt=Object.freeze({map:null,hash:"",transfer:void 0}),cdt=new WeakMap,udt=new WeakMap,ddt=new WeakMap,pdt=new WeakSet;class fdt{constructor(){Mnt(this,pdt),knt(this,cdt,!1),knt(this,udt,null),knt(this,ddt,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){var r=_nt(ddt,this).get(t);return void 0===r?e:Object.assign(e,r)}getRawValue(t){return _nt(ddt,this).get(t)}remove(t){if(_nt(ddt,this).delete(t),0===_nt(ddt,this).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(var e of _nt(ddt,this).values())if(e instanceof jut)return;this.onAnnotationEditor(null)}}setValue(t,e){var r=_nt(ddt,this).get(t),n=!1;if(void 0!==r)for(var[i,a]of Object.entries(e))r[i]!==a&&(n=!0,r[i]=a);else n=!0,_nt(ddt,this).set(t,e);n&&bnt(pdt,this,gdt).call(this),e instanceof jut&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return _nt(ddt,this).has(t)}getAll(){return _nt(ddt,this).size>0?rlt(_nt(ddt,this)):null}setAll(t){for(var[e,r]of Object.entries(t))this.setValue(e,r)}get size(){return _nt(ddt,this).size}resetModified(){_nt(cdt,this)&&(Snt(cdt,this,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new mdt(this)}get serializable(){if(0===_nt(ddt,this).size)return hdt;var t=new Map,e=new ldt,r=[],n=Object.create(null),i=!1;for(var[a,s]of _nt(ddt,this)){var o=s instanceof jut?s.serialize(!1,n):s;o&&(t.set(a,o),e.update("".concat(a,":").concat(JSON.stringify(o))),i||(i=!!o.bitmap))}if(i)for(var l of t.values())l.bitmap&&r.push(l.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:r}:hdt}get editorStats(){var t=null,e=new Map;for(var r of _nt(ddt,this).values()){var n;if(r instanceof jut){var i=r.telemetryFinalData;if(i){var{type:a}=i;e.has(a)||e.set(a,Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));var s=(n=t)[a]||(n[a]=new Map);for(var[o,l]of Object.entries(i)){var h;if("type"!==o){var c=s.get(o);c||(c=new Map,s.set(o,c));var u=null!==(h=c.get(l))&&void 0!==h?h:0;c.set(l,u+1)}}}}}for(var[d,p]of e)t[d]=p.computeTelemetryFinalData(t[d]);return t}resetModifiedIds(){Snt(udt,this,null)}get modifiedIds(){if(_nt(udt,this))return _nt(udt,this);var t=[];for(var e of _nt(ddt,this).values())e instanceof jut&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return Snt(udt,this,{ids:new Set(t),hash:t.join(",")})}}function gdt(){_nt(cdt,this)||(Snt(cdt,this,!0),"function"==typeof this.onSetModified&&this.onSetModified())}var vdt=new WeakMap;class mdt extends fdt{constructor(t){super(),knt(this,vdt,void 0);var{map:e,hash:r,transfer:n}=t.serializable,i=structuredClone(e,n?{transfer:n}:null);Snt(vdt,this,{map:i,hash:r,transfer:n})}get print(){Uot("Should not call PrintAnnotationStorage.print")}get serializable(){return _nt(vdt,this)}get modifiedIds(){return Yot(this,"modifiedIds",{ids:new Set,hash:""})}}var ydt=new WeakMap;class bdt{constructor(t){var{ownerDocument:e=globalThis.document,styleElement:r=null}=t;knt(this,ydt,new Set),this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));var e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(var t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),_nt(ydt,this).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(t){var e=this;return xnt((function*(){var{systemFontInfo:r,_inspectFont:n}=t;if(r&&!_nt(ydt,e).has(r.loadedName))if(Hot(!e.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),e.isFontLoadingAPISupported){var{loadedName:i,src:a,style:s}=r,o=new FontFace(i,a,s);e.addNativeFontFace(o);try{yield o.load(),_nt(ydt,e).add(i),null==n||n(r)}catch(t){Wot("Cannot load system font: ".concat(r.baseFontName,", installing it could help to improve PDF rendering.")),e.removeNativeFontFace(o)}}else Uot("Not implemented: loadSystemFont without the Font Loading API.")}))()}bind(t){var e=this;return xnt((function*(){if(!(t.attached||t.missingFile&&!t.systemFontInfo))if(t.attached=!0,t.systemFontInfo)yield e.loadSystemFont(t);else if(e.isFontLoadingAPISupported){var r=t.createNativeFontFace();if(r){e.addNativeFontFace(r);try{yield r.loaded}catch(e){throw Wot("Failed to load font '".concat(r.family,"': '").concat(e,"'.")),t.disableFontFace=!0,e}}}else{var n=t.createFontFaceRule();if(n){if(e.insertRule(n),e.isSyncFontLoadingSupported)return;yield new Promise((r=>{var n=e._queueLoadingCallback(r);e._prepareFontLoadEvent(t,n)}))}}}))()}get isFontLoadingAPISupported(){var t;return Yot(this,"isFontLoadingAPISupported",!(null===(t=this._document)||void 0===t||!t.fonts))}get isSyncFontLoadingSupported(){var t,e=!1;return(Ust||"undefined"!=typeof navigator&&"string"==typeof(null===(t=navigator)||void 0===t?void 0:t.userAgent)&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),Yot(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(t){var{loadingRequests:e}=this,r={done:!1,complete:function(){for(Hot(!r.done,"completeRequest() cannot be called twice."),r.done=!0;e.length>0&&e[0].done;){var t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(r),r}get _loadTestFont(){return Yot(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function r(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function n(t,e,r,n){return t.substring(0,e)+n+t.substring(e+r)}var i,a,s=this._document.createElement("canvas");s.width=1,s.height=1;var o=s.getContext("2d"),l=0;var h="lt".concat(Date.now()).concat(this.loadTestFontId++),c=this._loadTestFont,u=1482184792,d=r(c=n(c,976,h.length,h),16);for(i=0,a=h.length-3;i<a;i+=4)d=d-u+r(h,i)|0;i<h.length&&(d=d-u+r(h+"XXX",i)|0),c=n(c,16,4,function(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}(d));var p="url(data:font/opentype;base64,".concat(btoa(c),");"),f='@font-face {font-family:"'.concat(h,'";src:').concat(p,"}");this.insertRule(f);var g=this._document.createElement("div");for(var v of(g.style.visibility="hidden",g.style.width=g.style.height="10px",g.style.position="absolute",g.style.top=g.style.left="0px",[t.loadedName,h])){var m=this._document.createElement("span");m.textContent="Hi",m.style.fontFamily=v,g.append(m)}this._document.body.append(g),function t(e,r){if(++l>30)return Wot("Load test font never loaded."),void r();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?r():setTimeout(t.bind(null,e,r))}(h,(()=>{g.remove(),e.complete()}))}}class wdt{constructor(t,e){var{disableFontFace:r=!1,fontExtraProperties:n=!1,inspectFont:i=null}=e;for(var a in this.compiledGlyphs=Object.create(null),t)this[a]=t[a];this.disableFontFace=!0===r,this.fontExtraProperties=!0===n,this._inspectFont=i}createNativeFontFace(){var t,e;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){var r={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(r.style="oblique ".concat(this.cssFontInfo.italicAngle,"deg")),e=new FontFace(this.cssFontInfo.fontFamily,this.data,r)}else e=new FontFace(this.loadedName,this.data,{});return null===(t=this._inspectFont)||void 0===t||t.call(this,this),e}createFontFaceRule(){var t;if(!this.data||this.disableFontFace)return null;var e,r,n="url(data:".concat(this.mimetype,";base64,").concat((e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(tlt(e))),");");if(this.cssFontInfo){var i="font-weight: ".concat(this.cssFontInfo.fontWeight,";");this.cssFontInfo.italicAngle&&(i+="font-style: oblique ".concat(this.cssFontInfo.italicAngle,"deg;")),r='@font-face {font-family:"'.concat(this.cssFontInfo.fontFamily,'";').concat(i,"src:").concat(n,"}")}else r='@font-face {font-family:"'.concat(this.loadedName,'";src:').concat(n,"}");return null===(t=this._inspectFont)||void 0===t||t.call(this,this,n),r}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];var r,n=this.loadedName+"_path_"+e;try{r=t.get(n)}catch(t){Wot('getPathGenerator - ignoring character: "'.concat(t,'".'))}var i=new Path2D(r||"");return this.fontExtraProperties||t.delete(n),this.compiledGlyphs[e]=i}}var xdt=1,Adt=2,_dt=1,kdt=2,Sdt=3,Edt=4,Mdt=5,Tdt=6,Cdt=7,Pdt=8;function Idt(){}function Rdt(t){if(t instanceof Zot||t instanceof $ot||t instanceof Kot||t instanceof qot||t instanceof Qot||t instanceof Xot)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||Uot('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Zot(t.message);case"InvalidPDFException":return new $ot(t.message);case"MissingPDFException":return new Kot(t.message);case"PasswordException":return new qot(t.message,t.code);case"UnexpectedResponseException":return new Qot(t.message,t.status);case"UnknownErrorException":return new Xot(t.message,t.details)}return new Xot(t.message,t.toString())}var Odt=new WeakMap,Ldt=new WeakSet;class Ddt{constructor(t,e,r){Mnt(this,Ldt),knt(this,Odt,new AbortController),this.sourceName=t,this.targetName=e,this.comObj=r,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),r.addEventListener("message",bnt(Ldt,this,Fdt).bind(this),{signal:_nt(Odt,this).signal})}on(t,e){var r=this.actionHandler;if(r[t])throw new Error('There is already an actionName called "'.concat(t,'"'));r[t]=e}send(t,e,r){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},r)}sendWithPromise(t,e,r){var n=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[n]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},r)}catch(t){i.reject(t)}return i.promise}sendWithStream(t,e,r,n){var i=this.streamId++,a=this.sourceName,s=this.targetName,o=this.comObj;return new ReadableStream({start:r=>{var l=Promise.withResolvers();return this.streamControllers[i]={controller:r,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:s,action:t,streamId:i,data:e,desiredSize:r.desiredSize},n),l.promise},pull:t=>{var e=Promise.withResolvers();return this.streamControllers[i].pullCall=e,o.postMessage({sourceName:a,targetName:s,stream:Tdt,streamId:i,desiredSize:t.desiredSize}),e.promise},cancel:t=>{Hot(t instanceof Error,"cancel must have a valid reason");var e=Promise.withResolvers();return this.streamControllers[i].cancelCall=e,this.streamControllers[i].isClosed=!0,o.postMessage({sourceName:a,targetName:s,stream:_dt,streamId:i,reason:Rdt(t)}),e.promise}},r)}destroy(){var t;null===(t=_nt(Odt,this))||void 0===t||t.abort(),Snt(Odt,this,null)}}function Fdt(t){var{data:e}=t;if(e.targetName===this.sourceName)if(e.stream)bnt(Ldt,this,jdt).call(this,e);else if(e.callback){var r=e.callbackId,n=this.callbackCapabilities[r];if(!n)throw new Error("Cannot resolve callback ".concat(r));if(delete this.callbackCapabilities[r],e.callback===xdt)n.resolve(e.data);else{if(e.callback!==Adt)throw new Error("Unexpected callback case");n.reject(Rdt(e.reason))}}else{var i=this.actionHandler[e.action];if(!i)throw new Error("Unknown action from worker: ".concat(e.action));if(e.callbackId){var a=this.sourceName,s=e.sourceName,o=this.comObj;Promise.try(i,e.data).then((function(t){o.postMessage({sourceName:a,targetName:s,callback:xdt,callbackId:e.callbackId,data:t})}),(function(t){o.postMessage({sourceName:a,targetName:s,callback:Adt,callbackId:e.callbackId,reason:Rdt(t)})}))}else e.streamId?bnt(Ldt,this,Ndt).call(this,e):i(e.data)}}function Ndt(t){var e=t.streamId,r=this.sourceName,n=t.sourceName,i=this.comObj,a=this,s=this.actionHandler[t.action],o={enqueue(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,s=arguments.length>2?arguments[2]:void 0;if(!this.isCancelled){var o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:r,targetName:n,stream:Edt,streamId:e,chunk:t},s)}},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:n,stream:Sdt,streamId:e}),delete a.streamSinks[e])},error(t){Hot(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:n,stream:Mdt,streamId:e,reason:Rdt(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(s,t.data,o).then((function(){i.postMessage({sourceName:r,targetName:n,stream:Pdt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:Pdt,streamId:e,reason:Rdt(t)})}))}function jdt(t){var e=t.streamId,r=this.sourceName,n=t.sourceName,i=this.comObj,a=this.streamControllers[e],s=this.streamSinks[e];switch(t.stream){case Pdt:t.success?a.startCall.resolve():a.startCall.reject(Rdt(t.reason));break;case Cdt:t.success?a.pullCall.resolve():a.pullCall.reject(Rdt(t.reason));break;case Tdt:if(!s){i.postMessage({sourceName:r,targetName:n,stream:Cdt,streamId:e,success:!0});break}s.desiredSize<=0&&t.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=t.desiredSize,Promise.try(s.onPull||Idt).then((function(){i.postMessage({sourceName:r,targetName:n,stream:Cdt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:Cdt,streamId:e,reason:Rdt(t)})}));break;case Edt:if(Hot(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Sdt:if(Hot(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),bnt(Ldt,this,Bdt).call(this,a,e);break;case Mdt:Hot(a,"error should have stream controller"),a.controller.error(Rdt(t.reason)),bnt(Ldt,this,Bdt).call(this,a,e);break;case kdt:t.success?a.cancelCall.resolve():a.cancelCall.reject(Rdt(t.reason)),bnt(Ldt,this,Bdt).call(this,a,e);break;case _dt:if(!s)break;var o=Rdt(t.reason);Promise.try(s.onCancel||Idt,o).then((function(){i.postMessage({sourceName:r,targetName:n,stream:kdt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:kdt,streamId:e,reason:Rdt(t)})})),s.sinkCapability.reject(o),s.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}function Bdt(t,e){return zdt.apply(this,arguments)}function zdt(){return(zdt=xnt((function*(t,e){var r,n,i;yield Promise.allSettled([null===(r=t.startCall)||void 0===r?void 0:r.promise,null===(n=t.pullCall)||void 0===n?void 0:n.promise,null===(i=t.cancelCall)||void 0===i?void 0:i.promise]),delete this.streamControllers[e]}))).apply(this,arguments)}var Wdt=new WeakMap;class Udt{constructor(t){var{enableHWA:e=!1}=t;knt(this,Wdt,!1),Snt(Wdt,this,e)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");var r=this._createCanvas(t,e);return{canvas:r,context:r.getContext("2d",{willReadFrequently:!_nt(Wdt,this)})}}reset(t,e,r){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||r<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=r}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Uot("Abstract method `_createCanvas` called.")}}class Hdt{constructor(t){var{baseUrl:e=null,isCompressed:r=!0}=t;this.baseUrl=e,this.isCompressed=r}fetch(t){var e=this;return xnt((function*(){var{name:r}=t;if(!e.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!r)throw new Error("CMap name must be specified.");var n=e.baseUrl+r+(e.isCompressed?".bcmap":"");return e._fetch(n).then((t=>({cMapData:t,isCompressed:e.isCompressed}))).catch((t=>{throw new Error("Unable to load ".concat(e.isCompressed?"binary ":"","CMap at: ").concat(n))}))}))()}_fetch(t){return xnt((function*(){Uot("Abstract method `_fetch` called.")}))()}}class Gdt extends Hdt{_fetch(t){var e=this;return xnt((function*(){var r=yield flt(t,e.isCompressed?"arraybuffer":"text");return r instanceof ArrayBuffer?new Uint8Array(r):elt(r)}))()}}class Ydt{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,r,n,i){return"none"}destroy(){}}var Vdt=new WeakMap,qdt=new WeakMap,Xdt=new WeakMap,$dt=new WeakMap,Kdt=new WeakMap,Qdt=new WeakMap,Jdt=new WeakMap,Zdt=new WeakSet;function tpt(t){return _nt(qdt,t)||Snt(qdt,t,new Map)}function ept(t){return _nt(Qdt,t)||Snt(Qdt,t,new Map)}function rpt(t){if(!_nt(Xdt,t)){var e=_nt(Kdt,t).createElement("div"),{style:r}=e;r.visibility="hidden",r.contain="strict",r.width=r.height=0,r.position="absolute",r.top=r.left=0,r.zIndex=-1;var n=_nt(Kdt,t).createElementNS(dlt,"svg");n.setAttribute("width",0),n.setAttribute("height",0),Snt(Xdt,t,_nt(Kdt,t).createElementNS(dlt,"defs")),e.append(n),n.append(_nt(Xdt,t)),_nt(Kdt,t).body.append(e)}return _nt(Xdt,t)}function npt(t){if(1===t.length){for(var e=t[0],r=new Array(256),n=0;n<256;n++)r[n]=e[n]/255;var i=r.join(",");return[i,i,i]}for(var[a,s,o]=t,l=new Array(256),h=new Array(256),c=new Array(256),u=0;u<256;u++)l[u]=a[u]/255,h[u]=s[u]/255,c[u]=o[u]/255;return[l.join(","),h.join(","),c.join(",")]}function ipt(t){if(void 0===_nt(Vdt,this)){Snt(Vdt,this,"");var e=_nt(Kdt,this).URL;e!==_nt(Kdt,this).baseURI&&(ylt(e)?Wot('#createUrl: ignore "data:"-URL for performance reasons.'):Snt(Vdt,this,e.split("#",1)[0]))}return"url(".concat(_nt(Vdt,this),"#").concat(t,")")}function apt(t){var e=_nt(Kdt,this).createElementNS(dlt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}function spt(t){var e=_nt(Kdt,this).createElementNS(dlt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}function opt(t){var e=_nt(Kdt,this).createElementNS(dlt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),Ent(Zdt,this,rpt).append(e),e}function lpt(t,e,r){var n=_nt(Kdt,this).createElementNS(dlt,e);n.setAttribute("type","discrete"),n.setAttribute("tableValues",r),t.append(n)}function hpt(t,e,r,n){var i=_nt(Kdt,this).createElementNS(dlt,"feComponentTransfer");n.append(i),bnt(Zdt,this,lpt).call(this,i,"feFuncR",t),bnt(Zdt,this,lpt).call(this,i,"feFuncG",e),bnt(Zdt,this,lpt).call(this,i,"feFuncB",r)}function cpt(t,e){var r=_nt(Kdt,this).createElementNS(dlt,"feComponentTransfer");e.append(r),bnt(Zdt,this,lpt).call(this,r,"feFuncA",t)}function upt(t){return Ent(Zdt,this,rpt).style.color=t,Clt(getComputedStyle(Ent(Zdt,this,rpt)).getPropertyValue("color"))}class dpt{constructor(t){var{baseUrl:e=null}=t;this.baseUrl=e}fetch(t){var e=this;return xnt((function*(){var{filename:r}=t;if(!e.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!r)throw new Error("Font filename must be specified.");var n="".concat(e.baseUrl).concat(r);return e._fetch(n).catch((t=>{throw new Error("Unable to load font data at: ".concat(n))}))}))()}_fetch(t){return xnt((function*(){Uot("Abstract method `_fetch` called.")}))()}}class ppt extends dpt{_fetch(t){return xnt((function*(){var e=yield flt(t,"arraybuffer");return new Uint8Array(e)}))()}}function fpt(t){return gpt.apply(this,arguments)}function gpt(){return gpt=xnt((function*(t){var e=process.getBuiltinModule("fs"),r=yield e.promises.readFile(t);return new Uint8Array(r)})),gpt.apply(this,arguments)}Ust&&Wot("Please use the `legacy` build in Node.js environments.");var vpt="Fill",mpt="Stroke",ypt="Shading";function bpt(t,e){if(e){var r=e[2]-e[0],n=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],r,n),t.clip(i)}}class wpt{getPattern(){Uot("Abstract method `getPattern` called.")}}class xpt extends wpt{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){var e;for(var r of("axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))e.addColorStop(r[0],r[1]);return e}getPattern(t,e,r,n){var i;if(n===mpt||n===vpt){var a=e.current.getClippedPathBoundingBox(n,Plt(t))||[0,0,0,0],s=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.cachedCanvases.getCanvas("pattern",s,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-a[0],-a[1]),r=alt.transform(r,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),bpt(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),i=t.createPattern(l.canvas,"no-repeat");var c=new DOMMatrix(r);i.setTransform(c)}else bpt(t,this._bbox),i=this._createGradient(t);return i}}function Apt(t,e,r,n,i,a,s,o){var l,h=e.coords,c=e.colors,u=t.data,d=4*t.width;h[r+1]>h[n+1]&&(l=r,r=n,n=l,l=a,a=s,s=l),h[n+1]>h[i+1]&&(l=n,n=i,i=l,l=s,s=o,o=l),h[r+1]>h[n+1]&&(l=r,r=n,n=l,l=a,a=s,s=l);var p=(h[r]+e.offsetX)*e.scaleX,f=(h[r+1]+e.offsetY)*e.scaleY,g=(h[n]+e.offsetX)*e.scaleX,v=(h[n+1]+e.offsetY)*e.scaleY,m=(h[i]+e.offsetX)*e.scaleX,y=(h[i+1]+e.offsetY)*e.scaleY;if(!(f>=y))for(var b,w,x,A,_,k,S,E,M=c[a],T=c[a+1],C=c[a+2],P=c[s],I=c[s+1],R=c[s+2],O=c[o],L=c[o+1],D=c[o+2],F=Math.round(f),N=Math.round(y),j=F;j<=N;j++){if(j<v){var B=j<f?0:(f-j)/(f-v);b=p-(p-g)*B,w=M-(M-P)*B,x=T-(T-I)*B,A=C-(C-R)*B}else{var z=void 0;b=g-(g-m)*(z=j>y?1:v===y?0:(v-j)/(v-y)),w=P-(P-O)*z,x=I-(I-L)*z,A=R-(R-D)*z}var W=void 0;_=p-(p-m)*(W=j<f?0:j>y?1:(f-j)/(f-y)),k=M-(M-O)*W,S=T-(T-L)*W,E=C-(C-D)*W;for(var U=Math.round(Math.min(b,_)),H=Math.round(Math.max(b,_)),G=d*j+4*U,Y=U;Y<=H;Y++)(W=(b-Y)/(b-_))<0?W=0:W>1&&(W=1),u[G++]=w-(w-k)*W|0,u[G++]=x-(x-S)*W|0,u[G++]=A-(A-E)*W|0,u[G++]=255}}function _pt(t,e,r){var n,i,a=e.coords,s=e.colors;switch(e.type){case"lattice":var o=e.verticesPerRow,l=Math.floor(a.length/o)-1,h=o-1;for(n=0;n<l;n++)for(var c=n*o,u=0;u<h;u++,c++)Apt(t,r,a[c],a[c+1],a[c+o],s[c],s[c+1],s[c+o]),Apt(t,r,a[c+o+1],a[c+1],a[c+o],s[c+o+1],s[c+1],s[c+o]);break;case"triangles":for(n=0,i=a.length;n<i;n+=3)Apt(t,r,a[n],a[n+1],a[n+2],s[n],s[n+1],s[n+2]);break;default:throw new Error("illegal figure")}}class kpt extends wpt{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,r){var n=Math.floor(this._bounds[0]),i=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-n,s=Math.ceil(this._bounds[3])-i,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(s*t[1]*1.1)),3e3),h=a/o,c=s/l,u={coords:this._coords,colors:this._colors,offsetX:-n,offsetY:-i,scaleX:1/h,scaleY:1/c},d=o+4,p=l+4,f=r.getCanvas("mesh",d,p),g=f.context,v=g.createImageData(o,l);if(e)for(var m=v.data,y=0,b=m.length;y<b;y+=4)m[y]=e[0],m[y+1]=e[1],m[y+2]=e[2],m[y+3]=255;for(var w of this._figures)_pt(v,w,u);return g.putImageData(v,2,2),{canvas:f.canvas,offsetX:n-2*h,offsetY:i-2*c,scaleX:h,scaleY:c}}getPattern(t,e,r,n){var i;if(bpt(t,this._bbox),n===ypt)i=alt.singularValueDecompose2dScale(Plt(t));else if(i=alt.singularValueDecompose2dScale(e.baseTransform),this.matrix){var a=alt.singularValueDecompose2dScale(this.matrix);i=[i[0]*a[0],i[1]*a[1]]}var s=this._createMeshCanvas(i,n===ypt?null:this._background,e.cachedCanvases);return n!==ypt&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(s.offsetX,s.offsetY),t.scale(s.scaleX,s.scaleY),t.createPattern(s.canvas,"no-repeat")}}class Spt extends wpt{getPattern(){return"hotpink"}}var Ept=1,Mpt=2;class Tpt{constructor(t,e,r,n,i){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=r,this.canvasGraphicsFactory=n,this.baseTransform=i}createPatternCanvas(t){var{bbox:e,operatorList:r,paintType:n,tilingType:i,color:a,canvasGraphicsFactory:s}=this,{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),zot("TilingType: "+i);var h=e[0],c=e[1],u=e[2],d=e[3],p=u-h,f=d-c,g=alt.singularValueDecompose2dScale(this.matrix),v=alt.singularValueDecompose2dScale(this.baseTransform),m=g[0]*v[0],y=g[1]*v[1],b=p,w=f,x=!1,A=!1,_=Math.ceil(o*m),k=Math.ceil(l*y);_>=Math.ceil(p*m)?b=o:x=!0,k>=Math.ceil(f*y)?w=l:A=!0;var S=this.getSizeAndScale(b,this.ctx.canvas.width,m),E=this.getSizeAndScale(w,this.ctx.canvas.height,y),M=t.cachedCanvases.getCanvas("pattern",S.size,E.size),T=M.context,C=s.createCanvasGraphics(T);if(C.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(C,n,a),T.translate(-S.scale*h,-E.scale*c),C.transform(S.scale,0,0,E.scale,0,0),T.save(),this.clipBbox(C,h,c,u,d),C.baseTransform=Plt(C.ctx),C.executeOperatorList(r),C.endDrawing(),T.restore(),x||A){var P=M.canvas;x&&(b=o),A&&(w=l);for(var I=this.getSizeAndScale(b,this.ctx.canvas.width,m),R=this.getSizeAndScale(w,this.ctx.canvas.height,y),O=I.size,L=R.size,D=t.cachedCanvases.getCanvas("pattern-workaround",O,L),F=D.context,N=x?Math.floor(p/o):0,j=A?Math.floor(f/l):0,B=0;B<=N;B++)for(var z=0;z<=j;z++)F.drawImage(P,O*B,L*z,O,L,0,0,O,L);return{canvas:D.canvas,scaleX:I.scale,scaleY:R.scale,offsetX:h,offsetY:c}}return{canvas:M.canvas,scaleX:S.scale,scaleY:E.scale,offsetX:h,offsetY:c}}getSizeAndScale(t,e,r){var n=Math.max(Tpt.MAX_PATTERN_SIZE,e),i=Math.ceil(t*r);return i>=n?i=n:r=i/t,{scale:r,size:i}}clipBbox(t,e,r,n,i){var a=n-e,s=i-r;t.ctx.rect(e,r,a,s),t.current.updateRectMinMax(Plt(t.ctx),[e,r,n,i]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,r){var n=t.ctx,i=t.current;switch(e){case Ept:var a=this.ctx;n.fillStyle=a.fillStyle,n.strokeStyle=a.strokeStyle,i.fillColor=a.fillStyle,i.strokeColor=a.strokeStyle;break;case Mpt:var s=alt.makeHexColor(r[0],r[1],r[2]);n.fillStyle=s,n.strokeStyle=s,i.fillColor=s,i.strokeColor=s;break;default:throw new Jot("Unsupported paint type: ".concat(e))}}getPattern(t,e,r,n){var i=r;n!==ypt&&(i=alt.transform(i,e.baseTransform),this.matrix&&(i=alt.transform(i,this.matrix)));var a=this.createPatternCanvas(e),s=new DOMMatrix(i);s=(s=s.translate(a.offsetX,a.offsetY)).scale(1/a.scaleX,1/a.scaleY);var o=t.createPattern(a.canvas,"repeat");return o.setTransform(s),o}}function Cpt(t){var{src:e,srcPos:r=0,dest:n,width:i,height:a,nonBlackColor:s=4294967295,inverseDecode:o=!1}=t,l=nlt.isLittleEndian?4278190080:255,[h,c]=o?[s,l]:[l,s],u=i>>3,d=7&i,p=e.length;n=new Uint32Array(n.buffer);for(var f=0,g=0;g<a;g++){for(var v=r+u;r<v;r++){var m=r<p?e[r]:255;n[f++]=128&m?c:h,n[f++]=64&m?c:h,n[f++]=32&m?c:h,n[f++]=16&m?c:h,n[f++]=8&m?c:h,n[f++]=4&m?c:h,n[f++]=2&m?c:h,n[f++]=1&m?c:h}if(0!==d)for(var y=r<p?e[r++]:255,b=0;b<d;b++)n[f++]=y&1<<7-b?c:h}return{srcPos:r,destPos:f}}Tnt(Tpt,"MAX_PATTERN_SIZE",3e3);var Ppt=16;class Ipt{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,r){var n;return void 0!==this.cache[t]?(n=this.cache[t],this.canvasFactory.reset(n,e,r)):(n=this.canvasFactory.create(e,r),this.cache[t]=n),n}delete(t){delete this.cache[t]}clear(){for(var t in this.cache){var e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Rpt(t,e,r,n,i,a,s,o,l,h){var[c,u,d,p,f,g]=Plt(t);if(0===u&&0===d){var v=s*c+f,m=Math.round(v),y=o*p+g,b=Math.round(y),w=(s+l)*c+f,x=Math.abs(Math.round(w)-m)||1,A=(o+h)*p+g,_=Math.abs(Math.round(A)-b)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),m,b),t.drawImage(e,r,n,i,a,0,0,x,_),t.setTransform(c,u,d,p,f,g),[x,_]}if(0===c&&0===p){var k=o*d+f,S=Math.round(k),E=s*u+g,M=Math.round(E),T=(o+h)*d+f,C=Math.abs(Math.round(T)-S)||1,P=(s+l)*u+g,I=Math.abs(Math.round(P)-M)||1;return t.setTransform(0,Math.sign(u),Math.sign(d),0,S,M),t.drawImage(e,r,n,i,a,0,0,I,C),t.setTransform(c,u,d,p,f,g),[I,C]}return t.drawImage(e,r,n,i,a,s,o,l,h),[Math.hypot(c,u)*l,Math.hypot(d,p)*h]}class Opt{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Hst,this.textMatrixScale=1,this.fontMatrix=Gst,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=iot,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){var t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,r){[e,r]=alt.applyTransform([e,r],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,r),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,r)}updateRectMinMax(t,e){var r=alt.applyTransform(e,t),n=alt.applyTransform(e.slice(2),t),i=alt.applyTransform([e[0],e[3]],t),a=alt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,r[0],n[0],i[0],a[0]),this.minY=Math.min(this.minY,r[1],n[1],i[1],a[1]),this.maxX=Math.max(this.maxX,r[0],n[0],i[0],a[0]),this.maxY=Math.max(this.maxY,r[1],n[1],i[1],a[1])}updateScalingPathMinMax(t,e){alt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,r,n,i,a,s,o,l,h){var c=alt.bezierBoundingBox(e,r,n,i,a,s,o,l,h);h||this.updateRectMinMax(t,c)}getPathBoundingBox(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:vpt,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=[this.minX,this.minY,this.maxX,this.maxY];if(t===mpt){e||Uot("Stroke bounding box must include transform.");var n=alt.singularValueDecompose2dScale(e),i=n[0]*this.lineWidth/2,a=n[1]*this.lineWidth/2;r[0]-=i,r[1]-=a,r[2]+=i,r[3]+=a}return r}updateClipFromPath(){var t=alt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:vpt,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return alt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Lpt(t,e){if(e instanceof ImageData)t.putImageData(e,0,0);else{var r,n,i,a,s,o=e.height,l=e.width,h=o%Ppt,c=(o-h)/Ppt,u=0===h?c:c+1,d=t.createImageData(l,Ppt),p=0,f=e.data,g=d.data;if(e.kind===cot.GRAYSCALE_1BPP){var v=f.byteLength,m=new Uint32Array(g.buffer,0,g.byteLength>>2),y=m.length,b=l+7>>3,w=4294967295,x=nlt.isLittleEndian?4278190080:255;for(n=0;n<u;n++){for(a=n<c?Ppt:h,r=0,i=0;i<a;i++){for(var A=v-p,_=0,k=A>b?l:8*A-7,S=-8&k,E=0,M=0;_<S;_+=8)M=f[p++],m[r++]=128&M?w:x,m[r++]=64&M?w:x,m[r++]=32&M?w:x,m[r++]=16&M?w:x,m[r++]=8&M?w:x,m[r++]=4&M?w:x,m[r++]=2&M?w:x,m[r++]=1&M?w:x;for(;_<k;_++)0===E&&(M=f[p++],E=128),m[r++]=M&E?w:x,E>>=1}for(;r<y;)m[r++]=0;t.putImageData(d,0,n*Ppt)}}else if(e.kind===cot.RGBA_32BPP){for(i=0,s=l*Ppt*4,n=0;n<c;n++)g.set(f.subarray(p,p+s)),p+=s,t.putImageData(d,0,i),i+=Ppt;n<u&&(s=l*h*4,g.set(f.subarray(p,p+s)),t.putImageData(d,0,i))}else{if(e.kind!==cot.RGB_24BPP)throw new Error("bad image kind: ".concat(e.kind));for(s=l*(a=Ppt),n=0;n<u;n++){for(n>=c&&(s=l*(a=h)),r=0,i=s;i--;)g[r++]=f[p++],g[r++]=f[p++],g[r++]=f[p++],g[r++]=255;t.putImageData(d,0,n*Ppt)}}}}function Dpt(t,e){if(e.bitmap)t.drawImage(e.bitmap,0,0);else for(var r=e.height,n=e.width,i=r%Ppt,a=(r-i)/Ppt,s=0===i?a:a+1,o=t.createImageData(n,Ppt),l=0,h=e.data,c=o.data,u=0;u<s;u++){var d=u<a?Ppt:i;({srcPos:l}=Cpt({src:h,srcPos:l,dest:c,width:n,height:d,nonBlackColor:0})),t.putImageData(o,0,u*Ppt)}}function Fpt(t,e){for(var r of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[r]&&(e[r]=t[r]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function Npt(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!Ust){var{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function jpt(t,e){if(e)return!0;var r=alt.singularValueDecompose2dScale(t);r[0]=Math.fround(r[0]),r[1]=Math.fround(r[1]);var n=Math.fround((globalThis.devicePixelRatio||1)*plt.PDF_TO_CSS_UNITS);return r[0]<=n&&r[1]<=n}var Bpt=["butt","round","square"],zpt=["miter","round","bevel"],Wpt={},Upt={},Hpt=new WeakSet;class Gpt{constructor(t,e,r,n,i,a,s,o){var{optionalContentConfig:l,markedContentStack:h=null}=a;Mnt(this,Hpt),this.ctx=t,this.current=new Opt(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=r,this.canvasFactory=n,this.filterFactory=i,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=h||[],this.optionalContentConfig=l,this.cachedCanvases=new Ipt(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=o,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing(t){var{transform:e,viewport:r,transparency:n=!1,background:i=null}=t,a=this.ctx.canvas.width,s=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,a,s),this.ctx.fillStyle=o,n){var l=this.cachedCanvases.getCanvas("transparent",a,s);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...Plt(this.compositeCtx))}this.ctx.save(),Npt(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...r.transform),this.viewportScale=r.scale,this.baseTransform=Plt(this.ctx)}executeOperatorList(t,e,r,n){var i=t.argsArray,a=t.fnArray,s=e||0,o=i.length;if(o===s)return s;for(var l,h=o-s>10&&"function"==typeof r,c=h?Date.now()+15:0,u=0,d=this.commonObjs,p=this.objs;;){if(void 0!==n&&s===n.nextBreakPoint)return n.breakIt(s,r),s;if((l=a[s])!==Dot.dependency)this[l].apply(this,i[s]);else for(var f of i[s]){var g=f.startsWith("g_")?d:p;if(!g.has(f))return g.get(f,r),s}if(++s===o)return s;if(h&&++u>10){if(Date.now()>c)return r(),s;u=0}}}endDrawing(){for(var t of(bnt(Hpt,this,Ypt).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(var e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),bnt(Hpt,this,Vpt).call(this)}_scaleImage(t,e){for(var r,n,i,a,s=null!==(r=t.width)&&void 0!==r?r:t.displayWidth,o=null!==(n=t.height)&&void 0!==n?n:t.displayHeight,l=Math.max(Math.hypot(e[0],e[1]),1),h=Math.max(Math.hypot(e[2],e[3]),1),c=s,u=o,d="prescale1";l>2&&c>1||h>2&&u>1;){var p=c,f=u;l>2&&c>1&&(l/=c/(p=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c/2))),h>2&&u>1&&(h/=u/(f=u>=16384?Math.floor(u/2)-1||1:Math.ceil(u)/2)),(a=(i=this.cachedCanvases.getCanvas(d,p,f)).context).clearRect(0,0,p,f),a.drawImage(t,0,0,c,u,0,0,p,f),t=i.canvas,c=p,u=f,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:c,paintHeight:u}}_createMaskCanvas(t){var e,r,n,i,a=this.ctx,{width:s,height:o}=t,l=this.current.fillColor,h=this.current.patternFill,c=Plt(a);if((t.bitmap||t.data)&&t.count>1){var u=t.bitmap||t.data.buffer;r=JSON.stringify(h?c:[c.slice(0,4),l]),(e=this._cachedBitmapsMap.get(u))||(e=new Map,this._cachedBitmapsMap.set(u,e));var d=e.get(r);if(d&&!h)return{canvas:d,offsetX:Math.round(Math.min(c[0],c[2])+c[4]),offsetY:Math.round(Math.min(c[1],c[3])+c[5])};n=d}n||Dpt((i=this.cachedCanvases.getCanvas("maskCanvas",s,o)).context,t);var p=alt.transform(c,[1/s,0,0,-1/o,0,0]);p=alt.transform(p,[1,0,0,1,0,-o]);var[f,g,v,m]=alt.getAxialAlignedBoundingBox([0,0,s,o],p),y=Math.round(v-f)||1,b=Math.round(m-g)||1,w=this.cachedCanvases.getCanvas("fillCanvas",y,b),x=w.context,A=f,_=g;x.translate(-A,-_),x.transform(...p),n||(n=(n=this._scaleImage(i.canvas,Ilt(x))).img,e&&h&&e.set(r,n)),x.imageSmoothingEnabled=jpt(Plt(x),t.interpolate),Rpt(x,n,0,0,n.width,n.height,0,0,s,o),x.globalCompositeOperation="source-in";var k=alt.transform(Ilt(x),[1,0,0,1,-A,-_]);return x.fillStyle=h?l.getPattern(a,this,k,vpt):l,x.fillRect(0,0,s,o),e&&!h&&(this.cachedCanvases.delete("fillCanvas"),e.set(r,w.canvas)),{canvas:w.canvas,offsetX:Math.round(A),offsetY:Math.round(_)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Bpt[t]}setLineJoin(t){this.ctx.lineJoin=zpt[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){var r=this.ctx;void 0!==r.setLineDash&&(r.setLineDash(t),r.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(var[e,r]of t)switch(e){case"LW":this.setLineWidth(r);break;case"LC":this.setLineCap(r);break;case"LJ":this.setLineJoin(r);break;case"ML":this.setMiterLimit(r);break;case"D":this.setDash(r[0],r[1]);break;case"RI":this.setRenderingIntent(r);break;case"FL":this.setFlatness(r);break;case"Font":this.setFont(r[0],r[1]);break;case"CA":this.current.strokeAlpha=r;break;case"ca":this.current.fillAlpha=r,this.ctx.globalAlpha=r;break;case"BM":this.ctx.globalCompositeOperation=r;break;case"SMask":this.current.activeSMask=r?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(r)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){var t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");var t=this.ctx.canvas.width,e=this.ctx.canvas.height,r="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(r,t,e);this.suspendedCtx=this.ctx,this.ctx=n.context;var i=this.ctx;i.setTransform(...Plt(this.suspendedCtx)),Fpt(this.suspendedCtx,i),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,r){e.translate(t,r),this.__originalTranslate(t,r)},t.scale=function(t,r){e.scale(t,r),this.__originalScale(t,r)},t.transform=function(t,r,n,i,a,s){e.transform(t,r,n,i,a,s),this.__originalTransform(t,r,n,i,a,s)},t.setTransform=function(t,r,n,i,a,s){e.setTransform(t,r,n,i,a,s),this.__originalSetTransform(t,r,n,i,a,s)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,r){e.moveTo(t,r),this.__originalMoveTo(t,r)},t.lineTo=function(t,r){e.lineTo(t,r),this.__originalLineTo(t,r)},t.bezierCurveTo=function(t,r,n,i,a,s){e.bezierCurveTo(t,r,n,i,a,s),this.__originalBezierCurveTo(t,r,n,i,a,s)},t.rect=function(t,r,n,i){e.rect(t,r,n,i),this.__originalRect(t,r,n,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(i,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Fpt(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(this.current.activeSMask){t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];var e=this.current.activeSMask,r=this.suspendedCtx;this.composeSMask(r,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}}composeSMask(t,e,r,n){var i=n[0],a=n[1],s=n[2]-i,o=n[3]-a;0!==s&&0!==o&&(this.genericComposeSMask(e.context,r,s,o,e.subtype,e.backdrop,e.transferMap,i,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(r.canvas,0,0),t.restore())}genericComposeSMask(t,e,r,n,i,a,s,o,l,h,c){var u=t.canvas,d=o-h,p=l-c;if(a){var f=alt.makeHexColor(...a);if(d<0||p<0||d+r>u.width||p+n>u.height){var g=this.cachedCanvases.getCanvas("maskExtension",r,n),v=g.context;v.drawImage(u,-d,-p),v.globalCompositeOperation="destination-atop",v.fillStyle=f,v.fillRect(0,0,r,n),v.globalCompositeOperation="source-over",u=g.canvas,d=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);var m=new Path2D;m.rect(d,p,r,n),t.clip(m),t.globalCompositeOperation="destination-atop",t.fillStyle=f,t.fillRect(d,p,r,n),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===i&&s?e.filter=this.filterFactory.addAlphaFilter(s):"Luminosity"===i&&(e.filter=this.filterFactory.addLuminosityFilter(s));var y=new Path2D;y.rect(o,l,r,n),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(u,d,p,r,n,o,l,r,n),e.restore()}save(){this.inSMaskMode?(Fpt(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();var t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Fpt(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,r,n,i,a){this.ctx.transform(t,e,r,n,i,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,r){for(var n,i,a=this.ctx,s=this.current,o=s.x,l=s.y,h=Plt(a),c=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],u=c?r.slice(0):null,d=0,p=0,f=t.length;d<f;d++)switch(0|t[d]){case Dot.rectangle:o=e[p++],l=e[p++];var g=e[p++],v=e[p++],m=o+g,y=l+v;a.moveTo(o,l),0===g||0===v?a.lineTo(m,y):(a.lineTo(m,l),a.lineTo(m,y),a.lineTo(o,y)),c||s.updateRectMinMax(h,[o,l,m,y]),a.closePath();break;case Dot.moveTo:o=e[p++],l=e[p++],a.moveTo(o,l),c||s.updatePathMinMax(h,o,l);break;case Dot.lineTo:o=e[p++],l=e[p++],a.lineTo(o,l),c||s.updatePathMinMax(h,o,l);break;case Dot.curveTo:n=o,i=l,o=e[p+4],l=e[p+5],a.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],o,l),s.updateCurvePathMinMax(h,n,i,e[p],e[p+1],e[p+2],e[p+3],o,l,u),p+=6;break;case Dot.curveTo2:n=o,i=l,a.bezierCurveTo(o,l,e[p],e[p+1],e[p+2],e[p+3]),s.updateCurvePathMinMax(h,n,i,o,l,e[p],e[p+1],e[p+2],e[p+3],u),o=e[p+2],l=e[p+3],p+=4;break;case Dot.curveTo3:n=o,i=l,o=e[p+2],l=e[p+3],a.bezierCurveTo(e[p],e[p+1],o,l,o,l),s.updateCurvePathMinMax(h,n,i,e[p],e[p+1],o,l,o,l,u),p+=4;break;case Dot.closePath:a.closePath()}c&&s.updateScalingPathMinMax(h,u),s.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.ctx,r=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof r&&null!=r&&r.getPattern?(e.save(),e.strokeStyle=r.getPattern(e,this,Ilt(e),mpt),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.ctx,r=this.current.fillColor,n=!1;this.current.patternFill&&(e.save(),e.fillStyle=r.getPattern(e,this,Ilt(e),vpt),n=!0);var i=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==i&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(i)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Wpt}eoClip(){this.pendingClip=Upt}beginText(){this.current.textMatrix=Hst,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){var t=this.pendingTextPaths,e=this.ctx;if(void 0!==t){var r=new Path2D,n=e.getTransform().invertSelf();for(var{transform:i,x:a,y:s,fontSize:o,path:l}of t)r.addPath(l,new DOMMatrix(i).preMultiplySelf(n).translate(a,s).scale(o,-o));e.clip(r),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var r,n=this.commonObjs.get(t),i=this.current;if(!n)throw new Error("Can't find font for ".concat(t));if(i.fontMatrix=n.fontMatrix||Gst,0!==i.fontMatrix[0]&&0!==i.fontMatrix[3]||Wot("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=n,this.current.fontSize=e,!n.isType3Font){var a=n.loadedName||"sans-serif",s=(null===(r=n.systemFontInfo)||void 0===r?void 0:r.css)||'"'.concat(a,'", ').concat(n.fallbackName),o="normal";n.black?o="900":n.bold&&(o="bold");var l=n.italic?"italic":"normal",h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font="".concat(l," ").concat(o," ").concat(h,"px ").concat(s)}}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,r,n,i,a){this.current.textMatrix=[t,e,r,n,i,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,r,n,i){var a,s=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,u=h&lot,d=!!(h&hot),p=o.patternFill&&!l.missingFile,f=o.patternStroke&&!l.missingFile;if((l.disableFontFace||d||p||f)&&(a=l.getPathGenerator(this.commonObjs,t)),l.disableFontFace||p||f){if(s.save(),s.translate(e,r),s.scale(c,-c),u===iot||u===sot)if(n){var g=s.getTransform();s.setTransform(...n),s.fill(bnt(Hpt,this,qpt).call(this,a,g,n))}else s.fill(a);if(u===aot||u===sot)if(i){var v=s.getTransform();s.setTransform(...i),s.stroke(bnt(Hpt,this,qpt).call(this,a,v,i))}else s.lineWidth/=c,s.stroke(a);s.restore()}else u!==iot&&u!==sot||s.fillText(t,e,r),u!==aot&&u!==sot||s.strokeText(t,e,r);d&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Plt(s),x:e,y:r,fontSize:c,path:a})}get isFontSubpixelAAEnabled(){var{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);for(var e=t.getImageData(0,0,10,10).data,r=!1,n=3;n<e.length;n+=4)if(e[n]>0&&e[n]<255){r=!0;break}return Yot(this,"isFontSubpixelAAEnabled",r)}showText(t){var e=this.current,r=e.font;if(r.isType3Font)return this.showType3Text(t);var n=e.fontSize;if(0!==n){var i,a,s=this.ctx,o=e.fontSizeScale,l=e.charSpacing,h=e.wordSpacing,c=e.fontDirection,u=e.textHScale*c,d=t.length,p=r.vertical,f=p?1:-1,g=r.defaultVMetrics,v=n*e.fontMatrix[0],m=e.textRenderingMode===iot&&!r.disableFontFace&&!e.patternFill;if(s.save(),s.transform(...e.textMatrix),s.translate(e.x,e.y+e.textRise),c>0?s.scale(u,-1):s.scale(u,1),e.patternFill){s.save();var y=e.fillColor.getPattern(s,this,Ilt(s),vpt);i=Plt(s),s.restore(),s.fillStyle=y}if(e.patternStroke){s.save();var b=e.strokeColor.getPattern(s,this,Ilt(s),mpt);a=Plt(s),s.restore(),s.strokeStyle=b}var w=e.lineWidth,x=e.textMatrixScale;if(0===x||0===w){var A=e.textRenderingMode&lot;A!==aot&&A!==sot||(w=this.getSinglePixelWidth())}else w/=x;if(1!==o&&(s.scale(o,o),w/=o),s.lineWidth=w,r.isInvalidPDFjsFont){var _=[],k=0;for(var S of t)_.push(S.unicode),k+=S.width;return s.fillText(_.join(""),0,0),e.x+=k*v*u,s.restore(),void this.compose()}var E,M=0;for(E=0;E<d;++E){var T=t[E];if("number"!=typeof T){var C=!1,P=(T.isSpace?h:0)+l,I=T.fontChar,R=T.accent,O=void 0,L=void 0,D=T.width;if(p){var F=T.vmetric||g,N=-(T.vmetric?F[1]:.5*D)*v,j=F[2]*v;D=F?-F[0]:D,O=N/o,L=(M+j)/o}else O=M/o,L=0;if(r.remeasure&&D>0){var B=1e3*s.measureText(I).width/n*o;if(D<B&&this.isFontSubpixelAAEnabled){var z=D/B;C=!0,s.save(),s.scale(z,1),O/=z}else D!==B&&(O+=(D-B)/2e3*n/o)}if(this.contentVisible&&(T.isInFont||r.missingFile))if(m&&!R)s.fillText(I,O,L);else if(this.paintChar(I,O,L,i,a),R){var W=O+n*R.offset.x/o,U=L-n*R.offset.y/o;this.paintChar(R.fontChar,W,U,i,a)}M+=p?D*v-P*c:D*v+P*c,C&&s.restore()}else M+=f*T*n/1e3}p?e.y-=M:e.x+=M*u,s.restore(),this.compose()}}showType3Text(t){var e,r,n,i,a=this.ctx,s=this.current,o=s.font,l=s.fontSize,h=s.fontDirection,c=o.vertical?1:-1,u=s.charSpacing,d=s.wordSpacing,p=s.textHScale*h,f=s.fontMatrix||Gst,g=t.length;if(!(s.textRenderingMode===oot)&&0!==l){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),a.transform(...s.textMatrix),a.translate(s.x,s.y),a.scale(p,h),e=0;e<g;++e)if("number"!=typeof(r=t[e])){var v=(r.isSpace?d:0)+u,m=o.charProcOperatorList[r.operatorListId];if(m)this.contentVisible&&(this.processingType3=r,this.save(),a.scale(l,l),a.transform(...f),this.executeOperatorList(m),this.restore()),n=alt.applyTransform([r.width,0],f)[0]*l+v,a.translate(n,0),s.x+=n*p;else Wot('Type3 character "'.concat(r.operatorListId,'" is not available.'))}else i=c*r*l/1e3,this.ctx.translate(i,0),s.x+=i*p;a.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,r,n,i,a){this.ctx.rect(r,n,i-r,a-n),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){var e;if("TilingPattern"===t[0]){var r=t[1],n=this.baseTransform||Plt(this.ctx),i={createCanvasGraphics:t=>new Gpt(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Tpt(t,r,this.ctx,i,n)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,r){this.ctx.strokeStyle=this.current.strokeColor=alt.makeHexColor(t,e,r),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,r){this.ctx.fillStyle=this.current.fillColor=alt.makeHexColor(t,e,r),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.cachedPatterns.has(t)?e=this.cachedPatterns.get(t):(e=function(t){switch(t[0]){case"RadialAxial":return new xpt(t);case"Mesh":return new kpt(t);case"Dummy":return new Spt}throw new Error("Unknown IR type: ".concat(t[0]))}(this.getObject(t)),this.cachedPatterns.set(t,e)),r&&(e.matrix=r),e}shadingFill(t){if(this.contentVisible){var e=this.ctx;this.save();var r=this._getPattern(t);e.fillStyle=r.getPattern(e,this,Ilt(e),ypt);var n=Ilt(e);if(n){var{width:i,height:a}=e.canvas,[s,o,l,h]=alt.getAxialAlignedBoundingBox([0,0,i,a],n);this.ctx.fillRect(s,o,l-s,h-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}}beginInlineImage(){Uot("Should not call beginInlineImage")}beginImageData(){Uot("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Plt(this.ctx),e)){var r=e[2]-e[0],n=e[3]-e[1];this.ctx.rect(e[0],e[1],r,n),this.current.updateRectMinMax(Plt(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(this.contentVisible){this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);var e=this.ctx;t.isolated||zot("TODO: Support non-isolated groups."),t.knockout&&Wot("Knockout groups not supported.");var r=Plt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");var n=alt.getAxialAlignedBoundingBox(t.bbox,Plt(e)),i=[0,0,e.canvas.width,e.canvas.height];n=alt.intersect(n,i)||[0,0,0,0];var a=Math.floor(n[0]),s=Math.floor(n[1]),o=Math.max(Math.ceil(n[2])-a,1),l=Math.max(Math.ceil(n[3])-s,1);this.current.startNewPathAndClipBox([0,0,o,l]);var h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);var c=this.cachedCanvases.getCanvas(h,o,l),u=c.context;u.translate(-a,-s),u.transform(...r),t.smask?this.smaskStack.push({canvas:c.canvas,context:u,offsetX:a,offsetY:s,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,s),e.save()),Fpt(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}}endGroup(t){if(this.contentVisible){this.groupLevel--;var e=this.ctx,r=this.groupStack.pop();if(this.ctx=r,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();var n=Plt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...n);var i=alt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],n);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}}beginAnnotation(t,e,r,n,i){if(bnt(Hpt,this,Ypt).call(this),Npt(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){var a=e[2]-e[0],s=e[3]-e[1];if(i&&this.annotationCanvasMap){(r=r.slice())[4]-=e[0],r[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=a,e[3]=s;var[o,l]=alt.singularValueDecompose2dScale(Plt(this.ctx)),{viewportScale:h}=this,c=Math.ceil(a*this.outputScaleX*h),u=Math.ceil(s*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,u);var{canvas:d,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(o,0,0,-l,0,s*l),Npt(this.ctx)}else Npt(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],a,s),this.ctx.clip(),this.ctx.beginPath()}this.current=new Opt(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...r),this.transform(...n)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),bnt(Hpt,this,Vpt).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(this.contentVisible){var e=t.count;(t=this.getObject(t.data,t)).count=e;var r=this.ctx,n=this.processingType3;if(n&&(void 0===n.compiled&&(n.compiled=function(t){var{width:e,height:r}=t;if(e>1e3||r>1e3)return null;var n,i,a,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=e+1,l=new Uint8Array(o*(r+1)),h=e+7&-8,c=new Uint8Array(h*r),u=0;for(var d of t.data)for(var p=128;p>0;)c[u++]=d&p?0:255,p>>=1;var f=0;for(0!==c[u=0]&&(l[0]=1,++f),i=1;i<e;i++)c[u]!==c[u+1]&&(l[i]=c[u]?2:1,++f),u++;for(0!==c[u]&&(l[i]=2,++f),n=1;n<r;n++){a=n*o,c[(u=n*h)-h]!==c[u]&&(l[a]=c[u]?1:8,++f);var g=(c[u]?4:0)+(c[u-h]?8:0);for(i=1;i<e;i++)s[g=(g>>2)+(c[u+1]?4:0)+(c[u-h+1]?8:0)]&&(l[a+i]=s[g],++f),u++;if(c[u-h]!==c[u]&&(l[a+i]=c[u]?2:4,++f),f>1e3)return null}for(a=n*o,0!==c[u=h*(r-1)]&&(l[a]=8,++f),i=1;i<e;i++)c[u]!==c[u+1]&&(l[a+i]=c[u]?4:8,++f),u++;if(0!==c[u]&&(l[a+i]=4,++f),f>1e3)return null;var v=new Int32Array([0,o,-1,0,-o,0,0,0,1]),m=new Path2D;for(n=0;f&&n<=r;n++){for(var y=n*o,b=y+e;y<b&&!l[y];)y++;if(y!==b){m.moveTo(y%o,n);var w=y,x=l[y];do{var A=v[x];do{y+=A}while(!l[y]);var _=l[y];5!==_&&10!==_?(x=_,l[y]=0):(x=_&51*x>>4,l[y]&=x>>2|x<<2),m.lineTo(y%o,y/o|0),l[y]||--f}while(w!==y);--n}}return c=null,l=null,function(t){t.save(),t.scale(1/e,-1/r),t.translate(0,-r),t.fill(m),t.beginPath(),t.restore()}}(t)),n.compiled))n.compiled(r);else{var i=this._createMaskCanvas(t),a=i.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(a,i.offsetX,i.offsetY),r.restore(),this.compose()}}}paintImageMaskXObjectRepeat(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;if(this.contentVisible){t=this.getObject(t.data,t);var s=this.ctx;s.save();var o=Plt(s);s.transform(e,r,n,i,0,0);var l=this._createMaskCanvas(t);s.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(var h=0,c=a.length;h<c;h+=2){var u=alt.transform(o,[e,r,n,i,a[h],a[h+1]]),[d,p]=alt.applyTransform([0,0],u);s.drawImage(l.canvas,d,p)}s.restore(),this.compose()}}paintImageMaskXObjectGroup(t){if(this.contentVisible){var e=this.ctx,r=this.current.fillColor,n=this.current.patternFill;for(var i of t){var{data:a,width:s,height:o,transform:l}=i,h=this.cachedCanvases.getCanvas("maskCanvas",s,o),c=h.context;c.save(),Dpt(c,this.getObject(a,i)),c.globalCompositeOperation="source-in",c.fillStyle=n?r.getPattern(c,this,Ilt(e),vpt):r,c.fillRect(0,0,s,o),c.restore(),e.save(),e.transform(...l),e.scale(1,-1),Rpt(e,h.canvas,0,0,s,o,0,-1,1,1),e.restore()}this.compose()}}paintImageXObject(t){if(this.contentVisible){var e=this.getObject(t);e?this.paintInlineImageXObject(e):Wot("Dependent image isn't ready yet")}}paintImageXObjectRepeat(t,e,r,n){if(this.contentVisible){var i=this.getObject(t);if(i){for(var a=i.width,s=i.height,o=[],l=0,h=n.length;l<h;l+=2)o.push({transform:[e,0,0,r,n[l],n[l+1]],x:0,y:0,w:a,h:s});this.paintInlineImageXObjectGroup(i,o)}else Wot("Dependent image isn't ready yet")}}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;var{bitmap:e,width:r,height:n}=t,i=this.cachedCanvases.getCanvas("inlineImage",r,n),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",i.canvas}paintInlineImageXObject(t){if(this.contentVisible){var e,r=t.width,n=t.height,i=this.ctx;if(this.save(),!Ust){var{filter:a}=i;"none"!==a&&""!==a&&(i.filter="none")}if(i.scale(1/r,-1/n),t.bitmap)e=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)e=t;else{var s=this.cachedCanvases.getCanvas("inlineImage",r,n).context;Lpt(s,t),e=this.applyTransferMapsToCanvas(s)}var o=this._scaleImage(e,Ilt(i));i.imageSmoothingEnabled=jpt(Plt(i),t.interpolate),Rpt(i,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,r,n),this.compose(),this.restore()}}paintInlineImageXObjectGroup(t,e){if(this.contentVisible){var r,n=this.ctx;if(t.bitmap)r=t.bitmap;else{var i=t.width,a=t.height,s=this.cachedCanvases.getCanvas("inlineImage",i,a).context;Lpt(s,t),r=this.applyTransferMapsToCanvas(s)}for(var o of e)n.save(),n.transform(...o.transform),n.scale(1,-1),Rpt(n,r,o.x,o.y,o.w,o.h,0,-1,1,1),n.restore();this.compose()}}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){var e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);var r=this.ctx;this.pendingClip&&(e||(this.pendingClip===Upt?r.clip("evenodd"):r.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),r.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){var t=Plt(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{var e=Math.abs(t[0]*t[3]-t[2]*t[1]),r=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(r,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){var t,e,{lineWidth:r}=this.current,{a:n,b:i,c:a,d:s}=this.ctx.getTransform();if(0===i&&0===a){var o=Math.abs(n),l=Math.abs(s);if(o===l)if(0===r)t=e=1/o;else{var h=o*r;t=e=h<1?1/h:1}else if(0===r)t=1/o,e=1/l;else{var c=o*r,u=l*r;t=c<1?1/c:1,e=u<1?1/u:1}}else{var d=Math.abs(n*s-i*a),p=Math.hypot(n,i),f=Math.hypot(a,s);if(0===r)t=f/d,e=p/d;else{var g=r*d;t=f>g?f/g:1,e=p>g?p/g:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t){var{ctx:e}=this,{lineWidth:r}=this.current,[n,i]=this.getScaleForStroking();if(e.lineWidth=r||1,1!==n||1!==i){var a=e.getLineDash();if(t&&e.save(),e.scale(n,i),a.length>0){var s=Math.max(n,i);e.setLineDash(a.map((t=>t/s))),e.lineDashOffset/=s}e.stroke(),t&&e.restore()}else e.stroke()}isContentVisible(){for(var t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}function Ypt(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}function Vpt(){if(this.pageColors){var t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){var e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}function qpt(t,e,r){var n=new Path2D;return n.addPath(t,new DOMMatrix(r).invertSelf().multiplySelf(e)),n}for(var Xpt in Dot)void 0!==Gpt.prototype[Xpt]&&(Gpt.prototype[Dot[Xpt]]=Gpt.prototype[Xpt]);class $pt{static get workerPort(){return bnt($pt,this,Kpt)._}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");Kpt._=bnt($pt,this,t)}static get workerSrc(){return bnt($pt,this,Qpt)._}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");Qpt._=bnt($pt,this,t)}}var Kpt={_:null},Qpt={_:""},Jpt=new WeakMap,Zpt=new WeakMap;class tft{constructor(t){var{parsedData:e,rawData:r}=t;knt(this,Jpt,void 0),knt(this,Zpt,void 0),Snt(Jpt,this,e),Snt(Zpt,this,r)}getRaw(){return _nt(Zpt,this)}get(t){var e;return null!==(e=_nt(Jpt,this).get(t))&&void 0!==e?e:null}getAll(){return rlt(_nt(Jpt,this))}has(t){return _nt(Jpt,this).has(t)}}var eft=Symbol("INTERNAL"),rft=new WeakMap,nft=new WeakMap,ift=new WeakMap,aft=new WeakMap;class sft{constructor(t,e){var{name:r,intent:n,usage:i,rbGroups:a}=e;knt(this,rft,!1),knt(this,nft,!1),knt(this,ift,!1),knt(this,aft,!0),Snt(rft,this,!!(t&qst)),Snt(nft,this,!!(t&Xst)),this.name=r,this.intent=n,this.usage=i,this.rbGroups=a}get visible(){if(_nt(ift,this))return _nt(aft,this);if(!_nt(aft,this))return!1;var{print:t,view:e}=this.usage;return _nt(rft,this)?"OFF"!==(null==e?void 0:e.viewState):!_nt(nft,this)||"OFF"!==(null==t?void 0:t.printState)}_setVisible(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t!==eft&&Uot("Internal method `_setVisible` called."),Snt(ift,this,r),Snt(aft,this,e)}}var oft=new WeakMap,lft=new WeakMap,hft=new WeakMap,cft=new WeakMap,uft=new WeakSet;class dft{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:qst;if(Mnt(this,uft),knt(this,oft,null),knt(this,lft,new Map),knt(this,hft,null),knt(this,cft,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==t){for(var r of(this.name=t.name,this.creator=t.creator,Snt(cft,this,t.order),t.groups))_nt(lft,this).set(r.id,new sft(e,r));if("OFF"===t.baseState)for(var n of _nt(lft,this).values())n._setVisible(eft,!1);for(var i of t.on)_nt(lft,this).get(i)._setVisible(eft,!0);for(var a of t.off)_nt(lft,this).get(a)._setVisible(eft,!1);Snt(hft,this,this.getHash())}}isVisible(t){if(0===_nt(lft,this).size)return!0;if(!t)return zot("Optional content group not defined."),!0;if("OCG"===t.type)return _nt(lft,this).has(t.id)?_nt(lft,this).get(t.id).visible:(Wot("Optional content group not found: ".concat(t.id)),!0);if("OCMD"===t.type){if(t.expression)return bnt(uft,this,pft).call(this,t.expression);if(!t.policy||"AnyOn"===t.policy){for(var e of t.ids){if(!_nt(lft,this).has(e))return Wot("Optional content group not found: ".concat(e)),!0;if(_nt(lft,this).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(var r of t.ids){if(!_nt(lft,this).has(r))return Wot("Optional content group not found: ".concat(r)),!0;if(!_nt(lft,this).get(r).visible)return!1}return!0}if("AnyOff"===t.policy){for(var n of t.ids){if(!_nt(lft,this).has(n))return Wot("Optional content group not found: ".concat(n)),!0;if(!_nt(lft,this).get(n).visible)return!0}return!1}if("AllOff"===t.policy){for(var i of t.ids){if(!_nt(lft,this).has(i))return Wot("Optional content group not found: ".concat(i)),!0;if(_nt(lft,this).get(i).visible)return!1}return!0}return Wot("Unknown optional content policy ".concat(t.policy,".")),!0}return Wot("Unknown group type ".concat(t.type,".")),!0}setVisibility(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=_nt(lft,this).get(t);if(n){if(r&&e&&n.rbGroups.length)for(var i of n.rbGroups)for(var a of i){var s;if(a!==t)null===(s=_nt(lft,this).get(a))||void 0===s||s._setVisible(eft,!1,!0)}n._setVisible(eft,!!e,!0),Snt(oft,this,null)}else Wot("Optional content group not found: ".concat(t))}setOCGState(t){var e,{state:r,preserveRB:n}=t;for(var i of r){switch(i){case"ON":case"OFF":case"Toggle":e=i;continue}var a=_nt(lft,this).get(i);if(a)switch(e){case"ON":this.setVisibility(i,!0,n);break;case"OFF":this.setVisibility(i,!1,n);break;case"Toggle":this.setVisibility(i,!a.visible,n)}}Snt(oft,this,null)}get hasInitialVisibility(){return null===_nt(hft,this)||this.getHash()===_nt(hft,this)}getOrder(){return _nt(lft,this).size?_nt(cft,this)?_nt(cft,this).slice():[..._nt(lft,this).keys()]:null}getGroups(){return _nt(lft,this).size>0?rlt(_nt(lft,this)):null}getGroup(t){return _nt(lft,this).get(t)||null}getHash(){if(null!==_nt(oft,this))return _nt(oft,this);var t=new ldt;for(var[e,r]of _nt(lft,this))t.update("".concat(e,":").concat(r.visible));return Snt(oft,this,t.hexdigest())}}function pft(t){var e=t.length;if(e<2)return!0;for(var r=t[0],n=1;n<e;n++){var i=t[n],a=void 0;if(Array.isArray(i))a=bnt(uft,this,pft).call(this,i);else{if(!_nt(lft,this).has(i))return Wot("Optional content group not found: ".concat(i)),!0;a=_nt(lft,this).get(i).visible}switch(r){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return"And"===r}class fft{constructor(t,e){var{disableRange:r=!1,disableStream:n=!1}=e;Hot(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');var{length:i,initialData:a,progressiveDone:s,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=s,this._contentDispositionFilename=o,(null==a?void 0:a.length)>0){var l=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!r,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData(t){var{begin:e,chunk:r}=t,n=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;void 0===e?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):Hot(this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}_onProgress(t){var e,r,n,i;void 0===t.total?null===(e=this._rangeReaders[0])||void 0===e||null===(r=e.onProgress)||void 0===r||r.call(e,{loaded:t.loaded}):null===(n=this._fullRequestReader)||void 0===n||null===(i=n.onProgress)||void 0===i||i.call(n,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;null===(t=this._fullRequestReader)||void 0===t||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){var e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Hot(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");var t=this._queuedChunks;return this._queuedChunks=null,new gft(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new vft(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeReaders.slice(0)))r.cancel(t);this._pdfDataRangeTransport.abort()}}class gft{constructor(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;for(var i of(this._stream=t,this._done=r||!1,this._filename=blt(n)?n:null,this._queuedChunks=e||[],this._loaded=0,this._queuedChunks))this._loaded+=i.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){var t=this;return xnt((function*(){if(t._queuedChunks.length>0)return{value:t._queuedChunks.shift(),done:!1};if(t._done)return{value:void 0,done:!0};var e=Promise.withResolvers();return t._requests.push(e),e.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class vft{constructor(t,e,r){this._stream=t,this._begin=e,this._end=r,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{var e=this._requests.shift();for(var r of(e.resolve({value:t,done:!1}),this._requests))r.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){var t=this;return xnt((function*(){if(t._queuedChunk){var e=t._queuedChunk;return t._queuedChunk=null,{value:e,done:!1}}if(t._done)return{value:void 0,done:!0};var r=Promise.withResolvers();return t._requests.push(r),r.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function mft(t,e){var r=new Headers;if(!t||!e||"object"!=typeof e)return r;for(var n in e){var i=e[n];void 0!==i&&r.append(n,i)}return r}function yft(t){try{return new URL(t).origin}catch(t){}return null}function bft(t){var{responseHeaders:e,isHttp:r,rangeChunkSize:n,disableRange:i}=t,a={allowRangeRequests:!1,suggestedLength:void 0},s=parseInt(e.get("Content-Length"),10);return Number.isInteger(s)?(a.suggestedLength=s,s<=2*n||i||!r||"bytes"!==e.get("Accept-Ranges")||"identity"!==(e.get("Content-Encoding")||"identity")||(a.allowRangeRequests=!0),a):a}function wft(t){var e=t.get("Content-Disposition");if(e){var r=function(t){var e=!0,r=a("filename\\*","i").exec(t);if(r){var n=l(r=r[1]);return o(n=c(n=h(n=unescape(n))))}if(r=function(t){for(var e,r=[],n=a("filename\\*((?!0\\d)\\d+)(\\*?)","ig");null!==(e=n.exec(t));){var[,i,s,o]=e;if((i=parseInt(i,10))in r){if(0===i)break}else r[i]=[s,o]}for(var c=[],u=0;u<r.length&&u in r;++u){var[d,p]=r[u];p=l(p),d&&(p=unescape(p),0===u&&(p=h(p))),c.push(p)}return c.join("")}(t),r)return o(c(r));if(r=a("filename","i").exec(t)){var i=l(r=r[1]);return o(i=c(i))}function a(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function s(t,r){if(t){if(!/^[\x00-\xFF]+$/.test(r))return r;try{var n=new TextDecoder(t,{fatal:!0}),i=elt(r);r=n.decode(i),e=!1}catch(t){}}return r}function o(t){return e&&/[\x80-\xff]/.test(t)&&(t=s("utf-8",t),e&&(t=s("iso-8859-1",t))),t}function l(t){if(t.startsWith('"')){for(var e=t.slice(1).split('\\"'),r=0;r<e.length;++r){var n=e[r].indexOf('"');-1!==n&&(e[r]=e[r].slice(0,n),e.length=r+1),e[r]=e[r].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function h(t){var e=t.indexOf("'");return-1===e?t:s(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function c(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,r,n){if("q"===r||"Q"===r)return n=(n=n.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})),s(e,n);try{n=atob(n)}catch(t){}return s(e,n)}))}return""}(e);if(r.includes("%"))try{r=decodeURIComponent(r)}catch(t){}if(blt(r))return r}return null}function xft(t,e){return 404===t||0===t&&e.startsWith("file:")?new Kot('Missing PDF "'+e+'".'):new Qot("Unexpected server response (".concat(t,') while retrieving PDF "').concat(e,'".'),t)}function Aft(t){return 200===t||206===t}function _ft(t,e,r){return{method:"GET",headers:t,signal:r.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function kft(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Wot("getArrayBuffer - unexpected data format: ".concat(t)),new Uint8Array(t).buffer)}class Sft{constructor(t){Tnt(this,"_responseOrigin",null),this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=mft(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}getFullReader(){return Hot(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Eft(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new Mft(this,t,e);return this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class Eft{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;var e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;var r=new Headers(t.headers),n=e.url;fetch(n,_ft(r,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=yft(e.url),!Aft(e.status))throw xft(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();var r=e.headers,{allowRangeRequests:i,suggestedLength:a}=bft({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=a||this._contentLength,this._filename=wft(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Zot("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return xnt((function*(){var e;yield t._headersCapability.promise;var{value:r,done:n}=yield t._reader.read();return n?{value:r,done:n}:(t._loaded+=r.byteLength,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded,total:t._contentLength}),{value:kft(r),done:!1})}))()}cancel(t){var e;null===(e=this._reader)||void 0===e||e.cancel(t),this._abortController.abort()}}class Mft{constructor(t,e,r){this._stream=t,this._reader=null,this._loaded=0;var n=t.source;this._withCredentials=n.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!n.disableStream,this._abortController=new AbortController;var i=new Headers(t.headers);i.append("Range","bytes=".concat(e,"-").concat(r-1));var a=n.url;fetch(a,_ft(i,this._withCredentials,this._abortController)).then((e=>{var r=yft(e.url);if(r!==t._responseOrigin)throw new Error('Expected range response-origin "'.concat(r,'" to match "').concat(t._responseOrigin,'".'));if(!Aft(e.status))throw xft(e.status,a);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return xnt((function*(){var e;yield t._readCapability.promise;var{value:r,done:n}=yield t._reader.read();return n?{value:r,done:n}:(t._loaded+=r.byteLength,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded}),{value:kft(r),done:!1})}))()}cancel(t){var e;null===(e=this._reader)||void 0===e||e.cancel(t),this._abortController.abort()}}class Tft{constructor(t){var{url:e,httpHeaders:r,withCredentials:n}=t;Tnt(this,"_responseOrigin",null),this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=mft(this.isHttp,r),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){var e=new XMLHttpRequest,r=this.currXhrId++,n=this.pendingRequests[r]={xhr:e};for(var[i,a]of(e.open("GET",this.url),e.withCredentials=this.withCredentials,this.headers))e.setRequestHeader(i,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range","bytes=".concat(t.begin,"-").concat(t.end-1)),n.expectedStatus=206):n.expectedStatus=200,e.responseType="arraybuffer",Hot(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,r),e.onprogress=this.onProgress.bind(this,r),n.onHeadersReceived=t.onHeadersReceived,n.onDone=t.onDone,n.onError=t.onError,n.onProgress=t.onProgress,e.send(null),r}onProgress(t,e){var r,n=this.pendingRequests[t];n&&(null===(r=n.onProgress)||void 0===r||r.call(n,e))}onStateChange(t,e){var r=this.pendingRequests[t];if(r){var n=r.xhr;if(n.readyState>=2&&r.onHeadersReceived&&(r.onHeadersReceived(),delete r.onHeadersReceived),4===n.readyState&&t in this.pendingRequests)if(delete this.pendingRequests[t],0===n.status&&this.isHttp)r.onError(n.status);else{var i=n.status||200;if(200===i&&206===r.expectedStatus||i===r.expectedStatus){var a=function(t){var e=t.response;return"string"!=typeof e?e:elt(e).buffer}(n);if(206===i){var s=n.getResponseHeader("Content-Range"),o=/bytes (\d+)-(\d+)\/(\d+)/.exec(s);o?r.onDone({begin:parseInt(o[1],10),chunk:a}):(Wot('Missing or invalid "Content-Range" header.'),r.onError(0))}else a?r.onDone({begin:0,chunk:a}):r.onError(n.status)}else r.onError(n.status)}}}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){var e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Cft{constructor(t){this._source=t,this._manager=new Tft(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){var e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return Hot(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Pft(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){var r=new Ift(this._manager,t,e);return r.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class Pft{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){var t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=yft(e.responseURL);var r=e.getAllResponseHeaders(),n=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{var[e,...r]=t.split(": ");return[e,r.join(": ")]})):[]),{allowRangeRequests:i,suggestedLength:a}=bft({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=wft(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk));if(this._done=!0,!(this._cachedChunks.length>0)){for(var e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){for(var e of(this._storedError=xft(t,this._url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;null===(e=this.onProgress)||void 0===e||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}read(){var t=this;return xnt((function*(){if(yield t._headersCapability.promise,t._storedError)throw t._storedError;if(t._cachedChunks.length>0)return{value:t._cachedChunks.shift(),done:!1};if(t._done)return{value:void 0,done:!0};var e=Promise.withResolvers();return t._requests.push(e),e.promise}))()}cancel(t){for(var e of(this._done=!0,this._headersCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Ift{constructor(t,e,r){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:r,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var t,e=yft(null===(t=this._manager.getRequestXhr(this._requestId))||void 0===t?void 0:t.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error('Expected range response-origin "'.concat(e,'" to match "').concat(this._manager._responseOrigin,'".')),this._onError(0))}_close(){var t;null===(t=this.onClosed)||void 0===t||t.call(this,this)}_onDone(t){var e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e;for(var r of(this._done=!0,this._requests))r.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){var e;for(var r of(null!==(e=this._storedError)&&void 0!==e||(this._storedError=xft(t,this._url)),this._requests))r.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(null===(e=this.onProgress)||void 0===e||e.call(this,{loaded:t.loaded}))}get isStreamingSupported(){return!1}read(){var t=this;return xnt((function*(){if(t._storedError)throw t._storedError;if(null!==t._queuedChunk){var e=t._queuedChunk;return t._queuedChunk=null,{value:e,done:!1}}if(t._done)return{value:void 0,done:!0};var r=Promise.withResolvers();return t._requests.push(r),r.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}var Rft=/^[a-z][a-z0-9\-+.]+:/i;class Oft{constructor(t){this.source=t,this.url=function(t){if(Rft.test(t))return new URL(t);var e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),Hot("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}getFullReader(){return Hot(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Lft(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new Dft(this,t,e);return this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class Lft{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;var e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();var r=process.getBuiltinModule("fs");r.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(r.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new Kot('Missing PDF "'.concat(this._url,'".'))),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return xnt((function*(){var e;if(yield t._readCapability.promise,t._done)return{value:void 0,done:!0};if(t._storedError)throw t._storedError;var r=t._readableStream.read();return null===r?(t._readCapability=Promise.withResolvers(),t.read()):(t._loaded+=r.length,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded,total:t._contentLength}),{value:new Uint8Array(r).buffer,done:!1})}))()}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Zot("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Dft{constructor(t,e,r){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();var n=t.source;this._isStreamingSupported=!n.disableStream;var i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:r-1}))}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return xnt((function*(){var e;if(yield t._readCapability.promise,t._done)return{value:void 0,done:!0};if(t._storedError)throw t._storedError;var r=t._readableStream.read();return null===r?(t._readCapability=Promise.withResolvers(),t.read()):(t._loaded+=r.length,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded}),{value:new Uint8Array(r).buffer,done:!1})}))()}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}var Fft=30,Nft=new WeakMap,jft=new WeakMap,Bft=new WeakMap,zft=new WeakMap,Wft=new WeakMap,Uft=new WeakMap,Hft=new WeakMap,Gft=new WeakMap,Yft=new WeakMap,Vft=new WeakMap,qft=new WeakMap,Xft=new WeakMap,$ft=new WeakMap,Kft=new WeakMap,Qft=new WeakMap,Jft=new WeakMap,Zft=new WeakMap,tgt=new WeakMap,egt=new WeakSet;class rgt{constructor(t){var e,{textContentSource:r,container:n,viewport:i}=t;if(Mnt(this,egt),knt(this,Nft,Promise.withResolvers()),knt(this,jft,null),knt(this,Bft,!1),knt(this,zft,!(null===(e=globalThis.FontInspector)||void 0===e||!e.enabled)),knt(this,Wft,null),knt(this,Uft,null),knt(this,Hft,0),knt(this,Gft,0),knt(this,Yft,null),knt(this,Vft,null),knt(this,qft,0),knt(this,Xft,0),knt(this,$ft,Object.create(null)),knt(this,Kft,[]),knt(this,Qft,null),knt(this,Jft,[]),knt(this,Zft,new WeakMap),knt(this,tgt,null),r instanceof ReadableStream)Snt(Qft,this,r);else{if("object"!=typeof r)throw new Error('No "textContentSource" parameter specified.');Snt(Qft,this,new ReadableStream({start(t){t.enqueue(r),t.close()}}))}Snt(jft,this,Snt(Vft,this,n)),Snt(Xft,this,i.scale*(globalThis.devicePixelRatio||1)),Snt(qft,this,i.rotation),Snt(Uft,this,{div:null,properties:null,ctx:null});var{pageWidth:a,pageHeight:s,pageX:o,pageY:l}=i.rawDims;Snt(tgt,this,[1,0,0,-1,-o,l+s]),Snt(Gft,this,a),Snt(Hft,this,s),lgt.call(rgt),Rlt(n,i),_nt(Nft,this).promise.finally((()=>{fgt._.delete(this),Snt(Uft,this,null),Snt($ft,this,null)})).catch((()=>{}))}static get fontFamilyMap(){var{isWindows:t,isFirefox:e}=nlt.platform;return Yot(this,"fontFamilyMap",new Map([["sans-serif","".concat(t&&e?"Calibri, ":"","sans-serif")],["monospace","".concat(t&&e?"Lucida Console, ":"","monospace")]]))}render(){var t=()=>{_nt(Yft,this).read().then((e=>{var r,{value:n,done:i}=e;i?_nt(Nft,this).resolve():(null!==(r=_nt(Wft,this))&&void 0!==r||Snt(Wft,this,n.lang),Object.assign(_nt($ft,this),n.styles),bnt(egt,this,ngt).call(this,n.items),t())}),_nt(Nft,this).reject)};return Snt(Yft,this,_nt(Qft,this).getReader()),fgt._.add(this),t(),_nt(Nft,this).promise}update(t){var{viewport:e,onBefore:r=null}=t,n=e.scale*(globalThis.devicePixelRatio||1),i=e.rotation;if(i!==_nt(qft,this)&&(null==r||r(),Snt(qft,this,i),Rlt(_nt(Vft,this),{rotation:i})),n!==_nt(Xft,this)){null==r||r(),Snt(Xft,this,n);var a={div:null,properties:null,ctx:sgt.call(rgt,_nt(Wft,this))};for(var s of _nt(Jft,this))a.properties=_nt(Zft,this).get(s),a.div=s,bnt(egt,this,agt).call(this,a)}}cancel(){var t,e=new Zot("TextLayer task cancelled.");null===(t=_nt(Yft,this))||void 0===t||t.cancel(e).catch((()=>{})),Snt(Yft,this,null),_nt(Nft,this).reject(e)}get textDivs(){return _nt(Jft,this)}get textContentItemsStr(){return _nt(Kft,this)}static cleanup(){if(!(bnt(rgt,this,fgt)._.size>0)){for(var{canvas:t}of(bnt(rgt,this,cgt)._.clear(),bnt(rgt,this,ugt)._.values()))t.remove();bnt(rgt,this,ugt)._.clear()}}}function ngt(t){var e,r;if(!_nt(Bft,this)){null!==(r=(e=_nt(Uft,this)).ctx)&&void 0!==r||(e.ctx=sgt.call(Pst,_nt(Wft,this)));var n=_nt(Jft,this),i=_nt(Kft,this);for(var a of t){if(n.length>1e5)return Wot("Ignoring additional textDivs for performance reasons."),void Snt(Bft,this,!0);if(void 0!==a.str)i.push(a.str),bnt(egt,this,igt).call(this,a);else if("beginMarkedContentProps"===a.type||"beginMarkedContent"===a.type){var s=_nt(jft,this);Snt(jft,this,document.createElement("span")),_nt(jft,this).classList.add("markedContent"),null!==a.id&&_nt(jft,this).setAttribute("id","".concat(a.id)),s.append(_nt(jft,this))}else"endMarkedContent"===a.type&&Snt(jft,this,_nt(jft,this).parentNode)}}}function igt(t){var e=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};_nt(Jft,this).push(e);var n=alt.transform(_nt(tgt,this),t.transform),i=Math.atan2(n[1],n[0]),a=_nt($ft,this)[t.fontName];a.vertical&&(i+=Math.PI/2);var s=_nt(zft,this)&&a.fontSubstitution||a.fontFamily;s=Pst.fontFamilyMap.get(s)||s;var o,l,h=Math.hypot(n[2],n[3]),c=h*hgt.call(Pst,s,_nt(Wft,this));0===i?(o=n[4],l=n[5]-c):(o=n[4]+c*Math.sin(i),l=n[5]-c*Math.cos(i));var u="calc(var(--scale-factor)*",d=e.style;_nt(jft,this)===_nt(Vft,this)?(d.left="".concat((100*o/_nt(Gft,this)).toFixed(2),"%"),d.top="".concat((100*l/_nt(Hft,this)).toFixed(2),"%")):(d.left="".concat(u).concat(o.toFixed(2),"px)"),d.top="".concat(u).concat(l.toFixed(2),"px)")),d.fontSize="".concat(u).concat((pgt._*h).toFixed(2),"px)"),d.fontFamily=s,r.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,_nt(zft,this)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==i&&(r.angle=i*(180/Math.PI));var p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){var f=Math.abs(t.transform[0]),g=Math.abs(t.transform[3]);f!==g&&Math.max(f,g)/Math.min(f,g)>1.5&&(p=!0)}if(p&&(r.canvasWidth=a.vertical?t.height:t.width),_nt(Zft,this).set(e,r),_nt(Uft,this).div=e,_nt(Uft,this).properties=r,bnt(egt,this,agt).call(this,_nt(Uft,this)),r.hasText&&_nt(jft,this).append(e),r.hasEOL){var v=document.createElement("br");v.setAttribute("role","presentation"),_nt(jft,this).append(v)}}function agt(t){var{div:e,properties:r,ctx:n}=t,{style:i}=e,a="";if(pgt._>1&&(a="scale(".concat(1/pgt._,")")),0!==r.canvasWidth&&r.hasText){var{fontFamily:s}=i,{canvasWidth:o,fontSize:l}=r;ogt.call(Pst,n,l*_nt(Xft,this),s);var{width:h}=n.measureText(e.textContent);h>0&&(a="scaleX(".concat(o*_nt(Xft,this)/h,") ").concat(a))}0!==r.angle&&(a="rotate(".concat(r.angle,"deg) ").concat(a)),a.length>0&&(i.transform=a)}function sgt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=bnt(Pst,this,ugt)._.get(t||(t=""));if(!e){var r=document.createElement("canvas");r.className="hiddenCanvasElement",r.lang=t,document.body.append(r),e=r.getContext("2d",{alpha:!1,willReadFrequently:!0}),bnt(Pst,this,ugt)._.set(t,e),bnt(Pst,this,dgt)._.set(e,{size:0,family:""})}return e}function ogt(t,e,r){var n=bnt(Pst,this,dgt)._.get(t);e===n.size&&r===n.family||(t.font="".concat(e,"px ").concat(r),n.size=e,n.family=r)}function lgt(){if(null===bnt(Pst,this,pgt)._){var t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),pgt._=bnt(Pst,this,t.getBoundingClientRect().height),t.remove()}}function hgt(t,e){var r=bnt(Pst,this,cgt)._.get(t);if(r)return r;var n=bnt(Pst,this,sgt).call(this,e);n.canvas.width=n.canvas.height=Fft,bnt(Pst,this,ogt).call(this,n,Fft,t);var i=n.measureText(""),a=i.fontBoundingBoxAscent,s=Math.abs(i.fontBoundingBoxDescent);if(a){var o=a/(a+s);return bnt(Pst,this,cgt)._.set(t,o),n.canvas.width=n.canvas.height=0,o}n.strokeStyle="red",n.clearRect(0,0,Fft,Fft),n.strokeText("g",0,0);var l=n.getImageData(0,0,Fft,Fft).data;s=0;for(var h=l.length-1-3;h>=0;h-=4)if(l[h]>0){s=Math.ceil(h/4/Fft);break}n.clearRect(0,0,Fft,Fft),n.strokeText("A",0,Fft),a=0;for(var c=0,u=(l=n.getImageData(0,0,Fft,Fft).data).length;c<u;c+=4)if(l[c]>0){a=Fft-Math.floor(c/4/Fft);break}n.canvas.width=n.canvas.height=0;var d=a?a/(a+s):.8;return bnt(Pst,this,cgt)._.set(t,d),d}Pst=rgt;var cgt={_:new Map},ugt={_:new Map},dgt={_:new WeakMap},pgt={_:null},fgt={_:new Set};class ggt{static textContent(t){var e=[],r={items:e,styles:Object.create(null)};return function t(r){var n;if(r){var i=null,a=r.name;if("#text"===a)i=r.value;else{if(!ggt.shouldBuildText(a))return;null!=r&&null!==(n=r.attributes)&&void 0!==n&&n.textContent?i=r.attributes.textContent:r.value&&(i=r.value)}if(null!==i&&e.push({str:i}),r.children)for(var s of r.children)t(s)}}(t),r}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}var vgt=65536,mgt=Ust?class extends Udt{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}:class extends Udt{constructor(t){var{ownerDocument:e=globalThis.document,enableHWA:r=!1}=t;super({enableHWA:r}),this._document=e}_createCanvas(t,e){var r=this._document.createElement("canvas");return r.width=t,r.height=e,r}},ygt=Ust?class extends Hdt{_fetch(t){return xnt((function*(){return fpt(t)}))()}}:Gdt,bgt=Ust?class extends Ydt{}:class extends Ydt{constructor(t){var{docId:e,ownerDocument:r=globalThis.document}=t;super(),Mnt(this,Zdt),knt(this,Vdt,void 0),knt(this,qdt,void 0),knt(this,Xdt,void 0),knt(this,$dt,void 0),knt(this,Kdt,void 0),knt(this,Qdt,void 0),knt(this,Jdt,0),Snt($dt,this,e),Snt(Kdt,this,r)}addFilter(t){var e,r;if(!t)return"none";var n=Ent(Zdt,this,tpt).get(t);if(n)return n;var[i,a,s]=bnt(Zdt,this,npt).call(this,t),o=1===t.length?i:"".concat(i).concat(a).concat(s);if(n=Ent(Zdt,this,tpt).get(o))return Ent(Zdt,this,tpt).set(t,n),n;var l="g_".concat(_nt($dt,this),"_transfer_map_").concat((Snt(Jdt,this,(e=_nt(Jdt,this),r=e++,e)),r)),h=bnt(Zdt,this,ipt).call(this,l);Ent(Zdt,this,tpt).set(t,h),Ent(Zdt,this,tpt).set(o,h);var c=bnt(Zdt,this,opt).call(this,l);return bnt(Zdt,this,hpt).call(this,i,a,s,c),h}addHCMFilter(t,e){var r,n,i="".concat(t,"-").concat(e),a="base",s=Ent(Zdt,this,ept).get(a);if((null===(r=s)||void 0===r?void 0:r.key)===i)return s.url;s?(null===(n=s.filter)||void 0===n||n.remove(),s.key=i,s.url="none",s.filter=null):(s={key:i,url:"none",filter:null},Ent(Zdt,this,ept).set(a,s));if(!t||!e)return s.url;var o=bnt(Zdt,this,upt).call(this,t);t=alt.makeHexColor(...o);var l=bnt(Zdt,this,upt).call(this,e);if(e=alt.makeHexColor(...l),Ent(Zdt,this,rpt).style.color="","#000000"===t&&"#ffffff"===e||t===e)return s.url;for(var h=new Array(256),c=0;c<=255;c++){var u=c/255;h[c]=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4)}var d=h.join(","),p="g_".concat(_nt($dt,this),"_hcm_filter"),f=s.filter=bnt(Zdt,this,opt).call(this,p);bnt(Zdt,this,hpt).call(this,d,d,d,f),bnt(Zdt,this,spt).call(this,f);var g=(t,e)=>{for(var r=o[t]/255,n=l[t]/255,i=new Array(e+1),a=0;a<=e;a++)i[a]=r+a/e*(n-r);return i.join(",")};return bnt(Zdt,this,hpt).call(this,g(0,5),g(1,5),g(2,5),f),s.url=bnt(Zdt,this,ipt).call(this,p),s.url}addAlphaFilter(t){var e,r,n=Ent(Zdt,this,tpt).get(t);if(n)return n;var[i]=bnt(Zdt,this,npt).call(this,[t]),a="alpha_".concat(i);if(n=Ent(Zdt,this,tpt).get(a))return Ent(Zdt,this,tpt).set(t,n),n;var s="g_".concat(_nt($dt,this),"_alpha_map_").concat((Snt(Jdt,this,(e=_nt(Jdt,this),r=e++,e)),r)),o=bnt(Zdt,this,ipt).call(this,s);Ent(Zdt,this,tpt).set(t,o),Ent(Zdt,this,tpt).set(a,o);var l=bnt(Zdt,this,opt).call(this,s);return bnt(Zdt,this,cpt).call(this,i,l),o}addLuminosityFilter(t){var e,r,n,i,a=Ent(Zdt,this,tpt).get(t||"luminosity");if(a)return a;if(t?([n]=bnt(Zdt,this,npt).call(this,[t]),i="luminosity_".concat(n)):i="luminosity",a=Ent(Zdt,this,tpt).get(i))return Ent(Zdt,this,tpt).set(t,a),a;var s="g_".concat(_nt($dt,this),"_luminosity_map_").concat((Snt(Jdt,this,(e=_nt(Jdt,this),r=e++,e)),r)),o=bnt(Zdt,this,ipt).call(this,s);Ent(Zdt,this,tpt).set(t,o),Ent(Zdt,this,tpt).set(i,o);var l=bnt(Zdt,this,opt).call(this,s);return bnt(Zdt,this,apt).call(this,l),t&&bnt(Zdt,this,cpt).call(this,n,l),o}addHighlightHCMFilter(t,e,r,n,i){var a,s,o="".concat(e,"-").concat(r,"-").concat(n,"-").concat(i),l=Ent(Zdt,this,ept).get(t);if((null===(a=l)||void 0===a?void 0:a.key)===o)return l.url;l?(null===(s=l.filter)||void 0===s||s.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},Ent(Zdt,this,ept).set(t,l));if(!e||!r)return l.url;var[h,c]=[e,r].map(bnt(Zdt,this,upt).bind(this)),u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[p,f]=[n,i].map(bnt(Zdt,this,upt).bind(this));d<u&&([u,d,p,f]=[d,u,f,p]),Ent(Zdt,this,rpt).style.color="";var g=(t,e,r)=>{for(var n=new Array(256),i=(d-u)/r,a=t/255,s=(e-t)/(255*r),o=0,l=0;l<=r;l++){for(var h=Math.round(u+l*i),c=a+l*s,p=o;p<=h;p++)n[p]=c;o=h+1}for(var f=o;f<256;f++)n[f]=n[o-1];return n.join(",")},v="g_".concat(_nt($dt,this),"_hcm_").concat(t,"_filter"),m=l.filter=bnt(Zdt,this,opt).call(this,v);return bnt(Zdt,this,spt).call(this,m),bnt(Zdt,this,hpt).call(this,g(p[0],f[0],5),g(p[1],f[1],5),g(p[2],f[2],5),m),l.url=bnt(Zdt,this,ipt).call(this,v),l.url}destroy(){var t,e,r,n;arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&null!==(t=_nt(Qdt,this))&&void 0!==t&&t.size||(null===(e=_nt(Xdt,this))||void 0===e||e.parentNode.parentNode.remove(),Snt(Xdt,this,null),null===(r=_nt(qdt,this))||void 0===r||r.clear(),Snt(qdt,this,null),null===(n=_nt(Qdt,this))||void 0===n||n.clear(),Snt(Qdt,this,null),Snt(Jdt,this,0))}},wgt=Ust?class extends dpt{_fetch(t){return xnt((function*(){return fpt(t)}))()}}:ppt;function xgt(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"string"==typeof r||r instanceof URL?r={url:r}:(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});var n=new _gt,{docId:i}=n,a=r.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch(e){if(Ust&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(r.url):null,s=r.data?function(t){if(Ust&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return elt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(null==t?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(r.data):null,o=r.httpHeaders||null,l=!0===r.withCredentials,h=null!==(t=r.password)&&void 0!==t?t:null,c=r.range instanceof Sgt?r.range:null,u=Number.isInteger(r.rangeChunkSize)&&r.rangeChunkSize>0?r.rangeChunkSize:vgt,d=r.worker instanceof Ngt?r.worker:null,p=r.verbosity,f="string"!=typeof r.docBaseUrl||ylt(r.docBaseUrl)?null:r.docBaseUrl,g="string"==typeof r.cMapUrl?r.cMapUrl:null,v=!1!==r.cMapPacked,m=r.CMapReaderFactory||ygt,y="string"==typeof r.standardFontDataUrl?r.standardFontDataUrl:null,b=r.StandardFontDataFactory||wgt,w=!0!==r.stopAtErrors,x=Number.isInteger(r.maxImageSize)&&r.maxImageSize>-1?r.maxImageSize:-1,A=!1!==r.isEvalSupported,_="boolean"==typeof r.isOffscreenCanvasSupported?r.isOffscreenCanvasSupported:!Ust,k="boolean"==typeof r.isImageDecoderSupported?r.isImageDecoderSupported:!Ust&&(nlt.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(r.canvasMaxAreaInBytes)?r.canvasMaxAreaInBytes:-1,E="boolean"==typeof r.disableFontFace?r.disableFontFace:Ust,M=!0===r.fontExtraProperties,T=!0===r.enableXfa,C=r.ownerDocument||globalThis.document,P=!0===r.disableRange,I=!0===r.disableStream,R=!0===r.disableAutoFetch,O=!0===r.pdfBug,L=r.CanvasFactory||mgt,D=r.FilterFactory||bgt,F=!0===r.enableHWA,N=c?c.length:null!==(e=r.length)&&void 0!==e?e:NaN,j="boolean"==typeof r.useSystemFonts?r.useSystemFonts:!Ust&&!E,B="boolean"==typeof r.useWorkerFetch?r.useWorkerFetch:m===Gdt&&b===ppt&&g&&y&&_lt(g,document.baseURI)&&_lt(y,document.baseURI);jot(p);var z={canvasFactory:new L({ownerDocument:C,enableHWA:F}),filterFactory:new D({docId:i,ownerDocument:C}),cMapReaderFactory:B?null:new m({baseUrl:g,isCompressed:v}),standardFontDataFactory:B?null:new b({baseUrl:y})};if(!d){var W={verbosity:p,port:$pt.workerPort};d=W.port?Ngt.fromPort(W):new Ngt(W),n._worker=d}var U={docId:i,apiVersion:"4.10.38",data:s,password:h,disableAutoFetch:R,rangeChunkSize:u,length:N,docBaseUrl:f,enableXfa:T,evaluatorOptions:{maxImageSize:x,disableFontFace:E,ignoreErrors:w,isEvalSupported:A,isOffscreenCanvasSupported:_,isImageDecoderSupported:k,canvasMaxAreaInBytes:S,fontExtraProperties:M,useSystemFonts:j,cMapUrl:B?g:null,standardFontDataUrl:B?y:null}},H={disableFontFace:E,fontExtraProperties:M,ownerDocument:C,pdfBug:O,styleElement:null,loadingParams:{disableAutoFetch:R,enableXfa:T}};return d.promise.then((function(){if(n.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");var t,e=d.messageHandler.sendWithPromise("GetDocRequest",U,s?[s.buffer]:null);if(c)t=new fft(c,{disableRange:P,disableStream:I});else if(!s){if(!a)throw new Error("getDocument - no `url` parameter provided.");var r;if(Ust)if(_lt(a)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");r=Sft}else r=Oft;else r=_lt(a)?Sft:Cft;t=new r({url:a,length:N,httpHeaders:o,withCredentials:l,rangeChunkSize:u,disableRange:P,disableStream:I})}return e.then((e=>{if(n.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");var r=new Ddt(i,e,d.port),a=new $gt(r,n,t,H,z);n._transport=a,r.send("Ready",null)}))})).catch(n._capability.reject),n}function Agt(t){return"object"==typeof t&&Number.isInteger(null==t?void 0:t.num)&&t.num>=0&&Number.isInteger(null==t?void 0:t.gen)&&t.gen>=0}class _gt{constructor(){var t,e;this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d".concat((kgt._=(t=kgt._,e=t++,t),e)),this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){var t=this;return xnt((function*(){var e;t.destroyed=!0;try{var r,n;null!==(r=t._worker)&&void 0!==r&&r.port&&(t._worker._pendingDestroy=!0),yield null===(n=t._transport)||void 0===n?void 0:n.destroy()}catch(e){var i;throw null!==(i=t._worker)&&void 0!==i&&i.port&&delete t._worker._pendingDestroy,e}t._transport=null,null===(e=t._worker)||void 0===e||e.destroy(),t._worker=null}))()}}var kgt={_:0};class Sgt{constructor(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;this.length=t,this.initialData=e,this.progressiveDone=r,this.contentDispositionFilename=n,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(var r of this._rangeListeners)r(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(var r of this._progressListeners)r(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(var e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(var t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Uot("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Egt{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Yot(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){var{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Mgt=new WeakMap,Tgt=new WeakMap,Cgt=new WeakSet;class Pgt{constructor(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Mnt(this,Cgt),knt(this,Mgt,null),knt(this,Tgt,!1),this._pageIndex=t,this._pageInfo=e,this._transport=r,this._stats=n?new Alt:null,this._pdfBug=n,this.commonObjs=r.commonObjs,this.objs=new tvt,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport(){var{scale:t,rotation:e=this.rotate,offsetX:r=0,offsetY:n=0,dontFlip:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new vlt({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:r,offsetY:n,dontFlip:i})}getAnnotations(){var{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Yot(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){var t=this;return xnt((function*(){var e;return(null===(e=t._transport._htmlForXfa)||void 0===e?void 0:e.children[t._pageIndex])||null}))()}render(t){var e,r,{canvasContext:n,viewport:i,intent:a="display",annotationMode:s=tot.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:h=null,annotationCanvasMap:c=null,pageColors:u=null,printAnnotationStorage:d=null,isEditing:p=!1}=t;null===(e=this._stats)||void 0===e||e.time("Overall");var f=this._transport.getRenderingIntent(a,s,d,p),{renderingIntent:g,cacheKey:v}=f;Snt(Tgt,this,!1),bnt(Cgt,this,Rgt).call(this),h||(h=this._transport.getOptionalContentConfig(g));var m=this._intentStates.get(v);m||(m=Object.create(null),this._intentStates.set(v,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);var y,b=!!(g&Xst);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null===(y=this._stats)||void 0===y||y.time("Page Request"),this._pumpOperatorList(f));var w=t=>{var e;(m.renderTasks.delete(x),(this._maybeCleanupAfterRender||b)&&Snt(Tgt,this,!0),bnt(Cgt,this,Igt).call(this,!b),t?(x.capability.reject(t),this._abortOperatorList({intentState:m,reason:t instanceof Error?t:new Error(t)})):x.capability.resolve(),this._stats)&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),null!==(e=globalThis.Stats)&&void 0!==e&&e.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},x=new avt({callback:w,params:{canvasContext:n,viewport:i,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:u});((r=m).renderTasks||(r.renderTasks=new Set)).add(x);var A=x.task;return Promise.all([m.displayReadyCapability.promise,h]).then((t=>{var e,[r,n]=t;if(this.destroyed)w();else{if(null===(e=this._stats)||void 0===e||e.time("Rendering"),!(n.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");x.initializeGraphics({transparency:r,optionalContentConfig:n}),x.operatorListChanged()}})).catch(w),A}getOperatorList(){var{intent:t="display",annotationMode:e=tot.ENABLE,printAnnotationStorage:r=null,isEditing:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var i,a,s,o=this._transport.getRenderingIntent(t,e,r,n,!0),l=this._intentStates.get(o.cacheKey);(l||(l=Object.create(null),this._intentStates.set(o.cacheKey,l)),l.opListReadCapability)||((i=Object.create(null)).operatorListChanged=function(){l.operatorList.lastChunk&&(l.opListReadCapability.resolve(l.operatorList),l.renderTasks.delete(i))},l.opListReadCapability=Promise.withResolvers(),((a=l).renderTasks||(a.renderTasks=new Set)).add(i),l.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null===(s=this._stats)||void 0===s||s.time("Page Request"),this._pumpOperatorList(o));return l.opListReadCapability.promise}streamTextContent(){var{includeMarkedContent:t=!1,disableNormalization:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._transport._htmlForXfa)return this.getXfa().then((t=>ggt.textContent(t)));var e=this.streamTextContent(t);return new Promise((function(t,r){var n=e.getReader(),i={items:[],styles:Object.create(null),lang:null};!function e(){n.read().then((function(r){var n,{value:a,done:s}=r;s?t(i):(null!==(n=i.lang)&&void 0!==n||(i.lang=a.lang),Object.assign(i.styles,a.styles),i.items.push(...a.items),e())}),r)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;var t=[];for(var e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(var r of e.renderTasks)t.push(r.completed),r.cancel();return this.objs.clear(),Snt(Tgt,this,!1),bnt(Cgt,this,Rgt).call(this),Promise.all(t)}cleanup(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Snt(Tgt,this,!0);var e=bnt(Cgt,this,Igt).call(this,!1);return t&&e&&this._stats&&(this._stats=new Alt),e}_startRenderPage(t,e){var r,n,i=this._intentStates.get(e);i&&(null===(r=this._stats)||void 0===r||r.timeEnd("Page Request"),null===(n=i.displayReadyCapability)||void 0===n||n.resolve(t))}_renderPageChunk(t,e){for(var r=0,n=t.length;r<n;r++)e.operatorList.fnArray.push(t.fnArray[r]),e.operatorList.argsArray.push(t.argsArray[r]);for(var i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&bnt(Cgt,this,Igt).call(this,!0)}_pumpOperatorList(t){var{renderingIntent:e,cacheKey:r,annotationStorageSerializable:n,modifiedIds:i}=t,{map:a,transfer:s}=n,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:r,annotationStorage:a,modifiedIds:i},s).getReader(),l=this._intentStates.get(r);l.streamReader=o;var h=()=>{o.read().then((t=>{var{value:e,done:r}=t;r?l.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,l),h())}),(t=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){for(var e of(l.operatorList.lastChunk=!0,l.renderTasks))e.operatorListChanged();bnt(Cgt,this,Igt).call(this,!0)}if(l.displayReadyCapability)l.displayReadyCapability.reject(t);else{if(!l.opListReadCapability)throw t;l.opListReadCapability.reject(t)}}}))};h()}_abortOperatorList(t){var{intentState:e,reason:r,force:n=!1}=t;if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(r instanceof mlt){var i=100;return r.extraDelay>0&&r.extraDelay<1e3&&(i+=r.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:r,force:!0})}),i))}}if(e.streamReader.cancel(new Zot(r.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(var[a,s]of this._intentStates)if(s===e){this._intentStates.delete(a);break}this.cleanup()}}}get stats(){return this._stats}}function Igt(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(bnt(Cgt,this,Rgt).call(this),!_nt(Tgt,this)||this.destroyed)return!1;if(t)return Snt(Mgt,this,setTimeout((()=>{Snt(Mgt,this,null),bnt(Cgt,this,Igt).call(this,!1)}),5e3)),!1;for(var{renderTasks:e,operatorList:r}of this._intentStates.values())if(e.size>0||!r.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),Snt(Tgt,this,!1),!0}function Rgt(){_nt(Mgt,this)&&(clearTimeout(_nt(Mgt,this)),Snt(Mgt,this,null))}var Ogt=new WeakMap,Lgt=new WeakMap;class Dgt{constructor(){knt(this,Ogt,new Map),knt(this,Lgt,Promise.resolve())}postMessage(t,e){var r={data:structuredClone(t,e?{transfer:e}:null)};_nt(Lgt,this).then((()=>{for(var[t]of _nt(Ogt,this))t.call(this,r)}))}addEventListener(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=null;if((null==r?void 0:r.signal)instanceof AbortSignal){var{signal:i}=r;if(i.aborted)return void Wot("LoopbackPort - cannot use an `aborted` signal.");var a=()=>this.removeEventListener(t,e);n=()=>i.removeEventListener("abort",a),i.addEventListener("abort",a)}_nt(Ogt,this).set(e,n)}removeEventListener(t,e){var r=_nt(Ogt,this).get(e);null==r||r(),_nt(Ogt,this).delete(e)}terminate(){for(var[,t]of _nt(Ogt,this))null==t||t();_nt(Ogt,this).clear()}}var Fgt=new WeakSet;class Ngt{constructor(){var{name:t=null,port:e=null,verbosity:r=Bot()}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Mnt(this,Fgt),this.name=t,this.destroyed=!1,this.verbosity=r,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){var n;if(null!==(n=Ugt._)&&void 0!==n&&n.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(Ugt._||(Ugt._=new WeakMap)).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Ddt("main","worker",t),this._messageHandler.on("ready",(function(){})),bnt(Fgt,this,jgt).call(this)}_initialize(){if(Wgt._||Bgt(Ngt))this._setupFakeWorker();else{var{workerSrc:t}=Ngt;try{Ngt._isSameOrigin(window.location.href,t)||(t=Ngt._createCDNWrapper(new URL(t,window.location).href));var e=new Worker(t,{type:"module"}),r=new Ddt("main","worker",e),n=()=>{i.abort(),r.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},i=new AbortController;e.addEventListener("error",(()=>{this._webWorker||n()}),{signal:i.signal}),r.on("test",(t=>{i.abort(),!this.destroyed&&t?(this._messageHandler=r,this._port=e,this._webWorker=e,bnt(Fgt,this,jgt).call(this)):n()})),r.on("ready",(t=>{if(i.abort(),this.destroyed)n();else try{a()}catch(t){this._setupFakeWorker()}}));var a=()=>{var t=new Uint8Array;r.send("test",t,[t.buffer])};return void a()}catch(t){zot("The worker has been disabled.")}this._setupFakeWorker()}}_setupFakeWorker(){Wgt._||(Wot("Setting up fake worker."),Wgt._=!0),Ngt._setupFakeWorkerGlobal.then((t=>{var e,r;if(this.destroyed)this._readyCapability.reject(new Error("Worker was destroyed"));else{var n=new Dgt;this._port=n;var i="fake".concat((zgt._=(e=zgt._,r=e++,e),r)),a=new Ddt(i+"_worker",i,n);t.setup(a,n),this._messageHandler=new Ddt(i,i+"_worker",n),bnt(Fgt,this,jgt).call(this)}})).catch((t=>{this._readyCapability.reject(new Error('Setting up fake worker failed: "'.concat(t.message,'".')))}))}destroy(){var t,e,r;this.destroyed=!0,null===(t=this._webWorker)||void 0===t||t.terminate(),this._webWorker=null,null===(e=Ugt._)||void 0===e||e.delete(this._port),this._port=null,null===(r=this._messageHandler)||void 0===r||r.destroy(),this._messageHandler=null}static fromPort(t){var e;if(null==t||!t.port)throw new Error("PDFWorker.fromPort - invalid method signature.");var r=null===(e=bnt(Ngt,this,Ugt)._)||void 0===e?void 0:e.get(t.port);if(r){if(r._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return r}return new Ngt(t)}static get workerSrc(){if($pt.workerSrc)return $pt.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){var t=this,e=function(){var e=xnt((function*(){return Ent(Ngt,t,Bgt)?Ent(Ngt,t,Bgt):(yield import(t.workerSrc)).WorkerMessageHandler}));return function(){return e.apply(this,arguments)}}();return Yot(this,"_setupFakeWorkerGlobal",e())}}function jgt(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}function Bgt(t){try{var e;return(null===(e=globalThis.pdfjsWorker)||void 0===e?void 0:e.WorkerMessageHandler)||null}catch(t){return null}}Ist=Ngt;var zgt={_:0},Wgt={_:!1},Ugt={_:void 0};Ust&&(Wgt._=bnt(Ist,Ist,!0),$pt.workerSrc||($pt.workerSrc="./pdf.worker.mjs")),Ist._isSameOrigin=(t,e)=>{var r;try{if(!(r=new URL(t)).origin||"null"===r.origin)return!1}catch(t){return!1}var n=new URL(e,r);return r.origin===n.origin},Ist._createCDNWrapper=t=>{var e='await import("'.concat(t,'");');return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};var Hgt=new WeakMap,Ggt=new WeakMap,Ygt=new WeakMap,Vgt=new WeakMap,qgt=new WeakMap,Xgt=new WeakSet;class $gt{constructor(t,e,r,n,i){Mnt(this,Xgt),knt(this,Hgt,new Map),knt(this,Ggt,new Map),knt(this,Ygt,new Map),knt(this,Vgt,new Map),knt(this,qgt,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new tvt,this.fontLoader=new bdt({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=r,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return Yot(this,"annotationStorage",new fdt)}getRenderingIntent(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tot.ENABLE,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=qst,s=hdt;switch(t){case"any":a=Vst;break;case"display":break;case"print":a=Xst;break;default:Wot("getRenderingIntent - invalid intent: ".concat(t))}var o=a&Xst&&r instanceof mdt?r:this.annotationStorage;switch(e){case tot.DISABLE:a+=Qst;break;case tot.ENABLE:break;case tot.ENABLE_FORMS:a+=$st;break;case tot.ENABLE_STORAGE:a+=Kst,s=o.serializable;break;default:Wot("getRenderingIntent - invalid annotationMode: ".concat(e))}n&&(a+=Jst),i&&(a+=Zst);var{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,s.hash,h].join("_"),annotationStorageSerializable:s,modifiedIds:l}}destroy(){var t;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null===(t=_nt(qgt,this))||void 0===t||t.reject(new Error("Worker was destroyed during onPassword callback"));var e=[];for(var r of _nt(Ggt,this).values())e.push(r._destroy());_nt(Ggt,this).clear(),_nt(Ygt,this).clear(),_nt(Vgt,this).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();var n=this.messageHandler.sendWithPromise("Terminate",null);return e.push(n),Promise.all(e).then((()=>{var t,e;this.commonObjs.clear(),this.fontLoader.clear(),_nt(Hgt,this).clear(),this.filterFactory.destroy(),rgt.cleanup(),null===(t=this._networkStream)||void 0===t||t.cancelAllRequests(new Zot("Worker was terminated.")),null===(e=this.messageHandler)||void 0===e||e.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){var t=this,{messageHandler:e,loadingTask:r}=this;e.on("GetReader",((t,e)=>{Hot(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function(t){var{value:r,done:n}=t;n?e.close():(Hot(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),e.on("ReaderHeadersReady",function(){var e=xnt((function*(e){yield t._fullReader.headersReady;var{isStreamingSupported:n,isRangeSupported:i,contentLength:a}=t._fullReader;if(!n||!i){var s;if(t._lastProgress)null===(s=r.onProgress)||void 0===s||s.call(r,t._lastProgress);t._fullReader.onProgress=t=>{var e;null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.loaded,total:t.total})}}return{isStreamingSupported:n,isRangeSupported:i,contentLength:a}}));return function(t){return e.apply(this,arguments)}}()),e.on("GetRangeReader",((t,e)=>{Hot(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");var r=this._networkStream.getRangeReader(t.begin,t.end);r?(e.onPull=()=>{r.read().then((function(t){var{value:r,done:n}=t;n?e.close():(Hot(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{r.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),e.on("GetDoc",(t=>{var{pdfInfo:e}=t;this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,r._capability.resolve(new Egt(e,this))})),e.on("DocException",(t=>{r._capability.reject(Rdt(t))})),e.on("PasswordRequest",(t=>{Snt(qgt,this,Promise.withResolvers());try{if(!r.onPassword)throw Rdt(t);r.onPassword((t=>{t instanceof Error?_nt(qgt,this).reject(t):_nt(qgt,this).resolve({password:t})}),t.code)}catch(t){_nt(qgt,this).reject(t)}return _nt(qgt,this).promise})),e.on("DataLoaded",(t=>{var e;null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),e.on("StartRenderPage",(t=>{this.destroyed||_nt(Ggt,this).get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),e.on("commonobj",(t=>{var r,[n,i,a]=t;if(this.destroyed)return null;if(this.commonObjs.has(n))return null;switch(i){case"Font":var{disableFontFace:s,fontExtraProperties:o,pdfBug:l}=this._params;if("error"in a){var h=a.error;Wot("Error during font loading: ".concat(h)),this.commonObjs.resolve(n,h);break}var c=l&&null!==(r=globalThis.FontInspector)&&void 0!==r&&r.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,u=new wdt(a,{disableFontFace:s,fontExtraProperties:o,inspectFont:c});this.fontLoader.bind(u).catch((()=>e.sendWithPromise("FontFallback",{id:n}))).finally((()=>{!o&&u.data&&(u.data=null),this.commonObjs.resolve(n,u)}));break;case"CopyLocalImage":var{imageRef:d}=a;for(var p of(Hot(d,"The imageRef must be defined."),_nt(Ggt,this).values()))for(var[,f]of p.objs)if((null==f?void 0:f.ref)===d)return f.dataLen?(this.commonObjs.resolve(n,structuredClone(f)),f.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,a);break;default:throw new Error("Got unknown common object type ".concat(i))}return null})),e.on("obj",(t=>{var[e,r,n,i]=t;if(!this.destroyed){var a,s=_nt(Ggt,this).get(r);if(!s.objs.has(e))if(0!==s._intentStates.size)switch(n){case"Image":s.objs.resolve(e,i),(null==i?void 0:i.dataLen)>1e7&&(s._maybeCleanupAfterRender=!0);break;case"Pattern":s.objs.resolve(e,i);break;default:throw new Error("Got unknown object type ".concat(n))}else null==i||null===(a=i.bitmap)||void 0===a||a.close()}})),e.on("DocProgress",(t=>{var e;this.destroyed||null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.loaded,total:t.total})})),e.on("FetchBuiltInCMap",function(){var e=xnt((function*(e){if(t.destroyed)throw new Error("Worker was destroyed.");if(!t.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return t.cMapReaderFactory.fetch(e)}));return function(t){return e.apply(this,arguments)}}()),e.on("FetchStandardFontData",function(){var e=xnt((function*(e){if(t.destroyed)throw new Error("Worker was destroyed.");if(!t.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return t.standardFontDataFactory.fetch(e)}));return function(t){return e.apply(this,arguments)}}())}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var t,e;this.annotationStorage.size<=0&&Wot("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");var{map:r,transfer:n}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:r,filename:null!==(t=null===(e=this._fullReader)||void 0===e?void 0:e.filename)&&void 0!==t?t:null},n).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));var e=t-1,r=_nt(Ygt,this).get(e);if(r)return r;var n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&_nt(Vgt,this).set(r.refStr,t);var n=new Pgt(e,r,this,this._params.pdfBug);return _nt(Ggt,this).set(e,n),n}));return _nt(Ygt,this).set(e,n),n}getPageIndex(t){return Agt(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return bnt(Xgt,this,Kgt).call(this,"GetFieldObjects")}hasJSActions(){return bnt(Xgt,this,Kgt).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return bnt(Xgt,this,Kgt).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return bnt(Xgt,this,Kgt).call(this,"GetOptionalContentConfig").then((e=>new dft(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){var t="GetMetadata",e=_nt(Hgt,this).get(t);if(e)return e;var r=this.messageHandler.sendWithPromise(t,null).then((t=>{var e,r,n,i;return{info:t[0],metadata:t[1]?new tft(t[1]):null,contentDispositionFilename:null!==(e=null===(r=this._fullReader)||void 0===r?void 0:r.filename)&&void 0!==e?e:null,contentLength:null!==(n=null===(i=this._fullReader)||void 0===i?void 0:i.contentLength)&&void 0!==n?n:null}}));return _nt(Hgt,this).set(t,r),r}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(){var t=arguments,e=this;return xnt((function*(){var r=t.length>0&&void 0!==t[0]&&t[0];if(!e.destroyed){for(var n of(yield e.messageHandler.sendWithPromise("Cleanup",null),_nt(Ggt,e).values())){if(!n.cleanup())throw new Error("startCleanup: Page ".concat(n.pageNumber," is currently rendering."))}e.commonObjs.clear(),r||e.fontLoader.clear(),_nt(Hgt,e).clear(),e.filterFactory.destroy(!0),rgt.cleanup()}}))()}cachedPageNumber(t){var e;if(!Agt(t))return null;var r=0===t.gen?"".concat(t.num,"R"):"".concat(t.num,"R").concat(t.gen);return null!==(e=_nt(Vgt,this).get(r))&&void 0!==e?e:null}}function Kgt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=_nt(Hgt,this).get(t);if(r)return r;var n=this.messageHandler.sendWithPromise(t,e);return _nt(Hgt,this).set(t,n),n}var Qgt=Symbol("INITIAL_DATA"),Jgt=new WeakMap,Zgt=new WeakSet;class tvt{constructor(){Mnt(this,Zgt),knt(this,Jgt,Object.create(null))}get(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e){var r=bnt(Zgt,this,evt).call(this,t);return r.promise.then((()=>e(r.data))),null}var n=_nt(Jgt,this)[t];if(!n||n.data===Qgt)throw new Error("Requesting object that isn't resolved yet ".concat(t,"."));return n.data}has(t){var e=_nt(Jgt,this)[t];return!!e&&e.data!==Qgt}delete(t){var e=_nt(Jgt,this)[t];return!(!e||e.data===Qgt)&&(delete _nt(Jgt,this)[t],!0)}resolve(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=bnt(Zgt,this,evt).call(this,t);r.data=e,r.resolve()}clear(){for(var t in _nt(Jgt,this)){var e,{data:r}=_nt(Jgt,this)[t];null==r||null===(e=r.bitmap)||void 0===e||e.close()}Snt(Jgt,this,Object.create(null))}*[Symbol.iterator](){for(var t in _nt(Jgt,this)){var{data:e}=_nt(Jgt,this)[t];e!==Qgt&&(yield[t,e])}}}function evt(t){var e;return(e=_nt(Jgt,this))[t]||(e[t]=Pnt(Pnt({},Promise.withResolvers()),{},{data:Qgt}))}var rvt=new WeakMap;class nvt{constructor(t){knt(this,rvt,null),Snt(rvt,this,t),this.onContinue=null}get promise(){return _nt(rvt,this).capability.promise}cancel(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;_nt(rvt,this).cancel(null,t)}get separateAnnots(){var{separateAnnots:t}=_nt(rvt,this).operatorList;if(!t)return!1;var{annotationCanvasMap:e}=_nt(rvt,this);return t.form||t.canvas&&(null==e?void 0:e.size)>0}}var ivt=new WeakMap;class avt{constructor(t){var{callback:e,params:r,objs:n,commonObjs:i,annotationCanvasMap:a,operatorList:s,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:u=!1,pageColors:d=null}=t;knt(this,ivt,null),this.callback=e,this.params=r,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=s,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===c&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new nvt(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=r.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics(t){var e,r,{transparency:n=!1,optionalContentConfig:i}=t;if(!this.cancelled){if(this._canvas){if(svt._.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");svt._.add(this._canvas)}this._pdfBug&&null!==(e=globalThis.StepperManager)&&void 0!==e&&e.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());var{canvasContext:a,viewport:s,transform:o,background:l}=this.params;this.gfx=new Gpt(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:i},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:o,viewport:s,transparency:n,background:l}),this.operatorListIdx=0,this.graphicsReady=!0,null===(r=this.graphicsReadyCallback)||void 0===r||r.call(this)}}cancel(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.running=!1,this.cancelled=!0,null===(t=this.gfx)||void 0===t||t.endDrawing(),_nt(ivt,this)&&(window.cancelAnimationFrame(_nt(ivt,this)),Snt(ivt,this,null)),svt._.delete(this._canvas),this.callback(e||new mlt("Rendering cancelled, page ".concat(this._pageIndex+1),r))}operatorListChanged(){var t;this.graphicsReady?(null===(t=this.stepper)||void 0===t||t.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?Snt(ivt,this,window.requestAnimationFrame((()=>{Snt(ivt,this,null),this._nextBound().catch(this._cancelBound)}))):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){var t=this;return xnt((function*(){t.cancelled||(t.operatorListIdx=t.gfx.executeOperatorList(t.operatorList,t.operatorListIdx,t._continueBound,t.stepper),t.operatorListIdx===t.operatorList.argsArray.length&&(t.running=!1,t.operatorList.lastChunk&&(t.gfx.endDrawing(),svt._.delete(t._canvas),t.callback())))}))()}}var svt={_:new WeakSet},ovt="4.10.38",lvt="f9bea397f";function hvt(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function cvt(t){return Math.max(0,Math.min(255,255*t))}class uvt{static CMYK_G(t){var[e,r,n,i]=t;return["G",1-Math.min(1,.3*e+.59*n+.11*r+i)]}static G_CMYK(t){var[e]=t;return["CMYK",0,0,0,1-e]}static G_RGB(t){var[e]=t;return["RGB",e,e,e]}static G_rgb(t){var[e]=t;return[e=cvt(e),e,e]}static G_HTML(t){var[e]=t,r=hvt(e);return"#".concat(r).concat(r).concat(r)}static RGB_G(t){var[e,r,n]=t;return["G",.3*e+.59*r+.11*n]}static RGB_rgb(t){return t.map(cvt)}static RGB_HTML(t){return"#".concat(t.map(hvt).join(""))}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB(t){var[e,r,n,i]=t;return["RGB",1-Math.min(1,e+i),1-Math.min(1,n+i),1-Math.min(1,r+i)]}static CMYK_rgb(t){var[e,r,n,i]=t;return[cvt(1-Math.min(1,e+i)),cvt(1-Math.min(1,n+i)),cvt(1-Math.min(1,r+i))]}static CMYK_HTML(t){var e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK(t){var[e,r,n]=t,i=1-e,a=1-r,s=1-n;return["CMYK",i,a,s,Math.min(i,a,s)]}}class dvt{create(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");var n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),r||(n.setAttribute("width","".concat(t,"px")),n.setAttribute("height","".concat(e,"px"))),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox","0 0 ".concat(t," ").concat(e)),n}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Uot("Abstract method `_createSVG` called.")}}class pvt extends dvt{_createSVG(t){return document.createElementNS(dlt,t)}}class fvt{static setupStorage(t,e,r,n,i){var a=n.getValue(e,{value:null});switch(r.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===i)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===r.attributes.type||"checkbox"===r.attributes.type){if(a.value===r.attributes.xfaOn?t.setAttribute("checked",!0):a.value===r.attributes.xfaOff&&t.removeAttribute("checked"),"print"===i)break;t.addEventListener("change",(t=>{n.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===i)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value)for(var s of(t.setAttribute("value",a.value),r.children))s.attributes.value===a.value?s.attributes.selected=!0:s.attributes.hasOwnProperty("selected")&&delete s.attributes.selected;t.addEventListener("input",(t=>{var r=t.target.options,i=-1===r.selectedIndex?"":r[r.selectedIndex].value;n.setValue(e,{value:i})}))}}static setAttributes(t){var{html:e,element:r,storage:n=null,intent:i,linkService:a}=t,{attributes:s}=r,o=e instanceof HTMLAnchorElement;for(var[l,h]of("radio"===s.type&&(s.name="".concat(s.name,"-").concat(i)),Object.entries(s)))if(null!=h)switch(l){case"class":h.length&&e.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",h);break;case"style":Object.assign(e.style,h);break;case"textContent":e.textContent=h;break;default:(!o||"href"!==l&&"newWindow"!==l)&&e.setAttribute(l,h)}o&&a.addLinkAttributes(e,s.href,s.newWindow),n&&s.dataId&&this.setupStorage(e,s.dataId,r,n)}static render(t){var e=t.annotationStorage,r=t.linkService,n=t.xfaHtml,i=t.intent||"display",a=document.createElement(n.name);n.attributes&&this.setAttributes({html:a,element:n,intent:i,linkService:r});var s="richText"!==i,o=t.div;if(o.append(a),t.viewport){var l="matrix(".concat(t.viewport.transform.join(","),")");o.style.transform=l}s&&o.setAttribute("class","xfaLayer xfaFont");var h=[];if(0===n.children.length){if(n.value){var c=document.createTextNode(n.value);a.append(c),s&&ggt.shouldBuildText(n.name)&&h.push(c)}return{textDivs:h}}for(var u=[[n,-1,a]];u.length>0;){var d,p,[f,g,v]=u.at(-1);if(g+1!==f.children.length){var m=f.children[++u.at(-1)[1]];if(null!==m){var{name:y}=m;if("#text"!==y){var b=null!=m&&null!==(d=m.attributes)&&void 0!==d&&d.xmlns?document.createElementNS(m.attributes.xmlns,y):document.createElement(y);if(v.append(b),m.attributes&&this.setAttributes({html:b,element:m,storage:e,intent:i,linkService:r}),(null===(p=m.children)||void 0===p?void 0:p.length)>0)u.push([m,-1,b]);else if(m.value){var w=document.createTextNode(m.value);s&&ggt.shouldBuildText(y)&&h.push(w),b.append(w)}}else{var x=document.createTextNode(m.value);h.push(x),v.append(x)}}}else u.pop()}for(var A of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))A.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){var e="matrix(".concat(t.viewport.transform.join(","),")");t.div.style.transform=e,t.div.hidden=!1}}var gvt=1e3,vvt=new WeakSet;function mvt(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class yvt{static create(t){switch(t.data.annotationType){case dot:return new Evt(t);case uot:return new Pvt(t);case Tot:switch(t.data.fieldType){case"Tx":return new Rvt(t);case"Btn":return t.data.radioButton?new Dvt(t):t.data.checkBox?new Lvt(t):new Fvt(t);case"Ch":return new Nvt(t);case"Sig":return new Ovt(t)}return new Ivt(t);case Eot:return new jvt(t);case pot:return new gmt(t);case fot:return new mmt(t);case got:return new bmt(t);case vot:return new xmt(t);case yot:return new _mt(t);case kot:return new Smt(t);case Sot:return new Cmt(t);case mot:return new kmt(t);case bot:return new Imt(t);case wot:return new Rmt(t);case xot:return new Omt(t);case Aot:return new Lmt(t);case _ot:return new Dmt(t);case Mot:return new jmt(t);default:return new _vt(t)}}}var bvt=new WeakMap,wvt=new WeakMap,xvt=new WeakMap,Avt=new WeakSet;class _vt{constructor(t){var{isRenderable:e=!1,ignoreBorder:r=!1,createQuadrilaterals:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Mnt(this,Avt),knt(this,bvt,null),knt(this,wvt,!1),knt(this,xvt,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(r)),n&&this._createQuadrilaterals()}static _hasPopupData(t){var{titleObj:e,contentsObj:r,richText:n}=t;return!!(null!=e&&e.str||null!=r&&r.str||null!=n&&n.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return _vt._hasPopupData(this.data)}updateEdited(t){var e;if(this.container){_nt(bvt,this)||Snt(bvt,this,{rect:this.data.rect.slice(0)});var{rect:r}=t;r&&bnt(Avt,this,kvt).call(this,r),null===(e=_nt(xvt,this))||void 0===e||e.popup.updateEdited(t)}}resetEdited(){var t;_nt(bvt,this)&&(bnt(Avt,this,kvt).call(this,_nt(bvt,this).rect),null===(t=_nt(xvt,this))||void 0===t||t.popup.resetEdited(),Snt(bvt,this,null))}_createContainer(t){var{data:e,parent:{page:r,viewport:n}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",e.id),this instanceof Ivt||(i.tabIndex=gvt);var{style:a}=i;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(i.title=e.alternativeText),e.noRotate&&i.classList.add("norotate"),!e.rect||this instanceof jvt){var{rotation:s}=e;return e.hasOwnCanvas||0===s||this.setRotation(s,i),i}var{width:o,height:l}=mvt(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth="".concat(e.borderStyle.width,"px");var h=e.borderStyle.horizontalCornerRadius,c=e.borderStyle.verticalCornerRadius;if(h>0||c>0){var u="calc(".concat(h,"px * var(--scale-factor)) / calc(").concat(c,"px * var(--scale-factor))");a.borderRadius=u}else if(this instanceof Dvt){var d="calc(".concat(o,"px * var(--scale-factor)) / calc(").concat(l,"px * var(--scale-factor))");a.borderRadius=d}switch(e.borderStyle.style){case Cot:a.borderStyle="solid";break;case Pot:a.borderStyle="dashed";break;case Iot:Wot("Unimplemented border style: beveled");break;case Rot:Wot("Unimplemented border style: inset");break;case Oot:a.borderBottomStyle="solid"}var p=e.borderColor||null;p?(Snt(wvt,this,!0),a.borderColor=alt.makeHexColor(0|p[0],0|p[1],0|p[2])):a.borderWidth=0}var f=alt.normalizeRect([e.rect[0],r.view[3]-e.rect[1]+r.view[1],e.rect[2],r.view[3]-e.rect[3]+r.view[1]]),{pageWidth:g,pageHeight:v,pageX:m,pageY:y}=n.rawDims;a.left="".concat(100*(f[0]-m)/g,"%"),a.top="".concat(100*(f[1]-y)/v,"%");var{rotation:b}=e;return e.hasOwnCanvas||0===b?(a.width="".concat(100*o/g,"%"),a.height="".concat(100*l/v,"%")):this.setRotation(b,i),i}setRotation(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.container;if(this.data.rect){var r,n,{pageWidth:i,pageHeight:a}=this.parent.viewport.rawDims,{width:s,height:o}=mvt(this.data.rect);t%180==0?(r=100*s/i,n=100*o/a):(r=100*o/i,n=100*s/a),e.style.width="".concat(r,"%"),e.style.height="".concat(n,"%"),e.setAttribute("data-main-rotation",(360-t)%360)}}get _commonActions(){var t=(t,e,r)=>{var n=r.detail[t],i=n[0],a=n.slice(1);r.target.style[e]=uvt["".concat(i,"_HTML")](a),this.annotationStorage.setValue(this.data.id,{[e]:uvt["".concat(i,"_rgb")](a)})};return Yot(this,"_commonActions",{display:t=>{var{display:e}=t.detail,r=e%2==1;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:r,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{var{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{var e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){var r=this._commonActions;for(var n of Object.keys(e.detail)){var i=t[n]||r[n];null==i||i(e)}}_setDefaultPropertiesFromJS(t){if(this.enableScripting){var e=this.annotationStorage.getRawValue(this.data.id);if(e){var r=this._commonActions;for(var[n,i]of Object.entries(e)){var a=r[n];if(a)a({detail:{[n]:i},target:t}),delete e[n]}}}}_createQuadrilaterals(){if(this.container){var{quadPoints:t}=this.data;if(t){var[e,r,n,i]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){var[a,s,o,l]=t.subarray(2,6);if(n===a&&i===s&&e===o&&r===l)return}var h,{style:c}=this.container;if(_nt(wvt,this)){var{borderColor:u,borderWidth:d}=c;c.borderWidth=0,h=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">','<g fill="transparent" stroke="'.concat(u,'" stroke-width="').concat(d,'">')],this.container.classList.add("hasBorder")}var p=n-e,f=i-r,{svgFactory:g}=this,v=g.createElement("svg");v.classList.add("quadrilateralsContainer"),v.setAttribute("width",0),v.setAttribute("height",0);var m=g.createElement("defs");v.append(m);var y=g.createElement("clipPath"),b="clippath_".concat(this.data.id);y.setAttribute("id",b),y.setAttribute("clipPathUnits","objectBoundingBox"),m.append(y);for(var w=2,x=t.length;w<x;w+=8){var A,_=t[w],k=t[w+1],S=t[w+2],E=t[w+3],M=g.createElement("rect"),T=(S-e)/p,C=(i-k)/f,P=(_-S)/p,I=(k-E)/f;M.setAttribute("x",T),M.setAttribute("y",C),M.setAttribute("width",P),M.setAttribute("height",I),y.append(M),null===(A=h)||void 0===A||A.push('<rect vector-effect="non-scaling-stroke" x="'.concat(T,'" y="').concat(C,'" width="').concat(P,'" height="').concat(I,'"/>'))}_nt(wvt,this)&&(h.push("</g></svg>')"),c.backgroundImage=h.join("")),this.container.append(v),this.container.style.clipPath="url(#".concat(b,")")}}}_createPopup(){var{data:t}=this,e=Snt(xvt,this,new jvt({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:"popup_".concat(t.id),rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){Uot("Abstract method `AnnotationElement.render` called")}_getElementsByName(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=[];if(this._fieldObjects){var n=this._fieldObjects[t];if(n)for(var{page:i,id:a,exportValues:s}of n)if(-1!==i&&a!==e){var o="string"==typeof s?s:null,l=document.querySelector('[data-element-id="'.concat(a,'"]'));!l||vvt.has(l)?r.push({id:a,exportValue:o,domElement:l}):Wot("_getElementsByName - element not allowed: ".concat(a))}return r}for(var h of document.getElementsByName(t)){var{exportValue:c}=h,u=h.getAttribute("data-element-id");u!==e&&(vvt.has(h)&&r.push({id:u,exportValue:c,domElement:h}))}return r}show(){var t;this.container&&(this.container.hidden=!1),null===(t=this.popup)||void 0===t||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),null===(t=this.popup)||void 0===t||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){var t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(var e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(this._isEditable){var{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{var r;null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}}function kvt(t){var{container:{style:e},data:{rect:r,rotation:n},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:s,pageY:o}}}}=this;null==r||r.splice(0,4,...t);var{width:l,height:h}=mvt(t);e.left="".concat(100*(t[0]-s)/i,"%"),e.top="".concat(100*(a-t[3]+o)/a,"%"),0===n?(e.width="".concat(100*l/i,"%"),e.height="".concat(100*h/a,"%")):this.setRotation(n)}var Svt=new WeakSet;class Evt extends _vt{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(t,{isRenderable:!0,ignoreBorder:!(null==e||!e.ignoreBorder),createQuadrilaterals:!0}),Mnt(this,Svt),this.isTooltipOnly=t.data.isTooltipOnly}render(){var{data:t,linkService:e}=this,r=document.createElement("a");r.setAttribute("data-element-id",t.id);var n=!1;return t.url?(e.addLinkAttributes(r,t.url,t.newWindow),n=!0):t.action?(this._bindNamedAction(r,t.action),n=!0):t.attachment?(bnt(Svt,this,Tvt).call(this,r,t.attachment,t.attachmentDest),n=!0):t.setOCGState?(bnt(Svt,this,Cvt).call(this,r,t.setOCGState),n=!0):t.dest?(this._bindLink(r,t.dest),n=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(r,t),n=!0),t.resetForm?(this._bindResetFormAction(r,t.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(r,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(r),this.container}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&bnt(Svt,this,Mvt).call(this)}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),bnt(Svt,this,Mvt).call(this)}_bindJSAction(t,e){var r=this;t.href=this.linkService.getAnchorUrl("");var n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]),i=function(i){var a=n.get(i);if(!a)return 1;t[a]=()=>{var t;return null===(t=r.linkService.eventBus)||void 0===t||t.dispatch("dispatcheventinsandbox",{source:r,detail:{id:e.id,name:i}}),!1}};for(var a of Object.keys(e.actions))i(a);t.onclick||(t.onclick=()=>!1),bnt(Svt,this,Mvt).call(this)}_bindResetFormAction(t,e){var r=t.onclick;if(r||(t.href=this.linkService.getAnchorUrl("")),bnt(Svt,this,Mvt).call(this),!this._fieldObjects)return Wot('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(r||(t.onclick=()=>!1));t.onclick=()=>{null==r||r();var{fields:t,refs:n,include:i}=e,a=[];if(0!==t.length||0!==n.length){var s=new Set(n);for(var o of t){var l=this._fieldObjects[o]||[];for(var{id:h}of l)s.add(h)}for(var c of Object.values(this._fieldObjects))for(var u of c)s.has(u.id)===i&&a.push(u)}else for(var d of Object.values(this._fieldObjects))a.push(...d);var p,f=this.annotationStorage,g=[];for(var v of a){var{id:m}=v;switch(g.push(m),v.type){case"text":var y=v.defaultValue||"";f.setValue(m,{value:y});break;case"checkbox":case"radiobutton":var b=v.defaultValue===v.exportValues;f.setValue(m,{value:b});break;case"combobox":case"listbox":var w=v.defaultValue||"";f.setValue(m,{value:w});break;default:continue}var x=document.querySelector('[data-element-id="'.concat(m,'"]'));x&&(vvt.has(x)?x.dispatchEvent(new Event("resetform")):Wot("_bindResetFormAction - element not allowed: ".concat(m)))}this.enableScripting&&(null===(p=this.linkService.eventBus)||void 0===p||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:g,name:"ResetForm"}}));return!1}}}function Mvt(){this.container.setAttribute("data-internal-link","")}function Tvt(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>{var t;return null===(t=this.downloadManager)||void 0===t||t.openOrDownloadData(e.content,e.filename,r),!1},bnt(Svt,this,Mvt).call(this)}function Cvt(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),bnt(Svt,this,Mvt).call(this)}class Pvt extends _vt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");var t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Ivt extends _vt{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&("CANVAS"===(null===(e=t.previousSibling)||void 0===e?void 0:e.nodeName)&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return nlt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,r,n,i){r.includes("mouse")?t.addEventListener(r,(t=>{var e;null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(r,(t=>{var a;if("blur"===r){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===r){if(e.focused)return;e.focused=!0}i&&(null===(a=this.linkService.eventBus)||void 0===a||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(t)}}))}))}_setEventListeners(t,e,r,n){for(var[i,a]of r){var s,o,l;if("Action"===a||null!==(s=this.data.actions)&&void 0!==s&&s[a])"Focus"!==a&&"Blur"!==a||e||(e={focused:!1}),this._setEventListener(t,e,i,a,n),"Focus"!==a||null!==(o=this.data.actions)&&void 0!==o&&o.Blur?"Blur"!==a||null!==(l=this.data.actions)&&void 0!==l&&l.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null)}}_setBackgroundColor(t){var e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":alt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){var e,{fontColor:r}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,i=t.style,a=t=>Math.round(10*t)/10;if(this.data.multiLine){var s=Math.abs(this.data.rect[3]-this.data.rect[1]-2),o=s/(Math.round(s/(Yst*n))||1);e=Math.min(n,a(o/Yst))}else{var l=Math.abs(this.data.rect[3]-this.data.rect[1]-2);e=Math.min(n,a(l/Yst))}i.fontSize="calc(".concat(e,"px * var(--scale-factor))"),i.color=alt.makeHexColor(r[0],r[1],r[2]),null!==this.data.textAlignment&&(i.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Rvt extends Ivt{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,r,n){var i=this.annotationStorage;for(var a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=r),i.setValue(a.id,{[n]:r})}render(){var t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");var r=null;if(this.renderForms){var n,i=t.getValue(e,{value:this.data.fieldValue}),a=i.value||"",s=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;s&&a.length>s&&(a=a.slice(0,s));var o=i.formattedValue||(null===(n=this.data.textContent)||void 0===n?void 0:n.join("\n"))||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,""));var l={userValue:a,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((r=document.createElement("textarea")).textContent=null!=o?o:a,this.data.doNotScroll&&(r.style.overflowY="hidden")):((r=document.createElement("input")).type="text",r.setAttribute("value",null!=o?o:a),this.data.doNotScroll&&(r.style.overflowX="hidden")),this.data.hasOwnCanvas&&(r.hidden=!0),vvt.add(r),r.setAttribute("data-element-id",e),r.disabled=this.data.readOnly,r.name=this.data.fieldName,r.tabIndex=gvt,this._setRequired(r,this.data.required),s&&(r.maxLength=s),r.addEventListener("input",(n=>{t.setValue(e,{value:n.target.value}),this.setPropertyOnSiblings(r,"value",n.target.value,"value"),l.formattedValue=null})),r.addEventListener("resetform",(t=>{var e,n=null!==(e=this.data.defaultFieldValue)&&void 0!==e?e:"";r.value=l.userValue=n,l.formattedValue=null}));var h=t=>{var{formattedValue:e}=l;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){var c;r.addEventListener("focus",(t=>{var e;if(!l.focused){var{target:r}=t;l.userValue&&(r.value=l.userValue),l.lastCommittedValue=r.value,l.commitKey=1,null!==(e=this.data.actions)&&void 0!==e&&e.Focus||(l.focused=!0)}})),r.addEventListener("updatefromsandbox",(r=>{this.showElementAndHideCanvas(r.target);var n={value(r){var n;l.userValue=null!==(n=r.detail.value)&&void 0!==n?n:"",t.setValue(e,{value:l.userValue.toString()}),r.target.value=l.userValue},formattedValue(r){var{formattedValue:n}=r.detail;l.formattedValue=n,null!=n&&r.target!==document.activeElement&&(r.target.value=n),t.setValue(e,{formattedValue:n})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:r=>{var n,{charLimit:i}=r.detail,{target:a}=r;if(0!==i){a.setAttribute("maxLength",i);var s=l.userValue;!s||s.length<=i||(s=s.slice(0,i),a.value=l.userValue=s,t.setValue(e,{value:s}),null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}else a.removeAttribute("maxLength")}};this._dispatchEventFromSandbox(n,r)})),r.addEventListener("keydown",(t=>{var r;l.commitKey=1;var n=-1;if("Escape"===t.key?n=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(l.commitKey=3):n=2,-1!==n){var{value:i}=t.target;l.lastCommittedValue!==i&&(l.lastCommittedValue=i,l.userValue=i,null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:n,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}}));var u=h;h=null,r.addEventListener("blur",(t=>{var r;if(l.focused&&t.relatedTarget){null!==(r=this.data.actions)&&void 0!==r&&r.Blur||(l.focused=!1);var n,{value:i}=t.target;if(l.userValue=i,l.lastCommittedValue!==i)null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:l.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}});u(t)}})),null!==(c=this.data.actions)&&void 0!==c&&c.Keystroke&&r.addEventListener("beforeinput",(t=>{var r;l.lastCommittedValue=null;var{data:n,target:i}=t,{value:a,selectionStart:s,selectionEnd:o}=i,h=s,c=o;switch(t.inputType){case"deleteWordBackward":var u=a.substring(0,s).match(/\w*[^\w]*$/);u&&(h-=u[0].length);break;case"deleteWordForward":var d=a.substring(s).match(/^[^\w]*\w*/);d&&(c+=d[0].length);break;case"deleteContentBackward":s===o&&(h-=1);break;case"deleteContentForward":s===o&&(c+=1)}t.preventDefault(),null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,change:n||"",willCommit:!1,selStart:h,selEnd:c}})})),this._setEventListeners(r,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(h&&r.addEventListener("blur",h),this.data.comb){var d=(this.data.rect[2]-this.data.rect[0])/s;r.classList.add("comb"),r.style.letterSpacing="calc(".concat(d,"px * var(--scale-factor) - 1ch)")}}else(r=document.createElement("div")).textContent=this.data.fieldValue,r.style.verticalAlign="middle",r.style.display="table-cell",this.data.hasOwnCanvas&&(r.hidden=!0);return this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class Ovt extends Ivt{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Lvt extends Ivt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){var t=this.annotationStorage,e=this.data,r=e.id,n=t.getValue(r,{value:e.exportValue===e.fieldValue}).value;"string"==typeof n&&(n="Off"!==n,t.setValue(r,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");var i=document.createElement("input");return vvt.add(i),i.setAttribute("data-element-id",r),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=e.fieldName,n&&i.setAttribute("checked",!0),i.setAttribute("exportValue",e.exportValue),i.tabIndex=gvt,i.addEventListener("change",(n=>{var{name:i,checked:a}=n.target;for(var s of this._getElementsByName(i,r)){var o=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=o),t.setValue(s.id,{value:o})}t.setValue(r,{value:a})})),i.addEventListener("resetform",(t=>{var r=e.defaultFieldValue||"Off";t.target.checked=r===e.exportValue})),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",(e=>{var n={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(r,{value:e.target.checked})}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Dvt extends Ivt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");var t=this.annotationStorage,e=this.data,r=e.id,n=t.getValue(r,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof n&&(n=n!==e.buttonValue,t.setValue(r,{value:n})),n)for(var i of this._getElementsByName(e.fieldName,r))t.setValue(i.id,{value:!1});var a=document.createElement("input");if(vvt.add(a),a.setAttribute("data-element-id",r),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,n&&a.setAttribute("checked",!0),a.tabIndex=gvt,a.addEventListener("change",(e=>{var{name:n,checked:i}=e.target;for(var a of this._getElementsByName(n,r))t.setValue(a.id,{value:!1});t.setValue(r,{value:i})})),a.addEventListener("resetform",(t=>{var r=e.defaultFieldValue;t.target.checked=null!=r&&r===e.buttonValue})),this.enableScripting&&this.hasJSActions){var s=e.buttonValue;a.addEventListener("updatefromsandbox",(e=>{var n={value:e=>{var n=s===e.detail.value;for(var i of this._getElementsByName(e.target.name)){var a=n&&i.id===r;i.domElement&&(i.domElement.checked=a),t.setValue(i.id,{value:a})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Fvt extends Evt{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){var t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");var e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Nvt extends Ivt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");var t=this.annotationStorage,e=this.data.id,r=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");vvt.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=gvt;var i=this.data.combo&&this.data.options.length>0;for(var a of(this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",(t=>{var e=this.data.defaultFieldValue;for(var r of n.options)r.selected=r.value===e})),this.data.options)){var s=document.createElement("option");s.textContent=a.displayValue,s.value=a.exportValue,r.value.includes(a.exportValue)&&(s.setAttribute("selected",!0),i=!1),n.append(s)}var o=null;if(i){var l=document.createElement("option");l.value=" ",l.setAttribute("hidden",!0),l.setAttribute("selected",!0),n.prepend(l),o=()=>{l.remove(),n.removeEventListener("input",o),o=null},n.addEventListener("input",o)}var h=t=>{var e=t?"value":"textContent",{options:r,multiple:i}=n;return i?Array.prototype.filter.call(r,(t=>t.selected)).map((t=>t[e])):-1===r.selectedIndex?null:r[r.selectedIndex][e]},c=h(!1),u=t=>{var e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",(r=>{var i={value(r){var i;null===(i=o)||void 0===i||i();var a=r.detail.value,s=new Set(Array.isArray(a)?a:[a]);for(var l of n.options)l.selected=s.has(l.value);t.setValue(e,{value:h(!0)}),c=h(!1)},multipleSelection(t){n.multiple=!0},remove(r){var i=n.options,a=r.detail.remove;if(i[a].selected=!1,n.remove(a),i.length>0){var s=Array.prototype.findIndex.call(i,(t=>t.selected));-1===s&&(i[0].selected=!0)}t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},clear(r){for(;0!==n.length;)n.remove(0);t.setValue(e,{value:null,items:[]}),c=h(!1)},insert(r){var{index:i,displayValue:a,exportValue:s}=r.detail.insert,o=n.children[i],l=document.createElement("option");l.textContent=a,l.value=s,o?o.before(l):n.append(l),t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},items(r){for(var{items:i}=r.detail;0!==n.length;)n.remove(0);for(var a of i){var{displayValue:s,exportValue:o}=a,l=document.createElement("option");l.textContent=s,l.value=o,n.append(l)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},indices(r){var n=new Set(r.detail.indices);for(var i of r.target.options)i.selected=n.has(i.index);t.setValue(e,{value:h(!0)}),c=h(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(i,r)})),n.addEventListener("input",(r=>{var n,i=h(!0),a=h(!1);t.setValue(e,{value:i}),r.preventDefault(),null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:c,change:a,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):n.addEventListener("input",(function(r){t.setValue(e,{value:h(!0)})})),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class jvt extends _vt{constructor(t){var{data:e,elements:r}=t;super(t,{isRenderable:_vt._hasPopupData(e)}),this.elements=r,this.popup=null}render(){this.container.classList.add("popupAnnotation");var t=this.popup=new amt({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(var r of this.elements)r.popup=t,r.container.ariaHasPopup="dialog",e.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>"".concat(ult).concat(t))).join(",")),this.container}}var Bvt=new WeakMap,zvt=new WeakMap,Wvt=new WeakMap,Uvt=new WeakMap,Hvt=new WeakMap,Gvt=new WeakMap,Yvt=new WeakMap,Vvt=new WeakMap,qvt=new WeakMap,Xvt=new WeakMap,$vt=new WeakMap,Kvt=new WeakMap,Qvt=new WeakMap,Jvt=new WeakMap,Zvt=new WeakMap,tmt=new WeakMap,emt=new WeakMap,rmt=new WeakMap,nmt=new WeakMap,imt=new WeakSet;class amt{constructor(t){var{container:e,color:r,elements:n,titleObj:i,modificationDate:a,contentsObj:s,richText:o,parent:l,rect:h,parentRect:c,open:u}=t;for(var d of(Mnt(this,imt),knt(this,Bvt,bnt(imt,this,cmt).bind(this)),knt(this,zvt,bnt(imt,this,fmt).bind(this)),knt(this,Wvt,bnt(imt,this,pmt).bind(this)),knt(this,Uvt,bnt(imt,this,dmt).bind(this)),knt(this,Hvt,null),knt(this,Gvt,null),knt(this,Yvt,null),knt(this,Vvt,null),knt(this,qvt,null),knt(this,Xvt,null),knt(this,$vt,null),knt(this,Kvt,!1),knt(this,Qvt,null),knt(this,Jvt,null),knt(this,Zvt,null),knt(this,tmt,null),knt(this,emt,null),knt(this,rmt,null),knt(this,nmt,!1),Snt(Gvt,this,e),Snt(emt,this,i),Snt(Yvt,this,s),Snt(tmt,this,o),Snt(Xvt,this,l),Snt(Hvt,this,r),Snt(Zvt,this,h),Snt($vt,this,c),Snt(qvt,this,n),Snt(Vvt,this,Elt.toDateObject(a)),this.trigger=n.flatMap((t=>t.getElementsToTriggerPopup())),this.trigger))d.addEventListener("click",_nt(Uvt,this)),d.addEventListener("mouseenter",_nt(Wvt,this)),d.addEventListener("mouseleave",_nt(zvt,this)),d.classList.add("popupTriggerArea");for(var p of n){var f;null===(f=p.container)||void 0===f||f.addEventListener("keydown",_nt(Bvt,this))}_nt(Gvt,this).hidden=!0,u&&bnt(imt,this,dmt).call(this)}render(){if(!_nt(Qvt,this)){var t=Snt(Qvt,this,document.createElement("div"));if(t.className="popup",_nt(Hvt,this)){var e=t.style.outlineColor=alt.makeHexColor(..._nt(Hvt,this));if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor="color-mix(in srgb, ".concat(e," 30%, white)");else{t.style.backgroundColor=alt.makeHexColor(..._nt(Hvt,this).map((t=>Math.floor(.7*(255-t)+t))))}}var r=document.createElement("span");r.className="header";var n=document.createElement("h1");if(r.append(n),({dir:n.dir,str:n.textContent}=_nt(emt,this)),t.append(r),_nt(Vvt,this)){var i=document.createElement("span");i.classList.add("popupDate"),i.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),i.setAttribute("data-l10n-args",JSON.stringify({dateObj:_nt(Vvt,this).valueOf()})),r.append(i)}var a=Ent(imt,this,smt);if(a)fvt.render({xfaHtml:a,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{var s=this._formatContents(_nt(Yvt,this));t.append(s)}_nt(Gvt,this).append(t)}}_formatContents(t){var{str:e,dir:r}=t,n=document.createElement("p");n.classList.add("popupContent"),n.dir=r;for(var i=e.split(/(?:\r\n?|\n)/),a=0,s=i.length;a<s;++a){var o=i[a];n.append(document.createTextNode(o)),a<s-1&&n.append(document.createElement("br"))}return n}updateEdited(t){var e,{rect:r,popupContent:n}=t;_nt(rmt,this)||Snt(rmt,this,{contentsObj:_nt(Yvt,this),richText:_nt(tmt,this)}),r&&Snt(Jvt,this,null),n&&(Snt(tmt,this,bnt(imt,this,hmt).call(this,n)),Snt(Yvt,this,null)),null===(e=_nt(Qvt,this))||void 0===e||e.remove(),Snt(Qvt,this,null)}resetEdited(){var t;_nt(rmt,this)&&(({contentsObj:Int(Snt,[Yvt,this])._,richText:Int(Snt,[tmt,this])._}=_nt(rmt,this)),Snt(rmt,this,null),null===(t=_nt(Qvt,this))||void 0===t||t.remove(),Snt(Qvt,this,null),Snt(Jvt,this,null))}forceHide(){Snt(nmt,this,this.isVisible),_nt(nmt,this)&&(_nt(Gvt,this).hidden=!0)}maybeShow(){_nt(nmt,this)&&(_nt(Qvt,this)||bnt(imt,this,pmt).call(this),Snt(nmt,this,!1),_nt(Gvt,this).hidden=!1)}get isVisible(){return!1===_nt(Gvt,this).hidden}}function smt(t){var e=_nt(tmt,t),r=_nt(Yvt,t);return null==e||!e.str||null!=r&&r.str&&r.str!==e.str?null:_nt(tmt,t).html||null}function omt(t){var e;return(null===(e=Ent(imt,t,smt))||void 0===e||null===(e=e.attributes)||void 0===e||null===(e=e.style)||void 0===e?void 0:e.fontSize)||0}function lmt(t){var e;return(null===(e=Ent(imt,t,smt))||void 0===e||null===(e=e.attributes)||void 0===e||null===(e=e.style)||void 0===e?void 0:e.color)||null}function hmt(t){var e=[],r={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:Ent(imt,this,lmt),fontSize:Ent(imt,this,omt)?"calc(".concat(Ent(imt,this,omt),"px * var(--scale-factor))"):""}};for(var i of t.split("\n"))e.push({name:"span",value:i,attributes:n});return r}function cmt(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&_nt(Kvt,this))&&bnt(imt,this,dmt).call(this)}function umt(){if(null===_nt(Jvt,this)){var{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:r,pageX:n,pageY:i}}}=_nt(Xvt,this),a=!!_nt($vt,this),s=_nt(a?$vt:Zvt,this);for(var o of _nt(qvt,this))if(!s||null!==alt.intersect(o.data.rect,s)){s=o.data.rect,a=!0;break}var l=alt.normalizeRect([s[0],t[3]-s[1]+t[1],s[2],t[3]-s[3]+t[1]]),h=a?s[2]-s[0]+5:0,c=l[0]+h,u=l[1];Snt(Jvt,this,[100*(c-n)/e,100*(u-i)/r]);var{style:d}=_nt(Gvt,this);d.left="".concat(_nt(Jvt,this)[0],"%"),d.top="".concat(_nt(Jvt,this)[1],"%")}}function dmt(){Snt(Kvt,this,!_nt(Kvt,this)),_nt(Kvt,this)?(bnt(imt,this,pmt).call(this),_nt(Gvt,this).addEventListener("click",_nt(Uvt,this)),_nt(Gvt,this).addEventListener("keydown",_nt(Bvt,this))):(bnt(imt,this,fmt).call(this),_nt(Gvt,this).removeEventListener("click",_nt(Uvt,this)),_nt(Gvt,this).removeEventListener("keydown",_nt(Bvt,this)))}function pmt(){_nt(Qvt,this)||this.render(),this.isVisible?_nt(Kvt,this)&&_nt(Gvt,this).classList.add("focused"):(bnt(imt,this,umt).call(this),_nt(Gvt,this).hidden=!1,_nt(Gvt,this).style.zIndex=parseInt(_nt(Gvt,this).style.zIndex)+1e3)}function fmt(){_nt(Gvt,this).classList.remove("focused"),!_nt(Kvt,this)&&this.isVisible&&(_nt(Gvt,this).hidden=!0,_nt(Gvt,this).style.zIndex=parseInt(_nt(Gvt,this).style.zIndex)-1e3)}class gmt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=eot.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){var t=document.createElement("div");for(var e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){var r=document.createElement("span");r.textContent=e,t.append(r)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var vmt=new WeakMap;class mmt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),knt(this,vmt,null)}render(){this.container.classList.add("lineAnnotation");var t=this.data,{width:e,height:r}=mvt(t.rect),n=this.svgFactory.create(e,r,!0),i=Snt(vmt,this,this.svgFactory.createElement("svg:line"));return i.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),i.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),i.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),i.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),i.setAttribute("stroke-width",t.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),n.append(i),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _nt(vmt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var ymt=new WeakMap;class bmt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),knt(this,ymt,null)}render(){this.container.classList.add("squareAnnotation");var t=this.data,{width:e,height:r}=mvt(t.rect),n=this.svgFactory.create(e,r,!0),i=t.borderStyle.width,a=Snt(ymt,this,this.svgFactory.createElement("svg:rect"));return a.setAttribute("x",i/2),a.setAttribute("y",i/2),a.setAttribute("width",e-i),a.setAttribute("height",r-i),a.setAttribute("stroke-width",i||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _nt(ymt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var wmt=new WeakMap;class xmt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),knt(this,wmt,null)}render(){this.container.classList.add("circleAnnotation");var t=this.data,{width:e,height:r}=mvt(t.rect),n=this.svgFactory.create(e,r,!0),i=t.borderStyle.width,a=Snt(wmt,this,this.svgFactory.createElement("svg:ellipse"));return a.setAttribute("cx",e/2),a.setAttribute("cy",r/2),a.setAttribute("rx",e/2-i/2),a.setAttribute("ry",r/2-i/2),a.setAttribute("stroke-width",i||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _nt(wmt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var Amt=new WeakMap;class _mt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),knt(this,Amt,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);var{data:{rect:t,vertices:e,borderStyle:r,popupRef:n}}=this;if(!e)return this.container;for(var{width:i,height:a}=mvt(t),s=this.svgFactory.create(i,a,!0),o=[],l=0,h=e.length;l<h;l+=2){var c=e[l]-t[0],u=t[3]-e[l+1];o.push("".concat(c,",").concat(u))}o=o.join(" ");var d=Snt(Amt,this,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",o),d.setAttribute("stroke-width",r.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),s.append(d),this.container.append(s),!n&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _nt(Amt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}class kmt extends _mt{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Smt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var Emt=new WeakMap,Mmt=new WeakMap,Tmt=new WeakSet;class Cmt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Mnt(this,Tmt),knt(this,Emt,null),knt(this,Mmt,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?eot.HIGHLIGHT:eot.INK}render(){this.container.classList.add(this.containerClassName);var{data:{rect:t,rotation:e,inkLists:r,borderStyle:n,popupRef:i}}=this,{transform:a,width:s,height:o}=bnt(Tmt,this,Pmt).call(this,e,t),l=this.svgFactory.create(s,o,!0),h=Snt(Emt,this,this.svgFactory.createElement("svg:g"));l.append(h),h.setAttribute("stroke-width",n.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",a);for(var c=0,u=r.length;c<u;c++){var d=this.svgFactory.createElement(this.svgElementName);_nt(Mmt,this).push(d),d.setAttribute("points",r[c].join(",")),h.append(d)}return!i&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);var{thickness:e,points:r,rect:n}=t,i=_nt(Emt,this);if(e>=0&&i.setAttribute("stroke-width",e||1),r)for(var a=0,s=_nt(Mmt,this).length;a<s;a++)_nt(Mmt,this)[a].setAttribute("points",r[a].join(","));if(n){var{transform:o,width:l,height:h}=bnt(Tmt,this,Pmt).call(this,this.data.rotation,n);i.parentElement.setAttribute("viewBox","0 0 ".concat(l," ").concat(h)),i.setAttribute("transform",o)}}getElementsToTriggerPopup(){return _nt(Mmt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function Pmt(t,e){switch(t){case 90:return{transform:"rotate(90) translate(".concat(-e[0],",").concat(e[1],") scale(1,-1)"),width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:"rotate(180) translate(".concat(-e[2],",").concat(e[1],") scale(1,-1)"),width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:"rotate(270) translate(".concat(-e[2],",").concat(e[3],") scale(1,-1)"),width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:"translate(".concat(-e[0],",").concat(e[3],") scale(1,-1)"),width:e[2]-e[0],height:e[3]-e[1]}}}class Imt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=eot.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Rmt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class Omt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Lmt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Dmt extends _vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=eot.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var Fmt=new WeakMap,Nmt=new WeakSet;class jmt extends _vt{constructor(t){var e;super(t,{isRenderable:!0}),Mnt(this,Nmt),knt(this,Fmt,null);var{file:r}=this.data;this.filename=r.filename,this.content=r.content,null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("fileattachmentannotation",Pnt({source:this},r))}render(){this.container.classList.add("fileAttachmentAnnotation");var t,{container:e,data:r}=this;r.hasAppearance||0===r.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src="".concat(this.imageResourcesPath,"annotation-").concat(/paperclip/i.test(r.name)?"paperclip":"pushpin",".svg"),r.fillAlpha&&r.fillAlpha<1&&(t.style="filter: opacity(".concat(Math.round(100*r.fillAlpha),"%);"))),t.addEventListener("dblclick",bnt(Nmt,this,Bmt).bind(this)),Snt(Fmt,this,t);var{isMac:n}=nlt.platform;return e.addEventListener("keydown",(t=>{"Enter"===t.key&&(n?t.metaKey:t.ctrlKey)&&bnt(Nmt,this,Bmt).call(this)})),!r.popupRef&&this.hasPopupData?this._createPopup():t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return _nt(Fmt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function Bmt(){var t;null===(t=this.downloadManager)||void 0===t||t.openOrDownloadData(this.content,this.filename)}var zmt=new WeakMap,Wmt=new WeakMap,Umt=new WeakMap,Hmt=new WeakMap,Gmt=new WeakSet;class Ymt{constructor(t){var{div:e,accessibilityManager:r,annotationCanvasMap:n,annotationEditorUIManager:i,page:a,viewport:s,structTreeLayer:o}=t;Mnt(this,Gmt),knt(this,zmt,null),knt(this,Wmt,null),knt(this,Umt,new Map),knt(this,Hmt,null),this.div=e,Snt(zmt,this,r),Snt(Wmt,this,n),Snt(Hmt,this,o||null),this.page=a,this.viewport=s,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return _nt(Umt,this).size>0}render(t){var e=this;return xnt((function*(){var{annotations:r}=t,n=e.div;Rlt(n,e.viewport);var i=new Map,a={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new pvt,annotationStorage:t.annotationStorage||new fdt,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:e,elements:null};for(var s of r)if(!s.noHTML){var o=s.annotationType===Eot;if(o){var l=i.get(s.id);if(!l)continue;a.elements=l}else{var{width:h,height:c}=mvt(s.rect);if(h<=0||c<=0)continue}a.data=s;var u=yvt.create(a);if(u.isRenderable){if(!o&&s.popupRef){var d=i.get(s.popupRef);d?d.push(u):i.set(s.popupRef,[u])}var p,f=u.render();if(s.hidden&&(f.style.visibility="hidden"),yield bnt(Gmt,e,Vmt).call(e,f,s.id),u._isEditable)_nt(Umt,e).set(u.data.id,u),null===(p=e._annotationEditorUIManager)||void 0===p||p.renderAnnotationElement(u)}}bnt(Gmt,e,Xmt).call(e)}))()}update(t){var{viewport:e}=t,r=this.div;this.viewport=e,Rlt(r,{rotation:e.rotation}),bnt(Gmt,this,Xmt).call(this),r.hidden=!1}getEditableAnnotations(){return Array.from(_nt(Umt,this).values())}getEditableAnnotation(t){return _nt(Umt,this).get(t)}}function Vmt(t,e){return qmt.apply(this,arguments)}function qmt(){return qmt=xnt((function*(t,e){var r,n,i=t.firstChild||t,a=i.id="".concat(ult).concat(e),s=yield null===(r=_nt(Hmt,this))||void 0===r?void 0:r.getAriaAttributes(a);if(s)for(var[o,l]of s)i.setAttribute(o,l);this.div.append(t),null===(n=_nt(zmt,this))||void 0===n||n.moveElementInDOM(this.div,t,i,!1)})),qmt.apply(this,arguments)}function Xmt(){if(_nt(Wmt,this)){var t=this.div;for(var[e,r]of _nt(Wmt,this)){var n=t.querySelector('[data-annotation-id="'.concat(e,'"]'));if(n){r.className="annotationContent";var{firstChild:i}=n;i?"CANVAS"===i.nodeName?i.replaceWith(r):i.classList.contains("annotationContent")?i.after(r):i.before(r):n.append(r)}}_nt(Wmt,this).clear()}}var $mt=/\r\n?|\n/g,Kmt=new WeakMap,Qmt=new WeakMap,Jmt=new WeakMap,Zmt=new WeakMap,tyt=new WeakMap,eyt=new WeakSet;class ryt extends jut{static get _keyboardManager(){var t=ryt.prototype,e=t=>t.isEmpty(),r=cct.TRANSLATE_SMALL,n=cct.TRANSLATE_BIG;return Yot(this,"_keyboardManager",new yht([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[r,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,r],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}]]))}constructor(t){super(Pnt(Pnt({},t),{},{name:"freeTextEditor"})),Mnt(this,eyt),knt(this,Kmt,void 0),knt(this,Qmt,""),knt(this,Jmt,"".concat(this.id,"-editor")),knt(this,Zmt,null),knt(this,tyt,void 0),Snt(Kmt,this,t.color||ryt._defaultColor||jut._defaultLineColor),Snt(tyt,this,t.fontSize||ryt._defaultFontSize)}static initialize(t,e){jut.initialize(t,e);var r=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(r.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case rot.FREETEXT_SIZE:ryt._defaultFontSize=e;break;case rot.FREETEXT_COLOR:ryt._defaultColor=e}}updateParams(t,e){switch(t){case rot.FREETEXT_SIZE:bnt(eyt,this,nyt).call(this,e);break;case rot.FREETEXT_COLOR:bnt(eyt,this,iyt).call(this,e)}}static get defaultPropertiesToUpdate(){return[[rot.FREETEXT_SIZE,ryt._defaultFontSize],[rot.FREETEXT_COLOR,ryt._defaultColor||jut._defaultLineColor]]}get propertiesToUpdate(){return[[rot.FREETEXT_SIZE,_nt(tyt,this)],[rot.FREETEXT_COLOR,_nt(Kmt,this)]]}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){var t=this.parentScale;return[-ryt._internalPadding*t,-(ryt._internalPadding+_nt(tyt,this))*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!this.isInEditMode()){this.parent.setEditingState(!1),this.parent.updateToolbar(eot.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),Snt(Zmt,this,new AbortController);var t=this._uiManager.combinedSignal(_nt(Zmt,this));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}}disableEditMode(){var t;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",_nt(Jmt,this)),this._isDraggable=!0,null===(t=_nt(Zmt,this))||void 0===t||t.abort(),Snt(Zmt,this,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){var e;this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),null!==(e=this._initialOptions)&&void 0!==e&&e.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(this.isInEditMode()){super.commit(),this.disableEditMode();var t=_nt(Qmt,this),e=Snt(Qmt,this,bnt(eyt,this,ayt).call(this).trimEnd());if(t!==e){var r=t=>{Snt(Qmt,this,t),t?(bnt(eyt,this,lyt).call(this),this._uiManager.rebuild(this),bnt(eyt,this,syt).call(this)):this.remove()};this.addCommands({cmd:()=>{r(e)},undo:()=>{r(t)},mustExec:!1}),bnt(eyt,this,syt).call(this)}}}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){ryt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;var t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",_nt(Jmt,this)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;var{style:r}=this.editorDiv;if(r.fontSize="calc(".concat(_nt(tyt,this),"px * var(--scale-factor))"),r.color=_nt(Kmt,this),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),rht(this,this.div,["dblclick","keydown"]),this.width){var[n,i]=this.parentDimensions;if(this.annotationElementId){var{position:a}=this._initialData,[s,o]=this.getInitialTranslation();[s,o]=this.pageTranslationToScreen(s,o);var l,h,[c,u]=this.pageDimensions,[d,p]=this.pageTranslation;switch(this.rotation){case 0:l=t+(a[0]-d)/c,h=e+this.height-(a[1]-p)/u;break;case 90:l=t+(a[0]-d)/c,h=e-(a[1]-p)/u,[s,o]=[o,-s];break;case 180:l=t-this.width+(a[0]-d)/c,h=e-(a[1]-p)/u,[s,o]=[-s,-o];break;case 270:l=t+(a[0]-d-this.height*u)/c,h=e+(a[1]-p-this.width*c)/u,[s,o]=[-o,s]}this.setAt(l*n,h*i,s,o)}else this.setAt(t*n,e*i,this.width*n,this.height*i);bnt(eyt,this,lyt).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){var e=t.clipboardData||window.clipboardData,{types:r}=e;if(1!==r.length||"text/plain"!==r[0]){t.preventDefault();var n=cyt.call(ryt,e.getData("text")||"").replaceAll($mt,"\n");if(n){var i=window.getSelection();if(i.rangeCount){this.editorDiv.normalize(),i.deleteFromDocument();var a=i.getRangeAt(0);if(!n.includes("\n"))return a.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),void i.collapseToStart();var{startContainer:s,startOffset:o}=a,l=[],h=[];if(s.nodeType===Node.TEXT_NODE){var c=s.parentElement;if(h.push(s.nodeValue.slice(o).replaceAll($mt,"")),c!==this.editorDiv){var u=l;for(var d of this.editorDiv.childNodes)d!==c?u.push(oyt.call(ryt,d)):u=h}l.push(s.nodeValue.slice(0,o).replaceAll($mt,""))}else if(s===this.editorDiv){var p=l,f=0;for(var g of this.editorDiv.childNodes)f++===o&&(p=h),p.push(oyt.call(ryt,g))}Snt(Qmt,this,"".concat(l.join("\n")).concat(n).concat(h.join("\n"))),bnt(eyt,this,lyt).call(this);var v=new Range,m=l.reduce(((t,e)=>t+e.length),0);for(var{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){var b=y.nodeValue.length;if(m<=b){v.setStart(y,m),v.setEnd(y,m);break}m-=b}i.removeAllRanges(),i.addRange(v)}}}}get contentDiv(){return this.editorDiv}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return xnt((function*(){var a=null;if(t instanceof gmt){var{data:{defaultAppearanceData:{fontSize:s,fontColor:o},rect:l,rotation:h,id:c,popupRef:u},textContent:d,textPosition:p,parent:{page:{pageNumber:f}}}=t;if(!d||0===d.length)return null;a=t={annotationType:eot.FREETEXT,color:Array.from(o),fontSize:s,value:d.join("\n"),position:p,pageIndex:f-1,rect:l.slice(0),rotation:h,id:c,deleted:!1,popupRef:u}}var g=yield n().call(i,t,e,r);return Snt(tyt,g,t.fontSize),Snt(Kmt,g,alt.makeHexColor(...t.color)),Snt(Qmt,g,cyt.call(ryt,t.value)),g.annotationElementId=t.id||null,g._initialData=a,g}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var e=ryt._internalPadding*this.parentScale,r=this.getRect(e,e),n=jut._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:_nt(Kmt,this)),i={annotationType:eot.FREETEXT,color:n,fontSize:_nt(tyt,this),value:bnt(eyt,this,hyt).call(this),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?i:this.annotationElementId&&!bnt(eyt,this,uyt).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){var e=super.renderAnnotationElement(t);if(this.deleted)return e;var{style:r}=e;for(var n of(r.fontSize="calc(".concat(_nt(tyt,this),"px * var(--scale-factor))"),r.color=_nt(Kmt,this),e.replaceChildren(),_nt(Qmt,this).split("\n"))){var i=document.createElement("div");i.append(n?document.createTextNode(n):document.createElement("br")),e.append(i)}var a=ryt._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(a,a),popupContent:_nt(Qmt,this)}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}function nyt(t){var e=t=>{this.editorDiv.style.fontSize="calc(".concat(t,"px * var(--scale-factor))"),this.translate(0,-(t-_nt(tyt,this))*this.parentScale),Snt(tyt,this,t),bnt(eyt,this,syt).call(this)},r=_nt(tyt,this);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rot.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}function iyt(t){var e=t=>{Snt(Kmt,this,this.editorDiv.style.color=t)},r=_nt(Kmt,this);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rot.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}function ayt(){var t=[];this.editorDiv.normalize();var e=null;for(var r of this.editorDiv.childNodes){var n;(null===(n=e)||void 0===n?void 0:n.nodeType)===Node.TEXT_NODE&&"BR"===r.nodeName||(t.push(oyt.call(Rst,r)),e=r)}return t.join("\n")}function syt(){var t,[e,r]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{var{currentLayer:n,div:i}=this,a=i.style.display,s=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",n.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=a,i.classList.toggle("hidden",s)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/r):(this.width=t.height/e,this.height=t.width/r),this.fixAndSetPosition()}function oyt(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll($mt,"")}function lyt(){if(this.editorDiv.replaceChildren(),_nt(Qmt,this))for(var t of _nt(Qmt,this).split("\n")){var e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}function hyt(){return _nt(Qmt,this).replaceAll(" "," ")}function cyt(t){return t.replaceAll(" "," ")}function uyt(t){var{value:e,fontSize:r,color:n,pageIndex:i}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==r||t.color.some(((t,e)=>t!==n[e]))||t.pageIndex!==i}Rst=ryt,Tnt(ryt,"_freeTextDefaultContent",""),Tnt(ryt,"_internalPadding",0),Tnt(ryt,"_defaultColor",null),Tnt(ryt,"_defaultFontSize",10),Tnt(ryt,"_type","freetext"),Tnt(ryt,"_editorType",eot.FREETEXT);class dyt{toSVGPath(){Uot("Abstract method `toSVGPath` must be implemented.")}get box(){Uot("Abstract getter `box` must be implemented.")}serialize(t,e){Uot("Abstract method `serialize` must be implemented.")}static _rescale(t,e,r,n,i,a){a||(a=new Float32Array(t.length));for(var s=0,o=t.length;s<o;s+=2)a[s]=e+t[s]*n,a[s+1]=r+t[s+1]*i;return a}static _rescaleAndSwap(t,e,r,n,i,a){a||(a=new Float32Array(t.length));for(var s=0,o=t.length;s<o;s+=2)a[s]=e+t[s+1]*n,a[s+1]=r+t[s]*i;return a}static _translate(t,e,r,n){n||(n=new Float32Array(t.length));for(var i=0,a=t.length;i<a;i+=2)n[i]=e+t[i],n[i+1]=r+t[i+1];return n}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,r,n,i){switch(i){case 90:return[1-e/r,t/n];case 180:return[1-t/r,1-e/n];case 270:return[e/r,1-t/n];default:return[t/r,e/n]}}static _normalizePagePoint(t,e,r){switch(r){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,r,n,i,a){return[(t+5*r)/6,(e+5*n)/6,(5*r+i)/6,(5*n+a)/6,(r+i)/2,(n+a)/2]}}Tnt(dyt,"PRECISION",1e-4);var pyt=new WeakMap,fyt=new WeakMap,gyt=new WeakMap,vyt=new WeakMap,myt=new WeakMap,yyt=new WeakMap,byt=new WeakMap,wyt=new WeakMap,xyt=new WeakMap,Ayt=new WeakMap,_yt=new WeakMap,kyt=new WeakMap,Syt=new WeakMap,Eyt=new WeakSet;class Myt{constructor(t,e,r,n,i){var{x:a,y:s}=t,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;Mnt(this,Eyt),knt(this,pyt,void 0),knt(this,fyt,[]),knt(this,gyt,void 0),knt(this,vyt,void 0),knt(this,myt,[]),knt(this,yyt,new Float32Array(18)),knt(this,byt,void 0),knt(this,wyt,void 0),knt(this,xyt,void 0),knt(this,Ayt,void 0),knt(this,_yt,void 0),knt(this,kyt,void 0),knt(this,Syt,[]),Snt(pyt,this,e),Snt(kyt,this,n*r),Snt(vyt,this,i),_nt(yyt,this).set([NaN,NaN,NaN,NaN,a,s],6),Snt(gyt,this,o),Snt(Ayt,this,Dyt._*r),Snt(xyt,this,Fyt._*r),Snt(_yt,this,r),_nt(Syt,this).push(a,s)}isEmpty(){return isNaN(_nt(yyt,this)[8])}add(t){var e,{x:r,y:n}=t;Snt(byt,this,r),Snt(wyt,this,n);var[i,a,s,o]=_nt(pyt,this),[l,h,c,u]=_nt(yyt,this).subarray(8,12),d=r-c,p=n-u,f=Math.hypot(d,p);if(f<_nt(xyt,this))return!1;var g=f-_nt(Ayt,this),v=g/f,m=v*d,y=v*p,b=l,w=h;l=c,h=u,c+=m,u+=y,null===(e=_nt(Syt,this))||void 0===e||e.push(r,n);var x=m/g,A=-y/g*_nt(kyt,this),_=x*_nt(kyt,this);return _nt(yyt,this).set(_nt(yyt,this).subarray(2,8),0),_nt(yyt,this).set([c+A,u+_],4),_nt(yyt,this).set(_nt(yyt,this).subarray(14,18),12),_nt(yyt,this).set([c-A,u-_],16),isNaN(_nt(yyt,this)[6])?(0===_nt(myt,this).length&&(_nt(yyt,this).set([l+A,h+_],2),_nt(myt,this).push(NaN,NaN,NaN,NaN,(l+A-i)/s,(h+_-a)/o),_nt(yyt,this).set([l-A,h-_],14),_nt(fyt,this).push(NaN,NaN,NaN,NaN,(l-A-i)/s,(h-_-a)/o)),_nt(yyt,this).set([b,w,l,h,c,u],6),!this.isEmpty()):(_nt(yyt,this).set([b,w,l,h,c,u],6),Math.abs(Math.atan2(w-h,b-l)-Math.atan2(y,m))<Math.PI/2?([l,h,c,u]=_nt(yyt,this).subarray(2,6),_nt(myt,this).push(NaN,NaN,NaN,NaN,((l+c)/2-i)/s,((h+u)/2-a)/o),[l,h,b,w]=_nt(yyt,this).subarray(14,18),_nt(fyt,this).push(NaN,NaN,NaN,NaN,((b+l)/2-i)/s,((w+h)/2-a)/o),!0):([b,w,l,h,c,u]=_nt(yyt,this).subarray(0,6),_nt(myt,this).push(((b+5*l)/6-i)/s,((w+5*h)/6-a)/o,((5*l+c)/6-i)/s,((5*h+u)/6-a)/o,((l+c)/2-i)/s,((h+u)/2-a)/o),[c,u,l,h,b,w]=_nt(yyt,this).subarray(12,18),_nt(fyt,this).push(((b+5*l)/6-i)/s,((w+5*h)/6-a)/o,((5*l+c)/6-i)/s,((5*h+u)/6-a)/o,((l+c)/2-i)/s,((h+u)/2-a)/o),!0))}toSVGPath(){if(this.isEmpty())return"";var t=_nt(myt,this),e=_nt(fyt,this);if(isNaN(_nt(yyt,this)[6])&&!this.isEmpty())return bnt(Eyt,this,Cyt).call(this);var r=[];r.push("M".concat(t[4]," ").concat(t[5]));for(var n=6;n<t.length;n+=6)isNaN(t[n])?r.push("L".concat(t[n+4]," ").concat(t[n+5])):r.push("C".concat(t[n]," ").concat(t[n+1]," ").concat(t[n+2]," ").concat(t[n+3]," ").concat(t[n+4]," ").concat(t[n+5]));bnt(Eyt,this,Iyt).call(this,r);for(var i=e.length-6;i>=6;i-=6)isNaN(e[i])?r.push("L".concat(e[i+4]," ").concat(e[i+5])):r.push("C".concat(e[i]," ").concat(e[i+1]," ").concat(e[i+2]," ").concat(e[i+3]," ").concat(e[i+4]," ").concat(e[i+5]));return bnt(Eyt,this,Pyt).call(this,r),r.join(" ")}newFreeDrawOutline(t,e,r,n,i,a){return new Yyt(t,e,r,n,i,a)}getOutlines(){for(var t,e,r=_nt(myt,this),n=_nt(fyt,this),i=_nt(yyt,this),[a,s,o,l]=_nt(pyt,this),h=new Float32Array((null!==(t=null===(e=_nt(Syt,this))||void 0===e?void 0:e.length)&&void 0!==t?t:0)+2),c=0,u=h.length-2;c<u;c+=2)h[c]=(_nt(Syt,this)[c]-a)/o,h[c+1]=(_nt(Syt,this)[c+1]-s)/l;if(h[h.length-2]=(_nt(byt,this)-a)/o,h[h.length-1]=(_nt(wyt,this)-s)/l,isNaN(i[6])&&!this.isEmpty())return bnt(Eyt,this,Ryt).call(this,h);for(var d=new Float32Array(_nt(myt,this).length+24+_nt(fyt,this).length),p=r.length,f=0;f<p;f+=2)isNaN(r[f])?d[f]=d[f+1]=NaN:(d[f]=r[f],d[f+1]=r[f+1]);p=bnt(Eyt,this,Lyt).call(this,d,p);for(var g=n.length-6;g>=6;g-=6)for(var v=0;v<6;v+=2)isNaN(n[g+v])?(d[p]=d[p+1]=NaN,p+=2):(d[p]=n[g+v],d[p+1]=n[g+v+1],p+=2);return bnt(Eyt,this,Oyt).call(this,d,p),this.newFreeDrawOutline(d,h,_nt(pyt,this),_nt(_yt,this),_nt(gyt,this),_nt(vyt,this))}}function Tyt(){var t=_nt(yyt,this).subarray(4,6),e=_nt(yyt,this).subarray(16,18),[r,n,i,a]=_nt(pyt,this);return[(_nt(byt,this)+(t[0]-e[0])/2-r)/i,(_nt(wyt,this)+(t[1]-e[1])/2-n)/a,(_nt(byt,this)+(e[0]-t[0])/2-r)/i,(_nt(wyt,this)+(e[1]-t[1])/2-n)/a]}function Cyt(){var[t,e,r,n]=_nt(pyt,this),[i,a,s,o]=bnt(Eyt,this,Tyt).call(this);return"M".concat((_nt(yyt,this)[2]-t)/r," ").concat((_nt(yyt,this)[3]-e)/n," L").concat((_nt(yyt,this)[4]-t)/r," ").concat((_nt(yyt,this)[5]-e)/n," L").concat(i," ").concat(a," L").concat(s," ").concat(o," L").concat((_nt(yyt,this)[16]-t)/r," ").concat((_nt(yyt,this)[17]-e)/n," L").concat((_nt(yyt,this)[14]-t)/r," ").concat((_nt(yyt,this)[15]-e)/n," Z")}function Pyt(t){var e=_nt(fyt,this);t.push("L".concat(e[4]," ").concat(e[5]," Z"))}function Iyt(t){var[e,r,n,i]=_nt(pyt,this),a=_nt(yyt,this).subarray(4,6),s=_nt(yyt,this).subarray(16,18),[o,l,h,c]=bnt(Eyt,this,Tyt).call(this);t.push("L".concat((a[0]-e)/n," ").concat((a[1]-r)/i," L").concat(o," ").concat(l," L").concat(h," ").concat(c," L").concat((s[0]-e)/n," ").concat((s[1]-r)/i))}function Ryt(t){var e=_nt(yyt,this),[r,n,i,a]=_nt(pyt,this),[s,o,l,h]=bnt(Eyt,this,Tyt).call(this),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-r)/i,(e[3]-n)/a,NaN,NaN,NaN,NaN,(e[4]-r)/i,(e[5]-n)/a,NaN,NaN,NaN,NaN,s,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-r)/i,(e[17]-n)/a,NaN,NaN,NaN,NaN,(e[14]-r)/i,(e[15]-n)/a],0),this.newFreeDrawOutline(c,t,_nt(pyt,this),_nt(_yt,this),_nt(gyt,this),_nt(vyt,this))}function Oyt(t,e){var r=_nt(fyt,this);return t.set([NaN,NaN,NaN,NaN,r[4],r[5]],e),e+6}function Lyt(t,e){var r=_nt(yyt,this).subarray(4,6),n=_nt(yyt,this).subarray(16,18),[i,a,s,o]=_nt(pyt,this),[l,h,c,u]=bnt(Eyt,this,Tyt).call(this);return t.set([NaN,NaN,NaN,NaN,(r[0]-i)/s,(r[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,(n[0]-i)/s,(n[1]-a)/o],e),e+24}var Dyt={_:8},Fyt={_:Dyt._+2},Nyt=new WeakMap,jyt=new WeakMap,Byt=new WeakMap,zyt=new WeakMap,Wyt=new WeakMap,Uyt=new WeakMap,Hyt=new WeakMap,Gyt=new WeakSet;class Yyt extends dyt{constructor(t,e,r,n,i,a){super(),Mnt(this,Gyt),knt(this,Nyt,void 0),knt(this,jyt,new Float32Array(4)),knt(this,Byt,void 0),knt(this,zyt,void 0),knt(this,Wyt,void 0),knt(this,Uyt,void 0),knt(this,Hyt,void 0),Snt(Hyt,this,t),Snt(Wyt,this,e),Snt(Nyt,this,r),Snt(Uyt,this,n),Snt(Byt,this,i),Snt(zyt,this,a),this.lastPoint=[NaN,NaN],bnt(Gyt,this,Vyt).call(this,a);for(var[s,o,l,h]=_nt(jyt,this),c=0,u=t.length;c<u;c+=2)t[c]=(t[c]-s)/l,t[c+1]=(t[c+1]-o)/h;for(var d=0,p=e.length;d<p;d+=2)e[d]=(e[d]-s)/l,e[d+1]=(e[d+1]-o)/h}toSVGPath(){for(var t=["M".concat(_nt(Hyt,this)[4]," ").concat(_nt(Hyt,this)[5])],e=6,r=_nt(Hyt,this).length;e<r;e+=6)isNaN(_nt(Hyt,this)[e])?t.push("L".concat(_nt(Hyt,this)[e+4]," ").concat(_nt(Hyt,this)[e+5])):t.push("C".concat(_nt(Hyt,this)[e]," ").concat(_nt(Hyt,this)[e+1]," ").concat(_nt(Hyt,this)[e+2]," ").concat(_nt(Hyt,this)[e+3]," ").concat(_nt(Hyt,this)[e+4]," ").concat(_nt(Hyt,this)[e+5]));return t.push("Z"),t.join(" ")}serialize(t,e){var r,n,[i,a,s,o]=t,l=s-i,h=o-a;switch(e){case 0:r=dyt._rescale(_nt(Hyt,this),i,o,l,-h),n=dyt._rescale(_nt(Wyt,this),i,o,l,-h);break;case 90:r=dyt._rescaleAndSwap(_nt(Hyt,this),i,a,l,h),n=dyt._rescaleAndSwap(_nt(Wyt,this),i,a,l,h);break;case 180:r=dyt._rescale(_nt(Hyt,this),s,a,-l,h),n=dyt._rescale(_nt(Wyt,this),s,a,-l,h);break;case 270:r=dyt._rescaleAndSwap(_nt(Hyt,this),s,o,-l,-h),n=dyt._rescaleAndSwap(_nt(Wyt,this),s,o,-l,-h)}return{outline:Array.from(r),points:[Array.from(n)]}}get box(){return _nt(jyt,this)}newOutliner(t,e,r,n,i){return new Myt(t,e,r,n,i,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}getNewOutline(t,e){for(var[r,n,i,a]=_nt(jyt,this),[s,o,l,h]=_nt(Nyt,this),c=i*l,u=a*h,d=r*l+s,p=n*h+o,f=this.newOutliner({x:_nt(Wyt,this)[0]*c+d,y:_nt(Wyt,this)[1]*u+p},_nt(Nyt,this),_nt(Uyt,this),t,_nt(zyt,this),null!=e?e:_nt(Byt,this)),g=2;g<_nt(Wyt,this).length;g+=2)f.add({x:_nt(Wyt,this)[g]*c+d,y:_nt(Wyt,this)[g+1]*u+p});return f.getOutlines()}}function Vyt(t){for(var e=_nt(Hyt,this),r=e[4],n=e[5],i=r,a=n,s=r,o=n,l=r,h=n,c=t?Math.max:Math.min,u=6,d=e.length;u<d;u+=6){if(isNaN(e[u]))i=Math.min(i,e[u+4]),a=Math.min(a,e[u+5]),s=Math.max(s,e[u+4]),o=Math.max(o,e[u+5]),h<e[u+5]?(l=e[u+4],h=e[u+5]):h===e[u+5]&&(l=c(l,e[u+4]));else{var p=alt.bezierBoundingBox(r,n,...e.slice(u,u+6));i=Math.min(i,p[0]),a=Math.min(a,p[1]),s=Math.max(s,p[2]),o=Math.max(o,p[3]),h<p[3]?(l=p[2],h=p[3]):h===p[3]&&(l=c(l,p[2]))}r=e[u+4],n=e[u+5]}var f=_nt(jyt,this);f[0]=i-_nt(Byt,this),f[1]=a-_nt(Byt,this),f[2]=s-i+2*_nt(Byt,this),f[3]=o-a+2*_nt(Byt,this),this.lastPoint=[l,h]}var qyt=new WeakMap,Xyt=new WeakMap,$yt=new WeakMap,Kyt=new WeakMap,Qyt=new WeakSet;class Jyt{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];Mnt(this,Qyt),knt(this,qyt,void 0),knt(this,Xyt,void 0),knt(this,$yt,[]),knt(this,Kyt,[]);var i=1/0,a=-1/0,s=1/0,o=-1/0,l=Math.pow(10,-4);for(var{x:h,y:c,width:u,height:d}of t){var p=Math.floor((h-e)/l)*l,f=Math.ceil((h+u+e)/l)*l,g=Math.floor((c-e)/l)*l,v=Math.ceil((c+d+e)/l)*l,m=[p,g,v,!0],y=[f,g,v,!1];_nt($yt,this).push(m,y),i=Math.min(i,p),a=Math.max(a,f),s=Math.min(s,g),o=Math.max(o,v)}var b=a-i+2*r,w=o-s+2*r,x=i-r,A=s-r,_=_nt($yt,this).at(n?-1:-2),k=[_[0],_[2]];for(var S of _nt($yt,this)){var[E,M,T]=S;S[0]=(E-x)/b,S[1]=(M-A)/w,S[2]=(T-A)/w}Snt(qyt,this,new Float32Array([x,A,b,w])),Snt(Xyt,this,k)}getOutlines(){_nt($yt,this).sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));var t=[];for(var e of _nt($yt,this))e[3]?(t.push(...bnt(Qyt,this,nbt).call(this,e)),bnt(Qyt,this,ebt).call(this,e)):(bnt(Qyt,this,rbt).call(this,e),t.push(...bnt(Qyt,this,nbt).call(this,e)));return bnt(Qyt,this,Zyt).call(this,t)}}function Zyt(t){var e=[],r=new Set;for(var n of t){var[i,a,s]=n;e.push([i,a,n],[i,s,n])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(var o=0,l=e.length;o<l;o+=2){var h=e[o][2],c=e[o+1][2];h.push(c),c.push(h),r.add(h),r.add(c)}for(var u,d=[];r.size>0;){var p=r.values().next().value,[f,g,v,m,y]=p;r.delete(p);var b=f,w=g;for(u=[f,v],d.push(u);;){var x=void 0;if(r.has(m))x=m;else{if(!r.has(y))break;x=y}r.delete(x),[f,g,v,m,y]=x,b!==f&&(u.push(b,w,f,w===g?g:v),b=f),w=w===g?v:g}u.push(b,w)}return new sbt(d,_nt(qyt,this),_nt(Xyt,this))}function tbt(t){for(var e=_nt(Kyt,this),r=0,n=e.length-1;r<=n;){var i=r+n>>1,a=e[i][0];if(a===t)return i;a<t?r=i+1:n=i-1}return n+1}function ebt(t){var[,e,r]=t,n=bnt(Qyt,this,tbt).call(this,e);_nt(Kyt,this).splice(n,0,[e,r])}function rbt(t){for(var[,e,r]=t,n=bnt(Qyt,this,tbt).call(this,e),i=n;i<_nt(Kyt,this).length;i++){var[a,s]=_nt(Kyt,this)[i];if(a!==e)break;if(a===e&&s===r)return void _nt(Kyt,this).splice(i,1)}for(var o=n-1;o>=0;o--){var[l,h]=_nt(Kyt,this)[o];if(l!==e)break;if(l===e&&h===r)return void _nt(Kyt,this).splice(o,1)}}function nbt(t){for(var[e,r,n]=t,i=[[e,r,n]],a=bnt(Qyt,this,tbt).call(this,n),s=0;s<a;s++)for(var[o,l]=_nt(Kyt,this)[s],h=0,c=i.length;h<c;h++){var[,u,d]=i[h];if(!(l<=u||d<=o))if(u>=o)if(d>l)i[h][1]=l;else{if(1===c)return[];i.splice(h,1),h--,c--}else i[h][2]=o,d>l&&i.push([e,l,d])}return i}var ibt=new WeakMap,abt=new WeakMap;class sbt extends dyt{constructor(t,e,r){super(),knt(this,ibt,void 0),knt(this,abt,void 0),Snt(abt,this,t),Snt(ibt,this,e),this.lastPoint=r}toSVGPath(){var t=[];for(var e of _nt(abt,this)){var[r,n]=e;t.push("M".concat(r," ").concat(n));for(var i=2;i<e.length;i+=2){var a=e[i],s=e[i+1];a===r?(t.push("V".concat(s)),n=s):s===n&&(t.push("H".concat(a)),r=a)}t.push("Z")}return t.join(" ")}serialize(t,e){var[r,n,i,a]=t,s=[],o=i-r,l=a-n;for(var h of _nt(abt,this)){for(var c=new Array(h.length),u=0;u<h.length;u+=2)c[u]=r+h[u]*o,c[u+1]=a-h[u+1]*l;s.push(c)}return s}get box(){return _nt(ibt,this)}get classNamesForOutlining(){return["highlightOutline"]}}class obt extends Myt{newFreeDrawOutline(t,e,r,n,i,a){return new lbt(t,e,r,n,i,a)}}class lbt extends Yyt{newOutliner(t,e,r,n,i){return new obt(t,e,r,n,i,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}}var hbt=new WeakMap,cbt=new WeakMap,ubt=new WeakMap,dbt=new WeakMap,pbt=new WeakMap,fbt=new WeakMap,gbt=new WeakMap,vbt=new WeakMap,mbt=new WeakMap,ybt=new WeakMap,bbt=new WeakMap,wbt=new WeakSet;class xbt{static get _keyboardManager(){return Yot(this,"_keyboardManager",new yht([[["Escape","mac+Escape"],xbt.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],xbt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],xbt.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],xbt.prototype._moveToPrevious],[["Home","mac+Home"],xbt.prototype._moveToBeginning],[["End","mac+End"],xbt.prototype._moveToEnd]]))}constructor(t){var e,{editor:r=null,uiManager:n=null}=t;Mnt(this,wbt),knt(this,hbt,null),knt(this,cbt,null),knt(this,ubt,void 0),knt(this,dbt,null),knt(this,pbt,!1),knt(this,fbt,!1),knt(this,gbt,null),knt(this,vbt,void 0),knt(this,mbt,null),knt(this,ybt,null),knt(this,bbt,void 0),r?(Snt(fbt,this,!1),Snt(bbt,this,rot.HIGHLIGHT_COLOR),Snt(gbt,this,r)):(Snt(fbt,this,!0),Snt(bbt,this,rot.HIGHLIGHT_DEFAULT_COLOR)),Snt(ybt,this,(null==r?void 0:r._uiManager)||n),Snt(vbt,this,_nt(ybt,this)._eventBus),Snt(ubt,this,(null==r?void 0:r.color)||(null===(e=_nt(ybt,this))||void 0===e?void 0:e.highlightColors.values().next().value)||"#FFFF98"),Tbt._||(Tbt._=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}renderButton(){var t=Snt(hbt,this,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);var e=_nt(ybt,this)._signal;t.addEventListener("click",bnt(wbt,this,Sbt).bind(this),{signal:e}),t.addEventListener("keydown",bnt(wbt,this,kbt).bind(this),{signal:e});var r=Snt(cbt,this,document.createElement("span"));return r.className="swatch",r.setAttribute("aria-hidden",!0),r.style.backgroundColor=_nt(ubt,this),t.append(r),t}renderMainDropdown(){var t=Snt(dbt,this,bnt(wbt,this,Abt).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target!==_nt(hbt,this)){var e=t.target.getAttribute("data-color");e&&bnt(wbt,this,_bt).call(this,e,t)}else bnt(wbt,this,Sbt).call(this,t)}_moveToNext(t){var e,r;Ent(wbt,this,Mbt)?t.target!==_nt(hbt,this)?null===(e=t.target.nextSibling)||void 0===e||e.focus():null===(r=_nt(dbt,this).firstChild)||void 0===r||r.focus():bnt(wbt,this,Sbt).call(this,t)}_moveToPrevious(t){var e,r;t.target!==(null===(e=_nt(dbt,this))||void 0===e?void 0:e.firstChild)&&t.target!==_nt(hbt,this)?(Ent(wbt,this,Mbt)||bnt(wbt,this,Sbt).call(this,t),null===(r=t.target.previousSibling)||void 0===r||r.focus()):Ent(wbt,this,Mbt)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;Ent(wbt,this,Mbt)?null===(e=_nt(dbt,this).firstChild)||void 0===e||e.focus():bnt(wbt,this,Sbt).call(this,t)}_moveToEnd(t){var e;Ent(wbt,this,Mbt)?null===(e=_nt(dbt,this).lastChild)||void 0===e||e.focus():bnt(wbt,this,Sbt).call(this,t)}hideDropdown(){var t,e;null===(t=_nt(dbt,this))||void 0===t||t.classList.add("hidden"),null===(e=_nt(mbt,this))||void 0===e||e.abort(),Snt(mbt,this,null)}_hideDropdownFromKeyboard(){var t;_nt(fbt,this)||(Ent(wbt,this,Mbt)?(this.hideDropdown(),_nt(hbt,this).focus({preventScroll:!0,focusVisible:_nt(pbt,this)})):null===(t=_nt(gbt,this))||void 0===t||t.unselect())}updateColor(t){if(_nt(cbt,this)&&(_nt(cbt,this).style.backgroundColor=t),_nt(dbt,this)){var e=_nt(ybt,this).highlightColors.values();for(var r of _nt(dbt,this).children)r.setAttribute("aria-selected",e.next().value===t)}}destroy(){var t,e;null===(t=_nt(hbt,this))||void 0===t||t.remove(),Snt(hbt,this,null),Snt(cbt,this,null),null===(e=_nt(dbt,this))||void 0===e||e.remove(),Snt(dbt,this,null)}}function Abt(){var t=document.createElement("div"),e=_nt(ybt,this)._signal;for(var[r,n]of(t.addEventListener("contextmenu",klt,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),_nt(ybt,this).highlightColors)){var i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",n),i.title=r,i.setAttribute("data-l10n-id",Tbt._[r]);var a=document.createElement("span");i.append(a),a.className="swatch",a.style.backgroundColor=n,i.setAttribute("aria-selected",n===_nt(ubt,this)),i.addEventListener("click",bnt(wbt,this,_bt).bind(this,n),{signal:e}),t.append(i)}return t.addEventListener("keydown",bnt(wbt,this,kbt).bind(this),{signal:e}),t}function _bt(t,e){e.stopPropagation(),_nt(vbt,this).dispatch("switchannotationeditorparams",{source:this,type:_nt(bbt,this),value:t})}function kbt(t){Ost._keyboardManager.exec(this,t)}function Sbt(t){if(Ent(wbt,this,Mbt))this.hideDropdown();else if(Snt(pbt,this,0===t.detail),_nt(mbt,this)||(Snt(mbt,this,new AbortController),window.addEventListener("pointerdown",bnt(wbt,this,Ebt).bind(this),{signal:_nt(ybt,this).combinedSignal(_nt(mbt,this))})),_nt(dbt,this))_nt(dbt,this).classList.remove("hidden");else{var e=Snt(dbt,this,bnt(wbt,this,Abt).call(this));_nt(hbt,this).append(e)}}function Ebt(t){var e;null!==(e=_nt(dbt,this))&&void 0!==e&&e.contains(t.target)||this.hideDropdown()}function Mbt(t){return _nt(dbt,t)&&!_nt(dbt,t).classList.contains("hidden")}Ost=xbt;var Tbt={_:null},Cbt=new WeakMap,Pbt=new WeakMap,Ibt=new WeakMap,Rbt=new WeakMap,Obt=new WeakMap,Lbt=new WeakMap,Dbt=new WeakMap,Fbt=new WeakMap,Nbt=new WeakMap,jbt=new WeakMap,Bbt=new WeakMap,zbt=new WeakMap,Wbt=new WeakMap,Ubt=new WeakMap,Hbt=new WeakMap,Gbt=new WeakMap,Ybt=new WeakMap,Vbt=new WeakMap,qbt=new WeakSet;class Xbt extends jut{static get _keyboardManager(){var t=Xbt.prototype;return Yot(this,"_keyboardManager",new yht([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super(Pnt(Pnt({},t),{},{name:"highlightEditor"})),Mnt(this,qbt),knt(this,Cbt,null),knt(this,Pbt,0),knt(this,Ibt,void 0),knt(this,Rbt,null),knt(this,Obt,null),knt(this,Lbt,null),knt(this,Dbt,null),knt(this,Fbt,0),knt(this,Nbt,null),knt(this,jbt,null),knt(this,Bbt,null),knt(this,zbt,!1),knt(this,Wbt,null),knt(this,Ubt,void 0),knt(this,Hbt,null),knt(this,Gbt,""),knt(this,Ybt,void 0),knt(this,Vbt,""),this.color=t.color||Xbt._defaultColor,Snt(Ybt,this,t.thickness||Xbt._defaultThickness),Snt(Ubt,this,t.opacity||Xbt._defaultOpacity),Snt(Ibt,this,t.boxes||null),Snt(Vbt,this,t.methodOfCreation||""),Snt(Gbt,this,t.text||""),this._isDraggable=!1,t.highlightId>-1?(Snt(zbt,this,!0),bnt(qbt,this,Kbt).call(this,t),bnt(qbt,this,ewt).call(this)):_nt(Ibt,this)&&(Snt(Cbt,this,t.anchorNode),Snt(Pbt,this,t.anchorOffset),Snt(Dbt,this,t.focusNode),Snt(Fbt,this,t.focusOffset),bnt(qbt,this,$bt).call(this),bnt(qbt,this,ewt).call(this),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:_nt(zbt,this)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:_nt(Ybt,this),methodOfCreation:_nt(Vbt,this)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,e){var r;jut.initialize(t,e),Xbt._defaultColor||(Xbt._defaultColor=(null===(r=e.highlightColors)||void 0===r?void 0:r.values().next().value)||"#fff066")}static updateDefaultParams(t,e){switch(t){case rot.HIGHLIGHT_DEFAULT_COLOR:Xbt._defaultColor=e;break;case rot.HIGHLIGHT_THICKNESS:Xbt._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return _nt(Wbt,this)}updateParams(t,e){switch(t){case rot.HIGHLIGHT_COLOR:bnt(qbt,this,Qbt).call(this,e);break;case rot.HIGHLIGHT_THICKNESS:bnt(qbt,this,Jbt).call(this,e)}}static get defaultPropertiesToUpdate(){return[[rot.HIGHLIGHT_DEFAULT_COLOR,Xbt._defaultColor],[rot.HIGHLIGHT_THICKNESS,Xbt._defaultThickness]]}get propertiesToUpdate(){return[[rot.HIGHLIGHT_COLOR,this.color||Xbt._defaultColor],[rot.HIGHLIGHT_THICKNESS,_nt(Ybt,this)||Xbt._defaultThickness],[rot.HIGHLIGHT_FREE,_nt(zbt,this)]]}addEditToolbar(){var t=()=>super.addEditToolbar,e=this;return xnt((function*(){var r=yield t().call(e);return r?(e._uiManager.highlightColors&&(Snt(Obt,e,new xbt({editor:e})),r.addColorPicker(_nt(Obt,e))),r):null}))()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(bnt(qbt,this,awt).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,bnt(qbt,this,awt).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){bnt(qbt,this,twt).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(bnt(qbt,this,ewt).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e=!1;if(this.parent&&!t)bnt(qbt,this,twt).call(this);else if(t){var r;bnt(qbt,this,ewt).call(this,t),e=!this.parent&&(null===(r=this.div)||void 0===r?void 0:r.classList.contains("selectedEditor"))}super.setParent(t),this.show(this._isVisible),e&&this.select()}rotate(t){var e,{drawLayer:r}=this.parent;_nt(zbt,this)?(t=(t-this.rotation+360)%360,e=rwt.call(Xbt,_nt(jbt,this).box,t)):e=rwt.call(Xbt,[this.x,this.y,this.width,this.height],t),r.updateProperties(_nt(Bbt,this),{bbox:e,root:{"data-main-rotation":t}}),r.updateProperties(_nt(Hbt,this),{bbox:rwt.call(Xbt,_nt(Lbt,this).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;var t=super.render();_nt(Gbt,this)&&(t.setAttribute("aria-label",_nt(Gbt,this)),t.setAttribute("role","mark")),_nt(zbt,this)?t.classList.add("free"):this.div.addEventListener("keydown",bnt(qbt,this,nwt).bind(this),{signal:this._uiManager._signal});var e=Snt(Nbt,this,document.createElement("div"));t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=_nt(Rbt,this);var[r,n]=this.parentDimensions;return this.setDims(this.width*r,this.height*n),rht(this,_nt(Nbt,this),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(_nt(Hbt,this),{rootClass:{hovered:!0}}))}pointerleave(){var t;this.isSelected||(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(_nt(Hbt,this),{rootClass:{hovered:!1}}))}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:bnt(qbt,this,iwt).call(this,!0);break;case 1:case 3:bnt(qbt,this,iwt).call(this,!1)}}select(){var t;super.select(),_nt(Hbt,this)&&(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(_nt(Hbt,this),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),_nt(Hbt,this)&&(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(_nt(Hbt,this),{rootClass:{selected:!1}}),_nt(zbt,this)||bnt(qbt,this,iwt).call(this,!1))}get _mustFixPosition(){return!_nt(zbt,this)}show(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(_nt(Bbt,this),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(_nt(Hbt,this),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,r){var{target:n,x:i,y:a}=r,{x:s,y:o,width:l,height:h}=n.getBoundingClientRect(),c=new AbortController,u=t.combinedSignal(c),d=e=>{c.abort(),bnt(Xbt,this,hwt).call(this,t,e)};window.addEventListener("blur",d,{signal:u}),window.addEventListener("pointerup",d,{signal:u}),window.addEventListener("pointerdown",Slt,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",klt,{signal:u}),n.addEventListener("pointermove",bnt(Xbt,this,lwt).bind(this,t),{signal:u}),this._freeHighlight=new obt({x:i,y:a},[s,o,l,h],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return xnt((function*(){var a=null;if(t instanceof Imt){var{data:{quadPoints:s,rect:o,rotation:l,id:h,color:c,opacity:u,popupRef:d},parent:{page:{pageNumber:p}}}=t;a=t={annotationType:eot.HIGHLIGHT,color:Array.from(c),opacity:u,quadPoints:s,boxes:null,pageIndex:p-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,popupRef:d}}else if(t instanceof Cmt){var{data:{inkLists:f,rect:g,rotation:v,id:m,color:y,borderStyle:{rawWidth:b},popupRef:w},parent:{page:{pageNumber:x}}}=t;a=t={annotationType:eot.HIGHLIGHT,color:Array.from(y),thickness:b,inkLists:f,boxes:null,pageIndex:x-1,rect:g.slice(0),rotation:v,id:m,deleted:!1,popupRef:w}}var{color:A,quadPoints:_,inkLists:k,opacity:S}=t,E=yield n().call(i,t,e,r);E.color=alt.makeHexColor(...A),Snt(Ubt,E,S||1),k&&Snt(Ybt,E,t.thickness),E.annotationElementId=t.id||null,E._initialData=a;var[M,T]=E.pageDimensions,[C,P]=E.pageTranslation;if(_){for(var I=Snt(Ibt,E,[]),R=0;R<_.length;R+=8)I.push({x:(_[R]-C)/M,y:1-(_[R+1]-P)/T,width:(_[R+2]-_[R])/M,height:(_[R+1]-_[R+5])/T});bnt(qbt,E,$bt).call(E),bnt(qbt,E,ewt).call(E),E.rotate(E.rotation)}else if(k){Snt(zbt,E,!0);for(var O=k[0],L={x:O[0]-C,y:T-(O[1]-P)},D=new obt(L,[0,0,M,T],1,_nt(Ybt,E)/2,!0,.001),F=0,N=O.length;F<N;F+=2)L.x=O[F]-C,L.y=T-(O[F+1]-P),D.add(L);var{id:j,clipPathId:B}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:E.color,"fill-opacity":E._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:D.toSVGPath()}},!0,!0);bnt(qbt,E,Kbt).call(E,{highlightOutlines:D.getOutlines(),highlightId:j,clipPathId:B}),bnt(qbt,E,ewt).call(E)}return E}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();var e=this.getRect(0,0),r=jut._colorManager.convert(this.color),n={annotationType:eot.HIGHLIGHT,color:r,opacity:_nt(Ubt,this),thickness:_nt(Ybt,this),quadPoints:bnt(qbt,this,swt).call(this),outlines:bnt(qbt,this,owt).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:bnt(qbt,this,awt).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!bnt(qbt,this,cwt).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}function $bt(){var t=new Jyt(_nt(Ibt,this),.001);Snt(jbt,this,t.getOutlines()),[this.x,this.y,this.width,this.height]=_nt(jbt,this).box;var e=new Jyt(_nt(Ibt,this),.0025,.001,"ltr"===this._uiManager.direction);Snt(Lbt,this,e.getOutlines());var{lastPoint:r}=_nt(Lbt,this);Snt(Wbt,this,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])}function Kbt(t){var{highlightOutlines:e,highlightId:r,clipPathId:n}=t;Snt(jbt,this,e);if(Snt(Lbt,this,e.getNewOutline(_nt(Ybt,this)/2+1.5,.0025)),r>=0)Snt(Bbt,this,r),Snt(Rbt,this,n),this.parent.drawLayer.finalizeDraw(r,{bbox:e.box,path:{d:e.toSVGPath()}}),Snt(Hbt,this,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:_nt(Lbt,this).box,path:{d:_nt(Lbt,this).toSVGPath()}},!0));else if(this.parent){var i=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(_nt(Bbt,this),{bbox:rwt.call(Lst,_nt(jbt,this).box,(i-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(_nt(Hbt,this),{bbox:rwt.call(Lst,_nt(Lbt,this).box,i),path:{d:_nt(Lbt,this).toSVGPath()}})}var[a,s,o,l]=e.box;switch(this.rotation){case 0:this.x=a,this.y=s,this.width=o,this.height=l;break;case 90:var[h,c]=this.parentDimensions;this.x=s,this.y=1-a,this.width=o*c/h,this.height=l*h/c;break;case 180:this.x=1-a,this.y=1-s,this.width=o,this.height=l;break;case 270:var[u,d]=this.parentDimensions;this.x=1-s,this.y=a,this.width=o*d/u,this.height=l*u/d}var{lastPoint:p}=_nt(Lbt,this);Snt(Wbt,this,[(p[0]-a)/o,(p[1]-s)/l])}function Qbt(t){var e=(t,e)=>{var r,n;this.color=t,Snt(Ubt,this,e),null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(_nt(Bbt,this),{root:{fill:t,"fill-opacity":e}}),null===(n=_nt(Obt,this))||void 0===n||n.updateColor(t)},r=this.color,n=_nt(Ubt,this);this.addCommands({cmd:e.bind(this,t,Lst._defaultOpacity),undo:e.bind(this,r,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rot.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}function Jbt(t){var e=_nt(Ybt,this),r=t=>{Snt(Ybt,this,t),bnt(qbt,this,Zbt).call(this,t)};this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rot.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}function Zbt(t){if(_nt(zbt,this)){bnt(qbt,this,Kbt).call(this,{highlightOutlines:_nt(jbt,this).getNewOutline(t/2)}),this.fixAndSetPosition();var[e,r]=this.parentDimensions;this.setDims(this.width*e,this.height*r)}}function twt(){null!==_nt(Bbt,this)&&this.parent&&(this.parent.drawLayer.remove(_nt(Bbt,this)),Snt(Bbt,this,null),this.parent.drawLayer.remove(_nt(Hbt,this)),Snt(Hbt,this,null))}function ewt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null===_nt(Bbt,this)&&(({id:Int(Snt,[Bbt,this])._,clipPathId:Int(Snt,[Rbt,this])._}=t.drawLayer.draw({bbox:_nt(jbt,this).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":_nt(Ubt,this)},rootClass:{highlight:!0,free:_nt(zbt,this)},path:{d:_nt(jbt,this).toSVGPath()}},!1,!0)),Snt(Hbt,this,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:_nt(zbt,this)},bbox:_nt(Lbt,this).box,path:{d:_nt(Lbt,this).toSVGPath()}},_nt(zbt,this))),_nt(Nbt,this)&&(_nt(Nbt,this).style.clipPath=_nt(Rbt,this)))}function rwt(t,e){var[r,n,i,a]=t;switch(e){case 90:return[1-n-a,r,a,i];case 180:return[1-r-i,1-n-a,i,a];case 270:return[n,1-r-i,a,i]}return[r,n,i,a]}function nwt(t){Lst._keyboardManager.exec(this,t)}function iwt(t){if(_nt(Cbt,this)){var e=window.getSelection();t?e.setPosition(_nt(Cbt,this),_nt(Pbt,this)):e.setPosition(_nt(Dbt,this),_nt(Fbt,this))}}function awt(){return _nt(zbt,this)?this.rotation:0}function swt(){if(_nt(zbt,this))return null;var[t,e]=this.pageDimensions,[r,n]=this.pageTranslation,i=_nt(Ibt,this),a=new Float32Array(8*i.length),s=0;for(var{x:o,y:l,width:h,height:c}of i){var u=o*t+r,d=(1-l)*e+n;a[s]=a[s+4]=u,a[s+1]=a[s+3]=d,a[s+2]=a[s+6]=u+h*t,a[s+5]=a[s+7]=d-c*e,s+=8}return a}function owt(t){return _nt(jbt,this).serialize(t,bnt(qbt,this,awt).call(this))}function lwt(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}function hwt(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}function cwt(t){var{color:e}=this._initialData;return t.color.some(((t,r)=>t!==e[r]))}Lst=Xbt,Tnt(Xbt,"_defaultColor",null),Tnt(Xbt,"_defaultOpacity",1),Tnt(Xbt,"_defaultThickness",12),Tnt(Xbt,"_type","highlight"),Tnt(Xbt,"_editorType",eot.HIGHLIGHT),Tnt(Xbt,"_freeHighlightId",-1),Tnt(Xbt,"_freeHighlight",null),Tnt(Xbt,"_freeHighlightClipId","");var uwt=new WeakMap;class dwt{constructor(){knt(this,uwt,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(var[e,r]of Object.entries(t))this.updateProperty(e,r)}updateSVGProperty(t,e){_nt(uwt,this)[t]=e}toSVGProperties(){var t=_nt(uwt,this);return Snt(uwt,this,Object.create(null)),{root:t}}reset(){Snt(uwt,this,Object.create(null))}updateAll(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this;this.updateProperties(t)}clone(){Uot("Not implemented")}}var pwt=new WeakMap,fwt=new WeakMap,gwt=new WeakSet;class vwt extends jut{constructor(t){super(t),Mnt(this,gwt),knt(this,pwt,null),knt(this,fwt,void 0),Tnt(this,"_drawId",null),Snt(fwt,this,t.mustBeCommitted||!1),t.drawOutlines&&(bnt(gwt,this,mwt).call(this,t),bnt(gwt,this,wwt).call(this))}static _mergeSVGProperties(t,e){var r=new Set(Object.keys(t));for(var[n,i]of Object.entries(e))r.has(n)?Object.assign(t[n],i):t[n]=i;return t}static getDefaultDrawingOptions(t){Uot("Not implemented")}static get typesMap(){Uot("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){var r=this.typesMap.get(t);r&&this._defaultDrawingOptions.updateProperty(r,e),this._currentParent&&(Swt._.updateProperty(r,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){var r=this.constructor.typesMap.get(t);r&&this._updateProperty(t,r,e)}static get defaultPropertiesToUpdate(){var t=[],e=this._defaultDrawingOptions;for(var[r,n]of this.typesMap)t.push([r,e[n]]);return t}get propertiesToUpdate(){var t=[],{_drawingOptions:e}=this;for(var[r,n]of this.constructor.typesMap)t.push([r,e[n]]);return t}_updateProperty(t,e,r){var n=this._drawingOptions,i=n[e],a=t=>{var r;n.updateProperty(e,t);var i=_nt(pwt,this).updateProperty(e,t);i&&bnt(gwt,this,_wt).call(this,i),null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(this._drawId,n.toSVGProperties())};this.addCommands({cmd:a.bind(this,r),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,vwt._mergeSVGProperties(_nt(pwt,this).getPathResizingSVGProperties(bnt(gwt,this,Awt).call(this)),{bbox:bnt(gwt,this,kwt).call(this)}))}_onResized(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,vwt._mergeSVGProperties(_nt(pwt,this).getPathResizedSVGProperties(bnt(gwt,this,Awt).call(this)),{bbox:bnt(gwt,this,kwt).call(this)}))}_onTranslating(t,e){var r;null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(this._drawId,{bbox:bnt(gwt,this,kwt).call(this,t,e)})}_onTranslated(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,vwt._mergeSVGProperties(_nt(pwt,this).getPathTranslatedSVGProperties(bnt(gwt,this,Awt).call(this),this.parentDimensions),{bbox:bnt(gwt,this,kwt).call(this)}))}_onStartDragging(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,_nt(fwt,this)&&(Snt(fwt,this,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){bnt(gwt,this,bwt).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(bnt(gwt,this,wwt).call(this),bnt(gwt,this,_wt).call(this,_nt(pwt,this).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e=!1;if(this.parent&&!t)this._uiManager.removeShouldRescale(this),bnt(gwt,this,bwt).call(this);else if(t){var r;this._uiManager.addShouldRescale(this),bnt(gwt,this,wwt).call(this,t),e=!this.parent&&(null===(r=this.div)||void 0===r?void 0:r.classList.contains("selectedEditor"))}super.setParent(t),e&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,vwt._mergeSVGProperties({bbox:bnt(gwt,this,kwt).call(this)},_nt(pwt,this).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&bnt(gwt,this,_wt).call(this,_nt(pwt,this).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;var t=super.render();t.classList.add("draw");var e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";var[r,n]=this.parentDimensions;return this.setDims(this.width*r,this.height*n),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,r,n,i){Uot("Not implemented")}static startDrawing(t,e,r,n){var i,a,{target:s,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=n;if(!Cwt._||Cwt._===c){var{viewport:{rotation:u}}=t,{width:d,height:p}=s.getBoundingClientRect(),f=Ewt._=new AbortController,g=t.combinedSignal(f);Twt._||(Twt._=h),null!==(i=Cwt._)&&void 0!==i||(Cwt._=c),window.addEventListener("pointerup",(t=>{var e;Twt._===t.pointerId?this._endDraw(t):null===(e=Pwt._)||void 0===e||e.delete(t.pointerId)}),{signal:g}),window.addEventListener("pointercancel",(t=>{var e;Twt._===t.pointerId?this._currentParent.endDrawingSession():null===(e=Pwt._)||void 0===e||e.delete(t.pointerId)}),{signal:g}),window.addEventListener("pointerdown",(t=>{Cwt._===t.pointerType&&((Pwt._||(Pwt._=new Set)).add(t.pointerId),Swt._.isCancellable()&&(Swt._.removeLastElement(),Swt._.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",klt,{signal:g}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),s.addEventListener("touchmove",(t=>{t.timeStamp===Iwt._&&Slt(t)}),{signal:g}),t.toggleDrawing(),null===(a=e._editorUndoBar)||void 0===a||a.hide(),Swt._?t.drawLayer.updateProperties(this._currentDrawId,Swt._.startNew(o,l,d,p,u)):(e.updateUIForDefaultProperties(this),Swt._=this.createDrawerInstance(o,l,d,p,u),Mwt._=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(Mwt._.toSVGProperties(),Swt._.defaultSVGProperties),!0,!1)))}}static _drawMove(t){var e;if(Iwt._=-1,Swt._){var{offsetX:r,offsetY:n,pointerId:i}=t;Twt._===i&&((null===(e=Pwt._)||void 0===e?void 0:e.size)>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Swt._.add(r,n)),Iwt._=t.timeStamp,Slt(t)))}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,Swt._=null,Mwt._=null,Cwt._=null,Iwt._=NaN),Ewt._&&(Ewt._.abort(),Ewt._=null,Twt._=NaN,Pwt._=null)}static _endDraw(t){var e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,Swt._.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){var r=Swt._,n=this._currentDrawId,i=r.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(n,r.setLastElement(i))},undo:()=>{e.drawLayer.updateProperties(n,r.removeLastElement())},mustExec:!1,type:rot.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){var e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(rot.DRAW_STEP),!Swt._.isEmpty()){var{pageDimensions:[r,n],scale:i}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Swt._.getOutlines(r*i,n*i,i,this._INNER_MARGIN),drawingOptions:Mwt._,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,r,n,i,a){Uot("Not implemented")}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return xnt((function*(){var{rawDims:{pageWidth:a,pageHeight:s,pageX:o,pageY:l}}=e.viewport,h=i.deserializeDraw(o,l,a,s,i._INNER_MARGIN,t),c=yield n().call(i,t,e,r);return c.createDrawingOptions(t),bnt(gwt,c,mwt).call(c,{drawOutlines:h}),bnt(gwt,c,wwt).call(c),c.onScaleChanging(),c.rotate(),c}))()}serializeDraw(t){var[e,r]=this.pageTranslation,[n,i]=this.pageDimensions;return _nt(pwt,this).serialize([e,r,n,i],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}function mwt(t){var{drawOutlines:e,drawId:r,drawingOptions:n}=t;Snt(pwt,this,e),this._drawingOptions||(this._drawingOptions=n),r>=0?(this._drawId=r,this.parent.drawLayer.finalizeDraw(r,e.defaultProperties)):this._drawId=bnt(gwt,this,ywt).call(this,e,this.parent),bnt(gwt,this,_wt).call(this,e.box)}function ywt(t,e){var{id:r}=e.drawLayer.draw(Dst._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return r}function bwt(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}function wwt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=bnt(gwt,this,ywt).call(this,_nt(pwt,this),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}function xwt(t){var[e,r,n,i]=t,{parentDimensions:[a,s],rotation:o}=this;switch(o){case 90:return[r,1-e,n*(s/a),i*(a/s)];case 180:return[1-e,1-r,n,i];case 270:return[1-r,e,n*(s/a),i*(a/s)];default:return[e,r,n,i]}}function Awt(){var{x:t,y:e,width:r,height:n,parentDimensions:[i,a],rotation:s}=this;switch(s){case 90:return[1-e,t,r*(i/a),n*(a/i)];case 180:return[1-t,1-e,r,n];case 270:return[e,1-t,r*(i/a),n*(a/i)];default:return[t,e,r,n]}}function _wt(t){if([this.x,this.y,this.width,this.height]=bnt(gwt,this,xwt).call(this,t),this.div){this.fixAndSetPosition();var[e,r]=this.parentDimensions;this.setDims(this.width*e,this.height*r)}this._onResized()}function kwt(){var{x:t,y:e,width:r,height:n,rotation:i,parentRotation:a,parentDimensions:[s,o]}=this;switch((4*i+a)/90){case 1:return[1-e-n,t,n,r];case 2:return[1-t-r,1-e-n,r,n];case 3:return[e,1-t-r,n,r];case 4:return[t,e-r*(s/o),n*(o/s),r*(s/o)];case 5:return[1-e,t,r*(s/o),n*(o/s)];case 6:return[1-t-n*(o/s),1-e,n*(o/s),r*(s/o)];case 7:return[e-r*(s/o),1-t-n*(o/s),r*(s/o),n*(o/s)];case 8:return[t-r,e-n,r,n];case 9:return[1-e,t-r,n,r];case 10:return[1-t,1-e,r,n];case 11:return[e-n,1-t,n,r];case 12:return[t-n*(o/s),e,n*(o/s),r*(s/o)];case 13:return[1-e-r*(s/o),t-n*(o/s),r*(s/o),n*(o/s)];case 14:return[1-t,1-e-r*(s/o),n*(o/s),r*(s/o)];case 15:return[e,1-t,r*(s/o),n*(o/s)];default:return[t,e,r,n]}}Dst=vwt,Tnt(vwt,"_currentDrawId",-1),Tnt(vwt,"_currentParent",null);var Swt={_:null},Ewt={_:null},Mwt={_:null},Twt={_:NaN},Cwt={_:null},Pwt={_:null},Iwt={_:NaN};Tnt(vwt,"_INNER_MARGIN",3);var Rwt=new WeakMap,Owt=new WeakMap,Lwt=new WeakMap,Dwt=new WeakMap,Fwt=new WeakMap,Nwt=new WeakMap,jwt=new WeakMap,Bwt=new WeakMap,zwt=new WeakMap,Wwt=new WeakMap,Uwt=new WeakMap,Hwt=new WeakSet;class Gwt{constructor(t,e,r,n,i,a){Mnt(this,Hwt),knt(this,Rwt,new Float64Array(6)),knt(this,Owt,void 0),knt(this,Lwt,void 0),knt(this,Dwt,void 0),knt(this,Fwt,void 0),knt(this,Nwt,void 0),knt(this,jwt,""),knt(this,Bwt,0),knt(this,zwt,new rxt),knt(this,Wwt,void 0),knt(this,Uwt,void 0),Snt(Wwt,this,r),Snt(Uwt,this,n),Snt(Dwt,this,i),Snt(Fwt,this,a),[t,e]=bnt(Hwt,this,Ywt).call(this,t,e);var s=Snt(Owt,this,[NaN,NaN,NaN,NaN,t,e]);Snt(Nwt,this,[t,e]),Snt(Lwt,this,[{line:s,points:_nt(Nwt,this)}]),_nt(Rwt,this).set(s,0)}updateProperty(t,e){"stroke-width"===t&&Snt(Fwt,this,e)}isEmpty(){return!_nt(Lwt,this)||0===_nt(Lwt,this).length}isCancellable(){return _nt(Nwt,this).length<=10}add(t,e){[t,e]=bnt(Hwt,this,Ywt).call(this,t,e);var[r,n,i,a]=_nt(Rwt,this).subarray(2,6),s=t-i,o=e-a;return Math.hypot(_nt(Wwt,this)*s,_nt(Uwt,this)*o)<=2?null:(_nt(Nwt,this).push(t,e),isNaN(r)?(_nt(Rwt,this).set([i,a,t,e],2),_nt(Owt,this).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(_nt(Rwt,this)[0])&&_nt(Owt,this).splice(6,6),_nt(Rwt,this).set([r,n,i,a,t,e],0),_nt(Owt,this).push(...dyt.createBezierPoints(r,n,i,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){var r=this.add(t,e);return r||(2===_nt(Nwt,this).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,r,n,i){Snt(Wwt,this,r),Snt(Uwt,this,n),Snt(Dwt,this,i),[t,e]=bnt(Hwt,this,Ywt).call(this,t,e);var a=Snt(Owt,this,[NaN,NaN,NaN,NaN,t,e]);Snt(Nwt,this,[t,e]);var s=_nt(Lwt,this).at(-1);return s&&(s.line=new Float32Array(s.line),s.points=new Float32Array(s.points)),_nt(Lwt,this).push({line:a,points:_nt(Nwt,this)}),_nt(Rwt,this).set(a,0),Snt(Bwt,this,0),this.toSVGPath(),null}getLastElement(){return _nt(Lwt,this).at(-1)}setLastElement(t){return _nt(Lwt,this)?(_nt(Lwt,this).push(t),Snt(Owt,this,t.line),Snt(Nwt,this,t.points),Snt(Bwt,this,0),{path:{d:this.toSVGPath()}}):_nt(zwt,this).setLastElement(t)}removeLastElement(){if(!_nt(Lwt,this))return _nt(zwt,this).removeLastElement();_nt(Lwt,this).pop(),Snt(jwt,this,"");for(var t=0,e=_nt(Lwt,this).length;t<e;t++){var{line:r,points:n}=_nt(Lwt,this)[t];Snt(Owt,this,r),Snt(Nwt,this,n),Snt(Bwt,this,0),this.toSVGPath()}return{path:{d:_nt(jwt,this)}}}toSVGPath(){var t=dyt.svgRound(_nt(Owt,this)[4]),e=dyt.svgRound(_nt(Owt,this)[5]);if(2===_nt(Nwt,this).length)return Snt(jwt,this,"".concat(_nt(jwt,this)," M ").concat(t," ").concat(e," Z")),_nt(jwt,this);if(_nt(Nwt,this).length<=6){var r=_nt(jwt,this).lastIndexOf("M");Snt(jwt,this,"".concat(_nt(jwt,this).slice(0,r)," M ").concat(t," ").concat(e)),Snt(Bwt,this,6)}if(4===_nt(Nwt,this).length){var n=dyt.svgRound(_nt(Owt,this)[10]),i=dyt.svgRound(_nt(Owt,this)[11]);return Snt(jwt,this,"".concat(_nt(jwt,this)," L ").concat(n," ").concat(i)),Snt(Bwt,this,12),_nt(jwt,this)}var a=[];0===_nt(Bwt,this)&&(a.push("M ".concat(t," ").concat(e)),Snt(Bwt,this,6));for(var s=_nt(Bwt,this),o=_nt(Owt,this).length;s<o;s+=6){var[l,h,c,u,d,p]=_nt(Owt,this).slice(s,s+6).map(dyt.svgRound);a.push("C".concat(l," ").concat(h," ").concat(c," ").concat(u," ").concat(d," ").concat(p))}return Snt(jwt,this,_nt(jwt,this)+a.join(" ")),Snt(Bwt,this,_nt(Owt,this).length),_nt(jwt,this)}getOutlines(t,e,r,n){var i=_nt(Lwt,this).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),_nt(zwt,this).build(_nt(Lwt,this),t,e,r,_nt(Dwt,this),_nt(Fwt,this),n),Snt(Rwt,this,null),Snt(Owt,this,null),Snt(Lwt,this,null),Snt(jwt,this,null),_nt(zwt,this)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}function Ywt(t,e){return dyt._normalizePoint(t,e,_nt(Wwt,this),_nt(Uwt,this),_nt(Dwt,this))}var Vwt=new WeakMap,qwt=new WeakMap,Xwt=new WeakMap,$wt=new WeakMap,Kwt=new WeakMap,Qwt=new WeakMap,Jwt=new WeakMap,Zwt=new WeakMap,txt=new WeakMap,ext=new WeakSet;class rxt extends dyt{constructor(){super(...arguments),Mnt(this,ext),knt(this,Vwt,void 0),knt(this,qwt,0),knt(this,Xwt,void 0),knt(this,$wt,void 0),knt(this,Kwt,void 0),knt(this,Qwt,void 0),knt(this,Jwt,void 0),knt(this,Zwt,void 0),knt(this,txt,void 0)}build(t,e,r,n,i,a,s){Snt(Kwt,this,e),Snt(Qwt,this,r),Snt(Jwt,this,n),Snt(Zwt,this,i),Snt(txt,this,a),Snt(Xwt,this,null!=s?s:0),Snt($wt,this,t),bnt(ext,this,axt).call(this)}setLastElement(t){return _nt($wt,this).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return _nt($wt,this).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){var t=[];for(var{line:e}of _nt($wt,this))if(t.push("M".concat(dyt.svgRound(e[4])," ").concat(dyt.svgRound(e[5]))),6!==e.length)if(12!==e.length)for(var r=6,n=e.length;r<n;r+=6){var[i,a,s,o,l,h]=e.subarray(r,r+6).map(dyt.svgRound);t.push("C".concat(i," ").concat(a," ").concat(s," ").concat(o," ").concat(l," ").concat(h))}else t.push("L".concat(dyt.svgRound(e[10])," ").concat(dyt.svgRound(e[11])));else t.push("Z");return t.join("")}serialize(t,e){var r,n,i,a,s,o,l,h,c,[u,d,p,f]=t,g=[],v=[],[m,y,b,w]=bnt(ext,this,ixt).call(this);switch(_nt(Zwt,this)){case 0:c=dyt._rescale,r=u,n=d+f,i=p,a=-f,s=u+m*p,o=d+(1-y-w)*f,l=u+(m+b)*p,h=d+(1-y)*f;break;case 90:c=dyt._rescaleAndSwap,r=u,n=d,i=p,a=f,s=u+y*p,o=d+m*f,l=u+(y+w)*p,h=d+(m+b)*f;break;case 180:c=dyt._rescale,r=u+p,n=d,i=-p,a=f,s=u+(1-m-b)*p,o=d+y*f,l=u+(1-m)*p,h=d+(y+w)*f;break;case 270:c=dyt._rescaleAndSwap,r=u+p,n=d+f,i=-p,a=-f,s=u+(1-y-w)*p,o=d+(1-m-b)*f,l=u+(1-y)*p,h=d+(1-m)*f}for(var{line:x,points:A}of _nt($wt,this))g.push(c(x,r,n,i,a,e?new Array(x.length):null)),v.push(c(A,r,n,i,a,e?new Array(A.length):null));return{lines:g,points:v,rect:[s,o,l,h]}}static deserialize(t,e,r,n,i,a){var s,o,l,h,c,{paths:{lines:u,points:d},rotation:p,thickness:f}=a,g=[];switch(p){case 0:c=dyt._rescale,s=-t/r,o=e/n+1,l=1/r,h=-1/n;break;case 90:c=dyt._rescaleAndSwap,s=-e/n,o=-t/r,l=1/n,h=1/r;break;case 180:c=dyt._rescale,s=t/r+1,o=-e/n,l=-1/r,h=1/n;break;case 270:c=dyt._rescaleAndSwap,s=e/n+1,o=t/r+1,l=-1/n,h=-1/r}if(!u)for(var v of(u=[],d)){var m=v.length;if(2!==m)if(4!==m){var y=new Float32Array(3*(m-2));u.push(y);var[b,w,x,A]=v.subarray(0,4);y.set([NaN,NaN,NaN,NaN,b,w],0);for(var _=4;_<m;_+=2){var k=v[_],S=v[_+1];y.set(dyt.createBezierPoints(b,w,x,A,k,S),3*(_-2)),[b,w,x,A]=[x,A,k,S]}}else u.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));else u.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]))}for(var E=0,M=u.length;E<M;E++)g.push({line:c(u[E].map((t=>null!=t?t:NaN)),s,o,l,h),points:c(d[E].map((t=>null!=t?t:NaN)),s,o,l,h)});var T=new rxt;return T.build(g,r,n,1,p,f,i),T}get box(){return _nt(Vwt,this)}updateProperty(t,e){return"stroke-width"===t?bnt(ext,this,sxt).call(this,e):null}updateParentDimensions(t,e){var[r,n]=t,[i,a]=bnt(ext,this,nxt).call(this);Snt(Kwt,this,r),Snt(Qwt,this,n),Snt(Jwt,this,e);var[s,o]=bnt(ext,this,nxt).call(this),l=s-i,h=o-a,c=_nt(Vwt,this);return c[0]-=l,c[1]-=h,c[2]+=2*l,c[3]+=2*h,c}updateRotation(t){return Snt(qwt,this,t),{path:{transform:this.rotationTransform}}}get viewBox(){return _nt(Vwt,this).map(dyt.svgRound).join(" ")}get defaultProperties(){var[t,e]=_nt(Vwt,this);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(dyt.svgRound(t)," ").concat(dyt.svgRound(e))}}}get rotationTransform(){var[,,t,e]=_nt(Vwt,this),r=0,n=0,i=0,a=0,s=0,o=0;switch(_nt(qwt,this)){case 90:n=e/t,i=-t/e,s=t;break;case 180:r=-1,a=-1,s=t,o=e;break;case 270:n=-e/t,i=t/e,o=e;break;default:return""}return"matrix(".concat(r," ").concat(n," ").concat(i," ").concat(a," ").concat(dyt.svgRound(s)," ").concat(dyt.svgRound(o),")")}getPathResizingSVGProperties(t){var[e,r,n,i]=t,[a,s]=bnt(ext,this,nxt).call(this),[o,l,h,c]=_nt(Vwt,this);if(Math.abs(h-a)<=dyt.PRECISION||Math.abs(c-s)<=dyt.PRECISION){var u=e+n/2-(o+h/2),d=r+i/2-(l+c/2);return{path:{"transform-origin":"".concat(dyt.svgRound(e)," ").concat(dyt.svgRound(r)),transform:"".concat(this.rotationTransform," translate(").concat(u," ").concat(d,")")}}}var p=(n-2*a)/(h-2*a),f=(i-2*s)/(c-2*s),g=h/n,v=c/i;return{path:{"transform-origin":"".concat(dyt.svgRound(o)," ").concat(dyt.svgRound(l)),transform:"".concat(this.rotationTransform," scale(").concat(g," ").concat(v,") ")+"translate(".concat(dyt.svgRound(a)," ").concat(dyt.svgRound(s),") scale(").concat(p," ").concat(f,") ")+"translate(".concat(dyt.svgRound(-a)," ").concat(dyt.svgRound(-s),")")}}}getPathResizedSVGProperties(t){var[e,r,n,i]=t,[a,s]=bnt(ext,this,nxt).call(this),o=_nt(Vwt,this),[l,h,c,u]=o;if(o[0]=e,o[1]=r,o[2]=n,o[3]=i,Math.abs(c-a)<=dyt.PRECISION||Math.abs(u-s)<=dyt.PRECISION){var d=e+n/2-(l+c/2),p=r+i/2-(h+u/2);for(var{line:f,points:g}of _nt($wt,this))dyt._translate(f,d,p,f),dyt._translate(g,d,p,g);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(dyt.svgRound(e)," ").concat(dyt.svgRound(r)),transform:this.rotationTransform||null,d:this.toSVGPath()}}}var v=(n-2*a)/(c-2*a),m=(i-2*s)/(u-2*s),y=-v*(l+a)+e+a,b=-m*(h+s)+r+s;if(1!==v||1!==m||0!==y||0!==b)for(var{line:w,points:x}of _nt($wt,this))dyt._rescale(w,y,b,v,m,w),dyt._rescale(x,y,b,v,m,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(dyt.svgRound(e)," ").concat(dyt.svgRound(r)),transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties(t,e){var[r,n]=t,[i,a]=e,s=_nt(Vwt,this),o=r-s[0],l=n-s[1];if(_nt(Kwt,this)===i&&_nt(Qwt,this)===a)for(var{line:h,points:c}of _nt($wt,this))dyt._translate(h,o,l,h),dyt._translate(c,o,l,c);else{var u=_nt(Kwt,this)/i,d=_nt(Qwt,this)/a;for(var{line:p,points:f}of(Snt(Kwt,this,i),Snt(Qwt,this,a),_nt($wt,this)))dyt._rescale(p,o,l,u,d,p),dyt._rescale(f,o,l,u,d,f);s[2]*=u,s[3]*=d}return s[0]=r,s[1]=n,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":"".concat(dyt.svgRound(r)," ").concat(dyt.svgRound(n))}}}get defaultSVGProperties(){var t=_nt(Vwt,this);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":"".concat(dyt.svgRound(t[0])," ").concat(dyt.svgRound(t[1])),transform:this.rotationTransform||null},bbox:t}}}function nxt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_nt(txt,this),e=_nt(Xwt,this)+t/2*_nt(Jwt,this);return _nt(Zwt,this)%180==0?[e/_nt(Kwt,this),e/_nt(Qwt,this)]:[e/_nt(Qwt,this),e/_nt(Kwt,this)]}function ixt(){var[t,e,r,n]=_nt(Vwt,this),[i,a]=bnt(ext,this,nxt).call(this,0);return[t+i,e+a,r-2*i,n-2*a]}function axt(){var t=Snt(Vwt,this,new Float32Array([1/0,1/0,-1/0,-1/0]));for(var{line:e}of _nt($wt,this))if(e.length<=12)for(var r=4,n=e.length;r<n;r+=6){var[i,a]=e.subarray(r,r+2);t[0]=Math.min(t[0],i),t[1]=Math.min(t[1],a),t[2]=Math.max(t[2],i),t[3]=Math.max(t[3],a)}else for(var s=e[4],o=e[5],l=6,h=e.length;l<h;l+=6){var[c,u,d,p,f,g]=e.subarray(l,l+6);alt.bezierBoundingBox(s,o,c,u,d,p,f,g,t),s=f,o=g}var[v,m]=bnt(ext,this,nxt).call(this);t[0]=Math.min(1,Math.max(0,t[0]-v)),t[1]=Math.min(1,Math.max(0,t[1]-m)),t[2]=Math.min(1,Math.max(0,t[2]+v)),t[3]=Math.min(1,Math.max(0,t[3]+m)),t[2]-=t[0],t[3]-=t[1]}function sxt(t){var[e,r]=bnt(ext,this,nxt).call(this);Snt(txt,this,t);var[n,i]=bnt(ext,this,nxt).call(this),[a,s]=[n-e,i-r],o=_nt(Vwt,this);return o[0]-=a,o[1]-=s,o[2]+=2*a,o[3]+=2*s,o}var oxt=new WeakMap;class lxt extends dwt{constructor(t){super(),knt(this,oxt,void 0),Snt(oxt,this,t),super.updateProperties({fill:"none",stroke:jut._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(null!=e||(e=this["stroke-width"]),e*=_nt(oxt,this).realScale),super.updateSVGProperty(t,e)}clone(){var t=new lxt(_nt(oxt,this));return t.updateAll(this),t}}var hxt=new WeakSet;class cxt extends vwt{constructor(t){super(Pnt(Pnt({},t),{},{name:"inkEditor"})),Mnt(this,hxt),this._willKeepAspectRatio=!0}static initialize(t,e){jut.initialize(t,e),this._defaultDrawingOptions=new lxt(e.viewParameters)}static getDefaultDrawingOptions(t){var e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Yot(this,"typesMap",new Map([[rot.INK_THICKNESS,"stroke-width"],[rot.INK_COLOR,"stroke"],[rot.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,r,n,i){return new Gwt(t,e,r,n,i,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,r,n,i,a){return rxt.deserialize(t,e,r,n,i,a)}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return xnt((function*(){var a=null;if(t instanceof Cmt){var{data:{inkLists:s,rect:o,rotation:l,id:h,color:c,opacity:u,borderStyle:{rawWidth:d},popupRef:p},parent:{page:{pageNumber:f}}}=t;a=t={annotationType:eot.INK,color:Array.from(c),thickness:d,opacity:u,paths:{points:s},boxes:null,pageIndex:f-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,popupRef:p}}var g=yield n().call(i,t,e,r);return g.annotationElementId=t.id||null,g._initialData=a,g}))()}onScaleChanging(){if(this.parent){super.onScaleChanging();var{_drawId:t,_drawingOptions:e,parent:r}=this;e.updateSVGProperty("stroke-width"),r.drawLayer.updateProperties(t,e.toSVGProperties())}}static onScaleChangingWhenDrawing(){var t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions(t){var{color:e,thickness:r,opacity:n}=t;this._drawingOptions=cxt.getDefaultDrawingOptions({stroke:alt.makeHexColor(...e),"stroke-width":r,"stroke-opacity":n})}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var{lines:e,points:r,rect:n}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":a,"stroke-width":s}}=this,o={annotationType:eot.INK,color:jut._colorManager.convert(i),opacity:a,thickness:s,paths:{lines:e,points:r},pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!bnt(hxt,this,uxt).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(t){var{points:e,rect:r}=this.serializeDraw(!1);return t.updateEdited({rect:r,thickness:this._drawingOptions["stroke-width"],points:e}),null}}function uxt(t){var{color:e,thickness:r,opacity:n,pageIndex:i}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,r)=>t!==e[r]))||t.thickness!==r||t.opacity!==n||t.pageIndex!==i}Tnt(cxt,"_type","ink"),Tnt(cxt,"_editorType",eot.INK),Tnt(cxt,"_defaultDrawingOptions",null);var dxt=new WeakMap,pxt=new WeakMap,fxt=new WeakMap,gxt=new WeakMap,vxt=new WeakMap,mxt=new WeakMap,yxt=new WeakMap,bxt=new WeakMap,wxt=new WeakMap,xxt=new WeakMap,Axt=new WeakSet;class _xt extends jut{constructor(t){super(Pnt(Pnt({},t),{},{name:"stampEditor"})),Mnt(this,Axt),knt(this,dxt,null),knt(this,pxt,null),knt(this,fxt,null),knt(this,gxt,null),knt(this,vxt,null),knt(this,mxt,""),knt(this,yxt,null),knt(this,bxt,null),knt(this,wxt,!1),knt(this,xxt,!1),Snt(gxt,this,t.bitmapUrl),Snt(vxt,this,t.bitmapFile)}static initialize(t,e){jut.initialize(t,e)}static get supportedTypes(){return Yot(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>"image/".concat(t))))}static get supportedTypesStr(){return Yot(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(eot.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!(null===(t=this.altTextData)||void 0===t||!t.altText)}}static computeTelemetryFinalData(t){var e,r,n=t.get("hasAltText");return{hasAltText:null!==(e=n.get(!0))&&void 0!==e?e:0,hasNoAltText:null!==(r=n.get(!1))&&void 0!==r?r:0}}mlGuessAltText(){var t=arguments,e=this;return xnt((function*(){var r=t.length>0&&void 0!==t[0]?t[0]:null,n=!(t.length>1&&void 0!==t[1])||t[1];if(e.hasAltTextData())return null;var{mlManager:i}=e._uiManager;if(!i)throw new Error("No ML.");if(!(yield i.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");var{data:a,width:s,height:o}=r||e.copyCanvas(null,null,!0).imageData,l=yield i.guess({name:"altText",request:{data:a,width:s,height:o,channels:a.length/(s*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");var h=l.output;return yield e.setGuessedAltText(h),n&&!e.hasAltTextData()&&(e.altTextData={alt:h,decorative:!1}),h}))()}remove(){var t;_nt(pxt,this)&&(Snt(dxt,this,null),this._uiManager.imageManager.deleteId(_nt(pxt,this)),null===(t=_nt(yxt,this))||void 0===t||t.remove(),Snt(yxt,this,null),_nt(bxt,this)&&(clearTimeout(_nt(bxt,this)),Snt(bxt,this,null)));super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(_nt(pxt,this)&&null===_nt(yxt,this)&&bnt(Axt,this,Ext).call(this),this.isAttachedToDOM||this.parent.add(this))):_nt(pxt,this)&&bnt(Axt,this,Ext).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(_nt(fxt,this)||_nt(dxt,this)||_nt(gxt,this)||_nt(vxt,this)||_nt(pxt,this))}get isResizable(){return!0}render(){if(this.div)return this.div;var t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),_nt(dxt,this)?bnt(Axt,this,Mxt).call(this):bnt(Axt,this,Ext).call(this),this.width&&!this.annotationElementId){var[r,n]=this.parentDimensions;this.setAt(t*r,e*n,this.width*r,this.height*n)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(this.parent){null!==_nt(bxt,this)&&clearTimeout(_nt(bxt,this));Snt(bxt,this,setTimeout((()=>{Snt(bxt,this,null),bnt(Axt,this,Cxt).call(this)}),200))}}copyCanvas(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t||(t=224);var{width:n,height:i}=_nt(dxt,this),a=new Olt,s=_nt(dxt,this),o=n,l=i,h=null;if(e){var c,u;if(n>e||i>e){var d=Math.min(e/n,e/i);o=Math.floor(n*d),l=Math.floor(i*d)}var p=(h=document.createElement("canvas")).width=Math.ceil(o*a.sx),f=h.height=Math.ceil(l*a.sy);_nt(wxt,this)||(s=bnt(Axt,this,Txt).call(this,p,f));var g=h.getContext("2d");g.filter=this._uiManager.hcmFilter;var v="white",m="#cfcfd8";"none"!==this._uiManager.hcmFilter?m="black":null!==(c=(u=window).matchMedia)&&void 0!==c&&c.call(u,"(prefers-color-scheme: dark)").matches&&(v="#8f8f9d",m="#42414d");var y=15*a.sx,b=15*a.sy,w=new OffscreenCanvas(2*y,2*b),x=w.getContext("2d");x.fillStyle=v,x.fillRect(0,0,2*y,2*b),x.fillStyle=m,x.fillRect(0,0,y,b),x.fillRect(y,b,y,b),g.fillStyle=g.createPattern(w,"repeat"),g.fillRect(0,0,p,f),g.drawImage(s,0,0,s.width,s.height,0,0,p,f)}var A=null;if(r){var _,k;if(a.symmetric&&s.width<t&&s.height<t)_=s.width,k=s.height;else if(s=_nt(dxt,this),n>t||i>t){var S=Math.min(t/n,t/i);_=Math.floor(n*S),k=Math.floor(i*S),_nt(wxt,this)||(s=bnt(Axt,this,Txt).call(this,_,k))}var E=new OffscreenCanvas(_,k).getContext("2d",{willReadFrequently:!0});E.drawImage(s,0,0,s.width,s.height,0,0,_,k),A={width:_,height:k,data:E.getImageData(0,0,_,k).data}}return{canvas:h,width:o,height:l,imageData:A}}getImageForAltText(){return _nt(yxt,this)}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return xnt((function*(){var a=null;if(t instanceof Dmt){var s,{data:{rect:o,rotation:l,id:h,structParent:c,popupRef:u},container:d,parent:{page:{pageNumber:p}}}=t,f=d.querySelector("canvas"),g=r.imageManager.getFromCanvas(d.id,f);f.remove();var v=(null===(s=yield e._structTree.getAriaAttributes("".concat(ult).concat(h)))||void 0===s?void 0:s.get("aria-label"))||"";a=t={annotationType:eot.STAMP,bitmapId:g.id,bitmap:g.bitmap,pageIndex:p-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:v},isSvg:!1,structParent:c,popupRef:u}}var m=yield n().call(i,t,e,r),{rect:y,bitmap:b,bitmapUrl:w,bitmapId:x,isSvg:A,accessibilityData:_}=t;x&&r.imageManager.isValidId(x)?(Snt(pxt,m,x),b&&Snt(dxt,m,b)):Snt(gxt,m,w),Snt(wxt,m,A);var[k,S]=m.pageDimensions;return m.width=(y[2]-y[0])/k,m.height=(y[3]-y[1])/S,m.annotationElementId=t.id||null,_&&(m.altTextData=_),m._initialData=a,Snt(xxt,m,!!a),m}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var r={annotationType:eot.STAMP,bitmapId:_nt(pxt,this),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:_nt(wxt,this),structTreeParentId:this._structTreeParentId};if(t)return r.bitmapUrl=bnt(Axt,this,Pxt).call(this,!0),r.accessibilityData=this.serializeAltText(!0),r;var{decorative:n,altText:i}=this.serializeAltText(!1);if(!n&&i&&(r.accessibilityData={type:"Figure",alt:i}),this.annotationElementId){var a,s=bnt(Axt,this,Ixt).call(this,r);if(s.isSame)return null;if(s.isSameAltText)delete r.accessibilityData;else r.accessibilityData.structParent=null!==(a=this._initialData.structParent)&&void 0!==a?a:-1}if(r.id=this.annotationElementId,null===e)return r;e.stamps||(e.stamps=new Map);var o=_nt(wxt,this)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(e.stamps.has(_nt(pxt,this))){if(_nt(wxt,this)){var l=e.stamps.get(_nt(pxt,this));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=bnt(Axt,this,Pxt).call(this,!1))}}else e.stamps.set(_nt(pxt,this),{area:o,serialized:r}),r.bitmap=bnt(Axt,this,Pxt).call(this,!1);return r}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}function kxt(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?(Snt(dxt,this,t.bitmap),e||(Snt(pxt,this,t.id),Snt(wxt,this,t.isSvg)),t.file&&Snt(mxt,this,t.file.name),bnt(Axt,this,Mxt).call(this)):this.remove()}function Sxt(){if(Snt(fxt,this,null),this._uiManager.enableWaiting(!1),_nt(yxt,this)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_nt(dxt,this))return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_nt(dxt,this)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch(t){}}this.div.focus()}}function Ext(){var t=this;if(_nt(pxt,this))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(_nt(pxt,this)).then((t=>bnt(Axt,this,kxt).call(this,t,!0))).finally((()=>bnt(Axt,this,Sxt).call(this)));if(_nt(gxt,this)){var e=_nt(gxt,this);return Snt(gxt,this,null),this._uiManager.enableWaiting(!0),void Snt(fxt,this,this._uiManager.imageManager.getFromUrl(e).then((t=>bnt(Axt,this,kxt).call(this,t))).finally((()=>bnt(Axt,this,Sxt).call(this))))}if(_nt(vxt,this)){var r=_nt(vxt,this);return Snt(vxt,this,null),this._uiManager.enableWaiting(!0),void Snt(fxt,this,this._uiManager.imageManager.getFromFile(r).then((t=>bnt(Axt,this,kxt).call(this,t))).finally((()=>bnt(Axt,this,Sxt).call(this))))}var n=document.createElement("input");n.type="file",n.accept=Fst.supportedTypesStr;var i=this._uiManager._signal;Snt(fxt,this,new Promise((e=>{n.addEventListener("change",xnt((function*(){if(n.files&&0!==n.files.length){t._uiManager.enableWaiting(!0);var r=yield t._uiManager.imageManager.getFromFile(n.files[0]);t._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:t._uiManager.useNewAltTextFlow}}),bnt(Axt,t,kxt).call(t,r)}else t.remove();e()})),{signal:i}),n.addEventListener("cancel",(()=>{this.remove(),e()}),{signal:i})})).finally((()=>bnt(Axt,this,Sxt).call(this)))),n.click()}function Mxt(){var t,{div:e}=this,{width:r,height:n}=_nt(dxt,this),[i,a]=this.pageDimensions,s=.75;if(this.width)r=this.width*i,n=this.height*a;else if(r>s*i||n>s*a){var o=Math.min(s*i/r,s*a/n);r*=o,n*=o}var[l,h]=this.parentDimensions;this.setDims(r*l/i,n*h/a),this._uiManager.enableWaiting(!1);var c=Snt(yxt,this,document.createElement("canvas"));c.setAttribute("role","img"),this.addContainer(c),this.width=r/i,this.height=n/a,null!==(t=this._initialOptions)&&void 0!==t&&t.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),bnt(Axt,this,Cxt).call(this),_nt(xxt,this)||(this.parent.addUndoableEditor(this),Snt(xxt,this,!0)),this._reportTelemetry({action:"inserted_image"}),_nt(mxt,this)&&c.setAttribute("aria-label",_nt(mxt,this))}function Txt(t,e){for(var{width:r,height:n}=_nt(dxt,this),i=r,a=n,s=_nt(dxt,this);i>2*t||a>2*e;){var o=i,l=a;i>2*t&&(i=i>=16384?Math.floor(i/2)-1:Math.ceil(i/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));var h=new OffscreenCanvas(i,a);h.getContext("2d").drawImage(s,0,0,o,l,0,0,i,a),s=h.transferToImageBitmap()}return s}function Cxt(){var[t,e]=this.parentDimensions,{width:r,height:n}=this,i=new Olt,a=Math.ceil(r*t*i.sx),s=Math.ceil(n*e*i.sy),o=_nt(yxt,this);if(o&&(o.width!==a||o.height!==s)){o.width=a,o.height=s;var l=_nt(wxt,this)?_nt(dxt,this):bnt(Axt,this,Txt).call(this,a,s),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,s)}}function Pxt(t){if(t){if(_nt(wxt,this)){var e=this._uiManager.imageManager.getSvgUrl(_nt(pxt,this));if(e)return e}var r=document.createElement("canvas");return({width:r.width,height:r.height}=_nt(dxt,this)),r.getContext("2d").drawImage(_nt(dxt,this),0,0),r.toDataURL()}if(_nt(wxt,this)){var[n,i]=this.pageDimensions,a=Math.round(this.width*n*plt.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*plt.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(a,s);return o.getContext("2d").drawImage(_nt(dxt,this),0,0,_nt(dxt,this).width,_nt(dxt,this).height,0,0,a,s),o.transferToImageBitmap()}return structuredClone(_nt(dxt,this))}function Ixt(t){var e,{pageIndex:r,accessibilityData:{altText:n}}=this._initialData,i=t.pageIndex===r,a=((null===(e=t.accessibilityData)||void 0===e?void 0:e.alt)||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&i&&a,isSameAltText:a}}Fst=_xt,Tnt(_xt,"_type","stamp"),Tnt(_xt,"_editorType",eot.STAMP);var Rxt=new WeakMap,Oxt=new WeakMap,Lxt=new WeakMap,Dxt=new WeakMap,Fxt=new WeakMap,Nxt=new WeakMap,jxt=new WeakMap,Bxt=new WeakMap,zxt=new WeakMap,Wxt=new WeakMap,Uxt=new WeakMap,Hxt=new WeakMap,Gxt=new WeakMap,Yxt=new WeakMap,Vxt=new WeakSet;class qxt{constructor(t){var{uiManager:e,pageIndex:r,div:n,structTreeLayer:i,accessibilityManager:a,annotationLayer:s,drawLayer:o,textLayer:l,viewport:h,l10n:c}=t;Mnt(this,Vxt),knt(this,Rxt,void 0),knt(this,Oxt,!1),knt(this,Lxt,null),knt(this,Dxt,null),knt(this,Fxt,null),knt(this,Nxt,new Map),knt(this,jxt,!1),knt(this,Bxt,!1),knt(this,zxt,!1),knt(this,Wxt,null),knt(this,Uxt,null),knt(this,Hxt,null),knt(this,Gxt,null),knt(this,Yxt,void 0);var u=[...Zxt._.values()];if(!qxt._initialized)for(var d of(qxt._initialized=!0,u))d.initialize(c,e);e.registerEditorTypes(u),Snt(Yxt,this,e),this.pageIndex=r,this.div=n,Snt(Rxt,this,a),Snt(Lxt,this,s),this.viewport=h,Snt(Hxt,this,l),this.drawLayer=o,this._structTree=i,_nt(Yxt,this).addLayer(this)}get isEmpty(){return 0===_nt(Nxt,this).size}get isInvisible(){return this.isEmpty&&_nt(Yxt,this).getMode()===eot.NONE}updateToolbar(t){_nt(Yxt,this).updateToolbar(t)}updateMode(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_nt(Yxt,this).getMode();switch(bnt(Vxt,this,Jxt).call(this),t){case eot.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case eot.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case eot.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);var{classList:e}=this.div;for(var r of Zxt._.values())e.toggle("".concat(r._type,"Editing"),t===r._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===(null===(e=_nt(Hxt,this))||void 0===e?void 0:e.div)}setEditingState(t){_nt(Yxt,this).setEditingState(t)}addCommands(t){_nt(Yxt,this).addCommands(t)}cleanUndoStack(t){_nt(Yxt,this).cleanUndoStack(t)}toggleDrawing(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("drawing",!t)}togglePointerEvents(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];null===(t=_nt(Lxt,this))||void 0===t||t.div.classList.toggle("disabled",!e)}enable(){var t=this;return xnt((function*(){Snt(zxt,t,!0),t.div.tabIndex=0,t.togglePointerEvents(!0);var e=new Set;for(var r of _nt(Nxt,t).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(_nt(Yxt,t).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(_nt(Lxt,t)){var n=_nt(Lxt,t).getEditableAnnotations();for(var i of n)if(i.hide(),!_nt(Yxt,t).isDeletedAnnotationElement(i.data.id)&&!e.has(i.data.id)){var a=yield t.deserialize(i);a&&(t.addOrRebuild(a),a.enableEditing())}Snt(zxt,t,!1)}else Snt(zxt,t,!1)}))()}disable(){Snt(Bxt,this,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);var t=new Map,e=new Map;for(var r of _nt(Nxt,this).values()){var n;r.disableEditing(),r.annotationElementId&&(null===r.serialize()?(e.set(r.annotationElementId,r),null===(n=this.getEditableAnnotation(r.annotationElementId))||void 0===n||n.show(),r.remove()):t.set(r.annotationElementId,r))}if(_nt(Lxt,this)){var i=_nt(Lxt,this).getEditableAnnotations();for(var a of i){var{id:s}=a.data;if(!_nt(Yxt,this).isDeletedAnnotationElement(s)){var o=e.get(s);o?(o.resetAnnotationElement(a),o.show(!1),a.show()):((o=t.get(s))&&(_nt(Yxt,this).addChangedExistingAnnotation(o),o.renderAnnotationElement(a)&&o.show(!1)),a.show())}}}bnt(Vxt,this,Jxt).call(this),this.isEmpty&&(this.div.hidden=!0);var{classList:l}=this.div;for(var h of Zxt._.values())l.remove("".concat(h._type,"Editing"));this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),Snt(Bxt,this,!1)}getEditableAnnotation(t){var e;return(null===(e=_nt(Lxt,this))||void 0===e?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){_nt(Yxt,this).getActive()!==t&&_nt(Yxt,this).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,null!==(t=_nt(Hxt,this))&&void 0!==t&&t.div&&!_nt(Gxt,this)){Snt(Gxt,this,new AbortController);var e=_nt(Yxt,this).combinedSignal(_nt(Gxt,this));_nt(Hxt,this).div.addEventListener("pointerdown",bnt(Vxt,this,Xxt).bind(this),{signal:e}),_nt(Hxt,this).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,null!==(t=_nt(Hxt,this))&&void 0!==t&&t.div&&_nt(Gxt,this)&&(_nt(Gxt,this).abort(),Snt(Gxt,this,null),_nt(Hxt,this).div.classList.remove("highlighting"))}enableClick(){if(!_nt(Dxt,this)){Snt(Dxt,this,new AbortController);var t=_nt(Yxt,this).combinedSignal(_nt(Dxt,this));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});var e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}}disableClick(){var t;null===(t=_nt(Dxt,this))||void 0===t||t.abort(),Snt(Dxt,this,null)}attach(t){_nt(Nxt,this).set(t.id,t);var{annotationElementId:e}=t;e&&_nt(Yxt,this).isDeletedAnnotationElement(e)&&_nt(Yxt,this).removeDeletedAnnotationElement(t)}detach(t){var e;_nt(Nxt,this).delete(t.id),null===(e=_nt(Rxt,this))||void 0===e||e.removePointerInTextLayer(t.contentDiv),!_nt(Bxt,this)&&t.annotationElementId&&_nt(Yxt,this).addDeletedAnnotationElement(t)}remove(t){this.detach(t),_nt(Yxt,this).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(_nt(Yxt,this).addDeletedAnnotationElement(t.annotationElementId),jut.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),null===(e=t.parent)||void 0===e||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),_nt(Yxt,this).addEditor(t),this.attach(t),!t.isAttachedToDOM){var e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!_nt(zxt,this)),_nt(Yxt,this).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(t.isAttachedToDOM){var{activeElement:r}=document;t.div.contains(r)&&!_nt(Fxt,this)&&(t._focusEventsAllowed=!1,Snt(Fxt,this,setTimeout((()=>{Snt(Fxt,this,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:_nt(Yxt,this)._signal}),r.focus())}),0))),t._structTreeParentId=null===(e=_nt(Rxt,this))||void 0===e?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return _nt(Yxt,this).getId()}combinedSignal(t){return _nt(Yxt,this).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null===(t=Ent(Vxt,this,$xt))||void 0===t?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){_nt(Yxt,this).updateToolbar(t),_nt(Yxt,this).updateMode(t);var{offsetX:r,offsetY:n}=bnt(Vxt,this,Qxt).call(this),i=this.getNextId(),a=bnt(Vxt,this,Kxt).call(this,Pnt({parent:this,id:i,x:r,y:n,uiManager:_nt(Yxt,this),isCentered:!0},e));a&&this.add(a)}deserialize(t){var e=this;return xnt((function*(){var r,n;return(yield null===(r=Zxt._.get(null!==(n=t.annotationType)&&void 0!==n?n:t.annotationEditorType))||void 0===r?void 0:r.deserialize(t,e,_nt(Yxt,e)))||null}))()}createAndAddNewEditor(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getNextId(),i=bnt(Vxt,this,Kxt).call(this,Pnt({parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:_nt(Yxt,this),isCentered:e},r));return i&&this.add(i),i}addNewEditor(){this.createAndAddNewEditor(bnt(Vxt,this,Qxt).call(this),!0)}setSelected(t){_nt(Yxt,this).setSelected(t)}toggleSelected(t){_nt(Yxt,this).toggleSelected(t)}unselect(t){_nt(Yxt,this).unselect(t)}pointerup(t){var e,{isMac:r}=nlt.platform;0!==t.button||t.ctrlKey&&r||t.target===this.div&&_nt(jxt,this)&&(Snt(jxt,this,!1),null!==(e=Ent(Vxt,this,$xt))&&void 0!==e&&e.isDrawer&&Ent(Vxt,this,$xt).supportMultipleDrawings||(_nt(Oxt,this)?_nt(Yxt,this).getMode()!==eot.STAMP?this.createAndAddNewEditor(t,!1):_nt(Yxt,this).unselectAll():Snt(Oxt,this,!0)))}pointerdown(t){var e;if(_nt(Yxt,this).getMode()===eot.HIGHLIGHT&&this.enableTextSelection(),_nt(jxt,this))Snt(jxt,this,!1);else{var{isMac:r}=nlt.platform;if(!(0!==t.button||t.ctrlKey&&r)&&t.target===this.div)if(Snt(jxt,this,!0),null!==(e=Ent(Vxt,this,$xt))&&void 0!==e&&e.isDrawer)this.startDrawingSession(t);else{var n=_nt(Yxt,this).getActive();Snt(Oxt,this,!n||n.isEmpty())}}}startDrawingSession(t){if(this.div.focus(),_nt(Wxt,this))Ent(Vxt,this,$xt).startDrawing(this,_nt(Yxt,this),!1,t);else{_nt(Yxt,this).setCurrentDrawingSession(this),Snt(Wxt,this,new AbortController);var e=_nt(Yxt,this).combinedSignal(_nt(Wxt,this));this.div.addEventListener("blur",(t=>{var{relatedTarget:e}=t;e&&!this.div.contains(e)&&(Snt(Uxt,this,null),this.commitOrRemove())}),{signal:e}),Ent(Vxt,this,$xt).startDrawing(this,_nt(Yxt,this),!1,t)}}pause(t){if(t){var{activeElement:e}=document;this.div.contains(e)&&Snt(Uxt,this,e)}else _nt(Uxt,this)&&setTimeout((()=>{var t;null===(t=_nt(Uxt,this))||void 0===t||t.focus(),Snt(Uxt,this,null)}),0)}endDrawingSession(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return _nt(Wxt,this)?(_nt(Yxt,this).setCurrentDrawingSession(null),_nt(Wxt,this).abort(),Snt(Wxt,this,null),Snt(Uxt,this,null),Ent(Vxt,this,$xt).endDrawing(t)):null}findNewParent(t,e,r){var n=_nt(Yxt,this).findParent(e,r);return null!==n&&n!==this&&(n.changeParent(t),!0)}commitOrRemove(){return!!_nt(Wxt,this)&&(this.endDrawingSession(),!0)}onScaleChanging(){_nt(Wxt,this)&&Ent(Vxt,this,$xt).onScaleChangingWhenDrawing(this)}destroy(){var t;for(var e of(this.commitOrRemove(),(null===(t=_nt(Yxt,this).getActive())||void 0===t?void 0:t.parent)===this&&(_nt(Yxt,this).commitOrRemove(),_nt(Yxt,this).setActiveEditor(null)),_nt(Fxt,this)&&(clearTimeout(_nt(Fxt,this)),Snt(Fxt,this,null)),_nt(Nxt,this).values())){var r;null===(r=_nt(Rxt,this))||void 0===r||r.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove()}this.div=null,_nt(Nxt,this).clear(),_nt(Yxt,this).removeLayer(this)}render(t){var{viewport:e}=t;for(var r of(this.viewport=e,Rlt(this.div,e),_nt(Yxt,this).getEditors(this.pageIndex)))this.add(r),r.rebuild();this.updateMode()}update(t){var{viewport:e}=t;_nt(Yxt,this).commitOrRemove(),bnt(Vxt,this,Jxt).call(this);var r=this.viewport.rotation,n=e.rotation;if(this.viewport=e,Rlt(this.div,{rotation:n}),r!==n)for(var i of _nt(Nxt,this).values())i.rotate(n)}get pageDimensions(){var{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return _nt(Yxt,this).viewParameters.realScale}}function Xxt(t){_nt(Yxt,this).unselectAll();var{target:e}=t;if(e===_nt(Hxt,this).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&_nt(Hxt,this).div.contains(e)){var{isMac:r}=nlt.platform;if(0!==t.button||t.ctrlKey&&r)return;_nt(Yxt,this).showAllEditors("highlight",!0,!0),_nt(Hxt,this).div.classList.add("free"),this.toggleDrawing(),Xbt.startHighlighting(this,"ltr"===_nt(Yxt,this).direction,{target:_nt(Hxt,this).div,x:t.x,y:t.y}),_nt(Hxt,this).div.addEventListener("pointerup",(()=>{_nt(Hxt,this).div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:_nt(Yxt,this)._signal}),t.preventDefault()}}function $xt(t){return Zxt._.get(_nt(Yxt,t).getMode())}function Kxt(t){var e=Ent(Vxt,this,$xt);return e?new e.prototype.constructor(t):null}function Qxt(){var{x:t,y:e,width:r,height:n}=this.div.getBoundingClientRect(),i=Math.max(0,t),a=Math.max(0,e),s=(i+Math.min(window.innerWidth,t+r))/2-t,o=(a+Math.min(window.innerHeight,e+n))/2-e,[l,h]=this.viewport.rotation%180==0?[s,o]:[o,s];return{offsetX:l,offsetY:h}}function Jxt(){for(var t of _nt(Nxt,this).values())t.isEmpty()&&t.remove()}Tnt(qxt,"_initialized",!1);var Zxt={_:new Map([ryt,cxt,_xt,Xbt].map((t=>[t._editorType,t])))},tAt=new WeakMap,eAt=new WeakMap,rAt=new WeakMap,nAt=new WeakMap,iAt=new WeakSet;class aAt{constructor(t){var{pageIndex:e}=t;Mnt(this,iAt),knt(this,tAt,null),knt(this,eAt,0),knt(this,rAt,new Map),knt(this,nAt,new Map),this.pageIndex=e}setParent(t){if(_nt(tAt,this)){if(_nt(tAt,this)!==t){if(_nt(rAt,this).size>0)for(var e of _nt(rAt,this).values())e.remove(),t.append(e);Snt(tAt,this,t)}}else Snt(tAt,this,t)}static get _svgFactory(){return Yot(this,"_svgFactory",new pvt)}draw(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=(Snt(eAt,this,(e=_nt(eAt,this),r=e++,e)),r),s=bnt(iAt,this,oAt).call(this),o=aAt._svgFactory.createElement("defs");s.append(o);var l=aAt._svgFactory.createElement("path");o.append(l);var h="path_p".concat(this.pageIndex,"_").concat(a);l.setAttribute("id",h),l.setAttribute("vector-effect","non-scaling-stroke"),n&&_nt(nAt,this).set(a,l);var c=i?bnt(iAt,this,lAt).call(this,o,h):null,u=aAt._svgFactory.createElement("use");return s.append(u),u.setAttribute("href","#".concat(h)),this.updateProperties(s,t),_nt(rAt,this).set(a,s),{id:a,clipPathId:"url(#".concat(c,")")}}drawOutline(t,e){var r,n,i=(Snt(eAt,this,(r=_nt(eAt,this),n=r++,r)),n),a=bnt(iAt,this,oAt).call(this),s=aAt._svgFactory.createElement("defs");a.append(s);var o=aAt._svgFactory.createElement("path");s.append(o);var l,h="path_p".concat(this.pageIndex,"_").concat(i);if(o.setAttribute("id",h),o.setAttribute("vector-effect","non-scaling-stroke"),e){var c=aAt._svgFactory.createElement("mask");s.append(c),l="mask_p".concat(this.pageIndex,"_").concat(i),c.setAttribute("id",l),c.setAttribute("maskUnits","objectBoundingBox");var u=aAt._svgFactory.createElement("rect");c.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");var d=aAt._svgFactory.createElement("use");c.append(d),d.setAttribute("href","#".concat(h)),d.setAttribute("stroke","none"),d.setAttribute("fill","black"),d.setAttribute("fill-rule","nonzero"),d.classList.add("mask")}var p=aAt._svgFactory.createElement("use");a.append(p),p.setAttribute("href","#".concat(h)),l&&p.setAttribute("mask","url(#".concat(l,")"));var f=p.cloneNode();return a.append(f),p.classList.add("mainOutline"),f.classList.add("secondaryOutline"),this.updateProperties(a,t),_nt(rAt,this).set(i,a),i}finalizeDraw(t,e){_nt(nAt,this).delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(e){var{root:r,bbox:n,rootClass:i,path:a}=e,s="number"==typeof t?_nt(rAt,this).get(t):t;if(s){if(r&&bnt(iAt,this,hAt).call(this,s,r),n&&sAt.call(aAt,s,n),i){var{classList:o}=s;for(var[l,h]of Object.entries(i))o.toggle(l,h)}if(a){var c=s.firstChild.firstChild;bnt(iAt,this,hAt).call(this,c,a)}}}}updateParent(t,e){if(e!==this){var r=_nt(rAt,this).get(t);r&&(_nt(tAt,e).append(r),_nt(rAt,this).delete(t),_nt(rAt,e).set(t,r))}}remove(t){_nt(nAt,this).delete(t),null!==_nt(tAt,this)&&(_nt(rAt,this).get(t).remove(),_nt(rAt,this).delete(t))}destroy(){for(var t of(Snt(tAt,this,null),_nt(rAt,this).values()))t.remove();_nt(rAt,this).clear(),_nt(nAt,this).clear()}}function sAt(t,e){var[r,n,i,a]=e,{style:s}=t;s.top="".concat(100*n,"%"),s.left="".concat(100*r,"%"),s.width="".concat(100*i,"%"),s.height="".concat(100*a,"%")}function oAt(){var t=Nst._svgFactory.create(1,1,!0);return _nt(tAt,this).append(t),t.setAttribute("aria-hidden",!0),t}function lAt(t,e){var r=Nst._svgFactory.createElement("clipPath");t.append(r);var n="clip_".concat(e);r.setAttribute("id",n),r.setAttribute("clipPathUnits","objectBoundingBox");var i=Nst._svgFactory.createElement("use");return r.append(i),i.setAttribute("href","#".concat(e)),i.classList.add("clip"),n}function hAt(t,e){for(var[r,n]of Object.entries(e))null===n?t.removeAttribute(r):t.setAttribute(r,n)}Nst=aAt,globalThis.pdfjsTestingUtils={HighlightOutliner:Jyt};var cAt=Wst.getDocument;Wst.GlobalWorkerOptions.workerSrc="/node_modules/pdfjs-dist/build/pdf.worker.min.mjs";const uAt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}},{type:"attachment-selector",label:"file",name:"file",property:{displayField:"fullpath",displayFullUrl:!0,storageFilters:{type:Array,value:[{name:"category",value:"application"}]},useUpload:!0}},{type:"number",label:"page",name:"page"},{type:"select",label:"fit",name:"fit",property:{options:["none","ratio","width","height"]}}],help:"scene/component/pdf-viewer"},dAt=[2,4,8,16,32],pAt=16e3;class fAt extends(wtt(ytt)){async ready(){this.scaleIndex=0,this.displayScale=1,this.offsetX=0,this.offsetY=0,this.pdfDoc=null,this.canvas=document.createElement("canvas"),this.renderTask=null,this.loadPDF()}dispose(){super.dispose(),this.worker&&(this.worker.terminate(),this.worker=null),this.renderTask&&this.renderTask.cancel(),this.pdfDoc=null,this.canvas=null}async loadPDF(){const{file:t,page:e=1}=this.state;if(t)try{console.log(`📌 Loading PDF: ${t}`),this.pdfDoc=await cAt(t).promise;const r=this.pdfDoc.numPages;this.page=await this.pdfDoc.getPage(e>r?1:e),this.documentSize=this.page.getViewport({scale:1}),this.fit()}catch(t){console.error("🚨 Failed to load PDF:",t)}}onchange(t,e){("file"in t||"fit"in t||"page"in t)&&this.loadPDF()}async fit(){const{fit:t="none"}=this.state,{width:e,height:r}=this.bounds,n=this.documentSize;switch(t){case"none":default:this.displayScale=1;break;case"width":this.displayScale=e/n.width;break;case"height":this.displayScale=r/n.height;break;case"ratio":this.displayScale=Math.min(e/n.width,r/n.height)}this.scaleIndex=dAt.findIndex((t=>this.displayScale<=t)),-1===this.scaleIndex&&(this.scaleIndex=dAt.length-1),"ratio"===t?(this.offsetX=(e-n.width*this.displayScale)/2,this.offsetY=(r-n.height*this.displayScale)/2):(this.offsetX=0,this.offsetY=0),this.renderPDF()}async renderPDF(){if(!this.pdfDoc||!this.page)return;const{width:t,height:e}=this.documentSize;let r=dAt[this.scaleIndex],n=Math.min(t*r,pAt),i=Math.min(e*r,pAt);if(n===pAt||i===pAt){const a=t/e;a>1&&(i=n/a);const s=i/e;this.scaleIndex=dAt.findIndex((t=>s<=t))-1,r=dAt[this.scaleIndex],n=t*r,i=e*r}const a=document.createElement("canvas");a.width=n,a.height=i;const s={canvasContext:a.getContext("2d"),viewport:this.page.getViewport({scale:r})};if(this.renderTask){this.renderTask.cancel();try{await this.renderTask.promise}catch(t){console.warn("Previous render task was canceled.")}}this.renderTask=this.page.render(s);try{await this.renderTask.promise,this.canvas=a,this.renderTask=null,this.invalidate()}catch(t){"RenderingCancelledException"!==t.name&&console.error("Failed to render PDF:",t)}}render(t){super.render(t);const{left:e,top:r}=this.bounds,{width:n,height:i}=this.canvas;t.clip(),t.drawImage(this.canvas,e+this.offsetX,r+this.offsetY,(this.documentSize?.width||n)*this.displayScale,(this.documentSize?.height||i)*this.displayScale)}onwheel(t){t.preventDefault();var{left:e,top:r}=this.bounds,{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);n-=e,i-=r;const a=t.deltaY<0?1.05:.95,s=this.displayScale;this.displayScale=Math.min(Math.max(.5,this.displayScale*a),dAt[dAt.length-1]);const o=dAt.findIndex((t=>this.displayScale<=t)),l=-1===o?dAt.length-1:o,h=this.displayScale/s;this.offsetX=n-(n-this.offsetX)*h,this.offsetY=i-(i-this.offsetY)*h,this.invalidate(),l!==this.scaleIndex&&(this.scaleIndex=l,this.renderPDF())}ondragstart(t){this.position=this.transcoordC2S(t.offsetX,t.offsetY)}ondragmove(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);const n=e-this.position.x,i=r-this.position.y;this.offsetX+=n,this.offsetY+=i,this.position={x:e,y:r},this.invalidate()}ondblclick(t){this.fit()}get nature(){return uAt}}mtt.register("pdf-page",fAt);var gAt=t=>class extends t{animOnValueChange(t,e=!1,r){if(t!=this._lastValue){if(e)var n=t-(Number(r)||0);else n=t-(this._lastValue||0);this._lastValue=t,this._anim_alpha=-n,this.animate({step:t=>{this._anim_alpha=n*(t-1),this.invalidate()},duration:1e3,delta:"circ",options:{x:1},ease:"out"}).start()}}dispose(){super.dispose(),delete this._value_substitutor}onchange(t,e){t.hasOwnProperty("value")&&delete this._value_substitutor}get animAlpha(){return this._anim_alpha||0}get animValue(){return(this._lastValue||0)+(this._anim_alpha||0)}defaultValueSubstitutor(){return this.getState("value")}get valueSubstitutor(){return this._value_substitutor||(this._value_substitutor=att(this.getState("value"),this)||this.defaultValueSubstitutor),this._value_substitutor}get value(){return Number(this.valueSubstitutor())||0}set value(t){delete this._value_substitutor,this.setState("value",Number(P7(t)))}},vAt=t=>class extends t{_convertDataFormat(t,e){var r;if("json"===e)r=JSON.parse(t);else r=t;return r}isDataSource(){return!0}},mAt=0;const yAt=new FinalizationRegistry((()=>{mAt--}));class bAt{static get residents(){return mAt}static get residentsCount(){return mAt}constructor(t,e){this.counters={},this.references={},this.creator=t,this.disposer=e,mAt++,yAt.register(this,mAt)}dispose(){if(this.disposer)for(let t in this.references)this.disposer.call(null,t,this.references[t]);delete this.references,delete this.counters}get ids(){return Object.keys(this.references)}create(t){var e=this;return new Promise((function(r,n){e.creator?e.creator.call(null,t,(function(e){!function(e){e.release=function(){this.disposer&&this.disposer.call(null,t,e),delete e.release,G7("RELEASED",t)},r(e)}(e)}),(function(t){n(t)})):n(Error("Reference id("+t+") could not be created. Reference creator should be defined."))}))}add(t,e){var r=this,n=new Promise((function(n,i){var a=r.references[t];if(a)a===e?i(Error("Reference ID and target duplicate")):e?i(Error("Reference ID duplicate")):n(a);else{function s(e){e.release=function(){r.release(this)},r.references[t]=e,r.counters[t]=1,n(e)}if(e)s(e);else{if(!r.creator)return void i(Error("Reference id("+t+") is not allowed. Reference creator should be defined."));r.creator.call(null,t,(function(t){s(t)}),(function(t){i(t)}))}}}));return this.references[t]||(this.references[t]=n),n}async get(t,e){var r=this.references[t];if(r){if(!(r instanceof Promise)){if(!(t in this.counters))throw new Error("No Reference Count");return this.counters[t]++,r}if(e)return r=await r,this.counters[t]++,r}if(e)return await this.add(t);throw new Error("No References for "+t)}_id(t){for(let e in this.references){if(this.references[e]===t)return e}return-1}release(t){var e=this._id(t),r=this.references[e];r?(this.counters[e]--,0==this.counters[e]&&(this.disposer&&this.disposer.call(null,e,r),delete this.references[e],delete this.counters[e],delete t.release,G7("RELEASED",e))):U7("No Referenced ID")}}var wAt={},xAt={},AAt=[];function _At(t){var e="SCRIPT"==t.target.tagName?wAt:xAt,r=t.target.src||t.target.href;e[r]=!0,AAt.forEach(((t,n)=>{let{resolve:i,scripts:a,styles:s}=t;if(e==wAt){let t=a.indexOf(r);t>-1&&t<a.length-1&&SAt(a[t+1])}for(let t=0;t<a.length;t++)if(!wAt[a[t]])return;if(s)for(let t=0;t<s.length;t++)if(!xAt[s[t]])return;i(),AAt[n]=null})),AAt=AAt.filter(Boolean)}function kAt(t){var e=t.target.src,r="SCRIPT"==t.target.tagName?wAt:xAt;AAt.forEach(((n,i)=>{let{reject:a,scripts:s,styles:o}=n,l=!1;if(r===wAt){for(let t=0;t<s.length;t++)if(s[t]==e){l=!0;break}}else if(o)for(let t=0;t<o.length;t++)if(o[t]==e){l=!0;break}l&&(a(t),AAt[i]=null)})),AAt=AAt.filter(Boolean),delete r[e],document.head.removeChild(t.target)}function SAt(t){wAt[t]=!1;var e=document.createElement("script");e.onload=_At,e.onerror=kAt,e.type="text/javascript",e.src=t,document.head.appendChild(e)}class EAt{static load(t,e){return"string"==typeof t&&(t=[t]),"string"==typeof e&&(e=[e]),new Promise((function(r,n){if((!t||t instanceof Array)&&(!e||e instanceof Array)){var i,a=!0;if(e&&e.forEach((t=>{xAt.hasOwnProperty(t)||function(t){xAt[t]=!1;var e=document.createElement("link");e.onload=_At,e.onerror=kAt,e.type="text/css",e.rel="stylesheet",e.media="screen,print",e.href=t,document.head.appendChild(e)}(t),xAt[t]||(a=!1)})),t&&t.length>0&&t.forEach((t=>{wAt.hasOwnProperty(t)?wAt[t]||(a=!1):i=i||t})),i)SAt(i);else if(a)return void r();AAt.push({resolve:r,reject:n,scripts:t,styles:e})}else n("invalid sources for load")}))}}const MAt="0.0.0";var TAt=0,CAt=performance.now(),PAt=0;function IAt(){return TAt}requestAnimationFrame((function t(){requestAnimationFrame(t),PAt++;var e=performance.now(),r=e-CAt;r<1e3||(TAt=Math.round(1e3*PAt/r),CAt=e,PAt=0)}));var RAt=Let;function OAt(){}export{Ott as AbsoluteLayout,ost as AudioPlayer,Dtt as CardLayout,mtt as Component,Qtt as Connectable,yat as Container,Gtt as ContainerAbstract,i9 as DEFAULT,e9 as DPPX,vAt as DataSource,_st as Donut,Lat as Ellipse,hnt as EventMap,IAt as FPS,r9 as GESTURES,ast as GifView,gst as GlobalRef,cst as Group,Mtt as HTMLAbsoluteLayout,pst as HTMLOverlayContainer,Yat as HTMLOverlayElement,Gat as ImageView,ktt as InfoWindow,n9 as KEYEVENTS,Ytt as Layer,Ett as Layout,Rat as Line,Ntt as LinearHorizontalLayout,Btt as LinearVerticalLayout,dst as LocalRef,t9 as MAX_UNDO_SIZE,K7 as MODE_ADD,X7 as MODE_EDIT,J7 as MODE_PASTE_DATABIND,Q7 as MODE_PASTE_STYLE,$7 as MODE_SHIFT,q7 as MODE_VIEW,RAt as Model,Utt as MoveHandle,V7 as NOTHING,Uat as OrthoLine,fAt as PDFPage,yst as Path,Nat as Polygon,zat as Polyline,mst as Popup,tet as Rect,wtt as RectPath,bAt as ReferenceMap,jnt as RootContainer,ret as Ruler,Z7 as SCENE_MODE,Jnt as Scene,Rtt as ScenePopup,EAt as ScriptLoader,ytt as Shape,Bst as Star,ztt as TableLayout,lst as Text,wst as Triangle,gAt as ValueHolder,tit as create,G7 as debug,U7 as error,OAt as license,k4 as polyfill,MAt as version,H7 as warn};console.log("@hatiolab/things-scene@9.0.0-beta.21 is loaded");
65
+ */var Wst={d:(t,e)=>{for(var r in e)Wst.o(e,r)&&!Wst.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},Ust=globalThis.pdfjsLib={};Wst.d(Ust,{AbortException:()=>tlt,AnnotationEditorLayer:()=>Xxt,AnnotationEditorParamsType:()=>not,AnnotationEditorType:()=>rot,AnnotationEditorUIManager:()=>uct,AnnotationLayer:()=>Vmt,AnnotationMode:()=>eot,ColorPicker:()=>Abt,DOMSVGFactory:()=>fvt,DrawLayer:()=>sAt,FeatureTest:()=>ilt,GlobalWorkerOptions:()=>Kpt,ImageKind:()=>uot,InvalidPDFException:()=>Kot,MissingPDFException:()=>Qot,OPS:()=>Fot,OutputScale:()=>Llt,PDFDataRangeTransport:()=>Egt,PDFDateString:()=>Mlt,PDFWorker:()=>jgt,PasswordResponses:()=>Not,PermissionFlag:()=>iot,PixelsPerInch:()=>flt,RenderingCancelledException:()=>ylt,TextLayer:()=>ngt,TouchManager:()=>cut,UnexpectedResponseException:()=>Jot,Util:()=>slt,VerbosityLevel:()=>Dot,XfaLayer:()=>gvt,build:()=>hvt,createValidAbsoluteUrl:()=>Yot,fetchData:()=>glt,getDocument:()=>Agt,getFilenameFromUrl:()=>xlt,getPdfFilenameFromUrl:()=>Alt,getXfaPageViewport:()=>Clt,isDataScheme:()=>blt,isPdfFile:()=>wlt,noContextMenu:()=>Slt,normalizeUnicode:()=>ult,setLayerDimensions:()=>Olt,shadow:()=>Vot,stopEvent:()=>Elt,version:()=>lvt});var Hst=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),Gst=[1,0,0,1,0,0],Yst=[.001,0,0,.001,0,0],Vst=1.35,qst=1,Xst=2,$st=4,Kst=16,Qst=32,Jst=64,Zst=128,tot=256,eot={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},rot={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},not={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},iot={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},aot=0,sot=1,oot=2,lot=3,hot=3,cot=4,uot={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},dot=1,pot=2,fot=3,got=4,vot=5,mot=6,yot=7,bot=8,wot=9,xot=10,Aot=11,_ot=12,kot=13,Sot=14,Eot=15,Mot=16,Tot=17,Cot=20,Pot=1,Iot=2,Rot=3,Oot=4,Lot=5,Dot={ERRORS:0,WARNINGS:1,INFOS:5},Fot={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},Not={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},jot=Dot.WARNINGS;function Bot(t){Number.isInteger(t)&&(jot=t)}function zot(){return jot}function Wot(t){jot>=Dot.INFOS&&console.log("Info: ".concat(t))}function Uot(t){jot>=Dot.WARNINGS&&console.log("Warning: ".concat(t))}function Hot(t){throw new Error(t)}function Got(t,e){t||Hot(e)}function Yot(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!t)return null;try{if(r&&"string"==typeof t){if(r.addDefaultProtocol&&t.startsWith("www.")){var n=t.match(/\./g);(null==n?void 0:n.length)>=2&&(t="http://".concat(t))}if(r.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch(t){}}var i=e?new URL(t,e):new URL(t);if(function(t){switch(null==t?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch(t){}return null}function Vot(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!0,writable:!1}),r}var qot=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class Xot extends qot{constructor(t,e){super(t,"PasswordException"),this.code=e}}class $ot extends qot{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Kot extends qot{constructor(t){super(t,"InvalidPDFException")}}class Qot extends qot{constructor(t){super(t,"MissingPDFException")}}class Jot extends qot{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class Zot extends qot{constructor(t){super(t,"FormatError")}}class tlt extends qot{constructor(t){super(t,"AbortException")}}function elt(t){"object"==typeof t&&void 0!==(null==t?void 0:t.length)||Hot("Invalid argument for bytesToString");var e=t.length,r=8192;if(e<r)return String.fromCharCode.apply(null,t);for(var n=[],i=0;i<e;i+=r){var a=Math.min(i+r,e),s=t.subarray(i,a);n.push(String.fromCharCode.apply(null,s))}return n.join("")}function rlt(t){"string"!=typeof t&&Hot("Invalid argument for stringToBytes");for(var e=t.length,r=new Uint8Array(e),n=0;n<e;++n)r[n]=255&t.charCodeAt(n);return r}function nlt(t){var e=Object.create(null);for(var[r,n]of t)e[r]=n;return e}class ilt{static get isLittleEndian(){return Vot(this,"isLittleEndian",((t=new Uint8Array(4))[0]=1,1===new Uint32Array(t.buffer,0,1)[0]));var t}static get isEvalSupported(){return Vot(this,"isEvalSupported",function(){try{return new Function(""),!0}catch(t){return!1}}())}static get isOffscreenCanvasSupported(){return Vot(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Vot(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){var t,e;return"undefined"!=typeof navigator&&"string"==typeof(null===(t=navigator)||void 0===t?void 0:t.platform)?Vot(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof(null===(e=navigator)||void 0===e?void 0:e.userAgent)&&navigator.userAgent.includes("Firefox")}):Vot(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return Vot(this,"isCSSRoundSupported",null===(t=globalThis.CSS)||void 0===t||null===(e=t.supports)||void 0===e?void 0:e.call(t,"width: round(1.5px, 1px)"))}}var alt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class slt{static makeHexColor(t,e,r){return"#".concat(alt[t]).concat(alt[e]).concat(alt[r])}static scaleMinMax(t,e){var r;t[0]?(t[0]<0&&(r=e[0],e[0]=e[2],e[2]=r),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(r=e[1],e[1]=e[3],e[3]=r),e[1]*=t[3],e[3]*=t[3]):(r=e[0],e[0]=e[1],e[1]=r,r=e[2],e[2]=e[3],e[3]=r,t[1]<0&&(r=e[1],e[1]=e[3],e[3]=r),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(r=e[0],e[0]=e[2],e[2]=r),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){var r=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/r,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/r]}static getAxialAlignedBoundingBox(t,e){var r=this.applyTransform(t,e),n=this.applyTransform(t.slice(2,4),e),i=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(r[0],n[0],i[0],a[0]),Math.min(r[1],n[1],i[1],a[1]),Math.max(r[0],n[0],i[0],a[0]),Math.max(r[1],n[1],i[1],a[1])]}static inverseTransform(t){var e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){var e=[t[0],t[2],t[1],t[3]],r=t[0]*e[0]+t[1]*e[2],n=t[0]*e[1]+t[1]*e[3],i=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],s=(r+a)/2,o=Math.sqrt(Math.pow(r+a,2)-4*(r*a-i*n))/2,l=s+o||1,h=s-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){var e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){var r=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(r>n)return null;var i=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return i>a?null:[r,i,n,a]}static bezierBoundingBox(t,e,r,n,i,a,s,o,l){return l?(l[0]=Math.min(l[0],t,s),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,s),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,s),Math.min(e,o),Math.max(t,s),Math.max(e,o)],bnt(slt,this,llt).call(this,t,r,i,s,e,n,a,o,3*(3*(r-i)-t+s),6*(t-2*r+i),3*(r-t),l),bnt(slt,this,llt).call(this,t,r,i,s,e,n,a,o,3*(3*(n-a)-e+o),6*(e-2*n+a),3*(n-e),l),l}}function olt(t,e,r,n,i,a,s,o,l,h){if(!(l<=0||l>=1)){var c=1-l,u=l*l,d=u*l,p=c*(c*(c*t+3*l*e)+3*u*r)+d*n,f=c*(c*(c*i+3*l*a)+3*u*s)+d*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],f),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],f)}}function llt(t,e,r,n,i,a,s,o,l,h,c,u){if(Math.abs(l)<1e-12)Math.abs(h)>=1e-12&&bnt(Est,this,olt).call(this,t,e,r,n,i,a,s,o,-c/h,u);else{var d=Math.pow(h,2)-4*c*l;if(!(d<0)){var p=Math.sqrt(d),f=2*l;bnt(Est,this,olt).call(this,t,e,r,n,i,a,s,o,(-h+p)/f,u),bnt(Est,this,olt).call(this,t,e,r,n,i,a,s,o,(-h-p)/f,u)}}}Est=slt;var hlt=null,clt=null;function ult(t){return hlt||(hlt=/([\xA0\xB5\u037E\u0EB3\u2000-\u200A\u202F\u2126\uFB00-\uFB04\uFB06\uFB20-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBA1\uFBA4-\uFBA9\uFBAE-\uFBB1\uFBD3-\uFBDC\uFBDE-\uFBE7\uFBEA-\uFBF8\uFBFC\uFBFD\uFC00-\uFC5D\uFC64-\uFCF1\uFCF5-\uFD3D\uFD88\uFDF4\uFDFA\uFDFB\uFE71\uFE77\uFE79\uFE7B\uFE7D]+)|(\uFB05+)/g,clt=new Map([["ſt","ſt"]])),t.replaceAll(hlt,((t,e,r)=>e?e.normalize("NFKC"):clt.get(r)))}var dlt="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return new Promise((e=>{e(t(...r))}))});var plt="http://www.w3.org/2000/svg";class flt{}function glt(t){return vlt.apply(this,arguments)}function vlt(){return vlt=xnt((function*(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";if(klt(t,document.baseURI)){var r=yield fetch(t);if(!r.ok)throw new Error(r.statusText);switch(e){case"arraybuffer":return r.arrayBuffer();case"blob":return r.blob();case"json":return r.json()}return r.text()}return new Promise(((r,n)=>{var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(200!==i.status&&0!==i.status)n(new Error(i.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void r(i.response)}r(i.responseText)}},i.send(null)}))})),vlt.apply(this,arguments)}Mst=flt,Tnt(flt,"CSS",96),Tnt(flt,"PDF",72),Tnt(flt,"PDF_TO_CSS_UNITS",Mst.CSS/Mst.PDF);class mlt{constructor(t){var{viewBox:e,userUnit:r,scale:n,rotation:i,offsetX:a=0,offsetY:s=0,dontFlip:o=!1}=t;this.viewBox=e,this.userUnit=r,this.scale=n,this.rotation=i,this.offsetX=a,this.offsetY=s,n*=r;var l,h,c,u,d,p,f,g,v=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch((i%=360)<0&&(i+=360),i){case 180:l=-1,h=0,c=0,u=1;break;case 90:l=0,h=1,c=1,u=0;break;case 270:l=0,h=-1,c=-1,u=0;break;case 0:l=1,h=0,c=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(c=-c,u=-u),0===l?(d=Math.abs(m-e[1])*n+a,p=Math.abs(v-e[0])*n+s,f=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(d=Math.abs(v-e[0])*n+a,p=Math.abs(m-e[1])*n+s,f=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,h*n,c*n,u*n,d-l*n*v-c*n*m,p-h*n*v-u*n*m],this.width=f,this.height=g}get rawDims(){var{userUnit:t,viewBox:e}=this,r=e.map((e=>e*t));return Vot(this,"rawDims",{pageWidth:r[2]-r[0],pageHeight:r[3]-r[1],pageX:r[0],pageY:r[1]})}clone(){var{scale:t=this.scale,rotation:e=this.rotation,offsetX:r=this.offsetX,offsetY:n=this.offsetY,dontFlip:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new mlt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:r,offsetY:n,dontFlip:i})}convertToViewportPoint(t,e){return slt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){var e=slt.applyTransform([t[0],t[1]],this.transform),r=slt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],r[0],r[1]]}convertToPdfPoint(t,e){return slt.applyInverseTransform([t,e],this.transform)}}class ylt extends qot{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;super(t,"RenderingCancelledException"),this.extraDelay=e}}function blt(t){for(var e=t.length,r=0;r<e&&""===t[r].trim();)r++;return"data:"===t.substring(r,r+5).toLowerCase()}function wlt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function xlt(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Alt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"document.pdf";if("string"!=typeof t)return e;if(blt(t))return Uot('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;var r=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t),i=r.exec(n[1])||r.exec(n[2])||r.exec(n[3]);if(i&&(i=i[0]).includes("%"))try{i=r.exec(decodeURIComponent(i))[0]}catch(t){}return i||e}class _lt{constructor(){Tnt(this,"started",Object.create(null)),Tnt(this,"times",[])}time(t){t in this.started&&Uot("Timer is already running for ".concat(t)),this.started[t]=Date.now()}timeEnd(t){t in this.started||Uot("Timer has not been started for ".concat(t)),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){var t=[],e=0;for(var{name:r}of this.times)e=Math.max(r.length,e);for(var{name:n,start:i,end:a}of this.times)t.push("".concat(n.padEnd(e)," ").concat(a-i,"ms\n"));return t.join("")}}function klt(t,e){try{var{protocol:r}=e?new URL(t,e):new URL(t);return"http:"===r||"https:"===r}catch(t){return!1}}function Slt(t){t.preventDefault()}function Elt(t){t.preventDefault(),t.stopPropagation()}class Mlt{static toDateObject(t){if(!t||"string"!=typeof t)return null;bnt(Mlt,this,Tlt)._||(Tlt._=bnt(Mlt,this,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?")));var e=bnt(Mlt,this,Tlt)._.exec(t);if(!e)return null;var r=parseInt(e[1],10),n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;var i=parseInt(e[3],10);i=i>=1&&i<=31?i:1;var a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;var s=parseInt(e[5],10);s=s>=0&&s<=59?s:0;var o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;var l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;var c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(a+=h,s+=c):"+"===l&&(a-=h,s-=c),new Date(Date.UTC(r,n,i,a,s,o))}}var Tlt={_:void 0};function Clt(t,e){var{scale:r=1,rotation:n=0}=e,{width:i,height:a}=t.attributes.style,s=[0,0,parseInt(i),parseInt(a)];return new mlt({viewBox:s,userUnit:1,scale:r,rotation:n})}function Plt(t){if(t.startsWith("#")){var e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(Uot('Not a valid color format: "'.concat(t,'"')),[0,0,0])}function Ilt(t){var{a:e,b:r,c:n,d:i,e:a,f:s}=t.getTransform();return[e,r,n,i,a,s]}function Rlt(t){var{a:e,b:r,c:n,d:i,e:a,f:s}=t.getTransform().invertSelf();return[e,r,n,i,a,s]}function Olt(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(e instanceof mlt){var{pageWidth:i,pageHeight:a}=e.rawDims,{style:s}=t,o=ilt.isCSSRoundSupported,l="var(--scale-factor) * ".concat(i,"px"),h="var(--scale-factor) * ".concat(a,"px"),c=o?"round(down, ".concat(l,", var(--scale-round-x, 1px))"):"calc(".concat(l,")"),u=o?"round(down, ".concat(h,", var(--scale-round-y, 1px))"):"calc(".concat(h,")");r&&e.rotation%180!=0?(s.width=u,s.height=c):(s.width=c,s.height=u)}n&&t.setAttribute("data-main-rotation",e.rotation)}class Llt{constructor(){var t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}var Dlt=new WeakMap,Flt=new WeakMap,Nlt=new WeakMap,jlt=new WeakMap,Blt=new WeakMap,zlt=new WeakSet;class Wlt{constructor(t){Mnt(this,zlt),knt(this,Dlt,null),knt(this,Flt,null),knt(this,Nlt,void 0),knt(this,jlt,null),knt(this,Blt,null),Snt(Nlt,this,t),Xlt._||(Xlt._=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){var t=Snt(Dlt,this,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");var e=_nt(Nlt,this)._uiManager._signal;t.addEventListener("contextmenu",Slt,{signal:e}),t.addEventListener("pointerdown",Ult,{signal:e});var r=Snt(jlt,this,document.createElement("div"));r.className="buttons",t.append(r);var n=_nt(Nlt,this).toolbarPosition;if(n){var{style:i}=t,a="ltr"===_nt(Nlt,this)._uiManager.direction?1-n[0]:n[0];i.insetInlineEnd="".concat(100*a,"%"),i.top="calc(".concat(100*n[1],"% + var(--editor-toolbar-vert-offset))")}return bnt(zlt,this,Vlt).call(this),t}get div(){return _nt(Dlt,this)}hide(){var t;_nt(Dlt,this).classList.add("hidden"),null===(t=_nt(Flt,this))||void 0===t||t.hideDropdown()}show(){var t;_nt(Dlt,this).classList.remove("hidden"),null===(t=_nt(Blt,this))||void 0===t||t.shown()}addAltText(t){var e=this;return xnt((function*(){var r=yield t.render();bnt(zlt,e,Ylt).call(e,r),_nt(jlt,e).prepend(r,Ent(zlt,e,qlt)),Snt(Blt,e,t)}))()}addColorPicker(t){Snt(Flt,this,t);var e=t.renderButton();bnt(zlt,this,Ylt).call(this,e),_nt(jlt,this).prepend(e,Ent(zlt,this,qlt))}remove(){var t;_nt(Dlt,this).remove(),null===(t=_nt(Flt,this))||void 0===t||t.destroy(),Snt(Flt,this,null)}}function Ult(t){t.stopPropagation()}function Hlt(t){_nt(Nlt,this)._focusEventsAllowed=!1,Elt(t)}function Glt(t){_nt(Nlt,this)._focusEventsAllowed=!0,Elt(t)}function Ylt(t){var e=_nt(Nlt,this)._uiManager._signal;t.addEventListener("focusin",bnt(zlt,this,Hlt).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",bnt(zlt,this,Glt).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Slt,{signal:e})}function Vlt(){var{editorType:t,_uiManager:e}=_nt(Nlt,this),r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",Xlt._[t]),bnt(zlt,this,Ylt).call(this,r),r.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),_nt(jlt,this).append(r)}function qlt(t){var e=document.createElement("div");return e.className="divider",e}var Xlt={_:null},$lt=new WeakMap,Klt=new WeakMap,Qlt=new WeakMap,Jlt=new WeakSet;class Zlt{constructor(t){Mnt(this,Jlt),knt(this,$lt,null),knt(this,Klt,null),knt(this,Qlt,void 0),Snt(Qlt,this,t)}show(t,e,r){var[n,i]=bnt(Jlt,this,eht).call(this,e,r),{style:a}=_nt(Klt,this)||Snt(Klt,this,bnt(Jlt,this,tht).call(this));t.append(_nt(Klt,this)),a.insetInlineEnd="".concat(100*n,"%"),a.top="calc(".concat(100*i,"% + var(--editor-toolbar-vert-offset))")}hide(){_nt(Klt,this).remove()}}function tht(){var t=Snt(Klt,this,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Slt,{signal:_nt(Qlt,this)._signal});var e=Snt($lt,this,document.createElement("div"));return e.className="buttons",t.append(e),bnt(Jlt,this,rht).call(this),t}function eht(t,e){var r=0,n=0;for(var i of t){var a=i.y+i.height;if(!(a<r)){var s=i.x+(e?i.width:0);a>r?(n=s,r=a):e?s>n&&(n=s):s<n&&(n=s)}}return[e?1-n:n,r]}function rht(){var t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");var e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");var r=_nt(Qlt,this)._signal;t.addEventListener("contextmenu",Slt,{signal:r}),t.addEventListener("click",(()=>{_nt(Qlt,this).highlightSelection("floating_button")}),{signal:r}),_nt($lt,this).append(t)}function nht(t,e,r){for(var n of r)e.addEventListener(n,t[n].bind(t))}var iht=new WeakMap;class aht{constructor(){knt(this,iht,0)}get id(){var t,e;return"".concat("pdfjs_internal_editor_").concat((Snt(iht,this,(t=_nt(iht,this),e=t++,t)),e))}}var sht=new WeakMap,oht=new WeakMap,lht=new WeakMap,hht=new WeakSet;class cht{constructor(){Mnt(this,hht),knt(this,sht,function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();var t=new Uint8Array(32);return crypto.getRandomValues(t),elt(t)}()),knt(this,oht,0),knt(this,lht,null)}static get _isSVGFittingCanvas(){var t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',Vot(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}getFromFile(t){var e=this;return xnt((function*(){var{lastModified:r,name:n,size:i,type:a}=t;return bnt(hht,e,uht).call(e,"".concat(r,"_").concat(n,"_").concat(i,"_").concat(a),t)}))()}getFromUrl(t){var e=this;return xnt((function*(){return bnt(hht,e,uht).call(e,t,t)}))()}getFromBlob(t,e){var r=this;return xnt((function*(){var n=yield e;return bnt(hht,r,uht).call(r,t,n)}))()}getFromId(t){var e=this;return xnt((function*(){_nt(lht,e)||Snt(lht,e,new Map);var r=_nt(lht,e).get(t);if(!r)return null;if(r.bitmap)return r.refCounter+=1,r;if(r.file)return e.getFromFile(r.file);if(r.blobPromise){var{blobPromise:n}=r;return delete r.blobPromise,e.getFromBlob(r.id,n)}return e.getFromUrl(r.url)}))()}getFromCanvas(t,e){var r,n,i;_nt(lht,this)||Snt(lht,this,new Map);var a=_nt(lht,this).get(t);if(null!==(i=a)&&void 0!==i&&i.bitmap)return a.refCounter+=1,a;var s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),a={bitmap:s.transferToImageBitmap(),id:"image_".concat(_nt(sht,this),"_").concat((Snt(oht,this,(r=_nt(oht,this),n=r++,r)),n)),refCounter:1,isSvg:!1},_nt(lht,this).set(t,a),_nt(lht,this).set(a.id,a),a}getSvgUrl(t){var e=_nt(lht,this).get(t);return null!=e&&e.isSvg?e.svgUrl:null}deleteId(t){var e;_nt(lht,this)||Snt(lht,this,new Map);var r=_nt(lht,this).get(t);if(r&&(r.refCounter-=1,0===r.refCounter)){var{bitmap:n}=r;if(!r.url&&!r.file){var i=new OffscreenCanvas(n.width,n.height);i.getContext("bitmaprenderer").transferFromImageBitmap(n),r.blobPromise=i.convertToBlob()}null===(e=n.close)||void 0===e||e.call(n),r.bitmap=null}}isValidId(t){return t.startsWith("image_".concat(_nt(sht,this),"_"))}}function uht(t,e){return dht.apply(this,arguments)}function dht(){return dht=xnt((function*(t,e){var r;_nt(lht,this)||Snt(lht,this,new Map);var n=_nt(lht,this).get(t);if(null===n)return null;if(null!==(r=n)&&void 0!==r&&r.bitmap)return n.refCounter+=1,n;try{var i,a,s;if(n||(n={bitmap:null,id:"image_".concat(_nt(sht,this),"_").concat((Snt(oht,this,(i=_nt(oht,this),a=i++,i)),a)),refCounter:0,isSvg:!1}),"string"==typeof e?(n.url=e,s=yield glt(e,"blob")):e instanceof File?s=n.file=e:e instanceof Blob&&(s=e),"image/svg+xml"===s.type){var o=Tst._isSVGFittingCanvas,l=new FileReader,h=new Image,c=new Promise(((t,e)=>{h.onload=()=>{n.bitmap=h,n.isSvg=!0,t()},l.onload=xnt((function*(){var t=n.svgUrl=l.result;h.src=(yield o)?"".concat(t,"#svgView(preserveAspectRatio(none))"):t})),h.onerror=l.onerror=e}));l.readAsDataURL(s),yield c}else n.bitmap=yield createImageBitmap(s);n.refCounter=1}catch(t){Uot(t),n=null}return _nt(lht,this).set(t,n),n&&_nt(lht,this).set(n.id,n),n})),dht.apply(this,arguments)}Tst=cht;var pht=new WeakMap,fht=new WeakMap,ght=new WeakMap,vht=new WeakMap;class mht{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:128;knt(this,pht,[]),knt(this,fht,!1),knt(this,ght,void 0),knt(this,vht,-1),Snt(ght,this,t)}add(t){var{cmd:e,undo:r,post:n,mustExec:i,type:a=NaN,overwriteIfSameType:s=!1,keepUndo:o=!1}=t;if(i&&e(),!_nt(fht,this)){var l={cmd:e,undo:r,post:n,type:a};if(-1===_nt(vht,this))return _nt(pht,this).length>0&&(_nt(pht,this).length=0),Snt(vht,this,0),void _nt(pht,this).push(l);if(s&&_nt(pht,this)[_nt(vht,this)].type===a)return o&&(l.undo=_nt(pht,this)[_nt(vht,this)].undo),void(_nt(pht,this)[_nt(vht,this)]=l);var h=_nt(vht,this)+1;h===_nt(ght,this)?_nt(pht,this).splice(0,1):(Snt(vht,this,h),h<_nt(pht,this).length&&_nt(pht,this).splice(h)),_nt(pht,this).push(l)}}undo(){if(-1!==_nt(vht,this)){Snt(fht,this,!0);var{undo:t,post:e}=_nt(pht,this)[_nt(vht,this)];t(),null==e||e(),Snt(fht,this,!1),Snt(vht,this,_nt(vht,this)-1)}}redo(){if(_nt(vht,this)<_nt(pht,this).length-1){Snt(vht,this,_nt(vht,this)+1),Snt(fht,this,!0);var{cmd:t,post:e}=_nt(pht,this)[_nt(vht,this)];t(),null==e||e(),Snt(fht,this,!1)}}hasSomethingToUndo(){return-1!==_nt(vht,this)}hasSomethingToRedo(){return _nt(vht,this)<_nt(pht,this).length-1}cleanType(t){if(-1!==_nt(vht,this)){for(var e=_nt(vht,this);e>=0;e--)if(_nt(pht,this)[e].type!==t)return _nt(pht,this).splice(e+1,_nt(vht,this)-e),void Snt(vht,this,e);_nt(pht,this).length=0,Snt(vht,this,-1)}}destroy(){Snt(pht,this,null)}}var yht=new WeakSet;class bht{constructor(t){Mnt(this,yht),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;var{isMac:e}=ilt.platform;for(var[r,n,i={}]of t)for(var a of r){var s=a.startsWith("mac+");e&&s?(this.callbacks.set(a.slice(4),{callback:n,options:i}),this.allKeys.add(a.split("+").at(-1))):e||s||(this.callbacks.set(a,{callback:n,options:i}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(this.allKeys.has(e.key)){var r=this.callbacks.get(bnt(yht,this,wht).call(this,e));if(r){var{callback:n,options:{bubbles:i=!1,args:a=[],checker:s=null}}=r;s&&!s(t,e)||(n.bind(t,...a,e)(),i||Elt(e))}}}}function wht(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);var e=this.buffer.join("+");return this.buffer.length=0,e}class xht{get _colors(){var t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){var e=document.createElement("span");for(var r of(e.style.visibility="hidden",document.body.append(e),t.keys())){e.style.color=r;var n=window.getComputedStyle(e).color;t.set(r,Plt(n))}e.remove()}(t),Vot(this,"_colors",t)}convert(t){var e=Plt(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(var[r,n]of this._colors)if(n.every(((t,r)=>t===e[r])))return xht._colorsMapping.get(r);return e}getHexCode(t){var e=this._colors.get(t);return e?slt.makeHexColor(...e):t}}Tnt(xht,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));var Aht=new WeakMap,_ht=new WeakMap,kht=new WeakMap,Sht=new WeakMap,Eht=new WeakMap,Mht=new WeakMap,Tht=new WeakMap,Cht=new WeakMap,Pht=new WeakMap,Iht=new WeakMap,Rht=new WeakMap,Oht=new WeakMap,Lht=new WeakMap,Dht=new WeakMap,Fht=new WeakMap,Nht=new WeakMap,jht=new WeakMap,Bht=new WeakMap,zht=new WeakMap,Wht=new WeakMap,Uht=new WeakMap,Hht=new WeakMap,Ght=new WeakMap,Yht=new WeakMap,Vht=new WeakMap,qht=new WeakMap,Xht=new WeakMap,$ht=new WeakMap,Kht=new WeakMap,Qht=new WeakMap,Jht=new WeakMap,Zht=new WeakMap,tct=new WeakMap,ect=new WeakMap,rct=new WeakMap,nct=new WeakMap,ict=new WeakMap,act=new WeakMap,sct=new WeakMap,oct=new WeakMap,lct=new WeakMap,hct=new WeakMap,cct=new WeakSet;class uct{static get _keyboardManager(){var t=uct.prototype,e=t=>_nt(oct,t).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),r=(t,e)=>{var{target:r}=e;if(r instanceof HTMLInputElement){var{type:n}=r;return"text"!==n&&"number"!==n}return!0},n=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return Vot(this,"_keyboardManager",new bht([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:r}],[["ctrl+z","mac+meta+z"],t.undo,{checker:r}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:r}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:r}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,e)=>{var{target:r}=e;return!(r instanceof HTMLButtonElement)&&_nt(oct,t).contains(r)&&!t.isEnterHandled}}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,e)=>{var{target:r}=e;return!(r instanceof HTMLButtonElement)&&_nt(oct,t).contains(document.activeElement)}}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}]]))}constructor(t,e,r,n,i,a,s,o,l,h,c,u,d){Mnt(this,cct),knt(this,Aht,new AbortController),knt(this,_ht,null),knt(this,kht,new Map),knt(this,Sht,new Map),knt(this,Eht,null),knt(this,Mht,null),knt(this,Tht,null),knt(this,Cht,new mht),knt(this,Pht,null),knt(this,Iht,null),knt(this,Rht,0),knt(this,Oht,new Set),knt(this,Lht,null),knt(this,Dht,null),knt(this,Fht,new Set),Tnt(this,"_editorUndoBar",null),knt(this,Nht,!1),knt(this,jht,!1),knt(this,Bht,!1),knt(this,zht,null),knt(this,Wht,null),knt(this,Uht,null),knt(this,Hht,null),knt(this,Ght,!1),knt(this,Yht,null),knt(this,Vht,new aht),knt(this,qht,!1),knt(this,Xht,!1),knt(this,$ht,null),knt(this,Kht,null),knt(this,Qht,null),knt(this,Jht,null),knt(this,Zht,rot.NONE),knt(this,tct,new Set),knt(this,ect,null),knt(this,rct,null),knt(this,nct,null),knt(this,ict,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),knt(this,act,[0,0]),knt(this,sct,null),knt(this,oct,null),knt(this,lct,null),knt(this,hct,null);var p=this._signal=_nt(Aht,this).signal;Snt(oct,this,t),Snt(lct,this,e),Snt(Eht,this,r),this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:p}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),n._on("setpreference",this.onSetPreference.bind(this),{signal:p}),n._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),bnt(cct,this,mct).call(this),bnt(cct,this,kct).call(this),bnt(cct,this,wct).call(this),Snt(Mht,this,i.annotationStorage),Snt(zht,this,i.filterFactory),Snt(rct,this,a),Snt(Hht,this,s||null),Snt(Nht,this,o),Snt(jht,this,l),Snt(Bht,this,h),Snt(Jht,this,c||null),this.viewParameters={realScale:flt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=u||null,this._supportsPinchToZoom=!1!==d}destroy(){var t,e,r,n,i;for(var a of(null===(t=_nt(hct,this))||void 0===t||t.resolve(),Snt(hct,this,null),null===(e=_nt(Aht,this))||void 0===e||e.abort(),Snt(Aht,this,null),this._signal=null,_nt(Sht,this).values()))a.destroy();_nt(Sht,this).clear(),_nt(kht,this).clear(),_nt(Fht,this).clear(),Snt(_ht,this,null),_nt(tct,this).clear(),_nt(Cht,this).destroy(),null===(r=_nt(Eht,this))||void 0===r||r.destroy(),null===(n=_nt(Yht,this))||void 0===n||n.hide(),Snt(Yht,this,null),_nt(Wht,this)&&(clearTimeout(_nt(Wht,this)),Snt(Wht,this,null)),_nt(sct,this)&&(clearTimeout(_nt(sct,this)),Snt(sct,this,null)),null===(i=this._editorUndoBar)||void 0===i||i.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return _nt(Jht,this)}get useNewAltTextFlow(){return _nt(jht,this)}get useNewAltTextWhenAddingImage(){return _nt(Bht,this)}get hcmFilter(){return Vot(this,"hcmFilter",_nt(rct,this)?_nt(zht,this).addHCMFilter(_nt(rct,this).foreground,_nt(rct,this).background):"none")}get direction(){return Vot(this,"direction",getComputedStyle(_nt(oct,this)).direction)}get highlightColors(){return Vot(this,"highlightColors",_nt(Hht,this)?new Map(_nt(Hht,this).split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return Vot(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),Snt(Iht,this,t)}setMainHighlightColorPicker(t){Snt(Qht,this,t)}editAltText(t){var e,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null===(e=_nt(Eht,this))||void 0===e||e.editAltText(this,t,r)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference(t){var{name:e,value:r}=t;if("enableNewAltTextWhenAddingImage"===e)Snt(Bht,this,r)}onPageChanging(t){var{pageNumber:e}=t;Snt(Rht,this,e-1)}focusMainContainer(){_nt(oct,this).focus()}findParent(t,e){for(var r of _nt(Sht,this).values()){var{x:n,y:i,width:a,height:s}=r.div.getBoundingClientRect();if(t>=n&&t<=n+a&&e>=i&&e<=i+s)return r}return null}disableUserSelect(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];_nt(lct,this).classList.toggle("noUserSelect",t)}addShouldRescale(t){_nt(Fht,this).add(t)}removeShouldRescale(t){_nt(Fht,this).delete(t)}onScaleChanging(t){var e,{scale:r}=t;for(var n of(this.commitOrRemove(),this.viewParameters.realScale=r*flt.PDF_TO_CSS_UNITS,_nt(Fht,this)))n.onScaleChanging();null===(e=_nt(Iht,this))||void 0===e||e.onScaleChanging()}onRotationChanging(t){var{pagesRotation:e}=t;this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=document.getSelection();if(e&&!e.isCollapsed){var{anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:a}=e,s=e.toString(),o=bnt(cct,this,dct).call(this,e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(l){e.empty();var h=bnt(cct,this,pct).call(this,o),c=_nt(Zht,this)===rot.NONE,u=()=>{null==h||h.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:a,text:s}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(rot.HIGHLIGHT,u):u()}}}addToAnnotationStorage(t){t.isEmpty()||!_nt(Mht,this)||_nt(Mht,this).has(t.id)||_nt(Mht,this).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,_nt(Ght,this)&&(Snt(Ght,this,!1),bnt(cct,this,vct).call(this,"main_toolbar")),this.hasSelection){var{activeElement:t}=document;for(var e of _nt(tct,this))if(e.div.contains(t)){Snt(Kht,this,[e,t]),e._focusEventsAllowed=!1;break}}}focus(){if(_nt(Kht,this)){var[t,e]=_nt(Kht,this);Snt(Kht,this,null),e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}}addEditListeners(){bnt(cct,this,wct).call(this),bnt(cct,this,Act).call(this)}removeEditListeners(){bnt(cct,this,xct).call(this),bnt(cct,this,_ct).call(this)}dragOver(t){for(var{type:e}of t.dataTransfer.items)for(var r of _nt(Dht,this))if(r.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(var e of t.dataTransfer.items)for(var r of _nt(Dht,this))if(r.isHandlingMimeForPasting(e.type))return r.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null===(e=_nt(_ht,this))||void 0===e||e.commitOrRemove(),this.hasSelection){var r=[];for(var n of _nt(tct,this)){var i=n.serialize(!0);i&&r.push(i)}0!==r.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(r))}}cut(t){this.copy(t),this.delete()}paste(t){var e=this;return xnt((function*(){t.preventDefault();var{clipboardData:r}=t;for(var n of r.items)for(var i of _nt(Dht,e))if(i.isHandlingMimeForPasting(n.type))return void i.paste(n,e.currentLayer);var a=r.getData("application/pdfjs");if(a){try{a=JSON.parse(a)}catch(t){return void Uot('paste: "'.concat(t.message,'".'))}if(Array.isArray(a)){e.unselectAll();var s=e.currentLayer;try{var o=[];for(var l of a){var h=yield s.deserialize(l);if(!h)return;o.push(h)}e.addCommands({cmd:()=>{for(var t of o)bnt(cct,e,Pct).call(e,t);bnt(cct,e,Oct).call(e,o)},undo:()=>{for(var t of o)t.remove()},mustExec:!0})}catch(t){Uot('paste: "'.concat(t.message,'".'))}}}}))()}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),_nt(Zht,this)===rot.NONE||this.isEditorHandlingKeyboard||uct._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,_nt(Ght,this)&&(Snt(Ght,this,!1),bnt(cct,this,vct).call(this,"main_toolbar")))}onEditingAction(t){var{name:e}=t;switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(t){t?(bnt(cct,this,yct).call(this),bnt(cct,this,Act).call(this),bnt(cct,this,Sct).call(this,{isEditing:_nt(Zht,this)!==rot.NONE,isEmpty:bnt(cct,this,Rct).call(this),hasSomethingToUndo:_nt(Cht,this).hasSomethingToUndo(),hasSomethingToRedo:_nt(Cht,this).hasSomethingToRedo(),hasSelectedEditor:!1})):(bnt(cct,this,bct).call(this),bnt(cct,this,_ct).call(this),bnt(cct,this,Sct).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!_nt(Dht,this))for(var e of(Snt(Dht,this,t),_nt(Dht,this)))bnt(cct,this,Ect).call(this,e.defaultPropertiesToUpdate)}getId(){return _nt(Vht,this).id}get currentLayer(){return _nt(Sht,this).get(_nt(Rht,this))}getLayer(t){return _nt(Sht,this).get(t)}get currentPageIndex(){return _nt(Rht,this)}addLayer(t){_nt(Sht,this).set(t.pageIndex,t),_nt(qht,this)?t.enable():t.disable()}removeLayer(t){_nt(Sht,this).delete(t.pageIndex)}updateMode(t){var e=arguments,r=this;return xnt((function*(){var n=e.length>1&&void 0!==e[1]?e[1]:null,i=e.length>2&&void 0!==e[2]&&e[2];if(_nt(Zht,r)!==t&&(!_nt(hct,r)||(yield _nt(hct,r).promise,_nt(hct,r)))){var a;if(Snt(hct,r,Promise.withResolvers()),Snt(Zht,r,t),t===rot.NONE)return r.setEditingState(!1),bnt(cct,r,Cct).call(r),null===(a=r._editorUndoBar)||void 0===a||a.hide(),void _nt(hct,r).resolve();for(var s of(r.setEditingState(!0),yield bnt(cct,r,Mct).call(r),r.unselectAll(),_nt(Sht,r).values()))s.updateMode(t);if(!n)return i&&r.addNewEditorFromKeyboard(),void _nt(hct,r).resolve();for(var o of _nt(kht,r).values())o.annotationElementId===n?(r.setSelected(o),o.enterInEditMode()):o.unselect();_nt(hct,r).resolve()}}))()}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==_nt(Zht,this)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var r;if(_nt(Dht,this)){switch(t){case not.CREATE:return void this.currentLayer.addNewEditor();case not.HIGHLIGHT_DEFAULT_COLOR:null===(r=_nt(Qht,this))||void 0===r||r.updateColor(e);break;case not.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(_nt(nct,this)||Snt(nct,this,new Map)).set(t,e),this.showAllEditors("highlight",e)}for(var n of _nt(tct,this))n.updateParams(t,e);for(var i of _nt(Dht,this))i.updateDefaultParams(t,e)}}showAllEditors(t,e){var r,n;for(var i of _nt(kht,this).values())i.editorType===t&&i.show(e);(null===(r=null===(n=_nt(nct,this))||void 0===n?void 0:n.get(not.HIGHLIGHT_SHOW_ALL))||void 0===r||r)!==e&&bnt(cct,this,Ect).call(this,[[not.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(_nt(Xht,this)!==t)for(var e of(Snt(Xht,this,t),_nt(Sht,this).values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}getEditors(t){var e=[];for(var r of _nt(kht,this).values())r.pageIndex===t&&e.push(r);return e}getEditor(t){return _nt(kht,this).get(t)}addEditor(t){_nt(kht,this).set(t.id,t)}removeEditor(t){var e;(t.div.contains(document.activeElement)&&(_nt(Wht,this)&&clearTimeout(_nt(Wht,this)),Snt(Wht,this,setTimeout((()=>{this.focusMainContainer(),Snt(Wht,this,null)}),0))),_nt(kht,this).delete(t.id),this.unselect(t),t.annotationElementId&&_nt(Oht,this).has(t.annotationElementId))||(null===(e=_nt(Mht,this))||void 0===e||e.remove(t.id))}addDeletedAnnotationElement(t){_nt(Oht,this).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return _nt(Oht,this).has(t)}removeDeletedAnnotationElement(t){_nt(Oht,this).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){_nt(_ht,this)!==t&&(Snt(_ht,this,t),t&&bnt(cct,this,Ect).call(this,t.propertiesToUpdate))}updateUI(t){Ent(cct,this,Ict)===t&&bnt(cct,this,Ect).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){bnt(cct,this,Ect).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(_nt(tct,this).has(t))return _nt(tct,this).delete(t),t.unselect(),void bnt(cct,this,Sct).call(this,{hasSelectedEditor:this.hasSelection});_nt(tct,this).add(t),t.select(),bnt(cct,this,Ect).call(this,t.propertiesToUpdate),bnt(cct,this,Sct).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;for(var r of(null===(e=_nt(Iht,this))||void 0===e||e.commitOrRemove(),_nt(tct,this)))r!==t&&r.unselect();_nt(tct,this).clear(),_nt(tct,this).add(t),t.select(),bnt(cct,this,Ect).call(this,t.propertiesToUpdate),bnt(cct,this,Sct).call(this,{hasSelectedEditor:!0})}isSelected(t){return _nt(tct,this).has(t)}get firstSelectedEditor(){return _nt(tct,this).values().next().value}unselect(t){t.unselect(),_nt(tct,this).delete(t),bnt(cct,this,Sct).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==_nt(tct,this).size}get isEnterHandled(){return 1===_nt(tct,this).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;_nt(Cht,this).undo(),bnt(cct,this,Sct).call(this,{hasSomethingToUndo:_nt(Cht,this).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:bnt(cct,this,Rct).call(this)}),null===(t=this._editorUndoBar)||void 0===t||t.hide()}redo(){_nt(Cht,this).redo(),bnt(cct,this,Sct).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:_nt(Cht,this).hasSomethingToRedo(),isEmpty:bnt(cct,this,Rct).call(this)})}addCommands(t){_nt(Cht,this).add(t),bnt(cct,this,Sct).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:bnt(cct,this,Rct).call(this)})}cleanUndoStack(t){_nt(Cht,this).cleanType(t)}delete(){var t;this.commitOrRemove();var e=null===(t=this.currentLayer)||void 0===t?void 0:t.endDrawingSession(!0);if(this.hasSelection||e){var r=e?[e]:[..._nt(tct,this)],n=()=>{for(var t of r)bnt(cct,this,Pct).call(this,t)};this.addCommands({cmd:()=>{var t;for(var e of(null===(t=this._editorUndoBar)||void 0===t||t.show(n,1===r.length?r[0].editorType:r.length),r))e.remove()},undo:n,mustExec:!0})}}commitOrRemove(){var t;null===(t=_nt(_ht,this))||void 0===t||t.commitOrRemove()}hasSomethingToControl(){return _nt(_ht,this)||this.hasSelection}selectAll(){for(var t of _nt(tct,this))t.commit();bnt(cct,this,Oct).call(this,_nt(kht,this).values())}unselectAll(){var t;if((!_nt(_ht,this)||(_nt(_ht,this).commitOrRemove(),_nt(Zht,this)===rot.NONE))&&(null===(t=_nt(Iht,this))||void 0===t||!t.commitOrRemove())&&this.hasSelection){for(var e of _nt(tct,this))e.unselect();_nt(tct,this).clear(),bnt(cct,this,Sct).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||this.commitOrRemove(),this.hasSelection){_nt(act,this)[0]+=t,_nt(act,this)[1]+=e;var[r,n]=_nt(act,this),i=[..._nt(tct,this)];for(var a of(_nt(sct,this)&&clearTimeout(_nt(sct,this)),Snt(sct,this,setTimeout((()=>{Snt(sct,this,null),_nt(act,this)[0]=_nt(act,this)[1]=0,this.addCommands({cmd:()=>{for(var t of i)_nt(kht,this).has(t.id)&&t.translateInPage(r,n)},undo:()=>{for(var t of i)_nt(kht,this).has(t.id)&&t.translateInPage(-r,-n)},mustExec:!1})}),1e3)),i))a.translateInPage(t,e)}}setUpDragSession(){if(this.hasSelection)for(var t of(this.disableUserSelect(!0),Snt(Lht,this,new Map),_nt(tct,this)))_nt(Lht,this).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!_nt(Lht,this))return!1;this.disableUserSelect(!1);var t=_nt(Lht,this);Snt(Lht,this,null);var e=!1;for(var[{x:r,y:n,pageIndex:i},a]of t)a.newX=r,a.newY=n,a.newPageIndex=i,e||(e=r!==a.savedX||n!==a.savedY||i!==a.savedPageIndex);if(!e)return!1;var s=(t,e,r,n)=>{if(_nt(kht,this).has(t.id)){var i=_nt(Sht,this).get(n);i?t._setParentAndPosition(i,e,r):(t.pageIndex=n,t.x=e,t.y=r)}};return this.addCommands({cmd:()=>{for(var[e,{newX:r,newY:n,newPageIndex:i}]of t)s(e,r,n,i)},undo:()=>{for(var[e,{savedX:r,savedY:n,savedPageIndex:i}]of t)s(e,r,n,i)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(_nt(Lht,this))for(var r of _nt(Lht,this).keys())r.drag(t,e)}rebuild(t){if(null===t.parent){var e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return(null===(t=this.getActive())||void 0===t?void 0:t.shouldGetKeyboardEvents())||1===_nt(tct,this).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return _nt(_ht,this)===t}getActive(){return _nt(_ht,this)}getMode(){return _nt(Zht,this)}get imageManager(){return Vot(this,"imageManager",new cht)}getSelectionBoxes(t){if(!t)return null;for(var e=document.getSelection(),r=0,n=e.rangeCount;r<n;r++)if(!t.contains(e.getRangeAt(r).commonAncestorContainer))return null;var i,{x:a,y:s,width:o,height:l}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":i=(t,e,r,n)=>({x:(e-s)/l,y:1-(t+r-a)/o,width:n/l,height:r/o});break;case"180":i=(t,e,r,n)=>({x:1-(t+r-a)/o,y:1-(e+n-s)/l,width:r/o,height:n/l});break;case"270":i=(t,e,r,n)=>({x:1-(e+n-s)/l,y:(t-a)/o,width:n/l,height:r/o});break;default:i=(t,e,r,n)=>({x:(t-a)/o,y:(e-s)/l,width:r/o,height:n/l})}for(var h=[],c=0,u=e.rangeCount;c<u;c++){var d=e.getRangeAt(c);if(!d.collapsed)for(var{x:p,y:f,width:g,height:v}of d.getClientRects())0!==g&&0!==v&&h.push(i(p,f,g,v))}return 0===h.length?null:h}addChangedExistingAnnotation(t){var{annotationElementId:e,id:r}=t;(_nt(Tht,this)||Snt(Tht,this,new Map)).set(e,r)}removeChangedExistingAnnotation(t){var e,{annotationElementId:r}=t;null===(e=_nt(Tht,this))||void 0===e||e.delete(r)}renderAnnotationElement(t){var e,r=null===(e=_nt(Tht,this))||void 0===e?void 0:e.get(t.data.id);if(r){var n=_nt(Mht,this).getRawValue(r);n&&(_nt(Zht,this)!==rot.NONE||n.hasBeenModified)&&n.renderAnnotationElement(t)}}}function dct(t){var{anchorNode:e}=t;return e.nodeType===Node.TEXT_NODE?e.parentElement:e}function pct(t){var{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(var r of _nt(Sht,this).values())if(r.hasTextLayer(t))return r;return null}function fct(){var t=document.getSelection();if(t&&!t.isCollapsed){var e=bnt(cct,this,dct).call(this,t).closest(".textLayer"),r=this.getSelectionBoxes(e);r&&(_nt(Yht,this)||Snt(Yht,this,new Zlt(this)),_nt(Yht,this).show(e,r,"ltr"===this.direction))}}function gct(){var t,e=document.getSelection();if(e&&!e.isCollapsed){var{anchorNode:r}=e;if(r!==_nt(ect,this)){var n,i=bnt(cct,this,dct).call(this,e).closest(".textLayer");if(i){if(null===(t=_nt(Yht,this))||void 0===t||t.hide(),Snt(ect,this,r),bnt(cct,this,Sct).call(this,{hasSelectedText:!0}),(_nt(Zht,this)===rot.HIGHLIGHT||_nt(Zht,this)===rot.NONE)&&(_nt(Zht,this)===rot.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),Snt(Ght,this,this.isShiftKeyDown),!this.isShiftKeyDown)){var a=_nt(Zht,this)===rot.HIGHLIGHT?bnt(cct,this,pct).call(this,i):null;null==a||a.toggleDrawing();var s=new AbortController,o=this.combinedSignal(s),l=t=>{"pointerup"===t.type&&0!==t.button||(s.abort(),null==a||a.toggleDrawing(!0),"pointerup"===t.type&&bnt(cct,this,vct).call(this,"main_toolbar"))};window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})}}else _nt(ect,this)&&(null===(n=_nt(Yht,this))||void 0===n||n.hide(),Snt(ect,this,null),bnt(cct,this,Sct).call(this,{hasSelectedText:!1}))}}else{var h;_nt(ect,this)&&(null===(h=_nt(Yht,this))||void 0===h||h.hide(),Snt(ect,this,null),bnt(cct,this,Sct).call(this,{hasSelectedText:!1}))}}function vct(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";_nt(Zht,this)===rot.HIGHLIGHT?this.highlightSelection(t):_nt(Nht,this)&&bnt(cct,this,fct).call(this)}function mct(){document.addEventListener("selectionchange",bnt(cct,this,gct).bind(this),{signal:this._signal})}function yct(){if(!_nt(Uht,this)){Snt(Uht,this,new AbortController);var t=this.combinedSignal(_nt(Uht,this));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}}function bct(){var t;null===(t=_nt(Uht,this))||void 0===t||t.abort(),Snt(Uht,this,null)}function wct(){if(!_nt($ht,this)){Snt($ht,this,new AbortController);var t=this.combinedSignal(_nt($ht,this));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}}function xct(){var t;null===(t=_nt($ht,this))||void 0===t||t.abort(),Snt($ht,this,null)}function Act(){if(!_nt(Pht,this)){Snt(Pht,this,new AbortController);var t=this.combinedSignal(_nt(Pht,this));document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}}function _ct(){var t;null===(t=_nt(Pht,this))||void 0===t||t.abort(),Snt(Pht,this,null)}function kct(){var t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}function Sct(t){var e=Object.entries(t).some((t=>{var[e,r]=t;return _nt(ict,this)[e]!==r}));e&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(_nt(ict,this),t)}),_nt(Zht,this)===rot.HIGHLIGHT&&!1===t.hasSelectedEditor&&bnt(cct,this,Ect).call(this,[[not.HIGHLIGHT_FREE,!0]]))}function Ect(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}function Mct(){return Tct.apply(this,arguments)}function Tct(){return(Tct=xnt((function*(){if(!_nt(qht,this)){Snt(qht,this,!0);var t=[];for(var e of _nt(Sht,this).values())t.push(e.enable());for(var r of(yield Promise.all(t),_nt(kht,this).values()))r.enable()}}))).apply(this,arguments)}function Cct(){if(this.unselectAll(),_nt(qht,this)){for(var t of(Snt(qht,this,!1),_nt(Sht,this).values()))t.disable();for(var e of _nt(kht,this).values())e.disable()}}function Pct(t){var e=_nt(Sht,this).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}function Ict(t){var e=null;for(e of _nt(tct,t));return e}function Rct(){if(0===_nt(kht,this).size)return!0;if(1===_nt(kht,this).size)for(var t of _nt(kht,this).values())return t.isEmpty();return!1}function Oct(t){for(var e of _nt(tct,this))e.unselect();for(var r of(_nt(tct,this).clear(),t))r.isEmpty()||(_nt(tct,this).add(r),r.select());bnt(cct,this,Sct).call(this,{hasSelectedEditor:this.hasSelection})}Tnt(uct,"TRANSLATE_SMALL",1),Tnt(uct,"TRANSLATE_BIG",10);var Lct=new WeakMap,Dct=new WeakMap,Fct=new WeakMap,Nct=new WeakMap,jct=new WeakMap,Bct=new WeakMap,zct=new WeakMap,Wct=new WeakMap,Uct=new WeakMap,Hct=new WeakMap,Gct=new WeakMap,Yct=new WeakMap,Vct=new WeakSet;class qct{constructor(t){Mnt(this,Vct),knt(this,Lct,null),knt(this,Dct,!1),knt(this,Fct,null),knt(this,Nct,null),knt(this,jct,null),knt(this,Bct,null),knt(this,zct,!1),knt(this,Wct,null),knt(this,Uct,null),knt(this,Hct,null),knt(this,Gct,null),knt(this,Yct,!1),Snt(Uct,this,t),Snt(Yct,this,t._uiManager.useNewAltTextFlow),Qct._||(Qct._=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){var e;null!==(e=qct._l10n)&&void 0!==e||(qct._l10n=t)}render(){var t=this;return xnt((function*(){var e=Snt(Fct,t,document.createElement("button"));e.className="altText",e.tabIndex="0";var r=Snt(Nct,t,document.createElement("span"));e.append(r),_nt(Yct,t)?(e.classList.add("new"),e.setAttribute("data-l10n-id",Qct._.missing),r.setAttribute("data-l10n-id",Qct._["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));var n=_nt(Uct,t)._uiManager._signal;e.addEventListener("contextmenu",Slt,{signal:n}),e.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:n});var i=e=>{e.preventDefault(),_nt(Uct,t)._uiManager.editAltText(_nt(Uct,t)),_nt(Yct,t)&&_nt(Uct,t)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:Ent(Vct,t,Xct)}})};return e.addEventListener("click",i,{capture:!0,signal:n}),e.addEventListener("keydown",(r=>{r.target===e&&"Enter"===r.key&&(Snt(zct,t,!0),i(r))}),{signal:n}),yield bnt(Vct,t,$ct).call(t),e}))()}finish(){_nt(Fct,this)&&(_nt(Fct,this).focus({focusVisible:_nt(zct,this)}),Snt(zct,this,!1))}isEmpty(){return _nt(Yct,this)?null===_nt(Lct,this):!_nt(Lct,this)&&!_nt(Dct,this)}hasData(){return _nt(Yct,this)?null!==_nt(Lct,this)||!!_nt(Hct,this):this.isEmpty()}get guessedText(){return _nt(Hct,this)}setGuessedText(t){var e=this;return xnt((function*(){null===_nt(Lct,e)&&(Snt(Hct,e,t),Snt(Gct,e,yield qct._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),bnt(Vct,e,$ct).call(e))}))()}toggleAltTextBadge(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!_nt(Yct,this)||_nt(Lct,this))return null===(t=_nt(Wct,this))||void 0===t||t.remove(),void Snt(Wct,this,null);if(!_nt(Wct,this)){var r=Snt(Wct,this,document.createElement("div"));r.className="noAltTextBadge",_nt(Uct,this).div.append(r)}_nt(Wct,this).classList.toggle("hidden",!e)}serialize(t){var e=_nt(Lct,this);return t||_nt(Hct,this)!==e||(e=_nt(Gct,this)),{altText:e,decorative:_nt(Dct,this),guessedText:_nt(Hct,this),textWithDisclaimer:_nt(Gct,this)}}get data(){return{altText:_nt(Lct,this),decorative:_nt(Dct,this)}}set data(t){var{altText:e,decorative:r,guessedText:n,textWithDisclaimer:i,cancel:a=!1}=t;n&&(Snt(Hct,this,n),Snt(Gct,this,i)),_nt(Lct,this)===e&&_nt(Dct,this)===r||(a||(Snt(Lct,this,e),Snt(Dct,this,r)),bnt(Vct,this,$ct).call(this))}toggle(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];_nt(Fct,this)&&(!t&&_nt(Bct,this)&&(clearTimeout(_nt(Bct,this)),Snt(Bct,this,null)),_nt(Fct,this).disabled=!t)}shown(){_nt(Uct,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:Ent(Vct,this,Xct)}})}destroy(){var t,e;null===(t=_nt(Fct,this))||void 0===t||t.remove(),Snt(Fct,this,null),Snt(Nct,this,null),Snt(jct,this,null),null===(e=_nt(Wct,this))||void 0===e||e.remove(),Snt(Wct,this,null)}}function Xct(t){return(_nt(Lct,t)?"added":null===_nt(Lct,t)&&t.guessedText&&"review")||"missing"}function $ct(){return Kct.apply(this,arguments)}function Kct(){return(Kct=xnt((function*(){var t=_nt(Fct,this);if(t){if(_nt(Yct,this)){var e,r;if(t.classList.toggle("done",!!_nt(Lct,this)),t.setAttribute("data-l10n-id",Qct._[Ent(Vct,this,Xct)]),null===(e=_nt(Nct,this))||void 0===e||e.setAttribute("data-l10n-id",Qct._["".concat(Ent(Vct,this,Xct),"-label")]),!_nt(Lct,this))return void(null===(r=_nt(jct,this))||void 0===r||r.remove())}else{var n;if(!_nt(Lct,this)&&!_nt(Dct,this))return t.classList.remove("done"),void(null===(n=_nt(jct,this))||void 0===n||n.remove());t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}var i=_nt(jct,this);if(!i){Snt(jct,this,i=document.createElement("span")),i.className="tooltip",i.setAttribute("role","tooltip"),i.id="alt-text-tooltip-".concat(_nt(Uct,this).id);var a=_nt(Uct,this)._uiManager._signal;a.addEventListener("abort",(()=>{clearTimeout(_nt(Bct,this)),Snt(Bct,this,null)}),{once:!0}),t.addEventListener("mouseenter",(()=>{Snt(Bct,this,setTimeout((()=>{Snt(Bct,this,null),_nt(jct,this).classList.add("show"),_nt(Uct,this)._reportTelemetry({action:"alt_text_tooltip"})}),100))}),{signal:a}),t.addEventListener("mouseleave",(()=>{var t;_nt(Bct,this)&&(clearTimeout(_nt(Bct,this)),Snt(Bct,this,null)),null===(t=_nt(jct,this))||void 0===t||t.classList.remove("show")}),{signal:a})}_nt(Dct,this)?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=_nt(Lct,this)),i.parentNode||t.append(i);var s=_nt(Uct,this).getImageForAltText();null==s||s.setAttribute("aria-describedby",i.id)}}))).apply(this,arguments)}var Qct={_:null};Tnt(qct,"_l10n",null);var Jct=new WeakMap,Zct=new WeakMap,tut=new WeakMap,eut=new WeakMap,rut=new WeakMap,nut=new WeakMap,iut=new WeakMap,aut=new WeakMap,sut=new WeakMap,out=new WeakMap,lut=new WeakMap,hut=new WeakSet;class cut{constructor(t){var{container:e,isPinchingDisabled:r=null,isPinchingStopped:n=null,onPinchStart:i=null,onPinching:a=null,onPinchEnd:s=null,signal:o}=t;Mnt(this,hut),knt(this,Jct,void 0),knt(this,Zct,!1),knt(this,tut,null),knt(this,eut,void 0),knt(this,rut,void 0),knt(this,nut,void 0),knt(this,iut,void 0),knt(this,aut,void 0),knt(this,sut,null),knt(this,out,void 0),knt(this,lut,null),Snt(Jct,this,e),Snt(tut,this,n),Snt(eut,this,r),Snt(rut,this,i),Snt(nut,this,a),Snt(iut,this,s),Snt(out,this,new AbortController),Snt(aut,this,AbortSignal.any([o,_nt(out,this).signal])),e.addEventListener("touchstart",bnt(hut,this,uut).bind(this),{passive:!1,signal:_nt(aut,this)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Vot(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}destroy(){var t;null===(t=_nt(out,this))||void 0===t||t.abort(),Snt(out,this,null)}}function uut(t){var e,r;if(!(null!==(e=_nt(eut,this))&&void 0!==e&&e.call(this)||t.touches.length<2)){if(!_nt(lut,this)){var n;Snt(lut,this,new AbortController);var i=AbortSignal.any([_nt(aut,this),_nt(lut,this).signal]),a=_nt(Jct,this),s={signal:i,passive:!1};a.addEventListener("touchmove",bnt(hut,this,dut).bind(this),s),a.addEventListener("touchend",bnt(hut,this,put).bind(this),s),a.addEventListener("touchcancel",bnt(hut,this,put).bind(this),s),null===(n=_nt(rut,this))||void 0===n||n.call(this)}if(Elt(t),2!==t.touches.length||null!==(r=_nt(tut,this))&&void 0!==r&&r.call(this))Snt(sut,this,null);else{var[o,l]=t.touches;o.identifier>l.identifier&&([o,l]=[l,o]),Snt(sut,this,{touch0X:o.screenX,touch0Y:o.screenY,touch1X:l.screenX,touch1Y:l.screenY})}}}function dut(t){var e;if(_nt(sut,this)&&2===t.touches.length){var[r,n]=t.touches;r.identifier>n.identifier&&([r,n]=[n,r]);var{screenX:i,screenY:a}=r,{screenX:s,screenY:o}=n,l=_nt(sut,this),{touch0X:h,touch0Y:c,touch1X:u,touch1Y:d}=l,p=u-h,f=d-c,g=s-i,v=o-a,m=Math.hypot(g,v)||1,y=Math.hypot(p,f)||1;if(_nt(Zct,this)||!(Math.abs(y-m)<=Cst.MIN_TOUCH_DISTANCE_TO_PINCH))if(l.touch0X=i,l.touch0Y=a,l.touch1X=s,l.touch1Y=o,t.preventDefault(),_nt(Zct,this)){var b=[(i+s)/2,(a+o)/2];null===(e=_nt(nut,this))||void 0===e||e.call(this,b,y,m)}else Snt(Zct,this,!0)}}function put(t){var e;_nt(lut,this).abort(),Snt(lut,this,null),null===(e=_nt(iut,this))||void 0===e||e.call(this),_nt(sut,this)&&(t.preventDefault(),Snt(sut,this,null),Snt(Zct,this,!1))}Cst=cut;var fut=new WeakMap,gut=new WeakMap,vut=new WeakMap,mut=new WeakMap,yut=new WeakMap,but=new WeakMap,wut=new WeakMap,xut=new WeakMap,Aut=new WeakMap,_ut=new WeakMap,kut=new WeakMap,Sut=new WeakMap,Eut=new WeakMap,Mut=new WeakMap,Tut=new WeakMap,Cut=new WeakMap,Put=new WeakMap,Iut=new WeakMap,Rut=new WeakMap,Out=new WeakMap,Lut=new WeakMap,Dut=new WeakMap,Fut=new WeakMap,Nut=new WeakMap,jut=new WeakSet;class But{static get _resizerKeyboardManager(){var t=But.prototype._resizeWithKeyboard,e=uct.TRANSLATE_SMALL,r=uct.TRANSLATE_BIG;return Vot(this,"_resizerKeyboardManager",new bht([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-r,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[r,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-r]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,r]}],[["Escape","mac+Escape"],But.prototype._stopResizingWithKeyboard]]))}constructor(t){Mnt(this,jut),knt(this,fut,null),knt(this,gut,null),knt(this,vut,null),knt(this,mut,!1),knt(this,yut,null),knt(this,but,""),knt(this,wut,!1),knt(this,xut,null),knt(this,Aut,null),knt(this,_ut,null),knt(this,kut,null),knt(this,Sut,""),knt(this,Eut,!1),knt(this,Mut,null),knt(this,Tut,!1),knt(this,Cut,!1),knt(this,Put,!1),knt(this,Iut,null),knt(this,Rut,0),knt(this,Out,0),knt(this,Lut,null),knt(this,Dut,null),Tnt(this,"_editToolbar",null),Tnt(this,"_initialOptions",Object.create(null)),Tnt(this,"_initialData",null),Tnt(this,"_isVisible",!0),Tnt(this,"_uiManager",null),Tnt(this,"_focusEventsAllowed",!0),knt(this,Fut,!1),knt(this,Nut,But._zIndex++),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;var{rotation:e,rawDims:{pageWidth:r,pageHeight:n,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,n],this.pageTranslation=[i,a];var[s,o]=this.parentDimensions;this.x=t.x/s,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Vot(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){var e=new adt({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){var r;if(null!==(r=But._l10n)&&void 0!==r||(But._l10n=t),But._l10nResizer||(But._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),-1===But._borderLineWidth){var n=getComputedStyle(document.documentElement);But._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Hot("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return _nt(Fut,this)}set _isDraggable(t){var e;Snt(Fut,this,t),null===(e=this.div)||void 0===e||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){var[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=_nt(Nut,this)}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):bnt(jut,this,idt).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(_nt(Eut,this)?Snt(Eut,this,!1):this.parent.setSelected(this))}focusout(t){var e;if(this._focusEventsAllowed&&this.isAttachedToDOM){var r=t.relatedTarget;null!=r&&r.closest("#".concat(this.id))||(t.preventDefault(),null!==(e=this.parent)&&void 0!==e&&e.isMultipleSelection||this.commitOrRemove())}}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,r,n){var[i,a]=this.parentDimensions;[r,n]=this.screenToPageTranslation(r,n),this.x=(t+r)/i,this.y=(e+n)/a,this.fixAndSetPosition()}translate(t,e){bnt(jut,this,zut).call(this,this.parentDimensions,t,e)}translateInPage(t,e){_nt(Mut,this)||Snt(Mut,this,[this.x,this.y,this.width,this.height]),bnt(jut,this,zut).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){_nt(Mut,this)||Snt(Mut,this,[this.x,this.y,this.width,this.height]);var{div:r,parentDimensions:[n,i]}=this;if(this.x+=t/n,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){var{x:a,y:s}=this.div.getBoundingClientRect();this.parent.findNewParent(this,a,s)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}var{x:o,y:l}=this,[h,c]=this.getBaseTranslation();o+=h,l+=c;var{style:u}=r;u.left="".concat((100*o).toFixed(2),"%"),u.top="".concat((100*l).toFixed(2),"%"),this._onTranslating(o,l),r.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!_nt(Mut,this)&&(_nt(Mut,this)[0]!==this.x||_nt(Mut,this)[1]!==this.y)}get _hasBeenResized(){return!!_nt(Mut,this)&&(_nt(Mut,this)[2]!==this.width||_nt(Mut,this)[3]!==this.height)}getBaseTranslation(){var[t,e]=this.parentDimensions,{_borderLineWidth:r}=But,n=r/t,i=r/e;switch(this.rotation){case 90:return[-n,i];case 180:return[n,i];case 270:return[n,-i];default:return[-n,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.rotation,{div:{style:e},pageDimensions:[r,n]}=this,{x:i,y:a,width:s,height:o}=this;if(s*=r,o*=n,i*=r,a*=n,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(r-s,i)),a=Math.max(0,Math.min(n-o,a));break;case 90:i=Math.max(0,Math.min(r-o,i)),a=Math.min(n,Math.max(s,a));break;case 180:i=Math.min(r,Math.max(s,i)),a=Math.min(n,Math.max(o,a));break;case 270:i=Math.min(r,Math.max(o,i)),a=Math.max(0,Math.min(n-s,a))}this.x=i/=r,this.y=a/=n;var[l,h]=this.getBaseTranslation();i+=l,a+=h,e.left="".concat((100*i).toFixed(2),"%"),e.top="".concat((100*a).toFixed(2),"%"),this.moveInDOM()}screenToPageTranslation(t,e){return Wut.call(But,t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Wut.call(But,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){var{parentScale:t,pageDimensions:[e,r]}=this;return[e*t,r*t]}setDims(t,e){var[r,n]=this.parentDimensions,{style:i}=this.div;i.width="".concat((100*t/r).toFixed(2),"%"),_nt(wut,this)||(i.height="".concat((100*e/n).toFixed(2),"%"))}fixDims(){var{style:t}=this.div,{height:e,width:r}=t,n=r.endsWith("%"),i=!_nt(wut,this)&&e.endsWith("%");if(!n||!i){var[a,s]=this.parentDimensions;n||(t.width="".concat((100*parseFloat(r)/a).toFixed(2),"%")),_nt(wut,this)||i||(t.height="".concat((100*parseFloat(e)/s).toFixed(2),"%"))}}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(1e4*t)/1e4}_onResizing(){}altTextFinish(){var t;null===(t=_nt(vut,this))||void 0===t||t.finish()}addEditToolbar(){var t=this;return xnt((function*(){return t._editToolbar||_nt(Cut,t)||(t._editToolbar=new Wlt(t),t.div.append(t._editToolbar.render()),_nt(vut,t)&&(yield t._editToolbar.addAltText(_nt(vut,t)))),t._editToolbar}))()}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,null===(t=_nt(vut,this))||void 0===t||t.destroy())}addContainer(t){var e,r=null===(e=this._editToolbar)||void 0===e?void 0:e.div;r?r.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}addAltTextButton(){var t=this;return xnt((function*(){_nt(vut,t)||(qct.initialize(But._l10n),Snt(vut,t,new qct(t)),_nt(fut,t)&&(_nt(vut,t).data=_nt(fut,t),Snt(fut,t,null)),yield t.addEditToolbar())}))()}get altTextData(){var t;return null===(t=_nt(vut,this))||void 0===t?void 0:t.data}set altTextData(t){_nt(vut,this)&&(_nt(vut,this).data=t)}get guessedAltText(){var t;return null===(t=_nt(vut,this))||void 0===t?void 0:t.guessedText}setGuessedAltText(t){var e=this;return xnt((function*(){var r;yield null===(r=_nt(vut,e))||void 0===r?void 0:r.setGuessedText(t)}))()}serializeAltText(t){var e;return null===(e=_nt(vut,this))||void 0===e?void 0:e.serialize(t)}hasAltText(){return!!_nt(vut,this)&&!_nt(vut,this).isEmpty()}hasAltTextData(){var t,e;return null!==(t=null===(e=_nt(vut,this))||void 0===e?void 0:e.hasData())&&void 0!==t&&t}render(){var t;this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=_nt(mut,this)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),bnt(jut,this,Zut).call(this);var[e,r]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth="".concat((100*r/e).toFixed(2),"%"),this.div.style.maxHeight="".concat((100*e/r).toFixed(2),"%"));var[n,i]=this.getInitialTranslation();return this.translate(n,i),nht(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(_nt(Dut,this)||Snt(Dut,this,new cut({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:bnt(jut,this,Xut).bind(this),onPinching:bnt(jut,this,$ut).bind(this),onPinchEnd:bnt(jut,this,Kut).bind(this),signal:this._uiManager._signal}))),null===(t=this._uiManager._editorUndoBar)||void 0===t||t.hide(),this.div}pointerdown(t){var{isMac:e}=ilt.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(Snt(Eut,this,!0),this._isDraggable?bnt(jut,this,Jut).call(this,t):bnt(jut,this,Qut).call(this,t))}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){_nt(Iut,this)&&clearTimeout(_nt(Iut,this)),Snt(Iut,this,setTimeout((()=>{var t;Snt(Iut,this,null),null===(t=this.parent)||void 0===t||t.moveEditorInDOM(this)}),0))}_setParentAndPosition(t,e,r){t.changeParent(this),this.x=e,this.y=r,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.rotation,n=this.parentScale,[i,a]=this.pageDimensions,[s,o]=this.pageTranslation,l=t/n,h=e/n,c=this.x*i,u=this.y*a,d=this.width*i,p=this.height*a;switch(r){case 0:return[c+l+s,a-u-h-p+o,c+l+d+s,a-u-h+o];case 90:return[c+h+s,a-u+l+o,c+h+p+s,a-u+l+d+o];case 180:return[c-l-d+s,a-u+h+o,c-l+s,a-u+h+p+o];case 270:return[c-h-p+s,a-u-l-d+o,c-h+s,a-u-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){var[r,n,i,a]=t,s=i-r,o=a-n;switch(this.rotation){case 0:return[r,e-a,s,o];case 90:return[r,e-n,o,s];case 180:return[i,e-n,s,o];case 270:return[i,e-a,o,s];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){Snt(Cut,this,!0)}disableEditMode(){Snt(Cut,this,!1)}isInEditMode(){return _nt(Cut,this)}shouldGetKeyboardEvents(){return _nt(Put,this)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){var{top:t,left:e,bottom:r,right:n}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return e<a&&n>0&&t<i&&r>0}rebuild(){bnt(jut,this,Zut).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:(null===(t=this._initialData)||void 0===t?void 0:t.popupRef)||""}}serialize(){Hot("An editor must be serializable")}static deserialize(t,e,r){var n=this;return xnt((function*(){var i=new n.prototype.constructor({parent:e,id:e.getNextId(),uiManager:r});i.rotation=t.rotation,Snt(fut,i,t.accessibilityData);var[a,s]=i.pageDimensions,[o,l,h,c]=i.getRectInCurrentCoords(t.rect,s);return i.x=o/a,i.y=l/s,i.width=h/a,i.height=c/s,i}))()}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){var t,e;if(null===(t=_nt(kut,this))||void 0===t||t.abort(),Snt(kut,this,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),_nt(Iut,this)&&(clearTimeout(_nt(Iut,this)),Snt(Iut,this,null)),bnt(jut,this,idt).call(this),this.removeEditToolbar(),_nt(Lut,this)){for(var r of _nt(Lut,this).values())clearTimeout(r);Snt(Lut,this,null)}this.parent=null,null===(e=_nt(Dut,this))||void 0===e||e.destroy(),Snt(Dut,this,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(bnt(jut,this,Hut).call(this),_nt(xut,this).classList.remove("hidden"),nht(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(this.isResizable&&t.target===this.div&&"Enter"===t.key){this._uiManager.setSelected(this),Snt(_ut,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});var e=_nt(xut,this).children;if(!_nt(gut,this)){Snt(gut,this,Array.from(e));var r=bnt(jut,this,tdt).bind(this),n=bnt(jut,this,edt).bind(this),i=this._uiManager._signal;for(var a of _nt(gut,this)){var s=a.getAttribute("data-resizer-name");a.setAttribute("role","spinbutton"),a.addEventListener("keydown",r,{signal:i}),a.addEventListener("blur",n,{signal:i}),a.addEventListener("focus",bnt(jut,this,rdt).bind(this,s),{signal:i}),a.setAttribute("data-l10n-id",But._l10nResizer[s])}}var o=_nt(gut,this)[0],l=0;for(var h of e){if(h===o)break;l++}var c=(360-this.rotation+this.parentRotation)%360/90*(_nt(gut,this).length/4);if(c!==l){if(c<l)for(var u=0;u<l-c;u++)_nt(xut,this).append(_nt(xut,this).firstChild);else if(c>l)for(var d=0;d<c-l;d++)_nt(xut,this).firstChild.before(_nt(xut,this).lastChild);var p=0;for(var f of e){var g=_nt(gut,this)[p++].getAttribute("data-resizer-name");f.setAttribute("data-l10n-id",But._l10nResizer[g])}}bnt(jut,this,ndt).call(this,0),Snt(Put,this,!0),_nt(xut,this).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}}_resizeWithKeyboard(t,e){_nt(Put,this)&&bnt(jut,this,qut).call(this,_nt(Sut,this),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){bnt(jut,this,idt).call(this),this.div.focus()}select(){var t,e,r;this.makeResizable(),null===(t=this.div)||void 0===t||t.classList.add("selectedEditor"),this._editToolbar?(null===(e=this._editToolbar)||void 0===e||e.show(),null===(r=_nt(vut,this))||void 0===r||r.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{var t,e;null!==(t=this.div)&&void 0!==t&&t.classList.contains("selectedEditor")&&(null===(e=this._editToolbar)||void 0===e||e.show())}))}unselect(){var t,e,r,n,i;null===(t=_nt(xut,this))||void 0===t||t.classList.add("hidden"),null===(e=this.div)||void 0===e||e.classList.remove("selectedEditor"),null!==(r=this.div)&&void 0!==r&&r.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null===(n=this._editToolbar)||void 0===n||n.hide(),null===(i=_nt(vut,this))||void 0===i||i.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return _nt(Tut,this)}set isEditing(t){Snt(Tut,this,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){Snt(wut,this,!0);var r=t/e,{style:n}=this.div;n.aspectRatio=r,n.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){_nt(Lut,this)||Snt(Lut,this,new Map);var{action:e}=t,r=_nt(Lut,this).get(e);return r&&clearTimeout(r),r=setTimeout((()=>{this._reportTelemetry(t),_nt(Lut,this).delete(e),0===_nt(Lut,this).size&&Snt(Lut,this,null)}),But._telemetryTimeout),void _nt(Lut,this).set(e,r)}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),Snt(mut,this,!1)}disable(){this.div&&(this.div.tabIndex=-1),Snt(mut,this,!0)}renderAnnotationElement(t){var e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){var r=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),r.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){var{firstChild:e}=t.container;"DIV"===(null==e?void 0:e.nodeName)&&e.classList.contains("annotationContent")&&e.remove()}}function zut(t,e,r){var[n,i]=t;[e,r]=this.screenToPageTranslation(e,r),this.x+=e/n,this.y+=r/i,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}function Wut(t,e,r){switch(r){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}function Uut(t){switch(t){case 90:var[e,r]=this.pageDimensions;return[0,-e/r,r/e,0];case 180:return[-1,0,0,-1];case 270:var[n,i]=this.pageDimensions;return[0,n/i,-i/n,0];default:return[1,0,0,1]}}function Hut(){if(!_nt(xut,this)){Snt(xut,this,document.createElement("div")),_nt(xut,this).classList.add("resizers");var t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(var r of t){var n=document.createElement("div");_nt(xut,this).append(n),n.classList.add("resizer",r),n.setAttribute("data-resizer-name",r),n.addEventListener("pointerdown",bnt(jut,this,Gut).bind(this,r),{signal:e}),n.addEventListener("contextmenu",Slt,{signal:e}),n.tabIndex=-1}this.div.prepend(_nt(xut,this))}}function Gut(t,e){var r;e.preventDefault();var{isMac:n}=ilt.platform;if(!(0!==e.button||e.ctrlKey&&n)){null===(r=_nt(vut,this))||void 0===r||r.toggle(!1);var i=this._isDraggable;this._isDraggable=!1,Snt(Aut,this,[e.screenX,e.screenY]);var a=new AbortController,s=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",bnt(jut,this,qut).bind(this,t),{passive:!0,capture:!0,signal:s}),window.addEventListener("touchmove",Elt,{passive:!1,signal:s}),window.addEventListener("contextmenu",Slt,{signal:s}),Snt(_ut,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});var o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;var h=()=>{var t;a.abort(),this.parent.togglePointerEvents(!0),null===(t=_nt(vut,this))||void 0===t||t.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,bnt(jut,this,Vut).call(this)};window.addEventListener("pointerup",h,{signal:s}),window.addEventListener("blur",h,{signal:s})}}function Yut(t,e,r,n){this.width=r,this.height=n,this.x=t,this.y=e;var[i,a]=this.parentDimensions;this.setDims(i*r,a*n),this.fixAndSetPosition(),this._onResized()}function Vut(){if(_nt(_ut,this)){var{savedX:t,savedY:e,savedWidth:r,savedHeight:n}=_nt(_ut,this);Snt(_ut,this,null);var i=this.x,a=this.y,s=this.width,o=this.height;i===t&&a===e&&s===r&&o===n||this.addCommands({cmd:bnt(jut,this,Yut).bind(this,i,a,s,o),undo:bnt(jut,this,Yut).bind(this,t,e,r,n),mustExec:!0})}}function qut(t,e){var r,n,[i,a]=this.parentDimensions,s=this.x,o=this.y,l=this.width,h=this.height,c=Pst.MIN_SIZE/i,u=Pst.MIN_SIZE/a,d=bnt(jut,this,Uut).call(this,this.rotation),p=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],f=bnt(jut,this,Uut).call(this,360-this.rotation),g=!1,v=!1;switch(t){case"topLeft":g=!0,r=(t,e)=>[0,0],n=(t,e)=>[t,e];break;case"topMiddle":r=(t,e)=>[t/2,0],n=(t,e)=>[t/2,e];break;case"topRight":g=!0,r=(t,e)=>[t,0],n=(t,e)=>[0,e];break;case"middleRight":v=!0,r=(t,e)=>[t,e/2],n=(t,e)=>[0,e/2];break;case"bottomRight":g=!0,r=(t,e)=>[t,e],n=(t,e)=>[0,0];break;case"bottomMiddle":r=(t,e)=>[t/2,e],n=(t,e)=>[t/2,0];break;case"bottomLeft":g=!0,r=(t,e)=>[0,e],n=(t,e)=>[t,0];break;case"middleLeft":v=!0,r=(t,e)=>[0,e/2],n=(t,e)=>[t,e/2]}var m,y,b=r(l,h),w=n(l,h),x=p(...w),A=Pst._round(s+x[0]),_=Pst._round(o+x[1]),k=1,S=1;if(e.fromKeyboard)({deltaX:m,deltaY:y}=e);else{var{screenX:E,screenY:M}=e,[T,C]=_nt(Aut,this);[m,y]=this.screenToPageTranslation(E-T,M-C),_nt(Aut,this)[0]=E,_nt(Aut,this)[1]=M}if([m,y]=((t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e])(m/i,y/a),g){var P=Math.hypot(l,h);k=S=Math.max(Math.min(Math.hypot(w[0]-b[0]-m,w[1]-b[1]-y)/P,1/l,1/h),c/l,u/h)}else v?k=Math.max(c,Math.min(1,Math.abs(w[0]-b[0]-m)))/l:S=Math.max(u,Math.min(1,Math.abs(w[1]-b[1]-y)))/h;var I=Pst._round(l*k),R=Pst._round(h*S),O=A-(x=p(...n(I,R)))[0],L=_-x[1];_nt(Mut,this)||Snt(Mut,this,[this.x,this.y,this.width,this.height]),this.width=I,this.height=R,this.x=O,this.y=L,this.setDims(i*I,a*R),this.fixAndSetPosition(),this._onResizing()}function Xut(){var t;Snt(_ut,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),null===(t=_nt(vut,this))||void 0===t||t.toggle(!1),this.parent.togglePointerEvents(!1)}function $ut(t,e,r){var n=r/e*.7+1-.7;if(1!==n){var i=bnt(jut,this,Uut).call(this,this.rotation),a=(t,e)=>[i[0]*t+i[2]*e,i[1]*t+i[3]*e],[s,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,u=this.height,d=Pst.MIN_SIZE/s,p=Pst.MIN_SIZE/o;n=Math.max(Math.min(n,1/c,1/u),d/c,p/u);var f=Pst._round(c*n),g=Pst._round(u*n);if(f!==c||g!==u){_nt(Mut,this)||Snt(Mut,this,[l,h,c,u]);var v=a(c/2,u/2),m=Pst._round(l+v[0]),y=Pst._round(h+v[1]),b=a(f/2,g/2);this.x=m-b[0],this.y=y-b[1],this.width=f,this.height=g,this.setDims(s*f,o*g),this.fixAndSetPosition(),this._onResizing()}}}function Kut(){var t;null===(t=_nt(vut,this))||void 0===t||t.toggle(!0),this.parent.togglePointerEvents(!0),bnt(jut,this,Vut).call(this)}function Qut(t){var{isMac:e}=ilt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}function Jut(t){var{isSelected:e}=this;this._uiManager.setUpDragSession();var r=!1,n=new AbortController,i=this._uiManager.combinedSignal(n),a={capture:!0,passive:!1,signal:i},s=t=>{n.abort(),Snt(yut,this,null),Snt(Eut,this,!1),this._uiManager.endDragSession()||bnt(jut,this,Qut).call(this,t),r&&this._onStopDragging()};e&&(Snt(Rut,this,t.clientX),Snt(Out,this,t.clientY),Snt(yut,this,t.pointerId),Snt(but,this,t.pointerType),window.addEventListener("pointermove",(t=>{r||(r=!0,this._onStartDragging());var{clientX:e,clientY:n,pointerId:i}=t;if(i===_nt(yut,this)){var[a,s]=this.screenToPageTranslation(e-_nt(Rut,this),n-_nt(Out,this));Snt(Rut,this,e),Snt(Out,this,n),this._uiManager.dragSelectedEditors(a,s)}else Elt(t)}),a),window.addEventListener("touchmove",Elt,a),window.addEventListener("pointerdown",(t=>{t.pointerType===_nt(but,this)&&(_nt(Dut,this)||t.isPrimary)&&s(t),Elt(t)}),a));var o=t=>{_nt(yut,this)&&_nt(yut,this)!==t.pointerId?Elt(t):s(t)};window.addEventListener("pointerup",o,{signal:i}),window.addEventListener("blur",o,{signal:i})}function Zut(){if(!_nt(kut,this)&&this.div){Snt(kut,this,new AbortController);var t=this._uiManager.combinedSignal(_nt(kut,this));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}}function tdt(t){Pst._resizerKeyboardManager.exec(this,t)}function edt(t){var e;_nt(Put,this)&&(null===(e=t.relatedTarget)||void 0===e?void 0:e.parentNode)!==_nt(xut,this)&&bnt(jut,this,idt).call(this)}function rdt(t){Snt(Sut,this,_nt(Put,this)?t:"")}function ndt(t){if(_nt(gut,this))for(var e of _nt(gut,this))e.tabIndex=t}function idt(){Snt(Put,this,!1),bnt(jut,this,ndt).call(this,-1),bnt(jut,this,Vut).call(this)}Pst=But,Tnt(But,"_l10n",null),Tnt(But,"_l10nResizer",null),Tnt(But,"_borderLineWidth",-1),Tnt(But,"_colorManager",new xht),Tnt(But,"_zIndex",1),Tnt(But,"_telemetryTimeout",1e3);class adt extends But{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}var sdt=3285377520,odt=4294901760,ldt=65535;class hdt{constructor(t){this.h1=t?4294967295&t:sdt,this.h2=t?4294967295&t:sdt}update(t){var e,r;if("string"==typeof t){e=new Uint8Array(2*t.length),r=0;for(var n=0,i=t.length;n<i;n++){var a=t.charCodeAt(n);a<=255?e[r++]=a:(e[r++]=a>>>8,e[r++]=255&a)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");r=(e=t.slice()).byteLength}for(var s=r>>2,o=r-4*s,l=new Uint32Array(e.buffer,0,s),h=0,c=0,u=this.h1,d=this.h2,p=3432918353,f=461845907,g=11601,v=13715,m=0;m<s;m++)1&m?u=5*(u=(u^=h=(h=(h=(h=l[m])*p&odt|h*g&ldt)<<15|h>>>17)*f&odt|h*v&ldt)<<13|u>>>19)+3864292196:d=5*(d=(d^=c=(c=(c=(c=l[m])*p&odt|c*g&ldt)<<15|c>>>17)*f&odt|c*v&ldt)<<13|d>>>19)+3864292196;switch(h=0,o){case 3:h^=e[4*s+2]<<16;case 2:h^=e[4*s+1]<<8;case 1:h=(h=(h=(h^=e[4*s])*p&odt|h*g&ldt)<<15|h>>>17)*f&odt|h*v&ldt,1&s?u^=h:d^=h}this.h1=u,this.h2=d}hexdigest(){var t=this.h1,e=this.h2;return t=3981806797*(t^=e>>>1)&odt|36045*t&ldt,t=444984403*(t^=(e=4283543511*e&odt|(2950163797*(e<<16|t>>>16)&odt)>>>16)>>>1)&odt|60499*t&ldt,((t^=(e=3301882366*e&odt|(3120437893*(e<<16|t>>>16)&odt)>>>16)>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}var cdt=Object.freeze({map:null,hash:"",transfer:void 0}),udt=new WeakMap,ddt=new WeakMap,pdt=new WeakMap,fdt=new WeakSet;class gdt{constructor(){Mnt(this,fdt),knt(this,udt,!1),knt(this,ddt,null),knt(this,pdt,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){var r=_nt(pdt,this).get(t);return void 0===r?e:Object.assign(e,r)}getRawValue(t){return _nt(pdt,this).get(t)}remove(t){if(_nt(pdt,this).delete(t),0===_nt(pdt,this).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(var e of _nt(pdt,this).values())if(e instanceof But)return;this.onAnnotationEditor(null)}}setValue(t,e){var r=_nt(pdt,this).get(t),n=!1;if(void 0!==r)for(var[i,a]of Object.entries(e))r[i]!==a&&(n=!0,r[i]=a);else n=!0,_nt(pdt,this).set(t,e);n&&bnt(fdt,this,vdt).call(this),e instanceof But&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return _nt(pdt,this).has(t)}getAll(){return _nt(pdt,this).size>0?nlt(_nt(pdt,this)):null}setAll(t){for(var[e,r]of Object.entries(t))this.setValue(e,r)}get size(){return _nt(pdt,this).size}resetModified(){_nt(udt,this)&&(Snt(udt,this,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new ydt(this)}get serializable(){if(0===_nt(pdt,this).size)return cdt;var t=new Map,e=new hdt,r=[],n=Object.create(null),i=!1;for(var[a,s]of _nt(pdt,this)){var o=s instanceof But?s.serialize(!1,n):s;o&&(t.set(a,o),e.update("".concat(a,":").concat(JSON.stringify(o))),i||(i=!!o.bitmap))}if(i)for(var l of t.values())l.bitmap&&r.push(l.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:r}:cdt}get editorStats(){var t=null,e=new Map;for(var r of _nt(pdt,this).values()){var n;if(r instanceof But){var i=r.telemetryFinalData;if(i){var{type:a}=i;e.has(a)||e.set(a,Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));var s=(n=t)[a]||(n[a]=new Map);for(var[o,l]of Object.entries(i)){var h;if("type"!==o){var c=s.get(o);c||(c=new Map,s.set(o,c));var u=null!==(h=c.get(l))&&void 0!==h?h:0;c.set(l,u+1)}}}}}for(var[d,p]of e)t[d]=p.computeTelemetryFinalData(t[d]);return t}resetModifiedIds(){Snt(ddt,this,null)}get modifiedIds(){if(_nt(ddt,this))return _nt(ddt,this);var t=[];for(var e of _nt(pdt,this).values())e instanceof But&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return Snt(ddt,this,{ids:new Set(t),hash:t.join(",")})}}function vdt(){_nt(udt,this)||(Snt(udt,this,!0),"function"==typeof this.onSetModified&&this.onSetModified())}var mdt=new WeakMap;class ydt extends gdt{constructor(t){super(),knt(this,mdt,void 0);var{map:e,hash:r,transfer:n}=t.serializable,i=structuredClone(e,n?{transfer:n}:null);Snt(mdt,this,{map:i,hash:r,transfer:n})}get print(){Hot("Should not call PrintAnnotationStorage.print")}get serializable(){return _nt(mdt,this)}get modifiedIds(){return Vot(this,"modifiedIds",{ids:new Set,hash:""})}}var bdt=new WeakMap;class wdt{constructor(t){var{ownerDocument:e=globalThis.document,styleElement:r=null}=t;knt(this,bdt,new Set),this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));var e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(var t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),_nt(bdt,this).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(t){var e=this;return xnt((function*(){var{systemFontInfo:r,_inspectFont:n}=t;if(r&&!_nt(bdt,e).has(r.loadedName))if(Got(!e.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),e.isFontLoadingAPISupported){var{loadedName:i,src:a,style:s}=r,o=new FontFace(i,a,s);e.addNativeFontFace(o);try{yield o.load(),_nt(bdt,e).add(i),null==n||n(r)}catch(t){Uot("Cannot load system font: ".concat(r.baseFontName,", installing it could help to improve PDF rendering.")),e.removeNativeFontFace(o)}}else Hot("Not implemented: loadSystemFont without the Font Loading API.")}))()}bind(t){var e=this;return xnt((function*(){if(!(t.attached||t.missingFile&&!t.systemFontInfo))if(t.attached=!0,t.systemFontInfo)yield e.loadSystemFont(t);else if(e.isFontLoadingAPISupported){var r=t.createNativeFontFace();if(r){e.addNativeFontFace(r);try{yield r.loaded}catch(e){throw Uot("Failed to load font '".concat(r.family,"': '").concat(e,"'.")),t.disableFontFace=!0,e}}}else{var n=t.createFontFaceRule();if(n){if(e.insertRule(n),e.isSyncFontLoadingSupported)return;yield new Promise((r=>{var n=e._queueLoadingCallback(r);e._prepareFontLoadEvent(t,n)}))}}}))()}get isFontLoadingAPISupported(){var t;return Vot(this,"isFontLoadingAPISupported",!(null===(t=this._document)||void 0===t||!t.fonts))}get isSyncFontLoadingSupported(){var t,e=!1;return(Hst||"undefined"!=typeof navigator&&"string"==typeof(null===(t=navigator)||void 0===t?void 0:t.userAgent)&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),Vot(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(t){var{loadingRequests:e}=this,r={done:!1,complete:function(){for(Got(!r.done,"completeRequest() cannot be called twice."),r.done=!0;e.length>0&&e[0].done;){var t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(r),r}get _loadTestFont(){return Vot(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function r(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function n(t,e,r,n){return t.substring(0,e)+n+t.substring(e+r)}var i,a,s=this._document.createElement("canvas");s.width=1,s.height=1;var o=s.getContext("2d"),l=0;var h="lt".concat(Date.now()).concat(this.loadTestFontId++),c=this._loadTestFont,u=1482184792,d=r(c=n(c,976,h.length,h),16);for(i=0,a=h.length-3;i<a;i+=4)d=d-u+r(h,i)|0;i<h.length&&(d=d-u+r(h+"XXX",i)|0),c=n(c,16,4,function(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}(d));var p="url(data:font/opentype;base64,".concat(btoa(c),");"),f='@font-face {font-family:"'.concat(h,'";src:').concat(p,"}");this.insertRule(f);var g=this._document.createElement("div");for(var v of(g.style.visibility="hidden",g.style.width=g.style.height="10px",g.style.position="absolute",g.style.top=g.style.left="0px",[t.loadedName,h])){var m=this._document.createElement("span");m.textContent="Hi",m.style.fontFamily=v,g.append(m)}this._document.body.append(g),function t(e,r){if(++l>30)return Uot("Load test font never loaded."),void r();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?r():setTimeout(t.bind(null,e,r))}(h,(()=>{g.remove(),e.complete()}))}}class xdt{constructor(t,e){var{disableFontFace:r=!1,fontExtraProperties:n=!1,inspectFont:i=null}=e;for(var a in this.compiledGlyphs=Object.create(null),t)this[a]=t[a];this.disableFontFace=!0===r,this.fontExtraProperties=!0===n,this._inspectFont=i}createNativeFontFace(){var t,e;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){var r={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(r.style="oblique ".concat(this.cssFontInfo.italicAngle,"deg")),e=new FontFace(this.cssFontInfo.fontFamily,this.data,r)}else e=new FontFace(this.loadedName,this.data,{});return null===(t=this._inspectFont)||void 0===t||t.call(this,this),e}createFontFaceRule(){var t;if(!this.data||this.disableFontFace)return null;var e,r,n="url(data:".concat(this.mimetype,";base64,").concat((e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(elt(e))),");");if(this.cssFontInfo){var i="font-weight: ".concat(this.cssFontInfo.fontWeight,";");this.cssFontInfo.italicAngle&&(i+="font-style: oblique ".concat(this.cssFontInfo.italicAngle,"deg;")),r='@font-face {font-family:"'.concat(this.cssFontInfo.fontFamily,'";').concat(i,"src:").concat(n,"}")}else r='@font-face {font-family:"'.concat(this.loadedName,'";src:').concat(n,"}");return null===(t=this._inspectFont)||void 0===t||t.call(this,this,n),r}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];var r,n=this.loadedName+"_path_"+e;try{r=t.get(n)}catch(t){Uot('getPathGenerator - ignoring character: "'.concat(t,'".'))}var i=new Path2D(r||"");return this.fontExtraProperties||t.delete(n),this.compiledGlyphs[e]=i}}var Adt=1,_dt=2,kdt=1,Sdt=2,Edt=3,Mdt=4,Tdt=5,Cdt=6,Pdt=7,Idt=8;function Rdt(){}function Odt(t){if(t instanceof tlt||t instanceof Kot||t instanceof Qot||t instanceof Xot||t instanceof Jot||t instanceof $ot)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||Hot('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new tlt(t.message);case"InvalidPDFException":return new Kot(t.message);case"MissingPDFException":return new Qot(t.message);case"PasswordException":return new Xot(t.message,t.code);case"UnexpectedResponseException":return new Jot(t.message,t.status);case"UnknownErrorException":return new $ot(t.message,t.details)}return new $ot(t.message,t.toString())}var Ldt=new WeakMap,Ddt=new WeakSet;class Fdt{constructor(t,e,r){Mnt(this,Ddt),knt(this,Ldt,new AbortController),this.sourceName=t,this.targetName=e,this.comObj=r,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),r.addEventListener("message",bnt(Ddt,this,Ndt).bind(this),{signal:_nt(Ldt,this).signal})}on(t,e){var r=this.actionHandler;if(r[t])throw new Error('There is already an actionName called "'.concat(t,'"'));r[t]=e}send(t,e,r){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},r)}sendWithPromise(t,e,r){var n=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[n]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},r)}catch(t){i.reject(t)}return i.promise}sendWithStream(t,e,r,n){var i=this.streamId++,a=this.sourceName,s=this.targetName,o=this.comObj;return new ReadableStream({start:r=>{var l=Promise.withResolvers();return this.streamControllers[i]={controller:r,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:s,action:t,streamId:i,data:e,desiredSize:r.desiredSize},n),l.promise},pull:t=>{var e=Promise.withResolvers();return this.streamControllers[i].pullCall=e,o.postMessage({sourceName:a,targetName:s,stream:Cdt,streamId:i,desiredSize:t.desiredSize}),e.promise},cancel:t=>{Got(t instanceof Error,"cancel must have a valid reason");var e=Promise.withResolvers();return this.streamControllers[i].cancelCall=e,this.streamControllers[i].isClosed=!0,o.postMessage({sourceName:a,targetName:s,stream:kdt,streamId:i,reason:Odt(t)}),e.promise}},r)}destroy(){var t;null===(t=_nt(Ldt,this))||void 0===t||t.abort(),Snt(Ldt,this,null)}}function Ndt(t){var{data:e}=t;if(e.targetName===this.sourceName)if(e.stream)bnt(Ddt,this,Bdt).call(this,e);else if(e.callback){var r=e.callbackId,n=this.callbackCapabilities[r];if(!n)throw new Error("Cannot resolve callback ".concat(r));if(delete this.callbackCapabilities[r],e.callback===Adt)n.resolve(e.data);else{if(e.callback!==_dt)throw new Error("Unexpected callback case");n.reject(Odt(e.reason))}}else{var i=this.actionHandler[e.action];if(!i)throw new Error("Unknown action from worker: ".concat(e.action));if(e.callbackId){var a=this.sourceName,s=e.sourceName,o=this.comObj;Promise.try(i,e.data).then((function(t){o.postMessage({sourceName:a,targetName:s,callback:Adt,callbackId:e.callbackId,data:t})}),(function(t){o.postMessage({sourceName:a,targetName:s,callback:_dt,callbackId:e.callbackId,reason:Odt(t)})}))}else e.streamId?bnt(Ddt,this,jdt).call(this,e):i(e.data)}}function jdt(t){var e=t.streamId,r=this.sourceName,n=t.sourceName,i=this.comObj,a=this,s=this.actionHandler[t.action],o={enqueue(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,s=arguments.length>2?arguments[2]:void 0;if(!this.isCancelled){var o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:r,targetName:n,stream:Mdt,streamId:e,chunk:t},s)}},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:n,stream:Edt,streamId:e}),delete a.streamSinks[e])},error(t){Got(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:n,stream:Tdt,streamId:e,reason:Odt(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(s,t.data,o).then((function(){i.postMessage({sourceName:r,targetName:n,stream:Idt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:Idt,streamId:e,reason:Odt(t)})}))}function Bdt(t){var e=t.streamId,r=this.sourceName,n=t.sourceName,i=this.comObj,a=this.streamControllers[e],s=this.streamSinks[e];switch(t.stream){case Idt:t.success?a.startCall.resolve():a.startCall.reject(Odt(t.reason));break;case Pdt:t.success?a.pullCall.resolve():a.pullCall.reject(Odt(t.reason));break;case Cdt:if(!s){i.postMessage({sourceName:r,targetName:n,stream:Pdt,streamId:e,success:!0});break}s.desiredSize<=0&&t.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=t.desiredSize,Promise.try(s.onPull||Rdt).then((function(){i.postMessage({sourceName:r,targetName:n,stream:Pdt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:Pdt,streamId:e,reason:Odt(t)})}));break;case Mdt:if(Got(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Edt:if(Got(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),bnt(Ddt,this,zdt).call(this,a,e);break;case Tdt:Got(a,"error should have stream controller"),a.controller.error(Odt(t.reason)),bnt(Ddt,this,zdt).call(this,a,e);break;case Sdt:t.success?a.cancelCall.resolve():a.cancelCall.reject(Odt(t.reason)),bnt(Ddt,this,zdt).call(this,a,e);break;case kdt:if(!s)break;var o=Odt(t.reason);Promise.try(s.onCancel||Rdt,o).then((function(){i.postMessage({sourceName:r,targetName:n,stream:Sdt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:Sdt,streamId:e,reason:Odt(t)})})),s.sinkCapability.reject(o),s.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}function zdt(t,e){return Wdt.apply(this,arguments)}function Wdt(){return(Wdt=xnt((function*(t,e){var r,n,i;yield Promise.allSettled([null===(r=t.startCall)||void 0===r?void 0:r.promise,null===(n=t.pullCall)||void 0===n?void 0:n.promise,null===(i=t.cancelCall)||void 0===i?void 0:i.promise]),delete this.streamControllers[e]}))).apply(this,arguments)}var Udt=new WeakMap;class Hdt{constructor(t){var{enableHWA:e=!1}=t;knt(this,Udt,!1),Snt(Udt,this,e)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");var r=this._createCanvas(t,e);return{canvas:r,context:r.getContext("2d",{willReadFrequently:!_nt(Udt,this)})}}reset(t,e,r){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||r<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=r}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Hot("Abstract method `_createCanvas` called.")}}class Gdt{constructor(t){var{baseUrl:e=null,isCompressed:r=!0}=t;this.baseUrl=e,this.isCompressed=r}fetch(t){var e=this;return xnt((function*(){var{name:r}=t;if(!e.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!r)throw new Error("CMap name must be specified.");var n=e.baseUrl+r+(e.isCompressed?".bcmap":"");return e._fetch(n).then((t=>({cMapData:t,isCompressed:e.isCompressed}))).catch((t=>{throw new Error("Unable to load ".concat(e.isCompressed?"binary ":"","CMap at: ").concat(n))}))}))()}_fetch(t){return xnt((function*(){Hot("Abstract method `_fetch` called.")}))()}}class Ydt extends Gdt{_fetch(t){var e=this;return xnt((function*(){var r=yield glt(t,e.isCompressed?"arraybuffer":"text");return r instanceof ArrayBuffer?new Uint8Array(r):rlt(r)}))()}}class Vdt{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,r,n,i){return"none"}destroy(){}}var qdt=new WeakMap,Xdt=new WeakMap,$dt=new WeakMap,Kdt=new WeakMap,Qdt=new WeakMap,Jdt=new WeakMap,Zdt=new WeakMap,tpt=new WeakSet;function ept(t){return _nt(Xdt,t)||Snt(Xdt,t,new Map)}function rpt(t){return _nt(Jdt,t)||Snt(Jdt,t,new Map)}function npt(t){if(!_nt($dt,t)){var e=_nt(Qdt,t).createElement("div"),{style:r}=e;r.visibility="hidden",r.contain="strict",r.width=r.height=0,r.position="absolute",r.top=r.left=0,r.zIndex=-1;var n=_nt(Qdt,t).createElementNS(plt,"svg");n.setAttribute("width",0),n.setAttribute("height",0),Snt($dt,t,_nt(Qdt,t).createElementNS(plt,"defs")),e.append(n),n.append(_nt($dt,t)),_nt(Qdt,t).body.append(e)}return _nt($dt,t)}function ipt(t){if(1===t.length){for(var e=t[0],r=new Array(256),n=0;n<256;n++)r[n]=e[n]/255;var i=r.join(",");return[i,i,i]}for(var[a,s,o]=t,l=new Array(256),h=new Array(256),c=new Array(256),u=0;u<256;u++)l[u]=a[u]/255,h[u]=s[u]/255,c[u]=o[u]/255;return[l.join(","),h.join(","),c.join(",")]}function apt(t){if(void 0===_nt(qdt,this)){Snt(qdt,this,"");var e=_nt(Qdt,this).URL;e!==_nt(Qdt,this).baseURI&&(blt(e)?Uot('#createUrl: ignore "data:"-URL for performance reasons.'):Snt(qdt,this,e.split("#",1)[0]))}return"url(".concat(_nt(qdt,this),"#").concat(t,")")}function spt(t){var e=_nt(Qdt,this).createElementNS(plt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}function opt(t){var e=_nt(Qdt,this).createElementNS(plt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}function lpt(t){var e=_nt(Qdt,this).createElementNS(plt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),Ent(tpt,this,npt).append(e),e}function hpt(t,e,r){var n=_nt(Qdt,this).createElementNS(plt,e);n.setAttribute("type","discrete"),n.setAttribute("tableValues",r),t.append(n)}function cpt(t,e,r,n){var i=_nt(Qdt,this).createElementNS(plt,"feComponentTransfer");n.append(i),bnt(tpt,this,hpt).call(this,i,"feFuncR",t),bnt(tpt,this,hpt).call(this,i,"feFuncG",e),bnt(tpt,this,hpt).call(this,i,"feFuncB",r)}function upt(t,e){var r=_nt(Qdt,this).createElementNS(plt,"feComponentTransfer");e.append(r),bnt(tpt,this,hpt).call(this,r,"feFuncA",t)}function dpt(t){return Ent(tpt,this,npt).style.color=t,Plt(getComputedStyle(Ent(tpt,this,npt)).getPropertyValue("color"))}class ppt{constructor(t){var{baseUrl:e=null}=t;this.baseUrl=e}fetch(t){var e=this;return xnt((function*(){var{filename:r}=t;if(!e.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!r)throw new Error("Font filename must be specified.");var n="".concat(e.baseUrl).concat(r);return e._fetch(n).catch((t=>{throw new Error("Unable to load font data at: ".concat(n))}))}))()}_fetch(t){return xnt((function*(){Hot("Abstract method `_fetch` called.")}))()}}class fpt extends ppt{_fetch(t){return xnt((function*(){var e=yield glt(t,"arraybuffer");return new Uint8Array(e)}))()}}function gpt(t){return vpt.apply(this,arguments)}function vpt(){return vpt=xnt((function*(t){var e=process.getBuiltinModule("fs"),r=yield e.promises.readFile(t);return new Uint8Array(r)})),vpt.apply(this,arguments)}Hst&&Uot("Please use the `legacy` build in Node.js environments.");var mpt="Fill",ypt="Stroke",bpt="Shading";function wpt(t,e){if(e){var r=e[2]-e[0],n=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],r,n),t.clip(i)}}class xpt{getPattern(){Hot("Abstract method `getPattern` called.")}}class Apt extends xpt{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){var e;for(var r of("axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))e.addColorStop(r[0],r[1]);return e}getPattern(t,e,r,n){var i;if(n===ypt||n===mpt){var a=e.current.getClippedPathBoundingBox(n,Ilt(t))||[0,0,0,0],s=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.cachedCanvases.getCanvas("pattern",s,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-a[0],-a[1]),r=slt.transform(r,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),wpt(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),i=t.createPattern(l.canvas,"no-repeat");var c=new DOMMatrix(r);i.setTransform(c)}else wpt(t,this._bbox),i=this._createGradient(t);return i}}function _pt(t,e,r,n,i,a,s,o){var l,h=e.coords,c=e.colors,u=t.data,d=4*t.width;h[r+1]>h[n+1]&&(l=r,r=n,n=l,l=a,a=s,s=l),h[n+1]>h[i+1]&&(l=n,n=i,i=l,l=s,s=o,o=l),h[r+1]>h[n+1]&&(l=r,r=n,n=l,l=a,a=s,s=l);var p=(h[r]+e.offsetX)*e.scaleX,f=(h[r+1]+e.offsetY)*e.scaleY,g=(h[n]+e.offsetX)*e.scaleX,v=(h[n+1]+e.offsetY)*e.scaleY,m=(h[i]+e.offsetX)*e.scaleX,y=(h[i+1]+e.offsetY)*e.scaleY;if(!(f>=y))for(var b,w,x,A,_,k,S,E,M=c[a],T=c[a+1],C=c[a+2],P=c[s],I=c[s+1],R=c[s+2],O=c[o],L=c[o+1],D=c[o+2],F=Math.round(f),N=Math.round(y),j=F;j<=N;j++){if(j<v){var B=j<f?0:(f-j)/(f-v);b=p-(p-g)*B,w=M-(M-P)*B,x=T-(T-I)*B,A=C-(C-R)*B}else{var z=void 0;b=g-(g-m)*(z=j>y?1:v===y?0:(v-j)/(v-y)),w=P-(P-O)*z,x=I-(I-L)*z,A=R-(R-D)*z}var W=void 0;_=p-(p-m)*(W=j<f?0:j>y?1:(f-j)/(f-y)),k=M-(M-O)*W,S=T-(T-L)*W,E=C-(C-D)*W;for(var U=Math.round(Math.min(b,_)),H=Math.round(Math.max(b,_)),G=d*j+4*U,Y=U;Y<=H;Y++)(W=(b-Y)/(b-_))<0?W=0:W>1&&(W=1),u[G++]=w-(w-k)*W|0,u[G++]=x-(x-S)*W|0,u[G++]=A-(A-E)*W|0,u[G++]=255}}function kpt(t,e,r){var n,i,a=e.coords,s=e.colors;switch(e.type){case"lattice":var o=e.verticesPerRow,l=Math.floor(a.length/o)-1,h=o-1;for(n=0;n<l;n++)for(var c=n*o,u=0;u<h;u++,c++)_pt(t,r,a[c],a[c+1],a[c+o],s[c],s[c+1],s[c+o]),_pt(t,r,a[c+o+1],a[c+1],a[c+o],s[c+o+1],s[c+1],s[c+o]);break;case"triangles":for(n=0,i=a.length;n<i;n+=3)_pt(t,r,a[n],a[n+1],a[n+2],s[n],s[n+1],s[n+2]);break;default:throw new Error("illegal figure")}}class Spt extends xpt{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,r){var n=Math.floor(this._bounds[0]),i=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-n,s=Math.ceil(this._bounds[3])-i,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(s*t[1]*1.1)),3e3),h=a/o,c=s/l,u={coords:this._coords,colors:this._colors,offsetX:-n,offsetY:-i,scaleX:1/h,scaleY:1/c},d=o+4,p=l+4,f=r.getCanvas("mesh",d,p),g=f.context,v=g.createImageData(o,l);if(e)for(var m=v.data,y=0,b=m.length;y<b;y+=4)m[y]=e[0],m[y+1]=e[1],m[y+2]=e[2],m[y+3]=255;for(var w of this._figures)kpt(v,w,u);return g.putImageData(v,2,2),{canvas:f.canvas,offsetX:n-2*h,offsetY:i-2*c,scaleX:h,scaleY:c}}getPattern(t,e,r,n){var i;if(wpt(t,this._bbox),n===bpt)i=slt.singularValueDecompose2dScale(Ilt(t));else if(i=slt.singularValueDecompose2dScale(e.baseTransform),this.matrix){var a=slt.singularValueDecompose2dScale(this.matrix);i=[i[0]*a[0],i[1]*a[1]]}var s=this._createMeshCanvas(i,n===bpt?null:this._background,e.cachedCanvases);return n!==bpt&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(s.offsetX,s.offsetY),t.scale(s.scaleX,s.scaleY),t.createPattern(s.canvas,"no-repeat")}}class Ept extends xpt{getPattern(){return"hotpink"}}var Mpt=1,Tpt=2;class Cpt{constructor(t,e,r,n,i){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=r,this.canvasGraphicsFactory=n,this.baseTransform=i}createPatternCanvas(t){var{bbox:e,operatorList:r,paintType:n,tilingType:i,color:a,canvasGraphicsFactory:s}=this,{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),Wot("TilingType: "+i);var h=e[0],c=e[1],u=e[2],d=e[3],p=u-h,f=d-c,g=slt.singularValueDecompose2dScale(this.matrix),v=slt.singularValueDecompose2dScale(this.baseTransform),m=g[0]*v[0],y=g[1]*v[1],b=p,w=f,x=!1,A=!1,_=Math.ceil(o*m),k=Math.ceil(l*y);_>=Math.ceil(p*m)?b=o:x=!0,k>=Math.ceil(f*y)?w=l:A=!0;var S=this.getSizeAndScale(b,this.ctx.canvas.width,m),E=this.getSizeAndScale(w,this.ctx.canvas.height,y),M=t.cachedCanvases.getCanvas("pattern",S.size,E.size),T=M.context,C=s.createCanvasGraphics(T);if(C.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(C,n,a),T.translate(-S.scale*h,-E.scale*c),C.transform(S.scale,0,0,E.scale,0,0),T.save(),this.clipBbox(C,h,c,u,d),C.baseTransform=Ilt(C.ctx),C.executeOperatorList(r),C.endDrawing(),T.restore(),x||A){var P=M.canvas;x&&(b=o),A&&(w=l);for(var I=this.getSizeAndScale(b,this.ctx.canvas.width,m),R=this.getSizeAndScale(w,this.ctx.canvas.height,y),O=I.size,L=R.size,D=t.cachedCanvases.getCanvas("pattern-workaround",O,L),F=D.context,N=x?Math.floor(p/o):0,j=A?Math.floor(f/l):0,B=0;B<=N;B++)for(var z=0;z<=j;z++)F.drawImage(P,O*B,L*z,O,L,0,0,O,L);return{canvas:D.canvas,scaleX:I.scale,scaleY:R.scale,offsetX:h,offsetY:c}}return{canvas:M.canvas,scaleX:S.scale,scaleY:E.scale,offsetX:h,offsetY:c}}getSizeAndScale(t,e,r){var n=Math.max(Cpt.MAX_PATTERN_SIZE,e),i=Math.ceil(t*r);return i>=n?i=n:r=i/t,{scale:r,size:i}}clipBbox(t,e,r,n,i){var a=n-e,s=i-r;t.ctx.rect(e,r,a,s),t.current.updateRectMinMax(Ilt(t.ctx),[e,r,n,i]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,r){var n=t.ctx,i=t.current;switch(e){case Mpt:var a=this.ctx;n.fillStyle=a.fillStyle,n.strokeStyle=a.strokeStyle,i.fillColor=a.fillStyle,i.strokeColor=a.strokeStyle;break;case Tpt:var s=slt.makeHexColor(r[0],r[1],r[2]);n.fillStyle=s,n.strokeStyle=s,i.fillColor=s,i.strokeColor=s;break;default:throw new Zot("Unsupported paint type: ".concat(e))}}getPattern(t,e,r,n){var i=r;n!==bpt&&(i=slt.transform(i,e.baseTransform),this.matrix&&(i=slt.transform(i,this.matrix)));var a=this.createPatternCanvas(e),s=new DOMMatrix(i);s=(s=s.translate(a.offsetX,a.offsetY)).scale(1/a.scaleX,1/a.scaleY);var o=t.createPattern(a.canvas,"repeat");return o.setTransform(s),o}}function Ppt(t){var{src:e,srcPos:r=0,dest:n,width:i,height:a,nonBlackColor:s=4294967295,inverseDecode:o=!1}=t,l=ilt.isLittleEndian?4278190080:255,[h,c]=o?[s,l]:[l,s],u=i>>3,d=7&i,p=e.length;n=new Uint32Array(n.buffer);for(var f=0,g=0;g<a;g++){for(var v=r+u;r<v;r++){var m=r<p?e[r]:255;n[f++]=128&m?c:h,n[f++]=64&m?c:h,n[f++]=32&m?c:h,n[f++]=16&m?c:h,n[f++]=8&m?c:h,n[f++]=4&m?c:h,n[f++]=2&m?c:h,n[f++]=1&m?c:h}if(0!==d)for(var y=r<p?e[r++]:255,b=0;b<d;b++)n[f++]=y&1<<7-b?c:h}return{srcPos:r,destPos:f}}Tnt(Cpt,"MAX_PATTERN_SIZE",3e3);var Ipt=16;class Rpt{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,r){var n;return void 0!==this.cache[t]?(n=this.cache[t],this.canvasFactory.reset(n,e,r)):(n=this.canvasFactory.create(e,r),this.cache[t]=n),n}delete(t){delete this.cache[t]}clear(){for(var t in this.cache){var e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Opt(t,e,r,n,i,a,s,o,l,h){var[c,u,d,p,f,g]=Ilt(t);if(0===u&&0===d){var v=s*c+f,m=Math.round(v),y=o*p+g,b=Math.round(y),w=(s+l)*c+f,x=Math.abs(Math.round(w)-m)||1,A=(o+h)*p+g,_=Math.abs(Math.round(A)-b)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),m,b),t.drawImage(e,r,n,i,a,0,0,x,_),t.setTransform(c,u,d,p,f,g),[x,_]}if(0===c&&0===p){var k=o*d+f,S=Math.round(k),E=s*u+g,M=Math.round(E),T=(o+h)*d+f,C=Math.abs(Math.round(T)-S)||1,P=(s+l)*u+g,I=Math.abs(Math.round(P)-M)||1;return t.setTransform(0,Math.sign(u),Math.sign(d),0,S,M),t.drawImage(e,r,n,i,a,0,0,I,C),t.setTransform(c,u,d,p,f,g),[I,C]}return t.drawImage(e,r,n,i,a,s,o,l,h),[Math.hypot(c,u)*l,Math.hypot(d,p)*h]}class Lpt{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Gst,this.textMatrixScale=1,this.fontMatrix=Yst,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=aot,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){var t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,r){[e,r]=slt.applyTransform([e,r],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,r),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,r)}updateRectMinMax(t,e){var r=slt.applyTransform(e,t),n=slt.applyTransform(e.slice(2),t),i=slt.applyTransform([e[0],e[3]],t),a=slt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,r[0],n[0],i[0],a[0]),this.minY=Math.min(this.minY,r[1],n[1],i[1],a[1]),this.maxX=Math.max(this.maxX,r[0],n[0],i[0],a[0]),this.maxY=Math.max(this.maxY,r[1],n[1],i[1],a[1])}updateScalingPathMinMax(t,e){slt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,r,n,i,a,s,o,l,h){var c=slt.bezierBoundingBox(e,r,n,i,a,s,o,l,h);h||this.updateRectMinMax(t,c)}getPathBoundingBox(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:mpt,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=[this.minX,this.minY,this.maxX,this.maxY];if(t===ypt){e||Hot("Stroke bounding box must include transform.");var n=slt.singularValueDecompose2dScale(e),i=n[0]*this.lineWidth/2,a=n[1]*this.lineWidth/2;r[0]-=i,r[1]-=a,r[2]+=i,r[3]+=a}return r}updateClipFromPath(){var t=slt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:mpt,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return slt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Dpt(t,e){if(e instanceof ImageData)t.putImageData(e,0,0);else{var r,n,i,a,s,o=e.height,l=e.width,h=o%Ipt,c=(o-h)/Ipt,u=0===h?c:c+1,d=t.createImageData(l,Ipt),p=0,f=e.data,g=d.data;if(e.kind===uot.GRAYSCALE_1BPP){var v=f.byteLength,m=new Uint32Array(g.buffer,0,g.byteLength>>2),y=m.length,b=l+7>>3,w=4294967295,x=ilt.isLittleEndian?4278190080:255;for(n=0;n<u;n++){for(a=n<c?Ipt:h,r=0,i=0;i<a;i++){for(var A=v-p,_=0,k=A>b?l:8*A-7,S=-8&k,E=0,M=0;_<S;_+=8)M=f[p++],m[r++]=128&M?w:x,m[r++]=64&M?w:x,m[r++]=32&M?w:x,m[r++]=16&M?w:x,m[r++]=8&M?w:x,m[r++]=4&M?w:x,m[r++]=2&M?w:x,m[r++]=1&M?w:x;for(;_<k;_++)0===E&&(M=f[p++],E=128),m[r++]=M&E?w:x,E>>=1}for(;r<y;)m[r++]=0;t.putImageData(d,0,n*Ipt)}}else if(e.kind===uot.RGBA_32BPP){for(i=0,s=l*Ipt*4,n=0;n<c;n++)g.set(f.subarray(p,p+s)),p+=s,t.putImageData(d,0,i),i+=Ipt;n<u&&(s=l*h*4,g.set(f.subarray(p,p+s)),t.putImageData(d,0,i))}else{if(e.kind!==uot.RGB_24BPP)throw new Error("bad image kind: ".concat(e.kind));for(s=l*(a=Ipt),n=0;n<u;n++){for(n>=c&&(s=l*(a=h)),r=0,i=s;i--;)g[r++]=f[p++],g[r++]=f[p++],g[r++]=f[p++],g[r++]=255;t.putImageData(d,0,n*Ipt)}}}}function Fpt(t,e){if(e.bitmap)t.drawImage(e.bitmap,0,0);else for(var r=e.height,n=e.width,i=r%Ipt,a=(r-i)/Ipt,s=0===i?a:a+1,o=t.createImageData(n,Ipt),l=0,h=e.data,c=o.data,u=0;u<s;u++){var d=u<a?Ipt:i;({srcPos:l}=Ppt({src:h,srcPos:l,dest:c,width:n,height:d,nonBlackColor:0})),t.putImageData(o,0,u*Ipt)}}function Npt(t,e){for(var r of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[r]&&(e[r]=t[r]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function jpt(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!Hst){var{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function Bpt(t,e){if(e)return!0;var r=slt.singularValueDecompose2dScale(t);r[0]=Math.fround(r[0]),r[1]=Math.fround(r[1]);var n=Math.fround((globalThis.devicePixelRatio||1)*flt.PDF_TO_CSS_UNITS);return r[0]<=n&&r[1]<=n}var zpt=["butt","round","square"],Wpt=["miter","round","bevel"],Upt={},Hpt={},Gpt=new WeakSet;class Ypt{constructor(t,e,r,n,i,a,s,o){var{optionalContentConfig:l,markedContentStack:h=null}=a;Mnt(this,Gpt),this.ctx=t,this.current=new Lpt(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=r,this.canvasFactory=n,this.filterFactory=i,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=h||[],this.optionalContentConfig=l,this.cachedCanvases=new Rpt(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=o,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing(t){var{transform:e,viewport:r,transparency:n=!1,background:i=null}=t,a=this.ctx.canvas.width,s=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,a,s),this.ctx.fillStyle=o,n){var l=this.cachedCanvases.getCanvas("transparent",a,s);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...Ilt(this.compositeCtx))}this.ctx.save(),jpt(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...r.transform),this.viewportScale=r.scale,this.baseTransform=Ilt(this.ctx)}executeOperatorList(t,e,r,n){var i=t.argsArray,a=t.fnArray,s=e||0,o=i.length;if(o===s)return s;for(var l,h=o-s>10&&"function"==typeof r,c=h?Date.now()+15:0,u=0,d=this.commonObjs,p=this.objs;;){if(void 0!==n&&s===n.nextBreakPoint)return n.breakIt(s,r),s;if((l=a[s])!==Fot.dependency)this[l].apply(this,i[s]);else for(var f of i[s]){var g=f.startsWith("g_")?d:p;if(!g.has(f))return g.get(f,r),s}if(++s===o)return s;if(h&&++u>10){if(Date.now()>c)return r(),s;u=0}}}endDrawing(){for(var t of(bnt(Gpt,this,Vpt).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(var e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),bnt(Gpt,this,qpt).call(this)}_scaleImage(t,e){for(var r,n,i,a,s=null!==(r=t.width)&&void 0!==r?r:t.displayWidth,o=null!==(n=t.height)&&void 0!==n?n:t.displayHeight,l=Math.max(Math.hypot(e[0],e[1]),1),h=Math.max(Math.hypot(e[2],e[3]),1),c=s,u=o,d="prescale1";l>2&&c>1||h>2&&u>1;){var p=c,f=u;l>2&&c>1&&(l/=c/(p=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c/2))),h>2&&u>1&&(h/=u/(f=u>=16384?Math.floor(u/2)-1||1:Math.ceil(u)/2)),(a=(i=this.cachedCanvases.getCanvas(d,p,f)).context).clearRect(0,0,p,f),a.drawImage(t,0,0,c,u,0,0,p,f),t=i.canvas,c=p,u=f,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:c,paintHeight:u}}_createMaskCanvas(t){var e,r,n,i,a=this.ctx,{width:s,height:o}=t,l=this.current.fillColor,h=this.current.patternFill,c=Ilt(a);if((t.bitmap||t.data)&&t.count>1){var u=t.bitmap||t.data.buffer;r=JSON.stringify(h?c:[c.slice(0,4),l]),(e=this._cachedBitmapsMap.get(u))||(e=new Map,this._cachedBitmapsMap.set(u,e));var d=e.get(r);if(d&&!h)return{canvas:d,offsetX:Math.round(Math.min(c[0],c[2])+c[4]),offsetY:Math.round(Math.min(c[1],c[3])+c[5])};n=d}n||Fpt((i=this.cachedCanvases.getCanvas("maskCanvas",s,o)).context,t);var p=slt.transform(c,[1/s,0,0,-1/o,0,0]);p=slt.transform(p,[1,0,0,1,0,-o]);var[f,g,v,m]=slt.getAxialAlignedBoundingBox([0,0,s,o],p),y=Math.round(v-f)||1,b=Math.round(m-g)||1,w=this.cachedCanvases.getCanvas("fillCanvas",y,b),x=w.context,A=f,_=g;x.translate(-A,-_),x.transform(...p),n||(n=(n=this._scaleImage(i.canvas,Rlt(x))).img,e&&h&&e.set(r,n)),x.imageSmoothingEnabled=Bpt(Ilt(x),t.interpolate),Opt(x,n,0,0,n.width,n.height,0,0,s,o),x.globalCompositeOperation="source-in";var k=slt.transform(Rlt(x),[1,0,0,1,-A,-_]);return x.fillStyle=h?l.getPattern(a,this,k,mpt):l,x.fillRect(0,0,s,o),e&&!h&&(this.cachedCanvases.delete("fillCanvas"),e.set(r,w.canvas)),{canvas:w.canvas,offsetX:Math.round(A),offsetY:Math.round(_)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=zpt[t]}setLineJoin(t){this.ctx.lineJoin=Wpt[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){var r=this.ctx;void 0!==r.setLineDash&&(r.setLineDash(t),r.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(var[e,r]of t)switch(e){case"LW":this.setLineWidth(r);break;case"LC":this.setLineCap(r);break;case"LJ":this.setLineJoin(r);break;case"ML":this.setMiterLimit(r);break;case"D":this.setDash(r[0],r[1]);break;case"RI":this.setRenderingIntent(r);break;case"FL":this.setFlatness(r);break;case"Font":this.setFont(r[0],r[1]);break;case"CA":this.current.strokeAlpha=r;break;case"ca":this.current.fillAlpha=r,this.ctx.globalAlpha=r;break;case"BM":this.ctx.globalCompositeOperation=r;break;case"SMask":this.current.activeSMask=r?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(r)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){var t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");var t=this.ctx.canvas.width,e=this.ctx.canvas.height,r="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(r,t,e);this.suspendedCtx=this.ctx,this.ctx=n.context;var i=this.ctx;i.setTransform(...Ilt(this.suspendedCtx)),Npt(this.suspendedCtx,i),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,r){e.translate(t,r),this.__originalTranslate(t,r)},t.scale=function(t,r){e.scale(t,r),this.__originalScale(t,r)},t.transform=function(t,r,n,i,a,s){e.transform(t,r,n,i,a,s),this.__originalTransform(t,r,n,i,a,s)},t.setTransform=function(t,r,n,i,a,s){e.setTransform(t,r,n,i,a,s),this.__originalSetTransform(t,r,n,i,a,s)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,r){e.moveTo(t,r),this.__originalMoveTo(t,r)},t.lineTo=function(t,r){e.lineTo(t,r),this.__originalLineTo(t,r)},t.bezierCurveTo=function(t,r,n,i,a,s){e.bezierCurveTo(t,r,n,i,a,s),this.__originalBezierCurveTo(t,r,n,i,a,s)},t.rect=function(t,r,n,i){e.rect(t,r,n,i),this.__originalRect(t,r,n,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(i,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Npt(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(this.current.activeSMask){t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];var e=this.current.activeSMask,r=this.suspendedCtx;this.composeSMask(r,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}}composeSMask(t,e,r,n){var i=n[0],a=n[1],s=n[2]-i,o=n[3]-a;0!==s&&0!==o&&(this.genericComposeSMask(e.context,r,s,o,e.subtype,e.backdrop,e.transferMap,i,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(r.canvas,0,0),t.restore())}genericComposeSMask(t,e,r,n,i,a,s,o,l,h,c){var u=t.canvas,d=o-h,p=l-c;if(a){var f=slt.makeHexColor(...a);if(d<0||p<0||d+r>u.width||p+n>u.height){var g=this.cachedCanvases.getCanvas("maskExtension",r,n),v=g.context;v.drawImage(u,-d,-p),v.globalCompositeOperation="destination-atop",v.fillStyle=f,v.fillRect(0,0,r,n),v.globalCompositeOperation="source-over",u=g.canvas,d=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);var m=new Path2D;m.rect(d,p,r,n),t.clip(m),t.globalCompositeOperation="destination-atop",t.fillStyle=f,t.fillRect(d,p,r,n),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===i&&s?e.filter=this.filterFactory.addAlphaFilter(s):"Luminosity"===i&&(e.filter=this.filterFactory.addLuminosityFilter(s));var y=new Path2D;y.rect(o,l,r,n),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(u,d,p,r,n,o,l,r,n),e.restore()}save(){this.inSMaskMode?(Npt(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();var t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Npt(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,r,n,i,a){this.ctx.transform(t,e,r,n,i,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,r){for(var n,i,a=this.ctx,s=this.current,o=s.x,l=s.y,h=Ilt(a),c=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],u=c?r.slice(0):null,d=0,p=0,f=t.length;d<f;d++)switch(0|t[d]){case Fot.rectangle:o=e[p++],l=e[p++];var g=e[p++],v=e[p++],m=o+g,y=l+v;a.moveTo(o,l),0===g||0===v?a.lineTo(m,y):(a.lineTo(m,l),a.lineTo(m,y),a.lineTo(o,y)),c||s.updateRectMinMax(h,[o,l,m,y]),a.closePath();break;case Fot.moveTo:o=e[p++],l=e[p++],a.moveTo(o,l),c||s.updatePathMinMax(h,o,l);break;case Fot.lineTo:o=e[p++],l=e[p++],a.lineTo(o,l),c||s.updatePathMinMax(h,o,l);break;case Fot.curveTo:n=o,i=l,o=e[p+4],l=e[p+5],a.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],o,l),s.updateCurvePathMinMax(h,n,i,e[p],e[p+1],e[p+2],e[p+3],o,l,u),p+=6;break;case Fot.curveTo2:n=o,i=l,a.bezierCurveTo(o,l,e[p],e[p+1],e[p+2],e[p+3]),s.updateCurvePathMinMax(h,n,i,o,l,e[p],e[p+1],e[p+2],e[p+3],u),o=e[p+2],l=e[p+3],p+=4;break;case Fot.curveTo3:n=o,i=l,o=e[p+2],l=e[p+3],a.bezierCurveTo(e[p],e[p+1],o,l,o,l),s.updateCurvePathMinMax(h,n,i,e[p],e[p+1],o,l,o,l,u),p+=4;break;case Fot.closePath:a.closePath()}c&&s.updateScalingPathMinMax(h,u),s.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.ctx,r=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof r&&null!=r&&r.getPattern?(e.save(),e.strokeStyle=r.getPattern(e,this,Rlt(e),ypt),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.ctx,r=this.current.fillColor,n=!1;this.current.patternFill&&(e.save(),e.fillStyle=r.getPattern(e,this,Rlt(e),mpt),n=!0);var i=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==i&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(i)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Upt}eoClip(){this.pendingClip=Hpt}beginText(){this.current.textMatrix=Gst,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){var t=this.pendingTextPaths,e=this.ctx;if(void 0!==t){var r=new Path2D,n=e.getTransform().invertSelf();for(var{transform:i,x:a,y:s,fontSize:o,path:l}of t)r.addPath(l,new DOMMatrix(i).preMultiplySelf(n).translate(a,s).scale(o,-o));e.clip(r),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var r,n=this.commonObjs.get(t),i=this.current;if(!n)throw new Error("Can't find font for ".concat(t));if(i.fontMatrix=n.fontMatrix||Yst,0!==i.fontMatrix[0]&&0!==i.fontMatrix[3]||Uot("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=n,this.current.fontSize=e,!n.isType3Font){var a=n.loadedName||"sans-serif",s=(null===(r=n.systemFontInfo)||void 0===r?void 0:r.css)||'"'.concat(a,'", ').concat(n.fallbackName),o="normal";n.black?o="900":n.bold&&(o="bold");var l=n.italic?"italic":"normal",h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font="".concat(l," ").concat(o," ").concat(h,"px ").concat(s)}}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,r,n,i,a){this.current.textMatrix=[t,e,r,n,i,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,r,n,i){var a,s=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,u=h&hot,d=!!(h&cot),p=o.patternFill&&!l.missingFile,f=o.patternStroke&&!l.missingFile;if((l.disableFontFace||d||p||f)&&(a=l.getPathGenerator(this.commonObjs,t)),l.disableFontFace||p||f){if(s.save(),s.translate(e,r),s.scale(c,-c),u===aot||u===oot)if(n){var g=s.getTransform();s.setTransform(...n),s.fill(bnt(Gpt,this,Xpt).call(this,a,g,n))}else s.fill(a);if(u===sot||u===oot)if(i){var v=s.getTransform();s.setTransform(...i),s.stroke(bnt(Gpt,this,Xpt).call(this,a,v,i))}else s.lineWidth/=c,s.stroke(a);s.restore()}else u!==aot&&u!==oot||s.fillText(t,e,r),u!==sot&&u!==oot||s.strokeText(t,e,r);d&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Ilt(s),x:e,y:r,fontSize:c,path:a})}get isFontSubpixelAAEnabled(){var{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);for(var e=t.getImageData(0,0,10,10).data,r=!1,n=3;n<e.length;n+=4)if(e[n]>0&&e[n]<255){r=!0;break}return Vot(this,"isFontSubpixelAAEnabled",r)}showText(t){var e=this.current,r=e.font;if(r.isType3Font)return this.showType3Text(t);var n=e.fontSize;if(0!==n){var i,a,s=this.ctx,o=e.fontSizeScale,l=e.charSpacing,h=e.wordSpacing,c=e.fontDirection,u=e.textHScale*c,d=t.length,p=r.vertical,f=p?1:-1,g=r.defaultVMetrics,v=n*e.fontMatrix[0],m=e.textRenderingMode===aot&&!r.disableFontFace&&!e.patternFill;if(s.save(),s.transform(...e.textMatrix),s.translate(e.x,e.y+e.textRise),c>0?s.scale(u,-1):s.scale(u,1),e.patternFill){s.save();var y=e.fillColor.getPattern(s,this,Rlt(s),mpt);i=Ilt(s),s.restore(),s.fillStyle=y}if(e.patternStroke){s.save();var b=e.strokeColor.getPattern(s,this,Rlt(s),ypt);a=Ilt(s),s.restore(),s.strokeStyle=b}var w=e.lineWidth,x=e.textMatrixScale;if(0===x||0===w){var A=e.textRenderingMode&hot;A!==sot&&A!==oot||(w=this.getSinglePixelWidth())}else w/=x;if(1!==o&&(s.scale(o,o),w/=o),s.lineWidth=w,r.isInvalidPDFjsFont){var _=[],k=0;for(var S of t)_.push(S.unicode),k+=S.width;return s.fillText(_.join(""),0,0),e.x+=k*v*u,s.restore(),void this.compose()}var E,M=0;for(E=0;E<d;++E){var T=t[E];if("number"!=typeof T){var C=!1,P=(T.isSpace?h:0)+l,I=T.fontChar,R=T.accent,O=void 0,L=void 0,D=T.width;if(p){var F=T.vmetric||g,N=-(T.vmetric?F[1]:.5*D)*v,j=F[2]*v;D=F?-F[0]:D,O=N/o,L=(M+j)/o}else O=M/o,L=0;if(r.remeasure&&D>0){var B=1e3*s.measureText(I).width/n*o;if(D<B&&this.isFontSubpixelAAEnabled){var z=D/B;C=!0,s.save(),s.scale(z,1),O/=z}else D!==B&&(O+=(D-B)/2e3*n/o)}if(this.contentVisible&&(T.isInFont||r.missingFile))if(m&&!R)s.fillText(I,O,L);else if(this.paintChar(I,O,L,i,a),R){var W=O+n*R.offset.x/o,U=L-n*R.offset.y/o;this.paintChar(R.fontChar,W,U,i,a)}M+=p?D*v-P*c:D*v+P*c,C&&s.restore()}else M+=f*T*n/1e3}p?e.y-=M:e.x+=M*u,s.restore(),this.compose()}}showType3Text(t){var e,r,n,i,a=this.ctx,s=this.current,o=s.font,l=s.fontSize,h=s.fontDirection,c=o.vertical?1:-1,u=s.charSpacing,d=s.wordSpacing,p=s.textHScale*h,f=s.fontMatrix||Yst,g=t.length;if(!(s.textRenderingMode===lot)&&0!==l){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),a.transform(...s.textMatrix),a.translate(s.x,s.y),a.scale(p,h),e=0;e<g;++e)if("number"!=typeof(r=t[e])){var v=(r.isSpace?d:0)+u,m=o.charProcOperatorList[r.operatorListId];if(m)this.contentVisible&&(this.processingType3=r,this.save(),a.scale(l,l),a.transform(...f),this.executeOperatorList(m),this.restore()),n=slt.applyTransform([r.width,0],f)[0]*l+v,a.translate(n,0),s.x+=n*p;else Uot('Type3 character "'.concat(r.operatorListId,'" is not available.'))}else i=c*r*l/1e3,this.ctx.translate(i,0),s.x+=i*p;a.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,r,n,i,a){this.ctx.rect(r,n,i-r,a-n),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){var e;if("TilingPattern"===t[0]){var r=t[1],n=this.baseTransform||Ilt(this.ctx),i={createCanvasGraphics:t=>new Ypt(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Cpt(t,r,this.ctx,i,n)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,r){this.ctx.strokeStyle=this.current.strokeColor=slt.makeHexColor(t,e,r),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,r){this.ctx.fillStyle=this.current.fillColor=slt.makeHexColor(t,e,r),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.cachedPatterns.has(t)?e=this.cachedPatterns.get(t):(e=function(t){switch(t[0]){case"RadialAxial":return new Apt(t);case"Mesh":return new Spt(t);case"Dummy":return new Ept}throw new Error("Unknown IR type: ".concat(t[0]))}(this.getObject(t)),this.cachedPatterns.set(t,e)),r&&(e.matrix=r),e}shadingFill(t){if(this.contentVisible){var e=this.ctx;this.save();var r=this._getPattern(t);e.fillStyle=r.getPattern(e,this,Rlt(e),bpt);var n=Rlt(e);if(n){var{width:i,height:a}=e.canvas,[s,o,l,h]=slt.getAxialAlignedBoundingBox([0,0,i,a],n);this.ctx.fillRect(s,o,l-s,h-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}}beginInlineImage(){Hot("Should not call beginInlineImage")}beginImageData(){Hot("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Ilt(this.ctx),e)){var r=e[2]-e[0],n=e[3]-e[1];this.ctx.rect(e[0],e[1],r,n),this.current.updateRectMinMax(Ilt(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(this.contentVisible){this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);var e=this.ctx;t.isolated||Wot("TODO: Support non-isolated groups."),t.knockout&&Uot("Knockout groups not supported.");var r=Ilt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");var n=slt.getAxialAlignedBoundingBox(t.bbox,Ilt(e)),i=[0,0,e.canvas.width,e.canvas.height];n=slt.intersect(n,i)||[0,0,0,0];var a=Math.floor(n[0]),s=Math.floor(n[1]),o=Math.max(Math.ceil(n[2])-a,1),l=Math.max(Math.ceil(n[3])-s,1);this.current.startNewPathAndClipBox([0,0,o,l]);var h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);var c=this.cachedCanvases.getCanvas(h,o,l),u=c.context;u.translate(-a,-s),u.transform(...r),t.smask?this.smaskStack.push({canvas:c.canvas,context:u,offsetX:a,offsetY:s,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,s),e.save()),Npt(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}}endGroup(t){if(this.contentVisible){this.groupLevel--;var e=this.ctx,r=this.groupStack.pop();if(this.ctx=r,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();var n=Ilt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...n);var i=slt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],n);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}}beginAnnotation(t,e,r,n,i){if(bnt(Gpt,this,Vpt).call(this),jpt(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){var a=e[2]-e[0],s=e[3]-e[1];if(i&&this.annotationCanvasMap){(r=r.slice())[4]-=e[0],r[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=a,e[3]=s;var[o,l]=slt.singularValueDecompose2dScale(Ilt(this.ctx)),{viewportScale:h}=this,c=Math.ceil(a*this.outputScaleX*h),u=Math.ceil(s*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,u);var{canvas:d,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(o,0,0,-l,0,s*l),jpt(this.ctx)}else jpt(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],a,s),this.ctx.clip(),this.ctx.beginPath()}this.current=new Lpt(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...r),this.transform(...n)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),bnt(Gpt,this,qpt).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(this.contentVisible){var e=t.count;(t=this.getObject(t.data,t)).count=e;var r=this.ctx,n=this.processingType3;if(n&&(void 0===n.compiled&&(n.compiled=function(t){var{width:e,height:r}=t;if(e>1e3||r>1e3)return null;var n,i,a,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=e+1,l=new Uint8Array(o*(r+1)),h=e+7&-8,c=new Uint8Array(h*r),u=0;for(var d of t.data)for(var p=128;p>0;)c[u++]=d&p?0:255,p>>=1;var f=0;for(0!==c[u=0]&&(l[0]=1,++f),i=1;i<e;i++)c[u]!==c[u+1]&&(l[i]=c[u]?2:1,++f),u++;for(0!==c[u]&&(l[i]=2,++f),n=1;n<r;n++){a=n*o,c[(u=n*h)-h]!==c[u]&&(l[a]=c[u]?1:8,++f);var g=(c[u]?4:0)+(c[u-h]?8:0);for(i=1;i<e;i++)s[g=(g>>2)+(c[u+1]?4:0)+(c[u-h+1]?8:0)]&&(l[a+i]=s[g],++f),u++;if(c[u-h]!==c[u]&&(l[a+i]=c[u]?2:4,++f),f>1e3)return null}for(a=n*o,0!==c[u=h*(r-1)]&&(l[a]=8,++f),i=1;i<e;i++)c[u]!==c[u+1]&&(l[a+i]=c[u]?4:8,++f),u++;if(0!==c[u]&&(l[a+i]=4,++f),f>1e3)return null;var v=new Int32Array([0,o,-1,0,-o,0,0,0,1]),m=new Path2D;for(n=0;f&&n<=r;n++){for(var y=n*o,b=y+e;y<b&&!l[y];)y++;if(y!==b){m.moveTo(y%o,n);var w=y,x=l[y];do{var A=v[x];do{y+=A}while(!l[y]);var _=l[y];5!==_&&10!==_?(x=_,l[y]=0):(x=_&51*x>>4,l[y]&=x>>2|x<<2),m.lineTo(y%o,y/o|0),l[y]||--f}while(w!==y);--n}}return c=null,l=null,function(t){t.save(),t.scale(1/e,-1/r),t.translate(0,-r),t.fill(m),t.beginPath(),t.restore()}}(t)),n.compiled))n.compiled(r);else{var i=this._createMaskCanvas(t),a=i.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(a,i.offsetX,i.offsetY),r.restore(),this.compose()}}}paintImageMaskXObjectRepeat(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;if(this.contentVisible){t=this.getObject(t.data,t);var s=this.ctx;s.save();var o=Ilt(s);s.transform(e,r,n,i,0,0);var l=this._createMaskCanvas(t);s.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(var h=0,c=a.length;h<c;h+=2){var u=slt.transform(o,[e,r,n,i,a[h],a[h+1]]),[d,p]=slt.applyTransform([0,0],u);s.drawImage(l.canvas,d,p)}s.restore(),this.compose()}}paintImageMaskXObjectGroup(t){if(this.contentVisible){var e=this.ctx,r=this.current.fillColor,n=this.current.patternFill;for(var i of t){var{data:a,width:s,height:o,transform:l}=i,h=this.cachedCanvases.getCanvas("maskCanvas",s,o),c=h.context;c.save(),Fpt(c,this.getObject(a,i)),c.globalCompositeOperation="source-in",c.fillStyle=n?r.getPattern(c,this,Rlt(e),mpt):r,c.fillRect(0,0,s,o),c.restore(),e.save(),e.transform(...l),e.scale(1,-1),Opt(e,h.canvas,0,0,s,o,0,-1,1,1),e.restore()}this.compose()}}paintImageXObject(t){if(this.contentVisible){var e=this.getObject(t);e?this.paintInlineImageXObject(e):Uot("Dependent image isn't ready yet")}}paintImageXObjectRepeat(t,e,r,n){if(this.contentVisible){var i=this.getObject(t);if(i){for(var a=i.width,s=i.height,o=[],l=0,h=n.length;l<h;l+=2)o.push({transform:[e,0,0,r,n[l],n[l+1]],x:0,y:0,w:a,h:s});this.paintInlineImageXObjectGroup(i,o)}else Uot("Dependent image isn't ready yet")}}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;var{bitmap:e,width:r,height:n}=t,i=this.cachedCanvases.getCanvas("inlineImage",r,n),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",i.canvas}paintInlineImageXObject(t){if(this.contentVisible){var e,r=t.width,n=t.height,i=this.ctx;if(this.save(),!Hst){var{filter:a}=i;"none"!==a&&""!==a&&(i.filter="none")}if(i.scale(1/r,-1/n),t.bitmap)e=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)e=t;else{var s=this.cachedCanvases.getCanvas("inlineImage",r,n).context;Dpt(s,t),e=this.applyTransferMapsToCanvas(s)}var o=this._scaleImage(e,Rlt(i));i.imageSmoothingEnabled=Bpt(Ilt(i),t.interpolate),Opt(i,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,r,n),this.compose(),this.restore()}}paintInlineImageXObjectGroup(t,e){if(this.contentVisible){var r,n=this.ctx;if(t.bitmap)r=t.bitmap;else{var i=t.width,a=t.height,s=this.cachedCanvases.getCanvas("inlineImage",i,a).context;Dpt(s,t),r=this.applyTransferMapsToCanvas(s)}for(var o of e)n.save(),n.transform(...o.transform),n.scale(1,-1),Opt(n,r,o.x,o.y,o.w,o.h,0,-1,1,1),n.restore();this.compose()}}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){var e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);var r=this.ctx;this.pendingClip&&(e||(this.pendingClip===Hpt?r.clip("evenodd"):r.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),r.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){var t=Ilt(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{var e=Math.abs(t[0]*t[3]-t[2]*t[1]),r=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(r,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){var t,e,{lineWidth:r}=this.current,{a:n,b:i,c:a,d:s}=this.ctx.getTransform();if(0===i&&0===a){var o=Math.abs(n),l=Math.abs(s);if(o===l)if(0===r)t=e=1/o;else{var h=o*r;t=e=h<1?1/h:1}else if(0===r)t=1/o,e=1/l;else{var c=o*r,u=l*r;t=c<1?1/c:1,e=u<1?1/u:1}}else{var d=Math.abs(n*s-i*a),p=Math.hypot(n,i),f=Math.hypot(a,s);if(0===r)t=f/d,e=p/d;else{var g=r*d;t=f>g?f/g:1,e=p>g?p/g:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t){var{ctx:e}=this,{lineWidth:r}=this.current,[n,i]=this.getScaleForStroking();if(e.lineWidth=r||1,1!==n||1!==i){var a=e.getLineDash();if(t&&e.save(),e.scale(n,i),a.length>0){var s=Math.max(n,i);e.setLineDash(a.map((t=>t/s))),e.lineDashOffset/=s}e.stroke(),t&&e.restore()}else e.stroke()}isContentVisible(){for(var t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}function Vpt(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}function qpt(){if(this.pageColors){var t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){var e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}function Xpt(t,e,r){var n=new Path2D;return n.addPath(t,new DOMMatrix(r).invertSelf().multiplySelf(e)),n}for(var $pt in Fot)void 0!==Ypt.prototype[$pt]&&(Ypt.prototype[Fot[$pt]]=Ypt.prototype[$pt]);class Kpt{static get workerPort(){return bnt(Kpt,this,Qpt)._}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");Qpt._=bnt(Kpt,this,t)}static get workerSrc(){return bnt(Kpt,this,Jpt)._}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");Jpt._=bnt(Kpt,this,t)}}var Qpt={_:null},Jpt={_:""},Zpt=new WeakMap,tft=new WeakMap;class eft{constructor(t){var{parsedData:e,rawData:r}=t;knt(this,Zpt,void 0),knt(this,tft,void 0),Snt(Zpt,this,e),Snt(tft,this,r)}getRaw(){return _nt(tft,this)}get(t){var e;return null!==(e=_nt(Zpt,this).get(t))&&void 0!==e?e:null}getAll(){return nlt(_nt(Zpt,this))}has(t){return _nt(Zpt,this).has(t)}}var rft=Symbol("INTERNAL"),nft=new WeakMap,ift=new WeakMap,aft=new WeakMap,sft=new WeakMap;class oft{constructor(t,e){var{name:r,intent:n,usage:i,rbGroups:a}=e;knt(this,nft,!1),knt(this,ift,!1),knt(this,aft,!1),knt(this,sft,!0),Snt(nft,this,!!(t&Xst)),Snt(ift,this,!!(t&$st)),this.name=r,this.intent=n,this.usage=i,this.rbGroups=a}get visible(){if(_nt(aft,this))return _nt(sft,this);if(!_nt(sft,this))return!1;var{print:t,view:e}=this.usage;return _nt(nft,this)?"OFF"!==(null==e?void 0:e.viewState):!_nt(ift,this)||"OFF"!==(null==t?void 0:t.printState)}_setVisible(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t!==rft&&Hot("Internal method `_setVisible` called."),Snt(aft,this,r),Snt(sft,this,e)}}var lft=new WeakMap,hft=new WeakMap,cft=new WeakMap,uft=new WeakMap,dft=new WeakSet;class pft{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xst;if(Mnt(this,dft),knt(this,lft,null),knt(this,hft,new Map),knt(this,cft,null),knt(this,uft,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==t){for(var r of(this.name=t.name,this.creator=t.creator,Snt(uft,this,t.order),t.groups))_nt(hft,this).set(r.id,new oft(e,r));if("OFF"===t.baseState)for(var n of _nt(hft,this).values())n._setVisible(rft,!1);for(var i of t.on)_nt(hft,this).get(i)._setVisible(rft,!0);for(var a of t.off)_nt(hft,this).get(a)._setVisible(rft,!1);Snt(cft,this,this.getHash())}}isVisible(t){if(0===_nt(hft,this).size)return!0;if(!t)return Wot("Optional content group not defined."),!0;if("OCG"===t.type)return _nt(hft,this).has(t.id)?_nt(hft,this).get(t.id).visible:(Uot("Optional content group not found: ".concat(t.id)),!0);if("OCMD"===t.type){if(t.expression)return bnt(dft,this,fft).call(this,t.expression);if(!t.policy||"AnyOn"===t.policy){for(var e of t.ids){if(!_nt(hft,this).has(e))return Uot("Optional content group not found: ".concat(e)),!0;if(_nt(hft,this).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(var r of t.ids){if(!_nt(hft,this).has(r))return Uot("Optional content group not found: ".concat(r)),!0;if(!_nt(hft,this).get(r).visible)return!1}return!0}if("AnyOff"===t.policy){for(var n of t.ids){if(!_nt(hft,this).has(n))return Uot("Optional content group not found: ".concat(n)),!0;if(!_nt(hft,this).get(n).visible)return!0}return!1}if("AllOff"===t.policy){for(var i of t.ids){if(!_nt(hft,this).has(i))return Uot("Optional content group not found: ".concat(i)),!0;if(_nt(hft,this).get(i).visible)return!1}return!0}return Uot("Unknown optional content policy ".concat(t.policy,".")),!0}return Uot("Unknown group type ".concat(t.type,".")),!0}setVisibility(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=_nt(hft,this).get(t);if(n){if(r&&e&&n.rbGroups.length)for(var i of n.rbGroups)for(var a of i){var s;if(a!==t)null===(s=_nt(hft,this).get(a))||void 0===s||s._setVisible(rft,!1,!0)}n._setVisible(rft,!!e,!0),Snt(lft,this,null)}else Uot("Optional content group not found: ".concat(t))}setOCGState(t){var e,{state:r,preserveRB:n}=t;for(var i of r){switch(i){case"ON":case"OFF":case"Toggle":e=i;continue}var a=_nt(hft,this).get(i);if(a)switch(e){case"ON":this.setVisibility(i,!0,n);break;case"OFF":this.setVisibility(i,!1,n);break;case"Toggle":this.setVisibility(i,!a.visible,n)}}Snt(lft,this,null)}get hasInitialVisibility(){return null===_nt(cft,this)||this.getHash()===_nt(cft,this)}getOrder(){return _nt(hft,this).size?_nt(uft,this)?_nt(uft,this).slice():[..._nt(hft,this).keys()]:null}getGroups(){return _nt(hft,this).size>0?nlt(_nt(hft,this)):null}getGroup(t){return _nt(hft,this).get(t)||null}getHash(){if(null!==_nt(lft,this))return _nt(lft,this);var t=new hdt;for(var[e,r]of _nt(hft,this))t.update("".concat(e,":").concat(r.visible));return Snt(lft,this,t.hexdigest())}}function fft(t){var e=t.length;if(e<2)return!0;for(var r=t[0],n=1;n<e;n++){var i=t[n],a=void 0;if(Array.isArray(i))a=bnt(dft,this,fft).call(this,i);else{if(!_nt(hft,this).has(i))return Uot("Optional content group not found: ".concat(i)),!0;a=_nt(hft,this).get(i).visible}switch(r){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return"And"===r}class gft{constructor(t,e){var{disableRange:r=!1,disableStream:n=!1}=e;Got(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');var{length:i,initialData:a,progressiveDone:s,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=s,this._contentDispositionFilename=o,(null==a?void 0:a.length)>0){var l=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!r,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData(t){var{begin:e,chunk:r}=t,n=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;void 0===e?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):Got(this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}_onProgress(t){var e,r,n,i;void 0===t.total?null===(e=this._rangeReaders[0])||void 0===e||null===(r=e.onProgress)||void 0===r||r.call(e,{loaded:t.loaded}):null===(n=this._fullRequestReader)||void 0===n||null===(i=n.onProgress)||void 0===i||i.call(n,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;null===(t=this._fullRequestReader)||void 0===t||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){var e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Got(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");var t=this._queuedChunks;return this._queuedChunks=null,new vft(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new mft(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeReaders.slice(0)))r.cancel(t);this._pdfDataRangeTransport.abort()}}class vft{constructor(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;for(var i of(this._stream=t,this._done=r||!1,this._filename=wlt(n)?n:null,this._queuedChunks=e||[],this._loaded=0,this._queuedChunks))this._loaded+=i.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){var t=this;return xnt((function*(){if(t._queuedChunks.length>0)return{value:t._queuedChunks.shift(),done:!1};if(t._done)return{value:void 0,done:!0};var e=Promise.withResolvers();return t._requests.push(e),e.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class mft{constructor(t,e,r){this._stream=t,this._begin=e,this._end=r,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{var e=this._requests.shift();for(var r of(e.resolve({value:t,done:!1}),this._requests))r.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){var t=this;return xnt((function*(){if(t._queuedChunk){var e=t._queuedChunk;return t._queuedChunk=null,{value:e,done:!1}}if(t._done)return{value:void 0,done:!0};var r=Promise.withResolvers();return t._requests.push(r),r.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function yft(t,e){var r=new Headers;if(!t||!e||"object"!=typeof e)return r;for(var n in e){var i=e[n];void 0!==i&&r.append(n,i)}return r}function bft(t){try{return new URL(t).origin}catch(t){}return null}function wft(t){var{responseHeaders:e,isHttp:r,rangeChunkSize:n,disableRange:i}=t,a={allowRangeRequests:!1,suggestedLength:void 0},s=parseInt(e.get("Content-Length"),10);return Number.isInteger(s)?(a.suggestedLength=s,s<=2*n||i||!r||"bytes"!==e.get("Accept-Ranges")||"identity"!==(e.get("Content-Encoding")||"identity")||(a.allowRangeRequests=!0),a):a}function xft(t){var e=t.get("Content-Disposition");if(e){var r=function(t){var e=!0,r=a("filename\\*","i").exec(t);if(r){var n=l(r=r[1]);return o(n=c(n=h(n=unescape(n))))}if(r=function(t){for(var e,r=[],n=a("filename\\*((?!0\\d)\\d+)(\\*?)","ig");null!==(e=n.exec(t));){var[,i,s,o]=e;if((i=parseInt(i,10))in r){if(0===i)break}else r[i]=[s,o]}for(var c=[],u=0;u<r.length&&u in r;++u){var[d,p]=r[u];p=l(p),d&&(p=unescape(p),0===u&&(p=h(p))),c.push(p)}return c.join("")}(t),r)return o(c(r));if(r=a("filename","i").exec(t)){var i=l(r=r[1]);return o(i=c(i))}function a(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function s(t,r){if(t){if(!/^[\x00-\xFF]+$/.test(r))return r;try{var n=new TextDecoder(t,{fatal:!0}),i=rlt(r);r=n.decode(i),e=!1}catch(t){}}return r}function o(t){return e&&/[\x80-\xff]/.test(t)&&(t=s("utf-8",t),e&&(t=s("iso-8859-1",t))),t}function l(t){if(t.startsWith('"')){for(var e=t.slice(1).split('\\"'),r=0;r<e.length;++r){var n=e[r].indexOf('"');-1!==n&&(e[r]=e[r].slice(0,n),e.length=r+1),e[r]=e[r].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function h(t){var e=t.indexOf("'");return-1===e?t:s(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function c(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,r,n){if("q"===r||"Q"===r)return n=(n=n.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})),s(e,n);try{n=atob(n)}catch(t){}return s(e,n)}))}return""}(e);if(r.includes("%"))try{r=decodeURIComponent(r)}catch(t){}if(wlt(r))return r}return null}function Aft(t,e){return 404===t||0===t&&e.startsWith("file:")?new Qot('Missing PDF "'+e+'".'):new Jot("Unexpected server response (".concat(t,') while retrieving PDF "').concat(e,'".'),t)}function _ft(t){return 200===t||206===t}function kft(t,e,r){return{method:"GET",headers:t,signal:r.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Sft(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Uot("getArrayBuffer - unexpected data format: ".concat(t)),new Uint8Array(t).buffer)}class Eft{constructor(t){Tnt(this,"_responseOrigin",null),this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=yft(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}getFullReader(){return Got(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Mft(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new Tft(this,t,e);return this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class Mft{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;var e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;var r=new Headers(t.headers),n=e.url;fetch(n,kft(r,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=bft(e.url),!_ft(e.status))throw Aft(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();var r=e.headers,{allowRangeRequests:i,suggestedLength:a}=wft({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=a||this._contentLength,this._filename=xft(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new tlt("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return xnt((function*(){var e;yield t._headersCapability.promise;var{value:r,done:n}=yield t._reader.read();return n?{value:r,done:n}:(t._loaded+=r.byteLength,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded,total:t._contentLength}),{value:Sft(r),done:!1})}))()}cancel(t){var e;null===(e=this._reader)||void 0===e||e.cancel(t),this._abortController.abort()}}class Tft{constructor(t,e,r){this._stream=t,this._reader=null,this._loaded=0;var n=t.source;this._withCredentials=n.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!n.disableStream,this._abortController=new AbortController;var i=new Headers(t.headers);i.append("Range","bytes=".concat(e,"-").concat(r-1));var a=n.url;fetch(a,kft(i,this._withCredentials,this._abortController)).then((e=>{var r=bft(e.url);if(r!==t._responseOrigin)throw new Error('Expected range response-origin "'.concat(r,'" to match "').concat(t._responseOrigin,'".'));if(!_ft(e.status))throw Aft(e.status,a);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return xnt((function*(){var e;yield t._readCapability.promise;var{value:r,done:n}=yield t._reader.read();return n?{value:r,done:n}:(t._loaded+=r.byteLength,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded}),{value:Sft(r),done:!1})}))()}cancel(t){var e;null===(e=this._reader)||void 0===e||e.cancel(t),this._abortController.abort()}}class Cft{constructor(t){var{url:e,httpHeaders:r,withCredentials:n}=t;Tnt(this,"_responseOrigin",null),this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=yft(this.isHttp,r),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){var e=new XMLHttpRequest,r=this.currXhrId++,n=this.pendingRequests[r]={xhr:e};for(var[i,a]of(e.open("GET",this.url),e.withCredentials=this.withCredentials,this.headers))e.setRequestHeader(i,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range","bytes=".concat(t.begin,"-").concat(t.end-1)),n.expectedStatus=206):n.expectedStatus=200,e.responseType="arraybuffer",Got(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,r),e.onprogress=this.onProgress.bind(this,r),n.onHeadersReceived=t.onHeadersReceived,n.onDone=t.onDone,n.onError=t.onError,n.onProgress=t.onProgress,e.send(null),r}onProgress(t,e){var r,n=this.pendingRequests[t];n&&(null===(r=n.onProgress)||void 0===r||r.call(n,e))}onStateChange(t,e){var r=this.pendingRequests[t];if(r){var n=r.xhr;if(n.readyState>=2&&r.onHeadersReceived&&(r.onHeadersReceived(),delete r.onHeadersReceived),4===n.readyState&&t in this.pendingRequests)if(delete this.pendingRequests[t],0===n.status&&this.isHttp)r.onError(n.status);else{var i=n.status||200;if(200===i&&206===r.expectedStatus||i===r.expectedStatus){var a=function(t){var e=t.response;return"string"!=typeof e?e:rlt(e).buffer}(n);if(206===i){var s=n.getResponseHeader("Content-Range"),o=/bytes (\d+)-(\d+)\/(\d+)/.exec(s);o?r.onDone({begin:parseInt(o[1],10),chunk:a}):(Uot('Missing or invalid "Content-Range" header.'),r.onError(0))}else a?r.onDone({begin:0,chunk:a}):r.onError(n.status)}else r.onError(n.status)}}}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){var e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Pft{constructor(t){this._source=t,this._manager=new Cft(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){var e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return Got(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Ift(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){var r=new Rft(this._manager,t,e);return r.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class Ift{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){var t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=bft(e.responseURL);var r=e.getAllResponseHeaders(),n=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{var[e,...r]=t.split(": ");return[e,r.join(": ")]})):[]),{allowRangeRequests:i,suggestedLength:a}=wft({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=xft(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk));if(this._done=!0,!(this._cachedChunks.length>0)){for(var e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){for(var e of(this._storedError=Aft(t,this._url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;null===(e=this.onProgress)||void 0===e||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}read(){var t=this;return xnt((function*(){if(yield t._headersCapability.promise,t._storedError)throw t._storedError;if(t._cachedChunks.length>0)return{value:t._cachedChunks.shift(),done:!1};if(t._done)return{value:void 0,done:!0};var e=Promise.withResolvers();return t._requests.push(e),e.promise}))()}cancel(t){for(var e of(this._done=!0,this._headersCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Rft{constructor(t,e,r){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:r,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var t,e=bft(null===(t=this._manager.getRequestXhr(this._requestId))||void 0===t?void 0:t.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error('Expected range response-origin "'.concat(e,'" to match "').concat(this._manager._responseOrigin,'".')),this._onError(0))}_close(){var t;null===(t=this.onClosed)||void 0===t||t.call(this,this)}_onDone(t){var e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e;for(var r of(this._done=!0,this._requests))r.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){var e;for(var r of(null!==(e=this._storedError)&&void 0!==e||(this._storedError=Aft(t,this._url)),this._requests))r.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(null===(e=this.onProgress)||void 0===e||e.call(this,{loaded:t.loaded}))}get isStreamingSupported(){return!1}read(){var t=this;return xnt((function*(){if(t._storedError)throw t._storedError;if(null!==t._queuedChunk){var e=t._queuedChunk;return t._queuedChunk=null,{value:e,done:!1}}if(t._done)return{value:void 0,done:!0};var r=Promise.withResolvers();return t._requests.push(r),r.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}var Oft=/^[a-z][a-z0-9\-+.]+:/i;class Lft{constructor(t){this.source=t,this.url=function(t){if(Oft.test(t))return new URL(t);var e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),Got("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}getFullReader(){return Got(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Dft(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new Fft(this,t,e);return this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class Dft{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;var e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();var r=process.getBuiltinModule("fs");r.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(r.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new Qot('Missing PDF "'.concat(this._url,'".'))),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return xnt((function*(){var e;if(yield t._readCapability.promise,t._done)return{value:void 0,done:!0};if(t._storedError)throw t._storedError;var r=t._readableStream.read();return null===r?(t._readCapability=Promise.withResolvers(),t.read()):(t._loaded+=r.length,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded,total:t._contentLength}),{value:new Uint8Array(r).buffer,done:!1})}))()}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new tlt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Fft{constructor(t,e,r){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();var n=t.source;this._isStreamingSupported=!n.disableStream;var i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:r-1}))}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return xnt((function*(){var e;if(yield t._readCapability.promise,t._done)return{value:void 0,done:!0};if(t._storedError)throw t._storedError;var r=t._readableStream.read();return null===r?(t._readCapability=Promise.withResolvers(),t.read()):(t._loaded+=r.length,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded}),{value:new Uint8Array(r).buffer,done:!1})}))()}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}var Nft=30,jft=new WeakMap,Bft=new WeakMap,zft=new WeakMap,Wft=new WeakMap,Uft=new WeakMap,Hft=new WeakMap,Gft=new WeakMap,Yft=new WeakMap,Vft=new WeakMap,qft=new WeakMap,Xft=new WeakMap,$ft=new WeakMap,Kft=new WeakMap,Qft=new WeakMap,Jft=new WeakMap,Zft=new WeakMap,tgt=new WeakMap,egt=new WeakMap,rgt=new WeakSet;class ngt{constructor(t){var e,{textContentSource:r,container:n,viewport:i}=t;if(Mnt(this,rgt),knt(this,jft,Promise.withResolvers()),knt(this,Bft,null),knt(this,zft,!1),knt(this,Wft,!(null===(e=globalThis.FontInspector)||void 0===e||!e.enabled)),knt(this,Uft,null),knt(this,Hft,null),knt(this,Gft,0),knt(this,Yft,0),knt(this,Vft,null),knt(this,qft,null),knt(this,Xft,0),knt(this,$ft,0),knt(this,Kft,Object.create(null)),knt(this,Qft,[]),knt(this,Jft,null),knt(this,Zft,[]),knt(this,tgt,new WeakMap),knt(this,egt,null),r instanceof ReadableStream)Snt(Jft,this,r);else{if("object"!=typeof r)throw new Error('No "textContentSource" parameter specified.');Snt(Jft,this,new ReadableStream({start(t){t.enqueue(r),t.close()}}))}Snt(Bft,this,Snt(qft,this,n)),Snt($ft,this,i.scale*(globalThis.devicePixelRatio||1)),Snt(Xft,this,i.rotation),Snt(Hft,this,{div:null,properties:null,ctx:null});var{pageWidth:a,pageHeight:s,pageX:o,pageY:l}=i.rawDims;Snt(egt,this,[1,0,0,-1,-o,l+s]),Snt(Yft,this,a),Snt(Gft,this,s),hgt.call(ngt),Olt(n,i),_nt(jft,this).promise.finally((()=>{ggt._.delete(this),Snt(Hft,this,null),Snt(Kft,this,null)})).catch((()=>{}))}static get fontFamilyMap(){var{isWindows:t,isFirefox:e}=ilt.platform;return Vot(this,"fontFamilyMap",new Map([["sans-serif","".concat(t&&e?"Calibri, ":"","sans-serif")],["monospace","".concat(t&&e?"Lucida Console, ":"","monospace")]]))}render(){var t=()=>{_nt(Vft,this).read().then((e=>{var r,{value:n,done:i}=e;i?_nt(jft,this).resolve():(null!==(r=_nt(Uft,this))&&void 0!==r||Snt(Uft,this,n.lang),Object.assign(_nt(Kft,this),n.styles),bnt(rgt,this,igt).call(this,n.items),t())}),_nt(jft,this).reject)};return Snt(Vft,this,_nt(Jft,this).getReader()),ggt._.add(this),t(),_nt(jft,this).promise}update(t){var{viewport:e,onBefore:r=null}=t,n=e.scale*(globalThis.devicePixelRatio||1),i=e.rotation;if(i!==_nt(Xft,this)&&(null==r||r(),Snt(Xft,this,i),Olt(_nt(qft,this),{rotation:i})),n!==_nt($ft,this)){null==r||r(),Snt($ft,this,n);var a={div:null,properties:null,ctx:ogt.call(ngt,_nt(Uft,this))};for(var s of _nt(Zft,this))a.properties=_nt(tgt,this).get(s),a.div=s,bnt(rgt,this,sgt).call(this,a)}}cancel(){var t,e=new tlt("TextLayer task cancelled.");null===(t=_nt(Vft,this))||void 0===t||t.cancel(e).catch((()=>{})),Snt(Vft,this,null),_nt(jft,this).reject(e)}get textDivs(){return _nt(Zft,this)}get textContentItemsStr(){return _nt(Qft,this)}static cleanup(){if(!(bnt(ngt,this,ggt)._.size>0)){for(var{canvas:t}of(bnt(ngt,this,ugt)._.clear(),bnt(ngt,this,dgt)._.values()))t.remove();bnt(ngt,this,dgt)._.clear()}}}function igt(t){var e,r;if(!_nt(zft,this)){null!==(r=(e=_nt(Hft,this)).ctx)&&void 0!==r||(e.ctx=ogt.call(Ist,_nt(Uft,this)));var n=_nt(Zft,this),i=_nt(Qft,this);for(var a of t){if(n.length>1e5)return Uot("Ignoring additional textDivs for performance reasons."),void Snt(zft,this,!0);if(void 0!==a.str)i.push(a.str),bnt(rgt,this,agt).call(this,a);else if("beginMarkedContentProps"===a.type||"beginMarkedContent"===a.type){var s=_nt(Bft,this);Snt(Bft,this,document.createElement("span")),_nt(Bft,this).classList.add("markedContent"),null!==a.id&&_nt(Bft,this).setAttribute("id","".concat(a.id)),s.append(_nt(Bft,this))}else"endMarkedContent"===a.type&&Snt(Bft,this,_nt(Bft,this).parentNode)}}}function agt(t){var e=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};_nt(Zft,this).push(e);var n=slt.transform(_nt(egt,this),t.transform),i=Math.atan2(n[1],n[0]),a=_nt(Kft,this)[t.fontName];a.vertical&&(i+=Math.PI/2);var s=_nt(Wft,this)&&a.fontSubstitution||a.fontFamily;s=Ist.fontFamilyMap.get(s)||s;var o,l,h=Math.hypot(n[2],n[3]),c=h*cgt.call(Ist,s,_nt(Uft,this));0===i?(o=n[4],l=n[5]-c):(o=n[4]+c*Math.sin(i),l=n[5]-c*Math.cos(i));var u="calc(var(--scale-factor)*",d=e.style;_nt(Bft,this)===_nt(qft,this)?(d.left="".concat((100*o/_nt(Yft,this)).toFixed(2),"%"),d.top="".concat((100*l/_nt(Gft,this)).toFixed(2),"%")):(d.left="".concat(u).concat(o.toFixed(2),"px)"),d.top="".concat(u).concat(l.toFixed(2),"px)")),d.fontSize="".concat(u).concat((fgt._*h).toFixed(2),"px)"),d.fontFamily=s,r.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,_nt(Wft,this)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==i&&(r.angle=i*(180/Math.PI));var p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){var f=Math.abs(t.transform[0]),g=Math.abs(t.transform[3]);f!==g&&Math.max(f,g)/Math.min(f,g)>1.5&&(p=!0)}if(p&&(r.canvasWidth=a.vertical?t.height:t.width),_nt(tgt,this).set(e,r),_nt(Hft,this).div=e,_nt(Hft,this).properties=r,bnt(rgt,this,sgt).call(this,_nt(Hft,this)),r.hasText&&_nt(Bft,this).append(e),r.hasEOL){var v=document.createElement("br");v.setAttribute("role","presentation"),_nt(Bft,this).append(v)}}function sgt(t){var{div:e,properties:r,ctx:n}=t,{style:i}=e,a="";if(fgt._>1&&(a="scale(".concat(1/fgt._,")")),0!==r.canvasWidth&&r.hasText){var{fontFamily:s}=i,{canvasWidth:o,fontSize:l}=r;lgt.call(Ist,n,l*_nt($ft,this),s);var{width:h}=n.measureText(e.textContent);h>0&&(a="scaleX(".concat(o*_nt($ft,this)/h,") ").concat(a))}0!==r.angle&&(a="rotate(".concat(r.angle,"deg) ").concat(a)),a.length>0&&(i.transform=a)}function ogt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=bnt(Ist,this,dgt)._.get(t||(t=""));if(!e){var r=document.createElement("canvas");r.className="hiddenCanvasElement",r.lang=t,document.body.append(r),e=r.getContext("2d",{alpha:!1,willReadFrequently:!0}),bnt(Ist,this,dgt)._.set(t,e),bnt(Ist,this,pgt)._.set(e,{size:0,family:""})}return e}function lgt(t,e,r){var n=bnt(Ist,this,pgt)._.get(t);e===n.size&&r===n.family||(t.font="".concat(e,"px ").concat(r),n.size=e,n.family=r)}function hgt(){if(null===bnt(Ist,this,fgt)._){var t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),fgt._=bnt(Ist,this,t.getBoundingClientRect().height),t.remove()}}function cgt(t,e){var r=bnt(Ist,this,ugt)._.get(t);if(r)return r;var n=bnt(Ist,this,ogt).call(this,e);n.canvas.width=n.canvas.height=Nft,bnt(Ist,this,lgt).call(this,n,Nft,t);var i=n.measureText(""),a=i.fontBoundingBoxAscent,s=Math.abs(i.fontBoundingBoxDescent);if(a){var o=a/(a+s);return bnt(Ist,this,ugt)._.set(t,o),n.canvas.width=n.canvas.height=0,o}n.strokeStyle="red",n.clearRect(0,0,Nft,Nft),n.strokeText("g",0,0);var l=n.getImageData(0,0,Nft,Nft).data;s=0;for(var h=l.length-1-3;h>=0;h-=4)if(l[h]>0){s=Math.ceil(h/4/Nft);break}n.clearRect(0,0,Nft,Nft),n.strokeText("A",0,Nft),a=0;for(var c=0,u=(l=n.getImageData(0,0,Nft,Nft).data).length;c<u;c+=4)if(l[c]>0){a=Nft-Math.floor(c/4/Nft);break}n.canvas.width=n.canvas.height=0;var d=a?a/(a+s):.8;return bnt(Ist,this,ugt)._.set(t,d),d}Ist=ngt;var ugt={_:new Map},dgt={_:new Map},pgt={_:new WeakMap},fgt={_:null},ggt={_:new Set};class vgt{static textContent(t){var e=[],r={items:e,styles:Object.create(null)};return function t(r){var n;if(r){var i=null,a=r.name;if("#text"===a)i=r.value;else{if(!vgt.shouldBuildText(a))return;null!=r&&null!==(n=r.attributes)&&void 0!==n&&n.textContent?i=r.attributes.textContent:r.value&&(i=r.value)}if(null!==i&&e.push({str:i}),r.children)for(var s of r.children)t(s)}}(t),r}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}var mgt=65536,ygt=Hst?class extends Hdt{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}:class extends Hdt{constructor(t){var{ownerDocument:e=globalThis.document,enableHWA:r=!1}=t;super({enableHWA:r}),this._document=e}_createCanvas(t,e){var r=this._document.createElement("canvas");return r.width=t,r.height=e,r}},bgt=Hst?class extends Gdt{_fetch(t){return xnt((function*(){return gpt(t)}))()}}:Ydt,wgt=Hst?class extends Vdt{}:class extends Vdt{constructor(t){var{docId:e,ownerDocument:r=globalThis.document}=t;super(),Mnt(this,tpt),knt(this,qdt,void 0),knt(this,Xdt,void 0),knt(this,$dt,void 0),knt(this,Kdt,void 0),knt(this,Qdt,void 0),knt(this,Jdt,void 0),knt(this,Zdt,0),Snt(Kdt,this,e),Snt(Qdt,this,r)}addFilter(t){var e,r;if(!t)return"none";var n=Ent(tpt,this,ept).get(t);if(n)return n;var[i,a,s]=bnt(tpt,this,ipt).call(this,t),o=1===t.length?i:"".concat(i).concat(a).concat(s);if(n=Ent(tpt,this,ept).get(o))return Ent(tpt,this,ept).set(t,n),n;var l="g_".concat(_nt(Kdt,this),"_transfer_map_").concat((Snt(Zdt,this,(e=_nt(Zdt,this),r=e++,e)),r)),h=bnt(tpt,this,apt).call(this,l);Ent(tpt,this,ept).set(t,h),Ent(tpt,this,ept).set(o,h);var c=bnt(tpt,this,lpt).call(this,l);return bnt(tpt,this,cpt).call(this,i,a,s,c),h}addHCMFilter(t,e){var r,n,i="".concat(t,"-").concat(e),a="base",s=Ent(tpt,this,rpt).get(a);if((null===(r=s)||void 0===r?void 0:r.key)===i)return s.url;s?(null===(n=s.filter)||void 0===n||n.remove(),s.key=i,s.url="none",s.filter=null):(s={key:i,url:"none",filter:null},Ent(tpt,this,rpt).set(a,s));if(!t||!e)return s.url;var o=bnt(tpt,this,dpt).call(this,t);t=slt.makeHexColor(...o);var l=bnt(tpt,this,dpt).call(this,e);if(e=slt.makeHexColor(...l),Ent(tpt,this,npt).style.color="","#000000"===t&&"#ffffff"===e||t===e)return s.url;for(var h=new Array(256),c=0;c<=255;c++){var u=c/255;h[c]=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4)}var d=h.join(","),p="g_".concat(_nt(Kdt,this),"_hcm_filter"),f=s.filter=bnt(tpt,this,lpt).call(this,p);bnt(tpt,this,cpt).call(this,d,d,d,f),bnt(tpt,this,opt).call(this,f);var g=(t,e)=>{for(var r=o[t]/255,n=l[t]/255,i=new Array(e+1),a=0;a<=e;a++)i[a]=r+a/e*(n-r);return i.join(",")};return bnt(tpt,this,cpt).call(this,g(0,5),g(1,5),g(2,5),f),s.url=bnt(tpt,this,apt).call(this,p),s.url}addAlphaFilter(t){var e,r,n=Ent(tpt,this,ept).get(t);if(n)return n;var[i]=bnt(tpt,this,ipt).call(this,[t]),a="alpha_".concat(i);if(n=Ent(tpt,this,ept).get(a))return Ent(tpt,this,ept).set(t,n),n;var s="g_".concat(_nt(Kdt,this),"_alpha_map_").concat((Snt(Zdt,this,(e=_nt(Zdt,this),r=e++,e)),r)),o=bnt(tpt,this,apt).call(this,s);Ent(tpt,this,ept).set(t,o),Ent(tpt,this,ept).set(a,o);var l=bnt(tpt,this,lpt).call(this,s);return bnt(tpt,this,upt).call(this,i,l),o}addLuminosityFilter(t){var e,r,n,i,a=Ent(tpt,this,ept).get(t||"luminosity");if(a)return a;if(t?([n]=bnt(tpt,this,ipt).call(this,[t]),i="luminosity_".concat(n)):i="luminosity",a=Ent(tpt,this,ept).get(i))return Ent(tpt,this,ept).set(t,a),a;var s="g_".concat(_nt(Kdt,this),"_luminosity_map_").concat((Snt(Zdt,this,(e=_nt(Zdt,this),r=e++,e)),r)),o=bnt(tpt,this,apt).call(this,s);Ent(tpt,this,ept).set(t,o),Ent(tpt,this,ept).set(i,o);var l=bnt(tpt,this,lpt).call(this,s);return bnt(tpt,this,spt).call(this,l),t&&bnt(tpt,this,upt).call(this,n,l),o}addHighlightHCMFilter(t,e,r,n,i){var a,s,o="".concat(e,"-").concat(r,"-").concat(n,"-").concat(i),l=Ent(tpt,this,rpt).get(t);if((null===(a=l)||void 0===a?void 0:a.key)===o)return l.url;l?(null===(s=l.filter)||void 0===s||s.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},Ent(tpt,this,rpt).set(t,l));if(!e||!r)return l.url;var[h,c]=[e,r].map(bnt(tpt,this,dpt).bind(this)),u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[p,f]=[n,i].map(bnt(tpt,this,dpt).bind(this));d<u&&([u,d,p,f]=[d,u,f,p]),Ent(tpt,this,npt).style.color="";var g=(t,e,r)=>{for(var n=new Array(256),i=(d-u)/r,a=t/255,s=(e-t)/(255*r),o=0,l=0;l<=r;l++){for(var h=Math.round(u+l*i),c=a+l*s,p=o;p<=h;p++)n[p]=c;o=h+1}for(var f=o;f<256;f++)n[f]=n[o-1];return n.join(",")},v="g_".concat(_nt(Kdt,this),"_hcm_").concat(t,"_filter"),m=l.filter=bnt(tpt,this,lpt).call(this,v);return bnt(tpt,this,opt).call(this,m),bnt(tpt,this,cpt).call(this,g(p[0],f[0],5),g(p[1],f[1],5),g(p[2],f[2],5),m),l.url=bnt(tpt,this,apt).call(this,v),l.url}destroy(){var t,e,r,n;arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&null!==(t=_nt(Jdt,this))&&void 0!==t&&t.size||(null===(e=_nt($dt,this))||void 0===e||e.parentNode.parentNode.remove(),Snt($dt,this,null),null===(r=_nt(Xdt,this))||void 0===r||r.clear(),Snt(Xdt,this,null),null===(n=_nt(Jdt,this))||void 0===n||n.clear(),Snt(Jdt,this,null),Snt(Zdt,this,0))}},xgt=Hst?class extends ppt{_fetch(t){return xnt((function*(){return gpt(t)}))()}}:fpt;function Agt(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"string"==typeof r||r instanceof URL?r={url:r}:(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});var n=new kgt,{docId:i}=n,a=r.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch(e){if(Hst&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(r.url):null,s=r.data?function(t){if(Hst&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return rlt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(null==t?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(r.data):null,o=r.httpHeaders||null,l=!0===r.withCredentials,h=null!==(t=r.password)&&void 0!==t?t:null,c=r.range instanceof Egt?r.range:null,u=Number.isInteger(r.rangeChunkSize)&&r.rangeChunkSize>0?r.rangeChunkSize:mgt,d=r.worker instanceof jgt?r.worker:null,p=r.verbosity,f="string"!=typeof r.docBaseUrl||blt(r.docBaseUrl)?null:r.docBaseUrl,g="string"==typeof r.cMapUrl?r.cMapUrl:null,v=!1!==r.cMapPacked,m=r.CMapReaderFactory||bgt,y="string"==typeof r.standardFontDataUrl?r.standardFontDataUrl:null,b=r.StandardFontDataFactory||xgt,w=!0!==r.stopAtErrors,x=Number.isInteger(r.maxImageSize)&&r.maxImageSize>-1?r.maxImageSize:-1,A=!1!==r.isEvalSupported,_="boolean"==typeof r.isOffscreenCanvasSupported?r.isOffscreenCanvasSupported:!Hst,k="boolean"==typeof r.isImageDecoderSupported?r.isImageDecoderSupported:!Hst&&(ilt.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(r.canvasMaxAreaInBytes)?r.canvasMaxAreaInBytes:-1,E="boolean"==typeof r.disableFontFace?r.disableFontFace:Hst,M=!0===r.fontExtraProperties,T=!0===r.enableXfa,C=r.ownerDocument||globalThis.document,P=!0===r.disableRange,I=!0===r.disableStream,R=!0===r.disableAutoFetch,O=!0===r.pdfBug,L=r.CanvasFactory||ygt,D=r.FilterFactory||wgt,F=!0===r.enableHWA,N=c?c.length:null!==(e=r.length)&&void 0!==e?e:NaN,j="boolean"==typeof r.useSystemFonts?r.useSystemFonts:!Hst&&!E,B="boolean"==typeof r.useWorkerFetch?r.useWorkerFetch:m===Ydt&&b===fpt&&g&&y&&klt(g,document.baseURI)&&klt(y,document.baseURI);Bot(p);var z={canvasFactory:new L({ownerDocument:C,enableHWA:F}),filterFactory:new D({docId:i,ownerDocument:C}),cMapReaderFactory:B?null:new m({baseUrl:g,isCompressed:v}),standardFontDataFactory:B?null:new b({baseUrl:y})};if(!d){var W={verbosity:p,port:Kpt.workerPort};d=W.port?jgt.fromPort(W):new jgt(W),n._worker=d}var U={docId:i,apiVersion:"4.10.38",data:s,password:h,disableAutoFetch:R,rangeChunkSize:u,length:N,docBaseUrl:f,enableXfa:T,evaluatorOptions:{maxImageSize:x,disableFontFace:E,ignoreErrors:w,isEvalSupported:A,isOffscreenCanvasSupported:_,isImageDecoderSupported:k,canvasMaxAreaInBytes:S,fontExtraProperties:M,useSystemFonts:j,cMapUrl:B?g:null,standardFontDataUrl:B?y:null}},H={disableFontFace:E,fontExtraProperties:M,ownerDocument:C,pdfBug:O,styleElement:null,loadingParams:{disableAutoFetch:R,enableXfa:T}};return d.promise.then((function(){if(n.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");var t,e=d.messageHandler.sendWithPromise("GetDocRequest",U,s?[s.buffer]:null);if(c)t=new gft(c,{disableRange:P,disableStream:I});else if(!s){if(!a)throw new Error("getDocument - no `url` parameter provided.");var r;if(Hst)if(klt(a)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");r=Eft}else r=Lft;else r=klt(a)?Eft:Pft;t=new r({url:a,length:N,httpHeaders:o,withCredentials:l,rangeChunkSize:u,disableRange:P,disableStream:I})}return e.then((e=>{if(n.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");var r=new Fdt(i,e,d.port),a=new Kgt(r,n,t,H,z);n._transport=a,r.send("Ready",null)}))})).catch(n._capability.reject),n}function _gt(t){return"object"==typeof t&&Number.isInteger(null==t?void 0:t.num)&&t.num>=0&&Number.isInteger(null==t?void 0:t.gen)&&t.gen>=0}class kgt{constructor(){var t,e;this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d".concat((Sgt._=(t=Sgt._,e=t++,t),e)),this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){var t=this;return xnt((function*(){var e;t.destroyed=!0;try{var r,n;null!==(r=t._worker)&&void 0!==r&&r.port&&(t._worker._pendingDestroy=!0),yield null===(n=t._transport)||void 0===n?void 0:n.destroy()}catch(e){var i;throw null!==(i=t._worker)&&void 0!==i&&i.port&&delete t._worker._pendingDestroy,e}t._transport=null,null===(e=t._worker)||void 0===e||e.destroy(),t._worker=null}))()}}var Sgt={_:0};class Egt{constructor(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;this.length=t,this.initialData=e,this.progressiveDone=r,this.contentDispositionFilename=n,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(var r of this._rangeListeners)r(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(var r of this._progressListeners)r(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(var e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(var t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Hot("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Mgt{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Vot(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){var{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Tgt=new WeakMap,Cgt=new WeakMap,Pgt=new WeakSet;class Igt{constructor(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Mnt(this,Pgt),knt(this,Tgt,null),knt(this,Cgt,!1),this._pageIndex=t,this._pageInfo=e,this._transport=r,this._stats=n?new _lt:null,this._pdfBug=n,this.commonObjs=r.commonObjs,this.objs=new evt,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport(){var{scale:t,rotation:e=this.rotate,offsetX:r=0,offsetY:n=0,dontFlip:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new mlt({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:r,offsetY:n,dontFlip:i})}getAnnotations(){var{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Vot(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){var t=this;return xnt((function*(){var e;return(null===(e=t._transport._htmlForXfa)||void 0===e?void 0:e.children[t._pageIndex])||null}))()}render(t){var e,r,{canvasContext:n,viewport:i,intent:a="display",annotationMode:s=eot.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:h=null,annotationCanvasMap:c=null,pageColors:u=null,printAnnotationStorage:d=null,isEditing:p=!1}=t;null===(e=this._stats)||void 0===e||e.time("Overall");var f=this._transport.getRenderingIntent(a,s,d,p),{renderingIntent:g,cacheKey:v}=f;Snt(Cgt,this,!1),bnt(Pgt,this,Ogt).call(this),h||(h=this._transport.getOptionalContentConfig(g));var m=this._intentStates.get(v);m||(m=Object.create(null),this._intentStates.set(v,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);var y,b=!!(g&$st);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null===(y=this._stats)||void 0===y||y.time("Page Request"),this._pumpOperatorList(f));var w=t=>{var e;(m.renderTasks.delete(x),(this._maybeCleanupAfterRender||b)&&Snt(Cgt,this,!0),bnt(Pgt,this,Rgt).call(this,!b),t?(x.capability.reject(t),this._abortOperatorList({intentState:m,reason:t instanceof Error?t:new Error(t)})):x.capability.resolve(),this._stats)&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),null!==(e=globalThis.Stats)&&void 0!==e&&e.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},x=new svt({callback:w,params:{canvasContext:n,viewport:i,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:u});((r=m).renderTasks||(r.renderTasks=new Set)).add(x);var A=x.task;return Promise.all([m.displayReadyCapability.promise,h]).then((t=>{var e,[r,n]=t;if(this.destroyed)w();else{if(null===(e=this._stats)||void 0===e||e.time("Rendering"),!(n.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");x.initializeGraphics({transparency:r,optionalContentConfig:n}),x.operatorListChanged()}})).catch(w),A}getOperatorList(){var{intent:t="display",annotationMode:e=eot.ENABLE,printAnnotationStorage:r=null,isEditing:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var i,a,s,o=this._transport.getRenderingIntent(t,e,r,n,!0),l=this._intentStates.get(o.cacheKey);(l||(l=Object.create(null),this._intentStates.set(o.cacheKey,l)),l.opListReadCapability)||((i=Object.create(null)).operatorListChanged=function(){l.operatorList.lastChunk&&(l.opListReadCapability.resolve(l.operatorList),l.renderTasks.delete(i))},l.opListReadCapability=Promise.withResolvers(),((a=l).renderTasks||(a.renderTasks=new Set)).add(i),l.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null===(s=this._stats)||void 0===s||s.time("Page Request"),this._pumpOperatorList(o));return l.opListReadCapability.promise}streamTextContent(){var{includeMarkedContent:t=!1,disableNormalization:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._transport._htmlForXfa)return this.getXfa().then((t=>vgt.textContent(t)));var e=this.streamTextContent(t);return new Promise((function(t,r){var n=e.getReader(),i={items:[],styles:Object.create(null),lang:null};!function e(){n.read().then((function(r){var n,{value:a,done:s}=r;s?t(i):(null!==(n=i.lang)&&void 0!==n||(i.lang=a.lang),Object.assign(i.styles,a.styles),i.items.push(...a.items),e())}),r)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;var t=[];for(var e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(var r of e.renderTasks)t.push(r.completed),r.cancel();return this.objs.clear(),Snt(Cgt,this,!1),bnt(Pgt,this,Ogt).call(this),Promise.all(t)}cleanup(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Snt(Cgt,this,!0);var e=bnt(Pgt,this,Rgt).call(this,!1);return t&&e&&this._stats&&(this._stats=new _lt),e}_startRenderPage(t,e){var r,n,i=this._intentStates.get(e);i&&(null===(r=this._stats)||void 0===r||r.timeEnd("Page Request"),null===(n=i.displayReadyCapability)||void 0===n||n.resolve(t))}_renderPageChunk(t,e){for(var r=0,n=t.length;r<n;r++)e.operatorList.fnArray.push(t.fnArray[r]),e.operatorList.argsArray.push(t.argsArray[r]);for(var i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&bnt(Pgt,this,Rgt).call(this,!0)}_pumpOperatorList(t){var{renderingIntent:e,cacheKey:r,annotationStorageSerializable:n,modifiedIds:i}=t,{map:a,transfer:s}=n,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:r,annotationStorage:a,modifiedIds:i},s).getReader(),l=this._intentStates.get(r);l.streamReader=o;var h=()=>{o.read().then((t=>{var{value:e,done:r}=t;r?l.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,l),h())}),(t=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){for(var e of(l.operatorList.lastChunk=!0,l.renderTasks))e.operatorListChanged();bnt(Pgt,this,Rgt).call(this,!0)}if(l.displayReadyCapability)l.displayReadyCapability.reject(t);else{if(!l.opListReadCapability)throw t;l.opListReadCapability.reject(t)}}}))};h()}_abortOperatorList(t){var{intentState:e,reason:r,force:n=!1}=t;if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(r instanceof ylt){var i=100;return r.extraDelay>0&&r.extraDelay<1e3&&(i+=r.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:r,force:!0})}),i))}}if(e.streamReader.cancel(new tlt(r.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(var[a,s]of this._intentStates)if(s===e){this._intentStates.delete(a);break}this.cleanup()}}}get stats(){return this._stats}}function Rgt(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(bnt(Pgt,this,Ogt).call(this),!_nt(Cgt,this)||this.destroyed)return!1;if(t)return Snt(Tgt,this,setTimeout((()=>{Snt(Tgt,this,null),bnt(Pgt,this,Rgt).call(this,!1)}),5e3)),!1;for(var{renderTasks:e,operatorList:r}of this._intentStates.values())if(e.size>0||!r.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),Snt(Cgt,this,!1),!0}function Ogt(){_nt(Tgt,this)&&(clearTimeout(_nt(Tgt,this)),Snt(Tgt,this,null))}var Lgt=new WeakMap,Dgt=new WeakMap;class Fgt{constructor(){knt(this,Lgt,new Map),knt(this,Dgt,Promise.resolve())}postMessage(t,e){var r={data:structuredClone(t,e?{transfer:e}:null)};_nt(Dgt,this).then((()=>{for(var[t]of _nt(Lgt,this))t.call(this,r)}))}addEventListener(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=null;if((null==r?void 0:r.signal)instanceof AbortSignal){var{signal:i}=r;if(i.aborted)return void Uot("LoopbackPort - cannot use an `aborted` signal.");var a=()=>this.removeEventListener(t,e);n=()=>i.removeEventListener("abort",a),i.addEventListener("abort",a)}_nt(Lgt,this).set(e,n)}removeEventListener(t,e){var r=_nt(Lgt,this).get(e);null==r||r(),_nt(Lgt,this).delete(e)}terminate(){for(var[,t]of _nt(Lgt,this))null==t||t();_nt(Lgt,this).clear()}}var Ngt=new WeakSet;class jgt{constructor(){var{name:t=null,port:e=null,verbosity:r=zot()}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Mnt(this,Ngt),this.name=t,this.destroyed=!1,this.verbosity=r,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){var n;if(null!==(n=Hgt._)&&void 0!==n&&n.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(Hgt._||(Hgt._=new WeakMap)).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Fdt("main","worker",t),this._messageHandler.on("ready",(function(){})),bnt(Ngt,this,Bgt).call(this)}_initialize(){if(Ugt._||zgt(jgt))this._setupFakeWorker();else{var{workerSrc:t}=jgt;try{jgt._isSameOrigin(window.location.href,t)||(t=jgt._createCDNWrapper(new URL(t,window.location).href));var e=new Worker(t,{type:"module"}),r=new Fdt("main","worker",e),n=()=>{i.abort(),r.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},i=new AbortController;e.addEventListener("error",(()=>{this._webWorker||n()}),{signal:i.signal}),r.on("test",(t=>{i.abort(),!this.destroyed&&t?(this._messageHandler=r,this._port=e,this._webWorker=e,bnt(Ngt,this,Bgt).call(this)):n()})),r.on("ready",(t=>{if(i.abort(),this.destroyed)n();else try{a()}catch(t){this._setupFakeWorker()}}));var a=()=>{var t=new Uint8Array;r.send("test",t,[t.buffer])};return void a()}catch(t){Wot("The worker has been disabled.")}this._setupFakeWorker()}}_setupFakeWorker(){Ugt._||(Uot("Setting up fake worker."),Ugt._=!0),jgt._setupFakeWorkerGlobal.then((t=>{var e,r;if(this.destroyed)this._readyCapability.reject(new Error("Worker was destroyed"));else{var n=new Fgt;this._port=n;var i="fake".concat((Wgt._=(e=Wgt._,r=e++,e),r)),a=new Fdt(i+"_worker",i,n);t.setup(a,n),this._messageHandler=new Fdt(i,i+"_worker",n),bnt(Ngt,this,Bgt).call(this)}})).catch((t=>{this._readyCapability.reject(new Error('Setting up fake worker failed: "'.concat(t.message,'".')))}))}destroy(){var t,e,r;this.destroyed=!0,null===(t=this._webWorker)||void 0===t||t.terminate(),this._webWorker=null,null===(e=Hgt._)||void 0===e||e.delete(this._port),this._port=null,null===(r=this._messageHandler)||void 0===r||r.destroy(),this._messageHandler=null}static fromPort(t){var e;if(null==t||!t.port)throw new Error("PDFWorker.fromPort - invalid method signature.");var r=null===(e=bnt(jgt,this,Hgt)._)||void 0===e?void 0:e.get(t.port);if(r){if(r._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return r}return new jgt(t)}static get workerSrc(){if(Kpt.workerSrc)return Kpt.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){var t=this,e=function(){var e=xnt((function*(){return Ent(jgt,t,zgt)?Ent(jgt,t,zgt):(yield import(t.workerSrc)).WorkerMessageHandler}));return function(){return e.apply(this,arguments)}}();return Vot(this,"_setupFakeWorkerGlobal",e())}}function Bgt(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}function zgt(t){try{var e;return(null===(e=globalThis.pdfjsWorker)||void 0===e?void 0:e.WorkerMessageHandler)||null}catch(t){return null}}Rst=jgt;var Wgt={_:0},Ugt={_:!1},Hgt={_:void 0};Hst&&(Ugt._=bnt(Rst,Rst,!0),Kpt.workerSrc||(Kpt.workerSrc="./pdf.worker.mjs")),Rst._isSameOrigin=(t,e)=>{var r;try{if(!(r=new URL(t)).origin||"null"===r.origin)return!1}catch(t){return!1}var n=new URL(e,r);return r.origin===n.origin},Rst._createCDNWrapper=t=>{var e='await import("'.concat(t,'");');return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};var Ggt=new WeakMap,Ygt=new WeakMap,Vgt=new WeakMap,qgt=new WeakMap,Xgt=new WeakMap,$gt=new WeakSet;class Kgt{constructor(t,e,r,n,i){Mnt(this,$gt),knt(this,Ggt,new Map),knt(this,Ygt,new Map),knt(this,Vgt,new Map),knt(this,qgt,new Map),knt(this,Xgt,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new evt,this.fontLoader=new wdt({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=r,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return Vot(this,"annotationStorage",new gdt)}getRenderingIntent(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eot.ENABLE,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=Xst,s=cdt;switch(t){case"any":a=qst;break;case"display":break;case"print":a=$st;break;default:Uot("getRenderingIntent - invalid intent: ".concat(t))}var o=a&$st&&r instanceof ydt?r:this.annotationStorage;switch(e){case eot.DISABLE:a+=Jst;break;case eot.ENABLE:break;case eot.ENABLE_FORMS:a+=Kst;break;case eot.ENABLE_STORAGE:a+=Qst,s=o.serializable;break;default:Uot("getRenderingIntent - invalid annotationMode: ".concat(e))}n&&(a+=Zst),i&&(a+=tot);var{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,s.hash,h].join("_"),annotationStorageSerializable:s,modifiedIds:l}}destroy(){var t;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null===(t=_nt(Xgt,this))||void 0===t||t.reject(new Error("Worker was destroyed during onPassword callback"));var e=[];for(var r of _nt(Ygt,this).values())e.push(r._destroy());_nt(Ygt,this).clear(),_nt(Vgt,this).clear(),_nt(qgt,this).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();var n=this.messageHandler.sendWithPromise("Terminate",null);return e.push(n),Promise.all(e).then((()=>{var t,e;this.commonObjs.clear(),this.fontLoader.clear(),_nt(Ggt,this).clear(),this.filterFactory.destroy(),ngt.cleanup(),null===(t=this._networkStream)||void 0===t||t.cancelAllRequests(new tlt("Worker was terminated.")),null===(e=this.messageHandler)||void 0===e||e.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){var t=this,{messageHandler:e,loadingTask:r}=this;e.on("GetReader",((t,e)=>{Got(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function(t){var{value:r,done:n}=t;n?e.close():(Got(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),e.on("ReaderHeadersReady",function(){var e=xnt((function*(e){yield t._fullReader.headersReady;var{isStreamingSupported:n,isRangeSupported:i,contentLength:a}=t._fullReader;if(!n||!i){var s;if(t._lastProgress)null===(s=r.onProgress)||void 0===s||s.call(r,t._lastProgress);t._fullReader.onProgress=t=>{var e;null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.loaded,total:t.total})}}return{isStreamingSupported:n,isRangeSupported:i,contentLength:a}}));return function(t){return e.apply(this,arguments)}}()),e.on("GetRangeReader",((t,e)=>{Got(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");var r=this._networkStream.getRangeReader(t.begin,t.end);r?(e.onPull=()=>{r.read().then((function(t){var{value:r,done:n}=t;n?e.close():(Got(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{r.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),e.on("GetDoc",(t=>{var{pdfInfo:e}=t;this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,r._capability.resolve(new Mgt(e,this))})),e.on("DocException",(t=>{r._capability.reject(Odt(t))})),e.on("PasswordRequest",(t=>{Snt(Xgt,this,Promise.withResolvers());try{if(!r.onPassword)throw Odt(t);r.onPassword((t=>{t instanceof Error?_nt(Xgt,this).reject(t):_nt(Xgt,this).resolve({password:t})}),t.code)}catch(t){_nt(Xgt,this).reject(t)}return _nt(Xgt,this).promise})),e.on("DataLoaded",(t=>{var e;null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),e.on("StartRenderPage",(t=>{this.destroyed||_nt(Ygt,this).get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),e.on("commonobj",(t=>{var r,[n,i,a]=t;if(this.destroyed)return null;if(this.commonObjs.has(n))return null;switch(i){case"Font":var{disableFontFace:s,fontExtraProperties:o,pdfBug:l}=this._params;if("error"in a){var h=a.error;Uot("Error during font loading: ".concat(h)),this.commonObjs.resolve(n,h);break}var c=l&&null!==(r=globalThis.FontInspector)&&void 0!==r&&r.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,u=new xdt(a,{disableFontFace:s,fontExtraProperties:o,inspectFont:c});this.fontLoader.bind(u).catch((()=>e.sendWithPromise("FontFallback",{id:n}))).finally((()=>{!o&&u.data&&(u.data=null),this.commonObjs.resolve(n,u)}));break;case"CopyLocalImage":var{imageRef:d}=a;for(var p of(Got(d,"The imageRef must be defined."),_nt(Ygt,this).values()))for(var[,f]of p.objs)if((null==f?void 0:f.ref)===d)return f.dataLen?(this.commonObjs.resolve(n,structuredClone(f)),f.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,a);break;default:throw new Error("Got unknown common object type ".concat(i))}return null})),e.on("obj",(t=>{var[e,r,n,i]=t;if(!this.destroyed){var a,s=_nt(Ygt,this).get(r);if(!s.objs.has(e))if(0!==s._intentStates.size)switch(n){case"Image":s.objs.resolve(e,i),(null==i?void 0:i.dataLen)>1e7&&(s._maybeCleanupAfterRender=!0);break;case"Pattern":s.objs.resolve(e,i);break;default:throw new Error("Got unknown object type ".concat(n))}else null==i||null===(a=i.bitmap)||void 0===a||a.close()}})),e.on("DocProgress",(t=>{var e;this.destroyed||null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.loaded,total:t.total})})),e.on("FetchBuiltInCMap",function(){var e=xnt((function*(e){if(t.destroyed)throw new Error("Worker was destroyed.");if(!t.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return t.cMapReaderFactory.fetch(e)}));return function(t){return e.apply(this,arguments)}}()),e.on("FetchStandardFontData",function(){var e=xnt((function*(e){if(t.destroyed)throw new Error("Worker was destroyed.");if(!t.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return t.standardFontDataFactory.fetch(e)}));return function(t){return e.apply(this,arguments)}}())}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var t,e;this.annotationStorage.size<=0&&Uot("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");var{map:r,transfer:n}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:r,filename:null!==(t=null===(e=this._fullReader)||void 0===e?void 0:e.filename)&&void 0!==t?t:null},n).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));var e=t-1,r=_nt(Vgt,this).get(e);if(r)return r;var n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&_nt(qgt,this).set(r.refStr,t);var n=new Igt(e,r,this,this._params.pdfBug);return _nt(Ygt,this).set(e,n),n}));return _nt(Vgt,this).set(e,n),n}getPageIndex(t){return _gt(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return bnt($gt,this,Qgt).call(this,"GetFieldObjects")}hasJSActions(){return bnt($gt,this,Qgt).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return bnt($gt,this,Qgt).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return bnt($gt,this,Qgt).call(this,"GetOptionalContentConfig").then((e=>new pft(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){var t="GetMetadata",e=_nt(Ggt,this).get(t);if(e)return e;var r=this.messageHandler.sendWithPromise(t,null).then((t=>{var e,r,n,i;return{info:t[0],metadata:t[1]?new eft(t[1]):null,contentDispositionFilename:null!==(e=null===(r=this._fullReader)||void 0===r?void 0:r.filename)&&void 0!==e?e:null,contentLength:null!==(n=null===(i=this._fullReader)||void 0===i?void 0:i.contentLength)&&void 0!==n?n:null}}));return _nt(Ggt,this).set(t,r),r}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(){var t=arguments,e=this;return xnt((function*(){var r=t.length>0&&void 0!==t[0]&&t[0];if(!e.destroyed){for(var n of(yield e.messageHandler.sendWithPromise("Cleanup",null),_nt(Ygt,e).values())){if(!n.cleanup())throw new Error("startCleanup: Page ".concat(n.pageNumber," is currently rendering."))}e.commonObjs.clear(),r||e.fontLoader.clear(),_nt(Ggt,e).clear(),e.filterFactory.destroy(!0),ngt.cleanup()}}))()}cachedPageNumber(t){var e;if(!_gt(t))return null;var r=0===t.gen?"".concat(t.num,"R"):"".concat(t.num,"R").concat(t.gen);return null!==(e=_nt(qgt,this).get(r))&&void 0!==e?e:null}}function Qgt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=_nt(Ggt,this).get(t);if(r)return r;var n=this.messageHandler.sendWithPromise(t,e);return _nt(Ggt,this).set(t,n),n}var Jgt=Symbol("INITIAL_DATA"),Zgt=new WeakMap,tvt=new WeakSet;class evt{constructor(){Mnt(this,tvt),knt(this,Zgt,Object.create(null))}get(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e){var r=bnt(tvt,this,rvt).call(this,t);return r.promise.then((()=>e(r.data))),null}var n=_nt(Zgt,this)[t];if(!n||n.data===Jgt)throw new Error("Requesting object that isn't resolved yet ".concat(t,"."));return n.data}has(t){var e=_nt(Zgt,this)[t];return!!e&&e.data!==Jgt}delete(t){var e=_nt(Zgt,this)[t];return!(!e||e.data===Jgt)&&(delete _nt(Zgt,this)[t],!0)}resolve(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=bnt(tvt,this,rvt).call(this,t);r.data=e,r.resolve()}clear(){for(var t in _nt(Zgt,this)){var e,{data:r}=_nt(Zgt,this)[t];null==r||null===(e=r.bitmap)||void 0===e||e.close()}Snt(Zgt,this,Object.create(null))}*[Symbol.iterator](){for(var t in _nt(Zgt,this)){var{data:e}=_nt(Zgt,this)[t];e!==Jgt&&(yield[t,e])}}}function rvt(t){var e;return(e=_nt(Zgt,this))[t]||(e[t]=Pnt(Pnt({},Promise.withResolvers()),{},{data:Jgt}))}var nvt=new WeakMap;class ivt{constructor(t){knt(this,nvt,null),Snt(nvt,this,t),this.onContinue=null}get promise(){return _nt(nvt,this).capability.promise}cancel(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;_nt(nvt,this).cancel(null,t)}get separateAnnots(){var{separateAnnots:t}=_nt(nvt,this).operatorList;if(!t)return!1;var{annotationCanvasMap:e}=_nt(nvt,this);return t.form||t.canvas&&(null==e?void 0:e.size)>0}}var avt=new WeakMap;class svt{constructor(t){var{callback:e,params:r,objs:n,commonObjs:i,annotationCanvasMap:a,operatorList:s,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:u=!1,pageColors:d=null}=t;knt(this,avt,null),this.callback=e,this.params=r,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=s,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===c&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new ivt(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=r.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics(t){var e,r,{transparency:n=!1,optionalContentConfig:i}=t;if(!this.cancelled){if(this._canvas){if(ovt._.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");ovt._.add(this._canvas)}this._pdfBug&&null!==(e=globalThis.StepperManager)&&void 0!==e&&e.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());var{canvasContext:a,viewport:s,transform:o,background:l}=this.params;this.gfx=new Ypt(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:i},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:o,viewport:s,transparency:n,background:l}),this.operatorListIdx=0,this.graphicsReady=!0,null===(r=this.graphicsReadyCallback)||void 0===r||r.call(this)}}cancel(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.running=!1,this.cancelled=!0,null===(t=this.gfx)||void 0===t||t.endDrawing(),_nt(avt,this)&&(window.cancelAnimationFrame(_nt(avt,this)),Snt(avt,this,null)),ovt._.delete(this._canvas),this.callback(e||new ylt("Rendering cancelled, page ".concat(this._pageIndex+1),r))}operatorListChanged(){var t;this.graphicsReady?(null===(t=this.stepper)||void 0===t||t.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?Snt(avt,this,window.requestAnimationFrame((()=>{Snt(avt,this,null),this._nextBound().catch(this._cancelBound)}))):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){var t=this;return xnt((function*(){t.cancelled||(t.operatorListIdx=t.gfx.executeOperatorList(t.operatorList,t.operatorListIdx,t._continueBound,t.stepper),t.operatorListIdx===t.operatorList.argsArray.length&&(t.running=!1,t.operatorList.lastChunk&&(t.gfx.endDrawing(),ovt._.delete(t._canvas),t.callback())))}))()}}var ovt={_:new WeakSet},lvt="4.10.38",hvt="f9bea397f";function cvt(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function uvt(t){return Math.max(0,Math.min(255,255*t))}class dvt{static CMYK_G(t){var[e,r,n,i]=t;return["G",1-Math.min(1,.3*e+.59*n+.11*r+i)]}static G_CMYK(t){var[e]=t;return["CMYK",0,0,0,1-e]}static G_RGB(t){var[e]=t;return["RGB",e,e,e]}static G_rgb(t){var[e]=t;return[e=uvt(e),e,e]}static G_HTML(t){var[e]=t,r=cvt(e);return"#".concat(r).concat(r).concat(r)}static RGB_G(t){var[e,r,n]=t;return["G",.3*e+.59*r+.11*n]}static RGB_rgb(t){return t.map(uvt)}static RGB_HTML(t){return"#".concat(t.map(cvt).join(""))}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB(t){var[e,r,n,i]=t;return["RGB",1-Math.min(1,e+i),1-Math.min(1,n+i),1-Math.min(1,r+i)]}static CMYK_rgb(t){var[e,r,n,i]=t;return[uvt(1-Math.min(1,e+i)),uvt(1-Math.min(1,n+i)),uvt(1-Math.min(1,r+i))]}static CMYK_HTML(t){var e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK(t){var[e,r,n]=t,i=1-e,a=1-r,s=1-n;return["CMYK",i,a,s,Math.min(i,a,s)]}}class pvt{create(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");var n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),r||(n.setAttribute("width","".concat(t,"px")),n.setAttribute("height","".concat(e,"px"))),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox","0 0 ".concat(t," ").concat(e)),n}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Hot("Abstract method `_createSVG` called.")}}class fvt extends pvt{_createSVG(t){return document.createElementNS(plt,t)}}class gvt{static setupStorage(t,e,r,n,i){var a=n.getValue(e,{value:null});switch(r.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===i)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===r.attributes.type||"checkbox"===r.attributes.type){if(a.value===r.attributes.xfaOn?t.setAttribute("checked",!0):a.value===r.attributes.xfaOff&&t.removeAttribute("checked"),"print"===i)break;t.addEventListener("change",(t=>{n.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===i)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value)for(var s of(t.setAttribute("value",a.value),r.children))s.attributes.value===a.value?s.attributes.selected=!0:s.attributes.hasOwnProperty("selected")&&delete s.attributes.selected;t.addEventListener("input",(t=>{var r=t.target.options,i=-1===r.selectedIndex?"":r[r.selectedIndex].value;n.setValue(e,{value:i})}))}}static setAttributes(t){var{html:e,element:r,storage:n=null,intent:i,linkService:a}=t,{attributes:s}=r,o=e instanceof HTMLAnchorElement;for(var[l,h]of("radio"===s.type&&(s.name="".concat(s.name,"-").concat(i)),Object.entries(s)))if(null!=h)switch(l){case"class":h.length&&e.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",h);break;case"style":Object.assign(e.style,h);break;case"textContent":e.textContent=h;break;default:(!o||"href"!==l&&"newWindow"!==l)&&e.setAttribute(l,h)}o&&a.addLinkAttributes(e,s.href,s.newWindow),n&&s.dataId&&this.setupStorage(e,s.dataId,r,n)}static render(t){var e=t.annotationStorage,r=t.linkService,n=t.xfaHtml,i=t.intent||"display",a=document.createElement(n.name);n.attributes&&this.setAttributes({html:a,element:n,intent:i,linkService:r});var s="richText"!==i,o=t.div;if(o.append(a),t.viewport){var l="matrix(".concat(t.viewport.transform.join(","),")");o.style.transform=l}s&&o.setAttribute("class","xfaLayer xfaFont");var h=[];if(0===n.children.length){if(n.value){var c=document.createTextNode(n.value);a.append(c),s&&vgt.shouldBuildText(n.name)&&h.push(c)}return{textDivs:h}}for(var u=[[n,-1,a]];u.length>0;){var d,p,[f,g,v]=u.at(-1);if(g+1!==f.children.length){var m=f.children[++u.at(-1)[1]];if(null!==m){var{name:y}=m;if("#text"!==y){var b=null!=m&&null!==(d=m.attributes)&&void 0!==d&&d.xmlns?document.createElementNS(m.attributes.xmlns,y):document.createElement(y);if(v.append(b),m.attributes&&this.setAttributes({html:b,element:m,storage:e,intent:i,linkService:r}),(null===(p=m.children)||void 0===p?void 0:p.length)>0)u.push([m,-1,b]);else if(m.value){var w=document.createTextNode(m.value);s&&vgt.shouldBuildText(y)&&h.push(w),b.append(w)}}else{var x=document.createTextNode(m.value);h.push(x),v.append(x)}}}else u.pop()}for(var A of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))A.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){var e="matrix(".concat(t.viewport.transform.join(","),")");t.div.style.transform=e,t.div.hidden=!1}}var vvt=1e3,mvt=new WeakSet;function yvt(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class bvt{static create(t){switch(t.data.annotationType){case pot:return new Mvt(t);case dot:return new Ivt(t);case Cot:switch(t.data.fieldType){case"Tx":return new Ovt(t);case"Btn":return t.data.radioButton?new Fvt(t):t.data.checkBox?new Dvt(t):new Nvt(t);case"Ch":return new jvt(t);case"Sig":return new Lvt(t)}return new Rvt(t);case Mot:return new Bvt(t);case fot:return new vmt(t);case got:return new ymt(t);case vot:return new wmt(t);case mot:return new Amt(t);case bot:return new kmt(t);case Sot:return new Emt(t);case Eot:return new Pmt(t);case yot:return new Smt(t);case wot:return new Rmt(t);case xot:return new Omt(t);case Aot:return new Lmt(t);case _ot:return new Dmt(t);case kot:return new Fmt(t);case Tot:return new Bmt(t);default:return new kvt(t)}}}var wvt=new WeakMap,xvt=new WeakMap,Avt=new WeakMap,_vt=new WeakSet;class kvt{constructor(t){var{isRenderable:e=!1,ignoreBorder:r=!1,createQuadrilaterals:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Mnt(this,_vt),knt(this,wvt,null),knt(this,xvt,!1),knt(this,Avt,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(r)),n&&this._createQuadrilaterals()}static _hasPopupData(t){var{titleObj:e,contentsObj:r,richText:n}=t;return!!(null!=e&&e.str||null!=r&&r.str||null!=n&&n.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return kvt._hasPopupData(this.data)}updateEdited(t){var e;if(this.container){_nt(wvt,this)||Snt(wvt,this,{rect:this.data.rect.slice(0)});var{rect:r}=t;r&&bnt(_vt,this,Svt).call(this,r),null===(e=_nt(Avt,this))||void 0===e||e.popup.updateEdited(t)}}resetEdited(){var t;_nt(wvt,this)&&(bnt(_vt,this,Svt).call(this,_nt(wvt,this).rect),null===(t=_nt(Avt,this))||void 0===t||t.popup.resetEdited(),Snt(wvt,this,null))}_createContainer(t){var{data:e,parent:{page:r,viewport:n}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",e.id),this instanceof Rvt||(i.tabIndex=vvt);var{style:a}=i;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(i.title=e.alternativeText),e.noRotate&&i.classList.add("norotate"),!e.rect||this instanceof Bvt){var{rotation:s}=e;return e.hasOwnCanvas||0===s||this.setRotation(s,i),i}var{width:o,height:l}=yvt(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth="".concat(e.borderStyle.width,"px");var h=e.borderStyle.horizontalCornerRadius,c=e.borderStyle.verticalCornerRadius;if(h>0||c>0){var u="calc(".concat(h,"px * var(--scale-factor)) / calc(").concat(c,"px * var(--scale-factor))");a.borderRadius=u}else if(this instanceof Fvt){var d="calc(".concat(o,"px * var(--scale-factor)) / calc(").concat(l,"px * var(--scale-factor))");a.borderRadius=d}switch(e.borderStyle.style){case Pot:a.borderStyle="solid";break;case Iot:a.borderStyle="dashed";break;case Rot:Uot("Unimplemented border style: beveled");break;case Oot:Uot("Unimplemented border style: inset");break;case Lot:a.borderBottomStyle="solid"}var p=e.borderColor||null;p?(Snt(xvt,this,!0),a.borderColor=slt.makeHexColor(0|p[0],0|p[1],0|p[2])):a.borderWidth=0}var f=slt.normalizeRect([e.rect[0],r.view[3]-e.rect[1]+r.view[1],e.rect[2],r.view[3]-e.rect[3]+r.view[1]]),{pageWidth:g,pageHeight:v,pageX:m,pageY:y}=n.rawDims;a.left="".concat(100*(f[0]-m)/g,"%"),a.top="".concat(100*(f[1]-y)/v,"%");var{rotation:b}=e;return e.hasOwnCanvas||0===b?(a.width="".concat(100*o/g,"%"),a.height="".concat(100*l/v,"%")):this.setRotation(b,i),i}setRotation(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.container;if(this.data.rect){var r,n,{pageWidth:i,pageHeight:a}=this.parent.viewport.rawDims,{width:s,height:o}=yvt(this.data.rect);t%180==0?(r=100*s/i,n=100*o/a):(r=100*o/i,n=100*s/a),e.style.width="".concat(r,"%"),e.style.height="".concat(n,"%"),e.setAttribute("data-main-rotation",(360-t)%360)}}get _commonActions(){var t=(t,e,r)=>{var n=r.detail[t],i=n[0],a=n.slice(1);r.target.style[e]=dvt["".concat(i,"_HTML")](a),this.annotationStorage.setValue(this.data.id,{[e]:dvt["".concat(i,"_rgb")](a)})};return Vot(this,"_commonActions",{display:t=>{var{display:e}=t.detail,r=e%2==1;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:r,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{var{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{var e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){var r=this._commonActions;for(var n of Object.keys(e.detail)){var i=t[n]||r[n];null==i||i(e)}}_setDefaultPropertiesFromJS(t){if(this.enableScripting){var e=this.annotationStorage.getRawValue(this.data.id);if(e){var r=this._commonActions;for(var[n,i]of Object.entries(e)){var a=r[n];if(a)a({detail:{[n]:i},target:t}),delete e[n]}}}}_createQuadrilaterals(){if(this.container){var{quadPoints:t}=this.data;if(t){var[e,r,n,i]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){var[a,s,o,l]=t.subarray(2,6);if(n===a&&i===s&&e===o&&r===l)return}var h,{style:c}=this.container;if(_nt(xvt,this)){var{borderColor:u,borderWidth:d}=c;c.borderWidth=0,h=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">','<g fill="transparent" stroke="'.concat(u,'" stroke-width="').concat(d,'">')],this.container.classList.add("hasBorder")}var p=n-e,f=i-r,{svgFactory:g}=this,v=g.createElement("svg");v.classList.add("quadrilateralsContainer"),v.setAttribute("width",0),v.setAttribute("height",0);var m=g.createElement("defs");v.append(m);var y=g.createElement("clipPath"),b="clippath_".concat(this.data.id);y.setAttribute("id",b),y.setAttribute("clipPathUnits","objectBoundingBox"),m.append(y);for(var w=2,x=t.length;w<x;w+=8){var A,_=t[w],k=t[w+1],S=t[w+2],E=t[w+3],M=g.createElement("rect"),T=(S-e)/p,C=(i-k)/f,P=(_-S)/p,I=(k-E)/f;M.setAttribute("x",T),M.setAttribute("y",C),M.setAttribute("width",P),M.setAttribute("height",I),y.append(M),null===(A=h)||void 0===A||A.push('<rect vector-effect="non-scaling-stroke" x="'.concat(T,'" y="').concat(C,'" width="').concat(P,'" height="').concat(I,'"/>'))}_nt(xvt,this)&&(h.push("</g></svg>')"),c.backgroundImage=h.join("")),this.container.append(v),this.container.style.clipPath="url(#".concat(b,")")}}}_createPopup(){var{data:t}=this,e=Snt(Avt,this,new Bvt({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:"popup_".concat(t.id),rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){Hot("Abstract method `AnnotationElement.render` called")}_getElementsByName(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=[];if(this._fieldObjects){var n=this._fieldObjects[t];if(n)for(var{page:i,id:a,exportValues:s}of n)if(-1!==i&&a!==e){var o="string"==typeof s?s:null,l=document.querySelector('[data-element-id="'.concat(a,'"]'));!l||mvt.has(l)?r.push({id:a,exportValue:o,domElement:l}):Uot("_getElementsByName - element not allowed: ".concat(a))}return r}for(var h of document.getElementsByName(t)){var{exportValue:c}=h,u=h.getAttribute("data-element-id");u!==e&&(mvt.has(h)&&r.push({id:u,exportValue:c,domElement:h}))}return r}show(){var t;this.container&&(this.container.hidden=!1),null===(t=this.popup)||void 0===t||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),null===(t=this.popup)||void 0===t||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){var t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(var e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(this._isEditable){var{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{var r;null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}}function Svt(t){var{container:{style:e},data:{rect:r,rotation:n},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:s,pageY:o}}}}=this;null==r||r.splice(0,4,...t);var{width:l,height:h}=yvt(t);e.left="".concat(100*(t[0]-s)/i,"%"),e.top="".concat(100*(a-t[3]+o)/a,"%"),0===n?(e.width="".concat(100*l/i,"%"),e.height="".concat(100*h/a,"%")):this.setRotation(n)}var Evt=new WeakSet;class Mvt extends kvt{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(t,{isRenderable:!0,ignoreBorder:!(null==e||!e.ignoreBorder),createQuadrilaterals:!0}),Mnt(this,Evt),this.isTooltipOnly=t.data.isTooltipOnly}render(){var{data:t,linkService:e}=this,r=document.createElement("a");r.setAttribute("data-element-id",t.id);var n=!1;return t.url?(e.addLinkAttributes(r,t.url,t.newWindow),n=!0):t.action?(this._bindNamedAction(r,t.action),n=!0):t.attachment?(bnt(Evt,this,Cvt).call(this,r,t.attachment,t.attachmentDest),n=!0):t.setOCGState?(bnt(Evt,this,Pvt).call(this,r,t.setOCGState),n=!0):t.dest?(this._bindLink(r,t.dest),n=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(r,t),n=!0),t.resetForm?(this._bindResetFormAction(r,t.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(r,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(r),this.container}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&bnt(Evt,this,Tvt).call(this)}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),bnt(Evt,this,Tvt).call(this)}_bindJSAction(t,e){var r=this;t.href=this.linkService.getAnchorUrl("");var n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]),i=function(i){var a=n.get(i);if(!a)return 1;t[a]=()=>{var t;return null===(t=r.linkService.eventBus)||void 0===t||t.dispatch("dispatcheventinsandbox",{source:r,detail:{id:e.id,name:i}}),!1}};for(var a of Object.keys(e.actions))i(a);t.onclick||(t.onclick=()=>!1),bnt(Evt,this,Tvt).call(this)}_bindResetFormAction(t,e){var r=t.onclick;if(r||(t.href=this.linkService.getAnchorUrl("")),bnt(Evt,this,Tvt).call(this),!this._fieldObjects)return Uot('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(r||(t.onclick=()=>!1));t.onclick=()=>{null==r||r();var{fields:t,refs:n,include:i}=e,a=[];if(0!==t.length||0!==n.length){var s=new Set(n);for(var o of t){var l=this._fieldObjects[o]||[];for(var{id:h}of l)s.add(h)}for(var c of Object.values(this._fieldObjects))for(var u of c)s.has(u.id)===i&&a.push(u)}else for(var d of Object.values(this._fieldObjects))a.push(...d);var p,f=this.annotationStorage,g=[];for(var v of a){var{id:m}=v;switch(g.push(m),v.type){case"text":var y=v.defaultValue||"";f.setValue(m,{value:y});break;case"checkbox":case"radiobutton":var b=v.defaultValue===v.exportValues;f.setValue(m,{value:b});break;case"combobox":case"listbox":var w=v.defaultValue||"";f.setValue(m,{value:w});break;default:continue}var x=document.querySelector('[data-element-id="'.concat(m,'"]'));x&&(mvt.has(x)?x.dispatchEvent(new Event("resetform")):Uot("_bindResetFormAction - element not allowed: ".concat(m)))}this.enableScripting&&(null===(p=this.linkService.eventBus)||void 0===p||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:g,name:"ResetForm"}}));return!1}}}function Tvt(){this.container.setAttribute("data-internal-link","")}function Cvt(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>{var t;return null===(t=this.downloadManager)||void 0===t||t.openOrDownloadData(e.content,e.filename,r),!1},bnt(Evt,this,Tvt).call(this)}function Pvt(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),bnt(Evt,this,Tvt).call(this)}class Ivt extends kvt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");var t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Rvt extends kvt{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&("CANVAS"===(null===(e=t.previousSibling)||void 0===e?void 0:e.nodeName)&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ilt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,r,n,i){r.includes("mouse")?t.addEventListener(r,(t=>{var e;null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(r,(t=>{var a;if("blur"===r){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===r){if(e.focused)return;e.focused=!0}i&&(null===(a=this.linkService.eventBus)||void 0===a||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(t)}}))}))}_setEventListeners(t,e,r,n){for(var[i,a]of r){var s,o,l;if("Action"===a||null!==(s=this.data.actions)&&void 0!==s&&s[a])"Focus"!==a&&"Blur"!==a||e||(e={focused:!1}),this._setEventListener(t,e,i,a,n),"Focus"!==a||null!==(o=this.data.actions)&&void 0!==o&&o.Blur?"Blur"!==a||null!==(l=this.data.actions)&&void 0!==l&&l.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null)}}_setBackgroundColor(t){var e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":slt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){var e,{fontColor:r}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,i=t.style,a=t=>Math.round(10*t)/10;if(this.data.multiLine){var s=Math.abs(this.data.rect[3]-this.data.rect[1]-2),o=s/(Math.round(s/(Vst*n))||1);e=Math.min(n,a(o/Vst))}else{var l=Math.abs(this.data.rect[3]-this.data.rect[1]-2);e=Math.min(n,a(l/Vst))}i.fontSize="calc(".concat(e,"px * var(--scale-factor))"),i.color=slt.makeHexColor(r[0],r[1],r[2]),null!==this.data.textAlignment&&(i.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Ovt extends Rvt{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,r,n){var i=this.annotationStorage;for(var a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=r),i.setValue(a.id,{[n]:r})}render(){var t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");var r=null;if(this.renderForms){var n,i=t.getValue(e,{value:this.data.fieldValue}),a=i.value||"",s=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;s&&a.length>s&&(a=a.slice(0,s));var o=i.formattedValue||(null===(n=this.data.textContent)||void 0===n?void 0:n.join("\n"))||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,""));var l={userValue:a,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((r=document.createElement("textarea")).textContent=null!=o?o:a,this.data.doNotScroll&&(r.style.overflowY="hidden")):((r=document.createElement("input")).type="text",r.setAttribute("value",null!=o?o:a),this.data.doNotScroll&&(r.style.overflowX="hidden")),this.data.hasOwnCanvas&&(r.hidden=!0),mvt.add(r),r.setAttribute("data-element-id",e),r.disabled=this.data.readOnly,r.name=this.data.fieldName,r.tabIndex=vvt,this._setRequired(r,this.data.required),s&&(r.maxLength=s),r.addEventListener("input",(n=>{t.setValue(e,{value:n.target.value}),this.setPropertyOnSiblings(r,"value",n.target.value,"value"),l.formattedValue=null})),r.addEventListener("resetform",(t=>{var e,n=null!==(e=this.data.defaultFieldValue)&&void 0!==e?e:"";r.value=l.userValue=n,l.formattedValue=null}));var h=t=>{var{formattedValue:e}=l;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){var c;r.addEventListener("focus",(t=>{var e;if(!l.focused){var{target:r}=t;l.userValue&&(r.value=l.userValue),l.lastCommittedValue=r.value,l.commitKey=1,null!==(e=this.data.actions)&&void 0!==e&&e.Focus||(l.focused=!0)}})),r.addEventListener("updatefromsandbox",(r=>{this.showElementAndHideCanvas(r.target);var n={value(r){var n;l.userValue=null!==(n=r.detail.value)&&void 0!==n?n:"",t.setValue(e,{value:l.userValue.toString()}),r.target.value=l.userValue},formattedValue(r){var{formattedValue:n}=r.detail;l.formattedValue=n,null!=n&&r.target!==document.activeElement&&(r.target.value=n),t.setValue(e,{formattedValue:n})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:r=>{var n,{charLimit:i}=r.detail,{target:a}=r;if(0!==i){a.setAttribute("maxLength",i);var s=l.userValue;!s||s.length<=i||(s=s.slice(0,i),a.value=l.userValue=s,t.setValue(e,{value:s}),null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}else a.removeAttribute("maxLength")}};this._dispatchEventFromSandbox(n,r)})),r.addEventListener("keydown",(t=>{var r;l.commitKey=1;var n=-1;if("Escape"===t.key?n=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(l.commitKey=3):n=2,-1!==n){var{value:i}=t.target;l.lastCommittedValue!==i&&(l.lastCommittedValue=i,l.userValue=i,null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:n,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}}));var u=h;h=null,r.addEventListener("blur",(t=>{var r;if(l.focused&&t.relatedTarget){null!==(r=this.data.actions)&&void 0!==r&&r.Blur||(l.focused=!1);var n,{value:i}=t.target;if(l.userValue=i,l.lastCommittedValue!==i)null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:l.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}});u(t)}})),null!==(c=this.data.actions)&&void 0!==c&&c.Keystroke&&r.addEventListener("beforeinput",(t=>{var r;l.lastCommittedValue=null;var{data:n,target:i}=t,{value:a,selectionStart:s,selectionEnd:o}=i,h=s,c=o;switch(t.inputType){case"deleteWordBackward":var u=a.substring(0,s).match(/\w*[^\w]*$/);u&&(h-=u[0].length);break;case"deleteWordForward":var d=a.substring(s).match(/^[^\w]*\w*/);d&&(c+=d[0].length);break;case"deleteContentBackward":s===o&&(h-=1);break;case"deleteContentForward":s===o&&(c+=1)}t.preventDefault(),null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,change:n||"",willCommit:!1,selStart:h,selEnd:c}})})),this._setEventListeners(r,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(h&&r.addEventListener("blur",h),this.data.comb){var d=(this.data.rect[2]-this.data.rect[0])/s;r.classList.add("comb"),r.style.letterSpacing="calc(".concat(d,"px * var(--scale-factor) - 1ch)")}}else(r=document.createElement("div")).textContent=this.data.fieldValue,r.style.verticalAlign="middle",r.style.display="table-cell",this.data.hasOwnCanvas&&(r.hidden=!0);return this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class Lvt extends Rvt{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Dvt extends Rvt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){var t=this.annotationStorage,e=this.data,r=e.id,n=t.getValue(r,{value:e.exportValue===e.fieldValue}).value;"string"==typeof n&&(n="Off"!==n,t.setValue(r,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");var i=document.createElement("input");return mvt.add(i),i.setAttribute("data-element-id",r),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=e.fieldName,n&&i.setAttribute("checked",!0),i.setAttribute("exportValue",e.exportValue),i.tabIndex=vvt,i.addEventListener("change",(n=>{var{name:i,checked:a}=n.target;for(var s of this._getElementsByName(i,r)){var o=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=o),t.setValue(s.id,{value:o})}t.setValue(r,{value:a})})),i.addEventListener("resetform",(t=>{var r=e.defaultFieldValue||"Off";t.target.checked=r===e.exportValue})),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",(e=>{var n={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(r,{value:e.target.checked})}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Fvt extends Rvt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");var t=this.annotationStorage,e=this.data,r=e.id,n=t.getValue(r,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof n&&(n=n!==e.buttonValue,t.setValue(r,{value:n})),n)for(var i of this._getElementsByName(e.fieldName,r))t.setValue(i.id,{value:!1});var a=document.createElement("input");if(mvt.add(a),a.setAttribute("data-element-id",r),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,n&&a.setAttribute("checked",!0),a.tabIndex=vvt,a.addEventListener("change",(e=>{var{name:n,checked:i}=e.target;for(var a of this._getElementsByName(n,r))t.setValue(a.id,{value:!1});t.setValue(r,{value:i})})),a.addEventListener("resetform",(t=>{var r=e.defaultFieldValue;t.target.checked=null!=r&&r===e.buttonValue})),this.enableScripting&&this.hasJSActions){var s=e.buttonValue;a.addEventListener("updatefromsandbox",(e=>{var n={value:e=>{var n=s===e.detail.value;for(var i of this._getElementsByName(e.target.name)){var a=n&&i.id===r;i.domElement&&(i.domElement.checked=a),t.setValue(i.id,{value:a})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Nvt extends Mvt{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){var t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");var e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class jvt extends Rvt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");var t=this.annotationStorage,e=this.data.id,r=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");mvt.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=vvt;var i=this.data.combo&&this.data.options.length>0;for(var a of(this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",(t=>{var e=this.data.defaultFieldValue;for(var r of n.options)r.selected=r.value===e})),this.data.options)){var s=document.createElement("option");s.textContent=a.displayValue,s.value=a.exportValue,r.value.includes(a.exportValue)&&(s.setAttribute("selected",!0),i=!1),n.append(s)}var o=null;if(i){var l=document.createElement("option");l.value=" ",l.setAttribute("hidden",!0),l.setAttribute("selected",!0),n.prepend(l),o=()=>{l.remove(),n.removeEventListener("input",o),o=null},n.addEventListener("input",o)}var h=t=>{var e=t?"value":"textContent",{options:r,multiple:i}=n;return i?Array.prototype.filter.call(r,(t=>t.selected)).map((t=>t[e])):-1===r.selectedIndex?null:r[r.selectedIndex][e]},c=h(!1),u=t=>{var e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",(r=>{var i={value(r){var i;null===(i=o)||void 0===i||i();var a=r.detail.value,s=new Set(Array.isArray(a)?a:[a]);for(var l of n.options)l.selected=s.has(l.value);t.setValue(e,{value:h(!0)}),c=h(!1)},multipleSelection(t){n.multiple=!0},remove(r){var i=n.options,a=r.detail.remove;if(i[a].selected=!1,n.remove(a),i.length>0){var s=Array.prototype.findIndex.call(i,(t=>t.selected));-1===s&&(i[0].selected=!0)}t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},clear(r){for(;0!==n.length;)n.remove(0);t.setValue(e,{value:null,items:[]}),c=h(!1)},insert(r){var{index:i,displayValue:a,exportValue:s}=r.detail.insert,o=n.children[i],l=document.createElement("option");l.textContent=a,l.value=s,o?o.before(l):n.append(l),t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},items(r){for(var{items:i}=r.detail;0!==n.length;)n.remove(0);for(var a of i){var{displayValue:s,exportValue:o}=a,l=document.createElement("option");l.textContent=s,l.value=o,n.append(l)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},indices(r){var n=new Set(r.detail.indices);for(var i of r.target.options)i.selected=n.has(i.index);t.setValue(e,{value:h(!0)}),c=h(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(i,r)})),n.addEventListener("input",(r=>{var n,i=h(!0),a=h(!1);t.setValue(e,{value:i}),r.preventDefault(),null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:c,change:a,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):n.addEventListener("input",(function(r){t.setValue(e,{value:h(!0)})})),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Bvt extends kvt{constructor(t){var{data:e,elements:r}=t;super(t,{isRenderable:kvt._hasPopupData(e)}),this.elements=r,this.popup=null}render(){this.container.classList.add("popupAnnotation");var t=this.popup=new smt({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(var r of this.elements)r.popup=t,r.container.ariaHasPopup="dialog",e.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>"".concat(dlt).concat(t))).join(",")),this.container}}var zvt=new WeakMap,Wvt=new WeakMap,Uvt=new WeakMap,Hvt=new WeakMap,Gvt=new WeakMap,Yvt=new WeakMap,Vvt=new WeakMap,qvt=new WeakMap,Xvt=new WeakMap,$vt=new WeakMap,Kvt=new WeakMap,Qvt=new WeakMap,Jvt=new WeakMap,Zvt=new WeakMap,tmt=new WeakMap,emt=new WeakMap,rmt=new WeakMap,nmt=new WeakMap,imt=new WeakMap,amt=new WeakSet;class smt{constructor(t){var{container:e,color:r,elements:n,titleObj:i,modificationDate:a,contentsObj:s,richText:o,parent:l,rect:h,parentRect:c,open:u}=t;for(var d of(Mnt(this,amt),knt(this,zvt,bnt(amt,this,umt).bind(this)),knt(this,Wvt,bnt(amt,this,gmt).bind(this)),knt(this,Uvt,bnt(amt,this,fmt).bind(this)),knt(this,Hvt,bnt(amt,this,pmt).bind(this)),knt(this,Gvt,null),knt(this,Yvt,null),knt(this,Vvt,null),knt(this,qvt,null),knt(this,Xvt,null),knt(this,$vt,null),knt(this,Kvt,null),knt(this,Qvt,!1),knt(this,Jvt,null),knt(this,Zvt,null),knt(this,tmt,null),knt(this,emt,null),knt(this,rmt,null),knt(this,nmt,null),knt(this,imt,!1),Snt(Yvt,this,e),Snt(rmt,this,i),Snt(Vvt,this,s),Snt(emt,this,o),Snt($vt,this,l),Snt(Gvt,this,r),Snt(tmt,this,h),Snt(Kvt,this,c),Snt(Xvt,this,n),Snt(qvt,this,Mlt.toDateObject(a)),this.trigger=n.flatMap((t=>t.getElementsToTriggerPopup())),this.trigger))d.addEventListener("click",_nt(Hvt,this)),d.addEventListener("mouseenter",_nt(Uvt,this)),d.addEventListener("mouseleave",_nt(Wvt,this)),d.classList.add("popupTriggerArea");for(var p of n){var f;null===(f=p.container)||void 0===f||f.addEventListener("keydown",_nt(zvt,this))}_nt(Yvt,this).hidden=!0,u&&bnt(amt,this,pmt).call(this)}render(){if(!_nt(Jvt,this)){var t=Snt(Jvt,this,document.createElement("div"));if(t.className="popup",_nt(Gvt,this)){var e=t.style.outlineColor=slt.makeHexColor(..._nt(Gvt,this));if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor="color-mix(in srgb, ".concat(e," 30%, white)");else{t.style.backgroundColor=slt.makeHexColor(..._nt(Gvt,this).map((t=>Math.floor(.7*(255-t)+t))))}}var r=document.createElement("span");r.className="header";var n=document.createElement("h1");if(r.append(n),({dir:n.dir,str:n.textContent}=_nt(rmt,this)),t.append(r),_nt(qvt,this)){var i=document.createElement("span");i.classList.add("popupDate"),i.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),i.setAttribute("data-l10n-args",JSON.stringify({dateObj:_nt(qvt,this).valueOf()})),r.append(i)}var a=Ent(amt,this,omt);if(a)gvt.render({xfaHtml:a,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{var s=this._formatContents(_nt(Vvt,this));t.append(s)}_nt(Yvt,this).append(t)}}_formatContents(t){var{str:e,dir:r}=t,n=document.createElement("p");n.classList.add("popupContent"),n.dir=r;for(var i=e.split(/(?:\r\n?|\n)/),a=0,s=i.length;a<s;++a){var o=i[a];n.append(document.createTextNode(o)),a<s-1&&n.append(document.createElement("br"))}return n}updateEdited(t){var e,{rect:r,popupContent:n}=t;_nt(nmt,this)||Snt(nmt,this,{contentsObj:_nt(Vvt,this),richText:_nt(emt,this)}),r&&Snt(Zvt,this,null),n&&(Snt(emt,this,bnt(amt,this,cmt).call(this,n)),Snt(Vvt,this,null)),null===(e=_nt(Jvt,this))||void 0===e||e.remove(),Snt(Jvt,this,null)}resetEdited(){var t;_nt(nmt,this)&&(({contentsObj:Int(Snt,[Vvt,this])._,richText:Int(Snt,[emt,this])._}=_nt(nmt,this)),Snt(nmt,this,null),null===(t=_nt(Jvt,this))||void 0===t||t.remove(),Snt(Jvt,this,null),Snt(Zvt,this,null))}forceHide(){Snt(imt,this,this.isVisible),_nt(imt,this)&&(_nt(Yvt,this).hidden=!0)}maybeShow(){_nt(imt,this)&&(_nt(Jvt,this)||bnt(amt,this,fmt).call(this),Snt(imt,this,!1),_nt(Yvt,this).hidden=!1)}get isVisible(){return!1===_nt(Yvt,this).hidden}}function omt(t){var e=_nt(emt,t),r=_nt(Vvt,t);return null==e||!e.str||null!=r&&r.str&&r.str!==e.str?null:_nt(emt,t).html||null}function lmt(t){var e;return(null===(e=Ent(amt,t,omt))||void 0===e||null===(e=e.attributes)||void 0===e||null===(e=e.style)||void 0===e?void 0:e.fontSize)||0}function hmt(t){var e;return(null===(e=Ent(amt,t,omt))||void 0===e||null===(e=e.attributes)||void 0===e||null===(e=e.style)||void 0===e?void 0:e.color)||null}function cmt(t){var e=[],r={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:Ent(amt,this,hmt),fontSize:Ent(amt,this,lmt)?"calc(".concat(Ent(amt,this,lmt),"px * var(--scale-factor))"):""}};for(var i of t.split("\n"))e.push({name:"span",value:i,attributes:n});return r}function umt(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&_nt(Qvt,this))&&bnt(amt,this,pmt).call(this)}function dmt(){if(null===_nt(Zvt,this)){var{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:r,pageX:n,pageY:i}}}=_nt($vt,this),a=!!_nt(Kvt,this),s=_nt(a?Kvt:tmt,this);for(var o of _nt(Xvt,this))if(!s||null!==slt.intersect(o.data.rect,s)){s=o.data.rect,a=!0;break}var l=slt.normalizeRect([s[0],t[3]-s[1]+t[1],s[2],t[3]-s[3]+t[1]]),h=a?s[2]-s[0]+5:0,c=l[0]+h,u=l[1];Snt(Zvt,this,[100*(c-n)/e,100*(u-i)/r]);var{style:d}=_nt(Yvt,this);d.left="".concat(_nt(Zvt,this)[0],"%"),d.top="".concat(_nt(Zvt,this)[1],"%")}}function pmt(){Snt(Qvt,this,!_nt(Qvt,this)),_nt(Qvt,this)?(bnt(amt,this,fmt).call(this),_nt(Yvt,this).addEventListener("click",_nt(Hvt,this)),_nt(Yvt,this).addEventListener("keydown",_nt(zvt,this))):(bnt(amt,this,gmt).call(this),_nt(Yvt,this).removeEventListener("click",_nt(Hvt,this)),_nt(Yvt,this).removeEventListener("keydown",_nt(zvt,this)))}function fmt(){_nt(Jvt,this)||this.render(),this.isVisible?_nt(Qvt,this)&&_nt(Yvt,this).classList.add("focused"):(bnt(amt,this,dmt).call(this),_nt(Yvt,this).hidden=!1,_nt(Yvt,this).style.zIndex=parseInt(_nt(Yvt,this).style.zIndex)+1e3)}function gmt(){_nt(Yvt,this).classList.remove("focused"),!_nt(Qvt,this)&&this.isVisible&&(_nt(Yvt,this).hidden=!0,_nt(Yvt,this).style.zIndex=parseInt(_nt(Yvt,this).style.zIndex)-1e3)}class vmt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=rot.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){var t=document.createElement("div");for(var e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){var r=document.createElement("span");r.textContent=e,t.append(r)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var mmt=new WeakMap;class ymt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),knt(this,mmt,null)}render(){this.container.classList.add("lineAnnotation");var t=this.data,{width:e,height:r}=yvt(t.rect),n=this.svgFactory.create(e,r,!0),i=Snt(mmt,this,this.svgFactory.createElement("svg:line"));return i.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),i.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),i.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),i.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),i.setAttribute("stroke-width",t.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),n.append(i),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _nt(mmt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var bmt=new WeakMap;class wmt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),knt(this,bmt,null)}render(){this.container.classList.add("squareAnnotation");var t=this.data,{width:e,height:r}=yvt(t.rect),n=this.svgFactory.create(e,r,!0),i=t.borderStyle.width,a=Snt(bmt,this,this.svgFactory.createElement("svg:rect"));return a.setAttribute("x",i/2),a.setAttribute("y",i/2),a.setAttribute("width",e-i),a.setAttribute("height",r-i),a.setAttribute("stroke-width",i||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _nt(bmt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var xmt=new WeakMap;class Amt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),knt(this,xmt,null)}render(){this.container.classList.add("circleAnnotation");var t=this.data,{width:e,height:r}=yvt(t.rect),n=this.svgFactory.create(e,r,!0),i=t.borderStyle.width,a=Snt(xmt,this,this.svgFactory.createElement("svg:ellipse"));return a.setAttribute("cx",e/2),a.setAttribute("cy",r/2),a.setAttribute("rx",e/2-i/2),a.setAttribute("ry",r/2-i/2),a.setAttribute("stroke-width",i||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _nt(xmt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var _mt=new WeakMap;class kmt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),knt(this,_mt,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);var{data:{rect:t,vertices:e,borderStyle:r,popupRef:n}}=this;if(!e)return this.container;for(var{width:i,height:a}=yvt(t),s=this.svgFactory.create(i,a,!0),o=[],l=0,h=e.length;l<h;l+=2){var c=e[l]-t[0],u=t[3]-e[l+1];o.push("".concat(c,",").concat(u))}o=o.join(" ");var d=Snt(_mt,this,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",o),d.setAttribute("stroke-width",r.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),s.append(d),this.container.append(s),!n&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _nt(_mt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}class Smt extends kmt{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Emt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var Mmt=new WeakMap,Tmt=new WeakMap,Cmt=new WeakSet;class Pmt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Mnt(this,Cmt),knt(this,Mmt,null),knt(this,Tmt,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?rot.HIGHLIGHT:rot.INK}render(){this.container.classList.add(this.containerClassName);var{data:{rect:t,rotation:e,inkLists:r,borderStyle:n,popupRef:i}}=this,{transform:a,width:s,height:o}=bnt(Cmt,this,Imt).call(this,e,t),l=this.svgFactory.create(s,o,!0),h=Snt(Mmt,this,this.svgFactory.createElement("svg:g"));l.append(h),h.setAttribute("stroke-width",n.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",a);for(var c=0,u=r.length;c<u;c++){var d=this.svgFactory.createElement(this.svgElementName);_nt(Tmt,this).push(d),d.setAttribute("points",r[c].join(",")),h.append(d)}return!i&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);var{thickness:e,points:r,rect:n}=t,i=_nt(Mmt,this);if(e>=0&&i.setAttribute("stroke-width",e||1),r)for(var a=0,s=_nt(Tmt,this).length;a<s;a++)_nt(Tmt,this)[a].setAttribute("points",r[a].join(","));if(n){var{transform:o,width:l,height:h}=bnt(Cmt,this,Imt).call(this,this.data.rotation,n);i.parentElement.setAttribute("viewBox","0 0 ".concat(l," ").concat(h)),i.setAttribute("transform",o)}}getElementsToTriggerPopup(){return _nt(Tmt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function Imt(t,e){switch(t){case 90:return{transform:"rotate(90) translate(".concat(-e[0],",").concat(e[1],") scale(1,-1)"),width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:"rotate(180) translate(".concat(-e[2],",").concat(e[1],") scale(1,-1)"),width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:"rotate(270) translate(".concat(-e[2],",").concat(e[3],") scale(1,-1)"),width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:"translate(".concat(-e[0],",").concat(e[3],") scale(1,-1)"),width:e[2]-e[0],height:e[3]-e[1]}}}class Rmt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=rot.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Omt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class Lmt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Dmt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Fmt extends kvt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=rot.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var Nmt=new WeakMap,jmt=new WeakSet;class Bmt extends kvt{constructor(t){var e;super(t,{isRenderable:!0}),Mnt(this,jmt),knt(this,Nmt,null);var{file:r}=this.data;this.filename=r.filename,this.content=r.content,null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("fileattachmentannotation",Pnt({source:this},r))}render(){this.container.classList.add("fileAttachmentAnnotation");var t,{container:e,data:r}=this;r.hasAppearance||0===r.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src="".concat(this.imageResourcesPath,"annotation-").concat(/paperclip/i.test(r.name)?"paperclip":"pushpin",".svg"),r.fillAlpha&&r.fillAlpha<1&&(t.style="filter: opacity(".concat(Math.round(100*r.fillAlpha),"%);"))),t.addEventListener("dblclick",bnt(jmt,this,zmt).bind(this)),Snt(Nmt,this,t);var{isMac:n}=ilt.platform;return e.addEventListener("keydown",(t=>{"Enter"===t.key&&(n?t.metaKey:t.ctrlKey)&&bnt(jmt,this,zmt).call(this)})),!r.popupRef&&this.hasPopupData?this._createPopup():t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return _nt(Nmt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function zmt(){var t;null===(t=this.downloadManager)||void 0===t||t.openOrDownloadData(this.content,this.filename)}var Wmt=new WeakMap,Umt=new WeakMap,Hmt=new WeakMap,Gmt=new WeakMap,Ymt=new WeakSet;class Vmt{constructor(t){var{div:e,accessibilityManager:r,annotationCanvasMap:n,annotationEditorUIManager:i,page:a,viewport:s,structTreeLayer:o}=t;Mnt(this,Ymt),knt(this,Wmt,null),knt(this,Umt,null),knt(this,Hmt,new Map),knt(this,Gmt,null),this.div=e,Snt(Wmt,this,r),Snt(Umt,this,n),Snt(Gmt,this,o||null),this.page=a,this.viewport=s,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return _nt(Hmt,this).size>0}render(t){var e=this;return xnt((function*(){var{annotations:r}=t,n=e.div;Olt(n,e.viewport);var i=new Map,a={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new fvt,annotationStorage:t.annotationStorage||new gdt,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:e,elements:null};for(var s of r)if(!s.noHTML){var o=s.annotationType===Mot;if(o){var l=i.get(s.id);if(!l)continue;a.elements=l}else{var{width:h,height:c}=yvt(s.rect);if(h<=0||c<=0)continue}a.data=s;var u=bvt.create(a);if(u.isRenderable){if(!o&&s.popupRef){var d=i.get(s.popupRef);d?d.push(u):i.set(s.popupRef,[u])}var p,f=u.render();if(s.hidden&&(f.style.visibility="hidden"),yield bnt(Ymt,e,qmt).call(e,f,s.id),u._isEditable)_nt(Hmt,e).set(u.data.id,u),null===(p=e._annotationEditorUIManager)||void 0===p||p.renderAnnotationElement(u)}}bnt(Ymt,e,$mt).call(e)}))()}update(t){var{viewport:e}=t,r=this.div;this.viewport=e,Olt(r,{rotation:e.rotation}),bnt(Ymt,this,$mt).call(this),r.hidden=!1}getEditableAnnotations(){return Array.from(_nt(Hmt,this).values())}getEditableAnnotation(t){return _nt(Hmt,this).get(t)}}function qmt(t,e){return Xmt.apply(this,arguments)}function Xmt(){return Xmt=xnt((function*(t,e){var r,n,i=t.firstChild||t,a=i.id="".concat(dlt).concat(e),s=yield null===(r=_nt(Gmt,this))||void 0===r?void 0:r.getAriaAttributes(a);if(s)for(var[o,l]of s)i.setAttribute(o,l);this.div.append(t),null===(n=_nt(Wmt,this))||void 0===n||n.moveElementInDOM(this.div,t,i,!1)})),Xmt.apply(this,arguments)}function $mt(){if(_nt(Umt,this)){var t=this.div;for(var[e,r]of _nt(Umt,this)){var n=t.querySelector('[data-annotation-id="'.concat(e,'"]'));if(n){r.className="annotationContent";var{firstChild:i}=n;i?"CANVAS"===i.nodeName?i.replaceWith(r):i.classList.contains("annotationContent")?i.after(r):i.before(r):n.append(r)}}_nt(Umt,this).clear()}}var Kmt=/\r\n?|\n/g,Qmt=new WeakMap,Jmt=new WeakMap,Zmt=new WeakMap,tyt=new WeakMap,eyt=new WeakMap,ryt=new WeakSet;class nyt extends But{static get _keyboardManager(){var t=nyt.prototype,e=t=>t.isEmpty(),r=uct.TRANSLATE_SMALL,n=uct.TRANSLATE_BIG;return Vot(this,"_keyboardManager",new bht([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[r,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,r],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}]]))}constructor(t){super(Pnt(Pnt({},t),{},{name:"freeTextEditor"})),Mnt(this,ryt),knt(this,Qmt,void 0),knt(this,Jmt,""),knt(this,Zmt,"".concat(this.id,"-editor")),knt(this,tyt,null),knt(this,eyt,void 0),Snt(Qmt,this,t.color||nyt._defaultColor||But._defaultLineColor),Snt(eyt,this,t.fontSize||nyt._defaultFontSize)}static initialize(t,e){But.initialize(t,e);var r=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(r.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case not.FREETEXT_SIZE:nyt._defaultFontSize=e;break;case not.FREETEXT_COLOR:nyt._defaultColor=e}}updateParams(t,e){switch(t){case not.FREETEXT_SIZE:bnt(ryt,this,iyt).call(this,e);break;case not.FREETEXT_COLOR:bnt(ryt,this,ayt).call(this,e)}}static get defaultPropertiesToUpdate(){return[[not.FREETEXT_SIZE,nyt._defaultFontSize],[not.FREETEXT_COLOR,nyt._defaultColor||But._defaultLineColor]]}get propertiesToUpdate(){return[[not.FREETEXT_SIZE,_nt(eyt,this)],[not.FREETEXT_COLOR,_nt(Qmt,this)]]}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){var t=this.parentScale;return[-nyt._internalPadding*t,-(nyt._internalPadding+_nt(eyt,this))*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!this.isInEditMode()){this.parent.setEditingState(!1),this.parent.updateToolbar(rot.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),Snt(tyt,this,new AbortController);var t=this._uiManager.combinedSignal(_nt(tyt,this));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}}disableEditMode(){var t;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",_nt(Zmt,this)),this._isDraggable=!0,null===(t=_nt(tyt,this))||void 0===t||t.abort(),Snt(tyt,this,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){var e;this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),null!==(e=this._initialOptions)&&void 0!==e&&e.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(this.isInEditMode()){super.commit(),this.disableEditMode();var t=_nt(Jmt,this),e=Snt(Jmt,this,bnt(ryt,this,syt).call(this).trimEnd());if(t!==e){var r=t=>{Snt(Jmt,this,t),t?(bnt(ryt,this,hyt).call(this),this._uiManager.rebuild(this),bnt(ryt,this,oyt).call(this)):this.remove()};this.addCommands({cmd:()=>{r(e)},undo:()=>{r(t)},mustExec:!1}),bnt(ryt,this,oyt).call(this)}}}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){nyt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;var t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",_nt(Zmt,this)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;var{style:r}=this.editorDiv;if(r.fontSize="calc(".concat(_nt(eyt,this),"px * var(--scale-factor))"),r.color=_nt(Qmt,this),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),nht(this,this.div,["dblclick","keydown"]),this.width){var[n,i]=this.parentDimensions;if(this.annotationElementId){var{position:a}=this._initialData,[s,o]=this.getInitialTranslation();[s,o]=this.pageTranslationToScreen(s,o);var l,h,[c,u]=this.pageDimensions,[d,p]=this.pageTranslation;switch(this.rotation){case 0:l=t+(a[0]-d)/c,h=e+this.height-(a[1]-p)/u;break;case 90:l=t+(a[0]-d)/c,h=e-(a[1]-p)/u,[s,o]=[o,-s];break;case 180:l=t-this.width+(a[0]-d)/c,h=e-(a[1]-p)/u,[s,o]=[-s,-o];break;case 270:l=t+(a[0]-d-this.height*u)/c,h=e+(a[1]-p-this.width*c)/u,[s,o]=[-o,s]}this.setAt(l*n,h*i,s,o)}else this.setAt(t*n,e*i,this.width*n,this.height*i);bnt(ryt,this,hyt).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){var e=t.clipboardData||window.clipboardData,{types:r}=e;if(1!==r.length||"text/plain"!==r[0]){t.preventDefault();var n=uyt.call(nyt,e.getData("text")||"").replaceAll(Kmt,"\n");if(n){var i=window.getSelection();if(i.rangeCount){this.editorDiv.normalize(),i.deleteFromDocument();var a=i.getRangeAt(0);if(!n.includes("\n"))return a.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),void i.collapseToStart();var{startContainer:s,startOffset:o}=a,l=[],h=[];if(s.nodeType===Node.TEXT_NODE){var c=s.parentElement;if(h.push(s.nodeValue.slice(o).replaceAll(Kmt,"")),c!==this.editorDiv){var u=l;for(var d of this.editorDiv.childNodes)d!==c?u.push(lyt.call(nyt,d)):u=h}l.push(s.nodeValue.slice(0,o).replaceAll(Kmt,""))}else if(s===this.editorDiv){var p=l,f=0;for(var g of this.editorDiv.childNodes)f++===o&&(p=h),p.push(lyt.call(nyt,g))}Snt(Jmt,this,"".concat(l.join("\n")).concat(n).concat(h.join("\n"))),bnt(ryt,this,hyt).call(this);var v=new Range,m=l.reduce(((t,e)=>t+e.length),0);for(var{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){var b=y.nodeValue.length;if(m<=b){v.setStart(y,m),v.setEnd(y,m);break}m-=b}i.removeAllRanges(),i.addRange(v)}}}}get contentDiv(){return this.editorDiv}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return xnt((function*(){var a=null;if(t instanceof vmt){var{data:{defaultAppearanceData:{fontSize:s,fontColor:o},rect:l,rotation:h,id:c,popupRef:u},textContent:d,textPosition:p,parent:{page:{pageNumber:f}}}=t;if(!d||0===d.length)return null;a=t={annotationType:rot.FREETEXT,color:Array.from(o),fontSize:s,value:d.join("\n"),position:p,pageIndex:f-1,rect:l.slice(0),rotation:h,id:c,deleted:!1,popupRef:u}}var g=yield n().call(i,t,e,r);return Snt(eyt,g,t.fontSize),Snt(Qmt,g,slt.makeHexColor(...t.color)),Snt(Jmt,g,uyt.call(nyt,t.value)),g.annotationElementId=t.id||null,g._initialData=a,g}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var e=nyt._internalPadding*this.parentScale,r=this.getRect(e,e),n=But._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:_nt(Qmt,this)),i={annotationType:rot.FREETEXT,color:n,fontSize:_nt(eyt,this),value:bnt(ryt,this,cyt).call(this),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?i:this.annotationElementId&&!bnt(ryt,this,dyt).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){var e=super.renderAnnotationElement(t);if(this.deleted)return e;var{style:r}=e;for(var n of(r.fontSize="calc(".concat(_nt(eyt,this),"px * var(--scale-factor))"),r.color=_nt(Qmt,this),e.replaceChildren(),_nt(Jmt,this).split("\n"))){var i=document.createElement("div");i.append(n?document.createTextNode(n):document.createElement("br")),e.append(i)}var a=nyt._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(a,a),popupContent:_nt(Jmt,this)}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}function iyt(t){var e=t=>{this.editorDiv.style.fontSize="calc(".concat(t,"px * var(--scale-factor))"),this.translate(0,-(t-_nt(eyt,this))*this.parentScale),Snt(eyt,this,t),bnt(ryt,this,oyt).call(this)},r=_nt(eyt,this);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:not.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}function ayt(t){var e=t=>{Snt(Qmt,this,this.editorDiv.style.color=t)},r=_nt(Qmt,this);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:not.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}function syt(){var t=[];this.editorDiv.normalize();var e=null;for(var r of this.editorDiv.childNodes){var n;(null===(n=e)||void 0===n?void 0:n.nodeType)===Node.TEXT_NODE&&"BR"===r.nodeName||(t.push(lyt.call(Ost,r)),e=r)}return t.join("\n")}function oyt(){var t,[e,r]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{var{currentLayer:n,div:i}=this,a=i.style.display,s=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",n.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=a,i.classList.toggle("hidden",s)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/r):(this.width=t.height/e,this.height=t.width/r),this.fixAndSetPosition()}function lyt(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Kmt,"")}function hyt(){if(this.editorDiv.replaceChildren(),_nt(Jmt,this))for(var t of _nt(Jmt,this).split("\n")){var e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}function cyt(){return _nt(Jmt,this).replaceAll(" "," ")}function uyt(t){return t.replaceAll(" "," ")}function dyt(t){var{value:e,fontSize:r,color:n,pageIndex:i}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==r||t.color.some(((t,e)=>t!==n[e]))||t.pageIndex!==i}Ost=nyt,Tnt(nyt,"_freeTextDefaultContent",""),Tnt(nyt,"_internalPadding",0),Tnt(nyt,"_defaultColor",null),Tnt(nyt,"_defaultFontSize",10),Tnt(nyt,"_type","freetext"),Tnt(nyt,"_editorType",rot.FREETEXT);class pyt{toSVGPath(){Hot("Abstract method `toSVGPath` must be implemented.")}get box(){Hot("Abstract getter `box` must be implemented.")}serialize(t,e){Hot("Abstract method `serialize` must be implemented.")}static _rescale(t,e,r,n,i,a){a||(a=new Float32Array(t.length));for(var s=0,o=t.length;s<o;s+=2)a[s]=e+t[s]*n,a[s+1]=r+t[s+1]*i;return a}static _rescaleAndSwap(t,e,r,n,i,a){a||(a=new Float32Array(t.length));for(var s=0,o=t.length;s<o;s+=2)a[s]=e+t[s+1]*n,a[s+1]=r+t[s]*i;return a}static _translate(t,e,r,n){n||(n=new Float32Array(t.length));for(var i=0,a=t.length;i<a;i+=2)n[i]=e+t[i],n[i+1]=r+t[i+1];return n}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,r,n,i){switch(i){case 90:return[1-e/r,t/n];case 180:return[1-t/r,1-e/n];case 270:return[e/r,1-t/n];default:return[t/r,e/n]}}static _normalizePagePoint(t,e,r){switch(r){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,r,n,i,a){return[(t+5*r)/6,(e+5*n)/6,(5*r+i)/6,(5*n+a)/6,(r+i)/2,(n+a)/2]}}Tnt(pyt,"PRECISION",1e-4);var fyt=new WeakMap,gyt=new WeakMap,vyt=new WeakMap,myt=new WeakMap,yyt=new WeakMap,byt=new WeakMap,wyt=new WeakMap,xyt=new WeakMap,Ayt=new WeakMap,_yt=new WeakMap,kyt=new WeakMap,Syt=new WeakMap,Eyt=new WeakMap,Myt=new WeakSet;class Tyt{constructor(t,e,r,n,i){var{x:a,y:s}=t,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;Mnt(this,Myt),knt(this,fyt,void 0),knt(this,gyt,[]),knt(this,vyt,void 0),knt(this,myt,void 0),knt(this,yyt,[]),knt(this,byt,new Float32Array(18)),knt(this,wyt,void 0),knt(this,xyt,void 0),knt(this,Ayt,void 0),knt(this,_yt,void 0),knt(this,kyt,void 0),knt(this,Syt,void 0),knt(this,Eyt,[]),Snt(fyt,this,e),Snt(Syt,this,n*r),Snt(myt,this,i),_nt(byt,this).set([NaN,NaN,NaN,NaN,a,s],6),Snt(vyt,this,o),Snt(_yt,this,Fyt._*r),Snt(Ayt,this,Nyt._*r),Snt(kyt,this,r),_nt(Eyt,this).push(a,s)}isEmpty(){return isNaN(_nt(byt,this)[8])}add(t){var e,{x:r,y:n}=t;Snt(wyt,this,r),Snt(xyt,this,n);var[i,a,s,o]=_nt(fyt,this),[l,h,c,u]=_nt(byt,this).subarray(8,12),d=r-c,p=n-u,f=Math.hypot(d,p);if(f<_nt(Ayt,this))return!1;var g=f-_nt(_yt,this),v=g/f,m=v*d,y=v*p,b=l,w=h;l=c,h=u,c+=m,u+=y,null===(e=_nt(Eyt,this))||void 0===e||e.push(r,n);var x=m/g,A=-y/g*_nt(Syt,this),_=x*_nt(Syt,this);return _nt(byt,this).set(_nt(byt,this).subarray(2,8),0),_nt(byt,this).set([c+A,u+_],4),_nt(byt,this).set(_nt(byt,this).subarray(14,18),12),_nt(byt,this).set([c-A,u-_],16),isNaN(_nt(byt,this)[6])?(0===_nt(yyt,this).length&&(_nt(byt,this).set([l+A,h+_],2),_nt(yyt,this).push(NaN,NaN,NaN,NaN,(l+A-i)/s,(h+_-a)/o),_nt(byt,this).set([l-A,h-_],14),_nt(gyt,this).push(NaN,NaN,NaN,NaN,(l-A-i)/s,(h-_-a)/o)),_nt(byt,this).set([b,w,l,h,c,u],6),!this.isEmpty()):(_nt(byt,this).set([b,w,l,h,c,u],6),Math.abs(Math.atan2(w-h,b-l)-Math.atan2(y,m))<Math.PI/2?([l,h,c,u]=_nt(byt,this).subarray(2,6),_nt(yyt,this).push(NaN,NaN,NaN,NaN,((l+c)/2-i)/s,((h+u)/2-a)/o),[l,h,b,w]=_nt(byt,this).subarray(14,18),_nt(gyt,this).push(NaN,NaN,NaN,NaN,((b+l)/2-i)/s,((w+h)/2-a)/o),!0):([b,w,l,h,c,u]=_nt(byt,this).subarray(0,6),_nt(yyt,this).push(((b+5*l)/6-i)/s,((w+5*h)/6-a)/o,((5*l+c)/6-i)/s,((5*h+u)/6-a)/o,((l+c)/2-i)/s,((h+u)/2-a)/o),[c,u,l,h,b,w]=_nt(byt,this).subarray(12,18),_nt(gyt,this).push(((b+5*l)/6-i)/s,((w+5*h)/6-a)/o,((5*l+c)/6-i)/s,((5*h+u)/6-a)/o,((l+c)/2-i)/s,((h+u)/2-a)/o),!0))}toSVGPath(){if(this.isEmpty())return"";var t=_nt(yyt,this),e=_nt(gyt,this);if(isNaN(_nt(byt,this)[6])&&!this.isEmpty())return bnt(Myt,this,Pyt).call(this);var r=[];r.push("M".concat(t[4]," ").concat(t[5]));for(var n=6;n<t.length;n+=6)isNaN(t[n])?r.push("L".concat(t[n+4]," ").concat(t[n+5])):r.push("C".concat(t[n]," ").concat(t[n+1]," ").concat(t[n+2]," ").concat(t[n+3]," ").concat(t[n+4]," ").concat(t[n+5]));bnt(Myt,this,Ryt).call(this,r);for(var i=e.length-6;i>=6;i-=6)isNaN(e[i])?r.push("L".concat(e[i+4]," ").concat(e[i+5])):r.push("C".concat(e[i]," ").concat(e[i+1]," ").concat(e[i+2]," ").concat(e[i+3]," ").concat(e[i+4]," ").concat(e[i+5]));return bnt(Myt,this,Iyt).call(this,r),r.join(" ")}newFreeDrawOutline(t,e,r,n,i,a){return new Vyt(t,e,r,n,i,a)}getOutlines(){for(var t,e,r=_nt(yyt,this),n=_nt(gyt,this),i=_nt(byt,this),[a,s,o,l]=_nt(fyt,this),h=new Float32Array((null!==(t=null===(e=_nt(Eyt,this))||void 0===e?void 0:e.length)&&void 0!==t?t:0)+2),c=0,u=h.length-2;c<u;c+=2)h[c]=(_nt(Eyt,this)[c]-a)/o,h[c+1]=(_nt(Eyt,this)[c+1]-s)/l;if(h[h.length-2]=(_nt(wyt,this)-a)/o,h[h.length-1]=(_nt(xyt,this)-s)/l,isNaN(i[6])&&!this.isEmpty())return bnt(Myt,this,Oyt).call(this,h);for(var d=new Float32Array(_nt(yyt,this).length+24+_nt(gyt,this).length),p=r.length,f=0;f<p;f+=2)isNaN(r[f])?d[f]=d[f+1]=NaN:(d[f]=r[f],d[f+1]=r[f+1]);p=bnt(Myt,this,Dyt).call(this,d,p);for(var g=n.length-6;g>=6;g-=6)for(var v=0;v<6;v+=2)isNaN(n[g+v])?(d[p]=d[p+1]=NaN,p+=2):(d[p]=n[g+v],d[p+1]=n[g+v+1],p+=2);return bnt(Myt,this,Lyt).call(this,d,p),this.newFreeDrawOutline(d,h,_nt(fyt,this),_nt(kyt,this),_nt(vyt,this),_nt(myt,this))}}function Cyt(){var t=_nt(byt,this).subarray(4,6),e=_nt(byt,this).subarray(16,18),[r,n,i,a]=_nt(fyt,this);return[(_nt(wyt,this)+(t[0]-e[0])/2-r)/i,(_nt(xyt,this)+(t[1]-e[1])/2-n)/a,(_nt(wyt,this)+(e[0]-t[0])/2-r)/i,(_nt(xyt,this)+(e[1]-t[1])/2-n)/a]}function Pyt(){var[t,e,r,n]=_nt(fyt,this),[i,a,s,o]=bnt(Myt,this,Cyt).call(this);return"M".concat((_nt(byt,this)[2]-t)/r," ").concat((_nt(byt,this)[3]-e)/n," L").concat((_nt(byt,this)[4]-t)/r," ").concat((_nt(byt,this)[5]-e)/n," L").concat(i," ").concat(a," L").concat(s," ").concat(o," L").concat((_nt(byt,this)[16]-t)/r," ").concat((_nt(byt,this)[17]-e)/n," L").concat((_nt(byt,this)[14]-t)/r," ").concat((_nt(byt,this)[15]-e)/n," Z")}function Iyt(t){var e=_nt(gyt,this);t.push("L".concat(e[4]," ").concat(e[5]," Z"))}function Ryt(t){var[e,r,n,i]=_nt(fyt,this),a=_nt(byt,this).subarray(4,6),s=_nt(byt,this).subarray(16,18),[o,l,h,c]=bnt(Myt,this,Cyt).call(this);t.push("L".concat((a[0]-e)/n," ").concat((a[1]-r)/i," L").concat(o," ").concat(l," L").concat(h," ").concat(c," L").concat((s[0]-e)/n," ").concat((s[1]-r)/i))}function Oyt(t){var e=_nt(byt,this),[r,n,i,a]=_nt(fyt,this),[s,o,l,h]=bnt(Myt,this,Cyt).call(this),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-r)/i,(e[3]-n)/a,NaN,NaN,NaN,NaN,(e[4]-r)/i,(e[5]-n)/a,NaN,NaN,NaN,NaN,s,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-r)/i,(e[17]-n)/a,NaN,NaN,NaN,NaN,(e[14]-r)/i,(e[15]-n)/a],0),this.newFreeDrawOutline(c,t,_nt(fyt,this),_nt(kyt,this),_nt(vyt,this),_nt(myt,this))}function Lyt(t,e){var r=_nt(gyt,this);return t.set([NaN,NaN,NaN,NaN,r[4],r[5]],e),e+6}function Dyt(t,e){var r=_nt(byt,this).subarray(4,6),n=_nt(byt,this).subarray(16,18),[i,a,s,o]=_nt(fyt,this),[l,h,c,u]=bnt(Myt,this,Cyt).call(this);return t.set([NaN,NaN,NaN,NaN,(r[0]-i)/s,(r[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,(n[0]-i)/s,(n[1]-a)/o],e),e+24}var Fyt={_:8},Nyt={_:Fyt._+2},jyt=new WeakMap,Byt=new WeakMap,zyt=new WeakMap,Wyt=new WeakMap,Uyt=new WeakMap,Hyt=new WeakMap,Gyt=new WeakMap,Yyt=new WeakSet;class Vyt extends pyt{constructor(t,e,r,n,i,a){super(),Mnt(this,Yyt),knt(this,jyt,void 0),knt(this,Byt,new Float32Array(4)),knt(this,zyt,void 0),knt(this,Wyt,void 0),knt(this,Uyt,void 0),knt(this,Hyt,void 0),knt(this,Gyt,void 0),Snt(Gyt,this,t),Snt(Uyt,this,e),Snt(jyt,this,r),Snt(Hyt,this,n),Snt(zyt,this,i),Snt(Wyt,this,a),this.lastPoint=[NaN,NaN],bnt(Yyt,this,qyt).call(this,a);for(var[s,o,l,h]=_nt(Byt,this),c=0,u=t.length;c<u;c+=2)t[c]=(t[c]-s)/l,t[c+1]=(t[c+1]-o)/h;for(var d=0,p=e.length;d<p;d+=2)e[d]=(e[d]-s)/l,e[d+1]=(e[d+1]-o)/h}toSVGPath(){for(var t=["M".concat(_nt(Gyt,this)[4]," ").concat(_nt(Gyt,this)[5])],e=6,r=_nt(Gyt,this).length;e<r;e+=6)isNaN(_nt(Gyt,this)[e])?t.push("L".concat(_nt(Gyt,this)[e+4]," ").concat(_nt(Gyt,this)[e+5])):t.push("C".concat(_nt(Gyt,this)[e]," ").concat(_nt(Gyt,this)[e+1]," ").concat(_nt(Gyt,this)[e+2]," ").concat(_nt(Gyt,this)[e+3]," ").concat(_nt(Gyt,this)[e+4]," ").concat(_nt(Gyt,this)[e+5]));return t.push("Z"),t.join(" ")}serialize(t,e){var r,n,[i,a,s,o]=t,l=s-i,h=o-a;switch(e){case 0:r=pyt._rescale(_nt(Gyt,this),i,o,l,-h),n=pyt._rescale(_nt(Uyt,this),i,o,l,-h);break;case 90:r=pyt._rescaleAndSwap(_nt(Gyt,this),i,a,l,h),n=pyt._rescaleAndSwap(_nt(Uyt,this),i,a,l,h);break;case 180:r=pyt._rescale(_nt(Gyt,this),s,a,-l,h),n=pyt._rescale(_nt(Uyt,this),s,a,-l,h);break;case 270:r=pyt._rescaleAndSwap(_nt(Gyt,this),s,o,-l,-h),n=pyt._rescaleAndSwap(_nt(Uyt,this),s,o,-l,-h)}return{outline:Array.from(r),points:[Array.from(n)]}}get box(){return _nt(Byt,this)}newOutliner(t,e,r,n,i){return new Tyt(t,e,r,n,i,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}getNewOutline(t,e){for(var[r,n,i,a]=_nt(Byt,this),[s,o,l,h]=_nt(jyt,this),c=i*l,u=a*h,d=r*l+s,p=n*h+o,f=this.newOutliner({x:_nt(Uyt,this)[0]*c+d,y:_nt(Uyt,this)[1]*u+p},_nt(jyt,this),_nt(Hyt,this),t,_nt(Wyt,this),null!=e?e:_nt(zyt,this)),g=2;g<_nt(Uyt,this).length;g+=2)f.add({x:_nt(Uyt,this)[g]*c+d,y:_nt(Uyt,this)[g+1]*u+p});return f.getOutlines()}}function qyt(t){for(var e=_nt(Gyt,this),r=e[4],n=e[5],i=r,a=n,s=r,o=n,l=r,h=n,c=t?Math.max:Math.min,u=6,d=e.length;u<d;u+=6){if(isNaN(e[u]))i=Math.min(i,e[u+4]),a=Math.min(a,e[u+5]),s=Math.max(s,e[u+4]),o=Math.max(o,e[u+5]),h<e[u+5]?(l=e[u+4],h=e[u+5]):h===e[u+5]&&(l=c(l,e[u+4]));else{var p=slt.bezierBoundingBox(r,n,...e.slice(u,u+6));i=Math.min(i,p[0]),a=Math.min(a,p[1]),s=Math.max(s,p[2]),o=Math.max(o,p[3]),h<p[3]?(l=p[2],h=p[3]):h===p[3]&&(l=c(l,p[2]))}r=e[u+4],n=e[u+5]}var f=_nt(Byt,this);f[0]=i-_nt(zyt,this),f[1]=a-_nt(zyt,this),f[2]=s-i+2*_nt(zyt,this),f[3]=o-a+2*_nt(zyt,this),this.lastPoint=[l,h]}var Xyt=new WeakMap,$yt=new WeakMap,Kyt=new WeakMap,Qyt=new WeakMap,Jyt=new WeakSet;class Zyt{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];Mnt(this,Jyt),knt(this,Xyt,void 0),knt(this,$yt,void 0),knt(this,Kyt,[]),knt(this,Qyt,[]);var i=1/0,a=-1/0,s=1/0,o=-1/0,l=Math.pow(10,-4);for(var{x:h,y:c,width:u,height:d}of t){var p=Math.floor((h-e)/l)*l,f=Math.ceil((h+u+e)/l)*l,g=Math.floor((c-e)/l)*l,v=Math.ceil((c+d+e)/l)*l,m=[p,g,v,!0],y=[f,g,v,!1];_nt(Kyt,this).push(m,y),i=Math.min(i,p),a=Math.max(a,f),s=Math.min(s,g),o=Math.max(o,v)}var b=a-i+2*r,w=o-s+2*r,x=i-r,A=s-r,_=_nt(Kyt,this).at(n?-1:-2),k=[_[0],_[2]];for(var S of _nt(Kyt,this)){var[E,M,T]=S;S[0]=(E-x)/b,S[1]=(M-A)/w,S[2]=(T-A)/w}Snt(Xyt,this,new Float32Array([x,A,b,w])),Snt($yt,this,k)}getOutlines(){_nt(Kyt,this).sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));var t=[];for(var e of _nt(Kyt,this))e[3]?(t.push(...bnt(Jyt,this,ibt).call(this,e)),bnt(Jyt,this,rbt).call(this,e)):(bnt(Jyt,this,nbt).call(this,e),t.push(...bnt(Jyt,this,ibt).call(this,e)));return bnt(Jyt,this,tbt).call(this,t)}}function tbt(t){var e=[],r=new Set;for(var n of t){var[i,a,s]=n;e.push([i,a,n],[i,s,n])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(var o=0,l=e.length;o<l;o+=2){var h=e[o][2],c=e[o+1][2];h.push(c),c.push(h),r.add(h),r.add(c)}for(var u,d=[];r.size>0;){var p=r.values().next().value,[f,g,v,m,y]=p;r.delete(p);var b=f,w=g;for(u=[f,v],d.push(u);;){var x=void 0;if(r.has(m))x=m;else{if(!r.has(y))break;x=y}r.delete(x),[f,g,v,m,y]=x,b!==f&&(u.push(b,w,f,w===g?g:v),b=f),w=w===g?v:g}u.push(b,w)}return new obt(d,_nt(Xyt,this),_nt($yt,this))}function ebt(t){for(var e=_nt(Qyt,this),r=0,n=e.length-1;r<=n;){var i=r+n>>1,a=e[i][0];if(a===t)return i;a<t?r=i+1:n=i-1}return n+1}function rbt(t){var[,e,r]=t,n=bnt(Jyt,this,ebt).call(this,e);_nt(Qyt,this).splice(n,0,[e,r])}function nbt(t){for(var[,e,r]=t,n=bnt(Jyt,this,ebt).call(this,e),i=n;i<_nt(Qyt,this).length;i++){var[a,s]=_nt(Qyt,this)[i];if(a!==e)break;if(a===e&&s===r)return void _nt(Qyt,this).splice(i,1)}for(var o=n-1;o>=0;o--){var[l,h]=_nt(Qyt,this)[o];if(l!==e)break;if(l===e&&h===r)return void _nt(Qyt,this).splice(o,1)}}function ibt(t){for(var[e,r,n]=t,i=[[e,r,n]],a=bnt(Jyt,this,ebt).call(this,n),s=0;s<a;s++)for(var[o,l]=_nt(Qyt,this)[s],h=0,c=i.length;h<c;h++){var[,u,d]=i[h];if(!(l<=u||d<=o))if(u>=o)if(d>l)i[h][1]=l;else{if(1===c)return[];i.splice(h,1),h--,c--}else i[h][2]=o,d>l&&i.push([e,l,d])}return i}var abt=new WeakMap,sbt=new WeakMap;class obt extends pyt{constructor(t,e,r){super(),knt(this,abt,void 0),knt(this,sbt,void 0),Snt(sbt,this,t),Snt(abt,this,e),this.lastPoint=r}toSVGPath(){var t=[];for(var e of _nt(sbt,this)){var[r,n]=e;t.push("M".concat(r," ").concat(n));for(var i=2;i<e.length;i+=2){var a=e[i],s=e[i+1];a===r?(t.push("V".concat(s)),n=s):s===n&&(t.push("H".concat(a)),r=a)}t.push("Z")}return t.join(" ")}serialize(t,e){var[r,n,i,a]=t,s=[],o=i-r,l=a-n;for(var h of _nt(sbt,this)){for(var c=new Array(h.length),u=0;u<h.length;u+=2)c[u]=r+h[u]*o,c[u+1]=a-h[u+1]*l;s.push(c)}return s}get box(){return _nt(abt,this)}get classNamesForOutlining(){return["highlightOutline"]}}class lbt extends Tyt{newFreeDrawOutline(t,e,r,n,i,a){return new hbt(t,e,r,n,i,a)}}class hbt extends Vyt{newOutliner(t,e,r,n,i){return new lbt(t,e,r,n,i,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}}var cbt=new WeakMap,ubt=new WeakMap,dbt=new WeakMap,pbt=new WeakMap,fbt=new WeakMap,gbt=new WeakMap,vbt=new WeakMap,mbt=new WeakMap,ybt=new WeakMap,bbt=new WeakMap,wbt=new WeakMap,xbt=new WeakSet;class Abt{static get _keyboardManager(){return Vot(this,"_keyboardManager",new bht([[["Escape","mac+Escape"],Abt.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Abt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Abt.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Abt.prototype._moveToPrevious],[["Home","mac+Home"],Abt.prototype._moveToBeginning],[["End","mac+End"],Abt.prototype._moveToEnd]]))}constructor(t){var e,{editor:r=null,uiManager:n=null}=t;Mnt(this,xbt),knt(this,cbt,null),knt(this,ubt,null),knt(this,dbt,void 0),knt(this,pbt,null),knt(this,fbt,!1),knt(this,gbt,!1),knt(this,vbt,null),knt(this,mbt,void 0),knt(this,ybt,null),knt(this,bbt,null),knt(this,wbt,void 0),r?(Snt(gbt,this,!1),Snt(wbt,this,not.HIGHLIGHT_COLOR),Snt(vbt,this,r)):(Snt(gbt,this,!0),Snt(wbt,this,not.HIGHLIGHT_DEFAULT_COLOR)),Snt(bbt,this,(null==r?void 0:r._uiManager)||n),Snt(mbt,this,_nt(bbt,this)._eventBus),Snt(dbt,this,(null==r?void 0:r.color)||(null===(e=_nt(bbt,this))||void 0===e?void 0:e.highlightColors.values().next().value)||"#FFFF98"),Cbt._||(Cbt._=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}renderButton(){var t=Snt(cbt,this,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);var e=_nt(bbt,this)._signal;t.addEventListener("click",bnt(xbt,this,Ebt).bind(this),{signal:e}),t.addEventListener("keydown",bnt(xbt,this,Sbt).bind(this),{signal:e});var r=Snt(ubt,this,document.createElement("span"));return r.className="swatch",r.setAttribute("aria-hidden",!0),r.style.backgroundColor=_nt(dbt,this),t.append(r),t}renderMainDropdown(){var t=Snt(pbt,this,bnt(xbt,this,_bt).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target!==_nt(cbt,this)){var e=t.target.getAttribute("data-color");e&&bnt(xbt,this,kbt).call(this,e,t)}else bnt(xbt,this,Ebt).call(this,t)}_moveToNext(t){var e,r;Ent(xbt,this,Tbt)?t.target!==_nt(cbt,this)?null===(e=t.target.nextSibling)||void 0===e||e.focus():null===(r=_nt(pbt,this).firstChild)||void 0===r||r.focus():bnt(xbt,this,Ebt).call(this,t)}_moveToPrevious(t){var e,r;t.target!==(null===(e=_nt(pbt,this))||void 0===e?void 0:e.firstChild)&&t.target!==_nt(cbt,this)?(Ent(xbt,this,Tbt)||bnt(xbt,this,Ebt).call(this,t),null===(r=t.target.previousSibling)||void 0===r||r.focus()):Ent(xbt,this,Tbt)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;Ent(xbt,this,Tbt)?null===(e=_nt(pbt,this).firstChild)||void 0===e||e.focus():bnt(xbt,this,Ebt).call(this,t)}_moveToEnd(t){var e;Ent(xbt,this,Tbt)?null===(e=_nt(pbt,this).lastChild)||void 0===e||e.focus():bnt(xbt,this,Ebt).call(this,t)}hideDropdown(){var t,e;null===(t=_nt(pbt,this))||void 0===t||t.classList.add("hidden"),null===(e=_nt(ybt,this))||void 0===e||e.abort(),Snt(ybt,this,null)}_hideDropdownFromKeyboard(){var t;_nt(gbt,this)||(Ent(xbt,this,Tbt)?(this.hideDropdown(),_nt(cbt,this).focus({preventScroll:!0,focusVisible:_nt(fbt,this)})):null===(t=_nt(vbt,this))||void 0===t||t.unselect())}updateColor(t){if(_nt(ubt,this)&&(_nt(ubt,this).style.backgroundColor=t),_nt(pbt,this)){var e=_nt(bbt,this).highlightColors.values();for(var r of _nt(pbt,this).children)r.setAttribute("aria-selected",e.next().value===t)}}destroy(){var t,e;null===(t=_nt(cbt,this))||void 0===t||t.remove(),Snt(cbt,this,null),Snt(ubt,this,null),null===(e=_nt(pbt,this))||void 0===e||e.remove(),Snt(pbt,this,null)}}function _bt(){var t=document.createElement("div"),e=_nt(bbt,this)._signal;for(var[r,n]of(t.addEventListener("contextmenu",Slt,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),_nt(bbt,this).highlightColors)){var i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",n),i.title=r,i.setAttribute("data-l10n-id",Cbt._[r]);var a=document.createElement("span");i.append(a),a.className="swatch",a.style.backgroundColor=n,i.setAttribute("aria-selected",n===_nt(dbt,this)),i.addEventListener("click",bnt(xbt,this,kbt).bind(this,n),{signal:e}),t.append(i)}return t.addEventListener("keydown",bnt(xbt,this,Sbt).bind(this),{signal:e}),t}function kbt(t,e){e.stopPropagation(),_nt(mbt,this).dispatch("switchannotationeditorparams",{source:this,type:_nt(wbt,this),value:t})}function Sbt(t){Lst._keyboardManager.exec(this,t)}function Ebt(t){if(Ent(xbt,this,Tbt))this.hideDropdown();else if(Snt(fbt,this,0===t.detail),_nt(ybt,this)||(Snt(ybt,this,new AbortController),window.addEventListener("pointerdown",bnt(xbt,this,Mbt).bind(this),{signal:_nt(bbt,this).combinedSignal(_nt(ybt,this))})),_nt(pbt,this))_nt(pbt,this).classList.remove("hidden");else{var e=Snt(pbt,this,bnt(xbt,this,_bt).call(this));_nt(cbt,this).append(e)}}function Mbt(t){var e;null!==(e=_nt(pbt,this))&&void 0!==e&&e.contains(t.target)||this.hideDropdown()}function Tbt(t){return _nt(pbt,t)&&!_nt(pbt,t).classList.contains("hidden")}Lst=Abt;var Cbt={_:null},Pbt=new WeakMap,Ibt=new WeakMap,Rbt=new WeakMap,Obt=new WeakMap,Lbt=new WeakMap,Dbt=new WeakMap,Fbt=new WeakMap,Nbt=new WeakMap,jbt=new WeakMap,Bbt=new WeakMap,zbt=new WeakMap,Wbt=new WeakMap,Ubt=new WeakMap,Hbt=new WeakMap,Gbt=new WeakMap,Ybt=new WeakMap,Vbt=new WeakMap,qbt=new WeakMap,Xbt=new WeakSet;class $bt extends But{static get _keyboardManager(){var t=$bt.prototype;return Vot(this,"_keyboardManager",new bht([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super(Pnt(Pnt({},t),{},{name:"highlightEditor"})),Mnt(this,Xbt),knt(this,Pbt,null),knt(this,Ibt,0),knt(this,Rbt,void 0),knt(this,Obt,null),knt(this,Lbt,null),knt(this,Dbt,null),knt(this,Fbt,null),knt(this,Nbt,0),knt(this,jbt,null),knt(this,Bbt,null),knt(this,zbt,null),knt(this,Wbt,!1),knt(this,Ubt,null),knt(this,Hbt,void 0),knt(this,Gbt,null),knt(this,Ybt,""),knt(this,Vbt,void 0),knt(this,qbt,""),this.color=t.color||$bt._defaultColor,Snt(Vbt,this,t.thickness||$bt._defaultThickness),Snt(Hbt,this,t.opacity||$bt._defaultOpacity),Snt(Rbt,this,t.boxes||null),Snt(qbt,this,t.methodOfCreation||""),Snt(Ybt,this,t.text||""),this._isDraggable=!1,t.highlightId>-1?(Snt(Wbt,this,!0),bnt(Xbt,this,Qbt).call(this,t),bnt(Xbt,this,rwt).call(this)):_nt(Rbt,this)&&(Snt(Pbt,this,t.anchorNode),Snt(Ibt,this,t.anchorOffset),Snt(Fbt,this,t.focusNode),Snt(Nbt,this,t.focusOffset),bnt(Xbt,this,Kbt).call(this),bnt(Xbt,this,rwt).call(this),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:_nt(Wbt,this)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:_nt(Vbt,this),methodOfCreation:_nt(qbt,this)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,e){var r;But.initialize(t,e),$bt._defaultColor||($bt._defaultColor=(null===(r=e.highlightColors)||void 0===r?void 0:r.values().next().value)||"#fff066")}static updateDefaultParams(t,e){switch(t){case not.HIGHLIGHT_DEFAULT_COLOR:$bt._defaultColor=e;break;case not.HIGHLIGHT_THICKNESS:$bt._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return _nt(Ubt,this)}updateParams(t,e){switch(t){case not.HIGHLIGHT_COLOR:bnt(Xbt,this,Jbt).call(this,e);break;case not.HIGHLIGHT_THICKNESS:bnt(Xbt,this,Zbt).call(this,e)}}static get defaultPropertiesToUpdate(){return[[not.HIGHLIGHT_DEFAULT_COLOR,$bt._defaultColor],[not.HIGHLIGHT_THICKNESS,$bt._defaultThickness]]}get propertiesToUpdate(){return[[not.HIGHLIGHT_COLOR,this.color||$bt._defaultColor],[not.HIGHLIGHT_THICKNESS,_nt(Vbt,this)||$bt._defaultThickness],[not.HIGHLIGHT_FREE,_nt(Wbt,this)]]}addEditToolbar(){var t=()=>super.addEditToolbar,e=this;return xnt((function*(){var r=yield t().call(e);return r?(e._uiManager.highlightColors&&(Snt(Lbt,e,new Abt({editor:e})),r.addColorPicker(_nt(Lbt,e))),r):null}))()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(bnt(Xbt,this,swt).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,bnt(Xbt,this,swt).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){bnt(Xbt,this,ewt).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(bnt(Xbt,this,rwt).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e=!1;if(this.parent&&!t)bnt(Xbt,this,ewt).call(this);else if(t){var r;bnt(Xbt,this,rwt).call(this,t),e=!this.parent&&(null===(r=this.div)||void 0===r?void 0:r.classList.contains("selectedEditor"))}super.setParent(t),this.show(this._isVisible),e&&this.select()}rotate(t){var e,{drawLayer:r}=this.parent;_nt(Wbt,this)?(t=(t-this.rotation+360)%360,e=nwt.call($bt,_nt(Bbt,this).box,t)):e=nwt.call($bt,[this.x,this.y,this.width,this.height],t),r.updateProperties(_nt(zbt,this),{bbox:e,root:{"data-main-rotation":t}}),r.updateProperties(_nt(Gbt,this),{bbox:nwt.call($bt,_nt(Dbt,this).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;var t=super.render();_nt(Ybt,this)&&(t.setAttribute("aria-label",_nt(Ybt,this)),t.setAttribute("role","mark")),_nt(Wbt,this)?t.classList.add("free"):this.div.addEventListener("keydown",bnt(Xbt,this,iwt).bind(this),{signal:this._uiManager._signal});var e=Snt(jbt,this,document.createElement("div"));t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=_nt(Obt,this);var[r,n]=this.parentDimensions;return this.setDims(this.width*r,this.height*n),nht(this,_nt(jbt,this),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(_nt(Gbt,this),{rootClass:{hovered:!0}}))}pointerleave(){var t;this.isSelected||(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(_nt(Gbt,this),{rootClass:{hovered:!1}}))}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:bnt(Xbt,this,awt).call(this,!0);break;case 1:case 3:bnt(Xbt,this,awt).call(this,!1)}}select(){var t;super.select(),_nt(Gbt,this)&&(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(_nt(Gbt,this),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),_nt(Gbt,this)&&(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(_nt(Gbt,this),{rootClass:{selected:!1}}),_nt(Wbt,this)||bnt(Xbt,this,awt).call(this,!1))}get _mustFixPosition(){return!_nt(Wbt,this)}show(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(_nt(zbt,this),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(_nt(Gbt,this),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,r){var{target:n,x:i,y:a}=r,{x:s,y:o,width:l,height:h}=n.getBoundingClientRect(),c=new AbortController,u=t.combinedSignal(c),d=e=>{c.abort(),bnt($bt,this,cwt).call(this,t,e)};window.addEventListener("blur",d,{signal:u}),window.addEventListener("pointerup",d,{signal:u}),window.addEventListener("pointerdown",Elt,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",Slt,{signal:u}),n.addEventListener("pointermove",bnt($bt,this,hwt).bind(this,t),{signal:u}),this._freeHighlight=new lbt({x:i,y:a},[s,o,l,h],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return xnt((function*(){var a=null;if(t instanceof Rmt){var{data:{quadPoints:s,rect:o,rotation:l,id:h,color:c,opacity:u,popupRef:d},parent:{page:{pageNumber:p}}}=t;a=t={annotationType:rot.HIGHLIGHT,color:Array.from(c),opacity:u,quadPoints:s,boxes:null,pageIndex:p-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,popupRef:d}}else if(t instanceof Pmt){var{data:{inkLists:f,rect:g,rotation:v,id:m,color:y,borderStyle:{rawWidth:b},popupRef:w},parent:{page:{pageNumber:x}}}=t;a=t={annotationType:rot.HIGHLIGHT,color:Array.from(y),thickness:b,inkLists:f,boxes:null,pageIndex:x-1,rect:g.slice(0),rotation:v,id:m,deleted:!1,popupRef:w}}var{color:A,quadPoints:_,inkLists:k,opacity:S}=t,E=yield n().call(i,t,e,r);E.color=slt.makeHexColor(...A),Snt(Hbt,E,S||1),k&&Snt(Vbt,E,t.thickness),E.annotationElementId=t.id||null,E._initialData=a;var[M,T]=E.pageDimensions,[C,P]=E.pageTranslation;if(_){for(var I=Snt(Rbt,E,[]),R=0;R<_.length;R+=8)I.push({x:(_[R]-C)/M,y:1-(_[R+1]-P)/T,width:(_[R+2]-_[R])/M,height:(_[R+1]-_[R+5])/T});bnt(Xbt,E,Kbt).call(E),bnt(Xbt,E,rwt).call(E),E.rotate(E.rotation)}else if(k){Snt(Wbt,E,!0);for(var O=k[0],L={x:O[0]-C,y:T-(O[1]-P)},D=new lbt(L,[0,0,M,T],1,_nt(Vbt,E)/2,!0,.001),F=0,N=O.length;F<N;F+=2)L.x=O[F]-C,L.y=T-(O[F+1]-P),D.add(L);var{id:j,clipPathId:B}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:E.color,"fill-opacity":E._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:D.toSVGPath()}},!0,!0);bnt(Xbt,E,Qbt).call(E,{highlightOutlines:D.getOutlines(),highlightId:j,clipPathId:B}),bnt(Xbt,E,rwt).call(E)}return E}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();var e=this.getRect(0,0),r=But._colorManager.convert(this.color),n={annotationType:rot.HIGHLIGHT,color:r,opacity:_nt(Hbt,this),thickness:_nt(Vbt,this),quadPoints:bnt(Xbt,this,owt).call(this),outlines:bnt(Xbt,this,lwt).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:bnt(Xbt,this,swt).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!bnt(Xbt,this,uwt).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}function Kbt(){var t=new Zyt(_nt(Rbt,this),.001);Snt(Bbt,this,t.getOutlines()),[this.x,this.y,this.width,this.height]=_nt(Bbt,this).box;var e=new Zyt(_nt(Rbt,this),.0025,.001,"ltr"===this._uiManager.direction);Snt(Dbt,this,e.getOutlines());var{lastPoint:r}=_nt(Dbt,this);Snt(Ubt,this,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])}function Qbt(t){var{highlightOutlines:e,highlightId:r,clipPathId:n}=t;Snt(Bbt,this,e);if(Snt(Dbt,this,e.getNewOutline(_nt(Vbt,this)/2+1.5,.0025)),r>=0)Snt(zbt,this,r),Snt(Obt,this,n),this.parent.drawLayer.finalizeDraw(r,{bbox:e.box,path:{d:e.toSVGPath()}}),Snt(Gbt,this,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:_nt(Dbt,this).box,path:{d:_nt(Dbt,this).toSVGPath()}},!0));else if(this.parent){var i=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(_nt(zbt,this),{bbox:nwt.call(Dst,_nt(Bbt,this).box,(i-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(_nt(Gbt,this),{bbox:nwt.call(Dst,_nt(Dbt,this).box,i),path:{d:_nt(Dbt,this).toSVGPath()}})}var[a,s,o,l]=e.box;switch(this.rotation){case 0:this.x=a,this.y=s,this.width=o,this.height=l;break;case 90:var[h,c]=this.parentDimensions;this.x=s,this.y=1-a,this.width=o*c/h,this.height=l*h/c;break;case 180:this.x=1-a,this.y=1-s,this.width=o,this.height=l;break;case 270:var[u,d]=this.parentDimensions;this.x=1-s,this.y=a,this.width=o*d/u,this.height=l*u/d}var{lastPoint:p}=_nt(Dbt,this);Snt(Ubt,this,[(p[0]-a)/o,(p[1]-s)/l])}function Jbt(t){var e=(t,e)=>{var r,n;this.color=t,Snt(Hbt,this,e),null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(_nt(zbt,this),{root:{fill:t,"fill-opacity":e}}),null===(n=_nt(Lbt,this))||void 0===n||n.updateColor(t)},r=this.color,n=_nt(Hbt,this);this.addCommands({cmd:e.bind(this,t,Dst._defaultOpacity),undo:e.bind(this,r,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:not.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}function Zbt(t){var e=_nt(Vbt,this),r=t=>{Snt(Vbt,this,t),bnt(Xbt,this,twt).call(this,t)};this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:not.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}function twt(t){if(_nt(Wbt,this)){bnt(Xbt,this,Qbt).call(this,{highlightOutlines:_nt(Bbt,this).getNewOutline(t/2)}),this.fixAndSetPosition();var[e,r]=this.parentDimensions;this.setDims(this.width*e,this.height*r)}}function ewt(){null!==_nt(zbt,this)&&this.parent&&(this.parent.drawLayer.remove(_nt(zbt,this)),Snt(zbt,this,null),this.parent.drawLayer.remove(_nt(Gbt,this)),Snt(Gbt,this,null))}function rwt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null===_nt(zbt,this)&&(({id:Int(Snt,[zbt,this])._,clipPathId:Int(Snt,[Obt,this])._}=t.drawLayer.draw({bbox:_nt(Bbt,this).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":_nt(Hbt,this)},rootClass:{highlight:!0,free:_nt(Wbt,this)},path:{d:_nt(Bbt,this).toSVGPath()}},!1,!0)),Snt(Gbt,this,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:_nt(Wbt,this)},bbox:_nt(Dbt,this).box,path:{d:_nt(Dbt,this).toSVGPath()}},_nt(Wbt,this))),_nt(jbt,this)&&(_nt(jbt,this).style.clipPath=_nt(Obt,this)))}function nwt(t,e){var[r,n,i,a]=t;switch(e){case 90:return[1-n-a,r,a,i];case 180:return[1-r-i,1-n-a,i,a];case 270:return[n,1-r-i,a,i]}return[r,n,i,a]}function iwt(t){Dst._keyboardManager.exec(this,t)}function awt(t){if(_nt(Pbt,this)){var e=window.getSelection();t?e.setPosition(_nt(Pbt,this),_nt(Ibt,this)):e.setPosition(_nt(Fbt,this),_nt(Nbt,this))}}function swt(){return _nt(Wbt,this)?this.rotation:0}function owt(){if(_nt(Wbt,this))return null;var[t,e]=this.pageDimensions,[r,n]=this.pageTranslation,i=_nt(Rbt,this),a=new Float32Array(8*i.length),s=0;for(var{x:o,y:l,width:h,height:c}of i){var u=o*t+r,d=(1-l)*e+n;a[s]=a[s+4]=u,a[s+1]=a[s+3]=d,a[s+2]=a[s+6]=u+h*t,a[s+5]=a[s+7]=d-c*e,s+=8}return a}function lwt(t){return _nt(Bbt,this).serialize(t,bnt(Xbt,this,swt).call(this))}function hwt(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}function cwt(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}function uwt(t){var{color:e}=this._initialData;return t.color.some(((t,r)=>t!==e[r]))}Dst=$bt,Tnt($bt,"_defaultColor",null),Tnt($bt,"_defaultOpacity",1),Tnt($bt,"_defaultThickness",12),Tnt($bt,"_type","highlight"),Tnt($bt,"_editorType",rot.HIGHLIGHT),Tnt($bt,"_freeHighlightId",-1),Tnt($bt,"_freeHighlight",null),Tnt($bt,"_freeHighlightClipId","");var dwt=new WeakMap;class pwt{constructor(){knt(this,dwt,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(var[e,r]of Object.entries(t))this.updateProperty(e,r)}updateSVGProperty(t,e){_nt(dwt,this)[t]=e}toSVGProperties(){var t=_nt(dwt,this);return Snt(dwt,this,Object.create(null)),{root:t}}reset(){Snt(dwt,this,Object.create(null))}updateAll(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this;this.updateProperties(t)}clone(){Hot("Not implemented")}}var fwt=new WeakMap,gwt=new WeakMap,vwt=new WeakSet;class mwt extends But{constructor(t){super(t),Mnt(this,vwt),knt(this,fwt,null),knt(this,gwt,void 0),Tnt(this,"_drawId",null),Snt(gwt,this,t.mustBeCommitted||!1),t.drawOutlines&&(bnt(vwt,this,ywt).call(this,t),bnt(vwt,this,xwt).call(this))}static _mergeSVGProperties(t,e){var r=new Set(Object.keys(t));for(var[n,i]of Object.entries(e))r.has(n)?Object.assign(t[n],i):t[n]=i;return t}static getDefaultDrawingOptions(t){Hot("Not implemented")}static get typesMap(){Hot("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){var r=this.typesMap.get(t);r&&this._defaultDrawingOptions.updateProperty(r,e),this._currentParent&&(Ewt._.updateProperty(r,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){var r=this.constructor.typesMap.get(t);r&&this._updateProperty(t,r,e)}static get defaultPropertiesToUpdate(){var t=[],e=this._defaultDrawingOptions;for(var[r,n]of this.typesMap)t.push([r,e[n]]);return t}get propertiesToUpdate(){var t=[],{_drawingOptions:e}=this;for(var[r,n]of this.constructor.typesMap)t.push([r,e[n]]);return t}_updateProperty(t,e,r){var n=this._drawingOptions,i=n[e],a=t=>{var r;n.updateProperty(e,t);var i=_nt(fwt,this).updateProperty(e,t);i&&bnt(vwt,this,kwt).call(this,i),null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(this._drawId,n.toSVGProperties())};this.addCommands({cmd:a.bind(this,r),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,mwt._mergeSVGProperties(_nt(fwt,this).getPathResizingSVGProperties(bnt(vwt,this,_wt).call(this)),{bbox:bnt(vwt,this,Swt).call(this)}))}_onResized(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,mwt._mergeSVGProperties(_nt(fwt,this).getPathResizedSVGProperties(bnt(vwt,this,_wt).call(this)),{bbox:bnt(vwt,this,Swt).call(this)}))}_onTranslating(t,e){var r;null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(this._drawId,{bbox:bnt(vwt,this,Swt).call(this,t,e)})}_onTranslated(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,mwt._mergeSVGProperties(_nt(fwt,this).getPathTranslatedSVGProperties(bnt(vwt,this,_wt).call(this),this.parentDimensions),{bbox:bnt(vwt,this,Swt).call(this)}))}_onStartDragging(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,_nt(gwt,this)&&(Snt(gwt,this,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){bnt(vwt,this,wwt).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(bnt(vwt,this,xwt).call(this),bnt(vwt,this,kwt).call(this,_nt(fwt,this).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e=!1;if(this.parent&&!t)this._uiManager.removeShouldRescale(this),bnt(vwt,this,wwt).call(this);else if(t){var r;this._uiManager.addShouldRescale(this),bnt(vwt,this,xwt).call(this,t),e=!this.parent&&(null===(r=this.div)||void 0===r?void 0:r.classList.contains("selectedEditor"))}super.setParent(t),e&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,mwt._mergeSVGProperties({bbox:bnt(vwt,this,Swt).call(this)},_nt(fwt,this).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&bnt(vwt,this,kwt).call(this,_nt(fwt,this).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;var t=super.render();t.classList.add("draw");var e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";var[r,n]=this.parentDimensions;return this.setDims(this.width*r,this.height*n),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,r,n,i){Hot("Not implemented")}static startDrawing(t,e,r,n){var i,a,{target:s,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=n;if(!Pwt._||Pwt._===c){var{viewport:{rotation:u}}=t,{width:d,height:p}=s.getBoundingClientRect(),f=Mwt._=new AbortController,g=t.combinedSignal(f);Cwt._||(Cwt._=h),null!==(i=Pwt._)&&void 0!==i||(Pwt._=c),window.addEventListener("pointerup",(t=>{var e;Cwt._===t.pointerId?this._endDraw(t):null===(e=Iwt._)||void 0===e||e.delete(t.pointerId)}),{signal:g}),window.addEventListener("pointercancel",(t=>{var e;Cwt._===t.pointerId?this._currentParent.endDrawingSession():null===(e=Iwt._)||void 0===e||e.delete(t.pointerId)}),{signal:g}),window.addEventListener("pointerdown",(t=>{Pwt._===t.pointerType&&((Iwt._||(Iwt._=new Set)).add(t.pointerId),Ewt._.isCancellable()&&(Ewt._.removeLastElement(),Ewt._.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",Slt,{signal:g}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),s.addEventListener("touchmove",(t=>{t.timeStamp===Rwt._&&Elt(t)}),{signal:g}),t.toggleDrawing(),null===(a=e._editorUndoBar)||void 0===a||a.hide(),Ewt._?t.drawLayer.updateProperties(this._currentDrawId,Ewt._.startNew(o,l,d,p,u)):(e.updateUIForDefaultProperties(this),Ewt._=this.createDrawerInstance(o,l,d,p,u),Twt._=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(Twt._.toSVGProperties(),Ewt._.defaultSVGProperties),!0,!1)))}}static _drawMove(t){var e;if(Rwt._=-1,Ewt._){var{offsetX:r,offsetY:n,pointerId:i}=t;Cwt._===i&&((null===(e=Iwt._)||void 0===e?void 0:e.size)>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Ewt._.add(r,n)),Rwt._=t.timeStamp,Elt(t)))}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,Ewt._=null,Twt._=null,Pwt._=null,Rwt._=NaN),Mwt._&&(Mwt._.abort(),Mwt._=null,Cwt._=NaN,Iwt._=null)}static _endDraw(t){var e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,Ewt._.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){var r=Ewt._,n=this._currentDrawId,i=r.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(n,r.setLastElement(i))},undo:()=>{e.drawLayer.updateProperties(n,r.removeLastElement())},mustExec:!1,type:not.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){var e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(not.DRAW_STEP),!Ewt._.isEmpty()){var{pageDimensions:[r,n],scale:i}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Ewt._.getOutlines(r*i,n*i,i,this._INNER_MARGIN),drawingOptions:Twt._,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,r,n,i,a){Hot("Not implemented")}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return xnt((function*(){var{rawDims:{pageWidth:a,pageHeight:s,pageX:o,pageY:l}}=e.viewport,h=i.deserializeDraw(o,l,a,s,i._INNER_MARGIN,t),c=yield n().call(i,t,e,r);return c.createDrawingOptions(t),bnt(vwt,c,ywt).call(c,{drawOutlines:h}),bnt(vwt,c,xwt).call(c),c.onScaleChanging(),c.rotate(),c}))()}serializeDraw(t){var[e,r]=this.pageTranslation,[n,i]=this.pageDimensions;return _nt(fwt,this).serialize([e,r,n,i],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}function ywt(t){var{drawOutlines:e,drawId:r,drawingOptions:n}=t;Snt(fwt,this,e),this._drawingOptions||(this._drawingOptions=n),r>=0?(this._drawId=r,this.parent.drawLayer.finalizeDraw(r,e.defaultProperties)):this._drawId=bnt(vwt,this,bwt).call(this,e,this.parent),bnt(vwt,this,kwt).call(this,e.box)}function bwt(t,e){var{id:r}=e.drawLayer.draw(Fst._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return r}function wwt(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}function xwt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=bnt(vwt,this,bwt).call(this,_nt(fwt,this),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}function Awt(t){var[e,r,n,i]=t,{parentDimensions:[a,s],rotation:o}=this;switch(o){case 90:return[r,1-e,n*(s/a),i*(a/s)];case 180:return[1-e,1-r,n,i];case 270:return[1-r,e,n*(s/a),i*(a/s)];default:return[e,r,n,i]}}function _wt(){var{x:t,y:e,width:r,height:n,parentDimensions:[i,a],rotation:s}=this;switch(s){case 90:return[1-e,t,r*(i/a),n*(a/i)];case 180:return[1-t,1-e,r,n];case 270:return[e,1-t,r*(i/a),n*(a/i)];default:return[t,e,r,n]}}function kwt(t){if([this.x,this.y,this.width,this.height]=bnt(vwt,this,Awt).call(this,t),this.div){this.fixAndSetPosition();var[e,r]=this.parentDimensions;this.setDims(this.width*e,this.height*r)}this._onResized()}function Swt(){var{x:t,y:e,width:r,height:n,rotation:i,parentRotation:a,parentDimensions:[s,o]}=this;switch((4*i+a)/90){case 1:return[1-e-n,t,n,r];case 2:return[1-t-r,1-e-n,r,n];case 3:return[e,1-t-r,n,r];case 4:return[t,e-r*(s/o),n*(o/s),r*(s/o)];case 5:return[1-e,t,r*(s/o),n*(o/s)];case 6:return[1-t-n*(o/s),1-e,n*(o/s),r*(s/o)];case 7:return[e-r*(s/o),1-t-n*(o/s),r*(s/o),n*(o/s)];case 8:return[t-r,e-n,r,n];case 9:return[1-e,t-r,n,r];case 10:return[1-t,1-e,r,n];case 11:return[e-n,1-t,n,r];case 12:return[t-n*(o/s),e,n*(o/s),r*(s/o)];case 13:return[1-e-r*(s/o),t-n*(o/s),r*(s/o),n*(o/s)];case 14:return[1-t,1-e-r*(s/o),n*(o/s),r*(s/o)];case 15:return[e,1-t,r*(s/o),n*(o/s)];default:return[t,e,r,n]}}Fst=mwt,Tnt(mwt,"_currentDrawId",-1),Tnt(mwt,"_currentParent",null);var Ewt={_:null},Mwt={_:null},Twt={_:null},Cwt={_:NaN},Pwt={_:null},Iwt={_:null},Rwt={_:NaN};Tnt(mwt,"_INNER_MARGIN",3);var Owt=new WeakMap,Lwt=new WeakMap,Dwt=new WeakMap,Fwt=new WeakMap,Nwt=new WeakMap,jwt=new WeakMap,Bwt=new WeakMap,zwt=new WeakMap,Wwt=new WeakMap,Uwt=new WeakMap,Hwt=new WeakMap,Gwt=new WeakSet;class Ywt{constructor(t,e,r,n,i,a){Mnt(this,Gwt),knt(this,Owt,new Float64Array(6)),knt(this,Lwt,void 0),knt(this,Dwt,void 0),knt(this,Fwt,void 0),knt(this,Nwt,void 0),knt(this,jwt,void 0),knt(this,Bwt,""),knt(this,zwt,0),knt(this,Wwt,new nxt),knt(this,Uwt,void 0),knt(this,Hwt,void 0),Snt(Uwt,this,r),Snt(Hwt,this,n),Snt(Fwt,this,i),Snt(Nwt,this,a),[t,e]=bnt(Gwt,this,Vwt).call(this,t,e);var s=Snt(Lwt,this,[NaN,NaN,NaN,NaN,t,e]);Snt(jwt,this,[t,e]),Snt(Dwt,this,[{line:s,points:_nt(jwt,this)}]),_nt(Owt,this).set(s,0)}updateProperty(t,e){"stroke-width"===t&&Snt(Nwt,this,e)}isEmpty(){return!_nt(Dwt,this)||0===_nt(Dwt,this).length}isCancellable(){return _nt(jwt,this).length<=10}add(t,e){[t,e]=bnt(Gwt,this,Vwt).call(this,t,e);var[r,n,i,a]=_nt(Owt,this).subarray(2,6),s=t-i,o=e-a;return Math.hypot(_nt(Uwt,this)*s,_nt(Hwt,this)*o)<=2?null:(_nt(jwt,this).push(t,e),isNaN(r)?(_nt(Owt,this).set([i,a,t,e],2),_nt(Lwt,this).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(_nt(Owt,this)[0])&&_nt(Lwt,this).splice(6,6),_nt(Owt,this).set([r,n,i,a,t,e],0),_nt(Lwt,this).push(...pyt.createBezierPoints(r,n,i,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){var r=this.add(t,e);return r||(2===_nt(jwt,this).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,r,n,i){Snt(Uwt,this,r),Snt(Hwt,this,n),Snt(Fwt,this,i),[t,e]=bnt(Gwt,this,Vwt).call(this,t,e);var a=Snt(Lwt,this,[NaN,NaN,NaN,NaN,t,e]);Snt(jwt,this,[t,e]);var s=_nt(Dwt,this).at(-1);return s&&(s.line=new Float32Array(s.line),s.points=new Float32Array(s.points)),_nt(Dwt,this).push({line:a,points:_nt(jwt,this)}),_nt(Owt,this).set(a,0),Snt(zwt,this,0),this.toSVGPath(),null}getLastElement(){return _nt(Dwt,this).at(-1)}setLastElement(t){return _nt(Dwt,this)?(_nt(Dwt,this).push(t),Snt(Lwt,this,t.line),Snt(jwt,this,t.points),Snt(zwt,this,0),{path:{d:this.toSVGPath()}}):_nt(Wwt,this).setLastElement(t)}removeLastElement(){if(!_nt(Dwt,this))return _nt(Wwt,this).removeLastElement();_nt(Dwt,this).pop(),Snt(Bwt,this,"");for(var t=0,e=_nt(Dwt,this).length;t<e;t++){var{line:r,points:n}=_nt(Dwt,this)[t];Snt(Lwt,this,r),Snt(jwt,this,n),Snt(zwt,this,0),this.toSVGPath()}return{path:{d:_nt(Bwt,this)}}}toSVGPath(){var t=pyt.svgRound(_nt(Lwt,this)[4]),e=pyt.svgRound(_nt(Lwt,this)[5]);if(2===_nt(jwt,this).length)return Snt(Bwt,this,"".concat(_nt(Bwt,this)," M ").concat(t," ").concat(e," Z")),_nt(Bwt,this);if(_nt(jwt,this).length<=6){var r=_nt(Bwt,this).lastIndexOf("M");Snt(Bwt,this,"".concat(_nt(Bwt,this).slice(0,r)," M ").concat(t," ").concat(e)),Snt(zwt,this,6)}if(4===_nt(jwt,this).length){var n=pyt.svgRound(_nt(Lwt,this)[10]),i=pyt.svgRound(_nt(Lwt,this)[11]);return Snt(Bwt,this,"".concat(_nt(Bwt,this)," L ").concat(n," ").concat(i)),Snt(zwt,this,12),_nt(Bwt,this)}var a=[];0===_nt(zwt,this)&&(a.push("M ".concat(t," ").concat(e)),Snt(zwt,this,6));for(var s=_nt(zwt,this),o=_nt(Lwt,this).length;s<o;s+=6){var[l,h,c,u,d,p]=_nt(Lwt,this).slice(s,s+6).map(pyt.svgRound);a.push("C".concat(l," ").concat(h," ").concat(c," ").concat(u," ").concat(d," ").concat(p))}return Snt(Bwt,this,_nt(Bwt,this)+a.join(" ")),Snt(zwt,this,_nt(Lwt,this).length),_nt(Bwt,this)}getOutlines(t,e,r,n){var i=_nt(Dwt,this).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),_nt(Wwt,this).build(_nt(Dwt,this),t,e,r,_nt(Fwt,this),_nt(Nwt,this),n),Snt(Owt,this,null),Snt(Lwt,this,null),Snt(Dwt,this,null),Snt(Bwt,this,null),_nt(Wwt,this)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}function Vwt(t,e){return pyt._normalizePoint(t,e,_nt(Uwt,this),_nt(Hwt,this),_nt(Fwt,this))}var qwt=new WeakMap,Xwt=new WeakMap,$wt=new WeakMap,Kwt=new WeakMap,Qwt=new WeakMap,Jwt=new WeakMap,Zwt=new WeakMap,txt=new WeakMap,ext=new WeakMap,rxt=new WeakSet;class nxt extends pyt{constructor(){super(...arguments),Mnt(this,rxt),knt(this,qwt,void 0),knt(this,Xwt,0),knt(this,$wt,void 0),knt(this,Kwt,void 0),knt(this,Qwt,void 0),knt(this,Jwt,void 0),knt(this,Zwt,void 0),knt(this,txt,void 0),knt(this,ext,void 0)}build(t,e,r,n,i,a,s){Snt(Qwt,this,e),Snt(Jwt,this,r),Snt(Zwt,this,n),Snt(txt,this,i),Snt(ext,this,a),Snt($wt,this,null!=s?s:0),Snt(Kwt,this,t),bnt(rxt,this,sxt).call(this)}setLastElement(t){return _nt(Kwt,this).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return _nt(Kwt,this).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){var t=[];for(var{line:e}of _nt(Kwt,this))if(t.push("M".concat(pyt.svgRound(e[4])," ").concat(pyt.svgRound(e[5]))),6!==e.length)if(12!==e.length)for(var r=6,n=e.length;r<n;r+=6){var[i,a,s,o,l,h]=e.subarray(r,r+6).map(pyt.svgRound);t.push("C".concat(i," ").concat(a," ").concat(s," ").concat(o," ").concat(l," ").concat(h))}else t.push("L".concat(pyt.svgRound(e[10])," ").concat(pyt.svgRound(e[11])));else t.push("Z");return t.join("")}serialize(t,e){var r,n,i,a,s,o,l,h,c,[u,d,p,f]=t,g=[],v=[],[m,y,b,w]=bnt(rxt,this,axt).call(this);switch(_nt(txt,this)){case 0:c=pyt._rescale,r=u,n=d+f,i=p,a=-f,s=u+m*p,o=d+(1-y-w)*f,l=u+(m+b)*p,h=d+(1-y)*f;break;case 90:c=pyt._rescaleAndSwap,r=u,n=d,i=p,a=f,s=u+y*p,o=d+m*f,l=u+(y+w)*p,h=d+(m+b)*f;break;case 180:c=pyt._rescale,r=u+p,n=d,i=-p,a=f,s=u+(1-m-b)*p,o=d+y*f,l=u+(1-m)*p,h=d+(y+w)*f;break;case 270:c=pyt._rescaleAndSwap,r=u+p,n=d+f,i=-p,a=-f,s=u+(1-y-w)*p,o=d+(1-m-b)*f,l=u+(1-y)*p,h=d+(1-m)*f}for(var{line:x,points:A}of _nt(Kwt,this))g.push(c(x,r,n,i,a,e?new Array(x.length):null)),v.push(c(A,r,n,i,a,e?new Array(A.length):null));return{lines:g,points:v,rect:[s,o,l,h]}}static deserialize(t,e,r,n,i,a){var s,o,l,h,c,{paths:{lines:u,points:d},rotation:p,thickness:f}=a,g=[];switch(p){case 0:c=pyt._rescale,s=-t/r,o=e/n+1,l=1/r,h=-1/n;break;case 90:c=pyt._rescaleAndSwap,s=-e/n,o=-t/r,l=1/n,h=1/r;break;case 180:c=pyt._rescale,s=t/r+1,o=-e/n,l=-1/r,h=1/n;break;case 270:c=pyt._rescaleAndSwap,s=e/n+1,o=t/r+1,l=-1/n,h=-1/r}if(!u)for(var v of(u=[],d)){var m=v.length;if(2!==m)if(4!==m){var y=new Float32Array(3*(m-2));u.push(y);var[b,w,x,A]=v.subarray(0,4);y.set([NaN,NaN,NaN,NaN,b,w],0);for(var _=4;_<m;_+=2){var k=v[_],S=v[_+1];y.set(pyt.createBezierPoints(b,w,x,A,k,S),3*(_-2)),[b,w,x,A]=[x,A,k,S]}}else u.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));else u.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]))}for(var E=0,M=u.length;E<M;E++)g.push({line:c(u[E].map((t=>null!=t?t:NaN)),s,o,l,h),points:c(d[E].map((t=>null!=t?t:NaN)),s,o,l,h)});var T=new nxt;return T.build(g,r,n,1,p,f,i),T}get box(){return _nt(qwt,this)}updateProperty(t,e){return"stroke-width"===t?bnt(rxt,this,oxt).call(this,e):null}updateParentDimensions(t,e){var[r,n]=t,[i,a]=bnt(rxt,this,ixt).call(this);Snt(Qwt,this,r),Snt(Jwt,this,n),Snt(Zwt,this,e);var[s,o]=bnt(rxt,this,ixt).call(this),l=s-i,h=o-a,c=_nt(qwt,this);return c[0]-=l,c[1]-=h,c[2]+=2*l,c[3]+=2*h,c}updateRotation(t){return Snt(Xwt,this,t),{path:{transform:this.rotationTransform}}}get viewBox(){return _nt(qwt,this).map(pyt.svgRound).join(" ")}get defaultProperties(){var[t,e]=_nt(qwt,this);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(pyt.svgRound(t)," ").concat(pyt.svgRound(e))}}}get rotationTransform(){var[,,t,e]=_nt(qwt,this),r=0,n=0,i=0,a=0,s=0,o=0;switch(_nt(Xwt,this)){case 90:n=e/t,i=-t/e,s=t;break;case 180:r=-1,a=-1,s=t,o=e;break;case 270:n=-e/t,i=t/e,o=e;break;default:return""}return"matrix(".concat(r," ").concat(n," ").concat(i," ").concat(a," ").concat(pyt.svgRound(s)," ").concat(pyt.svgRound(o),")")}getPathResizingSVGProperties(t){var[e,r,n,i]=t,[a,s]=bnt(rxt,this,ixt).call(this),[o,l,h,c]=_nt(qwt,this);if(Math.abs(h-a)<=pyt.PRECISION||Math.abs(c-s)<=pyt.PRECISION){var u=e+n/2-(o+h/2),d=r+i/2-(l+c/2);return{path:{"transform-origin":"".concat(pyt.svgRound(e)," ").concat(pyt.svgRound(r)),transform:"".concat(this.rotationTransform," translate(").concat(u," ").concat(d,")")}}}var p=(n-2*a)/(h-2*a),f=(i-2*s)/(c-2*s),g=h/n,v=c/i;return{path:{"transform-origin":"".concat(pyt.svgRound(o)," ").concat(pyt.svgRound(l)),transform:"".concat(this.rotationTransform," scale(").concat(g," ").concat(v,") ")+"translate(".concat(pyt.svgRound(a)," ").concat(pyt.svgRound(s),") scale(").concat(p," ").concat(f,") ")+"translate(".concat(pyt.svgRound(-a)," ").concat(pyt.svgRound(-s),")")}}}getPathResizedSVGProperties(t){var[e,r,n,i]=t,[a,s]=bnt(rxt,this,ixt).call(this),o=_nt(qwt,this),[l,h,c,u]=o;if(o[0]=e,o[1]=r,o[2]=n,o[3]=i,Math.abs(c-a)<=pyt.PRECISION||Math.abs(u-s)<=pyt.PRECISION){var d=e+n/2-(l+c/2),p=r+i/2-(h+u/2);for(var{line:f,points:g}of _nt(Kwt,this))pyt._translate(f,d,p,f),pyt._translate(g,d,p,g);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(pyt.svgRound(e)," ").concat(pyt.svgRound(r)),transform:this.rotationTransform||null,d:this.toSVGPath()}}}var v=(n-2*a)/(c-2*a),m=(i-2*s)/(u-2*s),y=-v*(l+a)+e+a,b=-m*(h+s)+r+s;if(1!==v||1!==m||0!==y||0!==b)for(var{line:w,points:x}of _nt(Kwt,this))pyt._rescale(w,y,b,v,m,w),pyt._rescale(x,y,b,v,m,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(pyt.svgRound(e)," ").concat(pyt.svgRound(r)),transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties(t,e){var[r,n]=t,[i,a]=e,s=_nt(qwt,this),o=r-s[0],l=n-s[1];if(_nt(Qwt,this)===i&&_nt(Jwt,this)===a)for(var{line:h,points:c}of _nt(Kwt,this))pyt._translate(h,o,l,h),pyt._translate(c,o,l,c);else{var u=_nt(Qwt,this)/i,d=_nt(Jwt,this)/a;for(var{line:p,points:f}of(Snt(Qwt,this,i),Snt(Jwt,this,a),_nt(Kwt,this)))pyt._rescale(p,o,l,u,d,p),pyt._rescale(f,o,l,u,d,f);s[2]*=u,s[3]*=d}return s[0]=r,s[1]=n,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":"".concat(pyt.svgRound(r)," ").concat(pyt.svgRound(n))}}}get defaultSVGProperties(){var t=_nt(qwt,this);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":"".concat(pyt.svgRound(t[0])," ").concat(pyt.svgRound(t[1])),transform:this.rotationTransform||null},bbox:t}}}function ixt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_nt(ext,this),e=_nt($wt,this)+t/2*_nt(Zwt,this);return _nt(txt,this)%180==0?[e/_nt(Qwt,this),e/_nt(Jwt,this)]:[e/_nt(Jwt,this),e/_nt(Qwt,this)]}function axt(){var[t,e,r,n]=_nt(qwt,this),[i,a]=bnt(rxt,this,ixt).call(this,0);return[t+i,e+a,r-2*i,n-2*a]}function sxt(){var t=Snt(qwt,this,new Float32Array([1/0,1/0,-1/0,-1/0]));for(var{line:e}of _nt(Kwt,this))if(e.length<=12)for(var r=4,n=e.length;r<n;r+=6){var[i,a]=e.subarray(r,r+2);t[0]=Math.min(t[0],i),t[1]=Math.min(t[1],a),t[2]=Math.max(t[2],i),t[3]=Math.max(t[3],a)}else for(var s=e[4],o=e[5],l=6,h=e.length;l<h;l+=6){var[c,u,d,p,f,g]=e.subarray(l,l+6);slt.bezierBoundingBox(s,o,c,u,d,p,f,g,t),s=f,o=g}var[v,m]=bnt(rxt,this,ixt).call(this);t[0]=Math.min(1,Math.max(0,t[0]-v)),t[1]=Math.min(1,Math.max(0,t[1]-m)),t[2]=Math.min(1,Math.max(0,t[2]+v)),t[3]=Math.min(1,Math.max(0,t[3]+m)),t[2]-=t[0],t[3]-=t[1]}function oxt(t){var[e,r]=bnt(rxt,this,ixt).call(this);Snt(ext,this,t);var[n,i]=bnt(rxt,this,ixt).call(this),[a,s]=[n-e,i-r],o=_nt(qwt,this);return o[0]-=a,o[1]-=s,o[2]+=2*a,o[3]+=2*s,o}var lxt=new WeakMap;class hxt extends pwt{constructor(t){super(),knt(this,lxt,void 0),Snt(lxt,this,t),super.updateProperties({fill:"none",stroke:But._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(null!=e||(e=this["stroke-width"]),e*=_nt(lxt,this).realScale),super.updateSVGProperty(t,e)}clone(){var t=new hxt(_nt(lxt,this));return t.updateAll(this),t}}var cxt=new WeakSet;class uxt extends mwt{constructor(t){super(Pnt(Pnt({},t),{},{name:"inkEditor"})),Mnt(this,cxt),this._willKeepAspectRatio=!0}static initialize(t,e){But.initialize(t,e),this._defaultDrawingOptions=new hxt(e.viewParameters)}static getDefaultDrawingOptions(t){var e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Vot(this,"typesMap",new Map([[not.INK_THICKNESS,"stroke-width"],[not.INK_COLOR,"stroke"],[not.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,r,n,i){return new Ywt(t,e,r,n,i,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,r,n,i,a){return nxt.deserialize(t,e,r,n,i,a)}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return xnt((function*(){var a=null;if(t instanceof Pmt){var{data:{inkLists:s,rect:o,rotation:l,id:h,color:c,opacity:u,borderStyle:{rawWidth:d},popupRef:p},parent:{page:{pageNumber:f}}}=t;a=t={annotationType:rot.INK,color:Array.from(c),thickness:d,opacity:u,paths:{points:s},boxes:null,pageIndex:f-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,popupRef:p}}var g=yield n().call(i,t,e,r);return g.annotationElementId=t.id||null,g._initialData=a,g}))()}onScaleChanging(){if(this.parent){super.onScaleChanging();var{_drawId:t,_drawingOptions:e,parent:r}=this;e.updateSVGProperty("stroke-width"),r.drawLayer.updateProperties(t,e.toSVGProperties())}}static onScaleChangingWhenDrawing(){var t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions(t){var{color:e,thickness:r,opacity:n}=t;this._drawingOptions=uxt.getDefaultDrawingOptions({stroke:slt.makeHexColor(...e),"stroke-width":r,"stroke-opacity":n})}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var{lines:e,points:r,rect:n}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":a,"stroke-width":s}}=this,o={annotationType:rot.INK,color:But._colorManager.convert(i),opacity:a,thickness:s,paths:{lines:e,points:r},pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!bnt(cxt,this,dxt).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(t){var{points:e,rect:r}=this.serializeDraw(!1);return t.updateEdited({rect:r,thickness:this._drawingOptions["stroke-width"],points:e}),null}}function dxt(t){var{color:e,thickness:r,opacity:n,pageIndex:i}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,r)=>t!==e[r]))||t.thickness!==r||t.opacity!==n||t.pageIndex!==i}Tnt(uxt,"_type","ink"),Tnt(uxt,"_editorType",rot.INK),Tnt(uxt,"_defaultDrawingOptions",null);var pxt=new WeakMap,fxt=new WeakMap,gxt=new WeakMap,vxt=new WeakMap,mxt=new WeakMap,yxt=new WeakMap,bxt=new WeakMap,wxt=new WeakMap,xxt=new WeakMap,Axt=new WeakMap,_xt=new WeakSet;class kxt extends But{constructor(t){super(Pnt(Pnt({},t),{},{name:"stampEditor"})),Mnt(this,_xt),knt(this,pxt,null),knt(this,fxt,null),knt(this,gxt,null),knt(this,vxt,null),knt(this,mxt,null),knt(this,yxt,""),knt(this,bxt,null),knt(this,wxt,null),knt(this,xxt,!1),knt(this,Axt,!1),Snt(vxt,this,t.bitmapUrl),Snt(mxt,this,t.bitmapFile)}static initialize(t,e){But.initialize(t,e)}static get supportedTypes(){return Vot(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>"image/".concat(t))))}static get supportedTypesStr(){return Vot(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(rot.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!(null===(t=this.altTextData)||void 0===t||!t.altText)}}static computeTelemetryFinalData(t){var e,r,n=t.get("hasAltText");return{hasAltText:null!==(e=n.get(!0))&&void 0!==e?e:0,hasNoAltText:null!==(r=n.get(!1))&&void 0!==r?r:0}}mlGuessAltText(){var t=arguments,e=this;return xnt((function*(){var r=t.length>0&&void 0!==t[0]?t[0]:null,n=!(t.length>1&&void 0!==t[1])||t[1];if(e.hasAltTextData())return null;var{mlManager:i}=e._uiManager;if(!i)throw new Error("No ML.");if(!(yield i.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");var{data:a,width:s,height:o}=r||e.copyCanvas(null,null,!0).imageData,l=yield i.guess({name:"altText",request:{data:a,width:s,height:o,channels:a.length/(s*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");var h=l.output;return yield e.setGuessedAltText(h),n&&!e.hasAltTextData()&&(e.altTextData={alt:h,decorative:!1}),h}))()}remove(){var t;_nt(fxt,this)&&(Snt(pxt,this,null),this._uiManager.imageManager.deleteId(_nt(fxt,this)),null===(t=_nt(bxt,this))||void 0===t||t.remove(),Snt(bxt,this,null),_nt(wxt,this)&&(clearTimeout(_nt(wxt,this)),Snt(wxt,this,null)));super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(_nt(fxt,this)&&null===_nt(bxt,this)&&bnt(_xt,this,Mxt).call(this),this.isAttachedToDOM||this.parent.add(this))):_nt(fxt,this)&&bnt(_xt,this,Mxt).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(_nt(gxt,this)||_nt(pxt,this)||_nt(vxt,this)||_nt(mxt,this)||_nt(fxt,this))}get isResizable(){return!0}render(){if(this.div)return this.div;var t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),_nt(pxt,this)?bnt(_xt,this,Txt).call(this):bnt(_xt,this,Mxt).call(this),this.width&&!this.annotationElementId){var[r,n]=this.parentDimensions;this.setAt(t*r,e*n,this.width*r,this.height*n)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(this.parent){null!==_nt(wxt,this)&&clearTimeout(_nt(wxt,this));Snt(wxt,this,setTimeout((()=>{Snt(wxt,this,null),bnt(_xt,this,Pxt).call(this)}),200))}}copyCanvas(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t||(t=224);var{width:n,height:i}=_nt(pxt,this),a=new Llt,s=_nt(pxt,this),o=n,l=i,h=null;if(e){var c,u;if(n>e||i>e){var d=Math.min(e/n,e/i);o=Math.floor(n*d),l=Math.floor(i*d)}var p=(h=document.createElement("canvas")).width=Math.ceil(o*a.sx),f=h.height=Math.ceil(l*a.sy);_nt(xxt,this)||(s=bnt(_xt,this,Cxt).call(this,p,f));var g=h.getContext("2d");g.filter=this._uiManager.hcmFilter;var v="white",m="#cfcfd8";"none"!==this._uiManager.hcmFilter?m="black":null!==(c=(u=window).matchMedia)&&void 0!==c&&c.call(u,"(prefers-color-scheme: dark)").matches&&(v="#8f8f9d",m="#42414d");var y=15*a.sx,b=15*a.sy,w=new OffscreenCanvas(2*y,2*b),x=w.getContext("2d");x.fillStyle=v,x.fillRect(0,0,2*y,2*b),x.fillStyle=m,x.fillRect(0,0,y,b),x.fillRect(y,b,y,b),g.fillStyle=g.createPattern(w,"repeat"),g.fillRect(0,0,p,f),g.drawImage(s,0,0,s.width,s.height,0,0,p,f)}var A=null;if(r){var _,k;if(a.symmetric&&s.width<t&&s.height<t)_=s.width,k=s.height;else if(s=_nt(pxt,this),n>t||i>t){var S=Math.min(t/n,t/i);_=Math.floor(n*S),k=Math.floor(i*S),_nt(xxt,this)||(s=bnt(_xt,this,Cxt).call(this,_,k))}var E=new OffscreenCanvas(_,k).getContext("2d",{willReadFrequently:!0});E.drawImage(s,0,0,s.width,s.height,0,0,_,k),A={width:_,height:k,data:E.getImageData(0,0,_,k).data}}return{canvas:h,width:o,height:l,imageData:A}}getImageForAltText(){return _nt(bxt,this)}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return xnt((function*(){var a=null;if(t instanceof Fmt){var s,{data:{rect:o,rotation:l,id:h,structParent:c,popupRef:u},container:d,parent:{page:{pageNumber:p}}}=t,f=d.querySelector("canvas"),g=r.imageManager.getFromCanvas(d.id,f);f.remove();var v=(null===(s=yield e._structTree.getAriaAttributes("".concat(dlt).concat(h)))||void 0===s?void 0:s.get("aria-label"))||"";a=t={annotationType:rot.STAMP,bitmapId:g.id,bitmap:g.bitmap,pageIndex:p-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:v},isSvg:!1,structParent:c,popupRef:u}}var m=yield n().call(i,t,e,r),{rect:y,bitmap:b,bitmapUrl:w,bitmapId:x,isSvg:A,accessibilityData:_}=t;x&&r.imageManager.isValidId(x)?(Snt(fxt,m,x),b&&Snt(pxt,m,b)):Snt(vxt,m,w),Snt(xxt,m,A);var[k,S]=m.pageDimensions;return m.width=(y[2]-y[0])/k,m.height=(y[3]-y[1])/S,m.annotationElementId=t.id||null,_&&(m.altTextData=_),m._initialData=a,Snt(Axt,m,!!a),m}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var r={annotationType:rot.STAMP,bitmapId:_nt(fxt,this),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:_nt(xxt,this),structTreeParentId:this._structTreeParentId};if(t)return r.bitmapUrl=bnt(_xt,this,Ixt).call(this,!0),r.accessibilityData=this.serializeAltText(!0),r;var{decorative:n,altText:i}=this.serializeAltText(!1);if(!n&&i&&(r.accessibilityData={type:"Figure",alt:i}),this.annotationElementId){var a,s=bnt(_xt,this,Rxt).call(this,r);if(s.isSame)return null;if(s.isSameAltText)delete r.accessibilityData;else r.accessibilityData.structParent=null!==(a=this._initialData.structParent)&&void 0!==a?a:-1}if(r.id=this.annotationElementId,null===e)return r;e.stamps||(e.stamps=new Map);var o=_nt(xxt,this)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(e.stamps.has(_nt(fxt,this))){if(_nt(xxt,this)){var l=e.stamps.get(_nt(fxt,this));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=bnt(_xt,this,Ixt).call(this,!1))}}else e.stamps.set(_nt(fxt,this),{area:o,serialized:r}),r.bitmap=bnt(_xt,this,Ixt).call(this,!1);return r}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}function Sxt(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?(Snt(pxt,this,t.bitmap),e||(Snt(fxt,this,t.id),Snt(xxt,this,t.isSvg)),t.file&&Snt(yxt,this,t.file.name),bnt(_xt,this,Txt).call(this)):this.remove()}function Ext(){if(Snt(gxt,this,null),this._uiManager.enableWaiting(!1),_nt(bxt,this)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_nt(pxt,this))return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_nt(pxt,this)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch(t){}}this.div.focus()}}function Mxt(){var t=this;if(_nt(fxt,this))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(_nt(fxt,this)).then((t=>bnt(_xt,this,Sxt).call(this,t,!0))).finally((()=>bnt(_xt,this,Ext).call(this)));if(_nt(vxt,this)){var e=_nt(vxt,this);return Snt(vxt,this,null),this._uiManager.enableWaiting(!0),void Snt(gxt,this,this._uiManager.imageManager.getFromUrl(e).then((t=>bnt(_xt,this,Sxt).call(this,t))).finally((()=>bnt(_xt,this,Ext).call(this))))}if(_nt(mxt,this)){var r=_nt(mxt,this);return Snt(mxt,this,null),this._uiManager.enableWaiting(!0),void Snt(gxt,this,this._uiManager.imageManager.getFromFile(r).then((t=>bnt(_xt,this,Sxt).call(this,t))).finally((()=>bnt(_xt,this,Ext).call(this))))}var n=document.createElement("input");n.type="file",n.accept=Nst.supportedTypesStr;var i=this._uiManager._signal;Snt(gxt,this,new Promise((e=>{n.addEventListener("change",xnt((function*(){if(n.files&&0!==n.files.length){t._uiManager.enableWaiting(!0);var r=yield t._uiManager.imageManager.getFromFile(n.files[0]);t._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:t._uiManager.useNewAltTextFlow}}),bnt(_xt,t,Sxt).call(t,r)}else t.remove();e()})),{signal:i}),n.addEventListener("cancel",(()=>{this.remove(),e()}),{signal:i})})).finally((()=>bnt(_xt,this,Ext).call(this)))),n.click()}function Txt(){var t,{div:e}=this,{width:r,height:n}=_nt(pxt,this),[i,a]=this.pageDimensions,s=.75;if(this.width)r=this.width*i,n=this.height*a;else if(r>s*i||n>s*a){var o=Math.min(s*i/r,s*a/n);r*=o,n*=o}var[l,h]=this.parentDimensions;this.setDims(r*l/i,n*h/a),this._uiManager.enableWaiting(!1);var c=Snt(bxt,this,document.createElement("canvas"));c.setAttribute("role","img"),this.addContainer(c),this.width=r/i,this.height=n/a,null!==(t=this._initialOptions)&&void 0!==t&&t.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),bnt(_xt,this,Pxt).call(this),_nt(Axt,this)||(this.parent.addUndoableEditor(this),Snt(Axt,this,!0)),this._reportTelemetry({action:"inserted_image"}),_nt(yxt,this)&&c.setAttribute("aria-label",_nt(yxt,this))}function Cxt(t,e){for(var{width:r,height:n}=_nt(pxt,this),i=r,a=n,s=_nt(pxt,this);i>2*t||a>2*e;){var o=i,l=a;i>2*t&&(i=i>=16384?Math.floor(i/2)-1:Math.ceil(i/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));var h=new OffscreenCanvas(i,a);h.getContext("2d").drawImage(s,0,0,o,l,0,0,i,a),s=h.transferToImageBitmap()}return s}function Pxt(){var[t,e]=this.parentDimensions,{width:r,height:n}=this,i=new Llt,a=Math.ceil(r*t*i.sx),s=Math.ceil(n*e*i.sy),o=_nt(bxt,this);if(o&&(o.width!==a||o.height!==s)){o.width=a,o.height=s;var l=_nt(xxt,this)?_nt(pxt,this):bnt(_xt,this,Cxt).call(this,a,s),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,s)}}function Ixt(t){if(t){if(_nt(xxt,this)){var e=this._uiManager.imageManager.getSvgUrl(_nt(fxt,this));if(e)return e}var r=document.createElement("canvas");return({width:r.width,height:r.height}=_nt(pxt,this)),r.getContext("2d").drawImage(_nt(pxt,this),0,0),r.toDataURL()}if(_nt(xxt,this)){var[n,i]=this.pageDimensions,a=Math.round(this.width*n*flt.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*flt.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(a,s);return o.getContext("2d").drawImage(_nt(pxt,this),0,0,_nt(pxt,this).width,_nt(pxt,this).height,0,0,a,s),o.transferToImageBitmap()}return structuredClone(_nt(pxt,this))}function Rxt(t){var e,{pageIndex:r,accessibilityData:{altText:n}}=this._initialData,i=t.pageIndex===r,a=((null===(e=t.accessibilityData)||void 0===e?void 0:e.alt)||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&i&&a,isSameAltText:a}}Nst=kxt,Tnt(kxt,"_type","stamp"),Tnt(kxt,"_editorType",rot.STAMP);var Oxt=new WeakMap,Lxt=new WeakMap,Dxt=new WeakMap,Fxt=new WeakMap,Nxt=new WeakMap,jxt=new WeakMap,Bxt=new WeakMap,zxt=new WeakMap,Wxt=new WeakMap,Uxt=new WeakMap,Hxt=new WeakMap,Gxt=new WeakMap,Yxt=new WeakMap,Vxt=new WeakMap,qxt=new WeakSet;class Xxt{constructor(t){var{uiManager:e,pageIndex:r,div:n,structTreeLayer:i,accessibilityManager:a,annotationLayer:s,drawLayer:o,textLayer:l,viewport:h,l10n:c}=t;Mnt(this,qxt),knt(this,Oxt,void 0),knt(this,Lxt,!1),knt(this,Dxt,null),knt(this,Fxt,null),knt(this,Nxt,null),knt(this,jxt,new Map),knt(this,Bxt,!1),knt(this,zxt,!1),knt(this,Wxt,!1),knt(this,Uxt,null),knt(this,Hxt,null),knt(this,Gxt,null),knt(this,Yxt,null),knt(this,Vxt,void 0);var u=[...tAt._.values()];if(!Xxt._initialized)for(var d of(Xxt._initialized=!0,u))d.initialize(c,e);e.registerEditorTypes(u),Snt(Vxt,this,e),this.pageIndex=r,this.div=n,Snt(Oxt,this,a),Snt(Dxt,this,s),this.viewport=h,Snt(Gxt,this,l),this.drawLayer=o,this._structTree=i,_nt(Vxt,this).addLayer(this)}get isEmpty(){return 0===_nt(jxt,this).size}get isInvisible(){return this.isEmpty&&_nt(Vxt,this).getMode()===rot.NONE}updateToolbar(t){_nt(Vxt,this).updateToolbar(t)}updateMode(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_nt(Vxt,this).getMode();switch(bnt(qxt,this,Zxt).call(this),t){case rot.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case rot.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case rot.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);var{classList:e}=this.div;for(var r of tAt._.values())e.toggle("".concat(r._type,"Editing"),t===r._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===(null===(e=_nt(Gxt,this))||void 0===e?void 0:e.div)}setEditingState(t){_nt(Vxt,this).setEditingState(t)}addCommands(t){_nt(Vxt,this).addCommands(t)}cleanUndoStack(t){_nt(Vxt,this).cleanUndoStack(t)}toggleDrawing(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("drawing",!t)}togglePointerEvents(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];null===(t=_nt(Dxt,this))||void 0===t||t.div.classList.toggle("disabled",!e)}enable(){var t=this;return xnt((function*(){Snt(Wxt,t,!0),t.div.tabIndex=0,t.togglePointerEvents(!0);var e=new Set;for(var r of _nt(jxt,t).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(_nt(Vxt,t).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(_nt(Dxt,t)){var n=_nt(Dxt,t).getEditableAnnotations();for(var i of n)if(i.hide(),!_nt(Vxt,t).isDeletedAnnotationElement(i.data.id)&&!e.has(i.data.id)){var a=yield t.deserialize(i);a&&(t.addOrRebuild(a),a.enableEditing())}Snt(Wxt,t,!1)}else Snt(Wxt,t,!1)}))()}disable(){Snt(zxt,this,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);var t=new Map,e=new Map;for(var r of _nt(jxt,this).values()){var n;r.disableEditing(),r.annotationElementId&&(null===r.serialize()?(e.set(r.annotationElementId,r),null===(n=this.getEditableAnnotation(r.annotationElementId))||void 0===n||n.show(),r.remove()):t.set(r.annotationElementId,r))}if(_nt(Dxt,this)){var i=_nt(Dxt,this).getEditableAnnotations();for(var a of i){var{id:s}=a.data;if(!_nt(Vxt,this).isDeletedAnnotationElement(s)){var o=e.get(s);o?(o.resetAnnotationElement(a),o.show(!1),a.show()):((o=t.get(s))&&(_nt(Vxt,this).addChangedExistingAnnotation(o),o.renderAnnotationElement(a)&&o.show(!1)),a.show())}}}bnt(qxt,this,Zxt).call(this),this.isEmpty&&(this.div.hidden=!0);var{classList:l}=this.div;for(var h of tAt._.values())l.remove("".concat(h._type,"Editing"));this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),Snt(zxt,this,!1)}getEditableAnnotation(t){var e;return(null===(e=_nt(Dxt,this))||void 0===e?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){_nt(Vxt,this).getActive()!==t&&_nt(Vxt,this).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,null!==(t=_nt(Gxt,this))&&void 0!==t&&t.div&&!_nt(Yxt,this)){Snt(Yxt,this,new AbortController);var e=_nt(Vxt,this).combinedSignal(_nt(Yxt,this));_nt(Gxt,this).div.addEventListener("pointerdown",bnt(qxt,this,$xt).bind(this),{signal:e}),_nt(Gxt,this).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,null!==(t=_nt(Gxt,this))&&void 0!==t&&t.div&&_nt(Yxt,this)&&(_nt(Yxt,this).abort(),Snt(Yxt,this,null),_nt(Gxt,this).div.classList.remove("highlighting"))}enableClick(){if(!_nt(Fxt,this)){Snt(Fxt,this,new AbortController);var t=_nt(Vxt,this).combinedSignal(_nt(Fxt,this));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});var e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}}disableClick(){var t;null===(t=_nt(Fxt,this))||void 0===t||t.abort(),Snt(Fxt,this,null)}attach(t){_nt(jxt,this).set(t.id,t);var{annotationElementId:e}=t;e&&_nt(Vxt,this).isDeletedAnnotationElement(e)&&_nt(Vxt,this).removeDeletedAnnotationElement(t)}detach(t){var e;_nt(jxt,this).delete(t.id),null===(e=_nt(Oxt,this))||void 0===e||e.removePointerInTextLayer(t.contentDiv),!_nt(zxt,this)&&t.annotationElementId&&_nt(Vxt,this).addDeletedAnnotationElement(t)}remove(t){this.detach(t),_nt(Vxt,this).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(_nt(Vxt,this).addDeletedAnnotationElement(t.annotationElementId),But.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),null===(e=t.parent)||void 0===e||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),_nt(Vxt,this).addEditor(t),this.attach(t),!t.isAttachedToDOM){var e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!_nt(Wxt,this)),_nt(Vxt,this).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(t.isAttachedToDOM){var{activeElement:r}=document;t.div.contains(r)&&!_nt(Nxt,this)&&(t._focusEventsAllowed=!1,Snt(Nxt,this,setTimeout((()=>{Snt(Nxt,this,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:_nt(Vxt,this)._signal}),r.focus())}),0))),t._structTreeParentId=null===(e=_nt(Oxt,this))||void 0===e?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return _nt(Vxt,this).getId()}combinedSignal(t){return _nt(Vxt,this).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null===(t=Ent(qxt,this,Kxt))||void 0===t?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){_nt(Vxt,this).updateToolbar(t),_nt(Vxt,this).updateMode(t);var{offsetX:r,offsetY:n}=bnt(qxt,this,Jxt).call(this),i=this.getNextId(),a=bnt(qxt,this,Qxt).call(this,Pnt({parent:this,id:i,x:r,y:n,uiManager:_nt(Vxt,this),isCentered:!0},e));a&&this.add(a)}deserialize(t){var e=this;return xnt((function*(){var r,n;return(yield null===(r=tAt._.get(null!==(n=t.annotationType)&&void 0!==n?n:t.annotationEditorType))||void 0===r?void 0:r.deserialize(t,e,_nt(Vxt,e)))||null}))()}createAndAddNewEditor(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getNextId(),i=bnt(qxt,this,Qxt).call(this,Pnt({parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:_nt(Vxt,this),isCentered:e},r));return i&&this.add(i),i}addNewEditor(){this.createAndAddNewEditor(bnt(qxt,this,Jxt).call(this),!0)}setSelected(t){_nt(Vxt,this).setSelected(t)}toggleSelected(t){_nt(Vxt,this).toggleSelected(t)}unselect(t){_nt(Vxt,this).unselect(t)}pointerup(t){var e,{isMac:r}=ilt.platform;0!==t.button||t.ctrlKey&&r||t.target===this.div&&_nt(Bxt,this)&&(Snt(Bxt,this,!1),null!==(e=Ent(qxt,this,Kxt))&&void 0!==e&&e.isDrawer&&Ent(qxt,this,Kxt).supportMultipleDrawings||(_nt(Lxt,this)?_nt(Vxt,this).getMode()!==rot.STAMP?this.createAndAddNewEditor(t,!1):_nt(Vxt,this).unselectAll():Snt(Lxt,this,!0)))}pointerdown(t){var e;if(_nt(Vxt,this).getMode()===rot.HIGHLIGHT&&this.enableTextSelection(),_nt(Bxt,this))Snt(Bxt,this,!1);else{var{isMac:r}=ilt.platform;if(!(0!==t.button||t.ctrlKey&&r)&&t.target===this.div)if(Snt(Bxt,this,!0),null!==(e=Ent(qxt,this,Kxt))&&void 0!==e&&e.isDrawer)this.startDrawingSession(t);else{var n=_nt(Vxt,this).getActive();Snt(Lxt,this,!n||n.isEmpty())}}}startDrawingSession(t){if(this.div.focus(),_nt(Uxt,this))Ent(qxt,this,Kxt).startDrawing(this,_nt(Vxt,this),!1,t);else{_nt(Vxt,this).setCurrentDrawingSession(this),Snt(Uxt,this,new AbortController);var e=_nt(Vxt,this).combinedSignal(_nt(Uxt,this));this.div.addEventListener("blur",(t=>{var{relatedTarget:e}=t;e&&!this.div.contains(e)&&(Snt(Hxt,this,null),this.commitOrRemove())}),{signal:e}),Ent(qxt,this,Kxt).startDrawing(this,_nt(Vxt,this),!1,t)}}pause(t){if(t){var{activeElement:e}=document;this.div.contains(e)&&Snt(Hxt,this,e)}else _nt(Hxt,this)&&setTimeout((()=>{var t;null===(t=_nt(Hxt,this))||void 0===t||t.focus(),Snt(Hxt,this,null)}),0)}endDrawingSession(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return _nt(Uxt,this)?(_nt(Vxt,this).setCurrentDrawingSession(null),_nt(Uxt,this).abort(),Snt(Uxt,this,null),Snt(Hxt,this,null),Ent(qxt,this,Kxt).endDrawing(t)):null}findNewParent(t,e,r){var n=_nt(Vxt,this).findParent(e,r);return null!==n&&n!==this&&(n.changeParent(t),!0)}commitOrRemove(){return!!_nt(Uxt,this)&&(this.endDrawingSession(),!0)}onScaleChanging(){_nt(Uxt,this)&&Ent(qxt,this,Kxt).onScaleChangingWhenDrawing(this)}destroy(){var t;for(var e of(this.commitOrRemove(),(null===(t=_nt(Vxt,this).getActive())||void 0===t?void 0:t.parent)===this&&(_nt(Vxt,this).commitOrRemove(),_nt(Vxt,this).setActiveEditor(null)),_nt(Nxt,this)&&(clearTimeout(_nt(Nxt,this)),Snt(Nxt,this,null)),_nt(jxt,this).values())){var r;null===(r=_nt(Oxt,this))||void 0===r||r.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove()}this.div=null,_nt(jxt,this).clear(),_nt(Vxt,this).removeLayer(this)}render(t){var{viewport:e}=t;for(var r of(this.viewport=e,Olt(this.div,e),_nt(Vxt,this).getEditors(this.pageIndex)))this.add(r),r.rebuild();this.updateMode()}update(t){var{viewport:e}=t;_nt(Vxt,this).commitOrRemove(),bnt(qxt,this,Zxt).call(this);var r=this.viewport.rotation,n=e.rotation;if(this.viewport=e,Olt(this.div,{rotation:n}),r!==n)for(var i of _nt(jxt,this).values())i.rotate(n)}get pageDimensions(){var{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return _nt(Vxt,this).viewParameters.realScale}}function $xt(t){_nt(Vxt,this).unselectAll();var{target:e}=t;if(e===_nt(Gxt,this).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&_nt(Gxt,this).div.contains(e)){var{isMac:r}=ilt.platform;if(0!==t.button||t.ctrlKey&&r)return;_nt(Vxt,this).showAllEditors("highlight",!0,!0),_nt(Gxt,this).div.classList.add("free"),this.toggleDrawing(),$bt.startHighlighting(this,"ltr"===_nt(Vxt,this).direction,{target:_nt(Gxt,this).div,x:t.x,y:t.y}),_nt(Gxt,this).div.addEventListener("pointerup",(()=>{_nt(Gxt,this).div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:_nt(Vxt,this)._signal}),t.preventDefault()}}function Kxt(t){return tAt._.get(_nt(Vxt,t).getMode())}function Qxt(t){var e=Ent(qxt,this,Kxt);return e?new e.prototype.constructor(t):null}function Jxt(){var{x:t,y:e,width:r,height:n}=this.div.getBoundingClientRect(),i=Math.max(0,t),a=Math.max(0,e),s=(i+Math.min(window.innerWidth,t+r))/2-t,o=(a+Math.min(window.innerHeight,e+n))/2-e,[l,h]=this.viewport.rotation%180==0?[s,o]:[o,s];return{offsetX:l,offsetY:h}}function Zxt(){for(var t of _nt(jxt,this).values())t.isEmpty()&&t.remove()}Tnt(Xxt,"_initialized",!1);var tAt={_:new Map([nyt,uxt,kxt,$bt].map((t=>[t._editorType,t])))},eAt=new WeakMap,rAt=new WeakMap,nAt=new WeakMap,iAt=new WeakMap,aAt=new WeakSet;class sAt{constructor(t){var{pageIndex:e}=t;Mnt(this,aAt),knt(this,eAt,null),knt(this,rAt,0),knt(this,nAt,new Map),knt(this,iAt,new Map),this.pageIndex=e}setParent(t){if(_nt(eAt,this)){if(_nt(eAt,this)!==t){if(_nt(nAt,this).size>0)for(var e of _nt(nAt,this).values())e.remove(),t.append(e);Snt(eAt,this,t)}}else Snt(eAt,this,t)}static get _svgFactory(){return Vot(this,"_svgFactory",new fvt)}draw(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=(Snt(rAt,this,(e=_nt(rAt,this),r=e++,e)),r),s=bnt(aAt,this,lAt).call(this),o=sAt._svgFactory.createElement("defs");s.append(o);var l=sAt._svgFactory.createElement("path");o.append(l);var h="path_p".concat(this.pageIndex,"_").concat(a);l.setAttribute("id",h),l.setAttribute("vector-effect","non-scaling-stroke"),n&&_nt(iAt,this).set(a,l);var c=i?bnt(aAt,this,hAt).call(this,o,h):null,u=sAt._svgFactory.createElement("use");return s.append(u),u.setAttribute("href","#".concat(h)),this.updateProperties(s,t),_nt(nAt,this).set(a,s),{id:a,clipPathId:"url(#".concat(c,")")}}drawOutline(t,e){var r,n,i=(Snt(rAt,this,(r=_nt(rAt,this),n=r++,r)),n),a=bnt(aAt,this,lAt).call(this),s=sAt._svgFactory.createElement("defs");a.append(s);var o=sAt._svgFactory.createElement("path");s.append(o);var l,h="path_p".concat(this.pageIndex,"_").concat(i);if(o.setAttribute("id",h),o.setAttribute("vector-effect","non-scaling-stroke"),e){var c=sAt._svgFactory.createElement("mask");s.append(c),l="mask_p".concat(this.pageIndex,"_").concat(i),c.setAttribute("id",l),c.setAttribute("maskUnits","objectBoundingBox");var u=sAt._svgFactory.createElement("rect");c.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");var d=sAt._svgFactory.createElement("use");c.append(d),d.setAttribute("href","#".concat(h)),d.setAttribute("stroke","none"),d.setAttribute("fill","black"),d.setAttribute("fill-rule","nonzero"),d.classList.add("mask")}var p=sAt._svgFactory.createElement("use");a.append(p),p.setAttribute("href","#".concat(h)),l&&p.setAttribute("mask","url(#".concat(l,")"));var f=p.cloneNode();return a.append(f),p.classList.add("mainOutline"),f.classList.add("secondaryOutline"),this.updateProperties(a,t),_nt(nAt,this).set(i,a),i}finalizeDraw(t,e){_nt(iAt,this).delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(e){var{root:r,bbox:n,rootClass:i,path:a}=e,s="number"==typeof t?_nt(nAt,this).get(t):t;if(s){if(r&&bnt(aAt,this,cAt).call(this,s,r),n&&oAt.call(sAt,s,n),i){var{classList:o}=s;for(var[l,h]of Object.entries(i))o.toggle(l,h)}if(a){var c=s.firstChild.firstChild;bnt(aAt,this,cAt).call(this,c,a)}}}}updateParent(t,e){if(e!==this){var r=_nt(nAt,this).get(t);r&&(_nt(eAt,e).append(r),_nt(nAt,this).delete(t),_nt(nAt,e).set(t,r))}}remove(t){_nt(iAt,this).delete(t),null!==_nt(eAt,this)&&(_nt(nAt,this).get(t).remove(),_nt(nAt,this).delete(t))}destroy(){for(var t of(Snt(eAt,this,null),_nt(nAt,this).values()))t.remove();_nt(nAt,this).clear(),_nt(iAt,this).clear()}}function oAt(t,e){var[r,n,i,a]=e,{style:s}=t;s.top="".concat(100*n,"%"),s.left="".concat(100*r,"%"),s.width="".concat(100*i,"%"),s.height="".concat(100*a,"%")}function lAt(){var t=jst._svgFactory.create(1,1,!0);return _nt(eAt,this).append(t),t.setAttribute("aria-hidden",!0),t}function hAt(t,e){var r=jst._svgFactory.createElement("clipPath");t.append(r);var n="clip_".concat(e);r.setAttribute("id",n),r.setAttribute("clipPathUnits","objectBoundingBox");var i=jst._svgFactory.createElement("use");return r.append(i),i.setAttribute("href","#".concat(e)),i.classList.add("clip"),n}function cAt(t,e){for(var[r,n]of Object.entries(e))null===n?t.removeAttribute(r):t.setAttribute(r,n)}jst=sAt,globalThis.pdfjsTestingUtils={HighlightOutliner:Zyt};var uAt=Ust.getDocument;Ust.GlobalWorkerOptions.workerSrc="/node_modules/pdfjs-dist/build/pdf.worker.min.mjs";const dAt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}},{type:"attachment-selector",label:"file",name:"file",property:{displayField:"fullpath",displayFullUrl:!0,storageFilters:{type:Array,value:[{name:"category",value:"application"}]},useUpload:!0}},{type:"number",label:"page",name:"page"},{type:"select",label:"fit",name:"fit",property:{options:["none","ratio","width","height"]}}],help:"scene/component/pdf-viewer"},pAt=[2,4,8,16,32],fAt=16e3;class gAt extends(wtt(ytt)){async ready(){this.scaleIndex=0,this.displayScale=1,this.offsetX=0,this.offsetY=0,this.pdfDoc=null,this.canvas=document.createElement("canvas"),this.renderTask=null,this.loadPDF()}dispose(){super.dispose(),this.worker&&(this.worker.terminate(),this.worker=null),this.renderTask&&this.renderTask.cancel(),this.pdfDoc=null,this.canvas=null}async loadPDF(){const{file:t,page:e=1}=this.state;if(t)try{console.log(`📌 Loading PDF: ${t}`),this.pdfDoc=await uAt(t).promise;const r=this.pdfDoc.numPages;this.page=await this.pdfDoc.getPage(e>r?1:e),this.documentSize=this.page.getViewport({scale:1}),this.fit()}catch(t){console.error("🚨 Failed to load PDF:",t)}}onchange(t,e){("file"in t||"fit"in t||"page"in t)&&this.loadPDF()}async fit(){const{fit:t="none"}=this.state,{width:e,height:r}=this.bounds,n=this.documentSize;switch(t){case"none":default:this.displayScale=1;break;case"width":this.displayScale=e/n.width;break;case"height":this.displayScale=r/n.height;break;case"ratio":this.displayScale=Math.min(e/n.width,r/n.height)}this.scaleIndex=pAt.findIndex((t=>this.displayScale<=t)),-1===this.scaleIndex&&(this.scaleIndex=pAt.length-1),"ratio"===t?(this.offsetX=(e-n.width*this.displayScale)/2,this.offsetY=(r-n.height*this.displayScale)/2):(this.offsetX=0,this.offsetY=0),this.renderPDF()}async renderPDF(){if(!this.pdfDoc||!this.page)return;const{width:t,height:e}=this.documentSize;let r=pAt[this.scaleIndex],n=Math.min(t*r,fAt),i=Math.min(e*r,fAt);if(n===fAt||i===fAt){const a=t/e;a>1&&(i=n/a);const s=i/e;this.scaleIndex=pAt.findIndex((t=>s<=t))-1,r=pAt[this.scaleIndex],n=t*r,i=e*r}const a=document.createElement("canvas");a.width=n,a.height=i;const s={canvasContext:a.getContext("2d"),viewport:this.page.getViewport({scale:r})};if(this.renderTask){this.renderTask.cancel();try{await this.renderTask.promise}catch(t){console.warn("Previous render task was canceled.")}}this.renderTask=this.page.render(s);try{await this.renderTask.promise,this.canvas=a,this.renderTask=null,this.invalidate()}catch(t){"RenderingCancelledException"!==t.name&&console.error("Failed to render PDF:",t)}}render(t){super.render(t);const{left:e,top:r}=this.bounds,{width:n,height:i}=this.canvas;t.clip(),t.drawImage(this.canvas,e+this.offsetX,r+this.offsetY,(this.documentSize?.width||n)*this.displayScale,(this.documentSize?.height||i)*this.displayScale)}onwheel(t){t.preventDefault();var{left:e,top:r}=this.bounds,{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);n-=e,i-=r;const a=t.deltaY<0?1.05:.95,s=this.displayScale;this.displayScale=Math.min(Math.max(.5,this.displayScale*a),pAt[pAt.length-1]);const o=pAt.findIndex((t=>this.displayScale<=t)),l=-1===o?pAt.length-1:o,h=this.displayScale/s;this.offsetX=n-(n-this.offsetX)*h,this.offsetY=i-(i-this.offsetY)*h,this.invalidate(),l!==this.scaleIndex&&(this.scaleIndex=l,this.renderPDF())}ondragstart(t){this.position=this.transcoordC2S(t.offsetX,t.offsetY)}ondragmove(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);const n=e-this.position.x,i=r-this.position.y;this.offsetX+=n,this.offsetY+=i,this.position={x:e,y:r},this.invalidate()}ondblclick(t){this.fit()}get nature(){return dAt}}mtt.register("pdf-page",gAt);var vAt=t=>class extends t{animOnValueChange(t,e=!1,r){if(t!=this._lastValue){if(e)var n=t-(Number(r)||0);else n=t-(this._lastValue||0);this._lastValue=t,this._anim_alpha=-n,this.animate({step:t=>{this._anim_alpha=n*(t-1),this.invalidate()},duration:1e3,delta:"circ",options:{x:1},ease:"out"}).start()}}dispose(){super.dispose(),delete this._value_substitutor}onchange(t,e){t.hasOwnProperty("value")&&delete this._value_substitutor}get animAlpha(){return this._anim_alpha||0}get animValue(){return(this._lastValue||0)+(this._anim_alpha||0)}defaultValueSubstitutor(){return this.getState("value")}get valueSubstitutor(){return this._value_substitutor||(this._value_substitutor=att(this.getState("value"),this)||this.defaultValueSubstitutor),this._value_substitutor}get value(){return Number(this.valueSubstitutor())||0}set value(t){delete this._value_substitutor,this.setState("value",Number(P7(t)))}},mAt=t=>class extends t{_convertDataFormat(t,e){var r;if("json"===e)r=JSON.parse(t);else r=t;return r}isDataSource(){return!0}},yAt=0;const bAt=new FinalizationRegistry((()=>{yAt--}));class wAt{static get residents(){return yAt}static get residentsCount(){return yAt}constructor(t,e){this.counters={},this.references={},this.creator=t,this.disposer=e,yAt++,bAt.register(this,yAt)}dispose(){if(this.disposer)for(let t in this.references)this.disposer.call(null,t,this.references[t]);delete this.references,delete this.counters}get ids(){return Object.keys(this.references)}create(t){var e=this;return new Promise((function(r,n){e.creator?e.creator.call(null,t,(function(e){!function(e){e.release=function(){this.disposer&&this.disposer.call(null,t,e),delete e.release,G7("RELEASED",t)},r(e)}(e)}),(function(t){n(t)})):n(Error("Reference id("+t+") could not be created. Reference creator should be defined."))}))}add(t,e){var r=this,n=new Promise((function(n,i){var a=r.references[t];if(a)a===e?i(Error("Reference ID and target duplicate")):e?i(Error("Reference ID duplicate")):n(a);else{function s(e){e.release=function(){r.release(this)},r.references[t]=e,r.counters[t]=1,n(e)}if(e)s(e);else{if(!r.creator)return void i(Error("Reference id("+t+") is not allowed. Reference creator should be defined."));r.creator.call(null,t,(function(t){s(t)}),(function(t){i(t)}))}}}));return this.references[t]||(this.references[t]=n),n}async get(t,e){var r=this.references[t];if(r){if(!(r instanceof Promise)){if(!(t in this.counters))throw new Error("No Reference Count");return this.counters[t]++,r}if(e)return r=await r,this.counters[t]++,r}if(e)return await this.add(t);throw new Error("No References for "+t)}_id(t){for(let e in this.references){if(this.references[e]===t)return e}return-1}release(t){var e=this._id(t),r=this.references[e];r?(this.counters[e]--,0==this.counters[e]&&(this.disposer&&this.disposer.call(null,e,r),delete this.references[e],delete this.counters[e],delete t.release,G7("RELEASED",e))):U7("No Referenced ID")}}var xAt={},AAt={},_At=[];function kAt(t){var e="SCRIPT"==t.target.tagName?xAt:AAt,r=t.target.src||t.target.href;e[r]=!0,_At.forEach(((t,n)=>{let{resolve:i,scripts:a,styles:s}=t;if(e==xAt){let t=a.indexOf(r);t>-1&&t<a.length-1&&EAt(a[t+1])}for(let t=0;t<a.length;t++)if(!xAt[a[t]])return;if(s)for(let t=0;t<s.length;t++)if(!AAt[s[t]])return;i(),_At[n]=null})),_At=_At.filter(Boolean)}function SAt(t){var e=t.target.src,r="SCRIPT"==t.target.tagName?xAt:AAt;_At.forEach(((n,i)=>{let{reject:a,scripts:s,styles:o}=n,l=!1;if(r===xAt){for(let t=0;t<s.length;t++)if(s[t]==e){l=!0;break}}else if(o)for(let t=0;t<o.length;t++)if(o[t]==e){l=!0;break}l&&(a(t),_At[i]=null)})),_At=_At.filter(Boolean),delete r[e],document.head.removeChild(t.target)}function EAt(t){xAt[t]=!1;var e=document.createElement("script");e.onload=kAt,e.onerror=SAt,e.type="text/javascript",e.src=t,document.head.appendChild(e)}class MAt{static load(t,e){return"string"==typeof t&&(t=[t]),"string"==typeof e&&(e=[e]),new Promise((function(r,n){if((!t||t instanceof Array)&&(!e||e instanceof Array)){var i,a=!0;if(e&&e.forEach((t=>{AAt.hasOwnProperty(t)||function(t){AAt[t]=!1;var e=document.createElement("link");e.onload=kAt,e.onerror=SAt,e.type="text/css",e.rel="stylesheet",e.media="screen,print",e.href=t,document.head.appendChild(e)}(t),AAt[t]||(a=!1)})),t&&t.length>0&&t.forEach((t=>{xAt.hasOwnProperty(t)?xAt[t]||(a=!1):i=i||t})),i)EAt(i);else if(a)return void r();_At.push({resolve:r,reject:n,scripts:t,styles:e})}else n("invalid sources for load")}))}}const TAt="0.0.0";var CAt=0,PAt=performance.now(),IAt=0;function RAt(){return CAt}requestAnimationFrame((function t(){requestAnimationFrame(t),IAt++;var e=performance.now(),r=e-PAt;r<1e3||(CAt=Math.round(1e3*IAt/r),PAt=e,IAt=0)}));var OAt=Let;function LAt(){}export{Ott as AbsoluteLayout,lst as AudioPlayer,Dtt as CardLayout,mtt as Component,Qtt as Connectable,bat as Container,Gtt as ContainerAbstract,i9 as DEFAULT,e9 as DPPX,mAt as DataSource,kst as Donut,Dat as Ellipse,hnt as EventMap,RAt as FPS,r9 as GESTURES,sst as GifView,vst as GlobalRef,ust as Group,Mtt as HTMLAbsoluteLayout,fst as HTMLOverlayContainer,Vat as HTMLOverlayElement,Yat as ImageView,ktt as InfoWindow,n9 as KEYEVENTS,Ytt as Layer,Ett as Layout,Oat as Line,Ntt as LinearHorizontalLayout,Btt as LinearVerticalLayout,pst as LocalRef,t9 as MAX_UNDO_SIZE,K7 as MODE_ADD,X7 as MODE_EDIT,J7 as MODE_PASTE_DATABIND,Q7 as MODE_PASTE_STYLE,$7 as MODE_SHIFT,q7 as MODE_VIEW,OAt as Model,Utt as MoveHandle,V7 as NOTHING,Hat as OrthoLine,gAt as PDFPage,bst as Path,jat as Polygon,Wat as Polyline,yst as Popup,tet as Rect,wtt as RectPath,wAt as ReferenceMap,Bnt as RootContainer,ret as Ruler,Z7 as SCENE_MODE,Znt as Scene,Rtt as ScenePopup,MAt as ScriptLoader,ytt as Shape,zst as Star,ztt as TableLayout,hst as Text,xst as Triangle,vAt as ValueHolder,eit as create,G7 as debug,U7 as error,LAt as license,k4 as polyfill,TAt as version,H7 as warn};console.log("@hatiolab/things-scene@9.0.0-beta.22 is loaded");