@gamelearn/arcade-components 3.23.0 → 3.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,7 +66,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
66
66
  `,FORWARD_SLASH="/",ASTERISK="*",EMPTY_STRING$1="",TYPE_COMMENT="comment",TYPE_DECLARATION="declaration",inlineStyleParser=function(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");if(!l)return[];e=e||{};var n=1,t=1;function a(S){var g=S.match(NEWLINE_REGEX);g&&(n+=g.length);var y=S.lastIndexOf(NEWLINE);t=~y?S.length-y:t+S.length}function o(){var S={line:n,column:t};return function(g){return g.position=new d(S),u(),g}}function d(S){this.start=S,this.end={line:n,column:t},this.source=e.source}d.prototype.content=l;function h(S){var g=new Error(e.source+":"+n+":"+t+": "+S);if(g.reason=S,g.filename=e.source,g.line=n,g.column=t,g.source=l,!e.silent)throw g}function f(S){var g=S.exec(l);if(g){var y=g[0];return a(y),l=l.slice(y.length),g}}function u(){f(WHITESPACE_REGEX)}function p(S){var g;for(S=S||[];g=E();)g!==!1&&S.push(g);return S}function E(){var S=o();if(!(FORWARD_SLASH!=l.charAt(0)||ASTERISK!=l.charAt(1))){for(var g=2;EMPTY_STRING$1!=l.charAt(g)&&(ASTERISK!=l.charAt(g)||FORWARD_SLASH!=l.charAt(g+1));)++g;if(g+=2,EMPTY_STRING$1===l.charAt(g-1))return h("End of comment missing");var y=l.slice(2,g-2);return t+=2,a(y),l=l.slice(g),t+=2,S({type:TYPE_COMMENT,comment:y})}}function T(){var S=o(),g=f(PROPERTY_REGEX);if(g){if(E(),!f(COLON_REGEX))return h("property missing ':'");var y=f(VALUE_REGEX),b=S({type:TYPE_DECLARATION,property:trim(g[0].replace(COMMENT_REGEX,EMPTY_STRING$1)),value:y?trim(y[0].replace(COMMENT_REGEX,EMPTY_STRING$1)):EMPTY_STRING$1});return f(SEMICOLON_REGEX),b}}function v(){var S=[];p(S);for(var g;g=T();)g!==!1&&(S.push(g),p(S));return S}return u(),v()};function trim(l){return l?l.replace(TRIM_REGEX,EMPTY_STRING$1):EMPTY_STRING$1}var parse=inlineStyleParser;function StyleToObject(l,e){var n=null;if(!l||typeof l!="string")return n;for(var t,a=parse(l),o=typeof e=="function",d,h,f=0,u=a.length;f<u;f++)t=a[f],d=t.property,h=t.value,o?e(d,h,t):h&&(n||(n={}),n[d]=h);return n}var styleToObject=StyleToObject,utilities$4={};utilities$4.__esModule=!0;utilities$4.camelCase=void 0;var CUSTOM_PROPERTY_REGEX=/^--[a-zA-Z0-9-]+$/,HYPHEN_REGEX=/-([a-z])/g,NO_HYPHEN_REGEX=/^[^-]+$/,VENDOR_PREFIX_REGEX=/^-(webkit|moz|ms|o|khtml)-/,MS_VENDOR_PREFIX_REGEX=/^-(ms)-/,skipCamelCase=function(l){return!l||NO_HYPHEN_REGEX.test(l)||CUSTOM_PROPERTY_REGEX.test(l)},capitalize=function(l,e){return e.toUpperCase()},trimHyphen=function(l,e){return"".concat(e,"-")},camelCase=function(l,e){return e===void 0&&(e={}),skipCamelCase(l)?l:(l=l.toLowerCase(),e.reactCompat?l=l.replace(MS_VENDOR_PREFIX_REGEX,trimHyphen):l=l.replace(VENDOR_PREFIX_REGEX,trimHyphen),l.replace(HYPHEN_REGEX,capitalize))};utilities$4.camelCase=camelCase;(function(l){var e=commonjsGlobal&&commonjsGlobal.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};l.__esModule=!0;var n=e(styleToObject),t=utilities$4;function a(o,d){var h={};return!o||typeof o!="string"||(0,n.default)(o,function(f,u){f&&u&&(h[(0,t.camelCase)(f,d)]=u)}),h}l.default=a})(cjs);var React$1=React$2,styleToJS=cjs.default;function invertObject(l,e){if(!l||typeof l!="object")throw new TypeError("First argument must be an object");var n,t,a=typeof e=="function",o={},d={};for(n in l){if(t=l[n],a&&(o=e(n,t),o&&o.length===2)){d[o[0]]=o[1];continue}typeof t=="string"&&(d[t]=n)}return d}function isCustomComponent(l,e){if(l.indexOf("-")===-1)return e&&typeof e.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var styleToJSOptions={reactCompat:!0};function setStyleProp$1(l,e){if(l!=null)try{e.style=styleToJS(l,styleToJSOptions)}catch{e.style={}}}var PRESERVE_CUSTOM_ATTRIBUTES=React$1.version.split(".")[0]>=16,elementsWithNoTextChildren=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);function canTextBeChildOfNode$1(l){return!elementsWithNoTextChildren.has(l.name)}var utilities$3={PRESERVE_CUSTOM_ATTRIBUTES,invertObject,isCustomComponent,setStyleProp:setStyleProp$1,canTextBeChildOfNode:canTextBeChildOfNode$1,elementsWithNoTextChildren},reactProperty=lib$4,utilities$2=utilities$3,attributesToProps$2=function l(e){e=e||{};var n={reset:!0,submit:!0},t,a,o,d,h,f={},u=e.type&&n[e.type];for(t in e){if(o=e[t],reactProperty.isCustomAttribute(t)){f[t]=o;continue}if(a=t.toLowerCase(),d=getPropName(a),d){switch(h=reactProperty.getPropertyInfo(d),(d==="checked"||d==="value")&&!u&&(d=getPropName("default"+a)),f[d]=o,h&&h.type){case reactProperty.BOOLEAN:f[d]=!0;break;case reactProperty.OVERLOADED_BOOLEAN:o===""&&(f[d]=!0);break}continue}utilities$2.PRESERVE_CUSTOM_ATTRIBUTES&&(f[t]=o)}return utilities$2.setStyleProp(e.style,f),f};function getPropName(l){return reactProperty.possibleStandardNames[l]}var React=React$2,attributesToProps$1=attributesToProps$2,utilities$1=utilities$3,setStyleProp=utilities$1.setStyleProp,canTextBeChildOfNode=utilities$1.canTextBeChildOfNode;function domToReact$1(l,e){e=e||{};for(var n=e.library||React,t=n.cloneElement,a=n.createElement,o=n.isValidElement,d=[],h,f,u=typeof e.replace=="function",p,E,T,v=e.trim,S=0,g=l.length;S<g;S++){if(h=l[S],u&&(p=e.replace(h),o(p))){g>1&&(p=t(p,{key:p.key||S})),d.push(p);continue}if(h.type==="text"){if(f=!h.data.trim().length,f&&h.parent&&!canTextBeChildOfNode(h.parent)||v&&f)continue;d.push(h.data);continue}switch(E=h.attribs,skipAttributesToProps(h)?setStyleProp(E.style,E):E&&(E=attributesToProps$1(E)),T=null,h.type){case"script":case"style":h.children[0]&&(E.dangerouslySetInnerHTML={__html:h.children[0].data});break;case"tag":h.name==="textarea"&&h.children[0]?E.defaultValue=h.children[0].data:h.children&&h.children.length&&(T=domToReact$1(h.children,e));break;default:continue}g>1&&(E.key=S),d.push(a(h.name,E,T))}return d.length===1?d[0]:d}function skipAttributesToProps(l){return utilities$1.PRESERVE_CUSTOM_ATTRIBUTES&&l.type==="tag"&&utilities$1.isCustomComponent(l.name,l.attribs)}var domToReact_1=domToReact$1,CASE_SENSITIVE_TAG_NAMES$1=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussainBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],constants$2={CASE_SENSITIVE_TAG_NAMES:CASE_SENSITIVE_TAG_NAMES$1},node={},lib$3={},hasRequiredLib$1;function requireLib$1(){return hasRequiredLib$1||(hasRequiredLib$1=1,function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Doctype=l.CDATA=l.Tag=l.Style=l.Script=l.Comment=l.Directive=l.Text=l.Root=l.isTag=l.ElementType=void 0;var e;(function(t){t.Root="root",t.Text="text",t.Directive="directive",t.Comment="comment",t.Script="script",t.Style="style",t.Tag="tag",t.CDATA="cdata",t.Doctype="doctype"})(e=l.ElementType||(l.ElementType={}));function n(t){return t.type===e.Tag||t.type===e.Script||t.type===e.Style}l.isTag=n,l.Root=e.Root,l.Text=e.Text,l.Directive=e.Directive,l.Comment=e.Comment,l.Script=e.Script,l.Style=e.Style,l.Tag=e.Tag,l.CDATA=e.CDATA,l.Doctype=e.Doctype}(lib$3)),lib$3}var __extends=commonjsGlobal&&commonjsGlobal.__extends||function(){var l=function(e,n){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,a){t.__proto__=a}||function(t,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(t[o]=a[o])},l(e,n)};return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");l(e,n);function t(){this.constructor=e}e.prototype=n===null?Object.create(n):(t.prototype=n.prototype,new t)}}(),__assign=commonjsGlobal&&commonjsGlobal.__assign||function(){return __assign=Object.assign||function(l){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(l[a]=e[a])}return l},__assign.apply(this,arguments)};Object.defineProperty(node,"__esModule",{value:!0});node.cloneNode=node.hasChildren=node.isDocument=node.isDirective=node.isComment=node.isText=node.isCDATA=node.isTag=node.Element=node.Document=node.NodeWithChildren=node.ProcessingInstruction=node.Comment=node.Text=node.DataNode=node.Node=void 0;var domelementtype_1=requireLib$1(),nodeTypes=new Map([[domelementtype_1.ElementType.Tag,1],[domelementtype_1.ElementType.Script,1],[domelementtype_1.ElementType.Style,1],[domelementtype_1.ElementType.Directive,1],[domelementtype_1.ElementType.Text,3],[domelementtype_1.ElementType.CDATA,4],[domelementtype_1.ElementType.Comment,8],[domelementtype_1.ElementType.Root,9]]),Node$2=function(){function l(e){this.type=e,this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(l.prototype,"nodeType",{get:function(){var e;return(e=nodeTypes.get(this.type))!==null&&e!==void 0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),l.prototype.cloneNode=function(e){return e===void 0&&(e=!1),cloneNode(this,e)},l}();node.Node=Node$2;var DataNode=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.data=t,a}return Object.defineProperty(e.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!1,configurable:!0}),e}(Node$2);node.DataNode=DataNode;var Text$4=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Text,n)||this}return e}(DataNode);node.Text=Text$4;var Comment$1=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Comment,n)||this}return e}(DataNode);node.Comment=Comment$1;var ProcessingInstruction$1=function(l){__extends(e,l);function e(n,t){var a=l.call(this,domelementtype_1.ElementType.Directive,t)||this;return a.name=n,a}return e}(DataNode);node.ProcessingInstruction=ProcessingInstruction$1;var NodeWithChildren=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.children=t,a}return Object.defineProperty(e.prototype,"firstChild",{get:function(){var n;return(n=this.children[0])!==null&&n!==void 0?n:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childNodes",{get:function(){return this.children},set:function(n){this.children=n},enumerable:!1,configurable:!0}),e}(Node$2);node.NodeWithChildren=NodeWithChildren;var Document=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Root,n)||this}return e}(NodeWithChildren);node.Document=Document;var Element$1=function(l){__extends(e,l);function e(n,t,a,o){a===void 0&&(a=[]),o===void 0&&(o=n==="script"?domelementtype_1.ElementType.Script:n==="style"?domelementtype_1.ElementType.Style:domelementtype_1.ElementType.Tag);var d=l.call(this,o,a)||this;return d.name=n,d.attribs=t,d}return Object.defineProperty(e.prototype,"tagName",{get:function(){return this.name},set:function(n){this.name=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attributes",{get:function(){var n=this;return Object.keys(this.attribs).map(function(t){var a,o;return{name:t,value:n.attribs[t],namespace:(a=n["x-attribsNamespace"])===null||a===void 0?void 0:a[t],prefix:(o=n["x-attribsPrefix"])===null||o===void 0?void 0:o[t]}})},enumerable:!1,configurable:!0}),e}(NodeWithChildren);node.Element=Element$1;function isTag(l){return(0,domelementtype_1.isTag)(l)}node.isTag=isTag;function isCDATA(l){return l.type===domelementtype_1.ElementType.CDATA}node.isCDATA=isCDATA;function isText(l){return l.type===domelementtype_1.ElementType.Text}node.isText=isText;function isComment(l){return l.type===domelementtype_1.ElementType.Comment}node.isComment=isComment;function isDirective(l){return l.type===domelementtype_1.ElementType.Directive}node.isDirective=isDirective;function isDocument(l){return l.type===domelementtype_1.ElementType.Root}node.isDocument=isDocument;function hasChildren(l){return Object.prototype.hasOwnProperty.call(l,"children")}node.hasChildren=hasChildren;function cloneNode(l,e){e===void 0&&(e=!1);var n;if(isText(l))n=new Text$4(l.data);else if(isComment(l))n=new Comment$1(l.data);else if(isTag(l)){var t=e?cloneChildren(l.children):[],a=new Element$1(l.name,__assign({},l.attribs),t);t.forEach(function(f){return f.parent=a}),l.namespace!=null&&(a.namespace=l.namespace),l["x-attribsNamespace"]&&(a["x-attribsNamespace"]=__assign({},l["x-attribsNamespace"])),l["x-attribsPrefix"]&&(a["x-attribsPrefix"]=__assign({},l["x-attribsPrefix"])),n=a}else if(isCDATA(l)){var t=e?cloneChildren(l.children):[],o=new NodeWithChildren(domelementtype_1.ElementType.CDATA,t);t.forEach(function(u){return u.parent=o}),n=o}else if(isDocument(l)){var t=e?cloneChildren(l.children):[],d=new Document(t);t.forEach(function(u){return u.parent=d}),l["x-mode"]&&(d["x-mode"]=l["x-mode"]),n=d}else if(isDirective(l)){var h=new ProcessingInstruction$1(l.name,l.data);l["x-name"]!=null&&(h["x-name"]=l["x-name"],h["x-publicId"]=l["x-publicId"],h["x-systemId"]=l["x-systemId"]),n=h}else throw new Error("Not implemented yet: ".concat(l.type));return n.startIndex=l.startIndex,n.endIndex=l.endIndex,l.sourceCodeLocation!=null&&(n.sourceCodeLocation=l.sourceCodeLocation),n}node.cloneNode=cloneNode;function cloneChildren(l){for(var e=l.map(function(t){return cloneNode(t,!0)}),n=1;n<e.length;n++)e[n].prev=e[n-1],e[n-1].next=e[n];return e}var constants$1=constants$2,domhandler=node,CASE_SENSITIVE_TAG_NAMES=constants$1.CASE_SENSITIVE_TAG_NAMES,Comment=domhandler.Comment,Element=domhandler.Element,ProcessingInstruction=domhandler.ProcessingInstruction,Text$3=domhandler.Text,caseSensitiveTagNamesMap={},tagName;for(var i$1=0,len=CASE_SENSITIVE_TAG_NAMES.length;i$1<len;i$1++)tagName=CASE_SENSITIVE_TAG_NAMES[i$1],caseSensitiveTagNamesMap[tagName.toLowerCase()]=tagName;function getCaseSensitiveTagName(l){return caseSensitiveTagNamesMap[l]}function formatAttributes(l){for(var e={},n,t=0,a=l.length;t<a;t++)n=l[t],e[n.name]=n.value;return e}function formatTagName(l){l=l.toLowerCase();var e=getCaseSensitiveTagName(l);return e||l}function formatDOM$1(l,e,n){e=e||null;for(var t=[],a=0,o=l.length;a<o;a++){var d=l[a],h;switch(d.nodeType){case 1:h=new Element(formatTagName(d.nodeName),formatAttributes(d.attributes)),h.children=formatDOM$1(d.childNodes,h);break;case 3:h=new Text$3(d.nodeValue);break;case 8:h=new Comment(d.nodeValue);break;default:continue}var f=t[a-1]||null;f&&(f.next=h),h.parent=e,h.prev=f,h.next=null,t.push(h)}return n&&(h=new ProcessingInstruction(n.substring(0,n.indexOf(" ")).toLowerCase(),n),h.next=t[0]||null,h.parent=e,t.unshift(h),t[1]&&(t[1].prev=t[0])),t}function isIE$1(){return/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}var utilities={formatAttributes,formatDOM:formatDOM$1,isIE:isIE$1},HTML="html",HEAD="head",BODY="body",FIRST_TAG_REGEX=/<([a-zA-Z]+[0-9]?)/,HEAD_TAG_REGEX=/<head.*>/i,BODY_TAG_REGEX=/<body.*>/i,parseFromDocument=function(){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},parseFromString=function(){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")};if(typeof window.DOMParser=="function"){var domParser=new window.DOMParser,mimeType="text/html";parseFromString=function(l,e){return e&&(l="<"+e+">"+l+"</"+e+">"),domParser.parseFromString(l,mimeType)},parseFromDocument=parseFromString}if(document.implementation){var isIE=utilities.isIE,doc=document.implementation.createHTMLDocument(isIE()?"html-dom-parser":void 0);parseFromDocument=function(l,e){return e?(doc.documentElement.getElementsByTagName(e)[0].innerHTML=l,doc):(doc.documentElement.innerHTML=l,doc)}}var template=document.createElement("template"),parseFromTemplate;template.content&&(parseFromTemplate=function(l){return template.innerHTML=l,template.content.childNodes});function domparser$1(l){var e,n=l.match(FIRST_TAG_REGEX);n&&n[1]&&(e=n[1].toLowerCase());var t,a,o;switch(e){case HTML:return t=parseFromString(l),HEAD_TAG_REGEX.test(l)||(a=t.getElementsByTagName(HEAD)[0],a&&a.parentNode.removeChild(a)),BODY_TAG_REGEX.test(l)||(a=t.getElementsByTagName(BODY)[0],a&&a.parentNode.removeChild(a)),t.getElementsByTagName(HTML);case HEAD:case BODY:return o=parseFromDocument(l).getElementsByTagName(e),BODY_TAG_REGEX.test(l)&&HEAD_TAG_REGEX.test(l)?o[0].parentNode.childNodes:o;default:return parseFromTemplate?parseFromTemplate(l):parseFromDocument(l,BODY).getElementsByTagName(BODY)[0].childNodes}}var domparser_1=domparser$1,domparser=domparser_1,formatDOM=utilities.formatDOM,DIRECTIVE_REGEX=/<(![a-zA-Z\s]+)>/;function HTMLDOMParser(l){if(typeof l!="string")throw new TypeError("First argument must be a string");if(l==="")return[];var e=l.match(DIRECTIVE_REGEX),n;return e&&e[1]&&(n=e[1]),formatDOM(domparser(l),null,n)}var htmlToDom=HTMLDOMParser,lib$2={},hasRequiredLib;function requireLib(){return hasRequiredLib||(hasRequiredLib=1,function(l){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(f,u,p,E){E===void 0&&(E=p);var T=Object.getOwnPropertyDescriptor(u,p);(!T||("get"in T?!u.__esModule:T.writable||T.configurable))&&(T={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(f,E,T)}:function(f,u,p,E){E===void 0&&(E=p),f[E]=u[p]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(f,u){for(var p in f)p!=="default"&&!Object.prototype.hasOwnProperty.call(u,p)&&e(u,f,p)};Object.defineProperty(l,"__esModule",{value:!0}),l.DomHandler=void 0;var t=requireLib$1(),a=node;n(node,l);var o=/\s+/g,d={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1,xmlMode:!1},h=function(){function f(u,p,E){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof p=="function"&&(E=p,p=d),typeof u=="object"&&(p=u,u=void 0),this.callback=u??null,this.options=p??d,this.elementCB=E??null}return f.prototype.onparserinit=function(u){this.parser=u},f.prototype.onreset=function(){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},f.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},f.prototype.onerror=function(u){this.handleCallback(u)},f.prototype.onclosetag=function(){this.lastNode=null;var u=this.tagStack.pop();this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(u)},f.prototype.onopentag=function(u,p){var E=this.options.xmlMode?t.ElementType.Tag:void 0,T=new a.Element(u,p,void 0,E);this.addNode(T),this.tagStack.push(T)},f.prototype.ontext=function(u){var p=this.options.normalizeWhitespace,E=this.lastNode;if(E&&E.type===t.ElementType.Text)p?E.data=(E.data+u).replace(o," "):E.data+=u,this.options.withEndIndices&&(E.endIndex=this.parser.endIndex);else{p&&(u=u.replace(o," "));var T=new a.Text(u);this.addNode(T),this.lastNode=T}},f.prototype.oncomment=function(u){if(this.lastNode&&this.lastNode.type===t.ElementType.Comment){this.lastNode.data+=u;return}var p=new a.Comment(u);this.addNode(p),this.lastNode=p},f.prototype.oncommentend=function(){this.lastNode=null},f.prototype.oncdatastart=function(){var u=new a.Text(""),p=new a.NodeWithChildren(t.ElementType.CDATA,[u]);this.addNode(p),u.parent=p,this.lastNode=u},f.prototype.oncdataend=function(){this.lastNode=null},f.prototype.onprocessinginstruction=function(u,p){var E=new a.ProcessingInstruction(u,p);this.addNode(E)},f.prototype.handleCallback=function(u){if(typeof this.callback=="function")this.callback(u,this.dom);else if(u)throw u},f.prototype.addNode=function(u){var p=this.tagStack[this.tagStack.length-1],E=p.children[p.children.length-1];this.options.withStartIndices&&(u.startIndex=this.parser.startIndex),this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),p.children.push(u),E&&(u.prev=E,E.next=u),u.parent=p,this.lastNode=null},f}();l.DomHandler=h,l.default=h}(lib$2)),lib$2}var domToReact=domToReact_1,attributesToProps=attributesToProps$2,htmlToDOM=htmlToDom;htmlToDOM=typeof htmlToDOM.default=="function"?htmlToDOM.default:htmlToDOM;var domParserOptions={lowerCaseAttributeNames:!1};function HTMLReactParser(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");return l===""?[]:(e=e||{},domToReact(htmlToDOM(l,e.htmlparser2||domParserOptions),e))}HTMLReactParser.domToReact=domToReact;HTMLReactParser.htmlToDOM=htmlToDOM;HTMLReactParser.attributesToProps=attributesToProps;HTMLReactParser.Element=requireLib().Element;htmlReactParser.exports=HTMLReactParser;htmlReactParser.exports.default=HTMLReactParser;var htmlReactParserExports=htmlReactParser.exports;const HTMLReactParser$1=getDefaultExportFromCjs(htmlReactParserExports);HTMLReactParser$1.domToReact;HTMLReactParser$1.htmlToDOM;HTMLReactParser$1.attributesToProps;HTMLReactParser$1.Element;function LectureButtons({goToLecture:l,close:e,minutes:n,seconds:t,btnText:a}){return jsxRuntimeExports.jsx("div",{className:"lectures--buttons",children:l?jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>e(),"aria-label":a,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__count","data-testid":"countdown",children:jsxRuntimeExports.jsxs("span",{children:[n<10?`0${n}`:n,":",t<10?`0${t}`:t]})})})}LectureButtons.defaultProps={goToLecture:!1,close:()=>{},minutes:0,seconds:0};const noop$1=()=>{},ttsCache={},useEkho=({voice:l,text:e,audioType:n,loop:t=!1,started:a=!0,audio:o,soundActions:d,getEvent:h,volume:f=.5,onFinish:u=noop$1,onError:p=noop$1,onStart:E=noop$1,pauseTTS:T})=>{const[v,S,g,y]=d,b=!o&&!l,[R,_]=React$2.useState(!1),w=React$2.useRef({url:"",cc:"tts"}),C=React$2.useCallback(F=>h({type:"translate",payload:F}),[h]),N=React$2.useCallback(({id:F,type:M="base"})=>{var z;const I=C("usedVoices"),$=C("gameCharacters");return M==="base"?I==null?void 0:I[F]:M==="character"?(z=$==null?void 0:$[F])==null?void 0:z.voiceId:null},[C]),P=React$2.useCallback((F,M="tts")=>{w.current.url!==F&&(w.current={url:F,cc:M},v(F,M,t,f,u,E,p))},[v,t,f,u,E,p]),D=React$2.useCallback(async F=>{if(R&&F.voiceId&&F.text){let M=ttsCache[`${F.voiceId}_${F.text}`];try{M||(M=await h({type:"getSpeech",payload:F}),ttsCache[`${F.voiceId}_${F.text}`]=M),P(M)}catch{p()}}else p()},[h,R,p,P]),k=React$2.useCallback(()=>{w.current.url&&S(w.current.cc)},[S]);return React$2.useEffect(()=>(_(!0),()=>{_(!1),k()}),[k]),React$2.useEffect(()=>{T?g():y()},[g,T,y]),React$2.useEffect(()=>{b&&k()},[b,k]),React$2.useEffect(()=>{if(R&&a)if(n==="voice"&&(l!=null&&l.id)){const F=N(l);D({voiceId:F,text:e==null?void 0:e.replace("&#39;","'")})}else(n==="file"||!n)&&o?P(o==null?void 0:o.url):p()},[o,n,N,R,p,D,P,a,e,l]),k},cleanTextOfHtmlTags=l=>{const e=/<\/p>|<\/h1>|<\/h2>|<\/h3>|<\/h4>|<\/h5>|<\/h6>|<\/li>/gi,n=/&quot;/gi;if(l)return l.replace(e,". </p>").replace(n,"").replace(/(<([^>]+)>)/gi,"")},READING_TIME=.2;function LecturesComponent({emitEvent:l,getEvent:e,name:n,name_labelId:t,required:a,text:o,text_labelId:d,visible:h,documentType:f,viewed:u,soundActions:p,backgroundImage:E,hideBackgroundImageTheme:T=!1,keyboardControl:v,audio:S,audioType:g,audioVolume:y,voice:b,pause:R,styles:_}){const[w,C]=React$2.useState(),[N,P]=React$2.useState(!1),[D,k]=React$2.useState(0),F=o,M=Math.trunc(F.split(" ").length*READING_TIME),I=!a||a&&D>=M||a&&!h,[$]=p,z=`${n}. ${cleanTextOfHtmlTags(o)}`;useEkho({audioType:g,voice:b,text:z,audio:S,soundActions:p,getEvent:e,volume:y,pauseTTS:R});const X=J=>e({type:"translate",payload:J}),te=React$2.useCallback(()=>{I&&($("click-ui"),l({type:"finishMedia",payload:{name:t,type:"text",text:d,documentType:f}}))},[f,l,I,t,d,$]),ae=v({disabled:u,forward:te,escape:te});React$2.useEffect(()=>ae(),[ae]),React$2.useEffect(()=>{if(!h&&!N&&(te(),P(!0)),a&&h){const J=setInterval(()=>{k(H=>H+1)},1e3);return C(J),()=>{clearInterval(J)}}},[te,a,N,h]),React$2.useEffect(()=>{D===M&&clearInterval(w)},[w,D,M]);const ee=M-D,K=Math.floor(ee/60),ne=ee%60,ue=React$2.useMemo(()=>{let J="";return u?J="notes--results":(J="lectures--container",_&&(J+=` lectures--container--${_}`),E!=null&&E.url&&(J+=" lectures--container--with-custom-bg"),_&&T&&(J+=" disable-background-image")),J},[E==null?void 0:E.url,T,_,u]),pe={backgroundImage:E!=null&&E.url?`url('${E.url}')`:""};return h?jsxRuntimeExports.jsx("div",{className:ue,style:pe,children:jsxRuntimeExports.jsx("div",{className:u?"":"lectures__overlay",children:jsxRuntimeExports.jsxs("div",{className:u?"notes--results__text":`lectures lectures--${_}`,children:[jsxRuntimeExports.jsx("div",{className:"lectures--title",children:n}),jsxRuntimeExports.jsxs("div",{className:"lectures--text",dir:"auto",children:[jsxRuntimeExports.jsx("div",{children:F?HTMLReactParser$1(F):null}),u?null:jsxRuntimeExports.jsx(LectureButtons,{goToLecture:I,close:te,minutes:K,seconds:ne,btnText:X("screens.continue")})]})]})})}):null}LecturesComponent.defaultProps={emitEvent:()=>{},name:"",text:"",visible:!1,documentType:"",viewed:!1,required:!1,context:{},styles:""};function Slot({character:l,active:e,slot:n,lowQuality:t}){var T;const a=l.type==="image",o=l.type==="character",d=l.type==="object",h=(T=l==null?void 0:l.resource)==null?void 0:T.url,f=()=>a?`url(${h})`:o&&t?`url(${h.replace("character.glb","face.png")})`:d&&t?`url(${h.replace("object.glb","thumbnail.png")})`:"",u=()=>a?"contain":o||d?"auto 95%":"",p=()=>a?"center":o||d?"center bottom":"",E=a||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:p(),backgroundSize:u()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${n}`,style:E,children:e&&l.name?jsxRuntimeExports.jsx("span",{className:"conversation--character__name",children:l.name}):null},l.name)}Slot.propTypes={character:PropTypes.shape({name:PropTypes.string,url:PropTypes.string,type:PropTypes.string,emotion:PropTypes.string,uid:PropTypes.string,resource:PropTypes.shape({resourceId:PropTypes.string,url:PropTypes.string})}),active:PropTypes.bool,slot:PropTypes.number};Slot.defaultProps={character:{name:"",url:"",type:"",resource:{resourceId:""}},active:!1,slot:0};function toTrianglesDrawMode(l,e){if(e===three.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===three.TriangleFanDrawMode||e===three.TriangleStripDrawMode){let n=l.getIndex();if(n===null){const d=[],h=l.getAttribute("position");if(h!==void 0){for(let f=0;f<h.count;f++)d.push(f);l.setIndex(d),n=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const t=n.count-2,a=[];if(e===three.TriangleFanDrawMode)for(let d=1;d<=t;d++)a.push(n.getX(0)),a.push(n.getX(d)),a.push(n.getX(d+1));else for(let d=0;d<t;d++)d%2===0?(a.push(n.getX(d)),a.push(n.getX(d+1)),a.push(n.getX(d+2))):(a.push(n.getX(d+2)),a.push(n.getX(d+1)),a.push(n.getX(d)));a.length/3!==t&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=l.clone();return o.setIndex(a),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class GLTFLoader extends three.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new GLTFMaterialsClearcoatExtension(n)}),this.register(function(n){return new GLTFTextureBasisUExtension(n)}),this.register(function(n){return new GLTFTextureWebPExtension(n)}),this.register(function(n){return new GLTFTextureAVIFExtension(n)}),this.register(function(n){return new GLTFMaterialsSheenExtension(n)}),this.register(function(n){return new GLTFMaterialsTransmissionExtension(n)}),this.register(function(n){return new GLTFMaterialsVolumeExtension(n)}),this.register(function(n){return new GLTFMaterialsIorExtension(n)}),this.register(function(n){return new GLTFMaterialsEmissiveStrengthExtension(n)}),this.register(function(n){return new GLTFMaterialsSpecularExtension(n)}),this.register(function(n){return new GLTFMaterialsIridescenceExtension(n)}),this.register(function(n){return new GLTFMaterialsAnisotropyExtension(n)}),this.register(function(n){return new GLTFMaterialsBumpExtension(n)}),this.register(function(n){return new GLTFLightsExtension(n)}),this.register(function(n){return new GLTFMeshoptCompression(n)}),this.register(function(n){return new GLTFMeshGpuInstancing(n)})}load(e,n,t,a){const o=this;let d;if(this.resourcePath!=="")d=this.resourcePath;else if(this.path!==""){const u=three.LoaderUtils.extractUrlBase(e);d=three.LoaderUtils.resolveURL(u,this.path)}else d=three.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const h=function(u){a?a(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},f=new three.FileLoader(this.manager);f.setPath(this.path),f.setResponseType("arraybuffer"),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(u){try{o.parse(u,d,function(p){n(p),o.manager.itemEnd(e)},h)}catch(p){h(p)}},t,h)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,t,a){let o;const d={},h={},f=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(f.decode(new Uint8Array(e,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{d[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(E){a&&a(E);return}o=JSON.parse(d[EXTENSIONS.KHR_BINARY_GLTF].content)}else o=JSON.parse(f.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new GLTFParser(o,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p<this.pluginCallbacks.length;p++){const E=this.pluginCallbacks[p](u);E.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),h[E.name]=E,d[E.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const E=o.extensionsUsed[p],T=o.extensionsRequired||[];switch(E){case EXTENSIONS.KHR_MATERIALS_UNLIT:d[E]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:d[E]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:d[E]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:d[E]=new GLTFMeshQuantizationExtension;break;default:T.indexOf(E)>=0&&h[E]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+E+'".')}}u.setExtensions(d),u.setPlugins(h),u.parse(t,a)}parseAsync(e,n){const t=this;return new Promise(function(a,o){t.parse(e,n,a,o)})}}function GLTFRegistry(){let l={};return{get:function(e){return l[e]},add:function(e,n){l[e]=n},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const EXTENSIONS={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let t=0,a=n.length;t<a;t++){const o=n[t];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const n=this.parser,t="light:"+e;let a=n.cache.get(t);if(a)return a;const o=n.json,f=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const p=new three.Color(16777215);f.color!==void 0&&p.setRGB(f.color[0],f.color[1],f.color[2],three.LinearSRGBColorSpace);const E=f.range!==void 0?f.range:0;switch(f.type){case"directional":u=new three.DirectionalLight(p),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new three.PointLight(p),u.distance=E;break;case"spot":u=new three.SpotLight(p),u.distance=E,f.spot=f.spot||{},f.spot.innerConeAngle=f.spot.innerConeAngle!==void 0?f.spot.innerConeAngle:0,f.spot.outerConeAngle=f.spot.outerConeAngle!==void 0?f.spot.outerConeAngle:Math.PI/4,u.angle=f.spot.outerConeAngle,u.penumbra=1-f.spot.innerConeAngle/f.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+f.type)}return u.position.set(0,0,0),u.decay=2,assignExtrasToUserData(u,f),f.intensity!==void 0&&(u.intensity=f.intensity),u.name=n.createUniqueName(f.name||"light_"+e),a=Promise.resolve(u),n.cache.add(t,a),a}getDependency(e,n){if(e==="light")return this._loadLight(n)}createNodeAttachment(e){const n=this,t=this.parser,o=t.json.nodes[e],h=(o.extensions&&o.extensions[this.name]||{}).light;return h===void 0?null:this._loadLight(h).then(function(f){return t._getNodeRef(n.cache,h,f)})}}class GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return three.MeshBasicMaterial}extendParams(e,n,t){const a=[];e.color=new three.Color(1,1,1),e.opacity=1;const o=n.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const d=o.baseColorFactor;e.color.setRGB(d[0],d[1],d[2],three.LinearSRGBColorSpace),e.opacity=d[3]}o.baseColorTexture!==void 0&&a.push(t.assignTexture(e,"map",o.baseColorTexture,three.SRGBColorSpace))}return Promise.all(a)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name].emissiveStrength;return o!==void 0&&(n.emissiveIntensity=o),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];if(d.clearcoatFactor!==void 0&&(n.clearcoat=d.clearcoatFactor),d.clearcoatTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatMap",d.clearcoatTexture)),d.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=d.clearcoatRoughnessFactor),d.clearcoatRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatRoughnessMap",d.clearcoatRoughnessTexture)),d.clearcoatNormalTexture!==void 0&&(o.push(t.assignTexture(n,"clearcoatNormalMap",d.clearcoatNormalTexture)),d.clearcoatNormalTexture.scale!==void 0)){const h=d.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new three.Vector2(h,h)}return Promise.all(o)}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.iridescenceFactor!==void 0&&(n.iridescence=d.iridescenceFactor),d.iridescenceTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceMap",d.iridescenceTexture)),d.iridescenceIor!==void 0&&(n.iridescenceIOR=d.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),d.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=d.iridescenceThicknessMinimum),d.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=d.iridescenceThicknessMaximum),d.iridescenceThicknessTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceThicknessMap",d.iridescenceThicknessTexture)),Promise.all(o)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[];n.sheenColor=new three.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const d=a.extensions[this.name];if(d.sheenColorFactor!==void 0){const h=d.sheenColorFactor;n.sheenColor.setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace)}return d.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=d.sheenRoughnessFactor),d.sheenColorTexture!==void 0&&o.push(t.assignTexture(n,"sheenColorMap",d.sheenColorTexture,three.SRGBColorSpace)),d.sheenRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"sheenRoughnessMap",d.sheenRoughnessTexture)),Promise.all(o)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.transmissionFactor!==void 0&&(n.transmission=d.transmissionFactor),d.transmissionTexture!==void 0&&o.push(t.assignTexture(n,"transmissionMap",d.transmissionTexture)),Promise.all(o)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.thickness=d.thicknessFactor!==void 0?d.thicknessFactor:0,d.thicknessTexture!==void 0&&o.push(t.assignTexture(n,"thicknessMap",d.thicknessTexture)),n.attenuationDistance=d.attenuationDistance||1/0;const h=d.attenuationColor||[1,1,1];return n.attenuationColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),Promise.all(o)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name];return n.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.specularIntensity=d.specularFactor!==void 0?d.specularFactor:1,d.specularTexture!==void 0&&o.push(t.assignTexture(n,"specularIntensityMap",d.specularTexture));const h=d.specularColorFactor||[1,1,1];return n.specularColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),d.specularColorTexture!==void 0&&o.push(t.assignTexture(n,"specularColorMap",d.specularColorTexture,three.SRGBColorSpace)),Promise.all(o)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return n.bumpScale=d.bumpFactor!==void 0?d.bumpFactor:1,d.bumpTexture!==void 0&&o.push(t.assignTexture(n,"bumpMap",d.bumpTexture)),Promise.all(o)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.anisotropyStrength!==void 0&&(n.anisotropy=d.anisotropyStrength),d.anisotropyRotation!==void 0&&(n.anisotropyRotation=d.anisotropyRotation),d.anisotropyTexture!==void 0&&o.push(t.assignTexture(n,"anisotropyMap",d.anisotropyTexture)),Promise.all(o)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(e){const n=this.parser,t=n.json,a=t.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const o=a.extensions[this.name],d=n.options.ktx2Loader;if(!d){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,o.source,d)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFMeshoptCompression{constructor(e){this.name=EXTENSIONS.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,t=n.bufferViews[e];if(t.extensions&&t.extensions[this.name]){const a=t.extensions[this.name],o=this.parser.getDependency("buffer",a.buffer),d=this.parser.options.meshoptDecoder;if(!d||!d.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(h){const f=a.byteOffset||0,u=a.byteLength||0,p=a.count,E=a.byteStride,T=new Uint8Array(h,f,u);return d.decodeGltfBufferAsync?d.decodeGltfBufferAsync(p,E,T,a.mode,a.filter).then(function(v){return v.buffer}):d.ready.then(function(){const v=new ArrayBuffer(p*E);return d.decodeGltfBuffer(new Uint8Array(v),p,E,T,a.mode,a.filter),v})})}else return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=EXTENSIONS.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,t=n.nodes[e];if(!t.extensions||!t.extensions[this.name]||t.mesh===void 0)return null;const a=n.meshes[t.mesh];for(const u of a.primitives)if(u.mode!==WEBGL_CONSTANTS.TRIANGLES&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_STRIP&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_FAN&&u.mode!==void 0)return null;const d=t.extensions[this.name].attributes,h=[],f={};for(const u in d)h.push(this.parser.getDependency("accessor",d[u]).then(p=>(f[u]=p,f[u])));return h.length<1?null:(h.push(this.parser.createNodeMesh(e)),Promise.all(h).then(u=>{const p=u.pop(),E=p.isGroup?p.children:[p],T=u[0].count,v=[];for(const S of E){const g=new three.Matrix4,y=new three.Vector3,b=new three.Quaternion,R=new three.Vector3(1,1,1),_=new three.InstancedMesh(S.geometry,S.material,T);for(let w=0;w<T;w++)f.TRANSLATION&&y.fromBufferAttribute(f.TRANSLATION,w),f.ROTATION&&b.fromBufferAttribute(f.ROTATION,w),f.SCALE&&R.fromBufferAttribute(f.SCALE,w),_.setMatrixAt(w,g.compose(y,b,R));for(const w in f)if(w==="_COLOR_0"){const C=f[w];_.instanceColor=new three.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&S.geometry.setAttribute(w,f[w]);three.Object3D.prototype.copy.call(_,S),this.parser.assignFinalMaterial(_),v.push(_)}return p.isGroup?(p.clear(),p.add(...v),p):v[0]}))}}const BINARY_EXTENSION_HEADER_MAGIC="glTF",BINARY_EXTENSION_HEADER_LENGTH=12,BINARY_EXTENSION_CHUNK_TYPES={JSON:1313821514,BIN:5130562};class GLTFBinaryExtension{constructor(e){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,BINARY_EXTENSION_HEADER_LENGTH),t=new TextDecoder;if(this.header={magic:t.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const a=this.header.length-BINARY_EXTENSION_HEADER_LENGTH,o=new DataView(e,BINARY_EXTENSION_HEADER_LENGTH);let d=0;for(;d<a;){const h=o.getUint32(d,!0);d+=4;const f=o.getUint32(d,!0);if(d+=4,f===BINARY_EXTENSION_CHUNK_TYPES.JSON){const u=new Uint8Array(e,BINARY_EXTENSION_HEADER_LENGTH+d,h);this.content=t.decode(u)}else if(f===BINARY_EXTENSION_CHUNK_TYPES.BIN){const u=BINARY_EXTENSION_HEADER_LENGTH+d;this.body=e.slice(u,u+h)}d+=h}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=EXTENSIONS.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(e,n){const t=this.json,a=this.dracoLoader,o=e.extensions[this.name].bufferView,d=e.extensions[this.name].attributes,h={},f={},u={};for(const p in d){const E=ATTRIBUTES[p]||p.toLowerCase();h[E]=d[p]}for(const p in e.attributes){const E=ATTRIBUTES[p]||p.toLowerCase();if(d[p]!==void 0){const T=t.accessors[e.attributes[p]],v=WEBGL_COMPONENT_TYPES[T.componentType];u[E]=v.name,f[E]=T.normalized===!0}}return n.getDependency("bufferView",o).then(function(p){return new Promise(function(E,T){a.decodeDracoFile(p,function(v){for(const S in v.attributes){const g=v.attributes[S],y=f[S];y!==void 0&&(g.normalized=y)}E(v)},h,u,three.LinearSRGBColorSpace,T)})})}}class GLTFTextureTransformExtension{constructor(){this.name=EXTENSIONS.KHR_TEXTURE_TRANSFORM}extendTexture(e,n){return(n.texCoord===void 0||n.texCoord===e.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(e=e.clone(),n.texCoord!==void 0&&(e.channel=n.texCoord),n.offset!==void 0&&e.offset.fromArray(n.offset),n.rotation!==void 0&&(e.rotation=n.rotation),n.scale!==void 0&&e.repeat.fromArray(n.scale),e.needsUpdate=!0),e}}class GLTFMeshQuantizationExtension{constructor(){this.name=EXTENSIONS.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends three.Interpolant{constructor(e,n,t,a){super(e,n,t,a)}copySampleValue_(e){const n=this.resultBuffer,t=this.sampleValues,a=this.valueSize,o=e*a*3+a;for(let d=0;d!==a;d++)n[d]=t[o+d];return n}interpolate_(e,n,t,a){const o=this.resultBuffer,d=this.sampleValues,h=this.valueSize,f=h*2,u=h*3,p=a-n,E=(t-n)/p,T=E*E,v=T*E,S=e*u,g=S-u,y=-2*v+3*T,b=v-T,R=1-y,_=b-T+E;for(let w=0;w!==h;w++){const C=d[g+w+h],N=d[g+w+f]*p,P=d[S+w+h],D=d[S+w]*p;o[w]=R*C+_*N+y*P+b*D}return o}}const _q=new three.Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,n,t,a){const o=super.interpolate_(e,n,t,a);return _q.fromArray(o).normalize().toArray(o),o}}const WEBGL_CONSTANTS={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:three.NearestFilter,9729:three.LinearFilter,9984:three.NearestMipmapNearestFilter,9985:three.LinearMipmapNearestFilter,9986:three.NearestMipmapLinearFilter,9987:three.LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:three.ClampToEdgeWrapping,33648:three.MirroredRepeatWrapping,10497:three.RepeatWrapping},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PATH_PROPERTIES={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},INTERPOLATION={CUBICSPLINE:void 0,LINEAR:three.InterpolateLinear,STEP:three.InterpolateDiscrete},ALPHA_MODES={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function createDefaultMaterial(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new three.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:three.FrontSide})),l.DefaultMaterial}function addUnknownExtensionsToUserData(l,e,n){for(const t in n.extensions)l[t]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[t]=n.extensions[t])}function assignExtrasToUserData(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function addMorphTargets(l,e,n){let t=!1,a=!1,o=!1;for(let u=0,p=e.length;u<p;u++){const E=e[u];if(E.POSITION!==void 0&&(t=!0),E.NORMAL!==void 0&&(a=!0),E.COLOR_0!==void 0&&(o=!0),t&&a&&o)break}if(!t&&!a&&!o)return Promise.resolve(l);const d=[],h=[],f=[];for(let u=0,p=e.length;u<p;u++){const E=e[u];if(t){const T=E.POSITION!==void 0?n.getDependency("accessor",E.POSITION):l.attributes.position;d.push(T)}if(a){const T=E.NORMAL!==void 0?n.getDependency("accessor",E.NORMAL):l.attributes.normal;h.push(T)}if(o){const T=E.COLOR_0!==void 0?n.getDependency("accessor",E.COLOR_0):l.attributes.color;f.push(T)}}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f)]).then(function(u){const p=u[0],E=u[1],T=u[2];return t&&(l.morphAttributes.position=p),a&&(l.morphAttributes.normal=E),o&&(l.morphAttributes.color=T),l.morphTargetsRelative=!0,l})}function updateMorphTargets(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let n=0,t=e.weights.length;n<t;n++)l.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(l.morphTargetInfluences.length===n.length){l.morphTargetDictionary={};for(let t=0,a=n.length;t<a;t++)l.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(l){let e;const n=l.extensions&&l.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):e=l.indices+":"+createAttributesKey(l.attributes)+":"+l.mode,l.targets!==void 0)for(let t=0,a=l.targets.length;t<a;t++)e+=":"+createAttributesKey(l.targets[t]);return e}function createAttributesKey(l){let e="";const n=Object.keys(l).sort();for(let t=0,a=n.length;t<a;t++)e+=n[t]+":"+l[n[t]]+";";return e}function getNormalizedComponentScale(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function getImageURIMimeType(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const _identityMatrix=new three.Matrix4;class GLTFParser{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let t=!1,a=!1,o=-1;typeof navigator<"u"&&(t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,a=navigator.userAgent.indexOf("Firefox")>-1,o=a?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||t||a&&o<98?this.textureLoader=new three.TextureLoader(this.options.manager):this.textureLoader=new three.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new three.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const t=this,a=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(d){return d._markDefs&&d._markDefs()}),Promise.all(this._invokeAll(function(d){return d.beforeRoot&&d.beforeRoot()})).then(function(){return Promise.all([t.getDependencies("scene"),t.getDependencies("animation"),t.getDependencies("camera")])}).then(function(d){const h={scene:d[0][a.scene||0],scenes:d[0],animations:d[1],cameras:d[2],asset:a.asset,parser:t,userData:{}};return addUnknownExtensionsToUserData(o,h,a),assignExtrasToUserData(h,a),Promise.all(t._invokeAll(function(f){return f.afterRoot&&f.afterRoot(h)})).then(function(){e(h)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],t=this.json.meshes||[];for(let a=0,o=n.length;a<o;a++){const d=n[a].joints;for(let h=0,f=d.length;h<f;h++)e[d[h]].isBone=!0}for(let a=0,o=e.length;a<o;a++){const d=e[a];d.mesh!==void 0&&(this._addNodeRef(this.meshCache,d.mesh),d.skin!==void 0&&(t[d.mesh].isSkinnedMesh=!0)),d.camera!==void 0&&this._addNodeRef(this.cameraCache,d.camera)}}_addNodeRef(e,n){n!==void 0&&(e.refs[n]===void 0&&(e.refs[n]=e.uses[n]=0),e.refs[n]++)}_getNodeRef(e,n,t){if(e.refs[n]<=1)return t;const a=t.clone(),o=(d,h)=>{const f=this.associations.get(d);f!=null&&this.associations.set(h,f);for(const[u,p]of d.children.entries())o(p,h.children[u])};return o(t,a),a.name+="_instance_"+e.uses[n]++,a}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let t=0;t<n.length;t++){const a=e(n[t]);if(a)return a}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const t=[];for(let a=0;a<n.length;a++){const o=e(n[a]);o&&t.push(o)}return t}getDependency(e,n){const t=e+":"+n;let a=this.cache.get(t);if(!a){switch(e){case"scene":a=this.loadScene(n);break;case"node":a=this._invokeOne(function(o){return o.loadNode&&o.loadNode(n)});break;case"mesh":a=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(n)});break;case"accessor":a=this.loadAccessor(n);break;case"bufferView":a=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(n)});break;case"buffer":a=this.loadBuffer(n);break;case"material":a=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(n)});break;case"texture":a=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(n)});break;case"skin":a=this.loadSkin(n);break;case"animation":a=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(n)});break;case"camera":a=this.loadCamera(n);break;default:if(a=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,n)}),!a)throw new Error("Unknown type: "+e);break}this.cache.add(t,a)}return a}getDependencies(e){let n=this.cache.get(e);if(!n){const t=this,a=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(a.map(function(o,d){return t.getDependency(e,d)})),this.cache.add(e,n)}return n}loadBuffer(e){const n=this.json.buffers[e],t=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&e===0)return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(o,d){t.load(three.LoaderUtils.resolveURL(n.uri,a.path),o,void 0,function(){d(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(e){const n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(t){const a=n.byteLength||0,o=n.byteOffset||0;return t.slice(o,o+a)})}loadAccessor(e){const n=this,t=this.json,a=this.json.accessors[e];if(a.bufferView===void 0&&a.sparse===void 0){const d=WEBGL_TYPE_SIZES[a.type],h=WEBGL_COMPONENT_TYPES[a.componentType],f=a.normalized===!0,u=new h(a.count*d);return Promise.resolve(new three.BufferAttribute(u,d,f))}const o=[];return a.bufferView!==void 0?o.push(this.getDependency("bufferView",a.bufferView)):o.push(null),a.sparse!==void 0&&(o.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(o).then(function(d){const h=d[0],f=WEBGL_TYPE_SIZES[a.type],u=WEBGL_COMPONENT_TYPES[a.componentType],p=u.BYTES_PER_ELEMENT,E=p*f,T=a.byteOffset||0,v=a.bufferView!==void 0?t.bufferViews[a.bufferView].byteStride:void 0,S=a.normalized===!0;let g,y;if(v&&v!==E){const b=Math.floor(T/v),R="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+b+":"+a.count;let _=n.cache.get(R);_||(g=new u(h,b*v,a.count*v/p),_=new three.InterleavedBuffer(g,v/p),n.cache.add(R,_)),y=new three.InterleavedBufferAttribute(_,f,T%v/p,S)}else h===null?g=new u(a.count*f):g=new u(h,T,a.count*f),y=new three.BufferAttribute(g,f,S);if(a.sparse!==void 0){const b=WEBGL_TYPE_SIZES.SCALAR,R=WEBGL_COMPONENT_TYPES[a.sparse.indices.componentType],_=a.sparse.indices.byteOffset||0,w=a.sparse.values.byteOffset||0,C=new R(d[1],_,a.sparse.count*b),N=new u(d[2],w,a.sparse.count*f);h!==null&&(y=new three.BufferAttribute(y.array.slice(),y.itemSize,y.normalized));for(let P=0,D=C.length;P<D;P++){const k=C[P];if(y.setX(k,N[P*f]),f>=2&&y.setY(k,N[P*f+1]),f>=3&&y.setZ(k,N[P*f+2]),f>=4&&y.setW(k,N[P*f+3]),f>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return y})}loadTexture(e){const n=this.json,t=this.options,o=n.textures[e].source,d=n.images[o];let h=this.textureLoader;if(d.uri){const f=t.manager.getHandler(d.uri);f!==null&&(h=f)}return this.loadTextureImage(e,o,h)}loadTextureImage(e,n,t){const a=this,o=this.json,d=o.textures[e],h=o.images[n],f=(h.uri||h.bufferView)+":"+d.sampler;if(this.textureCache[f])return this.textureCache[f];const u=this.loadImageSource(n,t).then(function(p){p.flipY=!1,p.name=d.name||h.name||"",p.name===""&&typeof h.uri=="string"&&h.uri.startsWith("data:image/")===!1&&(p.name=h.uri);const T=(o.samplers||{})[d.sampler]||{};return p.magFilter=WEBGL_FILTERS[T.magFilter]||three.LinearFilter,p.minFilter=WEBGL_FILTERS[T.minFilter]||three.LinearMipmapLinearFilter,p.wrapS=WEBGL_WRAPPINGS[T.wrapS]||three.RepeatWrapping,p.wrapT=WEBGL_WRAPPINGS[T.wrapT]||three.RepeatWrapping,a.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[f]=u,u}loadImageSource(e,n){const t=this,a=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(E=>E.clone());const d=a.images[e],h=self.URL||self.webkitURL;let f=d.uri||"",u=!1;if(d.bufferView!==void 0)f=t.getDependency("bufferView",d.bufferView).then(function(E){u=!0;const T=new Blob([E],{type:d.mimeType});return f=h.createObjectURL(T),f});else if(d.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(f).then(function(E){return new Promise(function(T,v){let S=T;n.isImageBitmapLoader===!0&&(S=function(g){const y=new three.Texture(g);y.needsUpdate=!0,T(y)}),n.load(three.LoaderUtils.resolveURL(E,o.path),S,void 0,v)})}).then(function(E){return u===!0&&h.revokeObjectURL(f),E.userData.mimeType=d.mimeType||getImageURIMimeType(d.uri),E}).catch(function(E){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),E});return this.sourceCache[e]=p,p}assignTexture(e,n,t,a){const o=this;return this.getDependency("texture",t.index).then(function(d){if(!d)return null;if(t.texCoord!==void 0&&t.texCoord>0&&(d=d.clone(),d.channel=t.texCoord),o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const h=t.extensions!==void 0?t.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:void 0;if(h){const f=o.associations.get(d);d=o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(d,h),o.associations.set(d,f)}}return a!==void 0&&(d.colorSpace=a),e[n]=d,d})}assignFinalMaterial(e){const n=e.geometry;let t=e.material;const a=n.attributes.tangent===void 0,o=n.attributes.color!==void 0,d=n.attributes.normal===void 0;if(e.isPoints){const h="PointsMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.PointsMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,f.sizeAttenuation=!1,this.cache.add(h,f)),t=f}else if(e.isLine){const h="LineBasicMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.LineBasicMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,this.cache.add(h,f)),t=f}if(a||o||d){let h="ClonedMaterial:"+t.uuid+":";a&&(h+="derivative-tangents:"),o&&(h+="vertex-colors:"),d&&(h+="flat-shading:");let f=this.cache.get(h);f||(f=t.clone(),o&&(f.vertexColors=!0),d&&(f.flatShading=!0),a&&(f.normalScale&&(f.normalScale.y*=-1),f.clearcoatNormalScale&&(f.clearcoatNormalScale.y*=-1)),this.cache.add(h,f),this.associations.set(f,this.associations.get(t))),t=f}e.material=t}getMaterialType(){return three.MeshStandardMaterial}loadMaterial(e){const n=this,t=this.json,a=this.extensions,o=t.materials[e];let d;const h={},f=o.extensions||{},u=[];if(f[EXTENSIONS.KHR_MATERIALS_UNLIT]){const E=a[EXTENSIONS.KHR_MATERIALS_UNLIT];d=E.getMaterialType(),u.push(E.extendParams(h,o,n))}else{const E=o.pbrMetallicRoughness||{};if(h.color=new three.Color(1,1,1),h.opacity=1,Array.isArray(E.baseColorFactor)){const T=E.baseColorFactor;h.color.setRGB(T[0],T[1],T[2],three.LinearSRGBColorSpace),h.opacity=T[3]}E.baseColorTexture!==void 0&&u.push(n.assignTexture(h,"map",E.baseColorTexture,three.SRGBColorSpace)),h.metalness=E.metallicFactor!==void 0?E.metallicFactor:1,h.roughness=E.roughnessFactor!==void 0?E.roughnessFactor:1,E.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(h,"metalnessMap",E.metallicRoughnessTexture)),u.push(n.assignTexture(h,"roughnessMap",E.metallicRoughnessTexture))),d=this._invokeOne(function(T){return T.getMaterialType&&T.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(T){return T.extendMaterialParams&&T.extendMaterialParams(e,h)})))}o.doubleSided===!0&&(h.side=three.DoubleSide);const p=o.alphaMode||ALPHA_MODES.OPAQUE;if(p===ALPHA_MODES.BLEND?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,p===ALPHA_MODES.MASK&&(h.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"normalMap",o.normalTexture)),h.normalScale=new three.Vector2(1,1),o.normalTexture.scale!==void 0)){const E=o.normalTexture.scale;h.normalScale.set(E,E)}if(o.occlusionTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(h.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&d!==three.MeshBasicMaterial){const E=o.emissiveFactor;h.emissive=new three.Color().setRGB(E[0],E[1],E[2],three.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&d!==three.MeshBasicMaterial&&u.push(n.assignTexture(h,"emissiveMap",o.emissiveTexture,three.SRGBColorSpace)),Promise.all(u).then(function(){const E=new d(h);return o.name&&(E.name=o.name),assignExtrasToUserData(E,o),n.associations.set(E,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(a,E,o),E})}createUniqueName(e){const n=three.PropertyBinding.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,t=this.extensions,a=this.primitiveCache;function o(h){return t[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,n).then(function(f){return addPrimitiveAttributes(f,h,n)})}const d=[];for(let h=0,f=e.length;h<f;h++){const u=e[h],p=createPrimitiveKey(u),E=a[p];if(E)d.push(E.promise);else{let T;u.extensions&&u.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?T=o(u):T=addPrimitiveAttributes(new three.BufferGeometry,u,n),a[p]={primitive:u,promise:T},d.push(T)}}return Promise.all(d)}loadMesh(e){const n=this,t=this.json,a=this.extensions,o=t.meshes[e],d=o.primitives,h=[];for(let f=0,u=d.length;f<u;f++){const p=d[f].material===void 0?createDefaultMaterial(this.cache):this.getDependency("material",d[f].material);h.push(p)}return h.push(n.loadGeometries(d)),Promise.all(h).then(function(f){const u=f.slice(0,f.length-1),p=f[f.length-1],E=[];for(let v=0,S=p.length;v<S;v++){const g=p[v],y=d[v];let b;const R=u[v];if(y.mode===WEBGL_CONSTANTS.TRIANGLES||y.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||y.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||y.mode===void 0)b=o.isSkinnedMesh===!0?new three.SkinnedMesh(g,R):new three.Mesh(g,R),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),y.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleStripDrawMode):y.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleFanDrawMode));else if(y.mode===WEBGL_CONSTANTS.LINES)b=new three.LineSegments(g,R);else if(y.mode===WEBGL_CONSTANTS.LINE_STRIP)b=new three.Line(g,R);else if(y.mode===WEBGL_CONSTANTS.LINE_LOOP)b=new three.LineLoop(g,R);else if(y.mode===WEBGL_CONSTANTS.POINTS)b=new three.Points(g,R);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(b.geometry.morphAttributes).length>0&&updateMorphTargets(b,o),b.name=n.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(b,o),y.extensions&&addUnknownExtensionsToUserData(a,b,y),n.assignFinalMaterial(b),E.push(b)}for(let v=0,S=E.length;v<S;v++)n.associations.set(E[v],{meshes:e,primitives:v});if(E.length===1)return o.extensions&&addUnknownExtensionsToUserData(a,E[0],o),E[0];const T=new three.Group;o.extensions&&addUnknownExtensionsToUserData(a,T,o),n.associations.set(T,{meshes:e});for(let v=0,S=E.length;v<S;v++)T.add(E[v]);return T})}loadCamera(e){let n;const t=this.json.cameras[e],a=t[t.type];if(!a){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return t.type==="perspective"?n=new three.PerspectiveCamera(three.MathUtils.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):t.type==="orthographic"&&(n=new three.OrthographicCamera(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),t.name&&(n.name=this.createUniqueName(t.name)),assignExtrasToUserData(n,t),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],t=[];for(let a=0,o=n.joints.length;a<o;a++)t.push(this._loadNodeShallow(n.joints[a]));return n.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",n.inverseBindMatrices)):t.push(null),Promise.all(t).then(function(a){const o=a.pop(),d=a,h=[],f=[];for(let u=0,p=d.length;u<p;u++){const E=d[u];if(E){h.push(E);const T=new three.Matrix4;o!==null&&T.fromArray(o.array,u*16),f.push(T)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[u])}return new three.Skeleton(h,f)})}loadAnimation(e){const n=this.json,t=this,a=n.animations[e],o=a.name?a.name:"animation_"+e,d=[],h=[],f=[],u=[],p=[];for(let E=0,T=a.channels.length;E<T;E++){const v=a.channels[E],S=a.samplers[v.sampler],g=v.target,y=g.node,b=a.parameters!==void 0?a.parameters[S.input]:S.input,R=a.parameters!==void 0?a.parameters[S.output]:S.output;g.node!==void 0&&(d.push(this.getDependency("node",y)),h.push(this.getDependency("accessor",b)),f.push(this.getDependency("accessor",R)),u.push(S),p.push(g))}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f),Promise.all(u),Promise.all(p)]).then(function(E){const T=E[0],v=E[1],S=E[2],g=E[3],y=E[4],b=[];for(let R=0,_=T.length;R<_;R++){const w=T[R],C=v[R],N=S[R],P=g[R],D=y[R];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const k=t._createAnimationTracks(w,C,N,P,D);if(k)for(let F=0;F<k.length;F++)b.push(k[F])}return new three.AnimationClip(o,void 0,b)})}createNodeMesh(e){const n=this.json,t=this,a=n.nodes[e];return a.mesh===void 0?null:t.getDependency("mesh",a.mesh).then(function(o){const d=t._getNodeRef(t.meshCache,a.mesh,o);return a.weights!==void 0&&d.traverse(function(h){if(h.isMesh)for(let f=0,u=a.weights.length;f<u;f++)h.morphTargetInfluences[f]=a.weights[f]}),d})}loadNode(e){const n=this.json,t=this,a=n.nodes[e],o=t._loadNodeShallow(e),d=[],h=a.children||[];for(let u=0,p=h.length;u<p;u++)d.push(t.getDependency("node",h[u]));const f=a.skin===void 0?Promise.resolve(null):t.getDependency("skin",a.skin);return Promise.all([o,Promise.all(d),f]).then(function(u){const p=u[0],E=u[1],T=u[2];T!==null&&p.traverse(function(v){v.isSkinnedMesh&&v.bind(T,_identityMatrix)});for(let v=0,S=E.length;v<S;v++)p.add(E[v]);return p})}_loadNodeShallow(e){const n=this.json,t=this.extensions,a=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=n.nodes[e],d=o.name?a.createUniqueName(o.name):"",h=[],f=a._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return f&&h.push(f),o.camera!==void 0&&h.push(a.getDependency("camera",o.camera).then(function(u){return a._getNodeRef(a.cameraCache,o.camera,u)})),a._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){h.push(u)}),this.nodeCache[e]=Promise.all(h).then(function(u){let p;if(o.isBone===!0?p=new three.Bone:u.length>1?p=new three.Group:u.length===1?p=u[0]:p=new three.Object3D,p!==u[0])for(let E=0,T=u.length;E<T;E++)p.add(u[E]);if(o.name&&(p.userData.name=o.name,p.name=d),assignExtrasToUserData(p,o),o.extensions&&addUnknownExtensionsToUserData(t,p,o),o.matrix!==void 0){const E=new three.Matrix4;E.fromArray(o.matrix),p.applyMatrix4(E)}else o.translation!==void 0&&p.position.fromArray(o.translation),o.rotation!==void 0&&p.quaternion.fromArray(o.rotation),o.scale!==void 0&&p.scale.fromArray(o.scale);return a.associations.has(p)||a.associations.set(p,{}),a.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const n=this.extensions,t=this.json.scenes[e],a=this,o=new three.Group;t.name&&(o.name=a.createUniqueName(t.name)),assignExtrasToUserData(o,t),t.extensions&&addUnknownExtensionsToUserData(n,o,t);const d=t.nodes||[],h=[];for(let f=0,u=d.length;f<u;f++)h.push(a.getDependency("node",d[f]));return Promise.all(h).then(function(f){for(let p=0,E=f.length;p<E;p++)o.add(f[p]);const u=p=>{const E=new Map;for(const[T,v]of a.associations)(T instanceof three.Material||T instanceof three.Texture)&&E.set(T,v);return p.traverse(T=>{const v=a.associations.get(T);v!=null&&E.set(T,v)}),E};return a.associations=u(o),o})}_createAnimationTracks(e,n,t,a,o){const d=[],h=e.name?e.name:e.uuid,f=[];PATH_PROPERTIES[o.path]===PATH_PROPERTIES.weights?e.traverse(function(T){T.morphTargetInfluences&&f.push(T.name?T.name:T.uuid)}):f.push(h);let u;switch(PATH_PROPERTIES[o.path]){case PATH_PROPERTIES.weights:u=three.NumberKeyframeTrack;break;case PATH_PROPERTIES.rotation:u=three.QuaternionKeyframeTrack;break;case PATH_PROPERTIES.position:case PATH_PROPERTIES.scale:u=three.VectorKeyframeTrack;break;default:switch(t.itemSize){case 1:u=three.NumberKeyframeTrack;break;case 2:case 3:default:u=three.VectorKeyframeTrack;break}break}const p=a.interpolation!==void 0?INTERPOLATION[a.interpolation]:three.InterpolateLinear,E=this._getArrayFromAccessor(t);for(let T=0,v=f.length;T<v;T++){const S=new u(f[T]+"."+PATH_PROPERTIES[o.path],n.array,E,p);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(S),d.push(S)}return d}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const t=getNormalizedComponentScale(n.constructor),a=new Float32Array(n.length);for(let o=0,d=n.length;o<d;o++)a[o]=n[o]*t;n=a}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const a=this instanceof three.QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant;return new a(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function computeBounds(l,e,n){const t=e.attributes,a=new three.Box3;if(t.POSITION!==void 0){const h=n.json.accessors[t.POSITION],f=h.min,u=h.max;if(f!==void 0&&u!==void 0){if(a.set(new three.Vector3(f[0],f[1],f[2]),new three.Vector3(u[0],u[1],u[2])),h.normalized){const p=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[h.componentType]);a.min.multiplyScalar(p),a.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const h=new three.Vector3,f=new three.Vector3;for(let u=0,p=o.length;u<p;u++){const E=o[u];if(E.POSITION!==void 0){const T=n.json.accessors[E.POSITION],v=T.min,S=T.max;if(v!==void 0&&S!==void 0){if(f.setX(Math.max(Math.abs(v[0]),Math.abs(S[0]))),f.setY(Math.max(Math.abs(v[1]),Math.abs(S[1]))),f.setZ(Math.max(Math.abs(v[2]),Math.abs(S[2]))),T.normalized){const g=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[T.componentType]);f.multiplyScalar(g)}h.max(f)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(h)}l.boundingBox=a;const d=new three.Sphere;a.getCenter(d.center),d.radius=a.min.distanceTo(a.max)/2,l.boundingSphere=d}function addPrimitiveAttributes(l,e,n){const t=e.attributes,a=[];function o(d,h){return n.getDependency("accessor",d).then(function(f){l.setAttribute(h,f)})}for(const d in t){const h=ATTRIBUTES[d]||d.toLowerCase();h in l.attributes||a.push(o(t[d],h))}if(e.indices!==void 0&&!l.index){const d=n.getDependency("accessor",e.indices).then(function(h){l.setIndex(h)});a.push(d)}return three.ColorManagement.workingColorSpace!==three.LinearSRGBColorSpace&&"COLOR_0"in t&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${three.ColorManagement.workingColorSpace}" not supported.`),assignExtrasToUserData(l,e),computeBounds(l,e,n),Promise.all(a).then(function(){return e.targets!==void 0?addMorphTargets(l,e.targets,n):l})}const defaultCamPos=[0,14.63,16],isMobile=DeviceDetection(),loader$1=new GLTFLoader,box=new three.Box3,worldPos=new three.Vector3,size=new three.Vector3;function Panel({character:l,ttsStarted:e,active:n,visible:t}){var v,S,g,y,b;const a=React$2.useRef(null),o=React$2.useRef(null),d=l.type==="character",[h,f]=React$2.useState(!1),u=React$2.useRef(),p=React$2.useMemo(()=>{var R,_,w,C,N,P,D,k;return d?l.animationId&&((R=l.animation)!=null&&R.url)?l.animation:(C=(w=(_=l==null?void 0:l.resource)==null?void 0:_.animations)==null?void 0:w[l.emotion])!=null&&C.url?(P=(N=l==null?void 0:l.resource)==null?void 0:N.animations)==null?void 0:P[l.emotion]:(k=(D=l==null?void 0:l.resource)==null?void 0:D.animations)==null?void 0:k.neutral:{}},[l.emotion,l==null?void 0:l.animationId,l==null?void 0:l.animation,(v=l==null?void 0:l.resource)==null?void 0:v.animations,d]),E=React$2.useCallback(()=>{if(u.current){const R=u.current.userData.animator;R.getAction("idle")&&R.mix("idle",.1)}},[]);React$2.useEffect(()=>{var R,_,w;if(t)if(n)if(e){const C=(w=(_=(R=l==null?void 0:l.resource)==null?void 0:R.animations)==null?void 0:_.talking)==null?void 0:w.url;if(C&&u.current){const N=u.current.userData.animator,P=`${C}_talking`;N.getAction(P)?(N.mix(P,.1),f(!0)):loader$1.load(C,({animations:D})=>{if(!u.current)return;const k=N.getAction("idle").getClip();N.register(P,mixWithTalkingClip(D[0],k)),N.mix(P,.1),f(!0)})}}else E();else h&&E()},[(y=(g=(S=l==null?void 0:l.resource)==null?void 0:S.animations)==null?void 0:g.talking)==null?void 0:y.url,e,n,E,h,t]);const T=React$2.useCallback(R=>{if(l.type==="character"){const _=R.getObjectByName("Head_M",!0);_?(_.updateMatrixWorld(!0),box.setFromObject(R),box.getSize(size),_.getWorldPosition(worldPos),a.current.lookAt(worldPos)):a.current.position.setY(size.y-1.5*1.3),a.current.zoom=1.5}else cameraFitAnyObject(R,a.current),a.current.zoom=1;a.current.updateProjectionMatrix()},[l]);return fiber.useFrame(({gl:R,scene:_})=>{if(a.current&&o.current){const w=document.querySelectorAll(".conversation--character__item")[l.slot];if(w){const C=w.getBoundingClientRect(),N=w.parentNode.getBoundingClientRect(),[P,D]=[C.right-C.left,C.bottom-C.top];if(a.current.aspect=P/D,a.current.updateProjectionMatrix(),d&&u.current){box.setFromObject(u.current),box.getSize(size);const M=u.current.getObjectByName("Head_M",!0);M?(M.getWorldPosition(worldPos),a.current.lookAt(worldPos)):a.current.position.setY(size.y-1.5*1.3),a.current.zoom=1.5}const k={top:C.top-N.top,right:C.right-N.right,left:C.left-N.left,bottom:C.bottom-N.bottom},F=isMobile?24:40;k.bottom+=n?-F:F,R.setViewport(k.left,k.bottom,P,D),R.setScissor(k.left,k.bottom,P,D),o.current.environment=_.environment,R.render(o.current,a.current)}}},1),l.type==="image"?null:jsxRuntimeExports.jsxs("scene",{ref:o,children:[(b=l.resource)!=null&&b.url?jsxRuntimeExports.jsx(arcadeThreeCore.SceneResource,{ref:u,name:`char_${l.uid}`,url:l.resource.url,animationUrl:p.url,type:l.type,onRender:T,texturable:!0,interactive:!0,merge:l.type!=="character",visible:t}):null,jsxRuntimeExports.jsx(drei.PerspectiveCamera,{ref:a,fov:35,position:defaultCamPos,rotation:[0,0,0],onUpdate:R=>{R.layers.enableAll()},manual:!0}),jsxRuntimeExports.jsx(LightSet,{})]})}function PanelsWrapper({characters:l,slots:e,ttsStarted:n,flex:t,currentMessage:a,lod:o}){const[d,h]=React$2.useState(!1);return fiber.useFrame(({gl:f})=>{f.setScissorTest(!1),f.clear(!0,!0),f.setScissorTest(!0)}),React$2.useEffect(()=>{const f=()=>{h(!0)};return arcadeThreeCore.ProgressManager.addEventListener("loaded",f),()=>{arcadeThreeCore.ProgressManager.removeEventListener("loaded",f)}},[]),jsxRuntimeExports.jsx(arcadeThreeCore.QualityManager,{lod:o,active:!0,children:e.map((f,u)=>{let p=null;const E=l.findIndex(T=>T&&T.uid===f.uid);if(E>=0){const T=t?E:u;return p={...l[E]},p.slot=T,jsxRuntimeExports.jsx(Panel,{character:p,active:a.position===T,ttsStarted:n,visible:d},`${`${p.uid}_${u}`}_${E}`)}return null})})}function Scene(l){return l.lowQuality?null:jsxRuntimeExports.jsxs(arcadeThreeCore.Renderer,{className:"conversation--canvas",style:{position:"absolute",width:"100%",height:"100%"},gl:{antialias:!0},fullscreen:!1,onCreated:({gl:e})=>{e.setClearColor("white",0)},children:[jsxRuntimeExports.jsx(arcadeThreeCore.SettingsController,{current:{animate:l.pause}}),jsxRuntimeExports.jsx(arcadeThreeCore.EnvironmentWrapper,{url:"https://min.gamelearn.io/statics/envs/envmap_1k.hdr"}),jsxRuntimeExports.jsx(PanelsWrapper,{...l})]})}function SlotList({characters:l,actors:e,lodSettings:n,ttsStarted:t,currentMessage:a,flex:o,slots:d,children:h,pause:f,getEvent:u}){const p=({character:b,active:R,slot:_})=>({character:b,active:R,emotion:R?a.emotion:"neutral",slot:_}),E=React$2.useMemo(()=>u({type:"currentLod"}),[u]),T=E==="divideby64",v=d.reduce((b,R)=>{var C,N;const _=e==null?void 0:e.find(P=>P.uid===R.uid),w={...R};if(R.character)w.name=R.alias||R.character.name,w.resource=w.character.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type="character",b.push(w);else if(_){const{resource:P}=_;w.name=R.alias||R.name,w.position=w.position>=0?w.position:-1,w.resource=P,w.type=_.type,b.push(w)}else R.type?(w.name=R.alias||((C=R.character)==null?void 0:C.name)||R.name,w.resource=((N=w.character)==null?void 0:N.resource)||R.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type=R.type,b.push(w)):o||b.push(null);return b},[]),S=v.length&&v.some(b=>b),g=l.filter(b=>d.find(R=>b.uid===R.uid));function y(){return S?v.map((b,R)=>b?jsxRuntimeExports.jsx(Slot,{lowQuality:T,...p({character:b,active:a.position===b.position,slot:R})},`${b.uid+R}`):jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${R}`},`void_${0+R}`)):o?g.map((b,R)=>{const _=a.position===R;return jsxRuntimeExports.jsx(Slot,{...p({character:b,active:_,slot:R})},`${b.uid+R}`)}):d.length>0?d.map((b,R)=>{const _=l.find(w=>w.uid===b.uid);if(_){const w=a.position===R;return _.name=b.alias||_.name,jsxRuntimeExports.jsx(Slot,{...p({character:_,active:w,slot:R})},`${_.uid+R}`)}return jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${R}`},`${0+R}`)}):null}return jsxRuntimeExports.jsxs("div",{className:"conversation--characters",children:[jsxRuntimeExports.jsx(Scene,{characters:S?v:g,slots:d,flex:o,currentMessage:a,lodSettings:n,ttsStarted:t,pause:f,lod:E,lowQuality:T}),h||jsxRuntimeExports.jsx(y,{})]})}SlotList.defaultProps={characters:[],currentMessage:{},flex:!0,slots:[]};function Options({inherited:l,options:e,selectedChoice:n,selectChoice:t,showingResults:a,simplifiedOptions:o,required:d}){const[h,f]=React$2.useState(null),u=E=>{o?(f(E),setTimeout(()=>{t(E),f(null)},1e3)):t(E)},p=E=>!!(a&&(n==null?void 0:n.id)===E.id||(n==null?void 0:n.right)===!0||a&&!d);return e==null?void 0:e.filter(E=>E.text).map(E=>jsxRuntimeExports.jsxs("div",{className:`${l?"conversation--question custom-radio":"custom-radio"}
67
67
  ${(h==null?void 0:h.id)===E.id?"radio-text-clicked":""}`,children:[jsxRuntimeExports.jsx("input",{onChange:()=>{u(E)},className:"radio",type:"radio",id:E.text_labelId,name:E.id,checked:(n==null?void 0:n.id)===E.id,disabled:p(E)}),jsxRuntimeExports.jsx("label",{className:`${E.right?"radio-text-success":"radio-text-fail"}`,htmlFor:E.text_labelId,children:HTMLReactParser$1(E.text)})]},`${E.id}_${E.text_labelId}`))}const noop=()=>{};function BasicDecision({children:l,question:e,showingResults:n,selected:t,required:a,failed:o,onNext:d,translate:h,hasRewards:f,options:u}){const[p,E]=React$2.useState(!1);function T(){(t==null?void 0:t.id)!==void 0&&!p&&(E(!0),d())}return jsxRuntimeExports.jsxs("div",{className:`popup popup__large popup__basicDecision ${n&&(t!=null&&t.feedback)?"popup__feedback":""}`,children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:n?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[l,!(t!=null&&t.feedback)&&f.length===0&&jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e!==""&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:e})}),!(t!=null&&t.feedback)&&f.length>0&&jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e})]}):jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e})}),jsxRuntimeExports.jsx("div",{className:"popup__questions",dir:"auto",children:u}),jsxRuntimeExports.jsx("div",{className:"popup--buttons",children:(a?!o:(t==null?void 0:t.id)!==void 0)?jsxRuntimeExports.jsx("button",{"data-testid":"continueButtonDecision",type:"button",className:`gat--btn__navigation ${p||(t==null?void 0:t.id)===void 0?"disabled":""}`,onClick:()=>T(),"aria-label":h("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null})]})}function ComplexDecision({question:l,inScene:e,disabled:n,onNext:t,children:a,simplifiedOptions:o}){return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`conversation--body ${e?"conversation--body--inScene":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"conversation--message",children:[l!==""&&jsxRuntimeExports.jsx("div",{className:"conversation--main__text",children:HTMLReactParser$1(l)}),a]}),jsxRuntimeExports.jsxs("div",{style:{visibility:o?"hidden":"visible"},className:"conversation--controls conversation--controls--fixedbottom",children:[jsxRuntimeExports.jsx("div",{className:"gat--btn__round disabled",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"continueButtonComplexDecision",className:`gat--btn__round ${n?"disabled":""}`,type:"button",onClick:()=>!n&&t(),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})}function DecisionBody({options:l,question:e,inherited:n,branched:t,changeOption:a,onNext:o,failed:d,showingResults:h,currentSelectedChoice:f,children:u,translate:p,hasRewards:E,inScene:T,required:v,simplifiedOptions:S}){const g=R=>{h&&d&&a(R),o(R)},y=!h&&(f==null?void 0:f.id)!==void 0||!d,b={inherited:n,selectedChoice:f,selectChoice:(!v||t)&&(f==null?void 0:f.id)!==void 0||v&&!d?noop:g,options:l,showingResults:h,simplifiedOptions:S,required:v};return n?jsxRuntimeExports.jsx(ComplexDecision,{disabled:!y,question:e,inScene:T,onNext:()=>o(f),simplifiedOptions:S,children:jsxRuntimeExports.jsx(Options,{...b})}):jsxRuntimeExports.jsx(BasicDecision,{question:e,showingResults:h,selected:f,required:v,failed:d,onNext:()=>o(f),translate:p,hasRewards:E,options:jsxRuntimeExports.jsx(Options,{...b}),children:u})}function Wrapper({children:l,inherit:e}){return e?jsxRuntimeExports.jsx("div",{className:"conversation--feedback",children:l}):l}function FeedBack({choice:l,inherited:e,question:n}){return l.feedback?jsxRuntimeExports.jsx(Wrapper,{inherit:e,children:l.feedback&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"conversation--feedback__title",children:n}),jsxRuntimeExports.jsxs("div",{className:"conversation--feedback__text",dir:"auto",children:[l.right?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"conversation--feedback__wysiwyg",children:HTMLReactParser$1(l.feedback)})]})]})}):null}function DecisionComponent({emitEvent:l,getEvent:e,soundActions:n,keyboardControl:t,inScene:a,...o}){var I,$;const{inheritProps:d={},decisionNumber:h,required:f,question:u,onAddPoints:p,onFinish:E,branched:T,simplifiedOptions:v}=o,S=Object.keys(d).length>0,[g,y]=React$2.useState("options"),[b,R]=React$2.useState({}),[_]=n,w=f&&!(b!=null&&b.right),C=React$2.useRef(),N=z=>{var X;(X=z.audio)!=null&&X.url&&_(z.audio.url,"audio_file",!1,z.audioVolume)},P={...d,slots:d.slots?d.slots:d.characters,currentMessage:{position:null,emotion:""},emitEvent:l,getEvent:e};d&&d.flex&&P.slots&&(P.characters=P.characters.filter(z=>P.slots.find(X=>X.uid===z.uid)));const D=z=>{l({type:"decisionJournal",payload:{choice:z,decisionNumber:h}})},k=z=>{if(!w&&g==="results")_("click-ui"),S?v?E&&(D(z),E(z,()=>{R({}),y("options")})):(p&&p(z),D(z),l({type:"addPoints",payload:z==null?void 0:z.rewards,finish:!1,complex:!0,onFinish:()=>{E?E(z,()=>{R({}),y("options")}):l({type:"success"}),R({}),y("options")}})):(D(z),l({type:"addPoints",payload:z==null?void 0:z.rewards,finish:!0,complex:!0}));else if(Object.keys(z).length>0)if(_("click-ui"),v)if(z!=null&&z.rewards.filter(X=>X.type==="var").length){D({...z,simplified:!0});const X=z==null?void 0:z.rewards.filter(te=>te.type==="var");l({type:"addPoints",payload:X,finish:!1,complex:!0,onFinish:()=>{E?E(z,()=>{R({}),y("options")}):l({type:"success"}),R({}),y("options")}})}else D({...z,simplified:!0}),E(z,()=>{R({}),y("options")});else z.right?_("score"):(_("fail"),T||(S||f?(D(z),l({type:"addPoints",payload:z==null?void 0:z.rewards,finish:!1,complex:!0})):f||(R({}),y("options")))),R(z),N(z),y("results")},F={...o,selectView:y,selectedView:g,emitEvent:l,inherited:S,branched:T,soundActions:n,showingResults:g==="results",currentSelectedChoice:b,hasRewards:(b==null?void 0:b.rewards)||[],failed:w,inScene:a,required:f,simplifiedOptions:v,changeOption:z=>{_("click-ui"),R(z),y("options")},onNext:k,translate:z=>e({type:"translate",payload:z})},M=t({disabled:g!=="results",repeat:!1,forward:()=>{if(C.current!==b)C.current=b;else return;k(b)}});return React$2.useEffect(()=>M(),[M]),S?jsxRuntimeExports.jsx("div",{className:`conversation--layer
68
68
  ${b!=null&&b.feedback?"":"conversation--layer__defaultFeedback"}
69
- ${g==="results"?"conversation--layer__feedback":""}`,children:jsxRuntimeExports.jsxs("div",{className:`conversation ${a?"conversation--inScene":""}`,style:(I=d.background)!=null&&I.img?{backgroundImage:`url("${($=d.background.img)==null?void 0:$.url}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...P,children:g==="results"&&(b!=null&&b.feedback)?jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l}):null}),jsxRuntimeExports.jsx(DecisionBody,{...F})]})}):jsxRuntimeExports.jsx("div",{className:"popup--layer popup--layer--transparent",children:jsxRuntimeExports.jsx(DecisionBody,{...F,children:jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l})})})}function ImageComponent({emitEvent:l,img:e,imgName:n,documentType:t,visible:a,viewed:o,imgId_labelId:d,soundActions:h,keyboardControl:f,getEvent:u}){const p=b=>u({type:"translate",payload:b}),[E,T]=React$2.useState(!1),v=e.url,[S]=h,g=React$2.useCallback(()=>{S("click-ui"),l({type:"finishMedia",payload:{imgId:d,name:n,imgName:n,documentType:t,type:"image"}})},[S,d,n,t,l]),y=f({disabled:o,forward:g,escape:g});return React$2.useEffect(()=>y(),[y]),React$2.useEffect(()=>{!a&&!E&&(T(!0),g())},[g,a,E]),a?jsxRuntimeExports.jsx("div",{className:o?"notes--results":"readings--container readings--container--darkopacity",children:jsxRuntimeExports.jsxs("div",{className:o?"notes--results__text":"readings readings--image",children:[v&&jsxRuntimeExports.jsx("img",{src:v,alt:n}),o?null:jsxRuntimeExports.jsx("div",{className:v?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:g,"aria-label":p("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})})]})}):null}function VoiceOver({name:l}){return jsxRuntimeExports.jsx("div",{className:"conversation--voice__over",children:jsxRuntimeExports.jsx("span",{children:l||"Voice-Over"})})}function ThinkFul({text:l}){return jsxRuntimeExports.jsxs("div",{className:"conversation--voice__over",children:[jsxRuntimeExports.jsx("span",{className:"icon-bubble-thinkful-black"}),jsxRuntimeExports.jsxs("span",{children:["[",l,"]"]})]})}function Message({current:l,translate:e}){var t,a;const n=l.text;return jsxRuntimeExports.jsxs("div",{className:`conversation--message ${l.voiceOver||(t=l==null?void 0:l.emotion)!=null&&t.includes("think")?"voice--over":""}`,children:[l.voiceOver?jsxRuntimeExports.jsx(VoiceOver,{name:l.name}):null,(a=l==null?void 0:l.emotion)!=null&&a.includes("think")?jsxRuntimeExports.jsx(ThinkFul,{text:e("emotion.thinking")}):null,jsxRuntimeExports.jsx("div",{className:"conversation--main__text",children:HTMLReactParser$1(n)})]})}Message.defaultProps={current:{},voiceOver:!1};const cleanStyle={width:"100%",height:"100%",position:"static"};function HtmlWrap(l){const e=document.querySelector(".screens--container");return React$2.useEffect(()=>(l.onMount&&l.onMount(),()=>{l.onUnMount&&l.onUnMount()}),[]),jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{zIndexRange:[6,6],style:cleanStyle,portal:e?{current:e}:void 0,onOcclude:()=>{},calculatePosition:()=>[0,0],wrapperClass:"htmlpro-wrap-100-h",children:l.children})}const characterMs$3=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:l,emitEvent:e,getEvent:n,pause:t,lines:a,edges:o,characters:d,actors:h,background:f,soundActions:u,lodSettings:p,autoPlay:E,autoEnd:T,progress:v}){var Et,$e,pt;const S=a.length-1<=(v==null?void 0:v.line)?a.length-1:(v==null?void 0:v.line)||0,[g,y]=React$2.useState(!1),[b,R]=React$2.useState(!0),[_,w]=React$2.useState(!!E),[C,N]=React$2.useState(!1),[P,D]=React$2.useState(S),[k,F]=React$2.useState(!1),[M]=u,{start:I,stop:$}=useTimeout(),z=((Et=f==null?void 0:f.img)==null?void 0:Et.url)||null,X=a[P],{voiceOver:te,decision:ae}=X;let{flex:ee}=X,K=[];const ne=!!o,ue=te||X.type==="conversationalNarration",pe=ae||X.type==="conversationalDecision",J=X.type==="conversationalCamera",[H,W]=React$2.useState([]),V=React$2.useMemo(()=>H[H.length-1],[H]),B=React$2.useCallback(()=>{const He=o.find(Pe=>Pe.fromId===V)||o.find(Pe=>Pe.toId===V),Ye=a.find(Pe=>Pe.id===(He==null?void 0:He.fromId));return!V&&(v==null?void 0:v.line)>=0?{decision:!0}:Ye},[o,a,V,v==null?void 0:v.line]),Y=React$2.useCallback(()=>{if(ne){const Ye=B();return Ye==null?void 0:Ye.decision}const He=a[P-1]?a[P-1]:{};return P>0&&(He==null?void 0:He.decision)},[ne,B,a,P]),re=React$2.useCallback(()=>{if(ne){const Ye=B();return(Ye==null?void 0:Ye.type)==="conversationalCamera"}const He=a[P-1]?a[P-1]:{};return P>0&&(He==null?void 0:He.type)==="conversationalCamera"},[ne,a,P,B]),le=React$2.useCallback(He=>n({type:"translate",payload:He}),[n]),fe=React$2.useMemo(()=>{var Ye,Pe;if(pe)return{};if(ue)return X;const He=(Ye=X==null?void 0:X.slots)==null?void 0:Ye.find(we=>we.uid&&we.talking);return He||((Pe=X==null?void 0:X.slots)==null?void 0:Pe.find(we=>we.uid&&we.text))},[X,ue,pe]),de=a.slice(0,P+1).reverse().find(He=>He.slots),ge=!pe&&(($e=X.slots)==null?void 0:$e.filter(He=>He.uid).length),Ee=characterMs$3*(((pt=fe==null?void 0:fe.text)==null?void 0:pt.length)||0);let Re=[];X.slots?Re=X.slots:de&&(Re=de.slots);const Oe=Re.filter(He=>He.uid).map(He=>{const Ye=(d||h||[]).find(Pe=>Pe.uid===He.uid);return Ye&&(He.resource=Ye.resource,He.type=Ye.type),He.resource||(He.resource={}),He}),Ne={characters:Oe,lodSettings:p,actors:h,currentMessage:fe||{},slots:ue?K:X.slots,flex:ee,pause:t,getEvent:n};if(ue){const He=a.slice(P).find(Pe=>Pe.slots),Ye=de||He;Ye&&(K=Ye.slots,ee=Ye.flex)}else if(!pe&&ge&&(X.slots.forEach(He=>{const Ye=Oe.findIndex(Pe=>Pe.uid===He.uid);Ye>=0&&(Oe[Ye].emotion=He.emotion)}),fe&&fe.uid)){const He=X.slots.findIndex(Pe=>Pe.uid===fe.uid),Ye=Oe.findIndex(Pe=>Pe.uid===fe.uid);Oe.forEach(Pe=>{Pe.uid===fe.uid&&(Pe.name=fe.alias)}),fe.position=ee?Ye:He}const Xe=React$2.useCallback(()=>{e({type:"success"})},[e]),ft=React$2.useCallback((He,Ye)=>{const Pe=[3,2,1][He.id],ye=o.filter(De=>De.fromId===X.id).find(De=>parseInt(De.fromPointIndex)===Pe);if(ye){const De=a.findIndex(qe=>qe.id===ye.toId);ye.fromId===ye.toId?Ye():De>=0?(D(De),e({type:"notifyProgress",payload:{line:De}})):Xe()}else Xe()},[X.id,o,e,Xe,a]),nt=React$2.useCallback((He=!0)=>{const Ye=He?["fromId","toId"]:["toId","fromId"],Pe=o.filter(De=>De[Ye[0]]===X.id),we=Pe.length===1?Pe[0]:Pe.find(De=>De[Ye[1]]===V);if(!(we!=null&&we[Ye[0]])){Xe();return}He||W(H.slice(0,-1));const ye=a.findIndex(De=>De.id===we[Ye[1]]);ye>=0?(D(ye),e({type:"notifyProgress",payload:{line:ye}})):Xe()},[X.id,o,H,e,Xe,V,a]),St=React$2.useCallback(He=>{if(ne){if(He){const Ye=[3,2,1][He.id],we=o.filter(ye=>ye.fromId===X.id).find(ye=>parseInt(ye.fromPointIndex)===Ye);if(we){const ye=a.findIndex(De=>De.id===we.toId);ye>=0&&e({type:"notifyProgress",payload:{line:ye}})}else e({type:"saveNode"})}}else if(P<a.length-1){const Pe=P+1;e({type:"notifyProgress",payload:{line:Pe}})}else e({type:"saveNode"})},[o,a,e,P,X.id,ne]),ze=React$2.useCallback((He,Ye)=>{let Pe=!1;if(F(!1),W([...H,X.id]),R(!1),N(!1),ne)He?ft(He,Ye):nt();else if(P<a.length-1){const ye=P+1;D(ye),e({type:"notifyProgress",payload:{line:ye}}),Ye&&Ye()}else T||pe||J?Xe():Pe=!0;Pe||R(!0)},[H,X.id,ne,P,a.length,T,pe,J,ft,nt,e,Xe]),Me=()=>{if(R(!1),F(!1),N(!1),ne)nt(!1);else if(!Y()){const He=P-1;D(He),e({type:"notifyProgress",payload:{line:He}})}R(!0)},ke=React$2.useCallback(()=>ne?X&&X.type!=="conversationalDecision"&&!o.find(He=>He.fromId===X.id):P===a.length-1,[P,X,o,ne,a.length]),We=()=>{M("click-ui"),ke()?Xe():(w(!1),ze())},tt=()=>{M("click-ui"),w(!1),Me()},ct=_&&!pe&&!t&&!J,Dt=React$2.useMemo(()=>P===0||Y()||re(),[P,Y,re]);useEkho({audioType:X==null?void 0:X.audioType,volume:X==null?void 0:X.audioVolume,voice:X==null?void 0:X.voice,started:b,slide:P,text:cleanTextOfHtmlTags(fe==null?void 0:fe.text),audio:X==null?void 0:X.audio,soundActions:u,getEvent:n,pauseTTS:t,onStart:()=>{var He;(He=fe==null?void 0:fe.emotion)!=null&&He.includes("think")||F(!0)},onError:()=>{N(!0)},onFinish:()=>{F(!1),ct&&ze()}}),React$2.useEffect(()=>{var Ye;let He;return pe?()=>{}:(((X==null?void 0:X.audioType)==="none"||C)&&!((Ye=fe==null?void 0:fe.emotion)!=null&&Ye.includes("think"))&&(F(!0),He=setTimeout(()=>{F(!1)},Ee<minMs$1?minMs$1:Ee)),()=>{He&&clearTimeout(He)})},[C,X,fe==null?void 0:fe.emotion,Ee,pe]),React$2.useEffect(()=>(ct&&((X==null?void 0:X.audioType)==="none"||C)&&(!ke()||ke()&&T)&&I(ze,Ee<minMs$1?minMs$1:Ee),()=>{$()}),[fe,I,$,ze,X==null?void 0:X.audioType,ct,C,T,a,ke,Ee]),React$2.useEffect(()=>{if(ne&&!g){const He=v==null?void 0:v.line;if(He>=0){y(!0),D(He);return}const Ye=a.filter(Pe=>!o.find(we=>we.toId===Pe.id));if(Ye.length){const Pe=Ye[0],we=a.indexOf(Pe);we>=0&&(y(!0),D(we))}}},[o,ne,a,g,v==null?void 0:v.line]);const rt=l({disabled:pe,repeat:!1,forward:We,rewind:Dt?null:tt});if(React$2.useEffect(()=>rt(),[rt]),J)return jsxRuntimeExports.jsx(ChangeCamera,{...X,transition:{type:"none"},emitEvent:e,success:!1,onFinish:ze},`change-camera-${P}`);if(pe){const He=a[P].id?a.filter(Pe=>Pe.decision).findIndex(Pe=>Pe.id===a[P].id)+1:a.filter(Pe=>Pe.decision).findIndex(Pe=>Pe===a[P])+1,Ye={...X.payload,decisionNumber:He,required:!ne,branched:ne,onAddPoints:St,onFinish:ze,keyboardControl:l,emitEvent:e,getEvent:n,soundActions:u,inheritProps:{characters:Oe,background:f,flex:de?de.flex:!0,slots:de?de.slots:[]}};return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx(DecisionComponent,{...Ye})})}return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversational-pro-image",className:"conversation",style:z?{backgroundImage:`url("${z}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...Ne,ttsStarted:k}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[fe?jsxRuntimeExports.jsx(Message,{current:fe,translate:le}):null,jsxRuntimeExports.jsxs("div",{className:"conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-back",className:`gat--btn__round ${Dt?"disabled":""}`,disabled:Dt?!0:"",type:"button",onClick:tt,"aria-label":LangIsRtl()?le("storylines.misc.forward"):le("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-next",className:`gat--btn__round ${_&&ke()?"glowing-animation":""}`,type:"button",onClick:We,"aria-label":LangIsRtl()?le("storylines.misc.rewind"):le("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:l,getEvent:e,soundActions:n,messages:t,characters:a,alias:o,background:d,lodSettings:h}){var y;const[f,u]=React$2.useState(0),[p]=n,E=((y=d==null?void 0:d.img)==null?void 0:y.url)||null,T=t[f],v=a.map((b,R)=>({...b,name:o[R]?o[R]:b.name,uid:R})),S=()=>{const b=t.length-1;p("click-ui"),f+1<=b?u(f+1):l({type:"success"})},g=()=>{f>0&&(u(f-1),p("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversation-component",className:"conversation arcade-conversation",style:E?{backgroundImage:`url("${E}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:v,lodSettings:h,currentMessage:T,slots:v,emitEvent:l,getEvent:e,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[T?jsxRuntimeExports.jsx(Message,{current:T,voiceOver:T.emotion===null}):jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"conversation--controls arcade-conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-back-button",className:`gat--btn__round ${f>0?"":"visibility--hidden"}`,type:"button",onClick:g,children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-next-button",className:"gat--btn__round",type:"button",onClick:S,children:jsxRuntimeExports.jsx("span",{className:"icon-next"})})]})]})]})})}function Vignette({vignette:l,alias:e,translate:n,backgroundImageCover:t}){var u;const o=(l.img||{url:"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg"}).url,[d,h]=React$2.useState(!0),f=p=>{document.querySelector(`#${p}`).focus(),h(!d)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{"data-testid":"comic-image",className:`comic-image ${t?"comic-image--cover":""}`,children:o&&jsxRuntimeExports.jsx("img",{src:o,alt:"comic pic"})}),(u=l==null?void 0:l.textData)!=null&&u.text?jsxRuntimeExports.jsxs("div",{"data-testid":"comicCollapsable",className:`comic-collapsable ${d?"comic-collapsable--opened":""}`,children:[jsxRuntimeExports.jsx("button",{id:"buttonDown","data-testid":"buttonDown",onClick:()=>f("buttonUp"),type:"button",className:"un-btn comic-collapsable__headertoggle","aria-label":n("comic.toggleText"),children:jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"})}),jsxRuntimeExports.jsxs("div",{className:"comic-collapsable__text",children:[e?jsxRuntimeExports.jsxs("b",{children:[e,": "]}):null,HTMLReactParser$1(l.textData.text)]})]}):null,jsxRuntimeExports.jsx("button",{id:"buttonUp","data-testid":"buttonUp",tabIndex:d?"-1":"0","aria-hidden":d,className:`unset-button comic-buttonup
69
+ ${g==="results"?"conversation--layer__feedback":""}`,children:jsxRuntimeExports.jsxs("div",{className:`conversation ${a?"conversation--inScene":""}`,style:(I=d.background)!=null&&I.img?{backgroundImage:`url("${($=d.background.img)==null?void 0:$.url}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...P,children:g==="results"&&(b!=null&&b.feedback)?jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l}):null}),jsxRuntimeExports.jsx(DecisionBody,{...F})]})}):jsxRuntimeExports.jsx("div",{className:"popup--layer popup--layer--transparent",children:jsxRuntimeExports.jsx(DecisionBody,{...F,children:jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l})})})}function ImageComponent({emitEvent:l,img:e,imgName:n,documentType:t,visible:a,viewed:o,imgId_labelId:d,soundActions:h,keyboardControl:f,getEvent:u}){const p=b=>u({type:"translate",payload:b}),[E,T]=React$2.useState(!1),v=e.url,[S]=h,g=React$2.useCallback(()=>{S("click-ui"),l({type:"finishMedia",payload:{imgId:d,name:n,imgName:n,documentType:t,type:"image"}})},[S,d,n,t,l]),y=f({disabled:o,forward:g,escape:g});return React$2.useEffect(()=>y(),[y]),React$2.useEffect(()=>{!a&&!E&&(T(!0),g())},[g,a,E]),a?jsxRuntimeExports.jsx("div",{className:o?"notes--results":"readings--container readings--container--darkopacity",children:jsxRuntimeExports.jsxs("div",{className:o?"notes--results__text":"readings readings--image",children:[v&&jsxRuntimeExports.jsx("img",{src:v,alt:n}),o?null:jsxRuntimeExports.jsx("div",{className:v?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:g,"aria-label":p("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})})]})}):null}function VoiceOver({name:l}){return jsxRuntimeExports.jsx("div",{className:"conversation--voice__over",children:jsxRuntimeExports.jsx("span",{children:l||"Voice-Over"})})}function ThinkFul({text:l}){return jsxRuntimeExports.jsxs("div",{className:"conversation--voice__over",children:[jsxRuntimeExports.jsx("span",{className:"icon-bubble-thinkful-black"}),jsxRuntimeExports.jsxs("span",{children:["[",l,"]"]})]})}function Message({current:l,translate:e}){var t,a;const n=l.text;return jsxRuntimeExports.jsxs("div",{className:`conversation--message ${l.voiceOver||(t=l==null?void 0:l.emotion)!=null&&t.includes("think")?"voice--over":""}`,children:[l.voiceOver?jsxRuntimeExports.jsx(VoiceOver,{name:l.name}):null,(a=l==null?void 0:l.emotion)!=null&&a.includes("think")?jsxRuntimeExports.jsx(ThinkFul,{text:e("emotion.thinking")}):null,jsxRuntimeExports.jsx("div",{className:"conversation--main__text",children:HTMLReactParser$1(n)})]})}Message.defaultProps={current:{},voiceOver:!1};const cleanStyle={width:"100vw",height:"100%",position:"static"};function HtmlWrap(l){const e=document.querySelector(".screens--container");return React$2.useEffect(()=>(l.onMount&&l.onMount(),()=>{l.onUnMount&&l.onUnMount()}),[]),jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{zIndexRange:[6,6],style:cleanStyle,portal:e?{current:e}:void 0,onOcclude:()=>{},calculatePosition:()=>[0,0],wrapperClass:"htmlpro-wrap-100-h",children:l.children})}const characterMs$3=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:l,emitEvent:e,getEvent:n,pause:t,lines:a,edges:o,characters:d,actors:h,background:f,soundActions:u,lodSettings:p,autoPlay:E,autoEnd:T,progress:v}){var Et,$e,pt;const S=a.length-1<=(v==null?void 0:v.line)?a.length-1:(v==null?void 0:v.line)||0,[g,y]=React$2.useState(!1),[b,R]=React$2.useState(!0),[_,w]=React$2.useState(!!E),[C,N]=React$2.useState(!1),[P,D]=React$2.useState(S),[k,F]=React$2.useState(!1),[M]=u,{start:I,stop:$}=useTimeout(),z=((Et=f==null?void 0:f.img)==null?void 0:Et.url)||null,X=a[P],{voiceOver:te,decision:ae}=X;let{flex:ee}=X,K=[];const ne=!!o,ue=te||X.type==="conversationalNarration",pe=ae||X.type==="conversationalDecision",J=X.type==="conversationalCamera",[H,W]=React$2.useState([]),V=React$2.useMemo(()=>H[H.length-1],[H]),B=React$2.useCallback(()=>{const He=o.find(Pe=>Pe.fromId===V)||o.find(Pe=>Pe.toId===V),Ye=a.find(Pe=>Pe.id===(He==null?void 0:He.fromId));return!V&&(v==null?void 0:v.line)>=0?{decision:!0}:Ye},[o,a,V,v==null?void 0:v.line]),Y=React$2.useCallback(()=>{if(ne){const Ye=B();return Ye==null?void 0:Ye.decision}const He=a[P-1]?a[P-1]:{};return P>0&&(He==null?void 0:He.decision)},[ne,B,a,P]),re=React$2.useCallback(()=>{if(ne){const Ye=B();return(Ye==null?void 0:Ye.type)==="conversationalCamera"}const He=a[P-1]?a[P-1]:{};return P>0&&(He==null?void 0:He.type)==="conversationalCamera"},[ne,a,P,B]),le=React$2.useCallback(He=>n({type:"translate",payload:He}),[n]),fe=React$2.useMemo(()=>{var Ye,Pe;if(pe)return{};if(ue)return X;const He=(Ye=X==null?void 0:X.slots)==null?void 0:Ye.find(we=>we.uid&&we.talking);return He||((Pe=X==null?void 0:X.slots)==null?void 0:Pe.find(we=>we.uid&&we.text))},[X,ue,pe]),de=a.slice(0,P+1).reverse().find(He=>He.slots),ge=!pe&&(($e=X.slots)==null?void 0:$e.filter(He=>He.uid).length),Ee=characterMs$3*(((pt=fe==null?void 0:fe.text)==null?void 0:pt.length)||0);let Re=[];X.slots?Re=X.slots:de&&(Re=de.slots);const Oe=Re.filter(He=>He.uid).map(He=>{const Ye=(d||h||[]).find(Pe=>Pe.uid===He.uid);return Ye&&(He.resource=Ye.resource,He.type=Ye.type),He.resource||(He.resource={}),He}),Ne={characters:Oe,lodSettings:p,actors:h,currentMessage:fe||{},slots:ue?K:X.slots,flex:ee,pause:t,getEvent:n};if(ue){const He=a.slice(P).find(Pe=>Pe.slots),Ye=de||He;Ye&&(K=Ye.slots,ee=Ye.flex)}else if(!pe&&ge&&(X.slots.forEach(He=>{const Ye=Oe.findIndex(Pe=>Pe.uid===He.uid);Ye>=0&&(Oe[Ye].emotion=He.emotion)}),fe&&fe.uid)){const He=X.slots.findIndex(Pe=>Pe.uid===fe.uid),Ye=Oe.findIndex(Pe=>Pe.uid===fe.uid);Oe.forEach(Pe=>{Pe.uid===fe.uid&&(Pe.name=fe.alias)}),fe.position=ee?Ye:He}const Xe=React$2.useCallback(()=>{e({type:"success"})},[e]),ft=React$2.useCallback((He,Ye)=>{const Pe=[3,2,1][He.id],ye=o.filter(De=>De.fromId===X.id).find(De=>parseInt(De.fromPointIndex)===Pe);if(ye){const De=a.findIndex(qe=>qe.id===ye.toId);ye.fromId===ye.toId?Ye():De>=0?(D(De),e({type:"notifyProgress",payload:{line:De}})):Xe()}else Xe()},[X.id,o,e,Xe,a]),nt=React$2.useCallback((He=!0)=>{const Ye=He?["fromId","toId"]:["toId","fromId"],Pe=o.filter(De=>De[Ye[0]]===X.id),we=Pe.length===1?Pe[0]:Pe.find(De=>De[Ye[1]]===V);if(!(we!=null&&we[Ye[0]])){Xe();return}He||W(H.slice(0,-1));const ye=a.findIndex(De=>De.id===we[Ye[1]]);ye>=0?(D(ye),e({type:"notifyProgress",payload:{line:ye}})):Xe()},[X.id,o,H,e,Xe,V,a]),St=React$2.useCallback(He=>{if(ne){if(He){const Ye=[3,2,1][He.id],we=o.filter(ye=>ye.fromId===X.id).find(ye=>parseInt(ye.fromPointIndex)===Ye);if(we){const ye=a.findIndex(De=>De.id===we.toId);ye>=0&&e({type:"notifyProgress",payload:{line:ye}})}else e({type:"saveNode"})}}else if(P<a.length-1){const Pe=P+1;e({type:"notifyProgress",payload:{line:Pe}})}else e({type:"saveNode"})},[o,a,e,P,X.id,ne]),ze=React$2.useCallback((He,Ye)=>{let Pe=!1;if(F(!1),W([...H,X.id]),R(!1),N(!1),ne)He?ft(He,Ye):nt();else if(P<a.length-1){const ye=P+1;D(ye),e({type:"notifyProgress",payload:{line:ye}}),Ye&&Ye()}else T||pe||J?Xe():Pe=!0;Pe||R(!0)},[H,X.id,ne,P,a.length,T,pe,J,ft,nt,e,Xe]),Me=()=>{if(R(!1),F(!1),N(!1),ne)nt(!1);else if(!Y()){const He=P-1;D(He),e({type:"notifyProgress",payload:{line:He}})}R(!0)},ke=React$2.useCallback(()=>ne?X&&X.type!=="conversationalDecision"&&!o.find(He=>He.fromId===X.id):P===a.length-1,[P,X,o,ne,a.length]),We=()=>{M("click-ui"),ke()?Xe():(w(!1),ze())},tt=()=>{M("click-ui"),w(!1),Me()},ct=_&&!pe&&!t&&!J,Dt=React$2.useMemo(()=>P===0||Y()||re(),[P,Y,re]);useEkho({audioType:X==null?void 0:X.audioType,volume:X==null?void 0:X.audioVolume,voice:X==null?void 0:X.voice,started:b,slide:P,text:cleanTextOfHtmlTags(fe==null?void 0:fe.text),audio:X==null?void 0:X.audio,soundActions:u,getEvent:n,pauseTTS:t,onStart:()=>{var He;(He=fe==null?void 0:fe.emotion)!=null&&He.includes("think")||F(!0)},onError:()=>{N(!0)},onFinish:()=>{F(!1),ct&&ze()}}),React$2.useEffect(()=>{var Ye;let He;return pe?()=>{}:(((X==null?void 0:X.audioType)==="none"||C)&&!((Ye=fe==null?void 0:fe.emotion)!=null&&Ye.includes("think"))&&(F(!0),He=setTimeout(()=>{F(!1)},Ee<minMs$1?minMs$1:Ee)),()=>{He&&clearTimeout(He)})},[C,X,fe==null?void 0:fe.emotion,Ee,pe]),React$2.useEffect(()=>(ct&&((X==null?void 0:X.audioType)==="none"||C)&&(!ke()||ke()&&T)&&I(ze,Ee<minMs$1?minMs$1:Ee),()=>{$()}),[fe,I,$,ze,X==null?void 0:X.audioType,ct,C,T,a,ke,Ee]),React$2.useEffect(()=>{if(ne&&!g){const He=v==null?void 0:v.line;if(He>=0){y(!0),D(He);return}const Ye=a.filter(Pe=>!o.find(we=>we.toId===Pe.id));if(Ye.length){const Pe=Ye[0],we=a.indexOf(Pe);we>=0&&(y(!0),D(we))}}},[o,ne,a,g,v==null?void 0:v.line]);const rt=l({disabled:pe,repeat:!1,forward:We,rewind:Dt?null:tt});if(React$2.useEffect(()=>rt(),[rt]),J)return jsxRuntimeExports.jsx(ChangeCamera,{...X,transition:{type:"none"},emitEvent:e,success:!1,onFinish:ze},`change-camera-${P}`);if(pe){const He=a[P].id?a.filter(Pe=>Pe.decision).findIndex(Pe=>Pe.id===a[P].id)+1:a.filter(Pe=>Pe.decision).findIndex(Pe=>Pe===a[P])+1,Ye={...X.payload,decisionNumber:He,required:!ne,branched:ne,onAddPoints:St,onFinish:ze,keyboardControl:l,emitEvent:e,getEvent:n,soundActions:u,inheritProps:{characters:Oe,background:f,flex:de?de.flex:!0,slots:de?de.slots:[]}};return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx(DecisionComponent,{...Ye})})}return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversational-pro-image",className:"conversation",style:z?{backgroundImage:`url("${z}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...Ne,ttsStarted:k}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[fe?jsxRuntimeExports.jsx(Message,{current:fe,translate:le}):null,jsxRuntimeExports.jsxs("div",{className:"conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-back",className:`gat--btn__round ${Dt?"disabled":""}`,disabled:Dt?!0:"",type:"button",onClick:tt,"aria-label":LangIsRtl()?le("storylines.misc.forward"):le("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-next",className:`gat--btn__round ${_&&ke()?"glowing-animation":""}`,type:"button",onClick:We,"aria-label":LangIsRtl()?le("storylines.misc.rewind"):le("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:l,getEvent:e,soundActions:n,messages:t,characters:a,alias:o,background:d,lodSettings:h}){var y;const[f,u]=React$2.useState(0),[p]=n,E=((y=d==null?void 0:d.img)==null?void 0:y.url)||null,T=t[f],v=a.map((b,R)=>({...b,name:o[R]?o[R]:b.name,uid:R})),S=()=>{const b=t.length-1;p("click-ui"),f+1<=b?u(f+1):l({type:"success"})},g=()=>{f>0&&(u(f-1),p("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversation-component",className:"conversation arcade-conversation",style:E?{backgroundImage:`url("${E}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:v,lodSettings:h,currentMessage:T,slots:v,emitEvent:l,getEvent:e,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[T?jsxRuntimeExports.jsx(Message,{current:T,voiceOver:T.emotion===null}):jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"conversation--controls arcade-conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-back-button",className:`gat--btn__round ${f>0?"":"visibility--hidden"}`,type:"button",onClick:g,children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-next-button",className:"gat--btn__round",type:"button",onClick:S,children:jsxRuntimeExports.jsx("span",{className:"icon-next"})})]})]})]})})}function Vignette({vignette:l,alias:e,translate:n,backgroundImageCover:t}){var u;const o=(l.img||{url:"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg"}).url,[d,h]=React$2.useState(!0),f=p=>{document.querySelector(`#${p}`).focus(),h(!d)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{"data-testid":"comic-image",className:`comic-image ${t?"comic-image--cover":""}`,children:o&&jsxRuntimeExports.jsx("img",{src:o,alt:"comic pic"})}),(u=l==null?void 0:l.textData)!=null&&u.text?jsxRuntimeExports.jsxs("div",{"data-testid":"comicCollapsable",className:`comic-collapsable ${d?"comic-collapsable--opened":""}`,children:[jsxRuntimeExports.jsx("button",{id:"buttonDown","data-testid":"buttonDown",onClick:()=>f("buttonUp"),type:"button",className:"un-btn comic-collapsable__headertoggle","aria-label":n("comic.toggleText"),children:jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"})}),jsxRuntimeExports.jsxs("div",{className:"comic-collapsable__text",children:[e?jsxRuntimeExports.jsxs("b",{children:[e,": "]}):null,HTMLReactParser$1(l.textData.text)]})]}):null,jsxRuntimeExports.jsx("button",{id:"buttonUp","data-testid":"buttonUp",tabIndex:d?"-1":"0","aria-hidden":d,className:`unset-button comic-buttonup
70
70
  ${d?"":"comic-buttonup--visible"}`,type:"button",onClick:()=>f("buttonDown"),"aria-label":n("comic.toggleText"),children:jsxRuntimeExports.jsx("span",{className:"icon-up-arrow"})})]})}function Slide({slide:l,transition:e,translate:n,backgroundImageCover:t}){const a=l.transitionEffects||e;return jsxRuntimeExports.jsx("div",{className:`comic-slide__item ${a}`,"aria-label":"comic slide item",children:l.vignettes.map(o=>jsxRuntimeExports.jsx(Vignette,{vignette:o,alias:l.alias,"aria-hidden":"true",translate:n,backgroundImageCover:t},`Vignete ${o.vignetteOrder}`))})}const characterMs$2=75;function ComicComponent({slides:l,emitEvent:e,getEvent:n,soundActions:t=[()=>{},()=>{}],autoPlay:a,autoEnd:o,pause:d,isFirstNode:h=!1,progress:f,keyboardControl:u,backgroundImageCover:p=!1}){var ae,ee,K,ne,ue,pe,J,H;const E=(f==null?void 0:f.slide)||0,T=W=>n({type:"translate",payload:W}),[v,S]=React$2.useState(!0),[g,y]=React$2.useState(!!a),[b,R]=React$2.useState(!1),{start:_,stop:w}=useTimeout(),[C,N]=React$2.useState(E),[P,D]=React$2.useState("slide-animation"),[k]=t,F=l==null?void 0:l[C],M=React$2.useCallback(()=>{S(!1),e({type:"success"})},[e]),I=React$2.useCallback(()=>{if(S(!1),R(!1),C+1<l.length&&!d){const W=C+1;D("slide-animation"),N(W),S(!0),e({type:"notifyProgress",payload:{slide:W}})}else o&&!d&&M()},[C,l.length,d,o,e,M]),$=React$2.useCallback(()=>{if(S(!1),R(!1),C-1>=0){const W=C-1;D("slide-animation"),N(W),S(!0),k("click-ui"),e({type:"notifyProgress",payload:{slide:W}})}},[k,C,e]),z=()=>{k("click-ui"),y(!1),I()},X=()=>{k("click-ui"),y(!1),$()},te=u({repeat:!1,rewind:C>0?X:null,forward:C+1>=l.length?M:z,escape:C+1>=l.length?M:null});return React$2.useEffect(()=>te(),[te]),useEkho({audioType:(ae=l==null?void 0:l[C])==null?void 0:ae.audioType,voice:(ee=l==null?void 0:l[C])==null?void 0:ee.voice,text:cleanTextOfHtmlTags((ne=(K=l==null?void 0:l[C])==null?void 0:K.vignettes[0].textData)==null?void 0:ne.text),audio:(ue=l==null?void 0:l[C])==null?void 0:ue.audio,slide:C,started:v,soundActions:t,getEvent:n,pauseTTS:d,volume:(pe=l==null?void 0:l[C])!=null&&pe.audioVolume||((J=l==null?void 0:l[C])==null?void 0:J.audioVolume)===0?(H=l==null?void 0:l[C])==null?void 0:H.audioVolume:.5,onError:()=>{R(!0)},onFinish:()=>{g&&!(F!=null&&F.slideTimer)&&I()}}),React$2.useEffect(()=>{var W,V;if(g){if(F!=null&&F.slideTimer)_(I,F.slideTimer*1e3);else if((F==null?void 0:F.audioType)==="none"&&!d||b&&!d){const B=characterMs$2*(((V=(W=F==null?void 0:F.vignettes[0])==null?void 0:W.textData)==null?void 0:V.text.length)||0);_(I,B<1400?1400:B)}}return()=>{w()}},[b,g,I,d,F==null?void 0:F.audio,F==null?void 0:F.audioType,F==null?void 0:F.slideTimer,F==null?void 0:F.vignettes,_,w]),l!=null&&l.length?jsxRuntimeExports.jsx("div",{dir:LangIsRtl()?"rtl":"auto",className:`comic component ${h?"":"growIn-animation"}`,role:"main","aria-label":"Comic",children:jsxRuntimeExports.jsxs("div",{className:"comic-slider",role:"navigation","aria-label":"Slider",children:[l[C]&&jsxRuntimeExports.jsx(Slide,{slide:l[C],transition:P,soundActions:t,emitEvent:e,role:"complementary","aria-hidden":"true",translate:T,backgroundImageCover:p},`comic page ${l[C].slideOrder}`),C>0&&jsxRuntimeExports.jsx("button",{type:"button",className:"comic-control comic-control--left gat--btn__round","data-testid":"btn-bck",onClick:X,"aria-label":LangIsRtl()?T("comic.next"):T("comic.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),C<l.length&&jsxRuntimeExports.jsx("button",{type:"button",className:`comic-control comic-control--right gat--btn__round
71
71
  ${g&&C+1>=l.length?"glowing-animation":""}`,"data-testid":"btn-nxt",onClick:()=>{C+1<l.length?z():(k("click-ui"),M())},"aria-label":LangIsRtl()?T("comic.previous"):T("comic.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})}):null}const characterMs$1=75;function CartelComponent({img:l,text:e,audio:n,audioType:t,voice:a,emitEvent:o,getEvent:d,soundActions:h,audioVolume:f,pause:u,keyboardControl:p,backgroundImageCover:E=!1,autoEnd:T=!1,customTimer:v}){const[S,g]=React$2.useState(!1),y=I=>d({type:"translate",payload:I}),b=(l==null?void 0:l.url)||"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg",R=/\.(mp4|mov|webm)$/i.test(b),_=React$2.useRef(),w=React$2.useRef(),[C]=h;useEkho({audioType:t,voice:a,text:e,audio:n,soundActions:h,getEvent:d,volume:f,pauseTTS:u,onError:()=>{g(!0)},onFinish:()=>{T&&n&&!v&&N()}});const N=React$2.useCallback(()=>{C("click-ui"),o({type:"success"})},[o,C]),P=p({repeat:!1,forward:N,escape:N});React$2.useEffect(()=>P(),[P]);const D=(I,$)=>window.matchMedia("(min-width: 1280px)").matches?$:I,k=React$2.useCallback(()=>{if(E!==!0&&e&&_.current){const I=_.current.naturalWidth/_.current.naturalHeight;let $=_.current.height*I,z=_.current.height;if($>_.current.width&&($=_.current.width,z=_.current.width/I),w.current.style.width=`${$}px`,window.innerHeight<_.current.width)w.current.style.bottom=`${D(24,48)+D(36,100)}px`;else{const X=(window.innerHeight-z)/2+D(36,100);w.current.style.bottom=`${X}px`}}},[E,e]),F=React$2.useCallback(()=>{if(E!==!0&&e&&_.current){const I=_.current.videoWidth/_.current.videoHeight,$=_.current.getBoundingClientRect().height*I;w.current.style.width=`${$}px`,w.current.style.bottom=`${D(24,48)+D(36,100)}px`}},[E,e]);React$2.useEffect(()=>{_.current&&new ResizeObserver(()=>{D(24,48),R?F():k()}).observe(_.current)},[k,F,R]),React$2.useEffect(()=>{if(T&&!u){if(v&&v!==0){const I=v*1e3,$=setTimeout(()=>{N()},I);return()=>{clearTimeout($)}}else if(!n){const I=characterMs$1*(e.length||0),$=I<2400?2400:I,z=setTimeout(()=>{N()},$);return()=>{clearTimeout(z)}}}},[n,S,T,N,v,u,e.length]);const M={src:b,style:E?{minHeight:"100%",minWidth:"100%",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}:{height:"100%",width:"100%"}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:`cartel ${E?"cartel--cover":""}`,children:jsxRuntimeExports.jsxs("div",{className:"cartel__imagewrap",children:[R&&jsxRuntimeExports.jsx("video",{autoPlay:!0,ref:_,...M,onLoadedData:F}),!R&&jsxRuntimeExports.jsx("img",{ref:_,onLoad:k,className:"cartel__image",src:b,alt:"cartel pic"}),e&&jsxRuntimeExports.jsx("div",{ref:w,className:"cartel__textwrap",children:jsxRuntimeExports.jsx("div",{className:"cartel__text",children:jsxRuntimeExports.jsx("span",{children:e})})})]})}),jsxRuntimeExports.jsx("div",{className:"position--absolute center right",children:jsxRuntimeExports.jsx("button",{"data-testid":"cartel-close-button",type:"button",className:"gat--btn__round",onClick:()=>N(),"aria-label":y("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})})]})}var Typist$1={exports:{}};(function(l){l.exports=function(e){var n={};function t(a){if(n[a])return n[a].exports;var o=n[a]={exports:{},id:a,loaded:!1};return e[a].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}return t.m=e,t.c=n,t.p="",t(0)}([function(e,n,t){Object.defineProperty(n,"__esModule",{value:!0});var a=Object.assign||function(k){for(var F=1;F<arguments.length;F++){var M=arguments[F];for(var I in M)Object.prototype.hasOwnProperty.call(M,I)&&(k[I]=M[I])}return k},o=function(){function k(F,M){for(var I=0;I<M.length;I++){var $=M[I];$.enumerable=$.enumerable||!1,$.configurable=!0,"value"in $&&($.writable=!0),Object.defineProperty(F,$.key,$)}}return function(F,M,I){return M&&k(F.prototype,M),I&&k(F,I),F}}(),d=t(1),h=_(d),f=t(2),u=_(f),p=t(10),E=_(p),T=t(12),v=_(T),S=t(13),g=_(S),y=t(14),b=R(y);function R(k){if(k&&k.__esModule)return k;var F={};if(k!=null)for(var M in k)Object.prototype.hasOwnProperty.call(k,M)&&(F[M]=k[M]);return F.default=k,F}function _(k){return k&&k.__esModule?k:{default:k}}function w(k,F){if(!(k instanceof F))throw new TypeError("Cannot call a class as a function")}function C(k,F){if(!k)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return F&&(typeof F=="object"||typeof F=="function")?F:k}function N(k,F){if(typeof F!="function"&&F!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof F);k.prototype=Object.create(F&&F.prototype,{constructor:{value:k,enumerable:!1,writable:!0,configurable:!0}}),F&&(Object.setPrototypeOf?Object.setPrototypeOf(k,F):k.__proto__=F)}var P=["🔙","⏰"],D=function(k){N(F,k);function F(M){w(this,F);var I=C(this,(F.__proto__||Object.getPrototypeOf(F)).call(this,M));return I.state={textLines:[],isDone:!1},I.onTypingDone=function(){I.mounted&&(I.setState({isDone:!0}),I.props.onTypingDone())},I.delayGenerator=function($,z,X,te){var ae=I.props.avgTypingDelay,ee=I.props.stdTypingDelay;return I.props.delayGenerator(ae,ee,{line:$,lineIdx:z,character:X,charIdx:te,defDelayGenerator:function(){var ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ae,ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ee;return b.gaussianRnd(ne,ue)}})},I.typeLine=function($,z){if(!I.mounted)return Promise.resolve();var X=$,te=I.props.onLineTyped;return b.isBackspaceElement($)?($.props.delay>0&&(I.introducedDelay=$.props.delay),X="🔙".repeat($.props.count)):b.isDelayElement($)&&(I.introducedDelay=$.props.ms,X="⏰"),new Promise(function(ae,ee){I.setState({textLines:I.state.textLines.concat([""])},function(){b.eachPromise(X,I.typeCharacter,X,z).then(function(){return te(X,z)}).then(ae).catch(ee)})})},I.typeCharacter=function($,z,X,te){if(!I.mounted)return Promise.resolve();var ae=I.props.onCharacterTyped;return new Promise(function(ee){var K=I.state.textLines.slice();b.sleep(I.introducedDelay).then(function(){I.introducedDelay=null;var ne=$==="🔙",ue=$==="⏰";if(ue){ee();return}if(ne&&te>0){for(var pe=te-1,J=K[pe],H=pe;H>=0&&!(J.length>0&&!P.includes(J[0]));H--)pe=H,J=K[pe];K[pe]=J.substr(0,J.length-1)}else K[te]+=$;I.setState({textLines:K},function(){var W=I.delayGenerator(X,te,$,z);ae($,z),setTimeout(ee,W)})})})},I.mounted=!1,I.linesToType=[],I.introducedDelay=null,M.children&&(I.linesToType=b.extractTextFromElement(M.children)),I}return o(F,[{key:"componentDidMount",value:function(){this.mounted=!0;var I=this.props,$=I.children,z=I.startDelay;$?z>0&&typeof window<"u"?setTimeout(this.typeAllLines.bind(this),z):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(I,$){if($.textLines.length!==this.state.textLines.length)return!0;for(var z=0;z<$.textLines.length;z++){var X=this.state.textLines[z],te=$.textLines[z];if(X!==te)return!0}return this.state.isDone!==$.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var I=this,$=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.linesToType;return b.eachPromise($,this.typeLine).then(function(){return I.onTypingDone()})}},{key:"render",value:function(){var I=this.props,$=I.className,z=I.cursor,X=this.state.isDone,te=b.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return h.default.createElement("div",{className:"Typist "+$},te,h.default.createElement(E.default,a({isDone:X},z)))}}]),F}(d.Component);D.propTypes={children:u.default.node,className:u.default.string,avgTypingDelay:u.default.number,stdTypingDelay:u.default.number,startDelay:u.default.number,cursor:u.default.object,onCharacterTyped:u.default.func,onLineTyped:u.default.func,onTypingDone:u.default.func,delayGenerator:u.default.func},D.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:b.gaussianRnd},n.default=D,D.Backspace=v.default,D.Delay=g.default},function(e,n){e.exports=React$2},function(e,n,t){if(process.env.NODE_ENV!=="production"){var a=typeof Symbol=="function"&&Symbol.for&&Symbol.for("react.element")||60103,o=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===a},d=!0;e.exports=t(3)(o,d)}else e.exports=t(9)()},function(e,n,t){var a=t(4),o=t(5),d=t(6),h=t(7),f=t(8);e.exports=function(u,p){var E=typeof Symbol=="function"&&Symbol.iterator,T="@@iterator";function v(K){var ne=K&&(E&&K[E]||K[T]);if(typeof ne=="function")return ne}var S="<<anonymous>>",g={array:_("array"),bool:_("boolean"),func:_("function"),number:_("number"),object:_("object"),string:_("string"),symbol:_("symbol"),any:w(),arrayOf:C,element:N(),instanceOf:P,node:M(),objectOf:k,oneOf:D,oneOfType:F,shape:I};function y(K,ne){return K===ne?K!==0||1/K===1/ne:K!==K&&ne!==ne}function b(K){this.message=K,this.stack=""}b.prototype=Error.prototype;function R(K){if(process.env.NODE_ENV!=="production")var ne={},ue=0;function pe(H,W,V,B,Y,re,le){if(B=B||S,re=re||V,le!==h){if(p)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var fe=B+":"+V;!ne[fe]&&ue<3&&(d(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",re,B),ne[fe]=!0,ue++)}}return W[V]==null?H?W[V]===null?new b("The "+Y+" `"+re+"` is marked as required "+("in `"+B+"`, but its value is `null`.")):new b("The "+Y+" `"+re+"` is marked as required in "+("`"+B+"`, but its value is `undefined`.")):null:K(W,V,B,Y,re)}var J=pe.bind(null,!1);return J.isRequired=pe.bind(null,!0),J}function _(K){function ne(ue,pe,J,H,W,V){var B=ue[pe],Y=X(B);if(Y!==K){var re=te(B);return new b("Invalid "+H+" `"+W+"` of type "+("`"+re+"` supplied to `"+J+"`, expected ")+("`"+K+"`."))}return null}return R(ne)}function w(){return R(a.thatReturnsNull)}function C(K){function ne(ue,pe,J,H,W){if(typeof K!="function")return new b("Property `"+W+"` of component `"+J+"` has invalid PropType notation inside arrayOf.");var V=ue[pe];if(!Array.isArray(V)){var B=X(V);return new b("Invalid "+H+" `"+W+"` of type "+("`"+B+"` supplied to `"+J+"`, expected an array."))}for(var Y=0;Y<V.length;Y++){var re=K(V,Y,J,H,W+"["+Y+"]",h);if(re instanceof Error)return re}return null}return R(ne)}function N(){function K(ne,ue,pe,J,H){var W=ne[ue];if(!u(W)){var V=X(W);return new b("Invalid "+J+" `"+H+"` of type "+("`"+V+"` supplied to `"+pe+"`, expected a single ReactElement."))}return null}return R(K)}function P(K){function ne(ue,pe,J,H,W){if(!(ue[pe]instanceof K)){var V=K.name||S,B=ee(ue[pe]);return new b("Invalid "+H+" `"+W+"` of type "+("`"+B+"` supplied to `"+J+"`, expected ")+("instance of `"+V+"`."))}return null}return R(ne)}function D(K){if(!Array.isArray(K))return process.env.NODE_ENV!=="production"&&d(!1,"Invalid argument supplied to oneOf, expected an instance of array."),a.thatReturnsNull;function ne(ue,pe,J,H,W){for(var V=ue[pe],B=0;B<K.length;B++)if(y(V,K[B]))return null;var Y=JSON.stringify(K);return new b("Invalid "+H+" `"+W+"` of value `"+V+"` "+("supplied to `"+J+"`, expected one of "+Y+"."))}return R(ne)}function k(K){function ne(ue,pe,J,H,W){if(typeof K!="function")return new b("Property `"+W+"` of component `"+J+"` has invalid PropType notation inside objectOf.");var V=ue[pe],B=X(V);if(B!=="object")return new b("Invalid "+H+" `"+W+"` of type "+("`"+B+"` supplied to `"+J+"`, expected an object."));for(var Y in V)if(V.hasOwnProperty(Y)){var re=K(V,Y,J,H,W+"."+Y,h);if(re instanceof Error)return re}return null}return R(ne)}function F(K){if(!Array.isArray(K))return process.env.NODE_ENV!=="production"&&d(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),a.thatReturnsNull;for(var ne=0;ne<K.length;ne++){var ue=K[ne];if(typeof ue!="function")return d(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",ae(ue),ne),a.thatReturnsNull}function pe(J,H,W,V,B){for(var Y=0;Y<K.length;Y++){var re=K[Y];if(re(J,H,W,V,B,h)==null)return null}return new b("Invalid "+V+" `"+B+"` supplied to "+("`"+W+"`."))}return R(pe)}function M(){function K(ne,ue,pe,J,H){return $(ne[ue])?null:new b("Invalid "+J+" `"+H+"` supplied to "+("`"+pe+"`, expected a ReactNode."))}return R(K)}function I(K){function ne(ue,pe,J,H,W){var V=ue[pe],B=X(V);if(B!=="object")return new b("Invalid "+H+" `"+W+"` of type `"+B+"` "+("supplied to `"+J+"`, expected `object`."));for(var Y in K){var re=K[Y];if(re){var le=re(V,Y,J,H,W+"."+Y,h);if(le)return le}}return null}return R(ne)}function $(K){switch(typeof K){case"number":case"string":case"undefined":return!0;case"boolean":return!K;case"object":if(Array.isArray(K))return K.every($);if(K===null||u(K))return!0;var ne=v(K);if(ne){var ue=ne.call(K),pe;if(ne!==K.entries){for(;!(pe=ue.next()).done;)if(!$(pe.value))return!1}else for(;!(pe=ue.next()).done;){var J=pe.value;if(J&&!$(J[1]))return!1}}else return!1;return!0;default:return!1}}function z(K,ne){return K==="symbol"||ne["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&ne instanceof Symbol}function X(K){var ne=typeof K;return Array.isArray(K)?"array":K instanceof RegExp?"object":z(ne,K)?"symbol":ne}function te(K){if(typeof K>"u"||K===null)return""+K;var ne=X(K);if(ne==="object"){if(K instanceof Date)return"date";if(K instanceof RegExp)return"regexp"}return ne}function ae(K){var ne=te(K);switch(ne){case"array":case"object":return"an "+ne;case"boolean":case"date":case"regexp":return"a "+ne;default:return ne}}function ee(K){return!K.constructor||!K.constructor.name?S:K.constructor.name}return g.checkPropTypes=f,g.PropTypes=g,g}},function(e,n){function t(o){return function(){return o}}var a=function(){};a.thatReturns=t,a.thatReturnsFalse=t(!1),a.thatReturnsTrue=t(!0),a.thatReturnsNull=t(null),a.thatReturnsThis=function(){return this},a.thatReturnsArgument=function(o){return o},e.exports=a},function(e,n){var t=function(d){};process.env.NODE_ENV!=="production"&&(t=function(d){if(d===void 0)throw new Error("invariant requires an error message argument")});function a(o,d,h,f,u,p,E,T){if(t(d),!o){var v;if(d===void 0)v=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var S=[h,f,u,p,E,T],g=0;v=new Error(d.replace(/%s/g,function(){return S[g++]})),v.name="Invariant Violation"}throw v.framesToPop=1,v}}e.exports=a},function(e,n,t){var a=t(4),o=a;process.env.NODE_ENV!=="production"&&function(){var d=function(f){for(var u=arguments.length,p=Array(u>1?u-1:0),E=1;E<u;E++)p[E-1]=arguments[E];var T=0,v="Warning: "+f.replace(/%s/g,function(){return p[T++]});typeof console<"u"&&console.error(v);try{throw new Error(v)}catch{}};o=function(f,u){if(u===void 0)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(u.indexOf("Failed Composite propType: ")!==0&&!f){for(var p=arguments.length,E=Array(p>2?p-2:0),T=2;T<p;T++)E[T-2]=arguments[T];d.apply(void 0,[u].concat(E))}}}(),e.exports=o},function(e,n){var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=t},function(e,n,t){if(process.env.NODE_ENV!=="production")var a=t(5),o=t(6),d=t(7),h={};function f(u,p,E,T,v){if(process.env.NODE_ENV!=="production"){for(var S in u)if(u.hasOwnProperty(S)){var g;try{a(typeof u[S]=="function","%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",T||"React class",E,S),g=u[S](p,S,T,E,null,d)}catch(b){g=b}if(o(!g||g instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",T||"React class",E,S,typeof g),g instanceof Error&&!(g.message in h)){h[g.message]=!0;var y=v?v():"";o(!1,"Failed %s type: %s%s",E,g.message,y??"")}}}}e.exports=f},function(e,n,t){var a=t(4),o=t(5),d=t(7);e.exports=function(){function h(p,E,T,v,S,g){g!==d&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}h.isRequired=h;function f(){return h}var u={array:h,bool:h,func:h,number:h,object:h,string:h,symbol:h,any:h,arrayOf:f,element:h,instanceOf:f,node:h,objectOf:f,oneOf:f,oneOfType:f,shape:f};return u.checkPropTypes=a,u.PropTypes=u,u}},function(e,n,t){Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function S(g,y){for(var b=0;b<y.length;b++){var R=y[b];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(g,R.key,R)}}return function(g,y,b){return y&&S(g.prototype,y),b&&S(g,b),g}}(),o=t(1),d=u(o),h=t(2),f=u(h);t(11);function u(S){return S&&S.__esModule?S:{default:S}}function p(S,g){if(!(S instanceof g))throw new TypeError("Cannot call a class as a function")}function E(S,g){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:S}function T(S,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);S.prototype=Object.create(g&&g.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(S,g):S.__proto__=g)}var v=function(S){T(g,S);function g(y){p(this,g);var b=E(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,y));return b._isReRenderingCursor=!1,b.state={shouldRender:b.props.show},b}return a(g,[{key:"componentWillReceiveProps",value:function(b){var R=this,_=!this.props.isDone&&b.isDone&&this.props.hideWhenDone;_&&setTimeout(function(){return R.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var b=this.props,R=b.show,_=b.isDone;R&&(_||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var b=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){b.setState({shouldRender:!0},function(){b._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var b=this.props.blink?" Cursor--blinking":"";return d.default.createElement("span",{className:"Cursor"+b},this.props.element)}return null}}]),g}(o.Component);v.propTypes={blink:f.default.bool,show:f.default.bool,element:f.default.node,hideWhenDone:f.default.bool,hideWhenDoneDelay:f.default.number,isDone:f.default.bool},v.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},n.default=v},function(e,n){},function(e,n,t){Object.defineProperty(n,"__esModule",{value:!0});var a=t(1),o=f(a),d=t(2),h=f(d);function f(p){return p&&p.__esModule?p:{default:p}}var u=function(){return o.default.createElement("noscript",null)};u.componentName="Backspace",u.propTypes={count:h.default.number,delay:h.default.number},u.defaultProps={count:1,delay:0},n.default=u},function(e,n,t){Object.defineProperty(n,"__esModule",{value:!0});var a=t(1),o=f(a),d=t(2),h=f(d);function f(p){return p&&p.__esModule?p:{default:p}}var u=function(){return o.default.createElement("noscript",null)};u.componentName="Delay",u.propTypes={ms:h.default.number.isRequired},n.default=u},function(e,n,t){Object.defineProperty(n,"__esModule",{value:!0}),n.sleep=void 0;var a=function(){function R(_,w){var C=[],N=!0,P=!1,D=void 0;try{for(var k=_[Symbol.iterator](),F;!(N=(F=k.next()).done)&&(C.push(F.value),!(w&&C.length===w));N=!0);}catch(M){P=!0,D=M}finally{try{!N&&k.return&&k.return()}finally{if(P)throw D}}return C}return function(_,w){if(Array.isArray(_))return _;if(Symbol.iterator in Object(_))return R(_,w);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.gaussianRnd=u,n.eachPromise=p,n.exclude=E,n.isBackspaceElement=T,n.isDelayElement=v,n.extractTextFromElement=S,n.cloneElement=g,n.cloneElementWithSpecifiedText=b;var o=t(1),d=h(o);function h(R){return R&&R.__esModule?R:{default:R}}function f(R){if(Array.isArray(R)){for(var _=0,w=Array(R.length);_<R.length;_++)w[_]=R[_];return w}else return Array.from(R)}n.sleep=function(_){return new Promise(function(w){return _!=null?setTimeout(w,_):w()})};function u(R,_){for(var w=12,C=0,N=0;N<w;N++)C+=Math.random();return C-=w/2,Math.round(C*_)+R}function p(R,_){for(var w=arguments.length,C=Array(w>2?w-2:0),N=2;N<w;N++)C[N-2]=arguments[N];var P=function(k,F,M){return k.then(function(){return _.apply(void 0,[F,M].concat(C))})};return Array.from(R).reduce(P,Promise.resolve())}function E(R,_){var w={};for(var C in R)_.indexOf(C)===-1&&(w[C]=R[C]);return w}function T(R){return R&&R.type&&R.type.componentName==="Backspace"}function v(R){return R&&R.type&&R.type.componentName==="Delay"}function S(R){for(var _=R?[R]:[],w=[];_.length>0;){var C=_.pop();if(d.default.isValidElement(C))T(C)||v(C)?w.unshift(C):d.default.Children.forEach(C.props.children,function(I){_.push(I)});else if(Array.isArray(C)){var N=!0,P=!1,D=void 0;try{for(var k=C[Symbol.iterator](),F;!(N=(F=k.next()).done);N=!0){var M=F.value;_.push(M)}}catch(I){P=!0,D=I}finally{try{!N&&k.return&&k.return()}finally{if(P)throw D}}}else w.unshift(C)}return w}function g(R,_){var w=R.type,C=E(R.props,["children"]),N=new Date().getUTCMilliseconds(),P=N+Math.random()+Math.random();return C.key="Typist-element-"+w+"-"+P,d.default.createElement.apply(d.default,[w,C].concat(f(_)))}function y(R,_,w){if(w>=_.length)return[null,w];var C=w,N=function(M){var I=y(M,_,C),$=a(I,2),z=$[0],X=$[1];return C=X,z},P=d.default.isValidElement(R)&&!(T(R)||v(R));if(P){var D=d.default.Children.map(R.props.children,N)||[];return[g(R,D),C]}if(Array.isArray(R)){var k=R.map(N);return[k,C]}return[_[C],C+1]}function b(R){var _=R.element,w=R.textLines;if(_)return y(_,w,0)[0]}}])})(Typist$1);var TypistExports=Typist$1.exports;const Typist=getDefaultExportFromCjs(TypistExports),languages={js:["var rows = prompt('How many rows for your multiplication table?');","var cols = prompt('How many columns for your multiplication table?');"," ","if(rows == '' || rows == null)"," rows = 10;"," ","if(cols== '' || cols== null)"," cols = 10;"," ","createTable(rows, cols);"," ","function createTable(rows, cols)","{"," var j=1;"," var output = '<table border='1' width='500' cellspacing='0'cellpadding='5'>';"," "," for(i=1;i<=rows;i++)"," {"," output = output + '<tr>';"," while(j<=cols)"," {"," output = output + '<td>' + i*j + '</td>';"," j = j+1;"," }"," output = output + '</tr>';"," j = 1;"," }"," "," output = output + '</table>';"," document.write(output);","}"],lua:["-- Ensure that that the element at i is in the right position,","-- and return a closure which can be used for continuing the sort."," ","function quicksorter(i, vec, low, high)"," if low >= high then"," return quicksorter"," else -- low < high"," -- partition the vector and initialize the child closures"," local middle = partition(vec, low, high)"," local left, right = quicksorter"," ","-- Create the promise"," local function self(i, vec, low, high)"," if i < middle then"," left = left(i, vec, low, middle-1)"," return self"," elseif i > middle then"," right = right(i, vec, middle+1, high)"," return self"," end"," end"," ","-- Force the promise until i is in the right position"," return self(i, vec, low, high)"," end","end"," ","function lazysort(vec, low, high)"," local sorter = quicksorter"," return function(i)"," sorter = sorter(i, vec, low, high)"," return vec[i]"," end","end"],python:["#ask the user to enter four pieces of information"," ","firstname = input('Enter your first name: ')","surname = input('Enter your surname: ')","email = input('Enter your email: ')","yearsteaching = input('Enter the number of years teaching: ')"," ","file = open('staff.csv','r') #opens the file in read mode","found=False #sets whether the user is found to False"," ","for line in file: #reads each line in the file"," staff = line.split(',') #splits the line into the list called staff"," if staff[2] == email: #checks if the email entered is in the list"," found=True #if it is changes found to True"," ","file.close() #closes the file"," ","if found==True: #after the loop checks if the user is found"," print('Staff member already exists in the file') #displays on screen","else:"," #if the email was not in the file"," writefile=open('staff.csv','a') #open the file in append mode"," writefile.write(firstname + ',' + surname + ',' + email + ',' + yearsteaching) #write the new information to the file"," writefile.close() #close the file"," print('Staff member added to file')"]},themes={theme1:{bg:1,color:1,typo:2},theme2:{bg:3,color:2,typo:3},theme3:{bg:5,color:4,typo:1},theme4:{bg:1,color:3,typo:2},theme5:{bg:2,color:5,typo:1},theme6:{bg:5,color:6,typo:2},theme7:{bg:1,color:7,typo:3}};function ProgressBar({progress:l,type:e}){const n=languages[e];if(n){const t=n.reduce((d,h)=>(d.length?d.length:d)+h.length),a=Math.floor(l*100/t),o=a===100?"puzzle--hacker__percentage percentage--label":"puzzle--hacker__percentage";return jsxRuntimeExports.jsx("div",{className:"puzzle--hacker__progress",children:jsxRuntimeExports.jsx("span",{className:"puzzle--hacker__progress--item",style:{width:`${Math.floor(l*100/t)}%`},children:jsxRuntimeExports.jsxs("span",{className:o,children:[a,"%"]})})})}return null}function Code({codeContainer:l}){const e=l,n=e.split("<br>");return n.length>0?n.map((t,a)=>{const o=t.replace(/ /g," ");return jsxRuntimeExports.jsx("p",{children:o},`line_${0+a}`)}):jsxRuntimeExports.jsx("p",{children:e})}function HackerPuzzleComponent({emitEvent:l,getEvent:e,soundActions:n,info:t,themeNumber:a,type:o,writingSpeed:d,disableExit:h,setResolveAction:f}){const u=X=>e({type:"translate",payload:X}),[p]=n,{solution:E}=t,v=themes[`theme${a||1}`],[S,g]=React$2.useState(""),[y,b]=React$2.useState(0),[R,_]=React$2.useState(0),[w,C]=React$2.useState(!1),[N,P]=React$2.useState({start:0,end:0}),D=React$2.useRef(),k=React$2.useRef(),F=u("puzzle.hacker.congratulations"),M=(X,te)=>X>te.length?te.length:X,I=()=>{p("click-ui");const{rewards:X}=E.right;l({type:"addPoints",complex:!0,finish:!0,payload:X}),l({type:"passPuzzle"})};React$2.useEffect(()=>{D.current.focus(),w&&h(!0)},[w]),React$2.useEffect(()=>{f(X=>{p("score"),C(!0),l({type:"hidePuzzleButtons",payload:!1}),X()})},[f]);const $=()=>{if(languages[o]&&!w){k.current&&(k.current.scrollTop=D.current.scrollHeight);const X=languages[o],te=X[y],ae=X.reduce((K,ne)=>(K.length?K.length:K)+ne.length),ee=d>0?d:Math.floor(ae/50)+y;if(te){const K=te.split(""),ne=M(N.end,K),ue=K.slice(N.start,ne),pe=S+ue.join("");_(R+ue.join("").length),g(pe),ne===K.length?y+1>=X.length?(p("score"),C(!0)):(b(y+1),g(`${S+ue.join("")}<br>`),P({start:0,end:M(ee,K)})):P({start:ne,end:M(ne+ee,K)})}}},z=X=>{X.preventDefault(),$()};return jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,"data-testid":"hacker",ref:D,onKeyDown:z,onTouchStart:z,className:`puzzle--hacker__container background-hacker-${v.bg}`,children:[jsxRuntimeExports.jsx("div",{className:"puzzle--hacker__header",children:jsxRuntimeExports.jsx("span",{className:"title",children:"Console"})}),jsxRuntimeExports.jsxs("div",{className:`puzzle--hacker__body color-hacker-${v.color} typography-hacker-${v.typo}`,children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--hacker__code",ref:k,children:[jsxRuntimeExports.jsx(Code,{codeContainer:S}),w?jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,onCharacterTyped:()=>{k.current&&(k.current.scrollTop=D.current.scrollHeight)},cursor:{hideWhenDone:!0},className:"puzzle--hacker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),E.right.desc?`// ${E.right.desc}`:`${F}`]}):null]}),jsxRuntimeExports.jsx(ProgressBar,{type:o,progress:R})]}),w?jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:I,children:u("screens.continue")})}):null]})}HackerPuzzleComponent.defaultProps={type:"",writingSpeed:0,context:{},info:{},themeNumber:1};const imagenPorDefecto="https://min.gamelearn.io/css-resources/gamelearn/resources/puzzle-login-low.png";function LoginPuzzleComponent({emitEvent:l,soundActions:e,getEvent:n,info:t,user:a,login:o,password:d,image:h,setResolveAction:f,nodeId:u}){var ne;const p=ue=>n({type:"translate",payload:ue}),E=`login-puzzle_${u}`,T=LangIsRtl(),[v,S]=React$2.useState(""),[g,y]=React$2.useState(""),[b,R]=React$2.useState(!1),[_,w]=React$2.useState(""),[C,N]=React$2.useState(""),[P,D]=React$2.useState(!1),[k,F]=React$2.useState(!1),[M,I]=React$2.useState(!1),[$]=e,[z,X]=React$2.useState([]),te=((ne=h.img)==null?void 0:ne.url)||imagenPorDefecto,ae=()=>{const{rewards:ue}=t.solution.right,pe=[...z,...ue];l({type:"addPoints",complex:!0,finish:!0,payload:pe}),l({type:"passPuzzle"})},ee=()=>{$("click-ui");const ue={login:!0,password:!1};o&&(ue.login=a===v),ue.password=d===g,ue.login&&ue.password?(N("success"),D(!0),F(!1),$("score"),setTimeout(()=>{ae()},2e3)):(X([...z,...t.solution.wrong.rewards]),$("fail"),N("failed"),F(!0),l({type:"failPuzzle"}))},K=ue=>{let pe="";if(ue.length>=0){for(let J=0;J<ue.length;J+=1)pe+="•";w(pe)}};return React$2.useEffect(()=>{f(()=>{const ue=[...z,...t.resolve.rewards];I(!0),setTimeout(()=>{l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:E,rewards:ue,finish:!0}})},2e3)})},[z,t.resolve.rewards,l,f,E]),jsxRuntimeExports.jsx("div",{className:"puzzle--layer",style:{backgroundImage:`url("${te}")`},children:jsxRuntimeExports.jsxs("div",{className:`puzzle--login ${a?"puzzle--login--withuser":""}`,children:[jsxRuntimeExports.jsx("span",{className:"icon-login-puzzle",children:" "}),jsxRuntimeExports.jsx("span",{className:"puzzle--login__title",children:p("puzzle.initSession")}),jsxRuntimeExports.jsxs("div",{children:[o&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--login__label",children:p("puzzle.user")}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[M?jsxRuntimeExports.jsx("input",{dir:T?"rtl":"auto",disabled:P,"data-testid":"username",className:"puzzle--login__input success",type:"text",placeholder:a,value:a}):jsxRuntimeExports.jsx("input",{dir:T?"rtl":"auto",disabled:P,"data-testid":"username",className:`puzzle--login__input ${C}`,type:"text",placeholder:p("puzzle.user"),onChange:ue=>{S(ue.target.value),N(""),F(!1)}}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check",children:" "})]})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--login__label",children:jsxRuntimeExports.jsx("span",{children:p("puzzle.password")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[M?jsxRuntimeExports.jsx("input",{dir:T?"rtl":"auto",disabled:!0,"data-testid":"password",className:"puzzle--login__input puzzle--login__input--fakepassword success",type:"text",placeholder:d,value:d,style:{opacity:1}}):jsxRuntimeExports.jsx("input",{dir:T?"rtl":"auto",disabled:P,"data-testid":"password",className:`puzzle--login__input puzzle--login__input--fakepassword ${C}`,type:"text",placeholder:p("puzzle.password"),onFocus:()=>{R(!0)},onBlur:()=>{R(!1)},onChange:ue=>{y(ue.target.value),K(ue.target.value),N(""),F(!1)}}),M?null:jsxRuntimeExports.jsx("div",{dir:T?"rtl":"auto",className:`login-fakepassword${b?" login-fakepassword--focus":""}${_.length?" login-fakepassword--fill":""} ${C||""}`,children:g?_:p("puzzle.password")}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check",children:" "})]})]})]}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${g.length!==0&&!P?"":"disabled"}`,onClick:ee,children:p("puzzle.loginIn")}),!M&&k&&t.solution.wrong.desc!==""&&jsxRuntimeExports.jsx("div",{className:"puzzle--login__label--error",children:t.solution.wrong.desc})]})})}function FeedbackComponent$1({text:l,success:e,playSound:n,additionalStyle:t,functionOnClose:a,secondText:o,translate:d,shortText:h,hasTimeout:f,delay:u,timeExpired:p,keyboardControl:E}){const[T,v]=React$2.useState();React$2.useEffect(()=>{let b;return n&&n(e?"score":"fail"),l&&!h&&(b=setTimeout(()=>{v(!0)},1e3)),()=>{b&&clearTimeout(b)}},[n,e,h,l]),React$2.useEffect(()=>{let b;return f&&a&&(b=setTimeout(a,u)),()=>{b&&clearTimeout(b)}},[u,a,f]);const S=()=>e?"success":"failed",g=()=>e?"icon-correct-thumb":p?"icon-times-up":"icon-incorrect-thumb",y=E({disabled:!(l&&a&&T),repeat:!1,forward:a,close:a});return React$2.useEffect(()=>y(),[y]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{"data-testid":"feedback-layer",className:`feedback-layer ${T?"feedback-layer--withexplain":""}`,children:[jsxRuntimeExports.jsxs("div",{className:`feedback-layer__header ${h?"feedback-layer__header--in-shortText":""} ${t||""} ${S()}`,children:[o&&jsxRuntimeExports.jsxs("span",{className:"puzzle--terminal__visor--file",children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${t||""}`}),jsxRuntimeExports.jsx("span",{children:o})]}),jsxRuntimeExports.jsx("span",{className:"feedback-layer__maintitle",children:!l||!h?jsxRuntimeExports.jsx("div",{title:d(`tooltip.${e?"correct":"incorrect"}`),className:`${g()}`}):HTMLReactParser$1(l)}),h&&jsxRuntimeExports.jsx("button",{type:"button",className:"feedback-layer__closeX",onClick:()=>a(),"aria-label":d("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),!h&&l!==""&&jsxRuntimeExports.jsx("div",{className:"feedback-layer__explainwrap",children:jsxRuntimeExports.jsxs("div",{className:"feedback-layer__explain",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:HTMLReactParser$1(l)}),l&&a&&T&&jsxRuntimeExports.jsx("button",{type:"button","data-testid":"close-feedback",className:"gat--btn__navigation",onClick:()=>a(),"aria-label":d("storylines.misc.closePiece"),style:{display:"flex",margin:"auto",marginTop:"24px"},children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})})}FeedbackComponent$1.defaultProps={text:"",hasTimeout:!1,delay:3e3,success:!1};function KeyboardPuzzleComponent({emitEvent:l,getEvent:e,image:n,password:t,keyboard:a,info:o,disableExit:d,soundActions:h,setResolveAction:f,nodeId:u,keyboardControl:p,styles:E="default-theme"}){var ee,K;const[T,v]=React$2.useState(""),[S,g]=React$2.useState(""),[y,b]=React$2.useState(!1),[R,_]=React$2.useState(""),[w,C]=React$2.useState(!1),[N,P]=React$2.useState([]),D=ne=>e({type:"translate",payload:ne}),k=`keyboard-puzzle_${u}`,[F]=h,M=React$2.useCallback(ne=>{b(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:ne})},[l]),I=()=>{if(y){const{rewards:ne}=o.solution.right,ue=[...N,...ne];F("score"),M(ue)}else l({type:"hidePuzzleButtons",payload:!1}),b(!1),d(!1),C(!1);_("")},$=ne=>{ne===t?(d(!1),v("success"),F("score"),l({type:"passPuzzle"}),b(!0),C(!0),o.solution.right.desc?_(o.solution.right.desc):setTimeout(()=>{const{rewards:ue}=o.solution.right,pe=[...N,...ue];M(pe)},3e3)):(C(!0),v("failed"),F("fail"),l({type:"failPuzzle"}),b(!1),P([...N,...o.solution.wrong.rewards]),l({type:"hidePuzzleButtons",payload:!1}),v(""),g(""),C(!0),o.solution.wrong.desc?_(o.solution.wrong.desc):setTimeout(()=>{I()},3e3))};React$2.useEffect(()=>{f(()=>{d(!1),F("score"),v("success"),b(!0),_(o.solution.right.desc),g(t);const ne=[...N,...o.resolve.rewards];setTimeout(()=>{b(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:k,rewards:ne,finish:!0}})},2e3)})},[f,d,o.solution.right.desc,F,o.resolve.rewards,N,t,l,k]);const z=(ne,ue)=>{const pe=a[ne][ue];F("click-ui"),S.length<t.length+1&&(g(S+pe),S.length+1===t.length&&$(S+pe))},X=()=>{F("click-ui"),g(S.substring(0,S.length-1))},ae={backgroundImage:`url("${((ee=n.img)==null?void 0:ee.url)||""}")`,backgroudPosition:"center center"};return jsxRuntimeExports.jsxs("div",{className:`puzzle-keyboard puzzle-keyboard--${E}`,style:(K=n.img)!=null&&K.url?ae:null,children:[jsxRuntimeExports.jsx("div",{className:"puzzle-keyboard__header",children:jsxRuntimeExports.jsxs("div",{className:"puzzle-keyboard__digits",children:[t.split("").map((ne,ue)=>jsxRuntimeExports.jsx("div",{className:`puzzle-keyboard__digit ${T}`,children:S.split("")[ue]?S.split("")[ue]:""},`${ne+ue}`)),T!==""?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:T==="success"?jsxRuntimeExports.jsx("span",{className:"puzzle-keyboard__positionatedToDigits icon-mini-check-circle"}):jsxRuntimeExports.jsx("span",{className:"puzzle-keyboard__positionatedToDigits icon-mini-error-circle"})}):jsxRuntimeExports.jsx("button",{type:"button",onClick:X,className:"puzzle-keyboard__positionatedToDigits puzzle-keyboard__delete","aria-label":D("puzzles.keyboard-puzzle.deleteButton"),children:jsxRuntimeExports.jsx("span",{className:"icon-delete-key-2023"})})]})}),jsxRuntimeExports.jsxs("div",{className:"puzzle-keyboard__keypad",children:[E==="scifi-theme"&&jsxRuntimeExports.jsx("div",{"aria-hidden":!0,className:"puzzle-keyboard__scifi-notch",children:jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsxs("g",{fill:"none",fillRule:"evenodd",children:[jsxRuntimeExports.jsxs("g",{transform:"translate(3 3)",children:[jsxRuntimeExports.jsx("circle",{fill:"#1E282F",cx:"5",cy:"5",r:"5"}),jsxRuntimeExports.jsx("path",{d:"M1.48 8.55a5 5 0 1 0 7.008-7.133",fillOpacity:".096",fill:"#1DDDD8"}),jsxRuntimeExports.jsx("circle",{fill:"#1DDDD8",opacity:".359",cx:"3",cy:"3",r:"2"})]}),jsxRuntimeExports.jsx("circle",{stroke:"#1E282F",cx:"8",cy:"8",r:"7.5"})]})})})}),jsxRuntimeExports.jsx("div",{className:`keyboard-keys keyboard-keys--${E}`,children:a.map((ne,ue)=>(Array.isArray(ne)?ne:Object.values(ne)).map((pe,J)=>jsxRuntimeExports.jsx("button",{className:`keyboard-key keyboard-key--${E} ${pe==="*"?"keyboard-key--star":""}`,type:"button",onClick:()=>z(ue,J),children:jsxRuntimeExports.jsx("div",{children:pe})},pe)))}),E==="scifi-theme"&&jsxRuntimeExports.jsx("hr",{"aria-hidden":!0,className:"puzzle-keyboard__scifi-line"})]}),w&&jsxRuntimeExports.jsx(FeedbackComponent$1,{translate:D,text:R,success:y,functionOnClose:I,keyboardControl:p})]})}var lib$1={exports:{}},_FullInternals={},_CoreInternals={},Global={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l._registerNode=l.Konva=l.glob=void 0;const e=Math.PI/180;function n(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}l.glob=typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},l.Konva={_global:l.glob,version:"9.3.0",isBrowser:n(),isUnminified:/param/.test((function(a){}).toString()),dblClickWindow:400,getAngle(a){return l.Konva.angleDeg?a*e:a},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,pixelRatio:typeof window<"u"&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return l.Konva.DD.isDragging},isDragReady(){return!!l.Konva.DD.node},releaseCanvasOnDestroy:!0,document:l.glob.document,_injectGlobal(a){l.glob.Konva=a}};const t=a=>{l.Konva[a.prototype.getClassName()]=a};l._registerNode=t,l.Konva._injectGlobal(l.Konva)})(Global);var Util={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Util=l.Transform=void 0;const e=Global;class n{constructor(w=[1,0,0,1,0,0]){this.dirty=!1,this.m=w&&w.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new n(this.m)}copyInto(w){w.m[0]=this.m[0],w.m[1]=this.m[1],w.m[2]=this.m[2],w.m[3]=this.m[3],w.m[4]=this.m[4],w.m[5]=this.m[5]}point(w){var C=this.m;return{x:C[0]*w.x+C[2]*w.y+C[4],y:C[1]*w.x+C[3]*w.y+C[5]}}translate(w,C){return this.m[4]+=this.m[0]*w+this.m[2]*C,this.m[5]+=this.m[1]*w+this.m[3]*C,this}scale(w,C){return this.m[0]*=w,this.m[1]*=w,this.m[2]*=C,this.m[3]*=C,this}rotate(w){var C=Math.cos(w),N=Math.sin(w),P=this.m[0]*C+this.m[2]*N,D=this.m[1]*C+this.m[3]*N,k=this.m[0]*-N+this.m[2]*C,F=this.m[1]*-N+this.m[3]*C;return this.m[0]=P,this.m[1]=D,this.m[2]=k,this.m[3]=F,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(w,C){var N=this.m[0]+this.m[2]*C,P=this.m[1]+this.m[3]*C,D=this.m[2]+this.m[0]*w,k=this.m[3]+this.m[1]*w;return this.m[0]=N,this.m[1]=P,this.m[2]=D,this.m[3]=k,this}multiply(w){var C=this.m[0]*w.m[0]+this.m[2]*w.m[1],N=this.m[1]*w.m[0]+this.m[3]*w.m[1],P=this.m[0]*w.m[2]+this.m[2]*w.m[3],D=this.m[1]*w.m[2]+this.m[3]*w.m[3],k=this.m[0]*w.m[4]+this.m[2]*w.m[5]+this.m[4],F=this.m[1]*w.m[4]+this.m[3]*w.m[5]+this.m[5];return this.m[0]=C,this.m[1]=N,this.m[2]=P,this.m[3]=D,this.m[4]=k,this.m[5]=F,this}invert(){var w=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),C=this.m[3]*w,N=-this.m[1]*w,P=-this.m[2]*w,D=this.m[0]*w,k=w*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),F=w*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=C,this.m[1]=N,this.m[2]=P,this.m[3]=D,this.m[4]=k,this.m[5]=F,this}getMatrix(){return this.m}decompose(){var w=this.m[0],C=this.m[1],N=this.m[2],P=this.m[3],D=this.m[4],k=this.m[5],F=w*P-C*N;let M={x:D,y:k,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(w!=0||C!=0){var I=Math.sqrt(w*w+C*C);M.rotation=C>0?Math.acos(w/I):-Math.acos(w/I),M.scaleX=I,M.scaleY=F/I,M.skewX=(w*N+C*P)/F,M.skewY=0}else if(N!=0||P!=0){var $=Math.sqrt(N*N+P*P);M.rotation=Math.PI/2-(P>0?Math.acos(-N/$):-Math.acos(N/$)),M.scaleX=F/$,M.scaleY=$,M.skewX=0,M.skewY=(w*N+C*P)/F}return M.rotation=l.Util._getRotation(M.rotation),M}}l.Transform=n;var t="[object Array]",a="[object Number]",o="[object String]",d="[object Boolean]",h=Math.PI/180,f=180/Math.PI,u="#",p="",E="0",T="Konva warning: ",v="Konva error: ",S="rgb(",g={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},y=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,b=[];const R=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(_){setTimeout(_,60)};l.Util={_isElement(_){return!!(_&&_.nodeType==1)},_isFunction(_){return!!(_&&_.constructor&&_.call&&_.apply)},_isPlainObject(_){return!!_&&_.constructor===Object},_isArray(_){return Object.prototype.toString.call(_)===t},_isNumber(_){return Object.prototype.toString.call(_)===a&&!isNaN(_)&&isFinite(_)},_isString(_){return Object.prototype.toString.call(_)===o},_isBoolean(_){return Object.prototype.toString.call(_)===d},isObject(_){return _ instanceof Object},isValidSelector(_){if(typeof _!="string")return!1;var w=_[0];return w==="#"||w==="."||w===w.toUpperCase()},_sign(_){return _===0||_>0?1:-1},requestAnimFrame(_){b.push(_),b.length===1&&R(function(){const w=b;b=[],w.forEach(function(C){C()})})},createCanvasElement(){var _=document.createElement("canvas");try{_.style=_.style||{}}catch{}return _},createImageElement(){return document.createElement("img")},_isInDocument(_){for(;_=_.parentNode;)if(_==document)return!0;return!1},_urlToImage(_,w){var C=l.Util.createImageElement();C.onload=function(){w(C)},C.src=_},_rgbToHex(_,w,C){return((1<<24)+(_<<16)+(w<<8)+C).toString(16).slice(1)},_hexToRgb(_){_=_.replace(u,p);var w=parseInt(_,16);return{r:w>>16&255,g:w>>8&255,b:w&255}},getRandomColor(){for(var _=(Math.random()*16777215<<0).toString(16);_.length<6;)_=E+_;return u+_},getRGB(_){var w;return _ in g?(w=g[_],{r:w[0],g:w[1],b:w[2]}):_[0]===u?this._hexToRgb(_.substring(1)):_.substr(0,4)===S?(w=y.exec(_.replace(/ /g,"")),{r:parseInt(w[1],10),g:parseInt(w[2],10),b:parseInt(w[3],10)}):{r:0,g:0,b:0}},colorToRGBA(_){return _=_||"black",l.Util._namedColorToRBA(_)||l.Util._hex3ColorToRGBA(_)||l.Util._hex4ColorToRGBA(_)||l.Util._hex6ColorToRGBA(_)||l.Util._hex8ColorToRGBA(_)||l.Util._rgbColorToRGBA(_)||l.Util._rgbaColorToRGBA(_)||l.Util._hslColorToRGBA(_)},_namedColorToRBA(_){var w=g[_.toLowerCase()];return w?{r:w[0],g:w[1],b:w[2],a:1}:null},_rgbColorToRGBA(_){if(_.indexOf("rgb(")===0){_=_.match(/rgb\(([^)]+)\)/)[1];var w=_.split(/ *, */).map(Number);return{r:w[0],g:w[1],b:w[2],a:1}}},_rgbaColorToRGBA(_){if(_.indexOf("rgba(")===0){_=_.match(/rgba\(([^)]+)\)/)[1];var w=_.split(/ *, */).map((C,N)=>C.slice(-1)==="%"?N===3?parseInt(C)/100:parseInt(C)/100*255:Number(C));return{r:w[0],g:w[1],b:w[2],a:w[3]}}},_hex8ColorToRGBA(_){if(_[0]==="#"&&_.length===9)return{r:parseInt(_.slice(1,3),16),g:parseInt(_.slice(3,5),16),b:parseInt(_.slice(5,7),16),a:parseInt(_.slice(7,9),16)/255}},_hex6ColorToRGBA(_){if(_[0]==="#"&&_.length===7)return{r:parseInt(_.slice(1,3),16),g:parseInt(_.slice(3,5),16),b:parseInt(_.slice(5,7),16),a:1}},_hex4ColorToRGBA(_){if(_[0]==="#"&&_.length===5)return{r:parseInt(_[1]+_[1],16),g:parseInt(_[2]+_[2],16),b:parseInt(_[3]+_[3],16),a:parseInt(_[4]+_[4],16)/255}},_hex3ColorToRGBA(_){if(_[0]==="#"&&_.length===4)return{r:parseInt(_[1]+_[1],16),g:parseInt(_[2]+_[2],16),b:parseInt(_[3]+_[3],16),a:1}},_hslColorToRGBA(_){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(_)){const[w,...C]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(_),N=Number(C[0])/360,P=Number(C[1])/100,D=Number(C[2])/100;let k,F,M;if(P===0)return M=D*255,{r:Math.round(M),g:Math.round(M),b:Math.round(M),a:1};D<.5?k=D*(1+P):k=D+P-D*P;const I=2*D-k,$=[0,0,0];for(let z=0;z<3;z++)F=N+1/3*-(z-1),F<0&&F++,F>1&&F--,6*F<1?M=I+(k-I)*6*F:2*F<1?M=k:3*F<2?M=I+(k-I)*(2/3-F)*6:M=I,$[z]=M*255;return{r:Math.round($[0]),g:Math.round($[1]),b:Math.round($[2]),a:1}}},haveIntersection(_,w){return!(w.x>_.x+_.width||w.x+w.width<_.x||w.y>_.y+_.height||w.y+w.height<_.y)},cloneObject(_){var w={};for(var C in _)this._isPlainObject(_[C])?w[C]=this.cloneObject(_[C]):this._isArray(_[C])?w[C]=this.cloneArray(_[C]):w[C]=_[C];return w},cloneArray(_){return _.slice(0)},degToRad(_){return _*h},radToDeg(_){return _*f},_degToRad(_){return l.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),l.Util.degToRad(_)},_radToDeg(_){return l.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),l.Util.radToDeg(_)},_getRotation(_){return e.Konva.angleDeg?l.Util.radToDeg(_):_},_capitalize(_){return _.charAt(0).toUpperCase()+_.slice(1)},throw(_){throw new Error(v+_)},error(_){console.error(v+_)},warn(_){e.Konva.showWarnings&&console.warn(T+_)},each(_,w){for(var C in _)w(C,_[C])},_inRange(_,w,C){return w<=_&&_<C},_getProjectionToSegment(_,w,C,N,P,D){var k,F,M,I=(_-C)*(_-C)+(w-N)*(w-N);if(I==0)k=_,F=w,M=(P-C)*(P-C)+(D-N)*(D-N);else{var $=((P-_)*(C-_)+(D-w)*(N-w))/I;$<0?(k=_,F=w,M=(_-P)*(_-P)+(w-D)*(w-D)):$>1?(k=C,F=N,M=(C-P)*(C-P)+(N-D)*(N-D)):(k=_+$*(C-_),F=w+$*(N-w),M=(k-P)*(k-P)+(F-D)*(F-D))}return[k,F,M]},_getProjectionToLine(_,w,C){var N=l.Util.cloneObject(_),P=Number.MAX_VALUE;return w.forEach(function(D,k){if(!(!C&&k===w.length-1)){var F=w[(k+1)%w.length],M=l.Util._getProjectionToSegment(D.x,D.y,F.x,F.y,_.x,_.y),I=M[0],$=M[1],z=M[2];z<P&&(N.x=I,N.y=$,P=z)}}),N},_prepareArrayForTween(_,w,C){var N,P=[],D=[];if(_.length>w.length){var k=w;w=_,_=k}for(N=0;N<_.length;N+=2)P.push({x:_[N],y:_[N+1]});for(N=0;N<w.length;N+=2)D.push({x:w[N],y:w[N+1]});var F=[];return D.forEach(function(M){var I=l.Util._getProjectionToLine(M,P,C);F.push(I.x),F.push(I.y)}),F},_prepareToStringify(_){var w;_.visitedByCircularReferenceRemoval=!0;for(var C in _)if(_.hasOwnProperty(C)&&_[C]&&typeof _[C]=="object"){if(w=Object.getOwnPropertyDescriptor(_,C),_[C].visitedByCircularReferenceRemoval||l.Util._isElement(_[C]))if(w.configurable)delete _[C];else return null;else if(l.Util._prepareToStringify(_[C])===null)if(w.configurable)delete _[C];else return null}return delete _.visitedByCircularReferenceRemoval,_},_assign(_,w){for(var C in w)_[C]=w[C];return _},_getFirstPointerId(_){return _.touches?_.changedTouches[0].identifier:_.pointerId||999},releaseCanvas(..._){e.Konva.releaseCanvasOnDestroy&&_.forEach(w=>{w.width=0,w.height=0})},drawRoundedRectPath(_,w,C,N){let P=0,D=0,k=0,F=0;typeof N=="number"?P=D=k=F=Math.min(N,w/2,C/2):(P=Math.min(N[0]||0,w/2,C/2),D=Math.min(N[1]||0,w/2,C/2),F=Math.min(N[2]||0,w/2,C/2),k=Math.min(N[3]||0,w/2,C/2)),_.moveTo(P,0),_.lineTo(w-D,0),_.arc(w-D,D,D,Math.PI*3/2,0,!1),_.lineTo(w,C-F),_.arc(w-F,C-F,F,0,Math.PI/2,!1),_.lineTo(k,C),_.arc(k,C-k,k,Math.PI/2,Math.PI,!1),_.lineTo(0,P),_.arc(P,P,P,Math.PI,Math.PI*3/2,!1)}}})(Util);var Node$1={},Factory={},Validators={};Object.defineProperty(Validators,"__esModule",{value:!0});Validators.getComponentValidator=Validators.getBooleanValidator=Validators.getNumberArrayValidator=Validators.getFunctionValidator=Validators.getStringOrGradientValidator=Validators.getStringValidator=Validators.getNumberOrAutoValidator=Validators.getNumberOrArrayOfNumbersValidator=Validators.getNumberValidator=Validators.alphaComponent=Validators.RGBComponent=void 0;const Global_1$p=Global,Util_1$f=Util;function _formatValue(l){return Util_1$f.Util._isString(l)?'"'+l+'"':Object.prototype.toString.call(l)==="[object Number]"||Util_1$f.Util._isBoolean(l)?l:Object.prototype.toString.call(l)}function RGBComponent(l){return l>255?255:l<0?0:Math.round(l)}Validators.RGBComponent=RGBComponent;function alphaComponent(l){return l>1?1:l<1e-4?1e-4:l}Validators.alphaComponent=alphaComponent;function getNumberValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){return Util_1$f.Util._isNumber(l)||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),l}}Validators.getNumberValidator=getNumberValidator;function getNumberOrArrayOfNumbersValidator(l){if(Global_1$p.Konva.isUnminified)return function(e,n){let t=Util_1$f.Util._isNumber(e),a=Util_1$f.Util._isArray(e)&&e.length==l;return!t&&!a&&Util_1$f.Util.warn(_formatValue(e)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+l+")"),e}}Validators.getNumberOrArrayOfNumbersValidator=getNumberOrArrayOfNumbersValidator;function getNumberOrAutoValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){var n=Util_1$f.Util._isNumber(l),t=l==="auto";return n||t||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),l}}Validators.getNumberOrAutoValidator=getNumberOrAutoValidator;function getStringValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){return Util_1$f.Util._isString(l)||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),l}}Validators.getStringValidator=getStringValidator;function getStringOrGradientValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){const n=Util_1$f.Util._isString(l),t=Object.prototype.toString.call(l)==="[object CanvasGradient]"||l&&l.addColorStop;return n||t||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),l}}Validators.getStringOrGradientValidator=getStringOrGradientValidator;function getFunctionValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){return Util_1$f.Util._isFunction(l)||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),l}}Validators.getFunctionValidator=getFunctionValidator;function getNumberArrayValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&l instanceof n||(Util_1$f.Util._isArray(l)?l.forEach(function(t){Util_1$f.Util._isNumber(t)||Util_1$f.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),l}}Validators.getNumberArrayValidator=getNumberArrayValidator;function getBooleanValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){var n=l===!0||l===!1;return n||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),l}}Validators.getBooleanValidator=getBooleanValidator;function getComponentValidator(l){if(Global_1$p.Konva.isUnminified)return function(e,n){return e==null||Util_1$f.Util.isObject(e)||Util_1$f.Util.warn(_formatValue(e)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+l),e}}Validators.getComponentValidator=getComponentValidator;(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Factory=void 0;const e=Util,n=Validators;var t="get",a="set";l.Factory={addGetterSetter(o,d,h,f,u){l.Factory.addGetter(o,d,h),l.Factory.addSetter(o,d,f,u),l.Factory.addOverloadedGetterSetter(o,d)},addGetter(o,d,h){var f=t+e.Util._capitalize(d);o.prototype[f]=o.prototype[f]||function(){var u=this.attrs[d];return u===void 0?h:u}},addSetter(o,d,h,f){var u=a+e.Util._capitalize(d);o.prototype[u]||l.Factory.overWriteSetter(o,d,h,f)},overWriteSetter(o,d,h,f){var u=a+e.Util._capitalize(d);o.prototype[u]=function(p){return h&&p!==void 0&&p!==null&&(p=h.call(this,p,d)),this._setAttr(d,p),f&&f.call(this),this}},addComponentsGetterSetter(o,d,h,f,u){var p=h.length,E=e.Util._capitalize,T=t+E(d),v=a+E(d),S,g;o.prototype[T]=function(){var b={};for(S=0;S<p;S++)g=h[S],b[g]=this.getAttr(d+E(g));return b};var y=(0,n.getComponentValidator)(h);o.prototype[v]=function(b){var R=this.attrs[d],_;f&&(b=f.call(this,b)),y&&y.call(this,b,d);for(_ in b)b.hasOwnProperty(_)&&this._setAttr(d+E(_),b[_]);return b||h.forEach(w=>{this._setAttr(d+E(w),void 0)}),this._fireChangeEvent(d,R,b),u&&u.call(this),this},l.Factory.addOverloadedGetterSetter(o,d)},addOverloadedGetterSetter(o,d){var h=e.Util._capitalize(d),f=a+h,u=t+h;o.prototype[d]=function(){return arguments.length?(this[f](arguments[0]),this):this[u]()}},addDeprecatedGetterSetter(o,d,h,f){e.Util.error("Adding deprecated "+d);var u=t+e.Util._capitalize(d),p=d+" property is deprecated and will be removed soon. Look at Konva change log for more information.";o.prototype[u]=function(){e.Util.error(p);var E=this.attrs[d];return E===void 0?h:E},l.Factory.addSetter(o,d,f,function(){e.Util.error(p)}),l.Factory.addOverloadedGetterSetter(o,d)},backCompat(o,d){e.Util.each(d,function(h,f){var u=o.prototype[f],p=t+e.Util._capitalize(h),E=a+e.Util._capitalize(h);function T(){u.apply(this,arguments),e.Util.error('"'+h+'" method is deprecated and will be removed soon. Use ""'+f+'" instead.')}o.prototype[h]=T,o.prototype[p]=T,o.prototype[E]=T})},afterSetFilter(){this._filterUpToDate=!1}}})(Factory);var Canvas$1={},Context$2={};Object.defineProperty(Context$2,"__esModule",{value:!0});Context$2.HitContext=Context$2.SceneContext=Context$2.Context=void 0;const Util_1$e=Util,Global_1$o=Global;function simplifyArray(l){var e=[],n=l.length,t=Util_1$e.Util,a,o;for(a=0;a<n;a++)o=l[a],t._isNumber(o)?o=Math.round(o*1e3)/1e3:t._isString(o)||(o=o+""),e.push(o);return e}var COMMA=",",OPEN_PAREN="(",CLOSE_PAREN=")",OPEN_PAREN_BRACKET="([",CLOSE_BRACKET_PAREN="])",SEMICOLON=";",DOUBLE_PAREN="()",EQUALS="=",CONTEXT_METHODS=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],CONTEXT_PROPERTIES=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"];const traceArrMax=100;let Context$1=class{constructor(e){this.canvas=e,Global_1$o.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,n){var t=this.traceArr,a=t.length,o="",d,h,f,u;for(d=0;d<a;d++)h=t[d],f=h.method,f?(u=h.args,o+=f,e?o+=DOUBLE_PAREN:Util_1$e.Util._isArray(u[0])?o+=OPEN_PAREN_BRACKET+u.join(COMMA)+CLOSE_BRACKET_PAREN:(n&&(u=u.map(p=>typeof p=="number"?Math.floor(p):p)),o+=OPEN_PAREN+u.join(COMMA)+CLOSE_PAREN)):(o+=h.property,e||(o+=EQUALS+h.val)),o+=SEMICOLON;return o}clearTrace(){this.traceArr=[]}_trace(e){var n=this.traceArr,t;n.push(e),t=n.length,t>=traceArrMax&&n.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var n=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,n.getWidth()/n.pixelRatio,n.getHeight()/n.pixelRatio)}_applyLineCap(e){const n=e.attrs.lineCap;n&&this.setAttr("lineCap",n)}_applyOpacity(e){var n=e.getAbsoluteOpacity();n!==1&&this.setAttr("globalAlpha",n)}_applyLineJoin(e){const n=e.attrs.lineJoin;n&&this.setAttr("lineJoin",n)}setAttr(e,n){this._context[e]=n}arc(e,n,t,a,o,d){this._context.arc(e,n,t,a,o,d)}arcTo(e,n,t,a,o){this._context.arcTo(e,n,t,a,o)}beginPath(){this._context.beginPath()}bezierCurveTo(e,n,t,a,o,d){this._context.bezierCurveTo(e,n,t,a,o,d)}clearRect(e,n,t,a){this._context.clearRect(e,n,t,a)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,n){var t=arguments;if(t.length===2)return this._context.createImageData(e,n);if(t.length===1)return this._context.createImageData(e)}createLinearGradient(e,n,t,a){return this._context.createLinearGradient(e,n,t,a)}createPattern(e,n){return this._context.createPattern(e,n)}createRadialGradient(e,n,t,a,o,d){return this._context.createRadialGradient(e,n,t,a,o,d)}drawImage(e,n,t,a,o,d,h,f,u){var p=arguments,E=this._context;p.length===3?E.drawImage(e,n,t):p.length===5?E.drawImage(e,n,t,a,o):p.length===9&&E.drawImage(e,n,t,a,o,d,h,f,u)}ellipse(e,n,t,a,o,d,h,f){this._context.ellipse(e,n,t,a,o,d,h,f)}isPointInPath(e,n,t,a){return t?this._context.isPointInPath(t,e,n,a):this._context.isPointInPath(e,n,a)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,n,t,a){this._context.fillRect(e,n,t,a)}strokeRect(e,n,t,a){this._context.strokeRect(e,n,t,a)}fillText(e,n,t,a){a?this._context.fillText(e,n,t,a):this._context.fillText(e,n,t)}measureText(e){return this._context.measureText(e)}getImageData(e,n,t,a){return this._context.getImageData(e,n,t,a)}lineTo(e,n){this._context.lineTo(e,n)}moveTo(e,n){this._context.moveTo(e,n)}rect(e,n,t,a){this._context.rect(e,n,t,a)}putImageData(e,n,t){this._context.putImageData(e,n,t)}quadraticCurveTo(e,n,t,a){this._context.quadraticCurveTo(e,n,t,a)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,n){this._context.scale(e,n)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,n,t,a,o,d){this._context.setTransform(e,n,t,a,o,d)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,n,t,a){this._context.strokeText(e,n,t,a)}transform(e,n,t,a,o,d){this._context.transform(e,n,t,a,o,d)}translate(e,n){this._context.translate(e,n)}_enableTrace(){var e=this,n=CONTEXT_METHODS.length,t=this.setAttr,a,o,d=function(h){var f=e[h],u;e[h]=function(){return o=simplifyArray(Array.prototype.slice.call(arguments,0)),u=f.apply(e,arguments),e._trace({method:h,args:o}),u}};for(a=0;a<n;a++)d(CONTEXT_METHODS[a]);e.setAttr=function(){t.apply(e,arguments);var h=arguments[0],f=arguments[1];(h==="shadowOffsetX"||h==="shadowOffsetY"||h==="shadowBlur")&&(f=f/this.canvas.getPixelRatio()),e._trace({property:h,val:f})}}_applyGlobalCompositeOperation(e){const n=e.attrs.globalCompositeOperation;var t=!n||n==="source-over";t||this.setAttr("globalCompositeOperation",n)}};Context$2.Context=Context$1;CONTEXT_PROPERTIES.forEach(function(l){Object.defineProperty(Context$1.prototype,l,{get(){return this._context[l]},set(e){this._context[l]=e}})});class SceneContext extends Context$1{constructor(e,{willReadFrequently:n=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:n})}_fillColor(e){var n=e.fill();this.setAttr("fillStyle",n),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var n=e._getLinearGradient();n&&(this.setAttr("fillStyle",n),e._fillFunc(this))}_fillRadialGradient(e){const n=e._getRadialGradient();n&&(this.setAttr("fillStyle",n),e._fillFunc(this))}_fill(e){const n=e.fill(),t=e.getFillPriority();if(n&&t==="color"){this._fillColor(e);return}const a=e.getFillPatternImage();if(a&&t==="pattern"){this._fillPattern(e);return}const o=e.getFillLinearGradientColorStops();if(o&&t==="linear-gradient"){this._fillLinearGradient(e);return}const d=e.getFillRadialGradientColorStops();if(d&&t==="radial-gradient"){this._fillRadialGradient(e);return}n?this._fillColor(e):a?this._fillPattern(e):o?this._fillLinearGradient(e):d&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const n=e.getStrokeLinearGradientStartPoint(),t=e.getStrokeLinearGradientEndPoint(),a=e.getStrokeLinearGradientColorStops(),o=this.createLinearGradient(n.x,n.y,t.x,t.y);if(a){for(var d=0;d<a.length;d+=2)o.addColorStop(a[d],a[d+1]);this.setAttr("strokeStyle",o)}}_stroke(e){var n=e.dash(),t=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!t){this.save();var a=this.getCanvas().getPixelRatio();this.setTransform(a,0,0,a,0,0)}this._applyLineCap(e),n&&e.dashEnabled()&&(this.setLineDash(n),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");var o=e.getStrokeLinearGradientColorStops();o?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),t||this.restore()}}_applyShadow(e){var n,t,a,o=(n=e.getShadowRGBA())!==null&&n!==void 0?n:"black",d=(t=e.getShadowBlur())!==null&&t!==void 0?t:5,h=(a=e.getShadowOffset())!==null&&a!==void 0?a:{x:0,y:0},f=e.getAbsoluteScale(),u=this.canvas.getPixelRatio(),p=f.x*u,E=f.y*u;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",d*Math.min(Math.abs(p),Math.abs(E))),this.setAttr("shadowOffsetX",h.x*p),this.setAttr("shadowOffsetY",h.y*E)}}Context$2.SceneContext=SceneContext;class HitContext extends Context$1{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const o=e.getStrokeScaleEnabled();if(!o){this.save();var n=this.getCanvas().getPixelRatio();this.setTransform(n,0,0,n,0,0)}this._applyLineCap(e);var t=e.hitStrokeWidth(),a=t==="auto"?e.strokeWidth():t;this.setAttr("lineWidth",a),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),o||this.restore()}}}Context$2.HitContext=HitContext;Object.defineProperty(Canvas$1,"__esModule",{value:!0});Canvas$1.HitCanvas=Canvas$1.SceneCanvas=Canvas$1.Canvas=void 0;const Util_1$d=Util,Context_1=Context$2,Global_1$n=Global,Factory_1$z=Factory,Validators_1$y=Validators;var _pixelRatio;function getDevicePixelRatio(){if(_pixelRatio)return _pixelRatio;var l=Util_1$d.Util.createCanvasElement(),e=l.getContext("2d");return _pixelRatio=function(){var n=Global_1$n.Konva._global.devicePixelRatio||1,t=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return n/t}(),Util_1$d.Util.releaseCanvas(l),_pixelRatio}class Canvas{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var n=e||{},t=n.pixelRatio||Global_1$n.Konva.pixelRatio||getDevicePixelRatio();this.pixelRatio=t,this._canvas=Util_1$d.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){var n=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/n,this.getHeight()/n)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var n=this.pixelRatio,t=this.getContext()._context;t.scale(n,n)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var n=this.pixelRatio,t=this.getContext()._context;t.scale(n,n)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,n){this.setWidth(e||0),this.setHeight(n||0)}toDataURL(e,n){try{return this._canvas.toDataURL(e,n)}catch{try{return this._canvas.toDataURL()}catch(a){return Util_1$d.Util.error("Unable to get data URL. "+a.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}Canvas$1.Canvas=Canvas;Factory_1$z.Factory.addGetterSetter(Canvas,"pixelRatio",void 0,(0,Validators_1$y.getNumberValidator)());class SceneCanvas extends Canvas{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new Context_1.SceneContext(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}}Canvas$1.SceneCanvas=SceneCanvas;class HitCanvas extends Canvas{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new Context_1.HitContext(this),this.setSize(e.width,e.height)}}Canvas$1.HitCanvas=HitCanvas;var DragAndDrop={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.DD=void 0;const e=Global,n=Util;l.DD={get isDragging(){var t=!1;return l.DD._dragElements.forEach(a=>{a.dragStatus==="dragging"&&(t=!0)}),t},justDragged:!1,get node(){var t;return l.DD._dragElements.forEach(a=>{t=a.node}),t},_dragElements:new Map,_drag(t){const a=[];l.DD._dragElements.forEach((o,d)=>{const{node:h}=o,f=h.getStage();f.setPointersPositions(t),o.pointerId===void 0&&(o.pointerId=n.Util._getFirstPointerId(t));const u=f._changedPointerPositions.find(T=>T.id===o.pointerId);if(u){if(o.dragStatus!=="dragging"){var p=h.dragDistance(),E=Math.max(Math.abs(u.x-o.startPointerPos.x),Math.abs(u.y-o.startPointerPos.y));if(E<p||(h.startDrag({evt:t}),!h.isDragging()))return}h._setDragPosition(t,o),a.push(h)}}),a.forEach(o=>{o.fire("dragmove",{type:"dragmove",target:o,evt:t},!0)})},_endDragBefore(t){const a=[];l.DD._dragElements.forEach(o=>{const{node:d}=o,h=d.getStage();if(t&&h.setPointersPositions(t),!h._changedPointerPositions.find(p=>p.id===o.pointerId))return;(o.dragStatus==="dragging"||o.dragStatus==="stopped")&&(l.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,o.dragStatus="stopped");const u=o.node.getLayer()||o.node instanceof e.Konva.Stage&&o.node;u&&a.indexOf(u)===-1&&a.push(u)}),a.forEach(o=>{o.draw()})},_endDragAfter(t){l.DD._dragElements.forEach((a,o)=>{a.dragStatus==="stopped"&&a.node.fire("dragend",{type:"dragend",target:a.node,evt:t},!0),a.dragStatus!=="dragging"&&l.DD._dragElements.delete(o)})}},e.Konva.isBrowser&&(window.addEventListener("mouseup",l.DD._endDragBefore,!0),window.addEventListener("touchend",l.DD._endDragBefore,!0),window.addEventListener("mousemove",l.DD._drag),window.addEventListener("touchmove",l.DD._drag),window.addEventListener("mouseup",l.DD._endDragAfter,!1),window.addEventListener("touchend",l.DD._endDragAfter,!1))})(DragAndDrop);Object.defineProperty(Node$1,"__esModule",{value:!0});Node$1.Node=void 0;const Util_1$c=Util,Factory_1$y=Factory,Canvas_1$1=Canvas$1,Global_1$m=Global,DragAndDrop_1=DragAndDrop,Validators_1$x=Validators;var ABSOLUTE_OPACITY="absoluteOpacity",ALL_LISTENERS="allEventListeners",ABSOLUTE_TRANSFORM="absoluteTransform",ABSOLUTE_SCALE="absoluteScale",CANVAS="canvas",CHANGE="Change",CHILDREN="children",KONVA="konva",LISTENING="listening",MOUSEENTER="mouseenter",MOUSELEAVE="mouseleave",SET="set",SHAPE="Shape",SPACE$1=" ",STAGE="stage",TRANSFORM="transform",UPPER_STAGE="Stage",VISIBLE="visible",TRANSFORM_CHANGE_STR$1=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(SPACE$1);let idCounter=1;class Node{constructor(e){this._id=idCounter++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===TRANSFORM||e===ABSOLUTE_TRANSFORM)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,n){var t=this._cache.get(e),a=e===TRANSFORM||e===ABSOLUTE_TRANSFORM,o=t===void 0||a&&t.dirty===!0;return o&&(t=n.call(this),this._cache.set(e,t)),t}_calculate(e,n,t){if(!this._attachedDepsListeners.get(e)){const a=n.map(o=>o+"Change.konva").join(SPACE$1);this.on(a,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,t)}_getCanvasCache(){return this._cache.get(CANVAS)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===ABSOLUTE_TRANSFORM&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(CANVAS)){const{scene:e,filter:n,hit:t}=this._cache.get(CANVAS);Util_1$c.Util.releaseCanvas(e,n,t),this._cache.delete(CANVAS)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var n=e||{},t={};(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)&&(t=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));var a=Math.ceil(n.width||t.width),o=Math.ceil(n.height||t.height),d=n.pixelRatio,h=n.x===void 0?Math.floor(t.x):n.x,f=n.y===void 0?Math.floor(t.y):n.y,u=n.offset||0,p=n.drawBorder||!1,E=n.hitCanvasPixelRatio||1;if(!a||!o){Util_1$c.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}a+=u*2+1,o+=u*2+1,h-=u,f-=u;var T=new Canvas_1$1.SceneCanvas({pixelRatio:d,width:a,height:o}),v=new Canvas_1$1.SceneCanvas({pixelRatio:d,width:0,height:0,willReadFrequently:!0}),S=new Canvas_1$1.HitCanvas({pixelRatio:E,width:a,height:o}),g=T.getContext(),y=S.getContext();return S.isCache=!0,T.isCache=!0,this._cache.delete(CANVAS),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(T.getContext()._context.imageSmoothingEnabled=!1,v.getContext()._context.imageSmoothingEnabled=!1),g.save(),y.save(),g.translate(-h,-f),y.translate(-h,-f),this._isUnderCache=!0,this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this.drawScene(T,this),this.drawHit(S,this),this._isUnderCache=!1,g.restore(),y.restore(),p&&(g.save(),g.beginPath(),g.rect(0,0,a,o),g.closePath(),g.setAttr("strokeStyle","red"),g.setAttr("lineWidth",5),g.stroke(),g.restore()),this._cache.set(CANVAS,{scene:T,filter:v,hit:S,x:h,y:f}),this._requestDraw(),this}isCached(){return this._cache.has(CANVAS)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,n){var t=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],a=1/0,o=1/0,d=-1/0,h=-1/0,f=this.getAbsoluteTransform(n);return t.forEach(function(u){var p=f.point(u);a===void 0&&(a=d=p.x,o=h=p.y),a=Math.min(a,p.x),o=Math.min(o,p.y),d=Math.max(d,p.x),h=Math.max(h,p.y)}),{x:a,y:o,width:d-a,height:h-o}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();e.translate(n.x,n.y);var t=this._getCachedSceneCanvas(),a=t.pixelRatio;e.drawImage(t._canvas,0,0,t.width/a,t.height/a),e.restore()}_drawCachedHitCanvas(e){var n=this._getCanvasCache(),t=n.hit;e.save(),e.translate(n.x,n.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),n=this._getCanvasCache(),t=n.scene,a=n.filter,o=a.getContext(),d,h,f,u;if(e){if(!this._filterUpToDate){var p=t.pixelRatio;a.setSize(t.width/t.pixelRatio,t.height/t.pixelRatio);try{for(d=e.length,o.clear(),o.drawImage(t._canvas,0,0,t.getWidth()/p,t.getHeight()/p),h=o.getImageData(0,0,a.getWidth(),a.getHeight()),f=0;f<d;f++){if(u=e[f],typeof u!="function"){Util_1$c.Util.error("Filter should be type of function, but got "+typeof u+" instead. Please check correct filters");continue}u.call(this,h),o.putImageData(h,0,0)}}catch(E){Util_1$c.Util.error("Unable to apply filter. "+E.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return a}return t}on(e,n){if(this._cache&&this._cache.delete(ALL_LISTENERS),arguments.length===3)return this._delegate.apply(this,arguments);var t=e.split(SPACE$1),a=t.length,o,d,h,f,u;for(o=0;o<a;o++)d=t[o],h=d.split("."),f=h[0],u=h[1]||"",this.eventListeners[f]||(this.eventListeners[f]=[]),this.eventListeners[f].push({name:u,handler:n});return this}off(e,n){var t=(e||"").split(SPACE$1),a=t.length,o,d,h,f,u,p;if(this._cache&&this._cache.delete(ALL_LISTENERS),!e)for(d in this.eventListeners)this._off(d);for(o=0;o<a;o++)if(h=t[o],f=h.split("."),u=f[0],p=f[1],u)this.eventListeners[u]&&this._off(u,p,n);else for(d in this.eventListeners)this._off(d,p,n);return this}dispatchEvent(e){var n={target:this,type:e.type,evt:e};return this.fire(e.type,n),this}addEventListener(e,n){return this.on(e,function(t){n.call(this,t.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,n,t){var a=this;this.on(e,function(o){for(var d=o.target.findAncestors(n,!0,a),h=0;h<d.length;h++)o=Util_1$c.Util.cloneObject(o),o.currentTarget=d[h],t.call(d[h],o)})}remove(){return this.isDragging()&&this.stopDrag(),DragAndDrop_1.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this._clearSelfAndDescendantCache(STAGE),this._clearSelfAndDescendantCache(VISIBLE),this._clearSelfAndDescendantCache(LISTENING)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var n="get"+Util_1$c.Util._capitalize(e);return Util_1$c.Util._isFunction(this[n])?this[n]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),n=[];e;)n.push(e),e=e.getParent();return n}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{var n,t;if(!e)return this;for(n in e)n!==CHILDREN&&(t=SET+Util_1$c.Util._capitalize(n),Util_1$c.Util._isFunction(this[t])?this[t](e[n]):this._setAttr(n,e[n]))}),this}isListening(){return this._getCache(LISTENING,this._isListening)}_isListening(e){if(!this.listening())return!1;const t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(VISIBLE,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e,n=!1){if(e)return this._isVisible(e)&&this._isListening(e);var t=this.getLayer(),a=!1;DragAndDrop_1.DD._dragElements.forEach(d=>{d.dragStatus==="dragging"&&(d.node.nodeType==="Stage"||d.node.getLayer()===t)&&(a=!0)});var o=!n&&!Global_1$m.Konva.hitOnDragEnabled&&a;return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e=this.getDepth(),n=this,t=0,a,o,d,h;function f(p){for(a=[],o=p.length,d=0;d<o;d++)h=p[d],t++,h.nodeType!==SHAPE&&(a=a.concat(h.getChildren().slice())),h._id===n._id&&(d=o);a.length>0&&a[0].getDepth()<=e&&f(a)}const u=this.getStage();return n.nodeType!==UPPER_STAGE&&u&&f(u.getChildren()),t}getDepth(){for(var e=0,n=this.parent;n;)e++,n=n.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const e=this.getStage();if(!e)return null;var n=e.getPointerPosition();if(!n)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(n)}getAbsolutePosition(e){let n=!1,t=this.parent;for(;t;){if(t.isCached()){n=!0;break}t=t.parent}n&&!e&&(e=!0);var a=this.getAbsoluteTransform(e).getMatrix(),o=new Util_1$c.Transform,d=this.offset();return o.m=a.slice(),o.translate(d.x,d.y),o.getTranslation()}setAbsolutePosition(e){const{x:n,y:t,...a}=this._clearTransform();this.attrs.x=n,this.attrs.y=t,this._clearCache(TRANSFORM);var o=this._getAbsoluteTransform().copy();return o.invert(),o.translate(e.x,e.y),e={x:this.attrs.x+o.getTranslation().x,y:this.attrs.y+o.getTranslation().y},this._setTransform(a),this.setPosition({x:e.x,y:e.y}),this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this}_setTransform(e){var n;for(n in e)this.attrs[n]=e[n]}_clearTransform(){var e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){var n=e.x,t=e.y,a=this.x(),o=this.y();return n!==void 0&&(a+=n),t!==void 0&&(o+=t),this.setPosition({x:a,y:o}),this}_eachAncestorReverse(e,n){var t=[],a=this.getParent(),o,d;if(!(n&&n._id===this._id)){for(t.unshift(this);a&&(!n||a._id!==n._id);)t.unshift(a),a=a.parent;for(o=t.length,d=0;d<o;d++)e(t[d])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index,n=this.parent.getChildren().length;return e<n-1?(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index,n=this.parent.getChildren().length;return e<n-1?(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(e){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&Util_1$c.Util.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(ABSOLUTE_OPACITY,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var e=this.opacity(),n=this.getParent();return n&&!n._isUnderCache&&(e*=n.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e={},n=this.getAttrs(),t,a,o,d,h;e.attrs={};for(t in n)a=n[t],h=Util_1$c.Util.isObject(a)&&!Util_1$c.Util._isPlainObject(a)&&!Util_1$c.Util._isArray(a),!h&&(o=typeof this[t]=="function"&&this[t],delete n[t],d=o?o.call(this):null,n[t]=a,d!==a&&(e.attrs[t]=a));return e.className=this.getClassName(),Util_1$c.Util._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,n,t){var a=[];n&&this._isMatch(e)&&a.push(this);for(var o=this.parent;o;){if(o===t)return a;o._isMatch(e)&&a.push(o),o=o.parent}return a}isAncestorOf(e){return!1}findAncestor(e,n,t){return this.findAncestors(e,n,t)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var n=e.replace(/ /g,"").split(","),t=n.length,a,o;for(a=0;a<t;a++)if(o=n[a],Util_1$c.Util.isValidSelector(o)||(Util_1$c.Util.warn('Selector "'+o+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Util_1$c.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Util_1$c.Util.warn("Konva is awesome, right?")),o.charAt(0)==="#"){if(this.id()===o.slice(1))return!0}else if(o.charAt(0)==="."){if(this.hasName(o.slice(1)))return!0}else if(this.className===o||this.nodeType===o)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(STAGE,this._getStage)}_getStage(){var e=this.getParent();return e?e.getStage():null}fire(e,n={},t){return n.target=n.target||this,t?this._fireAndBubble(e,n):this._fire(e,n),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(ABSOLUTE_TRANSFORM,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var n;if(e)return n=new Util_1$c.Transform,this._eachAncestorReverse(function(a){var o=a.transformsEnabled();o==="all"?n.multiply(a.getTransform()):o==="position"&&n.translate(a.x()-a.offsetX(),a.y()-a.offsetY())},e),n;n=this._cache.get(ABSOLUTE_TRANSFORM)||new Util_1$c.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();var t=this.transformsEnabled();if(t==="all")n.multiply(this.getTransform());else if(t==="position"){const a=this.attrs.x||0,o=this.attrs.y||0,d=this.attrs.offsetX||0,h=this.attrs.offsetY||0;n.translate(a-d,o-h)}return n.dirty=!1,n}getAbsoluteScale(e){for(var n=this;n;)n._isUnderCache&&(e=n),n=n.getParent();const a=this.getAbsoluteTransform(e).decompose();return{x:a.scaleX,y:a.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(TRANSFORM,this._getTransform)}_getTransform(){var e,n,t=this._cache.get(TRANSFORM)||new Util_1$c.Transform;t.reset();var a=this.x(),o=this.y(),d=Global_1$m.Konva.getAngle(this.rotation()),h=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,f=(n=this.attrs.scaleY)!==null&&n!==void 0?n:1,u=this.attrs.skewX||0,p=this.attrs.skewY||0,E=this.attrs.offsetX||0,T=this.attrs.offsetY||0;return(a!==0||o!==0)&&t.translate(a,o),d!==0&&t.rotate(d),(u!==0||p!==0)&&t.skew(u,p),(h!==1||f!==1)&&t.scale(h,f),(E!==0||T!==0)&&t.translate(-1*E,-1*T),t.dirty=!1,t}clone(e){var n=Util_1$c.Util.cloneObject(this.attrs),t,a,o,d,h;for(t in e)n[t]=e[t];var f=new this.constructor(n);for(t in this.eventListeners)for(a=this.eventListeners[t],o=a.length,d=0;d<o;d++)h=a[d],h.name.indexOf(KONVA)<0&&(f.eventListeners[t]||(f.eventListeners[t]=[]),f.eventListeners[t].push(h));return f}_toKonvaCanvas(e){e=e||{};var n=this.getClientRect(),t=this.getStage(),a=e.x!==void 0?e.x:Math.floor(n.x),o=e.y!==void 0?e.y:Math.floor(n.y),d=e.pixelRatio||1,h=new Canvas_1$1.SceneCanvas({width:e.width||Math.ceil(n.width)||(t?t.width():0),height:e.height||Math.ceil(n.height)||(t?t.height():0),pixelRatio:d}),f=h.getContext();return e.imageSmoothingEnabled===!1&&(f._context.imageSmoothingEnabled=!1),f.save(),(a||o)&&f.translate(-1*a,-1*o),this.drawScene(h),f.restore(),h}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var n=e.mimeType||null,t=e.quality||null,a=this._toKonvaCanvas(e).toDataURL(n,t);return e.callback&&e.callback(a),a}toImage(e){return new Promise((n,t)=>{try{const a=e==null?void 0:e.callback;a&&delete e.callback,Util_1$c.Util._urlToImage(this.toDataURL(e),function(o){n(o),a==null||a(o)})}catch(a){t(a)}})}toBlob(e){return new Promise((n,t)=>{try{const a=e==null?void 0:e.callback;a&&delete e.callback,this.toCanvas(e).toBlob(o=>{n(o),a==null||a(o)},e==null?void 0:e.mimeType,e==null?void 0:e.quality)}catch(a){t(a)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Global_1$m.Konva.dragDistance}_off(e,n,t){var a=this.eventListeners[e],o,d,h;for(o=0;o<a.length;o++)if(d=a[o].name,h=a[o].handler,(d!=="konva"||n==="konva")&&(!n||d===n)&&(!t||t===h)){if(a.splice(o,1),a.length===0){delete this.eventListeners[e];break}o--}}_fireChangeEvent(e,n,t){this._fire(e+CHANGE,{oldVal:n,newVal:t})}addName(e){if(!this.hasName(e)){var n=this.name(),t=n?n+" "+e:e;this.name(t)}return this}hasName(e){if(!e)return!1;const n=this.name();if(!n)return!1;var t=(n||"").split(/\s/g);return t.indexOf(e)!==-1}removeName(e){var n=(this.name()||"").split(/\s/g),t=n.indexOf(e);return t!==-1&&(n.splice(t,1),this.name(n.join(" "))),this}setAttr(e,n){var t=this[SET+Util_1$c.Util._capitalize(e)];return Util_1$c.Util._isFunction(t)?t.call(this,n):this._setAttr(e,n),this}_requestDraw(){if(Global_1$m.Konva.autoDrawEnabled){const e=this.getLayer()||this.getStage();e==null||e.batchDraw()}}_setAttr(e,n){var t=this.attrs[e];t===n&&!Util_1$c.Util.isObject(n)||(n==null?delete this.attrs[e]:this.attrs[e]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(e,t,n),this._requestDraw())}_setComponentAttr(e,n,t){var a;t!==void 0&&(a=this.attrs[e],a||(this.attrs[e]=this.getAttr(e)),this.attrs[e][n]=t,this._fireChangeEvent(e,a,t))}_fireAndBubble(e,n,t){n&&this.nodeType===SHAPE&&(n.target=this);var a=(e===MOUSEENTER||e===MOUSELEAVE)&&(t&&(this===t||this.isAncestorOf&&this.isAncestorOf(t))||this.nodeType==="Stage"&&!t);if(!a){this._fire(e,n);var o=(e===MOUSEENTER||e===MOUSELEAVE)&&t&&t.isAncestorOf&&t.isAncestorOf(this)&&!t.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!o&&(t&&t.parent?this._fireAndBubble.call(this.parent,e,n,t):this._fireAndBubble.call(this.parent,e,n))}}_getProtoListeners(e){var n,t,a;const o=(n=this._cache.get(ALL_LISTENERS))!==null&&n!==void 0?n:{};let d=o==null?void 0:o[e];if(d===void 0){d=[];let h=Object.getPrototypeOf(this);for(;h;){const f=(a=(t=h.eventListeners)===null||t===void 0?void 0:t[e])!==null&&a!==void 0?a:[];d.push(...f),h=Object.getPrototypeOf(h)}o[e]=d,this._cache.set(ALL_LISTENERS,o)}return d}_fire(e,n){n=n||{},n.currentTarget=this,n.type=e;const t=this._getProtoListeners(e);if(t)for(var a=0;a<t.length;a++)t[a].handler.call(this,n);const o=this.eventListeners[e];if(o)for(var a=0;a<o.length;a++)o[a].handler.call(this,n)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var n=e?e.pointerId:void 0,t=this.getStage(),a=this.getAbsolutePosition();if(t){var o=t._getPointerById(n)||t._changedPointerPositions[0]||a;DragAndDrop_1.DD._dragElements.set(this._id,{node:this,startPointerPos:o,offset:{x:o.x-a.x,y:o.y-a.y},dragStatus:"ready",pointerId:n})}}startDrag(e,n=!0){DragAndDrop_1.DD._dragElements.has(this._id)||this._createDragElement(e);const t=DragAndDrop_1.DD._dragElements.get(this._id);t.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},n)}_setDragPosition(e,n){const t=this.getStage()._getPointerById(n.pointerId);if(t){var a={x:t.x-n.offset.x,y:t.y-n.offset.y},o=this.dragBoundFunc();if(o!==void 0){const d=o.call(this,a,e);d?a=d:Util_1$c.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==a.x||this._lastPos.y!==a.y)&&(this.setAbsolutePosition(a),this._requestDraw()),this._lastPos=a}}stopDrag(e){const n=DragAndDrop_1.DD._dragElements.get(this._id);n&&(n.dragStatus="stopped"),DragAndDrop_1.DD._endDragBefore(e),DragAndDrop_1.DD._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=DragAndDrop_1.DD._dragElements.get(this._id);return e?e.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(e){var n=e.evt.button!==void 0,t=!n||Global_1$m.Konva.dragButtons.indexOf(e.evt.button)>=0;if(t&&!this.isDragging()){var a=!1;DragAndDrop_1.DD._dragElements.forEach(o=>{this.isAncestorOf(o.node)&&(a=!0)}),a||this._createDragElement(e)}})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var e=this.getStage();if(!e)return;const n=DragAndDrop_1.DD._dragElements.get(this._id),t=n&&n.dragStatus==="dragging",a=n&&n.dragStatus==="ready";t?this.stopDrag():a&&DragAndDrop_1.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const n=this.getStage();if(!n)return!1;const t={x:-e.x,y:-e.y,width:n.width()+2*e.x,height:n.height()+2*e.y};return Util_1$c.Util.haveIntersection(t,this.getClientRect())}static create(e,n){return Util_1$c.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,n)}static _createNode(e,n){var t=Node.prototype.getClassName.call(e),a=e.children,o,d,h;n&&(e.attrs.container=n),Global_1$m.Konva[t]||(Util_1$c.Util.warn('Can not find a node with class name "'+t+'". Fallback to "Shape".'),t="Shape");const f=Global_1$m.Konva[t];if(o=new f(e.attrs),a)for(d=a.length,h=0;h<d;h++)o.add(Node._createNode(a[h]));return o}}Node$1.Node=Node;Node.prototype.nodeType="Node";Node.prototype._attrsAffectingSize=[];Node.prototype.eventListeners={};Node.prototype.on.call(Node.prototype,TRANSFORM_CHANGE_STR$1,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM)});Node.prototype.on.call(Node.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(VISIBLE)});Node.prototype.on.call(Node.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(LISTENING)});Node.prototype.on.call(Node.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY)});const addGetterSetter=Factory_1$y.Factory.addGetterSetter;addGetterSetter(Node,"zIndex");addGetterSetter(Node,"absolutePosition");addGetterSetter(Node,"position");addGetterSetter(Node,"x",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"y",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"globalCompositeOperation","source-over",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"opacity",1,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"name","",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"id","",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"rotation",0,(0,Validators_1$x.getNumberValidator)());Factory_1$y.Factory.addComponentsGetterSetter(Node,"scale",["x","y"]);addGetterSetter(Node,"scaleX",1,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"scaleY",1,(0,Validators_1$x.getNumberValidator)());Factory_1$y.Factory.addComponentsGetterSetter(Node,"skew",["x","y"]);addGetterSetter(Node,"skewX",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"skewY",0,(0,Validators_1$x.getNumberValidator)());Factory_1$y.Factory.addComponentsGetterSetter(Node,"offset",["x","y"]);addGetterSetter(Node,"offsetX",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"offsetY",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"dragDistance",null,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"width",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"height",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"listening",!0,(0,Validators_1$x.getBooleanValidator)());addGetterSetter(Node,"preventDefault",!0,(0,Validators_1$x.getBooleanValidator)());addGetterSetter(Node,"filters",null,function(l){return this._filterUpToDate=!1,l});addGetterSetter(Node,"visible",!0,(0,Validators_1$x.getBooleanValidator)());addGetterSetter(Node,"transformsEnabled","all",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"size");addGetterSetter(Node,"dragBoundFunc");addGetterSetter(Node,"draggable",!1,(0,Validators_1$x.getBooleanValidator)());Factory_1$y.Factory.backCompat(Node,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Container$2={};Object.defineProperty(Container$2,"__esModule",{value:!0});Container$2.Container=void 0;const Factory_1$x=Factory,Node_1$h=Node$1,Validators_1$w=Validators;let Container$1=class extends Node_1$h.Node{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const n=this.children||[];var t=[];return n.forEach(function(a){e(a)&&t.push(a)}),t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(var n=0;n<e.length;n++)this.add(e[n]);return this}const t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var n=this._generalFind(e,!0);return n.length>0?n[0]:void 0}_generalFind(e,n){var t=[];return this._descendants(a=>{const o=a._isMatch(e);return o&&t.push(a),!!(o&&n)}),t}_descendants(e){let n=!1;const t=this.getChildren();for(const a of t){if(n=e(a),n)return!0;if(a.hasChildren()&&(n=a._descendants(e),n))return!0}return!1}toObject(){var e=Node_1$h.Node.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(n=>{e.children.push(n.toObject())}),e}isAncestorOf(e){for(var n=e.getParent();n;){if(n._id===this._id)return!0;n=n.getParent()}return!1}clone(e){var n=Node_1$h.Node.prototype.clone.call(this,e);return this.getChildren().forEach(function(t){n.add(t.clone())}),n}getAllIntersections(e){var n=[];return this.find("Shape").forEach(t=>{t.isVisible()&&t.intersects(e)&&n.push(t)}),n}_clearSelfAndDescendantCache(e){var n;super._clearSelfAndDescendantCache(e),!this.isCached()&&((n=this.children)===null||n===void 0||n.forEach(function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(n,t){n.index=t}),this._requestDraw()}drawScene(e,n){var t=this.getLayer(),a=e||t&&t.getCanvas(),o=a&&a.getContext(),d=this._getCanvasCache(),h=d&&d.scene,f=a&&a.isCache;if(!this.isVisible()&&!f)return this;if(h){o.save();var u=this.getAbsoluteTransform(n).getMatrix();o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(o),o.restore()}else this._drawChildren("drawScene",a,n);return this}drawHit(e,n){if(!this.shouldDrawHit(n))return this;var t=this.getLayer(),a=e||t&&t.hitCanvas,o=a&&a.getContext(),d=this._getCanvasCache(),h=d&&d.hit;if(h){o.save();var f=this.getAbsoluteTransform(n).getMatrix();o.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedHitCanvas(o),o.restore()}else this._drawChildren("drawHit",a,n);return this}_drawChildren(e,n,t){var a,o=n&&n.getContext(),d=this.clipWidth(),h=this.clipHeight(),f=this.clipFunc(),u=d&&h||f;const p=t===this;if(u){o.save();var E=this.getAbsoluteTransform(t),T=E.getMatrix();o.transform(T[0],T[1],T[2],T[3],T[4],T[5]),o.beginPath();let y;if(f)y=f.call(this,o,this);else{var v=this.clipX(),S=this.clipY();o.rect(v,S,d,h)}o.clip.apply(o,y),T=E.copy().invert().getMatrix(),o.transform(T[0],T[1],T[2],T[3],T[4],T[5])}var g=!p&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";g&&(o.save(),o._applyGlobalCompositeOperation(this)),(a=this.children)===null||a===void 0||a.forEach(function(y){y[e](n,t)}),g&&o.restore(),u&&o.restore()}getClientRect(e={}){var n,t=e.skipTransform,a=e.relativeTo,o,d,h,f,u={x:1/0,y:1/0,width:0,height:0},p=this;(n=this.children)===null||n===void 0||n.forEach(function(g){if(g.visible()){var y=g.getClientRect({relativeTo:p,skipShadow:e.skipShadow,skipStroke:e.skipStroke});y.width===0&&y.height===0||(o===void 0?(o=y.x,d=y.y,h=y.x+y.width,f=y.y+y.height):(o=Math.min(o,y.x),d=Math.min(d,y.y),h=Math.max(h,y.x+y.width),f=Math.max(f,y.y+y.height)))}});for(var E=this.find("Shape"),T=!1,v=0;v<E.length;v++){var S=E[v];if(S._isVisible(this)){T=!0;break}}return T&&o!==void 0?u={x:o,y:d,width:h-o,height:f-d}:u={x:0,y:0,width:0,height:0},t?u:this._transformedRect(u,a)}};Container$2.Container=Container$1;Factory_1$x.Factory.addComponentsGetterSetter(Container$1,"clip",["x","y","width","height"]);Factory_1$x.Factory.addGetterSetter(Container$1,"clipX",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipY",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipWidth",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipHeight",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipFunc");var Stage$1={},PointerEvents={};Object.defineProperty(PointerEvents,"__esModule",{value:!0});PointerEvents.releaseCapture=PointerEvents.setPointerCapture=PointerEvents.hasPointerCapture=PointerEvents.createEvent=PointerEvents.getCapturedShape=void 0;const Global_1$l=Global,Captures=new Map,SUPPORT_POINTER_EVENTS=Global_1$l.Konva._global.PointerEvent!==void 0;function getCapturedShape(l){return Captures.get(l)}PointerEvents.getCapturedShape=getCapturedShape;function createEvent(l){return{evt:l,pointerId:l.pointerId}}PointerEvents.createEvent=createEvent;function hasPointerCapture(l,e){return Captures.get(l)===e}PointerEvents.hasPointerCapture=hasPointerCapture;function setPointerCapture(l,e){releaseCapture(l),e.getStage()&&(Captures.set(l,e),SUPPORT_POINTER_EVENTS&&e._fire("gotpointercapture",createEvent(new PointerEvent("gotpointercapture"))))}PointerEvents.setPointerCapture=setPointerCapture;function releaseCapture(l,e){const n=Captures.get(l);if(!n)return;const t=n.getStage();t&&t.content,Captures.delete(l),SUPPORT_POINTER_EVENTS&&n._fire("lostpointercapture",createEvent(new PointerEvent("lostpointercapture")))}PointerEvents.releaseCapture=releaseCapture;(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Stage=l.stages=void 0;const e=Util,n=Factory,t=Container$2,a=Global,o=Canvas$1,d=DragAndDrop,h=Global,f=PointerEvents;var u="Stage",p="string",E="px",T="mouseout",v="mouseleave",S="mouseover",g="mouseenter",y="mousemove",b="mousedown",R="mouseup",_="pointermove",w="pointerdown",C="pointerup",N="pointercancel",P="lostpointercapture",D="pointerout",k="pointerleave",F="pointerover",M="pointerenter",I="contextmenu",$="touchstart",z="touchend",X="touchmove",te="touchcancel",ae="wheel",ee=5,K=[[g,"_pointerenter"],[b,"_pointerdown"],[y,"_pointermove"],[R,"_pointerup"],[v,"_pointerleave"],[$,"_pointerdown"],[X,"_pointermove"],[z,"_pointerup"],[te,"_pointercancel"],[S,"_pointerover"],[ae,"_wheel"],[I,"_contextmenu"],[w,"_pointerdown"],[_,"_pointermove"],[C,"_pointerup"],[N,"_pointercancel"],[P,"_lostpointercapture"]];const ne={mouse:{[D]:T,[k]:v,[F]:S,[M]:g,[_]:y,[w]:b,[C]:R,[N]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[D]:"touchout",[k]:"touchleave",[F]:"touchover",[M]:"touchenter",[_]:X,[w]:$,[C]:z,[N]:te,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[D]:D,[k]:k,[F]:F,[M]:M,[_]:_,[w]:w,[C]:C,[N]:N,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},ue=V=>V.indexOf("pointer")>=0?"pointer":V.indexOf("touch")>=0?"touch":"mouse",pe=V=>{const B=ue(V);if(B==="pointer")return a.Konva.pointerEventsEnabled&&ne.pointer;if(B==="touch")return ne.touch;if(B==="mouse")return ne.mouse};function J(V={}){return(V.clipFunc||V.clipWidth||V.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),V}const H="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";l.stages=[];class W extends t.Container{constructor(B){super(J(B)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),l.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{J(this.attrs)}),this._checkVisibility()}_validateAdd(B){const Y=B.getType()==="Layer",re=B.getType()==="FastLayer";Y||re||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const B=this.visible()?"":"none";this.content.style.display=B}setContainer(B){if(typeof B===p){if(B.charAt(0)==="."){var Y=B.slice(1);B=document.getElementsByClassName(Y)[0]}else{var re;B.charAt(0)!=="#"?re=B:re=B.slice(1),B=document.getElementById(re)}if(!B)throw"Can not find container in document with id "+re}return this._setAttr("container",B),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),B.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var B=this.children,Y=B.length,re;for(re=0;re<Y;re++)B[re].clear();return this}clone(B){return B||(B={}),B.container=typeof document<"u"&&document.createElement("div"),t.Container.prototype.clone.call(this,B)}destroy(){super.destroy();var B=this.content;B&&e.Util._isInDocument(B)&&this.container().removeChild(B);var Y=l.stages.indexOf(this);return Y>-1&&l.stages.splice(Y,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const B=this._pointerPositions[0]||this._changedPointerPositions[0];return B?{x:B.x,y:B.y}:(e.Util.warn(H),null)}_getPointerById(B){return this._pointerPositions.find(Y=>Y.id===B)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(B){B=B||{},B.x=B.x||0,B.y=B.y||0,B.width=B.width||this.width(),B.height=B.height||this.height();var Y=new o.SceneCanvas({width:B.width,height:B.height,pixelRatio:B.pixelRatio||1}),re=Y.getContext()._context,le=this.children;return(B.x||B.y)&&re.translate(-1*B.x,-1*B.y),le.forEach(function(fe){if(fe.isVisible()){var de=fe._toKonvaCanvas(B);re.drawImage(de._canvas,B.x,B.y,de.getWidth()/de.getPixelRatio(),de.getHeight()/de.getPixelRatio())}}),Y}getIntersection(B){if(!B)return null;var Y=this.children,re=Y.length,le=re-1,fe;for(fe=le;fe>=0;fe--){const de=Y[fe].getIntersection(B);if(de)return de}return null}_resizeDOM(){var B=this.width(),Y=this.height();this.content&&(this.content.style.width=B+E,this.content.style.height=Y+E),this.bufferCanvas.setSize(B,Y),this.bufferHitCanvas.setSize(B,Y),this.children.forEach(re=>{re.setSize({width:B,height:Y}),re.draw()})}add(B,...Y){if(arguments.length>1){for(var re=0;re<arguments.length;re++)this.add(arguments[re]);return this}super.add(B);var le=this.children.length;return le>ee&&e.Util.warn("The stage has "+le+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),B.setSize({width:this.width(),height:this.height()}),B.draw(),a.Konva.isBrowser&&this.content.appendChild(B.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(B){return f.hasPointerCapture(B,this)}setPointerCapture(B){f.setPointerCapture(B,this)}releaseCapture(B){f.releaseCapture(B,this)}getLayers(){return this.children}_bindContentEvents(){a.Konva.isBrowser&&K.forEach(([B,Y])=>{this.content.addEventListener(B,re=>{this[Y](re)},{passive:!1})})}_pointerenter(B){this.setPointersPositions(B);const Y=pe(B.type);Y&&this._fire(Y.pointerenter,{evt:B,target:this,currentTarget:this})}_pointerover(B){this.setPointersPositions(B);const Y=pe(B.type);Y&&this._fire(Y.pointerover,{evt:B,target:this,currentTarget:this})}_getTargetShape(B){let Y=this[B+"targetShape"];return Y&&!Y.getStage()&&(Y=null),Y}_pointerleave(B){const Y=pe(B.type),re=ue(B.type);if(Y){this.setPointersPositions(B);var le=this._getTargetShape(re),fe=!d.DD.isDragging||a.Konva.hitOnDragEnabled;le&&fe?(le._fireAndBubble(Y.pointerout,{evt:B}),le._fireAndBubble(Y.pointerleave,{evt:B}),this._fire(Y.pointerleave,{evt:B,target:this,currentTarget:this}),this[re+"targetShape"]=null):fe&&(this._fire(Y.pointerleave,{evt:B,target:this,currentTarget:this}),this._fire(Y.pointerout,{evt:B,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(B){const Y=pe(B.type),re=ue(B.type);if(Y){this.setPointersPositions(B);var le=!1;this._changedPointerPositions.forEach(fe=>{var de=this.getIntersection(fe);if(d.DD.justDragged=!1,a.Konva["_"+re+"ListenClick"]=!0,!de||!de.isListening())return;a.Konva.capturePointerEventsEnabled&&de.setPointerCapture(fe.id),this[re+"ClickStartShape"]=de,de._fireAndBubble(Y.pointerdown,{evt:B,pointerId:fe.id}),le=!0;const ge=B.type.indexOf("touch")>=0;de.preventDefault()&&B.cancelable&&ge&&B.preventDefault()}),le||this._fire(Y.pointerdown,{evt:B,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(B){const Y=pe(B.type),re=ue(B.type);if(!Y)return;d.DD.isDragging&&d.DD.node.preventDefault()&&B.cancelable&&B.preventDefault(),this.setPointersPositions(B);var le=!d.DD.isDragging||a.Konva.hitOnDragEnabled;if(!le)return;var fe={};let de=!1;var ge=this._getTargetShape(re);this._changedPointerPositions.forEach(Ee=>{const Re=f.getCapturedShape(Ee.id)||this.getIntersection(Ee),Oe=Ee.id,Ne={evt:B,pointerId:Oe};var Xe=ge!==Re;if(Xe&&ge&&(ge._fireAndBubble(Y.pointerout,{...Ne},Re),ge._fireAndBubble(Y.pointerleave,{...Ne},Re)),Re){if(fe[Re._id])return;fe[Re._id]=!0}Re&&Re.isListening()?(de=!0,Xe&&(Re._fireAndBubble(Y.pointerover,{...Ne},ge),Re._fireAndBubble(Y.pointerenter,{...Ne},ge),this[re+"targetShape"]=Re),Re._fireAndBubble(Y.pointermove,{...Ne})):ge&&(this._fire(Y.pointerover,{evt:B,target:this,currentTarget:this,pointerId:Oe}),this[re+"targetShape"]=null)}),de||this._fire(Y.pointermove,{evt:B,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(B){const Y=pe(B.type),re=ue(B.type);if(!Y)return;this.setPointersPositions(B);const le=this[re+"ClickStartShape"],fe=this[re+"ClickEndShape"];var de={};let ge=!1;this._changedPointerPositions.forEach(Ee=>{const Re=f.getCapturedShape(Ee.id)||this.getIntersection(Ee);if(Re){if(Re.releaseCapture(Ee.id),de[Re._id])return;de[Re._id]=!0}const Oe=Ee.id,Ne={evt:B,pointerId:Oe};let Xe=!1;a.Konva["_"+re+"InDblClickWindow"]?(Xe=!0,clearTimeout(this[re+"DblTimeout"])):d.DD.justDragged||(a.Konva["_"+re+"InDblClickWindow"]=!0,clearTimeout(this[re+"DblTimeout"])),this[re+"DblTimeout"]=setTimeout(function(){a.Konva["_"+re+"InDblClickWindow"]=!1},a.Konva.dblClickWindow),Re&&Re.isListening()?(ge=!0,this[re+"ClickEndShape"]=Re,Re._fireAndBubble(Y.pointerup,{...Ne}),a.Konva["_"+re+"ListenClick"]&&le&&le===Re&&(Re._fireAndBubble(Y.pointerclick,{...Ne}),Xe&&fe&&fe===Re&&Re._fireAndBubble(Y.pointerdblclick,{...Ne}))):(this[re+"ClickEndShape"]=null,a.Konva["_"+re+"ListenClick"]&&this._fire(Y.pointerclick,{evt:B,target:this,currentTarget:this,pointerId:Oe}),Xe&&this._fire(Y.pointerdblclick,{evt:B,target:this,currentTarget:this,pointerId:Oe}))}),ge||this._fire(Y.pointerup,{evt:B,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a.Konva["_"+re+"ListenClick"]=!1,B.cancelable&&re!=="touch"&&B.preventDefault()}_contextmenu(B){this.setPointersPositions(B);var Y=this.getIntersection(this.getPointerPosition());Y&&Y.isListening()?Y._fireAndBubble(I,{evt:B}):this._fire(I,{evt:B,target:this,currentTarget:this})}_wheel(B){this.setPointersPositions(B);var Y=this.getIntersection(this.getPointerPosition());Y&&Y.isListening()?Y._fireAndBubble(ae,{evt:B}):this._fire(ae,{evt:B,target:this,currentTarget:this})}_pointercancel(B){this.setPointersPositions(B);const Y=f.getCapturedShape(B.pointerId)||this.getIntersection(this.getPointerPosition());Y&&Y._fireAndBubble(C,f.createEvent(B)),f.releaseCapture(B.pointerId)}_lostpointercapture(B){f.releaseCapture(B.pointerId)}setPointersPositions(B){var Y=this._getContentPosition(),re=null,le=null;B=B||window.event,B.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(B.touches,fe=>{this._pointerPositions.push({id:fe.identifier,x:(fe.clientX-Y.left)/Y.scaleX,y:(fe.clientY-Y.top)/Y.scaleY})}),Array.prototype.forEach.call(B.changedTouches||B.touches,fe=>{this._changedPointerPositions.push({id:fe.identifier,x:(fe.clientX-Y.left)/Y.scaleX,y:(fe.clientY-Y.top)/Y.scaleY})})):(re=(B.clientX-Y.left)/Y.scaleX,le=(B.clientY-Y.top)/Y.scaleY,this.pointerPos={x:re,y:le},this._pointerPositions=[{x:re,y:le,id:e.Util._getFirstPointerId(B)}],this._changedPointerPositions=[{x:re,y:le,id:e.Util._getFirstPointerId(B)}])}_setPointerPosition(B){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(B)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var B=this.content.getBoundingClientRect();return{top:B.top,left:B.left,scaleX:B.width/this.content.clientWidth||1,scaleY:B.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new o.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new o.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!!a.Konva.isBrowser){var B=this.container();if(!B)throw"Stage has no container. A container is required.";B.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),B.appendChild(this.content),this._resizeDOM()}}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(B){B.batchDraw()}),this}}l.Stage=W,W.prototype.nodeType=u,(0,h._registerNode)(W),n.Factory.addGetterSetter(W,"container")})(Stage$1);var Layer$2={},Shape={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Shape=l.shapes=void 0;const e=Global,n=Util,t=Factory,a=Node$1,o=Validators,d=Global,h=PointerEvents;var f="hasShadow",u="shadowRGBA",p="patternImage",E="linearGradient",T="radialGradient";let v;function S(){return v||(v=n.Util.createCanvasElement().getContext("2d"),v)}l.shapes={};function g(k){const F=this.attrs.fillRule;F?k.fill(F):k.fill()}function y(k){k.stroke()}function b(k){k.fill()}function R(k){k.stroke()}function _(){this._clearCache(f)}function w(){this._clearCache(u)}function C(){this._clearCache(p)}function N(){this._clearCache(E)}function P(){this._clearCache(T)}class D extends a.Node{constructor(F){super(F);let M;for(;M=n.Util.getRandomColor(),!(M&&!(M in l.shapes)););this.colorKey=M,l.shapes[M]=this}getContext(){return n.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return n.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(f,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(p,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var F=S();const M=F.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(M&&M.setTransform){const I=new n.Transform;I.translate(this.fillPatternX(),this.fillPatternY()),I.rotate(e.Konva.getAngle(this.fillPatternRotation())),I.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),I.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const $=I.getMatrix(),z=typeof DOMMatrix>"u"?{a:$[0],b:$[1],c:$[2],d:$[3],e:$[4],f:$[5]}:new DOMMatrix($);M.setTransform(z)}return M}}_getLinearGradient(){return this._getCache(E,this.__getLinearGradient)}__getLinearGradient(){var F=this.fillLinearGradientColorStops();if(F){for(var M=S(),I=this.fillLinearGradientStartPoint(),$=this.fillLinearGradientEndPoint(),z=M.createLinearGradient(I.x,I.y,$.x,$.y),X=0;X<F.length;X+=2)z.addColorStop(F[X],F[X+1]);return z}}_getRadialGradient(){return this._getCache(T,this.__getRadialGradient)}__getRadialGradient(){var F=this.fillRadialGradientColorStops();if(F){for(var M=S(),I=this.fillRadialGradientStartPoint(),$=this.fillRadialGradientEndPoint(),z=M.createRadialGradient(I.x,I.y,this.fillRadialGradientStartRadius(),$.x,$.y,this.fillRadialGradientEndRadius()),X=0;X<F.length;X+=2)z.addColorStop(F[X],F[X+1]);return z}}getShadowRGBA(){return this._getCache(u,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var F=n.Util.colorToRGBA(this.shadowColor());if(F)return"rgba("+F.r+","+F.g+","+F.b+","+F.a*(this.shadowOpacity()||1)+")"}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const F=this.hitStrokeWidth();return F==="auto"?this.hasStroke():this.strokeEnabled()&&!!F}intersects(F){var M=this.getStage();if(!M)return!1;const I=M.bufferHitCanvas;return I.getContext().clear(),this.drawHit(I,void 0,!0),I.context.getImageData(Math.round(F.x),Math.round(F.y),1,1).data[3]>0}destroy(){return a.Node.prototype.destroy.call(this),delete l.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(F){var M;if(!this.getStage()||!((M=this.attrs.perfectDrawEnabled)!==null&&M!==void 0?M:!0))return!1;const $=F||this.hasFill(),z=this.hasStroke(),X=this.getAbsoluteOpacity()!==1;if($&&z&&X)return!0;const te=this.hasShadow(),ae=this.shadowForStrokeEnabled();return!!($&&z&&te&&ae)}setStrokeHitEnabled(F){n.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),F?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){var F=this.size();return{x:this._centroid?-F.width/2:0,y:this._centroid?-F.height/2:0,width:F.width,height:F.height}}getClientRect(F={}){const M=F.skipTransform,I=F.relativeTo,$=this.getSelfRect(),X=!F.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,te=$.width+X,ae=$.height+X,ee=!F.skipShadow&&this.hasShadow(),K=ee?this.shadowOffsetX():0,ne=ee?this.shadowOffsetY():0,ue=te+Math.abs(K),pe=ae+Math.abs(ne),J=ee&&this.shadowBlur()||0,H=ue+J*2,W=pe+J*2,V={width:H,height:W,x:-(X/2+J)+Math.min(K,0)+$.x,y:-(X/2+J)+Math.min(ne,0)+$.y};return M?V:this._transformedRect(V,I)}drawScene(F,M){var I=this.getLayer(),$=F||I.getCanvas(),z=$.getContext(),X=this._getCanvasCache(),te=this.getSceneFunc(),ae=this.hasShadow(),ee,K,ne,ue=$.isCache,pe=M===this;if(!this.isVisible()&&!pe)return this;if(X){z.save();var J=this.getAbsoluteTransform(M).getMatrix();return z.transform(J[0],J[1],J[2],J[3],J[4],J[5]),this._drawCachedSceneCanvas(z),z.restore(),this}if(!te)return this;if(z.save(),this._useBufferCanvas()&&!ue){ee=this.getStage(),K=ee.bufferCanvas,ne=K.getContext(),ne.clear(),ne.save(),ne._applyLineJoin(this);var H=this.getAbsoluteTransform(M).getMatrix();ne.transform(H[0],H[1],H[2],H[3],H[4],H[5]),te.call(this,ne,this),ne.restore();var W=K.pixelRatio;ae&&z._applyShadow(this),z._applyOpacity(this),z._applyGlobalCompositeOperation(this),z.drawImage(K._canvas,0,0,K.width/W,K.height/W)}else{if(z._applyLineJoin(this),!pe){var H=this.getAbsoluteTransform(M).getMatrix();z.transform(H[0],H[1],H[2],H[3],H[4],H[5]),z._applyOpacity(this),z._applyGlobalCompositeOperation(this)}ae&&z._applyShadow(this),te.call(this,z,this)}return z.restore(),this}drawHit(F,M,I=!1){if(!this.shouldDrawHit(M,I))return this;var $=this.getLayer(),z=F||$.hitCanvas,X=z&&z.getContext(),te=this.hitFunc()||this.sceneFunc(),ae=this._getCanvasCache(),ee=ae&&ae.hit;if(this.colorKey||n.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),ee){X.save();var K=this.getAbsoluteTransform(M).getMatrix();return X.transform(K[0],K[1],K[2],K[3],K[4],K[5]),this._drawCachedHitCanvas(X),X.restore(),this}if(!te)return this;if(X.save(),X._applyLineJoin(this),!(this===M)){var ue=this.getAbsoluteTransform(M).getMatrix();X.transform(ue[0],ue[1],ue[2],ue[3],ue[4],ue[5])}return te.call(this,X,this),X.restore(),this}drawHitFromCache(F=0){var M=this._getCanvasCache(),I=this._getCachedSceneCanvas(),$=M.hit,z=$.getContext(),X=$.getWidth(),te=$.getHeight(),ae,ee,K,ne,ue,pe;z.clear(),z.drawImage(I._canvas,0,0,X,te);try{for(ae=z.getImageData(0,0,X,te),ee=ae.data,K=ee.length,ne=n.Util._hexToRgb(this.colorKey),ue=0;ue<K;ue+=4)pe=ee[ue+3],pe>F?(ee[ue]=ne.r,ee[ue+1]=ne.g,ee[ue+2]=ne.b,ee[ue+3]=255):ee[ue+3]=0;z.putImageData(ae,0,0)}catch(J){n.Util.error("Unable to draw hit graph from cached scene canvas. "+J.message)}return this}hasPointerCapture(F){return h.hasPointerCapture(F,this)}setPointerCapture(F){h.setPointerCapture(F,this)}releaseCapture(F){h.releaseCapture(F,this)}}l.Shape=D,D.prototype._fillFunc=g,D.prototype._strokeFunc=y,D.prototype._fillFuncHit=b,D.prototype._strokeFuncHit=R,D.prototype._centroid=!1,D.prototype.nodeType="Shape",(0,d._registerNode)(D),D.prototype.eventListeners={},D.prototype.on.call(D.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",_),D.prototype.on.call(D.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",w),D.prototype.on.call(D.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",C),D.prototype.on.call(D.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",N),D.prototype.on.call(D.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",P),t.Factory.addGetterSetter(D,"stroke",void 0,(0,o.getStringOrGradientValidator)()),t.Factory.addGetterSetter(D,"strokeWidth",2,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(D,"fillAfterStrokeEnabled",!1),t.Factory.addGetterSetter(D,"hitStrokeWidth","auto",(0,o.getNumberOrAutoValidator)()),t.Factory.addGetterSetter(D,"strokeHitEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(D,"perfectDrawEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(D,"shadowForStrokeEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(D,"lineJoin"),t.Factory.addGetterSetter(D,"lineCap"),t.Factory.addGetterSetter(D,"sceneFunc"),t.Factory.addGetterSetter(D,"hitFunc"),t.Factory.addGetterSetter(D,"dash"),t.Factory.addGetterSetter(D,"dashOffset",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(D,"shadowColor",void 0,(0,o.getStringValidator)()),t.Factory.addGetterSetter(D,"shadowBlur",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(D,"shadowOpacity",1,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(D,"shadowOffset",["x","y"]),t.Factory.addGetterSetter(D,"shadowOffsetX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(D,"shadowOffsetY",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(D,"fillPatternImage"),t.Factory.addGetterSetter(D,"fill",void 0,(0,o.getStringOrGradientValidator)()),t.Factory.addGetterSetter(D,"fillPatternX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(D,"fillPatternY",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(D,"fillLinearGradientColorStops"),t.Factory.addGetterSetter(D,"strokeLinearGradientColorStops"),t.Factory.addGetterSetter(D,"fillRadialGradientStartRadius",0),t.Factory.addGetterSetter(D,"fillRadialGradientEndRadius",0),t.Factory.addGetterSetter(D,"fillRadialGradientColorStops"),t.Factory.addGetterSetter(D,"fillPatternRepeat","repeat"),t.Factory.addGetterSetter(D,"fillEnabled",!0),t.Factory.addGetterSetter(D,"strokeEnabled",!0),t.Factory.addGetterSetter(D,"shadowEnabled",!0),t.Factory.addGetterSetter(D,"dashEnabled",!0),t.Factory.addGetterSetter(D,"strokeScaleEnabled",!0),t.Factory.addGetterSetter(D,"fillPriority","color"),t.Factory.addComponentsGetterSetter(D,"fillPatternOffset",["x","y"]),t.Factory.addGetterSetter(D,"fillPatternOffsetX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(D,"fillPatternOffsetY",0,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(D,"fillPatternScale",["x","y"]),t.Factory.addGetterSetter(D,"fillPatternScaleX",1,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(D,"fillPatternScaleY",1,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(D,"fillLinearGradientStartPoint",["x","y"]),t.Factory.addComponentsGetterSetter(D,"strokeLinearGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(D,"fillLinearGradientStartPointX",0),t.Factory.addGetterSetter(D,"strokeLinearGradientStartPointX",0),t.Factory.addGetterSetter(D,"fillLinearGradientStartPointY",0),t.Factory.addGetterSetter(D,"strokeLinearGradientStartPointY",0),t.Factory.addComponentsGetterSetter(D,"fillLinearGradientEndPoint",["x","y"]),t.Factory.addComponentsGetterSetter(D,"strokeLinearGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(D,"fillLinearGradientEndPointX",0),t.Factory.addGetterSetter(D,"strokeLinearGradientEndPointX",0),t.Factory.addGetterSetter(D,"fillLinearGradientEndPointY",0),t.Factory.addGetterSetter(D,"strokeLinearGradientEndPointY",0),t.Factory.addComponentsGetterSetter(D,"fillRadialGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(D,"fillRadialGradientStartPointX",0),t.Factory.addGetterSetter(D,"fillRadialGradientStartPointY",0),t.Factory.addComponentsGetterSetter(D,"fillRadialGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(D,"fillRadialGradientEndPointX",0),t.Factory.addGetterSetter(D,"fillRadialGradientEndPointY",0),t.Factory.addGetterSetter(D,"fillPatternRotation",0),t.Factory.addGetterSetter(D,"fillRule",void 0,(0,o.getStringValidator)()),t.Factory.backCompat(D,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})})(Shape);Object.defineProperty(Layer$2,"__esModule",{value:!0});Layer$2.Layer=void 0;const Util_1$b=Util,Container_1$1=Container$2,Node_1$g=Node$1,Factory_1$w=Factory,Canvas_1=Canvas$1,Validators_1$v=Validators,Shape_1$g=Shape,Global_1$k=Global;var HASH="#",BEFORE_DRAW="beforeDraw",DRAW="draw",INTERSECTION_OFFSETS=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],INTERSECTION_OFFSETS_LEN=INTERSECTION_OFFSETS.length;let Layer$1=class extends Container_1$1.Container{constructor(e){super(e),this.canvas=new Canvas_1.SceneCanvas,this.hitCanvas=new Canvas_1.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);var n=this.getStage();return n&&n.content&&(n.content.removeChild(this.getNativeCanvasElement()),e<n.children.length-1?n.content.insertBefore(this.getNativeCanvasElement(),n.children[e+1].getCanvas()._canvas):n.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Node_1$g.Node.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){var e=Node_1$g.Node.prototype.moveUp.call(this);if(!e)return!1;var n=this.getStage();return!n||!n.content?!1:(n.content.removeChild(this.getNativeCanvasElement()),this.index<n.children.length-1?n.content.insertBefore(this.getNativeCanvasElement(),n.children[this.index+1].getCanvas()._canvas):n.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Node_1$g.Node.prototype.moveDown.call(this)){var e=this.getStage();if(e){var n=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),n[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Node_1$g.Node.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var n=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),n[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var e=this.getNativeCanvasElement();return Node_1$g.Node.prototype.remove.call(this),e&&e.parentNode&&Util_1$b.Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:n}){return this.canvas.setSize(e,n),this.hitCanvas.setSize(e,n),this._setSmoothEnabled(),this}_validateAdd(e){var n=e.getType();n!=="Group"&&n!=="Shape"&&Util_1$b.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e=e||{},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),Node_1$g.Node.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Util_1$b.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Util_1$b.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Util_1$b.Util.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var n=1,t=!1;;){for(let a=0;a<INTERSECTION_OFFSETS_LEN;a++){const o=INTERSECTION_OFFSETS[a],d=this._getIntersection({x:e.x+o.x*n,y:e.y+o.y*n}),h=d.shape;if(h)return h;if(t=!!d.antialiased,!d.antialiased)break}if(t)n+=1;else return null}}_getIntersection(e){const n=this.hitCanvas.pixelRatio,t=this.hitCanvas.context.getImageData(Math.round(e.x*n),Math.round(e.y*n),1,1).data,a=t[3];if(a===255){const o=Util_1$b.Util._rgbToHex(t[0],t[1],t[2]),d=Shape_1$g.shapes[HASH+o];return d?{shape:d}:{antialiased:!0}}else if(a>0)return{antialiased:!0};return{}}drawScene(e,n){var t=this.getLayer(),a=e||t&&t.getCanvas();return this._fire(BEFORE_DRAW,{node:this}),this.clearBeforeDraw()&&a.getContext().clear(),Container_1$1.Container.prototype.drawScene.call(this,a,n),this._fire(DRAW,{node:this}),this}drawHit(e,n){var t=this.getLayer(),a=e||t&&t.hitCanvas;return t&&t.clearBeforeDraw()&&t.getHitCanvas().getContext().clear(),Container_1$1.Container.prototype.drawHit.call(this,a,n),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){Util_1$b.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return Util_1$b.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!(!this.parent||!this.parent.content)){var e=this.parent,n=!!this.hitCanvas._canvas.parentNode;n?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return Util_1$b.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Layer$2.Layer=Layer$1;Layer$1.prototype.nodeType="Layer";(0,Global_1$k._registerNode)(Layer$1);Factory_1$w.Factory.addGetterSetter(Layer$1,"imageSmoothingEnabled",!0);Factory_1$w.Factory.addGetterSetter(Layer$1,"clearBeforeDraw",!0);Factory_1$w.Factory.addGetterSetter(Layer$1,"hitGraphEnabled",!0,(0,Validators_1$v.getBooleanValidator)());var FastLayer$1={};Object.defineProperty(FastLayer$1,"__esModule",{value:!0});FastLayer$1.FastLayer=void 0;const Util_1$a=Util,Layer_1=Layer$2,Global_1$j=Global;class FastLayer extends Layer_1.Layer{constructor(e){super(e),this.listening(!1),Util_1$a.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}FastLayer$1.FastLayer=FastLayer;FastLayer.prototype.nodeType="FastLayer";(0,Global_1$j._registerNode)(FastLayer);var Group$2={};Object.defineProperty(Group$2,"__esModule",{value:!0});Group$2.Group=void 0;const Util_1$9=Util,Container_1=Container$2,Global_1$i=Global;let Group$1=class extends Container_1.Container{_validateAdd(e){var n=e.getType();n!=="Group"&&n!=="Shape"&&Util_1$9.Util.throw("You may only add groups and shapes to groups.")}};Group$2.Group=Group$1;Group$1.prototype.nodeType="Group";(0,Global_1$i._registerNode)(Group$1);var Animation$3={};Object.defineProperty(Animation$3,"__esModule",{value:!0});Animation$3.Animation=void 0;const Global_1$h=Global,Util_1$8=Util,now=function(){return Global_1$h.glob.performance&&Global_1$h.glob.performance.now?function(){return Global_1$h.glob.performance.now()}:function(){return new Date().getTime()}}();let Animation$2=class au{constructor(e,n){this.id=au.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:now(),frameRate:0},this.func=e,this.setLayers(n)}setLayers(e){let n=[];return e&&(n=Array.isArray(e)?e:[e]),this.layers=n,this}getLayers(){return this.layers}addLayer(e){const n=this.layers,t=n.length;for(let a=0;a<t;a++)if(n[a]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){const n=au.animations,t=n.length;for(let a=0;a<t;a++)if(n[a].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=now(),au._addAnimation(this),this}stop(){return au._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){const n=e.id,t=this.animations,a=t.length;for(let o=0;o<a;o++)if(t[o].id===n){this.animations.splice(o,1);break}}static _runFrames(){const e={},n=this.animations;for(let t=0;t<n.length;t++){const a=n[t],o=a.layers,d=a.func;a._updateFrameObject(now());const h=o.length;let f;if(d?f=d.call(a,a.frame)!==!1:f=!0,!!f)for(let u=0;u<h;u++){const p=o[u];p._id!==void 0&&(e[p._id]=p)}}for(let t in e)e.hasOwnProperty(t)&&e[t].batchDraw()}static _animationLoop(){const e=au;e.animations.length?(e._runFrames(),Util_1$8.Util.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Util_1$8.Util.requestAnimFrame(this._animationLoop))}};Animation$3.Animation=Animation$2;Animation$2.animations=[];Animation$2.animIdCounter=0;Animation$2.animRunning=!1;var Tween$1={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Easings=l.Tween=void 0;const e=Util,n=Animation$3,t=Node$1,a=Global;var o={node:1,duration:1,easing:1,onFinish:1,yoyo:1},d=1,h=2,f=3,u=0,p=["fill","stroke","shadowColor"];class E{constructor(S,g,y,b,R,_,w){this.prop=S,this.propFunc=g,this.begin=b,this._pos=b,this.duration=_,this._change=0,this.prevPos=0,this.yoyo=w,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=y,this._change=R-this.begin,this.pause()}fire(S){var g=this[S];g&&g()}setTime(S){S>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():S<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=S,this.update())}getTime(){return this._time}setPosition(S){this.prevPos=this._pos,this.propFunc(S),this._pos=S}getPosition(S){return S===void 0&&(S=this._time),this.func(S,this.begin,this._change,this.duration)}play(){this.state=h,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=f,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(S){this.pause(),this._time=S,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var S=this.getTimer()-this._startTime;this.state===h?this.setTime(S):this.state===f&&this.setTime(this.duration-S)}pause(){this.state=d,this.fire("onPause")}getTimer(){return new Date().getTime()}}class T{constructor(S){var g=this,y=S.node,b=y._id,R,_=S.easing||l.Easings.Linear,w=!!S.yoyo,C;typeof S.duration>"u"?R=.3:S.duration===0?R=.001:R=S.duration,this.node=y,this._id=u++;var N=y.getLayer()||(y instanceof a.Konva.Stage?y.getLayers():null);N||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new n.Animation(function(){g.tween.onEnterFrame()},N),this.tween=new E(C,function(P){g._tweenFunc(P)},_,0,1,R*1e3,w),this._addListeners(),T.attrs[b]||(T.attrs[b]={}),T.attrs[b][this._id]||(T.attrs[b][this._id]={}),T.tweens[b]||(T.tweens[b]={});for(C in S)o[C]===void 0&&this._addAttr(C,S[C]);this.reset(),this.onFinish=S.onFinish,this.onReset=S.onReset,this.onUpdate=S.onUpdate}_addAttr(S,g){var y=this.node,b=y._id,R,_,w,C,N,P,D,k;if(w=T.tweens[b][S],w&&delete T.attrs[b][w][S],R=y.getAttr(S),e.Util._isArray(g))if(_=[],N=Math.max(g.length,R.length),S==="points"&&g.length!==R.length&&(g.length>R.length?(D=R,R=e.Util._prepareArrayForTween(R,g,y.closed())):(P=g,g=e.Util._prepareArrayForTween(g,R,y.closed()))),S.indexOf("fill")===0)for(C=0;C<N;C++)if(C%2===0)_.push(g[C]-R[C]);else{var F=e.Util.colorToRGBA(R[C]);k=e.Util.colorToRGBA(g[C]),R[C]=F,_.push({r:k.r-F.r,g:k.g-F.g,b:k.b-F.b,a:k.a-F.a})}else for(C=0;C<N;C++)_.push(g[C]-R[C]);else p.indexOf(S)!==-1?(R=e.Util.colorToRGBA(R),k=e.Util.colorToRGBA(g),_={r:k.r-R.r,g:k.g-R.g,b:k.b-R.b,a:k.a-R.a}):_=g-R;T.attrs[b][this._id][S]={start:R,diff:_,end:g,trueEnd:P,trueStart:D},T.tweens[b][S]=this._id}_tweenFunc(S){var g=this.node,y=T.attrs[g._id][this._id],b,R,_,w,C,N,P,D;for(b in y){if(R=y[b],_=R.start,w=R.diff,D=R.end,e.Util._isArray(_))if(C=[],P=Math.max(_.length,D.length),b.indexOf("fill")===0)for(N=0;N<P;N++)N%2===0?C.push((_[N]||0)+w[N]*S):C.push("rgba("+Math.round(_[N].r+w[N].r*S)+","+Math.round(_[N].g+w[N].g*S)+","+Math.round(_[N].b+w[N].b*S)+","+(_[N].a+w[N].a*S)+")");else for(N=0;N<P;N++)C.push((_[N]||0)+w[N]*S);else p.indexOf(b)!==-1?C="rgba("+Math.round(_.r+w.r*S)+","+Math.round(_.g+w.g*S)+","+Math.round(_.b+w.b*S)+","+(_.a+w.a*S)+")":C=_+w*S;g.setAttr(b,C)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var S=this.node,g=T.attrs[S._id][this._id];g.points&&g.points.trueEnd&&S.setAttr("points",g.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var S=this.node,g=T.attrs[S._id][this._id];g.points&&g.points.trueStart&&S.points(g.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(S){return this.tween.seek(S*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var S=this.node._id,g=this._id,y=T.tweens[S],b;this.pause();for(b in y)delete T.tweens[S][b];delete T.attrs[S][g]}}l.Tween=T,T.attrs={},T.tweens={},t.Node.prototype.to=function(v){var S=v.onFinish;v.node=this,v.onFinish=function(){this.destroy(),S&&S()};var g=new T(v);g.play()},l.Easings={BackEaseIn(v,S,g,y){var b=1.70158;return g*(v/=y)*v*((b+1)*v-b)+S},BackEaseOut(v,S,g,y){var b=1.70158;return g*((v=v/y-1)*v*((b+1)*v+b)+1)+S},BackEaseInOut(v,S,g,y){var b=1.70158;return(v/=y/2)<1?g/2*(v*v*(((b*=1.525)+1)*v-b))+S:g/2*((v-=2)*v*(((b*=1.525)+1)*v+b)+2)+S},ElasticEaseIn(v,S,g,y,b,R){var _=0;return v===0?S:(v/=y)===1?S+g:(R||(R=y*.3),!b||b<Math.abs(g)?(b=g,_=R/4):_=R/(2*Math.PI)*Math.asin(g/b),-(b*Math.pow(2,10*(v-=1))*Math.sin((v*y-_)*(2*Math.PI)/R))+S)},ElasticEaseOut(v,S,g,y,b,R){var _=0;return v===0?S:(v/=y)===1?S+g:(R||(R=y*.3),!b||b<Math.abs(g)?(b=g,_=R/4):_=R/(2*Math.PI)*Math.asin(g/b),b*Math.pow(2,-10*v)*Math.sin((v*y-_)*(2*Math.PI)/R)+g+S)},ElasticEaseInOut(v,S,g,y,b,R){var _=0;return v===0?S:(v/=y/2)===2?S+g:(R||(R=y*(.3*1.5)),!b||b<Math.abs(g)?(b=g,_=R/4):_=R/(2*Math.PI)*Math.asin(g/b),v<1?-.5*(b*Math.pow(2,10*(v-=1))*Math.sin((v*y-_)*(2*Math.PI)/R))+S:b*Math.pow(2,-10*(v-=1))*Math.sin((v*y-_)*(2*Math.PI)/R)*.5+g+S)},BounceEaseOut(v,S,g,y){return(v/=y)<1/2.75?g*(7.5625*v*v)+S:v<2/2.75?g*(7.5625*(v-=1.5/2.75)*v+.75)+S:v<2.5/2.75?g*(7.5625*(v-=2.25/2.75)*v+.9375)+S:g*(7.5625*(v-=2.625/2.75)*v+.984375)+S},BounceEaseIn(v,S,g,y){return g-l.Easings.BounceEaseOut(y-v,0,g,y)+S},BounceEaseInOut(v,S,g,y){return v<y/2?l.Easings.BounceEaseIn(v*2,0,g,y)*.5+S:l.Easings.BounceEaseOut(v*2-y,0,g,y)*.5+g*.5+S},EaseIn(v,S,g,y){return g*(v/=y)*v+S},EaseOut(v,S,g,y){return-g*(v/=y)*(v-2)+S},EaseInOut(v,S,g,y){return(v/=y/2)<1?g/2*v*v+S:-g/2*(--v*(v-2)-1)+S},StrongEaseIn(v,S,g,y){return g*(v/=y)*v*v*v*v+S},StrongEaseOut(v,S,g,y){return g*((v=v/y-1)*v*v*v*v+1)+S},StrongEaseInOut(v,S,g,y){return(v/=y/2)<1?g/2*v*v*v*v*v+S:g/2*((v-=2)*v*v*v*v+2)+S},Linear(v,S,g,y){return g*v/y+S}}})(Tween$1);(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Konva=void 0;const e=Global,n=Util,t=Node$1,a=Container$2,o=Stage$1,d=Layer$2,h=FastLayer$1,f=Group$2,u=DragAndDrop,p=Shape,E=Animation$3,T=Tween$1,v=Context$2,S=Canvas$1;l.Konva=n.Util._assign(e.Konva,{Util:n.Util,Transform:n.Transform,Node:t.Node,Container:a.Container,Stage:o.Stage,stages:o.stages,Layer:d.Layer,FastLayer:h.FastLayer,Group:f.Group,DD:u.DD,Shape:p.Shape,shapes:p.shapes,Animation:E.Animation,Tween:T.Tween,Easings:T.Easings,Context:v.Context,Canvas:S.Canvas}),l.default=l.Konva})(_CoreInternals);var Arc$1={};Object.defineProperty(Arc$1,"__esModule",{value:!0});Arc$1.Arc=void 0;const Factory_1$v=Factory,Shape_1$f=Shape,Global_1$g=Global,Validators_1$u=Validators,Global_2$2=Global;class Arc extends Shape_1$f.Shape{_sceneFunc(e){var n=Global_1$g.Konva.getAngle(this.angle()),t=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,n,t),e.arc(0,0,this.innerRadius(),n,0,!t),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),n=this.outerRadius(),t=this.clockwise(),a=Global_1$g.Konva.getAngle(t?360-this.angle():this.angle()),o=Math.cos(Math.min(a,Math.PI)),d=1,h=Math.sin(Math.min(Math.max(Math.PI,a),3*Math.PI/2)),f=Math.sin(Math.min(a,Math.PI/2)),u=o*(o>0?e:n),p=d*n,E=h*(h>0?e:n),T=f*(f>0?n:e);return{x:u,y:t?-1*T:E,width:p-u,height:T-E}}}Arc$1.Arc=Arc;Arc.prototype._centroid=!0;Arc.prototype.className="Arc";Arc.prototype._attrsAffectingSize=["innerRadius","outerRadius"];(0,Global_2$2._registerNode)(Arc);Factory_1$v.Factory.addGetterSetter(Arc,"innerRadius",0,(0,Validators_1$u.getNumberValidator)());Factory_1$v.Factory.addGetterSetter(Arc,"outerRadius",0,(0,Validators_1$u.getNumberValidator)());Factory_1$v.Factory.addGetterSetter(Arc,"angle",0,(0,Validators_1$u.getNumberValidator)());Factory_1$v.Factory.addGetterSetter(Arc,"clockwise",!1,(0,Validators_1$u.getBooleanValidator)());var Arrow$1={},Line$2={};Object.defineProperty(Line$2,"__esModule",{value:!0});Line$2.Line=void 0;const Factory_1$u=Factory,Shape_1$e=Shape,Validators_1$t=Validators,Global_1$f=Global;function getControlPoints(l,e,n,t,a,o,d){var h=Math.sqrt(Math.pow(n-l,2)+Math.pow(t-e,2)),f=Math.sqrt(Math.pow(a-n,2)+Math.pow(o-t,2)),u=d*h/(h+f),p=d*f/(h+f),E=n-u*(a-l),T=t-u*(o-e),v=n+p*(a-l),S=t+p*(o-e);return[E,T,v,S]}function expandPoints(l,e){var n=l.length,t=[],a,o;for(a=2;a<n-2;a+=2)o=getControlPoints(l[a-2],l[a-1],l[a],l[a+1],l[a+2],l[a+3],e),!isNaN(o[0])&&(t.push(o[0]),t.push(o[1]),t.push(l[a]),t.push(l[a+1]),t.push(o[2]),t.push(o[3]));return t}let Line$1=class extends Shape_1$e.Shape{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){var n=this.points(),t=n.length,a=this.tension(),o=this.closed(),d=this.bezier(),h,f,u;if(t){if(e.beginPath(),e.moveTo(n[0],n[1]),a!==0&&t>4){for(h=this.getTensionPoints(),f=h.length,u=o?0:4,o||e.quadraticCurveTo(h[0],h[1],h[2],h[3]);u<f-2;)e.bezierCurveTo(h[u++],h[u++],h[u++],h[u++],h[u++],h[u++]);o||e.quadraticCurveTo(h[f-2],h[f-1],n[t-2],n[t-1])}else if(d)for(u=2;u<t;)e.bezierCurveTo(n[u++],n[u++],n[u++],n[u++],n[u++],n[u++]);else for(u=2;u<t;u+=2)e.lineTo(n[u],n[u+1]);o?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():expandPoints(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),n=e.length,t=this.tension(),a=getControlPoints(e[n-2],e[n-1],e[0],e[1],e[2],e[3],t),o=getControlPoints(e[n-4],e[n-3],e[n-2],e[n-1],e[0],e[1],t),d=expandPoints(e,t),h=[a[2],a[3]].concat(d).concat([o[0],o[1],e[n-2],e[n-1],o[2],o[3],a[0],a[1],e[0],e[1]]);return h}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:e=this.points();for(var n=e[0],t=e[0],a=e[1],o=e[1],d,h,f=0;f<e.length/2;f++)d=e[f*2],h=e[f*2+1],n=Math.min(n,d),t=Math.max(t,d),a=Math.min(a,h),o=Math.max(o,h);return{x:n,y:a,width:t-n,height:o-a}}};Line$2.Line=Line$1;Line$1.prototype.className="Line";Line$1.prototype._attrsAffectingSize=["points","bezier","tension"];(0,Global_1$f._registerNode)(Line$1);Factory_1$u.Factory.addGetterSetter(Line$1,"closed",!1);Factory_1$u.Factory.addGetterSetter(Line$1,"bezier",!1);Factory_1$u.Factory.addGetterSetter(Line$1,"tension",0,(0,Validators_1$t.getNumberValidator)());Factory_1$u.Factory.addGetterSetter(Line$1,"points",[],(0,Validators_1$t.getNumberArrayValidator)());var Path$1={},BezierFunctions={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.t2length=l.getQuadraticArcLength=l.getCubicArcLength=l.binomialCoefficients=l.cValues=l.tValues=void 0,l.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],l.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],l.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]];const e=(d,h,f)=>{let u,p,E;u=f/2,p=0;for(let v=0;v<20;v++)E=u*l.tValues[20][v]+u,p+=l.cValues[20][v]*t(d,h,E);return u*p};l.getCubicArcLength=e;const n=(d,h,f)=>{f===void 0&&(f=1);const u=d[0]-2*d[1]+d[2],p=h[0]-2*h[1]+h[2],E=2*d[1]-2*d[0],T=2*h[1]-2*h[0],v=4*(u*u+p*p),S=4*(u*E+p*T),g=E*E+T*T;if(v===0)return f*Math.sqrt(Math.pow(d[2]-d[0],2)+Math.pow(h[2]-h[0],2));const y=S/(2*v),b=g/v,R=f+y,_=b-y*y,w=R*R+_>0?Math.sqrt(R*R+_):0,C=y*y+_>0?Math.sqrt(y*y+_):0,N=y+Math.sqrt(y*y+_)!==0?_*Math.log(Math.abs((R+w)/(y+C))):0;return Math.sqrt(v)/2*(R*w-y*C+N)};l.getQuadraticArcLength=n;function t(d,h,f){const u=a(1,f,d),p=a(1,f,h),E=u*u+p*p;return Math.sqrt(E)}const a=(d,h,f)=>{const u=f.length-1;let p,E;if(u===0)return 0;if(d===0){E=0;for(let T=0;T<=u;T++)E+=l.binomialCoefficients[u][T]*Math.pow(1-h,u-T)*Math.pow(h,T)*f[T];return E}else{p=new Array(u);for(let T=0;T<u;T++)p[T]=u*(f[T+1]-f[T]);return a(d-1,h,p)}},o=(d,h,f)=>{let u=1,p=d/h,E=(d-f(p))/h,T=0;for(;u>.001;){const v=f(p+E),S=Math.abs(d-v)/h;if(S<u)u=S,p+=E;else{const g=f(p-E),y=Math.abs(d-g)/h;y<u?(u=y,p-=E):E/=2}if(T++,T>500)break}return p};l.t2length=o})(BezierFunctions);Object.defineProperty(Path$1,"__esModule",{value:!0});Path$1.Path=void 0;const Factory_1$t=Factory,Shape_1$d=Shape,Global_1$e=Global,BezierFunctions_1=BezierFunctions;class Path extends Shape_1$d.Shape{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Path.parsePathData(this.data()),this.pathLength=Path.getPathLength(this.dataArray)}_sceneFunc(e){var n=this.dataArray;e.beginPath();for(var t=!1,a=0;a<n.length;a++){var o=n[a].command,d=n[a].points;switch(o){case"L":e.lineTo(d[0],d[1]);break;case"M":e.moveTo(d[0],d[1]);break;case"C":e.bezierCurveTo(d[0],d[1],d[2],d[3],d[4],d[5]);break;case"Q":e.quadraticCurveTo(d[0],d[1],d[2],d[3]);break;case"A":var h=d[0],f=d[1],u=d[2],p=d[3],E=d[4],T=d[5],v=d[6],S=d[7],g=u>p?u:p,y=u>p?1:u/p,b=u>p?p/u:1;e.translate(h,f),e.rotate(v),e.scale(y,b),e.arc(0,0,g,E,E+T,1-S),e.scale(1/y,1/b),e.rotate(-v),e.translate(-h,-f);break;case"z":t=!0,e.closePath();break}}!t&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach(function(u){if(u.command==="A"){var p=u.points[4],E=u.points[5],T=u.points[4]+E,v=Math.PI/180;if(Math.abs(p-T)<v&&(v=Math.abs(p-T)),E<0)for(let S=p-v;S>T;S-=v){const g=Path.getPointOnEllipticalArc(u.points[0],u.points[1],u.points[2],u.points[3],S,0);e.push(g.x,g.y)}else for(let S=p+v;S<T;S+=v){const g=Path.getPointOnEllipticalArc(u.points[0],u.points[1],u.points[2],u.points[3],S,0);e.push(g.x,g.y)}}else if(u.command==="C")for(let S=0;S<=1;S+=.01){const g=Path.getPointOnCubicBezier(S,u.start.x,u.start.y,u.points[0],u.points[1],u.points[2],u.points[3],u.points[4],u.points[5]);e.push(g.x,g.y)}else e=e.concat(u.points)});for(var n=e[0],t=e[0],a=e[1],o=e[1],d,h,f=0;f<e.length/2;f++)d=e[f*2],h=e[f*2+1],isNaN(d)||(n=Math.min(n,d),t=Math.max(t,d)),isNaN(h)||(a=Math.min(a,h),o=Math.max(o,h));return{x:n,y:a,width:t-n,height:o-a}}getLength(){return this.pathLength}getPointAtLength(e){return Path.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(e,n,t,a){return Math.sqrt((t-e)*(t-e)+(a-n)*(a-n))}static getPathLength(e){let n=0;for(var t=0;t<e.length;++t)n+=e[t].pathLength;return n}static getPointAtLengthOfDataArray(e,n){var t,a=0,o=n.length;if(!o)return null;for(;a<o&&e>n[a].pathLength;)e-=n[a].pathLength,++a;if(a===o)return t=n[a-1].points.slice(-2),{x:t[0],y:t[1]};if(e<.01)return t=n[a].points.slice(0,2),{x:t[0],y:t[1]};var d=n[a],h=d.points;switch(d.command){case"L":return Path.getPointOnLine(e,d.start.x,d.start.y,h[0],h[1]);case"C":return Path.getPointOnCubicBezier((0,BezierFunctions_1.t2length)(e,Path.getPathLength(n),g=>(0,BezierFunctions_1.getCubicArcLength)([d.start.x,h[0],h[2],h[4]],[d.start.y,h[1],h[3],h[5]],g)),d.start.x,d.start.y,h[0],h[1],h[2],h[3],h[4],h[5]);case"Q":return Path.getPointOnQuadraticBezier((0,BezierFunctions_1.t2length)(e,Path.getPathLength(n),g=>(0,BezierFunctions_1.getQuadraticArcLength)([d.start.x,h[0],h[2]],[d.start.y,h[1],h[3]],g)),d.start.x,d.start.y,h[0],h[1],h[2],h[3]);case"A":var f=h[0],u=h[1],p=h[2],E=h[3],T=h[4],v=h[5],S=h[6];return T+=v*e/d.pathLength,Path.getPointOnEllipticalArc(f,u,p,E,T,S)}return null}static getPointOnLine(e,n,t,a,o,d,h){d===void 0&&(d=n),h===void 0&&(h=t);var f=(o-t)/(a-n+1e-8),u=Math.sqrt(e*e/(1+f*f));a<n&&(u*=-1);var p=f*u,E;if(a===n)E={x:d,y:h+p};else if((h-t)/(d-n+1e-8)===f)E={x:d+u,y:h+p};else{var T,v,S=this.getLineLength(n,t,a,o),g=(d-n)*(a-n)+(h-t)*(o-t);g=g/(S*S),T=n+g*(a-n),v=t+g*(o-t);var y=this.getLineLength(d,h,T,v),b=Math.sqrt(e*e-y*y);u=Math.sqrt(b*b/(1+f*f)),a<n&&(u*=-1),p=f*u,E={x:T+u,y:v+p}}return E}static getPointOnCubicBezier(e,n,t,a,o,d,h,f,u){function p(y){return y*y*y}function E(y){return 3*y*y*(1-y)}function T(y){return 3*y*(1-y)*(1-y)}function v(y){return(1-y)*(1-y)*(1-y)}var S=f*p(e)+d*E(e)+a*T(e)+n*v(e),g=u*p(e)+h*E(e)+o*T(e)+t*v(e);return{x:S,y:g}}static getPointOnQuadraticBezier(e,n,t,a,o,d,h){function f(v){return v*v}function u(v){return 2*v*(1-v)}function p(v){return(1-v)*(1-v)}var E=d*f(e)+a*u(e)+n*p(e),T=h*f(e)+o*u(e)+t*p(e);return{x:E,y:T}}static getPointOnEllipticalArc(e,n,t,a,o,d){var h=Math.cos(d),f=Math.sin(d),u={x:t*Math.cos(o),y:a*Math.sin(o)};return{x:e+(u.x*h-u.y*f),y:n+(u.x*f+u.y*h)}}static parsePathData(e){if(!e)return[];var n=e,t=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];n=n.replace(new RegExp(" ","g"),",");for(var a=0;a<t.length;a++)n=n.replace(new RegExp(t[a],"g"),"|"+t[a]);var o=n.split("|"),d=[],h=[],f=0,u=0,p=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,E;for(a=1;a<o.length;a++){var T=o[a],v=T.charAt(0);for(T=T.slice(1),h.length=0;E=p.exec(T);)h.push(E[0]);for(var S=[],g=0,y=h.length;g<y;g++){if(h[g]==="00"){S.push(0,0);continue}var b=parseFloat(h[g]);isNaN(b)?S.push(0):S.push(b)}for(;S.length>0&&!isNaN(S[0]);){var R="",_=[],w=f,C=u,N,P,D,k,F,M,I,$,z,X;switch(v){case"l":f+=S.shift(),u+=S.shift(),R="L",_.push(f,u);break;case"L":f=S.shift(),u=S.shift(),_.push(f,u);break;case"m":var te=S.shift(),ae=S.shift();if(f+=te,u+=ae,R="M",d.length>2&&d[d.length-1].command==="z"){for(var ee=d.length-2;ee>=0;ee--)if(d[ee].command==="M"){f=d[ee].points[0]+te,u=d[ee].points[1]+ae;break}}_.push(f,u),v="l";break;case"M":f=S.shift(),u=S.shift(),R="M",_.push(f,u),v="L";break;case"h":f+=S.shift(),R="L",_.push(f,u);break;case"H":f=S.shift(),R="L",_.push(f,u);break;case"v":u+=S.shift(),R="L",_.push(f,u);break;case"V":u=S.shift(),R="L",_.push(f,u);break;case"C":_.push(S.shift(),S.shift(),S.shift(),S.shift()),f=S.shift(),u=S.shift(),_.push(f,u);break;case"c":_.push(f+S.shift(),u+S.shift(),f+S.shift(),u+S.shift()),f+=S.shift(),u+=S.shift(),R="C",_.push(f,u);break;case"S":P=f,D=u,N=d[d.length-1],N.command==="C"&&(P=f+(f-N.points[2]),D=u+(u-N.points[3])),_.push(P,D,S.shift(),S.shift()),f=S.shift(),u=S.shift(),R="C",_.push(f,u);break;case"s":P=f,D=u,N=d[d.length-1],N.command==="C"&&(P=f+(f-N.points[2]),D=u+(u-N.points[3])),_.push(P,D,f+S.shift(),u+S.shift()),f+=S.shift(),u+=S.shift(),R="C",_.push(f,u);break;case"Q":_.push(S.shift(),S.shift()),f=S.shift(),u=S.shift(),_.push(f,u);break;case"q":_.push(f+S.shift(),u+S.shift()),f+=S.shift(),u+=S.shift(),R="Q",_.push(f,u);break;case"T":P=f,D=u,N=d[d.length-1],N.command==="Q"&&(P=f+(f-N.points[0]),D=u+(u-N.points[1])),f=S.shift(),u=S.shift(),R="Q",_.push(P,D,f,u);break;case"t":P=f,D=u,N=d[d.length-1],N.command==="Q"&&(P=f+(f-N.points[0]),D=u+(u-N.points[1])),f+=S.shift(),u+=S.shift(),R="Q",_.push(P,D,f,u);break;case"A":k=S.shift(),F=S.shift(),M=S.shift(),I=S.shift(),$=S.shift(),z=f,X=u,f=S.shift(),u=S.shift(),R="A",_=this.convertEndpointToCenterParameterization(z,X,f,u,I,$,k,F,M);break;case"a":k=S.shift(),F=S.shift(),M=S.shift(),I=S.shift(),$=S.shift(),z=f,X=u,f+=S.shift(),u+=S.shift(),R="A",_=this.convertEndpointToCenterParameterization(z,X,f,u,I,$,k,F,M);break}d.push({command:R||v,points:_,start:{x:w,y:C},pathLength:this.calcLength(w,C,R||v,_)})}(v==="z"||v==="Z")&&d.push({command:"z",points:[],start:void 0,pathLength:0})}return d}static calcLength(e,n,t,a){var o,d,h,f,u=Path;switch(t){case"L":return u.getLineLength(e,n,a[0],a[1]);case"C":return(0,BezierFunctions_1.getCubicArcLength)([e,a[0],a[2],a[4]],[n,a[1],a[3],a[5]],1);case"Q":return(0,BezierFunctions_1.getQuadraticArcLength)([e,a[0],a[2]],[n,a[1],a[3]],1);case"A":o=0;var p=a[4],E=a[5],T=a[4]+E,v=Math.PI/180;if(Math.abs(p-T)<v&&(v=Math.abs(p-T)),d=u.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],p,0),E<0)for(f=p-v;f>T;f-=v)h=u.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],f,0),o+=u.getLineLength(d.x,d.y,h.x,h.y),d=h;else for(f=p+v;f<T;f+=v)h=u.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],f,0),o+=u.getLineLength(d.x,d.y,h.x,h.y),d=h;return h=u.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],T,0),o+=u.getLineLength(d.x,d.y,h.x,h.y),o}return 0}static convertEndpointToCenterParameterization(e,n,t,a,o,d,h,f,u){var p=u*(Math.PI/180),E=Math.cos(p)*(e-t)/2+Math.sin(p)*(n-a)/2,T=-1*Math.sin(p)*(e-t)/2+Math.cos(p)*(n-a)/2,v=E*E/(h*h)+T*T/(f*f);v>1&&(h*=Math.sqrt(v),f*=Math.sqrt(v));var S=Math.sqrt((h*h*(f*f)-h*h*(T*T)-f*f*(E*E))/(h*h*(T*T)+f*f*(E*E)));o===d&&(S*=-1),isNaN(S)&&(S=0);var g=S*h*T/f,y=S*-f*E/h,b=(e+t)/2+Math.cos(p)*g-Math.sin(p)*y,R=(n+a)/2+Math.sin(p)*g+Math.cos(p)*y,_=function(F){return Math.sqrt(F[0]*F[0]+F[1]*F[1])},w=function(F,M){return(F[0]*M[0]+F[1]*M[1])/(_(F)*_(M))},C=function(F,M){return(F[0]*M[1]<F[1]*M[0]?-1:1)*Math.acos(w(F,M))},N=C([1,0],[(E-g)/h,(T-y)/f]),P=[(E-g)/h,(T-y)/f],D=[(-1*E-g)/h,(-1*T-y)/f],k=C(P,D);return w(P,D)<=-1&&(k=Math.PI),w(P,D)>=1&&(k=0),d===0&&k>0&&(k=k-2*Math.PI),d===1&&k<0&&(k=k+2*Math.PI),[b,R,h,f,N,k,p,d]}}Path$1.Path=Path;Path.prototype.className="Path";Path.prototype._attrsAffectingSize=["data"];(0,Global_1$e._registerNode)(Path);Factory_1$t.Factory.addGetterSetter(Path,"data");Object.defineProperty(Arrow$1,"__esModule",{value:!0});Arrow$1.Arrow=void 0;const Factory_1$s=Factory,Line_1$1=Line$2,Validators_1$s=Validators,Global_1$d=Global,Path_1$2=Path$1;class Arrow extends Line_1$1.Line{_sceneFunc(e){super._sceneFunc(e);var n=Math.PI*2,t=this.points(),a=t,o=this.tension()!==0&&t.length>4;o&&(a=this.getTensionPoints());var d=this.pointerLength(),h=t.length,f,u;if(o){const T=[a[a.length-4],a[a.length-3],a[a.length-2],a[a.length-1],t[h-2],t[h-1]],v=Path_1$2.Path.calcLength(a[a.length-4],a[a.length-3],"C",T),S=Path_1$2.Path.getPointOnQuadraticBezier(Math.min(1,1-d/v),T[0],T[1],T[2],T[3],T[4],T[5]);f=t[h-2]-S.x,u=t[h-1]-S.y}else f=t[h-2]-t[h-4],u=t[h-1]-t[h-3];var p=(Math.atan2(u,f)+n)%n,E=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[h-2],t[h-1]),e.rotate(p),e.moveTo(0,0),e.lineTo(-d,E/2),e.lineTo(-d,-E/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),o?(f=(a[0]+a[2])/2-t[0],u=(a[1]+a[3])/2-t[1]):(f=t[2]-t[0],u=t[3]-t[1]),e.rotate((Math.atan2(-u,-f)+n)%n),e.moveTo(0,0),e.lineTo(-d,E/2),e.lineTo(-d,-E/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var n=this.dashEnabled();n&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),n&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),n=this.pointerWidth()/2;return{x:e.x-n,y:e.y-n,width:e.width+n*2,height:e.height+n*2}}}Arrow$1.Arrow=Arrow;Arrow.prototype.className="Arrow";(0,Global_1$d._registerNode)(Arrow);Factory_1$s.Factory.addGetterSetter(Arrow,"pointerLength",10,(0,Validators_1$s.getNumberValidator)());Factory_1$s.Factory.addGetterSetter(Arrow,"pointerWidth",10,(0,Validators_1$s.getNumberValidator)());Factory_1$s.Factory.addGetterSetter(Arrow,"pointerAtBeginning",!1);Factory_1$s.Factory.addGetterSetter(Arrow,"pointerAtEnding",!0);var Circle$1={};Object.defineProperty(Circle$1,"__esModule",{value:!0});Circle$1.Circle=void 0;const Factory_1$r=Factory,Shape_1$c=Shape,Validators_1$r=Validators,Global_1$c=Global;class Circle extends Shape_1$c.Shape{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}}Circle$1.Circle=Circle;Circle.prototype._centroid=!0;Circle.prototype.className="Circle";Circle.prototype._attrsAffectingSize=["radius"];(0,Global_1$c._registerNode)(Circle);Factory_1$r.Factory.addGetterSetter(Circle,"radius",0,(0,Validators_1$r.getNumberValidator)());var Ellipse$1={};Object.defineProperty(Ellipse$1,"__esModule",{value:!0});Ellipse$1.Ellipse=void 0;const Factory_1$q=Factory,Shape_1$b=Shape,Validators_1$q=Validators,Global_1$b=Global;class Ellipse extends Shape_1$b.Shape{_sceneFunc(e){var n=this.radiusX(),t=this.radiusY();e.beginPath(),e.save(),n!==t&&e.scale(1,t/n),e.arc(0,0,n,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}Ellipse$1.Ellipse=Ellipse;Ellipse.prototype.className="Ellipse";Ellipse.prototype._centroid=!0;Ellipse.prototype._attrsAffectingSize=["radiusX","radiusY"];(0,Global_1$b._registerNode)(Ellipse);Factory_1$q.Factory.addComponentsGetterSetter(Ellipse,"radius",["x","y"]);Factory_1$q.Factory.addGetterSetter(Ellipse,"radiusX",0,(0,Validators_1$q.getNumberValidator)());Factory_1$q.Factory.addGetterSetter(Ellipse,"radiusY",0,(0,Validators_1$q.getNumberValidator)());var Image$4={};Object.defineProperty(Image$4,"__esModule",{value:!0});Image$4.Image=void 0;const Util_1$7=Util,Factory_1$p=Factory,Shape_1$a=Shape,Global_1$a=Global,Validators_1$p=Validators;let Image$3=class Ay extends Shape_1$a.Shape{constructor(e){super(e),this.on("imageChange.konva",()=>{this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&e.readyState===4||e&&e.addEventListener&&e.addEventListener("load",()=>{this._requestDraw()})}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const n=this.getWidth(),t=this.getHeight(),a=this.cornerRadius(),o=this.attrs.image;let d;if(o){const h=this.attrs.cropWidth,f=this.attrs.cropHeight;h&&f?d=[o,this.cropX(),this.cropY(),h,f,0,0,n,t]:d=[o,0,0,n,t]}(this.hasFill()||this.hasStroke()||a)&&(e.beginPath(),a?Util_1$7.Util.drawRoundedRectPath(e,n,t,a):e.rect(0,0,n,t),e.closePath(),e.fillStrokeShape(this)),o&&(a&&e.clip(),e.drawImage.apply(e,d))}_hitFunc(e){var n=this.width(),t=this.height(),a=this.cornerRadius();e.beginPath(),a?Util_1$7.Util.drawRoundedRectPath(e,n,t,a):e.rect(0,0,n,t),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,n;return(e=this.attrs.width)!==null&&e!==void 0?e:(n=this.image())===null||n===void 0?void 0:n.width}getHeight(){var e,n;return(e=this.attrs.height)!==null&&e!==void 0?e:(n=this.image())===null||n===void 0?void 0:n.height}static fromURL(e,n,t=null){var a=Util_1$7.Util.createImageElement();a.onload=function(){var o=new Ay({image:a});n(o)},a.onerror=t,a.crossOrigin="Anonymous",a.src=e}};Image$4.Image=Image$3;Image$3.prototype.className="Image";(0,Global_1$a._registerNode)(Image$3);Factory_1$p.Factory.addGetterSetter(Image$3,"cornerRadius",0,(0,Validators_1$p.getNumberOrArrayOfNumbersValidator)(4));Factory_1$p.Factory.addGetterSetter(Image$3,"image");Factory_1$p.Factory.addComponentsGetterSetter(Image$3,"crop",["x","y","width","height"]);Factory_1$p.Factory.addGetterSetter(Image$3,"cropX",0,(0,Validators_1$p.getNumberValidator)());Factory_1$p.Factory.addGetterSetter(Image$3,"cropY",0,(0,Validators_1$p.getNumberValidator)());Factory_1$p.Factory.addGetterSetter(Image$3,"cropWidth",0,(0,Validators_1$p.getNumberValidator)());Factory_1$p.Factory.addGetterSetter(Image$3,"cropHeight",0,(0,Validators_1$p.getNumberValidator)());var Label$1={};Object.defineProperty(Label$1,"__esModule",{value:!0});Label$1.Tag=Label$1.Label=void 0;const Factory_1$o=Factory,Shape_1$9=Shape,Group_1$1=Group$2,Validators_1$o=Validators,Global_1$9=Global;var ATTR_CHANGE_LIST$2=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],CHANGE_KONVA$1="Change.konva",NONE$1="none",UP="up",RIGHT$1="right",DOWN="down",LEFT$1="left",attrChangeListLen$1=ATTR_CHANGE_LIST$2.length;class Label extends Group_1$1.Group{constructor(e){super(e),this.on("add.konva",function(n){this._addListeners(n.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var n=this,t,a=function(){n._sync()};for(t=0;t<attrChangeListLen$1;t++)e.on(ATTR_CHANGE_LIST$2[t]+CHANGE_KONVA$1,a)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),n=this.getTag(),t,a,o,d,h,f,u;if(e&&n){switch(t=e.width(),a=e.height(),o=n.pointerDirection(),d=n.pointerWidth(),u=n.pointerHeight(),h=0,f=0,o){case UP:h=t/2,f=-1*u;break;case RIGHT$1:h=t+d,f=a/2;break;case DOWN:h=t/2,f=a+u;break;case LEFT$1:h=-1*d,f=a/2;break}n.setAttrs({x:-1*h,y:-1*f,width:t,height:a}),e.setAttrs({x:-1*h,y:-1*f})}}}Label$1.Label=Label;Label.prototype.className="Label";(0,Global_1$9._registerNode)(Label);class Tag extends Shape_1$9.Shape{_sceneFunc(e){var n=this.width(),t=this.height(),a=this.pointerDirection(),o=this.pointerWidth(),d=this.pointerHeight(),h=this.cornerRadius();let f=0,u=0,p=0,E=0;typeof h=="number"?f=u=p=E=Math.min(h,n/2,t/2):(f=Math.min(h[0]||0,n/2,t/2),u=Math.min(h[1]||0,n/2,t/2),E=Math.min(h[2]||0,n/2,t/2),p=Math.min(h[3]||0,n/2,t/2)),e.beginPath(),e.moveTo(f,0),a===UP&&(e.lineTo((n-o)/2,0),e.lineTo(n/2,-1*d),e.lineTo((n+o)/2,0)),e.lineTo(n-u,0),e.arc(n-u,u,u,Math.PI*3/2,0,!1),a===RIGHT$1&&(e.lineTo(n,(t-d)/2),e.lineTo(n+o,t/2),e.lineTo(n,(t+d)/2)),e.lineTo(n,t-E),e.arc(n-E,t-E,E,0,Math.PI/2,!1),a===DOWN&&(e.lineTo((n+o)/2,t),e.lineTo(n/2,t+d),e.lineTo((n-o)/2,t)),e.lineTo(p,t),e.arc(p,t-p,p,Math.PI/2,Math.PI,!1),a===LEFT$1&&(e.lineTo(0,(t+d)/2),e.lineTo(-1*o,t/2),e.lineTo(0,(t-d)/2)),e.lineTo(0,f),e.arc(f,f,f,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,n=0,t=this.pointerWidth(),a=this.pointerHeight(),o=this.pointerDirection(),d=this.width(),h=this.height();return o===UP?(n-=a,h+=a):o===DOWN?h+=a:o===LEFT$1?(e-=t*1.5,d+=t):o===RIGHT$1&&(d+=t*1.5),{x:e,y:n,width:d,height:h}}}Label$1.Tag=Tag;Tag.prototype.className="Tag";(0,Global_1$9._registerNode)(Tag);Factory_1$o.Factory.addGetterSetter(Tag,"pointerDirection",NONE$1);Factory_1$o.Factory.addGetterSetter(Tag,"pointerWidth",0,(0,Validators_1$o.getNumberValidator)());Factory_1$o.Factory.addGetterSetter(Tag,"pointerHeight",0,(0,Validators_1$o.getNumberValidator)());Factory_1$o.Factory.addGetterSetter(Tag,"cornerRadius",0,(0,Validators_1$o.getNumberOrArrayOfNumbersValidator)(4));var Rect$2={};Object.defineProperty(Rect$2,"__esModule",{value:!0});Rect$2.Rect=void 0;const Factory_1$n=Factory,Shape_1$8=Shape,Global_1$8=Global,Util_1$6=Util,Validators_1$n=Validators;let Rect$1=class extends Shape_1$8.Shape{_sceneFunc(e){var n=this.cornerRadius(),t=this.width(),a=this.height();e.beginPath(),n?Util_1$6.Util.drawRoundedRectPath(e,t,a,n):e.rect(0,0,t,a),e.closePath(),e.fillStrokeShape(this)}};Rect$2.Rect=Rect$1;Rect$1.prototype.className="Rect";(0,Global_1$8._registerNode)(Rect$1);Factory_1$n.Factory.addGetterSetter(Rect$1,"cornerRadius",0,(0,Validators_1$n.getNumberOrArrayOfNumbersValidator)(4));var RegularPolygon$1={};Object.defineProperty(RegularPolygon$1,"__esModule",{value:!0});RegularPolygon$1.RegularPolygon=void 0;const Factory_1$m=Factory,Shape_1$7=Shape,Validators_1$m=Validators,Global_1$7=Global;class RegularPolygon extends Shape_1$7.Shape{_sceneFunc(e){const n=this._getPoints();e.beginPath(),e.moveTo(n[0].x,n[0].y);for(var t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,n=this.attrs.radius||0,t=[];for(var a=0;a<e;a++)t.push({x:n*Math.sin(a*2*Math.PI/e),y:-1*n*Math.cos(a*2*Math.PI/e)});return t}getSelfRect(){const e=this._getPoints();var n=e[0].x,t=e[0].y,a=e[0].x,o=e[0].y;return e.forEach(d=>{n=Math.min(n,d.x),t=Math.max(t,d.x),a=Math.min(a,d.y),o=Math.max(o,d.y)}),{x:n,y:a,width:t-n,height:o-a}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}RegularPolygon$1.RegularPolygon=RegularPolygon;RegularPolygon.prototype.className="RegularPolygon";RegularPolygon.prototype._centroid=!0;RegularPolygon.prototype._attrsAffectingSize=["radius"];(0,Global_1$7._registerNode)(RegularPolygon);Factory_1$m.Factory.addGetterSetter(RegularPolygon,"radius",0,(0,Validators_1$m.getNumberValidator)());Factory_1$m.Factory.addGetterSetter(RegularPolygon,"sides",0,(0,Validators_1$m.getNumberValidator)());var Ring$1={};Object.defineProperty(Ring$1,"__esModule",{value:!0});Ring$1.Ring=void 0;const Factory_1$l=Factory,Shape_1$6=Shape,Validators_1$l=Validators,Global_1$6=Global;var PIx2=Math.PI*2;class Ring extends Shape_1$6.Shape{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,PIx2,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),PIx2,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Ring$1.Ring=Ring;Ring.prototype.className="Ring";Ring.prototype._centroid=!0;Ring.prototype._attrsAffectingSize=["innerRadius","outerRadius"];(0,Global_1$6._registerNode)(Ring);Factory_1$l.Factory.addGetterSetter(Ring,"innerRadius",0,(0,Validators_1$l.getNumberValidator)());Factory_1$l.Factory.addGetterSetter(Ring,"outerRadius",0,(0,Validators_1$l.getNumberValidator)());var Sprite$1={};Object.defineProperty(Sprite$1,"__esModule",{value:!0});Sprite$1.Sprite=void 0;const Factory_1$k=Factory,Shape_1$5=Shape,Animation_1=Animation$3,Validators_1$k=Validators,Global_1$5=Global;class Sprite extends Shape_1$5.Shape{constructor(e){super(e),this._updated=!0,this.anim=new Animation_1.Animation(()=>{var n=this._updated;return this._updated=!1,n}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){var n=this.animation(),t=this.frameIndex(),a=t*4,o=this.animations()[n],d=this.frameOffsets(),h=o[a+0],f=o[a+1],u=o[a+2],p=o[a+3],E=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,u,p),e.closePath(),e.fillStrokeShape(this)),E)if(d){var T=d[n],v=t*2;e.drawImage(E,h,f,u,p,T[v+0],T[v+1],u,p)}else e.drawImage(E,h,f,u,p,0,0,u,p)}_hitFunc(e){var n=this.animation(),t=this.frameIndex(),a=t*4,o=this.animations()[n],d=this.frameOffsets(),h=o[a+2],f=o[a+3];if(e.beginPath(),d){var u=d[n],p=t*2;e.rect(u[p+0],u[p+1],h,f)}else e.rect(0,0,h,f);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),n=this.animation(),t=this.animations(),a=t[n],o=a.length/4;e<o-1?this.frameIndex(e+1):this.frameIndex(0)}}Sprite$1.Sprite=Sprite;Sprite.prototype.className="Sprite";(0,Global_1$5._registerNode)(Sprite);Factory_1$k.Factory.addGetterSetter(Sprite,"animation");Factory_1$k.Factory.addGetterSetter(Sprite,"animations");Factory_1$k.Factory.addGetterSetter(Sprite,"frameOffsets");Factory_1$k.Factory.addGetterSetter(Sprite,"image");Factory_1$k.Factory.addGetterSetter(Sprite,"frameIndex",0,(0,Validators_1$k.getNumberValidator)());Factory_1$k.Factory.addGetterSetter(Sprite,"frameRate",17,(0,Validators_1$k.getNumberValidator)());Factory_1$k.Factory.backCompat(Sprite,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Star$1={};Object.defineProperty(Star$1,"__esModule",{value:!0});Star$1.Star=void 0;const Factory_1$j=Factory,Shape_1$4=Shape,Validators_1$j=Validators,Global_1$4=Global;class Star extends Shape_1$4.Shape{_sceneFunc(e){var n=this.innerRadius(),t=this.outerRadius(),a=this.numPoints();e.beginPath(),e.moveTo(0,0-t);for(var o=1;o<a*2;o++){var d=o%2===0?t:n,h=d*Math.sin(o*Math.PI/a),f=-1*d*Math.cos(o*Math.PI/a);e.lineTo(h,f)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Star$1.Star=Star;Star.prototype.className="Star";Star.prototype._centroid=!0;Star.prototype._attrsAffectingSize=["innerRadius","outerRadius"];(0,Global_1$4._registerNode)(Star);Factory_1$j.Factory.addGetterSetter(Star,"numPoints",5,(0,Validators_1$j.getNumberValidator)());Factory_1$j.Factory.addGetterSetter(Star,"innerRadius",0,(0,Validators_1$j.getNumberValidator)());Factory_1$j.Factory.addGetterSetter(Star,"outerRadius",0,(0,Validators_1$j.getNumberValidator)());var Text$2={};Object.defineProperty(Text$2,"__esModule",{value:!0});Text$2.Text=Text$2.stringToArray=void 0;const Util_1$5=Util,Factory_1$i=Factory,Shape_1$3=Shape,Validators_1$i=Validators,Global_1$3=Global;function stringToArray(l){return Array.from(l)}Text$2.stringToArray=stringToArray;var AUTO="auto",CENTER="center",INHERIT="inherit",JUSTIFY="justify",CHANGE_KONVA="Change.konva",CONTEXT_2D="2d",DASH="-",LEFT="left",TEXT="text",TEXT_UPPER="Text",TOP="top",BOTTOM="bottom",MIDDLE="middle",NORMAL$1="normal",PX_SPACE="px ",SPACE=" ",RIGHT="right",RTL="rtl",WORD="word",CHAR="char",NONE="none",ELLIPSIS="…",ATTR_CHANGE_LIST$1=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],attrChangeListLen=ATTR_CHANGE_LIST$1.length;function normalizeFontFamily(l){return l.split(",").map(e=>{e=e.trim();const n=e.indexOf(" ")>=0,t=e.indexOf('"')>=0||e.indexOf("'")>=0;return n&&!t&&(e=`"${e}"`),e}).join(", ")}var dummyContext;function getDummyContext(){return dummyContext||(dummyContext=Util_1$5.Util.createCanvasElement().getContext(CONTEXT_2D),dummyContext)}function _fillFunc$1(l){l.fillText(this._partialText,this._partialTextX,this._partialTextY)}function _strokeFunc$1(l){l.setAttr("miterLimit",2),l.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function checkDefaultFill(l){return l=l||{},!l.fillLinearGradientColorStops&&!l.fillRadialGradientColorStops&&!l.fillPatternImage&&(l.fill=l.fill||"black"),l}let Text$1=class extends Shape_1$3.Shape{constructor(e){super(checkDefaultFill(e)),this._partialTextX=0,this._partialTextY=0;for(var n=0;n<attrChangeListLen;n++)this.on(ATTR_CHANGE_LIST$1[n]+CHANGE_KONVA,this._setTextData);this._setTextData()}_sceneFunc(e){var n=this.textArr,t=n.length;if(this.text()){var a=this.padding(),o=this.fontSize(),d=this.lineHeight()*o,h=this.verticalAlign(),f=this.direction(),u=0,p=this.align(),E=this.getWidth(),T=this.letterSpacing(),v=this.fill(),S=this.textDecoration(),g=S.indexOf("underline")!==-1,y=S.indexOf("line-through")!==-1,b;f=f===INHERIT?e.direction:f;var R=0,R=d/2,_=0,w=0;for(f===RTL&&e.setAttr("direction",f),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",MIDDLE),e.setAttr("textAlign",LEFT),h===MIDDLE?u=(this.getHeight()-t*d-a*2)/2:h===BOTTOM&&(u=this.getHeight()-t*d-a*2),e.translate(a,u+a),b=0;b<t;b++){var _=0,w=0,C=n[b],N=C.text,P=C.width,D=C.lastInParagraph,k,F,M;if(e.save(),p===RIGHT?_+=E-P-a*2:p===CENTER&&(_+=(E-P-a*2)/2),g){e.save(),e.beginPath(),e.moveTo(_,R+w+Math.round(o/2)),k=N.split(" ").length-1,F=k===0,M=p===JUSTIFY&&!D?E-a*2:P,e.lineTo(_+Math.round(M),R+w+Math.round(o/2)),e.lineWidth=o/15;const ae=this._getLinearGradient();e.strokeStyle=ae||v,e.stroke(),e.restore()}if(y){e.save(),e.beginPath(),e.moveTo(_,R+w),k=N.split(" ").length-1,F=k===0,M=p===JUSTIFY&&D&&!F?E-a*2:P,e.lineTo(_+Math.round(M),R+w),e.lineWidth=o/15;const ae=this._getLinearGradient();e.strokeStyle=ae||v,e.stroke(),e.restore()}if(f!==RTL&&(T!==0||p===JUSTIFY)){k=N.split(" ").length-1;for(var I=stringToArray(N),$=0;$<I.length;$++){var z=I[$];z===" "&&!D&&p===JUSTIFY&&(_+=(E-a*2-P)/k),this._partialTextX=_,this._partialTextY=R+w,this._partialText=z,e.fillStrokeShape(this),_+=this.measureSize(z).width+T}}else T!==0&&e.setAttr("letterSpacing",`${T}px`),this._partialTextX=_,this._partialTextY=R+w,this._partialText=N,e.fillStrokeShape(this);e.restore(),t>1&&(R+=d)}}}_hitFunc(e){var n=this.getWidth(),t=this.getHeight();e.beginPath(),e.rect(0,0,n,t),e.closePath(),e.fillStrokeShape(this)}setText(e){var n=Util_1$5.Util._isString(e)?e:e==null?"":e+"";return this._setAttr(TEXT,n),this}getWidth(){var e=this.attrs.width===AUTO||this.attrs.width===void 0;return e?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){var e=this.attrs.height===AUTO||this.attrs.height===void 0;return e?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Util_1$5.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var n=getDummyContext(),t=this.fontSize(),a;return n.save(),n.font=this._getContextFont(),a=n.measureText(e),n.restore(),{width:a.width,height:t}}_getContextFont(){return this.fontStyle()+SPACE+this.fontVariant()+SPACE+(this.fontSize()+PX_SPACE)+normalizeFontFamily(this.fontFamily())}_addTextLine(e){this.align()===JUSTIFY&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var n=this.letterSpacing(),t=e.length;return getDummyContext().measureText(e).width+(t?n*(t-1):0)}_setTextData(){var e=this.text().split(`
72
72
  `),n=+this.fontSize(),t=0,a=this.lineHeight()*n,o=this.attrs.width,d=this.attrs.height,h=o!==AUTO&&o!==void 0,f=d!==AUTO&&d!==void 0,u=this.padding(),p=o-u*2,E=d-u*2,T=0,v=this.wrap(),S=v!==NONE,g=v!==CHAR&&S,y=this.ellipsis();this.textArr=[],getDummyContext().font=this._getContextFont();for(var b=y?this._getTextWidth(ELLIPSIS):0,R=0,_=e.length;R<_;++R){var w=e[R],C=this._getTextWidth(w);if(h&&C>p)for(;w.length>0;){for(var N=0,P=w.length,D="",k=0;N<P;){var F=N+P>>>1,M=w.slice(0,F+1),I=this._getTextWidth(M)+b;I<=p?(N=F+1,D=M,k=I):P=F}if(D){if(g){var $,z=w[D.length],X=z===SPACE||z===DASH;X&&k<=p?$=D.length:$=Math.max(D.lastIndexOf(SPACE),D.lastIndexOf(DASH))+1,$>0&&(N=$,D=D.slice(0,N),k=this._getTextWidth(D))}D=D.trimRight(),this._addTextLine(D),t=Math.max(t,k),T+=a;var te=this._shouldHandleEllipsis(T);if(te){this._tryToAddEllipsisToLastLine();break}if(w=w.slice(N),w=w.trimLeft(),w.length>0&&(C=this._getTextWidth(w),C<=p)){this._addTextLine(w),T+=a,t=Math.max(t,C);break}}else break}else this._addTextLine(w),T+=a,t=Math.max(t,C),this._shouldHandleEllipsis(T)&&R<_-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),f&&T+a>E)break}this.textHeight=n,this.textWidth=t}_shouldHandleEllipsis(e){var n=+this.fontSize(),t=this.lineHeight()*n,a=this.attrs.height,o=a!==AUTO&&a!==void 0,d=this.padding(),h=a-d*2,f=this.wrap(),u=f!==NONE;return!u||o&&e+t>h}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,n=e!==AUTO&&e!==void 0,t=this.padding(),a=e-t*2,o=this.ellipsis(),d=this.textArr[this.textArr.length-1];if(!(!d||!o)){if(n){var h=this._getTextWidth(d.text+ELLIPSIS)<a;h||(d.text=d.text.slice(0,d.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(d.text+ELLIPSIS)}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,n=this.hasShadow();return e&&n?!0:super._useBufferCanvas()}};Text$2.Text=Text$1;Text$1.prototype._fillFunc=_fillFunc$1;Text$1.prototype._strokeFunc=_strokeFunc$1;Text$1.prototype.className=TEXT_UPPER;Text$1.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"];(0,Global_1$3._registerNode)(Text$1);Factory_1$i.Factory.overWriteSetter(Text$1,"width",(0,Validators_1$i.getNumberOrAutoValidator)());Factory_1$i.Factory.overWriteSetter(Text$1,"height",(0,Validators_1$i.getNumberOrAutoValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"direction",INHERIT);Factory_1$i.Factory.addGetterSetter(Text$1,"fontFamily","Arial");Factory_1$i.Factory.addGetterSetter(Text$1,"fontSize",12,(0,Validators_1$i.getNumberValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"fontStyle",NORMAL$1);Factory_1$i.Factory.addGetterSetter(Text$1,"fontVariant",NORMAL$1);Factory_1$i.Factory.addGetterSetter(Text$1,"padding",0,(0,Validators_1$i.getNumberValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"align",LEFT);Factory_1$i.Factory.addGetterSetter(Text$1,"verticalAlign",TOP);Factory_1$i.Factory.addGetterSetter(Text$1,"lineHeight",1,(0,Validators_1$i.getNumberValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"wrap",WORD);Factory_1$i.Factory.addGetterSetter(Text$1,"ellipsis",!1,(0,Validators_1$i.getBooleanValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"letterSpacing",0,(0,Validators_1$i.getNumberValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"text","",(0,Validators_1$i.getStringValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"textDecoration","");var TextPath$1={};Object.defineProperty(TextPath$1,"__esModule",{value:!0});TextPath$1.TextPath=void 0;const Util_1$4=Util,Factory_1$h=Factory,Shape_1$2=Shape,Path_1$1=Path$1,Text_1$1=Text$2,Validators_1$h=Validators,Global_1$2=Global;var EMPTY_STRING="",NORMAL="normal";function _fillFunc(l){l.fillText(this.partialText,0,0)}function _strokeFunc(l){l.strokeText(this.partialText,0,0)}class TextPath extends Shape_1$2.Shape{constructor(e){super(e),this.dummyCanvas=Util_1$4.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Path_1$1.Path.getPathLength(this.dataArray)}_getPointAtLength(e){if(!this.attrs.data)return null;const n=this.pathLength;return e-1>n?null:Path_1$1.Path.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Path_1$1.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();var n=this.textDecoration(),t=this.fill(),a=this.fontSize(),o=this.glyphInfo;n==="underline"&&e.beginPath();for(var d=0;d<o.length;d++){e.save();var h=o[d].p0;e.translate(h.x,h.y),e.rotate(o[d].rotation),this.partialText=o[d].text,e.fillStrokeShape(this),n==="underline"&&(d===0&&e.moveTo(0,a/2+1),e.lineTo(a,a/2+1)),e.restore()}n==="underline"&&(e.strokeStyle=t,e.lineWidth=a/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var n=this.glyphInfo;if(n.length>=1){var t=n[0].p0;e.moveTo(t.x,t.y)}for(var a=0;a<n.length;a++){var o=n[a].p1;e.lineTo(o.x,o.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Util_1$4.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Text_1$1.Text.prototype.setText.call(this,e)}_getContextFont(){return Text_1$1.Text.prototype._getContextFont.call(this)}_getTextSize(e){var n=this.dummyCanvas,t=n.getContext("2d");t.save(),t.font=this._getContextFont();var a=t.measureText(e);return t.restore(),{width:a.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:e,height:n}=this._getTextSize(this.attrs.text);if(this.textWidth=e,this.textHeight=n,this.glyphInfo=[],!this.attrs.data)return null;const t=this.letterSpacing(),a=this.align(),o=this.kerningFunc(),d=Math.max(this.textWidth+((this.attrs.text||"").length-1)*t,0);let h=0;a==="center"&&(h=Math.max(0,this.pathLength/2-d/2)),a==="right"&&(h=Math.max(0,this.pathLength-d));const f=(0,Text_1$1.stringToArray)(this.text());let u=h;for(var p=0;p<f.length;p++){const E=this._getPointAtLength(u);if(!E)return;let T=this._getTextSize(f[p]).width+t;if(f[p]===" "&&a==="justify"){const R=this.text().split(" ").length-1;T+=(this.pathLength-d)/R}const v=this._getPointAtLength(u+T);if(!v)return;const S=Path_1$1.Path.getLineLength(E.x,E.y,v.x,v.y);let g=0;if(o)try{g=o(f[p-1],f[p])*this.fontSize()}catch{g=0}E.x+=g,v.x+=g,this.textWidth+=g;const y=Path_1$1.Path.getPointOnLine(g+S/2,E.x,E.y,v.x,v.y),b=Math.atan2(v.y-E.y,v.x-E.x);this.glyphInfo.push({transposeX:y.x,transposeY:y.y,text:f[p],rotation:b,p0:E,p1:v}),u+=T}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach(function(p){e.push(p.p0.x),e.push(p.p0.y),e.push(p.p1.x),e.push(p.p1.y)});for(var n=e[0]||0,t=e[0]||0,a=e[1]||0,o=e[1]||0,d,h,f=0;f<e.length/2;f++)d=e[f*2],h=e[f*2+1],n=Math.min(n,d),t=Math.max(t,d),a=Math.min(a,h),o=Math.max(o,h);var u=this.fontSize();return{x:n-u/2,y:a-u/2,width:t-n+u,height:o-a+u}}destroy(){return Util_1$4.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}TextPath$1.TextPath=TextPath;TextPath.prototype._fillFunc=_fillFunc;TextPath.prototype._strokeFunc=_strokeFunc;TextPath.prototype._fillFuncHit=_fillFunc;TextPath.prototype._strokeFuncHit=_strokeFunc;TextPath.prototype.className="TextPath";TextPath.prototype._attrsAffectingSize=["text","fontSize","data"];(0,Global_1$2._registerNode)(TextPath);Factory_1$h.Factory.addGetterSetter(TextPath,"data");Factory_1$h.Factory.addGetterSetter(TextPath,"fontFamily","Arial");Factory_1$h.Factory.addGetterSetter(TextPath,"fontSize",12,(0,Validators_1$h.getNumberValidator)());Factory_1$h.Factory.addGetterSetter(TextPath,"fontStyle",NORMAL);Factory_1$h.Factory.addGetterSetter(TextPath,"align","left");Factory_1$h.Factory.addGetterSetter(TextPath,"letterSpacing",0,(0,Validators_1$h.getNumberValidator)());Factory_1$h.Factory.addGetterSetter(TextPath,"textBaseline","middle");Factory_1$h.Factory.addGetterSetter(TextPath,"fontVariant",NORMAL);Factory_1$h.Factory.addGetterSetter(TextPath,"text",EMPTY_STRING);Factory_1$h.Factory.addGetterSetter(TextPath,"textDecoration",null);Factory_1$h.Factory.addGetterSetter(TextPath,"kerningFunc",null);var Transformer$1={};Object.defineProperty(Transformer$1,"__esModule",{value:!0});Transformer$1.Transformer=void 0;const Util_1$3=Util,Factory_1$g=Factory,Node_1$f=Node$1,Shape_1$1=Shape,Rect_1$1=Rect$2,Group_1=Group$2,Global_1$1=Global,Validators_1$g=Validators,Global_2$1=Global;var EVENTS_NAME="tr-konva",ATTR_CHANGE_LIST=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(l=>l+`.${EVENTS_NAME}`).join(" "),NODES_RECT="nodesRect",TRANSFORM_CHANGE_STR=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],ANGLES={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const TOUCH_DEVICE="ontouchstart"in Global_1$1.Konva._global;function getCursor(l,e,n){if(l==="rotater")return n;e+=Util_1$3.Util.degToRad(ANGLES[l]||0);var t=(Util_1$3.Util.radToDeg(e)%360+360)%360;return Util_1$3.Util._inRange(t,315+22.5,360)||Util_1$3.Util._inRange(t,0,22.5)?"ns-resize":Util_1$3.Util._inRange(t,45-22.5,45+22.5)?"nesw-resize":Util_1$3.Util._inRange(t,90-22.5,90+22.5)?"ew-resize":Util_1$3.Util._inRange(t,135-22.5,135+22.5)?"nwse-resize":Util_1$3.Util._inRange(t,180-22.5,180+22.5)?"ns-resize":Util_1$3.Util._inRange(t,225-22.5,225+22.5)?"nesw-resize":Util_1$3.Util._inRange(t,270-22.5,270+22.5)?"ew-resize":Util_1$3.Util._inRange(t,315-22.5,315+22.5)?"nwse-resize":(Util_1$3.Util.error("Transformer has unknown angle for cursor detection: "+t),"pointer")}var ANCHORS_NAMES=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],MAX_SAFE_INTEGER=1e8;function getCenter(l){return{x:l.x+l.width/2*Math.cos(l.rotation)+l.height/2*Math.sin(-l.rotation),y:l.y+l.height/2*Math.cos(l.rotation)+l.width/2*Math.sin(l.rotation)}}function rotateAroundPoint(l,e,n){const t=n.x+(l.x-n.x)*Math.cos(e)-(l.y-n.y)*Math.sin(e),a=n.y+(l.x-n.x)*Math.sin(e)+(l.y-n.y)*Math.cos(e);return{...l,rotation:l.rotation+e,x:t,y:a}}function rotateAroundCenter(l,e){const n=getCenter(l);return rotateAroundPoint(l,e,n)}function getSnap(l,e,n){let t=e;for(let a=0;a<l.length;a++){const o=Global_1$1.Konva.getAngle(l[a]),d=Math.abs(o-e)%(Math.PI*2);Math.min(d,Math.PI*2-d)<n&&(t=o)}return t}class Transformer extends Group_1.Group{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(ATTR_CHANGE_LIST,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return Util_1$3.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return EVENTS_NAME+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const n=e.filter(a=>a.isAncestorOf(this)?(Util_1$3.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0);this._nodes=e=n,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(a=>{const o=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()},d=a._attrsAffectingSize.map(h=>h+"Change."+this._getEventNamespace()).join(" ");a.on(d,o),a.on(TRANSFORM_CHANGE_STR.map(h=>h+`.${this._getEventNamespace()}`).join(" "),o),a.on(`absoluteTransformChange.${this._getEventNamespace()}`,o),this._proxyDrag(a)}),this._resetTransformCache();var t=!!this.findOne(".top-left");return t&&this.update(),this}_proxyDrag(e){let n;e.on(`dragstart.${this._getEventNamespace()}`,t=>{n=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(t,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,t=>{if(!n)return;const a=e.getAbsolutePosition(),o=a.x-n.x,d=a.y-n.y;this.nodes().forEach(h=>{if(h===e||h.isDragging())return;const f=h.getAbsolutePosition();h.setAbsolutePosition({x:f.x+o,y:f.y+d}),h.startDrag(t)}),n=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(NODES_RECT),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(NODES_RECT,this.__getNodeRect)}__getNodeShape(e,n=this.rotation(),t){var a=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(t),d=e.getAbsolutePosition(t),h=a.x*o.x-e.offsetX()*o.x,f=a.y*o.y-e.offsetY()*o.y;const u=(Global_1$1.Konva.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),p={x:d.x+h*Math.cos(u)+f*Math.sin(-u),y:d.y+f*Math.cos(u)+h*Math.sin(u),width:a.width*o.x,height:a.height*o.y,rotation:u};return rotateAroundPoint(p,-Global_1$1.Konva.getAngle(n),{x:0,y:0})}__getNodeRect(){var e=this.getNode();if(!e)return{x:-MAX_SAFE_INTEGER,y:-MAX_SAFE_INTEGER,width:0,height:0,rotation:0};const n=[];this.nodes().map(u=>{const p=u.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var E=[{x:p.x,y:p.y},{x:p.x+p.width,y:p.y},{x:p.x+p.width,y:p.y+p.height},{x:p.x,y:p.y+p.height}],T=u.getAbsoluteTransform();E.forEach(function(v){var S=T.point(v);n.push(S)})});const t=new Util_1$3.Transform;t.rotate(-Global_1$1.Konva.getAngle(this.rotation()));var a=1/0,o=1/0,d=-1/0,h=-1/0;n.forEach(function(u){var p=t.point(u);a===void 0&&(a=d=p.x,o=h=p.y),a=Math.min(a,p.x),o=Math.min(o,p.y),d=Math.max(d,p.x),h=Math.max(h,p.y)}),t.invert();const f=t.point({x:a,y:o});return{x:f.x,y:f.y,width:d-a,height:h-o,rotation:Global_1$1.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),ANCHORS_NAMES.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater")}_createAnchor(e){var n=new Rect_1$1.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:TOUCH_DEVICE?10:"auto"}),t=this;n.on("mousedown touchstart",function(a){t._handleMouseDown(a)}),n.on("dragstart",a=>{n.stopDrag(),a.cancelBubble=!0}),n.on("dragend",a=>{a.cancelBubble=!0}),n.on("mouseenter",()=>{var a=Global_1$1.Konva.getAngle(this.rotation()),o=this.rotateAnchorCursor(),d=getCursor(e,a,o);n.getStage().content&&(n.getStage().content.style.cursor=d),this._cursorChange=!0}),n.on("mouseout",()=>{n.getStage().content&&(n.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(n)}_createBack(){var e=new Shape_1$1.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(n,t){var a=t.getParent(),o=a.padding();n.beginPath(),n.rect(-o,-o,t.width()+o*2,t.height()+o*2),n.moveTo(t.width()/2,-o),a.rotateEnabled()&&a.rotateLineVisible()&&n.lineTo(t.width()/2,-a.rotateAnchorOffset()*Util_1$3.Util._sign(t.height())-o),n.fillStrokeShape(t)},hitFunc:(n,t)=>{if(this.shouldOverdrawWholeArea()){var a=this.padding();n.beginPath(),n.rect(-a,-a,t.width()+a*2,t.height()+a*2),n.fillStrokeShape(t)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",n=>{n.cancelBubble=!0}),e.on("dragmove",n=>{n.cancelBubble=!0}),e.on("dragend",n=>{n.cancelBubble=!0}),this.on("dragmove",n=>{this.update()})}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var n=this._getNodeRect(),t=n.width,a=n.height,o=Math.sqrt(Math.pow(t,2)+Math.pow(a,2));this.sin=Math.abs(a/o),this.cos=Math.abs(t/o),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var d=e.target.getAbsolutePosition(),h=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:h.x-d.x,y:h.y-d.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(f=>{f._fire("transformstart",{evt:e.evt,target:f})})}_handleMouseMove(e){var n,t,a,o=this.findOne("."+this._movingAnchorName),d=o.getStage();d.setPointersPositions(e);const h=d.getPointerPosition();let f={x:h.x-this._anchorDragOffset.x,y:h.y-this._anchorDragOffset.y};const u=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(f=this.anchorDragBoundFunc()(u,f,e)),o.setAbsolutePosition(f);const p=o.getAbsolutePosition();if(!(u.x===p.x&&u.y===p.y)){if(this._movingAnchorName==="rotater"){var E=this._getNodeRect();n=o.x()-E.width/2,t=-o.y()+E.height/2;let $=Math.atan2(-t,n)+Math.PI/2;E.height<0&&($-=Math.PI);var T=Global_1$1.Konva.getAngle(this.rotation());const z=T+$,X=Global_1$1.Konva.getAngle(this.rotationSnapTolerance()),ae=getSnap(this.rotationSnaps(),z,X)-E.rotation,ee=rotateAroundCenter(E,ae);this._fitNodesInto(ee,e);return}var v=this.shiftBehavior(),S;v==="inverted"?S=this.keepRatio()&&!e.shiftKey:v==="none"?S=this.keepRatio():S=this.keepRatio()||e.shiftKey;var _=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(S){var g=_?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};a=Math.sqrt(Math.pow(g.x-o.x(),2)+Math.pow(g.y-o.y(),2));var y=this.findOne(".top-left").x()>g.x?-1:1,b=this.findOne(".top-left").y()>g.y?-1:1;n=a*this.cos*y,t=a*this.sin*b,this.findOne(".top-left").x(g.x-n),this.findOne(".top-left").y(g.y-t)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(S){var g=_?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};a=Math.sqrt(Math.pow(o.x()-g.x,2)+Math.pow(g.y-o.y(),2));var y=this.findOne(".top-right").x()<g.x?-1:1,b=this.findOne(".top-right").y()>g.y?-1:1;n=a*this.cos*y,t=a*this.sin*b,this.findOne(".top-right").x(g.x+n),this.findOne(".top-right").y(g.y-t)}var R=o.position();this.findOne(".top-left").y(R.y),this.findOne(".bottom-right").x(R.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(o.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(o.x());else if(this._movingAnchorName==="bottom-left"){if(S){var g=_?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};a=Math.sqrt(Math.pow(g.x-o.x(),2)+Math.pow(o.y()-g.y,2));var y=g.x<o.x()?-1:1,b=o.y()<g.y?-1:1;n=a*this.cos*y,t=a*this.sin*b,o.x(g.x-n),o.y(g.y+t)}R=o.position(),this.findOne(".top-left").x(R.x),this.findOne(".bottom-right").y(R.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(S){var g=_?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};a=Math.sqrt(Math.pow(o.x()-g.x,2)+Math.pow(o.y()-g.y,2));var y=this.findOne(".bottom-right").x()<g.x?-1:1,b=this.findOne(".bottom-right").y()<g.y?-1:1;n=a*this.cos*y,t=a*this.sin*b,this.findOne(".bottom-right").x(g.x+n),this.findOne(".bottom-right").y(g.y+t)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));var _=this.centeredScaling()||e.altKey;if(_){var w=this.findOne(".top-left"),C=this.findOne(".bottom-right"),N=w.x(),P=w.y(),D=this.getWidth()-C.x(),k=this.getHeight()-C.y();C.move({x:-N,y:-P}),w.move({x:D,y:k})}var F=this.findOne(".top-left").getAbsolutePosition();n=F.x,t=F.y;var M=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),I=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:n,y:t,width:M,height:I,rotation:Global_1$1.Konva.getAngle(this.rotation())},e)}}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var n=this.getNode();this._fire("transformend",{evt:e,target:n}),n&&this._nodes.forEach(t=>{t._fire("transformend",{evt:e,target:t})}),this._movingAnchorName=null}}_fitNodesInto(e,n){var t=this._getNodeRect();const a=1;if(Util_1$3.Util._inRange(e.width,-this.padding()*2-a,a)){this.update();return}if(Util_1$3.Util._inRange(e.height,-this.padding()*2-a,a)){this.update();return}var o=new Util_1$3.Transform;if(o.rotate(Global_1$1.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const T=o.point({x:-this.padding()*2,y:0});e.x+=T.x,e.y+=T.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=T.x,this._anchorDragOffset.y-=T.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const T=o.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=T.x,this._anchorDragOffset.y-=T.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const T=o.point({x:0,y:-this.padding()*2});e.x+=T.x,e.y+=T.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=T.x,this._anchorDragOffset.y-=T.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const T=o.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=T.x,this._anchorDragOffset.y-=T.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const T=this.boundBoxFunc()(t,e);T?e=T:Util_1$3.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const d=1e7,h=new Util_1$3.Transform;h.translate(t.x,t.y),h.rotate(t.rotation),h.scale(t.width/d,t.height/d);const f=new Util_1$3.Transform,u=e.width/d,p=e.height/d;this.flipEnabled()===!1?(f.translate(e.x,e.y),f.rotate(e.rotation),f.translate(e.width<0?e.width:0,e.height<0?e.height:0),f.scale(Math.abs(u),Math.abs(p))):(f.translate(e.x,e.y),f.rotate(e.rotation),f.scale(u,p));const E=f.multiply(h.invert());this._nodes.forEach(T=>{var v;const S=T.getParent().getAbsoluteTransform(),g=T.getTransform().copy();g.translate(T.offsetX(),T.offsetY());const y=new Util_1$3.Transform;y.multiply(S.copy().invert()).multiply(E).multiply(S).multiply(g);const b=y.decompose();T.setAttrs(b),this._fire("transform",{evt:n,target:T}),T._fire("transform",{evt:n,target:T}),(v=T.getLayer())===null||v===void 0||v.batchDraw()}),this.rotation(Util_1$3.Util._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,n){this.findOne(e).setAttrs(n)}update(){var e,n=this._getNodeRect();this.rotation(Util_1$3.Util._getRotation(n.rotation));var t=n.width,a=n.height,o=this.enabledAnchors(),d=this.resizeEnabled(),h=this.padding(),f=this.anchorSize();const u=this.find("._anchor");u.forEach(E=>{E.setAttrs({width:f,height:f,offsetX:f/2,offsetY:f/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:f/2+h,offsetY:f/2+h,visible:d&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:t/2,y:0,offsetY:f/2+h,visible:d&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:t,y:0,offsetX:f/2-h,offsetY:f/2+h,visible:d&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:a/2,offsetX:f/2+h,visible:d&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:t,y:a/2,offsetX:f/2-h,visible:d&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:a,offsetX:f/2+h,offsetY:f/2-h,visible:d&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:t/2,y:a,offsetY:f/2-h,visible:d&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:t,y:a,offsetX:f/2-h,offsetY:f/2-h,visible:d&&o.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:t/2,y:-this.rotateAnchorOffset()*Util_1$3.Util._sign(a)-h,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:t,height:a,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const p=this.anchorStyleFunc();p&&u.forEach(E=>{p(E)}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Group_1.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return Node_1$f.Node.prototype.toObject.call(this)}clone(e){var n=Node_1$f.Node.prototype.clone.call(this,e);return n}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Transformer$1.Transformer=Transformer;function validateAnchors(l){return l instanceof Array||Util_1$3.Util.warn("enabledAnchors value should be an array"),l instanceof Array&&l.forEach(function(e){ANCHORS_NAMES.indexOf(e)===-1&&Util_1$3.Util.warn("Unknown anchor name: "+e+". Available names are: "+ANCHORS_NAMES.join(", "))}),l||[]}Transformer.prototype.className="Transformer";(0,Global_2$1._registerNode)(Transformer);Factory_1$g.Factory.addGetterSetter(Transformer,"enabledAnchors",ANCHORS_NAMES,validateAnchors);Factory_1$g.Factory.addGetterSetter(Transformer,"flipEnabled",!0,(0,Validators_1$g.getBooleanValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"resizeEnabled",!0);Factory_1$g.Factory.addGetterSetter(Transformer,"anchorSize",10,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"rotateEnabled",!0);Factory_1$g.Factory.addGetterSetter(Transformer,"rotateLineVisible",!0);Factory_1$g.Factory.addGetterSetter(Transformer,"rotationSnaps",[]);Factory_1$g.Factory.addGetterSetter(Transformer,"rotateAnchorOffset",50,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"rotateAnchorCursor","crosshair");Factory_1$g.Factory.addGetterSetter(Transformer,"rotationSnapTolerance",5,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"borderEnabled",!0);Factory_1$g.Factory.addGetterSetter(Transformer,"anchorStroke","rgb(0, 161, 255)");Factory_1$g.Factory.addGetterSetter(Transformer,"anchorStrokeWidth",1,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"anchorFill","white");Factory_1$g.Factory.addGetterSetter(Transformer,"anchorCornerRadius",0,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"borderStroke","rgb(0, 161, 255)");Factory_1$g.Factory.addGetterSetter(Transformer,"borderStrokeWidth",1,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"borderDash");Factory_1$g.Factory.addGetterSetter(Transformer,"keepRatio",!0);Factory_1$g.Factory.addGetterSetter(Transformer,"shiftBehavior","default");Factory_1$g.Factory.addGetterSetter(Transformer,"centeredScaling",!1);Factory_1$g.Factory.addGetterSetter(Transformer,"ignoreStroke",!1);Factory_1$g.Factory.addGetterSetter(Transformer,"padding",0,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"node");Factory_1$g.Factory.addGetterSetter(Transformer,"nodes");Factory_1$g.Factory.addGetterSetter(Transformer,"boundBoxFunc");Factory_1$g.Factory.addGetterSetter(Transformer,"anchorDragBoundFunc");Factory_1$g.Factory.addGetterSetter(Transformer,"anchorStyleFunc");Factory_1$g.Factory.addGetterSetter(Transformer,"shouldOverdrawWholeArea",!1);Factory_1$g.Factory.addGetterSetter(Transformer,"useSingleNodeRotation",!0);Factory_1$g.Factory.backCompat(Transformer,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Wedge$1={};Object.defineProperty(Wedge$1,"__esModule",{value:!0});Wedge$1.Wedge=void 0;const Factory_1$f=Factory,Shape_1=Shape,Global_1=Global,Validators_1$f=Validators,Global_2=Global;class Wedge extends Shape_1.Shape{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,Global_1.Konva.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}Wedge$1.Wedge=Wedge;Wedge.prototype.className="Wedge";Wedge.prototype._centroid=!0;Wedge.prototype._attrsAffectingSize=["radius"];(0,Global_2._registerNode)(Wedge);Factory_1$f.Factory.addGetterSetter(Wedge,"radius",0,(0,Validators_1$f.getNumberValidator)());Factory_1$f.Factory.addGetterSetter(Wedge,"angle",0,(0,Validators_1$f.getNumberValidator)());Factory_1$f.Factory.addGetterSetter(Wedge,"clockwise",!1);Factory_1$f.Factory.backCompat(Wedge,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Blur$1={};Object.defineProperty(Blur$1,"__esModule",{value:!0});Blur$1.Blur=void 0;const Factory_1$e=Factory,Node_1$e=Node$1,Validators_1$e=Validators;function BlurStack(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var mul_table=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],shg_table=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function filterGaussBlurRGBA(l,e){var n=l.data,t=l.width,a=l.height,o,d,h,f,u,p,E,T,v,S,g,y,b,R,_,w,C,N,P,D,k,F,M,I,$=e+e+1,z=t-1,X=a-1,te=e+1,ae=te*(te+1)/2,ee=new BlurStack,K=null,ne=ee,ue=null,pe=null,J=mul_table[e],H=shg_table[e];for(h=1;h<$;h++)ne=ne.next=new BlurStack,h===te&&(K=ne);for(ne.next=ee,E=p=0,d=0;d<a;d++){for(w=C=N=P=T=v=S=g=0,y=te*(D=n[p]),b=te*(k=n[p+1]),R=te*(F=n[p+2]),_=te*(M=n[p+3]),T+=ae*D,v+=ae*k,S+=ae*F,g+=ae*M,ne=ee,h=0;h<te;h++)ne.r=D,ne.g=k,ne.b=F,ne.a=M,ne=ne.next;for(h=1;h<te;h++)f=p+((z<h?z:h)<<2),T+=(ne.r=D=n[f])*(I=te-h),v+=(ne.g=k=n[f+1])*I,S+=(ne.b=F=n[f+2])*I,g+=(ne.a=M=n[f+3])*I,w+=D,C+=k,N+=F,P+=M,ne=ne.next;for(ue=ee,pe=K,o=0;o<t;o++)n[p+3]=M=g*J>>H,M!==0?(M=255/M,n[p]=(T*J>>H)*M,n[p+1]=(v*J>>H)*M,n[p+2]=(S*J>>H)*M):n[p]=n[p+1]=n[p+2]=0,T-=y,v-=b,S-=R,g-=_,y-=ue.r,b-=ue.g,R-=ue.b,_-=ue.a,f=E+((f=o+e+1)<z?f:z)<<2,w+=ue.r=n[f],C+=ue.g=n[f+1],N+=ue.b=n[f+2],P+=ue.a=n[f+3],T+=w,v+=C,S+=N,g+=P,ue=ue.next,y+=D=pe.r,b+=k=pe.g,R+=F=pe.b,_+=M=pe.a,w-=D,C-=k,N-=F,P-=M,pe=pe.next,p+=4;E+=t}for(o=0;o<t;o++){for(C=N=P=w=v=S=g=T=0,p=o<<2,y=te*(D=n[p]),b=te*(k=n[p+1]),R=te*(F=n[p+2]),_=te*(M=n[p+3]),T+=ae*D,v+=ae*k,S+=ae*F,g+=ae*M,ne=ee,h=0;h<te;h++)ne.r=D,ne.g=k,ne.b=F,ne.a=M,ne=ne.next;for(u=t,h=1;h<=e;h++)p=u+o<<2,T+=(ne.r=D=n[p])*(I=te-h),v+=(ne.g=k=n[p+1])*I,S+=(ne.b=F=n[p+2])*I,g+=(ne.a=M=n[p+3])*I,w+=D,C+=k,N+=F,P+=M,ne=ne.next,h<X&&(u+=t);for(p=o,ue=ee,pe=K,d=0;d<a;d++)f=p<<2,n[f+3]=M=g*J>>H,M>0?(M=255/M,n[f]=(T*J>>H)*M,n[f+1]=(v*J>>H)*M,n[f+2]=(S*J>>H)*M):n[f]=n[f+1]=n[f+2]=0,T-=y,v-=b,S-=R,g-=_,y-=ue.r,b-=ue.g,R-=ue.b,_-=ue.a,f=o+((f=d+te)<X?f:X)*t<<2,T+=w+=ue.r=n[f],v+=C+=ue.g=n[f+1],S+=N+=ue.b=n[f+2],g+=P+=ue.a=n[f+3],ue=ue.next,y+=D=pe.r,b+=k=pe.g,R+=F=pe.b,_+=M=pe.a,w-=D,C-=k,N-=F,P-=M,pe=pe.next,p+=t}}const Blur=function l(e){var n=Math.round(this.blurRadius());n>0&&filterGaussBlurRGBA(e,n)};Blur$1.Blur=Blur;Factory_1$e.Factory.addGetterSetter(Node_1$e.Node,"blurRadius",0,(0,Validators_1$e.getNumberValidator)(),Factory_1$e.Factory.afterSetFilter);var Brighten$1={};Object.defineProperty(Brighten$1,"__esModule",{value:!0});Brighten$1.Brighten=void 0;const Factory_1$d=Factory,Node_1$d=Node$1,Validators_1$d=Validators,Brighten=function(l){var e=this.brightness()*255,n=l.data,t=n.length,a;for(a=0;a<t;a+=4)n[a]+=e,n[a+1]+=e,n[a+2]+=e};Brighten$1.Brighten=Brighten;Factory_1$d.Factory.addGetterSetter(Node_1$d.Node,"brightness",0,(0,Validators_1$d.getNumberValidator)(),Factory_1$d.Factory.afterSetFilter);var Contrast$1={};Object.defineProperty(Contrast$1,"__esModule",{value:!0});Contrast$1.Contrast=void 0;const Factory_1$c=Factory,Node_1$c=Node$1,Validators_1$c=Validators,Contrast=function(l){var e=Math.pow((this.contrast()+100)/100,2),n=l.data,t=n.length,a=150,o=150,d=150,h;for(h=0;h<t;h+=4)a=n[h],o=n[h+1],d=n[h+2],a/=255,a-=.5,a*=e,a+=.5,a*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,d/=255,d-=.5,d*=e,d+=.5,d*=255,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,d=d<0?0:d>255?255:d,n[h]=a,n[h+1]=o,n[h+2]=d};Contrast$1.Contrast=Contrast;Factory_1$c.Factory.addGetterSetter(Node_1$c.Node,"contrast",0,(0,Validators_1$c.getNumberValidator)(),Factory_1$c.Factory.afterSetFilter);var Emboss$1={};Object.defineProperty(Emboss$1,"__esModule",{value:!0});Emboss$1.Emboss=void 0;const Factory_1$b=Factory,Node_1$b=Node$1,Util_1$2=Util,Validators_1$b=Validators,Emboss=function(l){var e=this.embossStrength()*10,n=this.embossWhiteLevel()*255,t=this.embossDirection(),a=this.embossBlend(),o=0,d=0,h=l.data,f=l.width,u=l.height,p=f*4,E=u;switch(t){case"top-left":o=-1,d=-1;break;case"top":o=-1,d=0;break;case"top-right":o=-1,d=1;break;case"right":o=0,d=1;break;case"bottom-right":o=1,d=1;break;case"bottom":o=1,d=0;break;case"bottom-left":o=1,d=-1;break;case"left":o=0,d=-1;break;default:Util_1$2.Util.error("Unknown emboss direction: "+t)}do{var T=(E-1)*p,v=o;E+v<1&&(v=0),E+v>u&&(v=0);var S=(E-1+v)*f*4,g=f;do{var y=T+(g-1)*4,b=d;g+b<1&&(b=0),g+b>f&&(b=0);var R=S+(g-1+b)*4,_=h[y]-h[R],w=h[y+1]-h[R+1],C=h[y+2]-h[R+2],N=_,P=N>0?N:-N,D=w>0?w:-w,k=C>0?C:-C;if(D>P&&(N=w),k>P&&(N=C),N*=e,a){var F=h[y]+N,M=h[y+1]+N,I=h[y+2]+N;h[y]=F>255?255:F<0?0:F,h[y+1]=M>255?255:M<0?0:M,h[y+2]=I>255?255:I<0?0:I}else{var $=n-N;$<0?$=0:$>255&&($=255),h[y]=h[y+1]=h[y+2]=$}}while(--g)}while(--E)};Emboss$1.Emboss=Emboss;Factory_1$b.Factory.addGetterSetter(Node_1$b.Node,"embossStrength",.5,(0,Validators_1$b.getNumberValidator)(),Factory_1$b.Factory.afterSetFilter);Factory_1$b.Factory.addGetterSetter(Node_1$b.Node,"embossWhiteLevel",.5,(0,Validators_1$b.getNumberValidator)(),Factory_1$b.Factory.afterSetFilter);Factory_1$b.Factory.addGetterSetter(Node_1$b.Node,"embossDirection","top-left",null,Factory_1$b.Factory.afterSetFilter);Factory_1$b.Factory.addGetterSetter(Node_1$b.Node,"embossBlend",!1,null,Factory_1$b.Factory.afterSetFilter);var Enhance$1={};Object.defineProperty(Enhance$1,"__esModule",{value:!0});Enhance$1.Enhance=void 0;const Factory_1$a=Factory,Node_1$a=Node$1,Validators_1$a=Validators;function remap(l,e,n,t,a){var o=n-e,d=a-t,h;return o===0?t+d/2:d===0?t:(h=(l-e)/o,h=d*h+t,h)}const Enhance=function(l){var e=l.data,n=e.length,t=e[0],a=t,o,d=e[1],h=d,f,u=e[2],p=u,E,T,v=this.enhance();if(v!==0){for(T=0;T<n;T+=4)o=e[T+0],o<t?t=o:o>a&&(a=o),f=e[T+1],f<d?d=f:f>h&&(h=f),E=e[T+2],E<u?u=E:E>p&&(p=E);a===t&&(a=255,t=0),h===d&&(h=255,d=0),p===u&&(p=255,u=0);var S,g,y,b,R,_,w,C,N;for(v>0?(g=a+v*(255-a),y=t-v*(t-0),R=h+v*(255-h),_=d-v*(d-0),C=p+v*(255-p),N=u-v*(u-0)):(S=(a+t)*.5,g=a+v*(a-S),y=t+v*(t-S),b=(h+d)*.5,R=h+v*(h-b),_=d+v*(d-b),w=(p+u)*.5,C=p+v*(p-w),N=u+v*(u-w)),T=0;T<n;T+=4)e[T+0]=remap(e[T+0],t,a,y,g),e[T+1]=remap(e[T+1],d,h,_,R),e[T+2]=remap(e[T+2],u,p,N,C)}};Enhance$1.Enhance=Enhance;Factory_1$a.Factory.addGetterSetter(Node_1$a.Node,"enhance",0,(0,Validators_1$a.getNumberValidator)(),Factory_1$a.Factory.afterSetFilter);var Grayscale$1={};Object.defineProperty(Grayscale$1,"__esModule",{value:!0});Grayscale$1.Grayscale=void 0;const Grayscale=function(l){var e=l.data,n=e.length,t,a;for(t=0;t<n;t+=4)a=.34*e[t]+.5*e[t+1]+.16*e[t+2],e[t]=a,e[t+1]=a,e[t+2]=a};Grayscale$1.Grayscale=Grayscale;var HSL$1={};Object.defineProperty(HSL$1,"__esModule",{value:!0});HSL$1.HSL=void 0;const Factory_1$9=Factory,Node_1$9=Node$1,Validators_1$9=Validators;Factory_1$9.Factory.addGetterSetter(Node_1$9.Node,"hue",0,(0,Validators_1$9.getNumberValidator)(),Factory_1$9.Factory.afterSetFilter);Factory_1$9.Factory.addGetterSetter(Node_1$9.Node,"saturation",0,(0,Validators_1$9.getNumberValidator)(),Factory_1$9.Factory.afterSetFilter);Factory_1$9.Factory.addGetterSetter(Node_1$9.Node,"luminance",0,(0,Validators_1$9.getNumberValidator)(),Factory_1$9.Factory.afterSetFilter);const HSL=function(l){var e=l.data,n=e.length,t=1,a=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,d=this.luminance()*127,h,f=t*a*Math.cos(o*Math.PI/180),u=t*a*Math.sin(o*Math.PI/180),p=.299*t+.701*f+.167*u,E=.587*t-.587*f+.33*u,T=.114*t-.114*f-.497*u,v=.299*t-.299*f-.328*u,S=.587*t+.413*f+.035*u,g=.114*t-.114*f+.293*u,y=.299*t-.3*f+1.25*u,b=.587*t-.586*f-1.05*u,R=.114*t+.886*f-.2*u,_,w,C,N;for(h=0;h<n;h+=4)_=e[h+0],w=e[h+1],C=e[h+2],N=e[h+3],e[h+0]=p*_+E*w+T*C+d,e[h+1]=v*_+S*w+g*C+d,e[h+2]=y*_+b*w+R*C+d,e[h+3]=N};HSL$1.HSL=HSL;var HSV$1={};Object.defineProperty(HSV$1,"__esModule",{value:!0});HSV$1.HSV=void 0;const Factory_1$8=Factory,Node_1$8=Node$1,Validators_1$8=Validators,HSV=function(l){var e=l.data,n=e.length,t=Math.pow(2,this.value()),a=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,d,h=t*a*Math.cos(o*Math.PI/180),f=t*a*Math.sin(o*Math.PI/180),u=.299*t+.701*h+.167*f,p=.587*t-.587*h+.33*f,E=.114*t-.114*h-.497*f,T=.299*t-.299*h-.328*f,v=.587*t+.413*h+.035*f,S=.114*t-.114*h+.293*f,g=.299*t-.3*h+1.25*f,y=.587*t-.586*h-1.05*f,b=.114*t+.886*h-.2*f,R,_,w,C;for(d=0;d<n;d+=4)R=e[d+0],_=e[d+1],w=e[d+2],C=e[d+3],e[d+0]=u*R+p*_+E*w,e[d+1]=T*R+v*_+S*w,e[d+2]=g*R+y*_+b*w,e[d+3]=C};HSV$1.HSV=HSV;Factory_1$8.Factory.addGetterSetter(Node_1$8.Node,"hue",0,(0,Validators_1$8.getNumberValidator)(),Factory_1$8.Factory.afterSetFilter);Factory_1$8.Factory.addGetterSetter(Node_1$8.Node,"saturation",0,(0,Validators_1$8.getNumberValidator)(),Factory_1$8.Factory.afterSetFilter);Factory_1$8.Factory.addGetterSetter(Node_1$8.Node,"value",0,(0,Validators_1$8.getNumberValidator)(),Factory_1$8.Factory.afterSetFilter);var Invert$1={};Object.defineProperty(Invert$1,"__esModule",{value:!0});Invert$1.Invert=void 0;const Invert=function(l){var e=l.data,n=e.length,t;for(t=0;t<n;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]};Invert$1.Invert=Invert;var Kaleidoscope$1={};Object.defineProperty(Kaleidoscope$1,"__esModule",{value:!0});Kaleidoscope$1.Kaleidoscope=void 0;const Factory_1$7=Factory,Node_1$7=Node$1,Util_1$1=Util,Validators_1$7=Validators;var ToPolar=function(l,e,n){var t=l.data,a=e.data,o=l.width,d=l.height,h=n.polarCenterX||o/2,f=n.polarCenterY||d/2,u,p,E,T=0,v=0,S=0,g=0,y,b=Math.sqrt(h*h+f*f);p=o-h,E=d-f,y=Math.sqrt(p*p+E*E),b=y>b?y:b;var R=d,_=o,w,C,N=360/_*Math.PI/180,P,D;for(C=0;C<_;C+=1)for(P=Math.sin(C*N),D=Math.cos(C*N),w=0;w<R;w+=1)p=Math.floor(h+b*w/R*D),E=Math.floor(f+b*w/R*P),u=(E*o+p)*4,T=t[u+0],v=t[u+1],S=t[u+2],g=t[u+3],u=(C+w*o)*4,a[u+0]=T,a[u+1]=v,a[u+2]=S,a[u+3]=g},FromPolar=function(l,e,n){var t=l.data,a=e.data,o=l.width,d=l.height,h=n.polarCenterX||o/2,f=n.polarCenterY||d/2,u,p,E,T,v,S=0,g=0,y=0,b=0,R,_=Math.sqrt(h*h+f*f);p=o-h,E=d-f,R=Math.sqrt(p*p+E*E),_=R>_?R:_;var w=d,C=o,N,P,D=n.polarRotation||0,k,F;for(p=0;p<o;p+=1)for(E=0;E<d;E+=1)T=p-h,v=E-f,N=Math.sqrt(T*T+v*v)*w/_,P=(Math.atan2(v,T)*180/Math.PI+360+D)%360,P=P*C/360,k=Math.floor(P),F=Math.floor(N),u=(F*o+k)*4,S=t[u+0],g=t[u+1],y=t[u+2],b=t[u+3],u=(E*o+p)*4,a[u+0]=S,a[u+1]=g,a[u+2]=y,a[u+3]=b};const Kaleidoscope=function(l){var e=l.width,n=l.height,t,a,o,d,h,f,u,p,E,T,v=Math.round(this.kaleidoscopePower()),S=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(S%360)/360);if(!(v<1)){var y=Util_1$1.Util.createCanvasElement();y.width=e,y.height=n;var b=y.getContext("2d").getImageData(0,0,e,n);Util_1$1.Util.releaseCanvas(y),ToPolar(l,b,{polarCenterX:e/2,polarCenterY:n/2});for(var R=e/Math.pow(2,v);R<=8;)R=R*2,v-=1;R=Math.ceil(R);var _=R,w=0,C=_,N=1;for(g+R>e&&(w=_,C=0,N=-1),a=0;a<n;a+=1)for(t=w;t!==C;t+=N)o=Math.round(t+g)%e,E=(e*a+o)*4,h=b.data[E+0],f=b.data[E+1],u=b.data[E+2],p=b.data[E+3],T=(e*a+t)*4,b.data[T+0]=h,b.data[T+1]=f,b.data[T+2]=u,b.data[T+3]=p;for(a=0;a<n;a+=1)for(_=Math.floor(R),d=0;d<v;d+=1){for(t=0;t<_+1;t+=1)E=(e*a+t)*4,h=b.data[E+0],f=b.data[E+1],u=b.data[E+2],p=b.data[E+3],T=(e*a+_*2-t-1)*4,b.data[T+0]=h,b.data[T+1]=f,b.data[T+2]=u,b.data[T+3]=p;_*=2}FromPolar(b,l,{polarRotation:0})}};Kaleidoscope$1.Kaleidoscope=Kaleidoscope;Factory_1$7.Factory.addGetterSetter(Node_1$7.Node,"kaleidoscopePower",2,(0,Validators_1$7.getNumberValidator)(),Factory_1$7.Factory.afterSetFilter);Factory_1$7.Factory.addGetterSetter(Node_1$7.Node,"kaleidoscopeAngle",0,(0,Validators_1$7.getNumberValidator)(),Factory_1$7.Factory.afterSetFilter);var Mask$1={};Object.defineProperty(Mask$1,"__esModule",{value:!0});Mask$1.Mask=void 0;const Factory_1$6=Factory,Node_1$6=Node$1,Validators_1$6=Validators;function pixelAt(l,e,n){var t=(n*l.width+e)*4,a=[];return a.push(l.data[t++],l.data[t++],l.data[t++],l.data[t++]),a}function rgbDistance(l,e){return Math.sqrt(Math.pow(l[0]-e[0],2)+Math.pow(l[1]-e[1],2)+Math.pow(l[2]-e[2],2))}function rgbMean(l){for(var e=[0,0,0],n=0;n<l.length;n++)e[0]+=l[n][0],e[1]+=l[n][1],e[2]+=l[n][2];return e[0]/=l.length,e[1]/=l.length,e[2]/=l.length,e}function backgroundMask(l,e){var n=pixelAt(l,0,0),t=pixelAt(l,l.width-1,0),a=pixelAt(l,0,l.height-1),o=pixelAt(l,l.width-1,l.height-1),d=e||10;if(rgbDistance(n,t)<d&&rgbDistance(t,o)<d&&rgbDistance(o,a)<d&&rgbDistance(a,n)<d){for(var h=rgbMean([t,n,o,a]),f=[],u=0;u<l.width*l.height;u++){var p=rgbDistance(h,[l.data[u*4],l.data[u*4+1],l.data[u*4+2]]);f[u]=p<d?0:255}return f}}function applyMask(l,e){for(var n=0;n<l.width*l.height;n++)l.data[4*n+3]=e[n]}function erodeMask(l,e,n){for(var t=[1,1,1,1,0,1,1,1,1],a=Math.round(Math.sqrt(t.length)),o=Math.floor(a/2),d=[],h=0;h<n;h++)for(var f=0;f<e;f++){for(var u=h*e+f,p=0,E=0;E<a;E++)for(var T=0;T<a;T++){var v=h+E-o,S=f+T-o;if(v>=0&&v<n&&S>=0&&S<e){var g=v*e+S,y=t[E*a+T];p+=l[g]*y}}d[u]=p===255*8?255:0}return d}function dilateMask(l,e,n){for(var t=[1,1,1,1,1,1,1,1,1],a=Math.round(Math.sqrt(t.length)),o=Math.floor(a/2),d=[],h=0;h<n;h++)for(var f=0;f<e;f++){for(var u=h*e+f,p=0,E=0;E<a;E++)for(var T=0;T<a;T++){var v=h+E-o,S=f+T-o;if(v>=0&&v<n&&S>=0&&S<e){var g=v*e+S,y=t[E*a+T];p+=l[g]*y}}d[u]=p>=255*4?255:0}return d}function smoothEdgeMask(l,e,n){for(var t=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],a=Math.round(Math.sqrt(t.length)),o=Math.floor(a/2),d=[],h=0;h<n;h++)for(var f=0;f<e;f++){for(var u=h*e+f,p=0,E=0;E<a;E++)for(var T=0;T<a;T++){var v=h+E-o,S=f+T-o;if(v>=0&&v<n&&S>=0&&S<e){var g=v*e+S,y=t[E*a+T];p+=l[g]*y}}d[u]=p}return d}const Mask=function(l){var e=this.threshold(),n=backgroundMask(l,e);return n&&(n=erodeMask(n,l.width,l.height),n=dilateMask(n,l.width,l.height),n=smoothEdgeMask(n,l.width,l.height),applyMask(l,n)),l};Mask$1.Mask=Mask;Factory_1$6.Factory.addGetterSetter(Node_1$6.Node,"threshold",0,(0,Validators_1$6.getNumberValidator)(),Factory_1$6.Factory.afterSetFilter);var Noise$1={};Object.defineProperty(Noise$1,"__esModule",{value:!0});Noise$1.Noise=void 0;const Factory_1$5=Factory,Node_1$5=Node$1,Validators_1$5=Validators,Noise=function(l){var e=this.noise()*255,n=l.data,t=n.length,a=e/2,o;for(o=0;o<t;o+=4)n[o+0]+=a-2*a*Math.random(),n[o+1]+=a-2*a*Math.random(),n[o+2]+=a-2*a*Math.random()};Noise$1.Noise=Noise;Factory_1$5.Factory.addGetterSetter(Node_1$5.Node,"noise",.2,(0,Validators_1$5.getNumberValidator)(),Factory_1$5.Factory.afterSetFilter);var Pixelate$1={};Object.defineProperty(Pixelate$1,"__esModule",{value:!0});Pixelate$1.Pixelate=void 0;const Factory_1$4=Factory,Util_1=Util,Node_1$4=Node$1,Validators_1$4=Validators,Pixelate=function(l){var e=Math.ceil(this.pixelSize()),n=l.width,t=l.height,a,o,d,h,f,u,p,E=Math.ceil(n/e),T=Math.ceil(t/e),v,S,g,y,b,R,_,w=l.data;if(e<=0){Util_1.Util.error("pixelSize value can not be <= 0");return}for(b=0;b<E;b+=1)for(R=0;R<T;R+=1){for(h=0,f=0,u=0,p=0,v=b*e,S=v+e,g=R*e,y=g+e,_=0,a=v;a<S;a+=1)if(!(a>=n))for(o=g;o<y;o+=1)o>=t||(d=(n*o+a)*4,h+=w[d+0],f+=w[d+1],u+=w[d+2],p+=w[d+3],_+=1);for(h=h/_,f=f/_,u=u/_,p=p/_,a=v;a<S;a+=1)if(!(a>=n))for(o=g;o<y;o+=1)o>=t||(d=(n*o+a)*4,w[d+0]=h,w[d+1]=f,w[d+2]=u,w[d+3]=p)}};Pixelate$1.Pixelate=Pixelate;Factory_1$4.Factory.addGetterSetter(Node_1$4.Node,"pixelSize",8,(0,Validators_1$4.getNumberValidator)(),Factory_1$4.Factory.afterSetFilter);var Posterize$1={};Object.defineProperty(Posterize$1,"__esModule",{value:!0});Posterize$1.Posterize=void 0;const Factory_1$3=Factory,Node_1$3=Node$1,Validators_1$3=Validators,Posterize=function(l){var e=Math.round(this.levels()*254)+1,n=l.data,t=n.length,a=255/e,o;for(o=0;o<t;o+=1)n[o]=Math.floor(n[o]/a)*a};Posterize$1.Posterize=Posterize;Factory_1$3.Factory.addGetterSetter(Node_1$3.Node,"levels",.5,(0,Validators_1$3.getNumberValidator)(),Factory_1$3.Factory.afterSetFilter);var RGB$1={};Object.defineProperty(RGB$1,"__esModule",{value:!0});RGB$1.RGB=void 0;const Factory_1$2=Factory,Node_1$2=Node$1,Validators_1$2=Validators,RGB=function(l){var e=l.data,n=e.length,t=this.red(),a=this.green(),o=this.blue(),d,h;for(d=0;d<n;d+=4)h=(.34*e[d]+.5*e[d+1]+.16*e[d+2])/255,e[d]=h*t,e[d+1]=h*a,e[d+2]=h*o,e[d+3]=e[d+3]};RGB$1.RGB=RGB;Factory_1$2.Factory.addGetterSetter(Node_1$2.Node,"red",0,function(l){return this._filterUpToDate=!1,l>255?255:l<0?0:Math.round(l)});Factory_1$2.Factory.addGetterSetter(Node_1$2.Node,"green",0,function(l){return this._filterUpToDate=!1,l>255?255:l<0?0:Math.round(l)});Factory_1$2.Factory.addGetterSetter(Node_1$2.Node,"blue",0,Validators_1$2.RGBComponent,Factory_1$2.Factory.afterSetFilter);var RGBA$1={};Object.defineProperty(RGBA$1,"__esModule",{value:!0});RGBA$1.RGBA=void 0;const Factory_1$1=Factory,Node_1$1=Node$1,Validators_1$1=Validators,RGBA=function(l){var e=l.data,n=e.length,t=this.red(),a=this.green(),o=this.blue(),d=this.alpha(),h,f;for(h=0;h<n;h+=4)f=1-d,e[h]=t*d+e[h]*f,e[h+1]=a*d+e[h+1]*f,e[h+2]=o*d+e[h+2]*f};RGBA$1.RGBA=RGBA;Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"red",0,function(l){return this._filterUpToDate=!1,l>255?255:l<0?0:Math.round(l)});Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"green",0,function(l){return this._filterUpToDate=!1,l>255?255:l<0?0:Math.round(l)});Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"blue",0,Validators_1$1.RGBComponent,Factory_1$1.Factory.afterSetFilter);Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"alpha",1,function(l){return this._filterUpToDate=!1,l>1?1:l<0?0:l});var Sepia$1={};Object.defineProperty(Sepia$1,"__esModule",{value:!0});Sepia$1.Sepia=void 0;const Sepia=function(l){var e=l.data,n=e.length,t,a,o,d;for(t=0;t<n;t+=4)a=e[t+0],o=e[t+1],d=e[t+2],e[t+0]=Math.min(255,a*.393+o*.769+d*.189),e[t+1]=Math.min(255,a*.349+o*.686+d*.168),e[t+2]=Math.min(255,a*.272+o*.534+d*.131)};Sepia$1.Sepia=Sepia;var Solarize$1={};Object.defineProperty(Solarize$1,"__esModule",{value:!0});Solarize$1.Solarize=void 0;const Solarize=function(l){var e=l.data,n=l.width,t=l.height,a=n*4,o=t;do{var d=(o-1)*a,h=n;do{var f=d+(h-1)*4,u=e[f],p=e[f+1],E=e[f+2];u>127&&(u=255-u),p>127&&(p=255-p),E>127&&(E=255-E),e[f]=u,e[f+1]=p,e[f+2]=E}while(--h)}while(--o)};Solarize$1.Solarize=Solarize;var Threshold$1={};Object.defineProperty(Threshold$1,"__esModule",{value:!0});Threshold$1.Threshold=void 0;const Factory_1=Factory,Node_1=Node$1,Validators_1=Validators,Threshold=function(l){var e=this.threshold()*255,n=l.data,t=n.length,a;for(a=0;a<t;a+=1)n[a]=n[a]<e?0:255};Threshold$1.Threshold=Threshold;Factory_1.Factory.addGetterSetter(Node_1.Node,"threshold",.5,(0,Validators_1.getNumberValidator)(),Factory_1.Factory.afterSetFilter);Object.defineProperty(_FullInternals,"__esModule",{value:!0});_FullInternals.Konva=void 0;const _CoreInternals_1=_CoreInternals,Arc_1=Arc$1,Arrow_1=Arrow$1,Circle_1=Circle$1,Ellipse_1=Ellipse$1,Image_1=Image$4,Label_1=Label$1,Line_1=Line$2,Path_1=Path$1,Rect_1=Rect$2,RegularPolygon_1=RegularPolygon$1,Ring_1=Ring$1,Sprite_1=Sprite$1,Star_1=Star$1,Text_1=Text$2,TextPath_1=TextPath$1,Transformer_1=Transformer$1,Wedge_1=Wedge$1,Blur_1=Blur$1,Brighten_1=Brighten$1,Contrast_1=Contrast$1,Emboss_1=Emboss$1,Enhance_1=Enhance$1,Grayscale_1=Grayscale$1,HSL_1=HSL$1,HSV_1=HSV$1,Invert_1=Invert$1,Kaleidoscope_1=Kaleidoscope$1,Mask_1=Mask$1,Noise_1=Noise$1,Pixelate_1=Pixelate$1,Posterize_1=Posterize$1,RGB_1=RGB$1,RGBA_1=RGBA$1,Sepia_1=Sepia$1,Solarize_1=Solarize$1,Threshold_1=Threshold$1;_FullInternals.Konva=_CoreInternals_1.Konva.Util._assign(_CoreInternals_1.Konva,{Arc:Arc_1.Arc,Arrow:Arrow_1.Arrow,Circle:Circle_1.Circle,Ellipse:Ellipse_1.Ellipse,Image:Image_1.Image,Label:Label_1.Label,Tag:Label_1.Tag,Line:Line_1.Line,Path:Path_1.Path,Rect:Rect_1.Rect,RegularPolygon:RegularPolygon_1.RegularPolygon,Ring:Ring_1.Ring,Sprite:Sprite_1.Sprite,Star:Star_1.Star,Text:Text_1.Text,TextPath:TextPath_1.TextPath,Transformer:Transformer_1.Transformer,Wedge:Wedge_1.Wedge,Filters:{Blur:Blur_1.Blur,Brighten:Brighten_1.Brighten,Contrast:Contrast_1.Contrast,Emboss:Emboss_1.Emboss,Enhance:Enhance_1.Enhance,Grayscale:Grayscale_1.Grayscale,HSL:HSL_1.HSL,HSV:HSV_1.HSV,Invert:Invert_1.Invert,Kaleidoscope:Kaleidoscope_1.Kaleidoscope,Mask:Mask_1.Mask,Noise:Noise_1.Noise,Pixelate:Pixelate_1.Pixelate,Posterize:Posterize_1.Posterize,RGB:RGB_1.RGB,RGBA:RGBA_1.RGBA,Sepia:Sepia_1.Sepia,Solarize:Solarize_1.Solarize,Threshold:Threshold_1.Threshold}});var lib=lib$1.exports;Object.defineProperty(lib,"__esModule",{value:!0});const _FullInternals_1=_FullInternals;lib$1.exports=_FullInternals_1.Konva;var Core={exports:{}};(function(l,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;var n=_CoreInternals;Object.defineProperty(e,"Konva",{enumerable:!0,get:function(){return n.Konva}});const t=_CoreInternals;l.exports=t.Konva})(Core,Core.exports);var CoreExports=Core.exports;const Konva=getDefaultExportFromCjs(CoreExports);var reactReconciler={exports:{}},scheduler={exports:{}},scheduler_production_min={};/**
@@ -269,7 +269,7 @@ For more info see: https://github.com/konvajs/react-konva/issues/194
269
269
  */var _win,_doc,_docElement,_pluginInitted,_tempDiv,_recentSetterPlugin,_reverting,_windowExists=function l(){return typeof window<"u"},_transformProps={},_RAD2DEG=180/Math.PI,_DEG2RAD=Math.PI/180,_atan2=Math.atan2,_bigNum=1e8,_capsExp=/([A-Z])/g,_horizontalExp=/(left|right|width|margin|padding|x)/i,_complexExp=/[\s,\(]\S/,_propertyAliases={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},_renderCSSProp=function l(e,n){return n.set(n.t,n.p,Math.round((n.s+n.c*e)*1e4)/1e4+n.u,n)},_renderPropWithEnd=function l(e,n){return n.set(n.t,n.p,e===1?n.e:Math.round((n.s+n.c*e)*1e4)/1e4+n.u,n)},_renderCSSPropWithBeginning=function l(e,n){return n.set(n.t,n.p,e?Math.round((n.s+n.c*e)*1e4)/1e4+n.u:n.b,n)},_renderRoundedCSSProp=function l(e,n){var t=n.s+n.c*e;n.set(n.t,n.p,~~(t+(t<0?-.5:.5))+n.u,n)},_renderNonTweeningValue=function l(e,n){return n.set(n.t,n.p,e?n.e:n.b,n)},_renderNonTweeningValueOnlyAtEnd=function l(e,n){return n.set(n.t,n.p,e!==1?n.b:n.e,n)},_setterCSSStyle=function l(e,n,t){return e.style[n]=t},_setterCSSProp=function l(e,n,t){return e.style.setProperty(n,t)},_setterTransform=function l(e,n,t){return e._gsap[n]=t},_setterScale=function l(e,n,t){return e._gsap.scaleX=e._gsap.scaleY=t},_setterScaleWithRender=function l(e,n,t,a,o){var d=e._gsap;d.scaleX=d.scaleY=t,d.renderTransform(o,d)},_setterTransformWithRender=function l(e,n,t,a,o){var d=e._gsap;d[n]=t,d.renderTransform(o,d)},_transformProp="transform",_transformOriginProp=_transformProp+"Origin",_saveStyle=function l(e,n){var t=this,a=this.target,o=a.style,d=a._gsap;if(e in _transformProps&&o){if(this.tfm=this.tfm||{},e!=="transform")e=_propertyAliases[e]||e,~e.indexOf(",")?e.split(",").forEach(function(h){return t.tfm[h]=_get(a,h)}):this.tfm[e]=d.x?d[e]:_get(a,e),e===_transformOriginProp&&(this.tfm.zOrigin=d.zOrigin);else return _propertyAliases.transform.split(",").forEach(function(h){return l.call(t,h,n)});if(this.props.indexOf(_transformProp)>=0)return;d.svg&&(this.svgo=a.getAttribute("data-svg-origin"),this.props.push(_transformOriginProp,n,"")),e=_transformProp}(o||n)&&this.props.push(e,n,o[e])},_removeIndependentTransforms=function l(e){e.translate&&(e.removeProperty("translate"),e.removeProperty("scale"),e.removeProperty("rotate"))},_revertStyle=function l(){var e=this.props,n=this.target,t=n.style,a=n._gsap,o,d;for(o=0;o<e.length;o+=3)e[o+1]?n[e[o]]=e[o+2]:e[o+2]?t[e[o]]=e[o+2]:t.removeProperty(e[o].substr(0,2)==="--"?e[o]:e[o].replace(_capsExp,"-$1").toLowerCase());if(this.tfm){for(d in this.tfm)a[d]=this.tfm[d];a.svg&&(a.renderTransform(),n.setAttribute("data-svg-origin",this.svgo||"")),o=_reverting(),(!o||!o.isStart)&&!t[_transformProp]&&(_removeIndependentTransforms(t),a.zOrigin&&t[_transformOriginProp]&&(t[_transformOriginProp]+=" "+a.zOrigin+"px",a.zOrigin=0,a.renderTransform()),a.uncache=1)}},_getStyleSaver=function l(e,n){var t={target:e,props:[],revert:_revertStyle,save:_saveStyle};return e._gsap||gsap.core.getCache(e),n&&n.split(",").forEach(function(a){return t.save(a)}),t},_supports3D,_createElement=function l(e,n){var t=_doc.createElementNS?_doc.createElementNS((n||"http://www.w3.org/1999/xhtml").replace(/^https/,"http"),e):_doc.createElement(e);return t&&t.style?t:_doc.createElement(e)},_getComputedProperty=function l(e,n,t){var a=getComputedStyle(e);return a[n]||a.getPropertyValue(n.replace(_capsExp,"-$1").toLowerCase())||a.getPropertyValue(n)||!t&&l(e,_checkPropPrefix(n)||n,1)||""},_prefixes="O,Moz,ms,Ms,Webkit".split(","),_checkPropPrefix=function l(e,n,t){var a=n||_tempDiv,o=a.style,d=5;if(e in o&&!t)return e;for(e=e.charAt(0).toUpperCase()+e.substr(1);d--&&!(_prefixes[d]+e in o););return d<0?null:(d===3?"ms":d>=0?_prefixes[d]:"")+e},_initCore=function l(){_windowExists()&&window.document&&(_win=window,_doc=_win.document,_docElement=_doc.documentElement,_tempDiv=_createElement("div")||{style:{}},_createElement("div"),_transformProp=_checkPropPrefix(_transformProp),_transformOriginProp=_transformProp+"Origin",_tempDiv.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",_supports3D=!!_checkPropPrefix("perspective"),_reverting=gsap.core.reverting,_pluginInitted=1)},_getBBoxHack=function l(e){var n=_createElement("svg",this.ownerSVGElement&&this.ownerSVGElement.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),t=this.parentNode,a=this.nextSibling,o=this.style.cssText,d;if(_docElement.appendChild(n),n.appendChild(this),this.style.display="block",e)try{d=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=l}catch{}else this._gsapBBox&&(d=this._gsapBBox());return t&&(a?t.insertBefore(this,a):t.appendChild(this)),_docElement.removeChild(n),this.style.cssText=o,d},_getAttributeFallbacks=function l(e,n){for(var t=n.length;t--;)if(e.hasAttribute(n[t]))return e.getAttribute(n[t])},_getBBox=function l(e){var n;try{n=e.getBBox()}catch{n=_getBBoxHack.call(e,!0)}return n&&(n.width||n.height)||e.getBBox===_getBBoxHack||(n=_getBBoxHack.call(e,!0)),n&&!n.width&&!n.x&&!n.y?{x:+_getAttributeFallbacks(e,["x","cx","x1"])||0,y:+_getAttributeFallbacks(e,["y","cy","y1"])||0,width:0,height:0}:n},_isSVG=function l(e){return!!(e.getCTM&&(!e.parentNode||e.ownerSVGElement)&&_getBBox(e))},_removeProperty=function l(e,n){if(n){var t=e.style,a;n in _transformProps&&n!==_transformOriginProp&&(n=_transformProp),t.removeProperty?(a=n.substr(0,2),(a==="ms"||n.substr(0,6)==="webkit")&&(n="-"+n),t.removeProperty(a==="--"?n:n.replace(_capsExp,"-$1").toLowerCase())):t.removeAttribute(n)}},_addNonTweeningPT=function l(e,n,t,a,o,d){var h=new PropTween(e._pt,n,t,0,1,d?_renderNonTweeningValueOnlyAtEnd:_renderNonTweeningValue);return e._pt=h,h.b=a,h.e=o,e._props.push(t),h},_nonConvertibleUnits={deg:1,rad:1,turn:1},_nonStandardLayouts={grid:1,flex:1},_convertToUnit=function l(e,n,t,a){var o=parseFloat(t)||0,d=(t+"").trim().substr((o+"").length)||"px",h=_tempDiv.style,f=_horizontalExp.test(n),u=e.tagName.toLowerCase()==="svg",p=(u?"client":"offset")+(f?"Width":"Height"),E=100,T=a==="px",v=a==="%",S,g,y,b;if(a===d||!o||_nonConvertibleUnits[a]||_nonConvertibleUnits[d])return o;if(d!=="px"&&!T&&(o=l(e,n,t,"px")),b=e.getCTM&&_isSVG(e),(v||d==="%")&&(_transformProps[n]||~n.indexOf("adius")))return S=b?e.getBBox()[f?"width":"height"]:e[p],_round(v?o/S*E:o/100*S);if(h[f?"width":"height"]=E+(T?d:a),g=~n.indexOf("adius")||a==="em"&&e.appendChild&&!u?e:e.parentNode,b&&(g=(e.ownerSVGElement||{}).parentNode),(!g||g===_doc||!g.appendChild)&&(g=_doc.body),y=g._gsap,y&&v&&y.width&&f&&y.time===_ticker.time&&!y.uncache)return _round(o/y.width*E);if(v&&(n==="height"||n==="width")){var R=e.style[n];e.style[n]=E+a,S=e[p],R?e.style[n]=R:_removeProperty(e,n)}else(v||d==="%")&&!_nonStandardLayouts[_getComputedProperty(g,"display")]&&(h.position=_getComputedProperty(e,"position")),g===e&&(h.position="static"),g.appendChild(_tempDiv),S=_tempDiv[p],g.removeChild(_tempDiv),h.position="absolute";return f&&v&&(y=_getCache(g),y.time=_ticker.time,y.width=g[p]),_round(T?S*o/E:S&&o?E/S*o:0)},_get=function l(e,n,t,a){var o;return _pluginInitted||_initCore(),n in _propertyAliases&&n!=="transform"&&(n=_propertyAliases[n],~n.indexOf(",")&&(n=n.split(",")[0])),_transformProps[n]&&n!=="transform"?(o=_parseTransform(e,a),o=n!=="transformOrigin"?o[n]:o.svg?o.origin:_firstTwoOnly(_getComputedProperty(e,_transformOriginProp))+" "+o.zOrigin+"px"):(o=e.style[n],(!o||o==="auto"||a||~(o+"").indexOf("calc("))&&(o=_specialProps[n]&&_specialProps[n](e,n,t)||_getComputedProperty(e,n)||_getProperty(e,n)||(n==="opacity"?1:0))),t&&!~(o+"").trim().indexOf(" ")?_convertToUnit(e,n,o,t)+t:o},_tweenComplexCSSString=function l(e,n,t,a){if(!t||t==="none"){var o=_checkPropPrefix(n,e,1),d=o&&_getComputedProperty(e,o,1);d&&d!==t?(n=o,t=d):n==="borderColor"&&(t=_getComputedProperty(e,"borderTopColor"))}var h=new PropTween(this._pt,e.style,n,0,1,_renderComplexString),f=0,u=0,p,E,T,v,S,g,y,b,R,_,w,C;if(h.b=t,h.e=a,t+="",a+="",a==="auto"&&(g=e.style[n],e.style[n]=a,a=_getComputedProperty(e,n)||a,g?e.style[n]=g:_removeProperty(e,n)),p=[t,a],_colorStringFilter(p),t=p[0],a=p[1],T=t.match(_numWithUnitExp)||[],C=a.match(_numWithUnitExp)||[],C.length){for(;E=_numWithUnitExp.exec(a);)y=E[0],R=a.substring(f,E.index),S?S=(S+1)%5:(R.substr(-5)==="rgba("||R.substr(-5)==="hsla(")&&(S=1),y!==(g=T[u++]||"")&&(v=parseFloat(g)||0,w=g.substr((v+"").length),y.charAt(1)==="="&&(y=_parseRelative(v,y)+w),b=parseFloat(y),_=y.substr((b+"").length),f=_numWithUnitExp.lastIndex-_.length,_||(_=_||_config.units[n]||w,f===a.length&&(a+=_,h.e+=_)),w!==_&&(v=_convertToUnit(e,n,g,_)||0),h._pt={_next:h._pt,p:R||u===1?R:",",s:v,c:b-v,m:S&&S<4||n==="zIndex"?Math.round:0});h.c=f<a.length?a.substring(f,a.length):""}else h.r=n==="display"&&a==="none"?_renderNonTweeningValueOnlyAtEnd:_renderNonTweeningValue;return _relExp.test(a)&&(h.e=0),this._pt=h,h},_keywordToPercent={top:"0%",bottom:"100%",left:"0%",right:"100%",center:"50%"},_convertKeywordsToPercentages=function l(e){var n=e.split(" "),t=n[0],a=n[1]||"50%";return(t==="top"||t==="bottom"||a==="left"||a==="right")&&(e=t,t=a,a=e),n[0]=_keywordToPercent[t]||t,n[1]=_keywordToPercent[a]||a,n.join(" ")},_renderClearProps=function l(e,n){if(n.tween&&n.tween._time===n.tween._dur){var t=n.t,a=t.style,o=n.u,d=t._gsap,h,f,u;if(o==="all"||o===!0)a.cssText="",f=1;else for(o=o.split(","),u=o.length;--u>-1;)h=o[u],_transformProps[h]&&(f=1,h=h==="transformOrigin"?_transformOriginProp:_transformProp),_removeProperty(t,h);f&&(_removeProperty(t,_transformProp),d&&(d.svg&&t.removeAttribute("transform"),_parseTransform(t,1),d.uncache=1,_removeIndependentTransforms(a)))}},_specialProps={clearProps:function l(e,n,t,a,o){if(o.data!=="isFromStart"){var d=e._pt=new PropTween(e._pt,n,t,0,0,_renderClearProps);return d.u=a,d.pr=-10,d.tween=o,e._props.push(t),1}}},_identity2DMatrix=[1,0,0,1,0,0],_rotationalProperties={},_isNullTransform=function l(e){return e==="matrix(1, 0, 0, 1, 0, 0)"||e==="none"||!e},_getComputedTransformMatrixAsArray=function l(e){var n=_getComputedProperty(e,_transformProp);return _isNullTransform(n)?_identity2DMatrix:n.substr(7).match(_numExp).map(_round)},_getMatrix=function l(e,n){var t=e._gsap||_getCache(e),a=e.style,o=_getComputedTransformMatrixAsArray(e),d,h,f,u;return t.svg&&e.getAttribute("transform")?(f=e.transform.baseVal.consolidate().matrix,o=[f.a,f.b,f.c,f.d,f.e,f.f],o.join(",")==="1,0,0,1,0,0"?_identity2DMatrix:o):(o===_identity2DMatrix&&!e.offsetParent&&e!==_docElement&&!t.svg&&(f=a.display,a.display="block",d=e.parentNode,(!d||!e.offsetParent)&&(u=1,h=e.nextElementSibling,_docElement.appendChild(e)),o=_getComputedTransformMatrixAsArray(e),f?a.display=f:_removeProperty(e,"display"),u&&(h?d.insertBefore(e,h):d?d.appendChild(e):_docElement.removeChild(e))),n&&o.length>6?[o[0],o[1],o[4],o[5],o[12],o[13]]:o)},_applySVGOrigin=function l(e,n,t,a,o,d){var h=e._gsap,f=o||_getMatrix(e,!0),u=h.xOrigin||0,p=h.yOrigin||0,E=h.xOffset||0,T=h.yOffset||0,v=f[0],S=f[1],g=f[2],y=f[3],b=f[4],R=f[5],_=n.split(" "),w=parseFloat(_[0])||0,C=parseFloat(_[1])||0,N,P,D,k;t?f!==_identity2DMatrix&&(P=v*y-S*g)&&(D=w*(y/P)+C*(-g/P)+(g*R-y*b)/P,k=w*(-S/P)+C*(v/P)-(v*R-S*b)/P,w=D,C=k):(N=_getBBox(e),w=N.x+(~_[0].indexOf("%")?w/100*N.width:w),C=N.y+(~(_[1]||_[0]).indexOf("%")?C/100*N.height:C)),a||a!==!1&&h.smooth?(b=w-u,R=C-p,h.xOffset=E+(b*v+R*g)-b,h.yOffset=T+(b*S+R*y)-R):h.xOffset=h.yOffset=0,h.xOrigin=w,h.yOrigin=C,h.smooth=!!a,h.origin=n,h.originIsAbsolute=!!t,e.style[_transformOriginProp]="0px 0px",d&&(_addNonTweeningPT(d,h,"xOrigin",u,w),_addNonTweeningPT(d,h,"yOrigin",p,C),_addNonTweeningPT(d,h,"xOffset",E,h.xOffset),_addNonTweeningPT(d,h,"yOffset",T,h.yOffset)),e.setAttribute("data-svg-origin",w+" "+C)},_parseTransform=function l(e,n){var t=e._gsap||new GSCache(e);if("x"in t&&!n&&!t.uncache)return t;var a=e.style,o=t.scaleX<0,d="px",h="deg",f=getComputedStyle(e),u=_getComputedProperty(e,_transformOriginProp)||"0",p,E,T,v,S,g,y,b,R,_,w,C,N,P,D,k,F,M,I,$,z,X,te,ae,ee,K,ne,ue,pe,J,H,W;return p=E=T=g=y=b=R=_=w=0,v=S=1,t.svg=!!(e.getCTM&&_isSVG(e)),f.translate&&((f.translate!=="none"||f.scale!=="none"||f.rotate!=="none")&&(a[_transformProp]=(f.translate!=="none"?"translate3d("+(f.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(f.rotate!=="none"?"rotate("+f.rotate+") ":"")+(f.scale!=="none"?"scale("+f.scale.split(" ").join(",")+") ":"")+(f[_transformProp]!=="none"?f[_transformProp]:"")),a.scale=a.rotate=a.translate="none"),P=_getMatrix(e,t.svg),t.svg&&(t.uncache?(ee=e.getBBox(),u=t.xOrigin-ee.x+"px "+(t.yOrigin-ee.y)+"px",ae=""):ae=!n&&e.getAttribute("data-svg-origin"),_applySVGOrigin(e,ae||u,!!ae||t.originIsAbsolute,t.smooth!==!1,P)),C=t.xOrigin||0,N=t.yOrigin||0,P!==_identity2DMatrix&&(M=P[0],I=P[1],$=P[2],z=P[3],p=X=P[4],E=te=P[5],P.length===6?(v=Math.sqrt(M*M+I*I),S=Math.sqrt(z*z+$*$),g=M||I?_atan2(I,M)*_RAD2DEG:0,R=$||z?_atan2($,z)*_RAD2DEG+g:0,R&&(S*=Math.abs(Math.cos(R*_DEG2RAD))),t.svg&&(p-=C-(C*M+N*$),E-=N-(C*I+N*z))):(W=P[6],J=P[7],ne=P[8],ue=P[9],pe=P[10],H=P[11],p=P[12],E=P[13],T=P[14],D=_atan2(W,pe),y=D*_RAD2DEG,D&&(k=Math.cos(-D),F=Math.sin(-D),ae=X*k+ne*F,ee=te*k+ue*F,K=W*k+pe*F,ne=X*-F+ne*k,ue=te*-F+ue*k,pe=W*-F+pe*k,H=J*-F+H*k,X=ae,te=ee,W=K),D=_atan2(-$,pe),b=D*_RAD2DEG,D&&(k=Math.cos(-D),F=Math.sin(-D),ae=M*k-ne*F,ee=I*k-ue*F,K=$*k-pe*F,H=z*F+H*k,M=ae,I=ee,$=K),D=_atan2(I,M),g=D*_RAD2DEG,D&&(k=Math.cos(D),F=Math.sin(D),ae=M*k+I*F,ee=X*k+te*F,I=I*k-M*F,te=te*k-X*F,M=ae,X=ee),y&&Math.abs(y)+Math.abs(g)>359.9&&(y=g=0,b=180-b),v=_round(Math.sqrt(M*M+I*I+$*$)),S=_round(Math.sqrt(te*te+W*W)),D=_atan2(X,te),R=Math.abs(D)>2e-4?D*_RAD2DEG:0,w=H?1/(H<0?-H:H):0),t.svg&&(ae=e.getAttribute("transform"),t.forceCSS=e.setAttribute("transform","")||!_isNullTransform(_getComputedProperty(e,_transformProp)),ae&&e.setAttribute("transform",ae))),Math.abs(R)>90&&Math.abs(R)<270&&(o?(v*=-1,R+=g<=0?180:-180,g+=g<=0?180:-180):(S*=-1,R+=R<=0?180:-180)),n=n||t.uncache,t.x=p-((t.xPercent=p&&(!n&&t.xPercent||(Math.round(e.offsetWidth/2)===Math.round(-p)?-50:0)))?e.offsetWidth*t.xPercent/100:0)+d,t.y=E-((t.yPercent=E&&(!n&&t.yPercent||(Math.round(e.offsetHeight/2)===Math.round(-E)?-50:0)))?e.offsetHeight*t.yPercent/100:0)+d,t.z=T+d,t.scaleX=_round(v),t.scaleY=_round(S),t.rotation=_round(g)+h,t.rotationX=_round(y)+h,t.rotationY=_round(b)+h,t.skewX=R+h,t.skewY=_+h,t.transformPerspective=w+d,(t.zOrigin=parseFloat(u.split(" ")[2])||!n&&t.zOrigin||0)&&(a[_transformOriginProp]=_firstTwoOnly(u)),t.xOffset=t.yOffset=0,t.force3D=_config.force3D,t.renderTransform=t.svg?_renderSVGTransforms:_supports3D?_renderCSSTransforms:_renderNon3DTransforms,t.uncache=0,t},_firstTwoOnly=function l(e){return(e=e.split(" "))[0]+" "+e[1]},_addPxTranslate=function l(e,n,t){var a=getUnit(n);return _round(parseFloat(n)+parseFloat(_convertToUnit(e,"x",t+"px",a)))+a},_renderNon3DTransforms=function l(e,n){n.z="0px",n.rotationY=n.rotationX="0deg",n.force3D=0,_renderCSSTransforms(e,n)},_zeroDeg="0deg",_zeroPx="0px",_endParenthesis=") ",_renderCSSTransforms=function l(e,n){var t=n||this,a=t.xPercent,o=t.yPercent,d=t.x,h=t.y,f=t.z,u=t.rotation,p=t.rotationY,E=t.rotationX,T=t.skewX,v=t.skewY,S=t.scaleX,g=t.scaleY,y=t.transformPerspective,b=t.force3D,R=t.target,_=t.zOrigin,w="",C=b==="auto"&&e&&e!==1||b===!0;if(_&&(E!==_zeroDeg||p!==_zeroDeg)){var N=parseFloat(p)*_DEG2RAD,P=Math.sin(N),D=Math.cos(N),k;N=parseFloat(E)*_DEG2RAD,k=Math.cos(N),d=_addPxTranslate(R,d,P*k*-_),h=_addPxTranslate(R,h,-Math.sin(N)*-_),f=_addPxTranslate(R,f,D*k*-_+_)}y!==_zeroPx&&(w+="perspective("+y+_endParenthesis),(a||o)&&(w+="translate("+a+"%, "+o+"%) "),(C||d!==_zeroPx||h!==_zeroPx||f!==_zeroPx)&&(w+=f!==_zeroPx||C?"translate3d("+d+", "+h+", "+f+") ":"translate("+d+", "+h+_endParenthesis),u!==_zeroDeg&&(w+="rotate("+u+_endParenthesis),p!==_zeroDeg&&(w+="rotateY("+p+_endParenthesis),E!==_zeroDeg&&(w+="rotateX("+E+_endParenthesis),(T!==_zeroDeg||v!==_zeroDeg)&&(w+="skew("+T+", "+v+_endParenthesis),(S!==1||g!==1)&&(w+="scale("+S+", "+g+_endParenthesis),R.style[_transformProp]=w||"translate(0, 0)"},_renderSVGTransforms=function l(e,n){var t=n||this,a=t.xPercent,o=t.yPercent,d=t.x,h=t.y,f=t.rotation,u=t.skewX,p=t.skewY,E=t.scaleX,T=t.scaleY,v=t.target,S=t.xOrigin,g=t.yOrigin,y=t.xOffset,b=t.yOffset,R=t.forceCSS,_=parseFloat(d),w=parseFloat(h),C,N,P,D,k;f=parseFloat(f),u=parseFloat(u),p=parseFloat(p),p&&(p=parseFloat(p),u+=p,f+=p),f||u?(f*=_DEG2RAD,u*=_DEG2RAD,C=Math.cos(f)*E,N=Math.sin(f)*E,P=Math.sin(f-u)*-T,D=Math.cos(f-u)*T,u&&(p*=_DEG2RAD,k=Math.tan(u-p),k=Math.sqrt(1+k*k),P*=k,D*=k,p&&(k=Math.tan(p),k=Math.sqrt(1+k*k),C*=k,N*=k)),C=_round(C),N=_round(N),P=_round(P),D=_round(D)):(C=E,D=T,N=P=0),(_&&!~(d+"").indexOf("px")||w&&!~(h+"").indexOf("px"))&&(_=_convertToUnit(v,"x",d,"px"),w=_convertToUnit(v,"y",h,"px")),(S||g||y||b)&&(_=_round(_+S-(S*C+g*P)+y),w=_round(w+g-(S*N+g*D)+b)),(a||o)&&(k=v.getBBox(),_=_round(_+a/100*k.width),w=_round(w+o/100*k.height)),k="matrix("+C+","+N+","+P+","+D+","+_+","+w+")",v.setAttribute("transform",k),R&&(v.style[_transformProp]=k)},_addRotationalPropTween=function l(e,n,t,a,o){var d=360,h=_isString(o),f=parseFloat(o)*(h&&~o.indexOf("rad")?_RAD2DEG:1),u=f-a,p=a+u+"deg",E,T;return h&&(E=o.split("_")[1],E==="short"&&(u%=d,u!==u%(d/2)&&(u+=u<0?d:-d)),E==="cw"&&u<0?u=(u+d*_bigNum)%d-~~(u/d)*d:E==="ccw"&&u>0&&(u=(u-d*_bigNum)%d-~~(u/d)*d)),e._pt=T=new PropTween(e._pt,n,t,a,u,_renderPropWithEnd),T.e=p,T.u="deg",e._props.push(t),T},_assign=function l(e,n){for(var t in n)e[t]=n[t];return e},_addRawTransformPTs=function l(e,n,t){var a=_assign({},t._gsap),o="perspective,force3D,transformOrigin,svgOrigin",d=t.style,h,f,u,p,E,T,v,S;a.svg?(u=t.getAttribute("transform"),t.setAttribute("transform",""),d[_transformProp]=n,h=_parseTransform(t,1),_removeProperty(t,_transformProp),t.setAttribute("transform",u)):(u=getComputedStyle(t)[_transformProp],d[_transformProp]=n,h=_parseTransform(t,1),d[_transformProp]=u);for(f in _transformProps)u=a[f],p=h[f],u!==p&&o.indexOf(f)<0&&(v=getUnit(u),S=getUnit(p),E=v!==S?_convertToUnit(t,f,u,S):parseFloat(u),T=parseFloat(p),e._pt=new PropTween(e._pt,h,f,E,T-E,_renderCSSProp),e._pt.u=S||0,e._props.push(f));_assign(h,a)};_forEachName("padding,margin,Width,Radius",function(l,e){var n="Top",t="Right",a="Bottom",o="Left",d=(e<3?[n,t,a,o]:[n+o,n+t,a+t,a+o]).map(function(h){return e<2?l+h:"border"+h+l});_specialProps[e>1?"border"+l:l]=function(h,f,u,p,E){var T,v;if(arguments.length<4)return T=d.map(function(S){return _get(h,S,u)}),v=T.join(" "),v.split(T[0]).length===5?T[0]:v;T=(p+"").split(" "),v={},d.forEach(function(S,g){return v[S]=T[g]=T[g]||T[(g-1)/2|0]}),h.init(f,v,E)}});var CSSPlugin={name:"css",register:_initCore,targetTest:function l(e){return e.style&&e.nodeType},init:function l(e,n,t,a,o){var d=this._props,h=e.style,f=t.vars.startAt,u,p,E,T,v,S,g,y,b,R,_,w,C,N,P,D;_pluginInitted||_initCore(),this.styles=this.styles||_getStyleSaver(e),D=this.styles.props,this.tween=t;for(g in n)if(g!=="autoRound"&&(p=n[g],!(_plugins[g]&&_checkPlugin(g,n,t,a,e,o)))){if(v=typeof p,S=_specialProps[g],v==="function"&&(p=p.call(t,a,e,o),v=typeof p),v==="string"&&~p.indexOf("random(")&&(p=_replaceRandom(p)),S)S(this,e,g,p,t)&&(P=1);else if(g.substr(0,2)==="--")u=(getComputedStyle(e).getPropertyValue(g)+"").trim(),p+="",_colorExp.lastIndex=0,_colorExp.test(u)||(y=getUnit(u),b=getUnit(p)),b?y!==b&&(u=_convertToUnit(e,g,u,b)+b):y&&(p+=y),this.add(h,"setProperty",u,p,a,o,0,0,g),d.push(g),D.push(g,0,h[g]);else if(v!=="undefined"){if(f&&g in f?(u=typeof f[g]=="function"?f[g].call(t,a,e,o):f[g],_isString(u)&&~u.indexOf("random(")&&(u=_replaceRandom(u)),getUnit(u+"")||u==="auto"||(u+=_config.units[g]||getUnit(_get(e,g))||""),(u+"").charAt(1)==="="&&(u=_get(e,g))):u=_get(e,g),T=parseFloat(u),R=v==="string"&&p.charAt(1)==="="&&p.substr(0,2),R&&(p=p.substr(2)),E=parseFloat(p),g in _propertyAliases&&(g==="autoAlpha"&&(T===1&&_get(e,"visibility")==="hidden"&&E&&(T=0),D.push("visibility",0,h.visibility),_addNonTweeningPT(this,h,"visibility",T?"inherit":"hidden",E?"inherit":"hidden",!E)),g!=="scale"&&g!=="transform"&&(g=_propertyAliases[g],~g.indexOf(",")&&(g=g.split(",")[0]))),_=g in _transformProps,_){if(this.styles.save(g),w||(C=e._gsap,C.renderTransform&&!n.parseTransform||_parseTransform(e,n.parseTransform),N=n.smoothOrigin!==!1&&C.smooth,w=this._pt=new PropTween(this._pt,h,_transformProp,0,1,C.renderTransform,C,0,-1),w.dep=1),g==="scale")this._pt=new PropTween(this._pt,C,"scaleY",C.scaleY,(R?_parseRelative(C.scaleY,R+E):E)-C.scaleY||0,_renderCSSProp),this._pt.u=0,d.push("scaleY",g),g+="X";else if(g==="transformOrigin"){D.push(_transformOriginProp,0,h[_transformOriginProp]),p=_convertKeywordsToPercentages(p),C.svg?_applySVGOrigin(e,p,0,N,0,this):(b=parseFloat(p.split(" ")[2])||0,b!==C.zOrigin&&_addNonTweeningPT(this,C,"zOrigin",C.zOrigin,b),_addNonTweeningPT(this,h,g,_firstTwoOnly(u),_firstTwoOnly(p)));continue}else if(g==="svgOrigin"){_applySVGOrigin(e,p,1,N,0,this);continue}else if(g in _rotationalProperties){_addRotationalPropTween(this,C,g,T,R?_parseRelative(T,R+p):p);continue}else if(g==="smoothOrigin"){_addNonTweeningPT(this,C,"smooth",C.smooth,p);continue}else if(g==="force3D"){C[g]=p;continue}else if(g==="transform"){_addRawTransformPTs(this,p,e);continue}}else g in h||(g=_checkPropPrefix(g)||g);if(_||(E||E===0)&&(T||T===0)&&!_complexExp.test(p)&&g in h)y=(u+"").substr((T+"").length),E||(E=0),b=getUnit(p)||(g in _config.units?_config.units[g]:y),y!==b&&(T=_convertToUnit(e,g,u,b)),this._pt=new PropTween(this._pt,_?C:h,g,T,(R?_parseRelative(T,R+E):E)-T,!_&&(b==="px"||g==="zIndex")&&n.autoRound!==!1?_renderRoundedCSSProp:_renderCSSProp),this._pt.u=b||0,y!==b&&b!=="%"&&(this._pt.b=u,this._pt.r=_renderCSSPropWithBeginning);else if(g in h)_tweenComplexCSSString.call(this,e,g,u,R?R+p:p);else if(g in e)this.add(e,g,u||e[g],R?R+p:p,a,o);else if(g!=="parseTransform"){_missingPlugin(g,p);continue}_||(g in h?D.push(g,0,h[g]):D.push(g,1,u||e[g])),d.push(g)}}P&&_sortPropTweensByPriority(this)},render:function l(e,n){if(n.tween._time||!_reverting())for(var t=n._pt;t;)t.r(e,t.d),t=t._next;else n.styles.revert()},get:_get,aliases:_propertyAliases,getSetter:function l(e,n,t){var a=_propertyAliases[n];return a&&a.indexOf(",")<0&&(n=a),n in _transformProps&&n!==_transformOriginProp&&(e._gsap.x||_get(e,"x"))?t&&_recentSetterPlugin===t?n==="scale"?_setterScale:_setterTransform:(_recentSetterPlugin=t||{})&&(n==="scale"?_setterScaleWithRender:_setterTransformWithRender):e.style&&!_isUndefined(e.style[n])?_setterCSSStyle:~n.indexOf("-")?_setterCSSProp:_getSetter(e,n)},core:{_removeProperty,_getMatrix}};gsap.utils.checkPrefix=_checkPropPrefix;gsap.core.getStyleSaver=_getStyleSaver;(function(l,e,n,t){var a=_forEachName(l+","+e+","+n,function(o){_transformProps[o]=1});_forEachName(e,function(o){_config.units[o]="deg",_rotationalProperties[o]=1}),_propertyAliases[a[13]]=l+","+e,_forEachName(t,function(o){var d=o.split(":");_propertyAliases[d[1]]=a[d[0]]})})("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY");_forEachName("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(l){_config.units[l]="px"});gsap.registerPlugin(CSSPlugin);var gsapWithCSS=gsap.registerPlugin(CSSPlugin)||gsap;gsapWithCSS.core.Tween;function SpeechBubbleComponent({message:l,translate:e},n){const[t,a]=React$2.useState(!1),o=()=>{const d=l.avatar,h=d.lastIndexOf("/");return d.includes("/object/")?d.slice(0,h).concat("/mini-thumbnail.png"):d.includes("/character/")?d.slice(0,h).concat("/mini-face.png"):d};return React$2.useLayoutEffect(()=>{t||a(!0)},[t]),jsxRuntimeExports.jsxs("div",{dir:"auto",ref:n,className:`
270
270
  speech-bubble
271
271
  ${l.thinkful?"speech-bubble--italic":""}
272
- `,children:[jsxRuntimeExports.jsxs("div",{className:`speech-bubble__header ${l.thinkful?"speech-bubble__header--thinking":""}`,children:[l.thinkful?jsxRuntimeExports.jsx("div",{className:"thinking-icon-wrap",children:jsxRuntimeExports.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,l.avatar?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("img",{src:o(),alt:l.name})}):null,l.voiceOver?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("div",{className:"icon-narrator"})}):null,jsxRuntimeExports.jsxs("div",{className:"speech-bubble__name",children:[jsxRuntimeExports.jsx("span",{children:l.name}),l.thinkful?jsxRuntimeExports.jsxs("span",{children:["[ ",e("emotion.thinking")," ]"]}):null]})]}),l.text?jsxRuntimeExports.jsx("div",{className:"speech-bubble__text",children:HTMLReactParser$1(l.text)}):null]})}const SpeechBubbleComponent$1=React$2.forwardRef(SpeechBubbleComponent);function BubbleWrapper({currentMessage:l,translate:e}){const n=document.querySelector(".screens--container");return jsxRuntimeExports.jsx("group",{children:jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:n?{current:n}:void 0,style:{width:"100%",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(SpeechBubbleComponent$1,{translate:e,message:l})})})}const cache={},loader=new GLTFLoader;function useStateMachine(l){const e=fiber.useThree(u=>u.scene),n=React$2.useMemo(()=>{var p;const u={};for(const E of l)if(E.slots)for(const T of E.slots){if(!T.uid)continue;const v=(p=T.character)==null?void 0:p.resource.animations;v&&(u[T.uid]||(u[T.uid]=Object.keys(v).reduce((S,g)=>(S[g]=v[g].url,S),{})))}return u},[l]),t=React$2.useMemo(()=>{const u=new Set;for(const p of l)if(p.slots)for(const E of p.slots)E.uid&&u.add(E.uid);return Array.from(u)},[l]),a=async u=>{const p=n[u];if(!cache[p.talking]){const{animations:T}=await loader.loadAsync(p.talking);T[0].name="talking",cache[p.talking]=T[0]}},o=()=>{t.forEach(u=>{f(u,"idle")})},d=()=>{t.forEach(u=>{const p=e.getObjectByProperty("uid",u);p&&(delete p.userData._active,f(u,"idle"))})},h=async(u,p,E)=>{const T=getCurrentVisible(u,e);if(cache[u]||(cache[u]={}),!T)return new Promise(S=>S(!1));const v=T.userData.animator;if(p){const S=n[u];let g=cache[S.talking],y=p,b=cache[p];if(!b){const{animations:R}=await loader.loadAsync(p);b=cache[p]=R[0]}if(E&&S.talking!==p&&(g?(b=mixWithTalkingClip(g,b),y+="_talking"):a(u).then(()=>{g=cache[S.talking],b=mixWithTalkingClip(g,b),y+="_talking"})),!T.userData._active||T.userData._active!==y){T.userData._active=y;const R=v.register(y,b);return new Promise(_=>{v.mix(y).then(w=>_(w?R:!1))})}}return new Promise(S=>S(!1))},f=async(u,p)=>{const E=getCurrentVisible(u,e);if(cache[u]||(cache[u]={}),!E)return new Promise(v=>v(!1));const T=E.userData.animator;if(p==="idle")return T.mix("idle"),T.getAction("idle");{const v=n[u],S=p.split("_")[0],g=v[S],y=cache[v.talking];if(g){let b=cache[g];if(!b){const{animations:R}=await loader.loadAsync(g);b=cache[g]=R[0]}if(p.includes("talking")&&p!=="talking"&&(b=mixWithTalkingClip(y,b)),!E.userData._active||E.userData._active!==p){E.userData._active=p;const R=T.register(p,b);return new Promise(_=>{T.mix(p).then(w=>_(w?R:!1))})}}}return new Promise(v=>v(!1))};return{startAnimation:f,startAnimationUrl:h,preloadTalking:a,resetActives:o,unmountActives:d}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:l,emitEvent:e,getEvent:n,lines:t,actors:a,edges:o,soundActions:d,zoomInActor:h,autoPlay:f,autoEnd:u,pause:p,progress:E}){var Pt;const T=t.length-1<=(E==null?void 0:E.line)?t.length-1:(E==null?void 0:E.line)||0,[v,S]=React$2.useState(T),[g,y]=React$2.useState(!!f),[b,R]=React$2.useState(!1),[_,w]=React$2.useState(!1),C=fiber.useThree(Ke=>Ke.scene),N=fiber.useThree(Ke=>Ke.camera),{start:P,stop:D}=useTimeout(),k=React$2.useRef([]),F=React$2.useMemo(()=>N.clone(),[]),M=React$2.useRef({pos:[0,0,0],child:null}),I=t[v],$=t[v-1],z=React$2.useRef(!1),X=!!o,{voiceOver:te,decision:ae}=I||{},ee=React$2.useRef({}),K=(Pt=I==null?void 0:I.slots)==null?void 0:Pt.find(Ke=>Ke.talking),ne=React$2.useRef(!1),{startAnimation:ue,startAnimationUrl:pe,resetActives:J,preloadTalking:H,unmountActives:W}=useStateMachine(t),V=React$2.useRef(),B=Object.keys((I==null?void 0:I.audio)||{}).length,Y=Object.keys((I==null?void 0:I.voice)||{}).length,re=te||(I==null?void 0:I.type)==="conversationalNarration",le=ae||(I==null?void 0:I.type)==="conversationalDecision",fe=(I==null?void 0:I.type)==="conversationalCamera",de=g&&!le&&!fe,[ge,Ee]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Re=React$2.useMemo(()=>t.reduce((Ke,vt)=>(vt.slots&&vt.slots.filter(At=>At.uid).forEach(At=>{Ke.includes(At.uid)||Ke.push(At.uid)}),Ke),[]),[t]),Oe=React$2.useCallback(Ke=>n({type:"translate",payload:Ke}),[n]),[Ne,Xe]=React$2.useState([]),ft=React$2.useMemo(()=>Ne[Ne.length-1],[Ne]),nt=React$2.useCallback(()=>{const Ke=o.find(Ue=>Ue.fromId===ft)||o.find(Ue=>Ue.toId===ft),vt=t.find(Ue=>Ue.id===(Ke==null?void 0:Ke.fromId));return!ft&&(E==null?void 0:E.line)>=0?{decision:!0}:vt},[o,t,ft]),St=React$2.useCallback(()=>{if(X){const vt=nt();return vt==null?void 0:vt.decision}const Ke=t[v-1]?t[v-1]:{};return v>0&&(Ke==null?void 0:Ke.decision)},[I,X,t,ft,o]),ze=React$2.useCallback(()=>{if(X){const vt=nt();return(vt==null?void 0:vt.type)==="conversationalCamera"}const Ke=t[v-1]?t[v-1]:{};return v>0&&(Ke==null?void 0:Ke.type)==="conversationalCamera"},[I,X,t,ft,o]),Me=React$2.useCallback(Ke=>{var Ue,At;const vt=a.find(st=>(st==null?void 0:st.uid)===(Ke==null?void 0:Ke.uid)?st:"");return((At=(Ue=Ke==null?void 0:Ke.character)==null?void 0:Ue.resource)==null?void 0:At.url)||(vt==null?void 0:vt.completeUrl)||""},[a]),ke=(Ke=()=>{})=>{if(ne.current)ne.current&&(ne.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const vt=M.current.child?M.current.pos:F.position.toArray();if(animationTarget.position.fromArray(vt),M.current.parent){animationTarget.quaternion.equals(N.quaternion)||animationTarget.applyQuaternion(N.quaternion);const Ue=M.current.isLeft?-1:1,At=headSize*Ue;animationTarget.translateX(-10*Ue+At),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{ne.current=!0},onUpdate:()=>{k.current.length&&k.current.forEach(Ue=>{const{object:At}=Ue;At.material.visible=!0})},onComplete:()=>{Ke(),raycast.set(N.getWorldPosition(new three.Vector3(0,0,0)),N.getWorldDirection(new three.Vector3));const Ue=raycast.intersectObjects(C.children,!0);k.current=Ue.filter(At=>At.distance<10),k.current.length&&k.current.forEach(At=>{const{object:st}=At;st.material.side=0}),ne.current=!1,z.current&&e({type:"success"}),M.current.child||N.copy(F)},...animationTarget.position})}},We=React$2.useCallback(()=>{M.current.child=null,M.current.parent=null,h&&ke()},[h]),tt=(Ke,vt,Ue,At=!1)=>{const st=vt.includes("seated");Ue?pe(Ke,Ue.url,vt.includes("talking")).then(xe=>{xe&&BASIC_ACTIONS_TYPES_WHITELIST.includes(Ue.animationId)&&(z.current?ue(Ke,"idle"):ue(Ke,V.current===Ke?"neutral_talking":"neutral"))}):ue(Ke,At&&!st?`${vt}-seated`:vt)},ct=()=>{if(!(K!=null&&K.emotion)||z.current)return;const{emotion:Ke,uid:vt,animation:Ue}=K,At=getCurrentVisible(vt,C);if(At){const{isSeated:st}=At;H(vt).then(()=>{tt(vt,st&&!Ke.includes("seated")?`${Ke}-seated_talking`:`${Ke}_talking`,Ue,st),Ue&&BASIC_ACTIONS_TYPES_WHITELIST.includes(Ue.animationId)&&(V.current=vt)})}},Dt=()=>{if(!(K!=null&&K.uid)||z.current)return;const{emotion:Ke,uid:vt,animation:Ue}=K,At=getCurrentVisible(vt,C);if(At){const{isSeated:st}=At;V.current===vt?(tt(vt,"neutral",null,st),V.current=null):tt(vt,Ke,Ue,st)}},rt=React$2.useCallback(()=>{z.current=!0,Ee({show:!1}),We(),J(),h||e({type:"success"})},[N,e,We,h]);React$2.useEffect(()=>()=>{ee.current={},W()},[]);const Et=Ke=>{Ee({show:!1}),S(Ke),e({type:"notifyProgress",payload:{line:Ke}})},$e=React$2.useCallback((Ke=!0)=>{const vt=Ke?["fromId","toId"]:["toId","fromId"],Ue=o.filter(xe=>xe[vt[0]]===I.id),At=Ue.length===1?Ue[0]:Ue.find(xe=>xe[vt[1]]===ft);if(!(At!=null&&At[vt[0]])){rt();return}Ke||Xe(Ne.slice(0,Ne.length-1));const st=t.findIndex(xe=>xe.id===At[vt[1]]);st>=0?Et(st):rt()},[I==null?void 0:I.id,e,o,rt,t]),pt=React$2.useCallback((Ke,vt)=>{const Ue=[3,2,1][Ke.id],st=o.filter(ie=>ie.fromId===(I==null?void 0:I.id)).find(ie=>parseInt(ie.fromPointIndex)===Ue),xe=t.findIndex(ie=>ie.id===(st==null?void 0:st.toId));xe>=0?(st==null?void 0:st.fromId)===(st==null?void 0:st.toId)?vt():Et(xe):rt()},[I==null?void 0:I.id,o,rt,t]),He=React$2.useCallback(()=>{if(ee.current={...K},w(!1),Dt(),X)$e(!1);else if(!St()){const Ke=v-1;Ee({show:!1}),S(Ke),e({type:"notifyProgress",payload:{line:Ke}})}},[$e,e,X,$,v,K]),Ye=React$2.useCallback(Ke=>{if(X){if(Ke){const vt=[3,2,1][Ke.id],At=o.filter(st=>st.fromId===I.id).find(st=>parseInt(st.fromPointIndex)===vt);if(At){const st=t.findIndex(xe=>xe.id===At.toId);st>=0&&e({type:"notifyProgress",payload:{line:st}})}else e({type:"saveNode"})}}else if(v<t.length-1){const vt=v+1;e({type:"notifyProgress",payload:{line:vt}})}else e({type:"saveNode"})},[o,v,t,e,I==null?void 0:I.id,X]),Pe=React$2.useCallback((Ke,vt)=>{if(ee.current={...K},Xe([...Ne,I.id]),w(!1),Dt(),X)Ke?pt(Ke,vt):$e();else if(v<t.length-1){const Ue=v+1;Et(Ue)}else(u||le||fe)&&rt()},[e,I==null?void 0:I.id,X,le,fe,v,t.length,pt,$e,rt,K]),we=()=>{y(!1),He()},ye=()=>X?I&&I.type!=="conversationalDecision"&&!o.find(Ke=>Ke.fromId===I.id):v===t.length-1,De=()=>{ye()?rt():(y(!1),Pe())};React$2.useEffect(()=>{if(X&&!b){const Ke=E==null?void 0:E.line;if(Ke>=0){R(!0),S(Ke);return}const vt=t.filter(Ue=>!o.find(At=>At.toId===Ue.id));if(vt.length){const Ue=vt[0],At=t.indexOf(Ue);At>=0&&(R(!0),S(At))}}},[o,X,t,b]);const qe=Ke=>{if(ee.current.uid===Ke.uid||M.current.parent===Ke)return;const vt=new three.Object3D,Ue=Ke.getObjectByName("Head_M");Ue.updateMatrixWorld(!0),vt.applyMatrix4(Ue.matrixWorld),vt.applyQuaternion(N.quaternion);const At=h?2.5:2,st=h?1.2:1.5;vt.translateY(At),vt.translateX(st);const xe=new three.Vector3;xe.setFromMatrixPosition(Ue.matrixWorld);const me=xe.project(N).x<0;M.current={pos:vt.position.toArray(),child:Ue,parent:Ke,isLeft:me}},Lt=Ke=>{e({type:"resetZIndexUIContainer",payload:Ke})};React$2.useEffect(()=>{var Ke;if(re)We(),Ee({text:I==null?void 0:I.text,name:(I==null?void 0:I.alias)||(I==null?void 0:I.name)||`[ ${Oe("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Me(K),show:!0});else if(!z.current&&!le&&!fe){const vt=I==null?void 0:I.slots.filter(st=>st.uid&&!st.talking),Ue=[...vt.map(st=>st.uid)||[],K==null?void 0:K.uid];if(Re.filter(st=>!Ue.includes(st)).forEach(st=>{ue(st,"idle")}),vt.forEach(st=>{const xe=getCurrentVisible(st.uid,C);if(xe){const{isSeated:ie}=xe;tt(st.uid,st.emotion,st.animation,ie)}}),K){const st=getCurrentVisible(K.uid,C),xe=a.find(ie=>ie.uid===K.uid);st&&!z.current?setTimeout(()=>{var ie,me;if(K.uid===st.uid){qe(st);const{isSeated:Se,userData:Ce}=st,{emotion:ce,animation:be}=K;!((ie=Ce._active)!=null&&ie.includes("talking"))&&!((me=Ce._active)!=null&&me.includes(ce))&&tt(K.uid,ce,be,Se);const Ie=()=>{var Je;Ee({text:K.text,name:K.alias||((Je=K.character)==null?void 0:Je.name),inScene:!0,thinkful:K.emotion.includes("think"),avatar:Me(K),show:!0})};h?(ne.current=!1,ke(Ie)):Ie()}},150):(We(),Ee({text:K.text,name:K.alias||((Ke=K.character)==null?void 0:Ke.name)||(xe==null?void 0:xe.name),left:!1,top:K.text.length>maxCharacterToSwitch,inScene:!1,thinkful:K.emotion.includes("think"),avatar:Me(K),show:!0}))}else We(),Ee({show:!0})}},[a,I,h,C,Oe,Me,We,le,re,Re]);const kt=cleanTextOfHtmlTags(ge==null?void 0:ge.text),Le=useEkho({audioType:I==null?void 0:I.audioType,volume:I==null?void 0:I.audioVolume,voice:I==null?void 0:I.voice,started:ge.show,text:kt,audio:I==null?void 0:I.audio,soundActions:d,getEvent:n,pauseTTS:p,onStart:()=>{var Ke;(Ke=K==null?void 0:K.emotion)!=null&&Ke.includes("think")||ct()},onError:()=>{Dt(),w(!0)},onFinish:()=>{Dt(),de&&!p&&Pe()}});React$2.useEffect(()=>(Le(),()=>{Le()}),[v,Le]),React$2.useEffect(()=>{var Ke;if(((I==null?void 0:I.audioType)==="none"||_)&&(ge!=null&&ge.show)&&!(K!=null&&K.emotion.includes("think"))){ct();const vt=characterMs*(((Ke=ge==null?void 0:ge.text)==null?void 0:Ke.length)||0);setTimeout(()=>{Dt()},vt<minMs?minMs:vt)}},[_,I==null?void 0:I.audioType,K==null?void 0:K.emotion,ge]),React$2.useEffect(()=>{var Ke;if(de&&ge.show&&((I==null?void 0:I.audioType)==="none"||_)&&!p){const vt=characterMs*(((Ke=ge==null?void 0:ge.text)==null?void 0:Ke.length)||0);(!ye()||ye()&&u)&&P(Pe,vt<minMs?minMs:vt)}return()=>{D()}},[ge,Pe,P,u,D,I==null?void 0:I.audioType,de,B,Y,_]);const ht=React$2.useMemo(()=>v===0||St()||ze(),[v,St,ze]),wt=l({disabled:le||!ge.show,repeat:!1,forward:De,rewind:ht?null:we});React$2.useEffect(()=>wt(),[wt]);const at=document.querySelector(".screens--container");if(fe)return jsxRuntimeExports.jsx(ChangeCamera,{...I,emitEvent:e,success:!1,onFinish:Pe},`change-camera-${v}`);if(le){const Ke=I.id?t.filter(Ue=>Ue.decision).findIndex(Ue=>Ue.id===I.id)+1:t.filter(Ue=>Ue.decision).findIndex(Ue=>Ue===I)+1,vt={...I.payload,decisionNumber:Ke,inheritProps:{slots:[],disableBackground:!0},required:!X,branched:X,onAddPoints:Ye,onFinish:Pe,emitEvent:e,getEvent:n,pause:p,soundActions:d,keyboardControl:l};return jsxRuntimeExports.jsx(HtmlWrap,{onMount:()=>{We(),Lt(!0)},onUnMount:()=>{ne.current=!1,Lt(!1)},children:jsxRuntimeExports.jsx(DecisionComponent,{inScene:!0,...vt})})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[ge.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:Oe,currentMessage:ge}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:at?{current:at}:void 0,zIndexRange:[6,6],onOcclude:()=>{},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"ltr",className:"dialog-component-controls",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:we,disabled:ht||!ge.show,className:`gat--btn__round ${ht||!ge.show?"disabled":""}`,"aria-label":LangIsRtl()?Oe("storylines.misc.forward"):Oe("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:De,disabled:!ge.show,className:`gat--btn__round
272
+ `,children:[jsxRuntimeExports.jsxs("div",{className:`speech-bubble__header ${l.thinkful?"speech-bubble__header--thinking":""}`,children:[l.thinkful?jsxRuntimeExports.jsx("div",{className:"thinking-icon-wrap",children:jsxRuntimeExports.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,l.avatar?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("img",{src:o(),alt:l.name})}):null,l.voiceOver?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("div",{className:"icon-narrator"})}):null,jsxRuntimeExports.jsxs("div",{className:"speech-bubble__name",children:[jsxRuntimeExports.jsx("span",{children:l.name}),l.thinkful?jsxRuntimeExports.jsxs("span",{children:["[ ",e("emotion.thinking")," ]"]}):null]})]}),l.text?jsxRuntimeExports.jsx("div",{className:"speech-bubble__text",children:HTMLReactParser$1(l.text)}):null]})}const SpeechBubbleComponent$1=React$2.forwardRef(SpeechBubbleComponent);function BubbleWrapper({currentMessage:l,translate:e}){const n=document.querySelector(".screens--container");return jsxRuntimeExports.jsx("group",{children:jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:n?{current:n}:void 0,style:{width:"100vw",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(SpeechBubbleComponent$1,{translate:e,message:l})})})}const cache={},loader=new GLTFLoader;function useStateMachine(l){const e=fiber.useThree(u=>u.scene),n=React$2.useMemo(()=>{var p;const u={};for(const E of l)if(E.slots)for(const T of E.slots){if(!T.uid)continue;const v=(p=T.character)==null?void 0:p.resource.animations;v&&(u[T.uid]||(u[T.uid]=Object.keys(v).reduce((S,g)=>(S[g]=v[g].url,S),{})))}return u},[l]),t=React$2.useMemo(()=>{const u=new Set;for(const p of l)if(p.slots)for(const E of p.slots)E.uid&&u.add(E.uid);return Array.from(u)},[l]),a=async u=>{const p=n[u];if(!cache[p.talking]){const{animations:T}=await loader.loadAsync(p.talking);T[0].name="talking",cache[p.talking]=T[0]}},o=()=>{t.forEach(u=>{f(u,"idle")})},d=()=>{t.forEach(u=>{const p=e.getObjectByProperty("uid",u);p&&(delete p.userData._active,f(u,"idle"))})},h=async(u,p,E)=>{const T=getCurrentVisible(u,e);if(cache[u]||(cache[u]={}),!T)return new Promise(S=>S(!1));const v=T.userData.animator;if(p){const S=n[u];let g=cache[S.talking],y=p,b=cache[p];if(!b){const{animations:R}=await loader.loadAsync(p);b=cache[p]=R[0]}if(E&&S.talking!==p&&(g?(b=mixWithTalkingClip(g,b),y+="_talking"):a(u).then(()=>{g=cache[S.talking],b=mixWithTalkingClip(g,b),y+="_talking"})),!T.userData._active||T.userData._active!==y){T.userData._active=y;const R=v.register(y,b);return new Promise(_=>{v.mix(y).then(w=>_(w?R:!1))})}}return new Promise(S=>S(!1))},f=async(u,p)=>{const E=getCurrentVisible(u,e);if(cache[u]||(cache[u]={}),!E)return new Promise(v=>v(!1));const T=E.userData.animator;if(p==="idle")return T.mix("idle"),T.getAction("idle");{const v=n[u],S=p.split("_")[0],g=v[S],y=cache[v.talking];if(g){let b=cache[g];if(!b){const{animations:R}=await loader.loadAsync(g);b=cache[g]=R[0]}if(p.includes("talking")&&p!=="talking"&&(b=mixWithTalkingClip(y,b)),!E.userData._active||E.userData._active!==p){E.userData._active=p;const R=T.register(p,b);return new Promise(_=>{T.mix(p).then(w=>_(w?R:!1))})}}}return new Promise(v=>v(!1))};return{startAnimation:f,startAnimationUrl:h,preloadTalking:a,resetActives:o,unmountActives:d}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:l,emitEvent:e,getEvent:n,lines:t,actors:a,edges:o,soundActions:d,zoomInActor:h,autoPlay:f,autoEnd:u,pause:p,progress:E}){var Pt;const T=t.length-1<=(E==null?void 0:E.line)?t.length-1:(E==null?void 0:E.line)||0,[v,S]=React$2.useState(T),[g,y]=React$2.useState(!!f),[b,R]=React$2.useState(!1),[_,w]=React$2.useState(!1),C=fiber.useThree(Ke=>Ke.scene),N=fiber.useThree(Ke=>Ke.camera),{start:P,stop:D}=useTimeout(),k=React$2.useRef([]),F=React$2.useMemo(()=>N.clone(),[]),M=React$2.useRef({pos:[0,0,0],child:null}),I=t[v],$=t[v-1],z=React$2.useRef(!1),X=!!o,{voiceOver:te,decision:ae}=I||{},ee=React$2.useRef({}),K=(Pt=I==null?void 0:I.slots)==null?void 0:Pt.find(Ke=>Ke.talking),ne=React$2.useRef(!1),{startAnimation:ue,startAnimationUrl:pe,resetActives:J,preloadTalking:H,unmountActives:W}=useStateMachine(t),V=React$2.useRef(),B=Object.keys((I==null?void 0:I.audio)||{}).length,Y=Object.keys((I==null?void 0:I.voice)||{}).length,re=te||(I==null?void 0:I.type)==="conversationalNarration",le=ae||(I==null?void 0:I.type)==="conversationalDecision",fe=(I==null?void 0:I.type)==="conversationalCamera",de=g&&!le&&!fe,[ge,Ee]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Re=React$2.useMemo(()=>t.reduce((Ke,vt)=>(vt.slots&&vt.slots.filter(At=>At.uid).forEach(At=>{Ke.includes(At.uid)||Ke.push(At.uid)}),Ke),[]),[t]),Oe=React$2.useCallback(Ke=>n({type:"translate",payload:Ke}),[n]),[Ne,Xe]=React$2.useState([]),ft=React$2.useMemo(()=>Ne[Ne.length-1],[Ne]),nt=React$2.useCallback(()=>{const Ke=o.find(Ue=>Ue.fromId===ft)||o.find(Ue=>Ue.toId===ft),vt=t.find(Ue=>Ue.id===(Ke==null?void 0:Ke.fromId));return!ft&&(E==null?void 0:E.line)>=0?{decision:!0}:vt},[o,t,ft]),St=React$2.useCallback(()=>{if(X){const vt=nt();return vt==null?void 0:vt.decision}const Ke=t[v-1]?t[v-1]:{};return v>0&&(Ke==null?void 0:Ke.decision)},[I,X,t,ft,o]),ze=React$2.useCallback(()=>{if(X){const vt=nt();return(vt==null?void 0:vt.type)==="conversationalCamera"}const Ke=t[v-1]?t[v-1]:{};return v>0&&(Ke==null?void 0:Ke.type)==="conversationalCamera"},[I,X,t,ft,o]),Me=React$2.useCallback(Ke=>{var Ue,At;const vt=a.find(st=>(st==null?void 0:st.uid)===(Ke==null?void 0:Ke.uid)?st:"");return((At=(Ue=Ke==null?void 0:Ke.character)==null?void 0:Ue.resource)==null?void 0:At.url)||(vt==null?void 0:vt.completeUrl)||""},[a]),ke=(Ke=()=>{})=>{if(ne.current)ne.current&&(ne.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const vt=M.current.child?M.current.pos:F.position.toArray();if(animationTarget.position.fromArray(vt),M.current.parent){animationTarget.quaternion.equals(N.quaternion)||animationTarget.applyQuaternion(N.quaternion);const Ue=M.current.isLeft?-1:1,At=headSize*Ue;animationTarget.translateX(-10*Ue+At),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{ne.current=!0},onUpdate:()=>{k.current.length&&k.current.forEach(Ue=>{const{object:At}=Ue;At.material.visible=!0})},onComplete:()=>{Ke(),raycast.set(N.getWorldPosition(new three.Vector3(0,0,0)),N.getWorldDirection(new three.Vector3));const Ue=raycast.intersectObjects(C.children,!0);k.current=Ue.filter(At=>At.distance<10),k.current.length&&k.current.forEach(At=>{const{object:st}=At;st.material.side=0}),ne.current=!1,z.current&&e({type:"success"}),M.current.child||N.copy(F)},...animationTarget.position})}},We=React$2.useCallback(()=>{M.current.child=null,M.current.parent=null,h&&ke()},[h]),tt=(Ke,vt,Ue,At=!1)=>{const st=vt.includes("seated");Ue?pe(Ke,Ue.url,vt.includes("talking")).then(xe=>{xe&&BASIC_ACTIONS_TYPES_WHITELIST.includes(Ue.animationId)&&(z.current?ue(Ke,"idle"):ue(Ke,V.current===Ke?"neutral_talking":"neutral"))}):ue(Ke,At&&!st?`${vt}-seated`:vt)},ct=()=>{if(!(K!=null&&K.emotion)||z.current)return;const{emotion:Ke,uid:vt,animation:Ue}=K,At=getCurrentVisible(vt,C);if(At){const{isSeated:st}=At;H(vt).then(()=>{tt(vt,st&&!Ke.includes("seated")?`${Ke}-seated_talking`:`${Ke}_talking`,Ue,st),Ue&&BASIC_ACTIONS_TYPES_WHITELIST.includes(Ue.animationId)&&(V.current=vt)})}},Dt=()=>{if(!(K!=null&&K.uid)||z.current)return;const{emotion:Ke,uid:vt,animation:Ue}=K,At=getCurrentVisible(vt,C);if(At){const{isSeated:st}=At;V.current===vt?(tt(vt,"neutral",null,st),V.current=null):tt(vt,Ke,Ue,st)}},rt=React$2.useCallback(()=>{z.current=!0,Ee({show:!1}),We(),J(),h||e({type:"success"})},[N,e,We,h]);React$2.useEffect(()=>()=>{ee.current={},W()},[]);const Et=Ke=>{Ee({show:!1}),S(Ke),e({type:"notifyProgress",payload:{line:Ke}})},$e=React$2.useCallback((Ke=!0)=>{const vt=Ke?["fromId","toId"]:["toId","fromId"],Ue=o.filter(xe=>xe[vt[0]]===I.id),At=Ue.length===1?Ue[0]:Ue.find(xe=>xe[vt[1]]===ft);if(!(At!=null&&At[vt[0]])){rt();return}Ke||Xe(Ne.slice(0,Ne.length-1));const st=t.findIndex(xe=>xe.id===At[vt[1]]);st>=0?Et(st):rt()},[I==null?void 0:I.id,e,o,rt,t]),pt=React$2.useCallback((Ke,vt)=>{const Ue=[3,2,1][Ke.id],st=o.filter(ie=>ie.fromId===(I==null?void 0:I.id)).find(ie=>parseInt(ie.fromPointIndex)===Ue),xe=t.findIndex(ie=>ie.id===(st==null?void 0:st.toId));xe>=0?(st==null?void 0:st.fromId)===(st==null?void 0:st.toId)?vt():Et(xe):rt()},[I==null?void 0:I.id,o,rt,t]),He=React$2.useCallback(()=>{if(ee.current={...K},w(!1),Dt(),X)$e(!1);else if(!St()){const Ke=v-1;Ee({show:!1}),S(Ke),e({type:"notifyProgress",payload:{line:Ke}})}},[$e,e,X,$,v,K]),Ye=React$2.useCallback(Ke=>{if(X){if(Ke){const vt=[3,2,1][Ke.id],At=o.filter(st=>st.fromId===I.id).find(st=>parseInt(st.fromPointIndex)===vt);if(At){const st=t.findIndex(xe=>xe.id===At.toId);st>=0&&e({type:"notifyProgress",payload:{line:st}})}else e({type:"saveNode"})}}else if(v<t.length-1){const vt=v+1;e({type:"notifyProgress",payload:{line:vt}})}else e({type:"saveNode"})},[o,v,t,e,I==null?void 0:I.id,X]),Pe=React$2.useCallback((Ke,vt)=>{if(ee.current={...K},Xe([...Ne,I.id]),w(!1),Dt(),X)Ke?pt(Ke,vt):$e();else if(v<t.length-1){const Ue=v+1;Et(Ue)}else(u||le||fe)&&rt()},[e,I==null?void 0:I.id,X,le,fe,v,t.length,pt,$e,rt,K]),we=()=>{y(!1),He()},ye=()=>X?I&&I.type!=="conversationalDecision"&&!o.find(Ke=>Ke.fromId===I.id):v===t.length-1,De=()=>{ye()?rt():(y(!1),Pe())};React$2.useEffect(()=>{if(X&&!b){const Ke=E==null?void 0:E.line;if(Ke>=0){R(!0),S(Ke);return}const vt=t.filter(Ue=>!o.find(At=>At.toId===Ue.id));if(vt.length){const Ue=vt[0],At=t.indexOf(Ue);At>=0&&(R(!0),S(At))}}},[o,X,t,b]);const qe=Ke=>{if(ee.current.uid===Ke.uid||M.current.parent===Ke)return;const vt=new three.Object3D,Ue=Ke.getObjectByName("Head_M");Ue.updateMatrixWorld(!0),vt.applyMatrix4(Ue.matrixWorld),vt.applyQuaternion(N.quaternion);const At=h?2.5:2,st=h?1.2:1.5;vt.translateY(At),vt.translateX(st);const xe=new three.Vector3;xe.setFromMatrixPosition(Ue.matrixWorld);const me=xe.project(N).x<0;M.current={pos:vt.position.toArray(),child:Ue,parent:Ke,isLeft:me}},Lt=Ke=>{e({type:"resetZIndexUIContainer",payload:Ke})};React$2.useEffect(()=>{var Ke;if(re)We(),Ee({text:I==null?void 0:I.text,name:(I==null?void 0:I.alias)||(I==null?void 0:I.name)||`[ ${Oe("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Me(K),show:!0});else if(!z.current&&!le&&!fe){const vt=I==null?void 0:I.slots.filter(st=>st.uid&&!st.talking),Ue=[...vt.map(st=>st.uid)||[],K==null?void 0:K.uid];if(Re.filter(st=>!Ue.includes(st)).forEach(st=>{ue(st,"idle")}),vt.forEach(st=>{const xe=getCurrentVisible(st.uid,C);if(xe){const{isSeated:ie}=xe;tt(st.uid,st.emotion,st.animation,ie)}}),K){const st=getCurrentVisible(K.uid,C),xe=a.find(ie=>ie.uid===K.uid);st&&!z.current?setTimeout(()=>{var ie,me;if(K.uid===st.uid){qe(st);const{isSeated:Se,userData:Ce}=st,{emotion:ce,animation:be}=K;!((ie=Ce._active)!=null&&ie.includes("talking"))&&!((me=Ce._active)!=null&&me.includes(ce))&&tt(K.uid,ce,be,Se);const Ie=()=>{var Je;Ee({text:K.text,name:K.alias||((Je=K.character)==null?void 0:Je.name),inScene:!0,thinkful:K.emotion.includes("think"),avatar:Me(K),show:!0})};h?(ne.current=!1,ke(Ie)):Ie()}},150):(We(),Ee({text:K.text,name:K.alias||((Ke=K.character)==null?void 0:Ke.name)||(xe==null?void 0:xe.name),left:!1,top:K.text.length>maxCharacterToSwitch,inScene:!1,thinkful:K.emotion.includes("think"),avatar:Me(K),show:!0}))}else We(),Ee({show:!0})}},[a,I,h,C,Oe,Me,We,le,re,Re]);const kt=cleanTextOfHtmlTags(ge==null?void 0:ge.text),Le=useEkho({audioType:I==null?void 0:I.audioType,volume:I==null?void 0:I.audioVolume,voice:I==null?void 0:I.voice,started:ge.show,text:kt,audio:I==null?void 0:I.audio,soundActions:d,getEvent:n,pauseTTS:p,onStart:()=>{var Ke;(Ke=K==null?void 0:K.emotion)!=null&&Ke.includes("think")||ct()},onError:()=>{Dt(),w(!0)},onFinish:()=>{Dt(),de&&!p&&Pe()}});React$2.useEffect(()=>(Le(),()=>{Le()}),[v,Le]),React$2.useEffect(()=>{var Ke;if(((I==null?void 0:I.audioType)==="none"||_)&&(ge!=null&&ge.show)&&!(K!=null&&K.emotion.includes("think"))){ct();const vt=characterMs*(((Ke=ge==null?void 0:ge.text)==null?void 0:Ke.length)||0);setTimeout(()=>{Dt()},vt<minMs?minMs:vt)}},[_,I==null?void 0:I.audioType,K==null?void 0:K.emotion,ge]),React$2.useEffect(()=>{var Ke;if(de&&ge.show&&((I==null?void 0:I.audioType)==="none"||_)&&!p){const vt=characterMs*(((Ke=ge==null?void 0:ge.text)==null?void 0:Ke.length)||0);(!ye()||ye()&&u)&&P(Pe,vt<minMs?minMs:vt)}return()=>{D()}},[ge,Pe,P,u,D,I==null?void 0:I.audioType,de,B,Y,_]);const ht=React$2.useMemo(()=>v===0||St()||ze(),[v,St,ze]),wt=l({disabled:le||!ge.show,repeat:!1,forward:De,rewind:ht?null:we});React$2.useEffect(()=>wt(),[wt]);const at=document.querySelector(".screens--container");if(fe)return jsxRuntimeExports.jsx(ChangeCamera,{...I,emitEvent:e,success:!1,onFinish:Pe},`change-camera-${v}`);if(le){const Ke=I.id?t.filter(Ue=>Ue.decision).findIndex(Ue=>Ue.id===I.id)+1:t.filter(Ue=>Ue.decision).findIndex(Ue=>Ue===I)+1,vt={...I.payload,decisionNumber:Ke,inheritProps:{slots:[],disableBackground:!0},required:!X,branched:X,onAddPoints:Ye,onFinish:Pe,emitEvent:e,getEvent:n,pause:p,soundActions:d,keyboardControl:l};return jsxRuntimeExports.jsx(HtmlWrap,{onMount:()=>{We(),Lt(!0)},onUnMount:()=>{ne.current=!1,Lt(!1)},children:jsxRuntimeExports.jsx(DecisionComponent,{inScene:!0,...vt})})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[ge.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:Oe,currentMessage:ge}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100vw",height:"100%",position:"static"},portal:at?{current:at}:void 0,zIndexRange:[6,6],onOcclude:()=>{},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"ltr",className:"dialog-component-controls",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:we,disabled:ht||!ge.show,className:`gat--btn__round ${ht||!ge.show?"disabled":""}`,"aria-label":LangIsRtl()?Oe("storylines.misc.forward"):Oe("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:De,disabled:!ge.show,className:`gat--btn__round
273
273
  ${ge.show?"":"disabled"}
274
274
  ${g&&ye()?"glowing-animation":""}`,"aria-label":LangIsRtl()?Oe("storylines.misc.rewind"):Oe("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})}const activeCache=arcadeThreeCore.ProgressManager.request("AssetLoader").cache,assetLoader=new arcadeThreeCore.AssetLoader(void 0,activeCache);function Animation({animation:l,loopTimes:e,onAnimationFinish:n,onAnimationSave:t,resource:a,makeDefault:o}){const[d,h]=React$2.useState(!1),f=fiber.useThree(p=>p.scene),u=React$2.useRef(1);return React$2.useEffect(()=>{h(!1)},[a.uid,l==null?void 0:l.url]),React$2.useEffect(()=>{if(!d){const p=f.getObjectByProperty("uid",a.uid);if(p&&l&&l.url&&p.skeletonId===(l==null?void 0:l.skeletonId))if(o)t({uid:a.uid,animation:l==null?void 0:l.id,index:p.index}),n();else{const E=p.userData.animator,T=()=>{E.getAction(l.url).setLoop(three.LoopRepeat,1/0),u.current=1;function S(){u.current>=e&&(E.mix("idle"),n(),E.removeEventListener("loop",S)),u.current+=1}E.mix(l==null?void 0:l.url).then(g=>{g&&E.addEventListener("loop",S)}),h(!0)};E.getAction(l==null?void 0:l.url)?T():assetLoader.load(l==null?void 0:l.url,v=>{E.register(l==null?void 0:l.url,v.animations[0]),T()},void 0,v=>{console.error(`Asset loader failed with: ${l.url}`,v),n()})}else n()}},[f,l==null?void 0:l.url,e,d,a.uid,o,l,a,n,t]),null}function MultipleAnimation({animations:l=[],enableInteraction:e,emitEvent:n}){const t=l.length,a=React$2.useRef(0),o=()=>{a.current+=1,a.current>=t&&e&&n({type:"success"})},d=h=>{n({type:"saveAnimation",payload:h})};return React$2.useEffect(()=>{a.current=0},[l]),React$2.useEffect(()=>{e||n({type:"success"})},[n,e]),l.map(({animation:h,...f},u)=>{var p;return jsxRuntimeExports.jsx(Animation,{animation:h,...f,onAnimationFinish:o,onAnimationSave:d},(h==null?void 0:h.id)||((p=f.resource)==null?void 0:p.uid)||u)})}function EmailPill({text:l,error:e,handleClick:n}){return jsxRuntimeExports.jsxs("div",{"data-testid":`${e?" pill--error":"pill--ok"}`,className:`email-pill ${e?" email-pill--error":""}`,children:[jsxRuntimeExports.jsx("div",{children:l}),jsxRuntimeExports.jsx("div",{className:"email-pill__delete",children:jsxRuntimeExports.jsx("button",{type:"button",onClick:n,className:"icon-close unset-button","aria-label":"icon click"})})]})}function StepOne({handleContinue:l,handleCancel:e,translate:n,text:t}){const[a,o]=React$2.useState([]),[d,h]=React$2.useState(0),[f,u]=React$2.useState(0),p=React$2.useRef(null),E=(g,y,b)=>{g.stopPropagation(),o(a.filter(R=>R!==a[b])),y.error&&h(d-1),y.isRepeat&&u(f-1)},T=()=>{p.current&&p.current.focus()},v=()=>{[" ",",",";","."].includes(p.current.value)&&(p.current.value="")},S=g=>{const y=p.current.value,b=["Space","Comma","Period","Enter"],R=["Space","Comma","Enter","Tab"];y===""&&(b.includes(g.code)||g.keyCode==="186"||g.key==="Enter"||g.key===" ")?g.preventDefault():p.current.value.length>1&&(R.includes(g.code)||g.type==="blur")&&(g.preventDefault(),/[A-Za-z0-9._%+-]{3,}@[A-Za-z0-9_+-]{2,}([.]{1}[a-zA-Z]{2,}|[.]{1}[a-zA-Z]{2,}[.]{1}[a-zA-Z]{2,})/.test(y)?a.find(w=>w.text===y)?(u(f+1),o([...a,{text:y,error:!0,isRepeat:!0}])):o([...a,{text:y}]):(o([...a,{text:y,error:!0}]),h(d+1)),p.current.value="")};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:n("puzzles.referrals.inviter.titleStep1")}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__subtitle",children:t}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__form",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__instructions",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.instructions")}),jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.limit")})]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__faketextarea",onKeyUp:()=>{},role:"button",tabIndex:"-1",onClick:T,"aria-labelledby":"list of emails",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__scrollarea",id:"list of emails",children:[a&&a.map((g,y)=>jsxRuntimeExports.jsx(EmailPill,{text:g.text,error:g.error,handleClick:b=>E(b,g,y),emailPillIndex:y},`${a.indexOf(g)}`)),a.length<=9?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("input",{id:"email",ref:p,className:"referrals-piece__inputemail",onChange:v,onKeyDown:S,onBlur:S,type:"email",autoComplete:"off"}),jsxRuntimeExports.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:jsxRuntimeExports.jsx("span",{children:n("puzzles.referrals.inviter.skipButton")})})]}):null]})}),jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"auto",className:"referrals-piece__footervalidation",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__errormessage",children:[jsxRuntimeExports.jsx("div",{children:f>0?n("puzzles.referrals.inviter.errorEmailRepeat"):null}),jsxRuntimeExports.jsx("div",{children:d>0?n("puzzles.referrals.inviter.errorMessage"):null})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[a.length,"/10"]})]})]})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__buttons",children:[jsxRuntimeExports.jsx("button",{"data-testid":"cancelButton",className:"gat--btn gat--btn__secondary",type:"button",onClick:e,children:n("puzzles.referrals.inviter.skipButton")}),jsxRuntimeExports.jsx("button",{className:`gat--btn gat--btn__primary ${f>0||d>0||a.length===0?" disabled":""}`,type:"button",disabled:d>0||a.length===0,onClick:()=>l(a),children:n("puzzles.referrals.inviter.inviteButton")})]})]})}function StepTwo({handleFinish:l,translate:e,valid:n,invalid:t}){const[a,o]=React$2.useState(!1),d=()=>{o(!a)},h=n.current===1?"invitationSend":"invitationsSend",f=t===1?"invitationNotSend":"invitationsNotSend";return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",dir:"auto",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:e("puzzles.referrals.inviter.titleStep2")}),jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__feedback",children:[n.current!==0&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-check-circle-black color--success"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:n.current})," ",e(`puzzles.referrals.inviter.${h}`)]})]}),!!t.current&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-error-circle-black color--error"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:t.current})," ",e(`puzzles.referrals.inviter.${f}`)]}),jsxRuntimeExports.jsx("button",{className:"un-button",type:"button",onClick:d,children:e("puzzles.referrals.inviter.whyFail")})]})]}),a?jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__failsreasons",children:[jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons1")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons2")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons3")})]}):null]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__buttons",children:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",type:"button",onClick:l,children:e("puzzles.referrals.inviter.continueButton")})})]})}function ReferralComponent({emitEvent:l,getEvent:e,text:n,rewards:t,referrals:a}){const o=v=>e({type:"translate",payload:v}),[d,h]=React$2.useState("step1"),f=React$2.useRef(0),u=React$2.useRef(0),p=async v=>{const S=v.map(y=>y.text),g=await l({type:"sendReferrals",payload:S});f.current=g&&g.data?g.data.valid.length:0,u.current=S.length-f.current,h("step2")};if(!a)return l({type:"success"}),null;const E=()=>{l({type:"success"})},T=()=>{if(f.current){const v=t.map(S=>(S.points*=f.current,S));l({type:"addPoints",complex:!0,finish:!0,payload:v})}else l({type:"success"})};return jsxRuntimeExports.jsx("div",{className:"referrals-piece",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__center",children:[d==="step1"&&jsxRuntimeExports.jsx(StepOne,{translate:o,handleContinue:p,handleCancel:E,text:n}),d==="step2"&&jsxRuntimeExports.jsx(StepTwo,{translate:o,handleFinish:T,valid:f,invalid:u})]})})}function DragToSceneComponent({itemResolver:l,consume:e,hasComplexNotResolvers:n,hasComplexResolvers:t,resolverObjects:a,feedback:o,emitEvent:d,getEvent:h,soundActions:f,keyboardControl:u}){const[p]=f,[E,T]=React$2.useState(!1),v=y=>h({type:"translate",payload:y}),S=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:E.success,onFinish:()=>{E.success?d({type:"success"}):d({type:"closeScreen"})},payload:E.rewards})},[d,E]),g=React$2.useCallback(()=>{if(a.find(b=>b===l.uid)){let b;t?(b=o.resolvers.rights.find(R=>R.uidObject===l.uid),b||(b=o.resolvers.rights[0])):b=o.resolvers.rights[0],e&&d({type:"consumeItem",payload:{uid:l.uid,targetId:l.uid,name:l.name}}),T({...b,success:!0})}else{let b;n?(b=o.notResolvers.wrongs.find(R=>R.uidObject===l.uid),b||(b=o.notResolvers.wrongs[0])):b=o.notResolvers.wrongs[0],T({...b,success:!1})}},[a,l,t,e,o,d,n]);return React$2.useEffect(()=>{l?g():d({type:"closeScreen"})},[d,l,g]),E?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:E.desc,success:E.success,playSound:p,hasTimeout:!E.desc,delay:2e3,translate:v,keyboardControl:u,functionOnClose:S}):null}exports.AnimationComponent=MultipleAnimation;exports.AutoEvaluationComponent=AutoEvaluation;exports.CardsSelectorPuzzleComponent=CardsSelectorPuzzleComponent;exports.CartelComponent=CartelComponent;exports.ChainedImageClickPuzzleComponent=ChainedImageClickPuzzleComponent;exports.ChangeCamera=ChangeCamera;exports.ComicComponent=ComicComponent;exports.ConversationalComponent=ConversationalComponent;exports.ConversationalProComponent=ConversationalProComponent;exports.CrackerPuzzleComponent=CrackerPuzzleComponent;exports.DecisionComponent=DecisionComponent;exports.DialogComponent=DialogComponent;exports.DragItemPuzzleComponent=DragItemPuzzleComponent;exports.DragToSceneComponent=DragToSceneComponent;exports.FrameImageClickComponent=FrameImageClickComponent;exports.HackerPuzzleComponent=HackerPuzzleComponent;exports.HangedPuzzleComponent=HangedPuzzleComponent;exports.ImageClickPuzzleComponent=ImageClickPuzzleComponent;exports.ImageComponent=ImageComponent;exports.InventoryItem=InventoryItem;exports.KeyboardPuzzleComponent=KeyboardPuzzleComponent;exports.LecturesComponent=LecturesComponent;exports.LoginPuzzleComponent=LoginPuzzleComponent;exports.NoticeComponent=NoticeComponent;exports.PatternComponent=PatternComponent;exports.PdfComponent=PdfComponent;exports.PdfVisor=PdfVisor;exports.ReferralComponent=ReferralComponent;exports.SurveyComponent=SurveyComponent;exports.TerminalPuzzleComponent=TerminalPuzzleComponent;exports.TestComponent=TestComponent;exports.TextClickPuzzleComponent=TextClickPuzzleComponent;exports.UrlComponent=UrlComponent;exports.VideoComponent=VideoComponent;exports.VideoVisor=VideoVisor;exports.WebBuilderPuzzleComponent=WebBuilderPuzzleComponent;exports.WriterPuzzleComponent=WriterPuzzleComponent;
275
275
  //# sourceMappingURL=arcade-components.cjs.map