@gamelearn/arcade-components 3.14.3 → 3.14.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,12 +63,12 @@ object-assign
63
63
  */var objectAssign,hasRequiredObjectAssign;function requireObjectAssign(){if(hasRequiredObjectAssign)return objectAssign;hasRequiredObjectAssign=1;var l=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function t(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function a(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var d={},h=0;h<10;h++)d["_"+String.fromCharCode(h)]=h;var f=Object.getOwnPropertyNames(d).map(function(p){return d[p]});if(f.join("")!=="0123456789")return!1;var u={};return"abcdefghijklmnopqrst".split("").forEach(function(p){u[p]=p}),Object.keys(Object.assign({},u)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return objectAssign=a()?Object.assign:function(o,d){for(var h,f=t(o),u,p=1;p<arguments.length;p++){h=Object(arguments[p]);for(var x in h)e.call(h,x)&&(f[x]=h[x]);if(l){u=l(h);for(var R=0;R<u.length;R++)n.call(h,u[R])&&(f[u[R]]=h[u[R]])}}return f},objectAssign}var ReactPropTypesSecret_1,hasRequiredReactPropTypesSecret;function requireReactPropTypesSecret(){if(hasRequiredReactPropTypesSecret)return ReactPropTypesSecret_1;hasRequiredReactPropTypesSecret=1;var l="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ReactPropTypesSecret_1=l,ReactPropTypesSecret_1}var checkPropTypes_1,hasRequiredCheckPropTypes;function requireCheckPropTypes(){if(hasRequiredCheckPropTypes)return checkPropTypes_1;hasRequiredCheckPropTypes=1;var l=function(){};if(process.env.NODE_ENV!=="production"){var e=requireReactPropTypesSecret(),n={},t=Function.call.bind(Object.prototype.hasOwnProperty);l=function(o){var d="Warning: "+o;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function a(o,d,h,f,u){if(process.env.NODE_ENV!=="production"){for(var p in o)if(t(o,p)){var x;try{if(typeof o[p]!="function"){var R=Error((f||"React class")+": "+h+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[p]+"`.");throw R.name="Invariant Violation",R}x=o[p](d,p,f,h,null,e)}catch(E){x=E}if(x&&!(x instanceof Error)&&l((f||"React class")+": type specification of "+h+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof x+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),x instanceof Error&&!(x.message in n)){n[x.message]=!0;var S=u?u():"";l("Failed "+h+" type: "+x.message+(S??""))}}}}return a.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},checkPropTypes_1=a,checkPropTypes_1}var factoryWithTypeCheckers,hasRequiredFactoryWithTypeCheckers;function requireFactoryWithTypeCheckers(){if(hasRequiredFactoryWithTypeCheckers)return factoryWithTypeCheckers;hasRequiredFactoryWithTypeCheckers=1;var l=requireReactIs(),e=requireObjectAssign(),n=requireReactPropTypesSecret(),t=requireCheckPropTypes(),a=Function.call.bind(Object.prototype.hasOwnProperty),o=function(){};process.env.NODE_ENV!=="production"&&(o=function(h){var f="Warning: "+h;typeof console<"u"&&console.error(f);try{throw new Error(f)}catch{}});function d(){return null}return factoryWithTypeCheckers=function(h,f){var u=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function x(q){var re=q&&(u&&q[u]||q[p]);if(typeof re=="function")return re}var R="<<anonymous>>",S={array:T("array"),bool:T("boolean"),func:T("function"),number:T("number"),object:T("object"),string:T("string"),symbol:T("symbol"),any:b(),arrayOf:_,element:w(),elementType:C(),instanceOf:P,node:F(),objectOf:N,oneOf:D,oneOfType:k,shape:M,exact:U};function E(q,re){return q===re?q!==0||1/q===1/re:q!==q&&re!==re}function g(q){this.message=q,this.stack=""}g.prototype=Error.prototype;function v(q){if(process.env.NODE_ENV!=="production")var re={},ce=0;function fe(H,W,V,z,Q,ee,le){if(z=z||R,ee=ee||V,le!==n){if(f){var ue=new Error("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");throw ue.name="Invariant Violation",ue}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var he=z+":"+V;!re[he]&&ce<3&&(o("You are manually calling a React.PropTypes validation function for the `"+ee+"` prop on `"+z+"`. 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[he]=!0,ce++)}}return W[V]==null?H?W[V]===null?new g("The "+Q+" `"+ee+"` is marked as required "+("in `"+z+"`, but its value is `null`.")):new g("The "+Q+" `"+ee+"` is marked as required in "+("`"+z+"`, but its value is `undefined`.")):null:q(W,V,z,Q,ee)}var te=fe.bind(null,!1);return te.isRequired=fe.bind(null,!0),te}function T(q){function re(ce,fe,te,H,W,V){var z=ce[fe],Q=J(z);if(Q!==q){var ee=ne(z);return new g("Invalid "+H+" `"+W+"` of type "+("`"+ee+"` supplied to `"+te+"`, expected ")+("`"+q+"`."))}return null}return v(re)}function b(){return v(d)}function _(q){function re(ce,fe,te,H,W){if(typeof q!="function")return new g("Property `"+W+"` of component `"+te+"` has invalid PropType notation inside arrayOf.");var V=ce[fe];if(!Array.isArray(V)){var z=J(V);return new g("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+te+"`, expected an array."))}for(var Q=0;Q<V.length;Q++){var ee=q(V,Q,te,H,W+"["+Q+"]",n);if(ee instanceof Error)return ee}return null}return v(re)}function w(){function q(re,ce,fe,te,H){var W=re[ce];if(!h(W)){var V=J(W);return new g("Invalid "+te+" `"+H+"` of type "+("`"+V+"` supplied to `"+fe+"`, expected a single ReactElement."))}return null}return v(q)}function C(){function q(re,ce,fe,te,H){var W=re[ce];if(!l.isValidElementType(W)){var V=J(W);return new g("Invalid "+te+" `"+H+"` of type "+("`"+V+"` supplied to `"+fe+"`, expected a single ReactElement type."))}return null}return v(q)}function P(q){function re(ce,fe,te,H,W){if(!(ce[fe]instanceof q)){var V=q.name||R,z=Y(ce[fe]);return new g("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+te+"`, expected ")+("instance of `"+V+"`."))}return null}return v(re)}function D(q){if(!Array.isArray(q))return process.env.NODE_ENV!=="production"&&(arguments.length>1?o("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):o("Invalid argument supplied to oneOf, expected an array.")),d;function re(ce,fe,te,H,W){for(var V=ce[fe],z=0;z<q.length;z++)if(E(V,q[z]))return null;var Q=JSON.stringify(q,function(le,ue){var he=ne(ue);return he==="symbol"?String(ue):ue});return new g("Invalid "+H+" `"+W+"` of value `"+String(V)+"` "+("supplied to `"+te+"`, expected one of "+Q+"."))}return v(re)}function N(q){function re(ce,fe,te,H,W){if(typeof q!="function")return new g("Property `"+W+"` of component `"+te+"` has invalid PropType notation inside objectOf.");var V=ce[fe],z=J(V);if(z!=="object")return new g("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+te+"`, expected an object."));for(var Q in V)if(a(V,Q)){var ee=q(V,Q,te,H,W+"."+Q,n);if(ee instanceof Error)return ee}return null}return v(re)}function k(q){if(!Array.isArray(q))return process.env.NODE_ENV!=="production"&&o("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var re=0;re<q.length;re++){var ce=q[re];if(typeof ce!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ie(ce)+" at index "+re+"."),d}function fe(te,H,W,V,z){for(var Q=0;Q<q.length;Q++){var ee=q[Q];if(ee(te,H,W,V,z,n)==null)return null}return new g("Invalid "+V+" `"+z+"` supplied to "+("`"+W+"`."))}return v(fe)}function F(){function q(re,ce,fe,te,H){return $(re[ce])?null:new g("Invalid "+te+" `"+H+"` supplied to "+("`"+fe+"`, expected a ReactNode."))}return v(q)}function M(q){function re(ce,fe,te,H,W){var V=ce[fe],z=J(V);if(z!=="object")return new g("Invalid "+H+" `"+W+"` of type `"+z+"` "+("supplied to `"+te+"`, expected `object`."));for(var Q in q){var ee=q[Q];if(ee){var le=ee(V,Q,te,H,W+"."+Q,n);if(le)return le}}return null}return v(re)}function U(q){function re(ce,fe,te,H,W){var V=ce[fe],z=J(V);if(z!=="object")return new g("Invalid "+H+" `"+W+"` of type `"+z+"` "+("supplied to `"+te+"`, expected `object`."));var Q=e({},ce[fe],q);for(var ee in Q){var le=q[ee];if(!le)return new g("Invalid "+H+" `"+W+"` key `"+ee+"` supplied to `"+te+"`.\nBad object: "+JSON.stringify(ce[fe],null," ")+`
64
64
  Valid keys: `+JSON.stringify(Object.keys(q),null," "));var ue=le(V,ee,te,H,W+"."+ee,n);if(ue)return ue}return null}return v(re)}function $(q){switch(typeof q){case"number":case"string":case"undefined":return!0;case"boolean":return!q;case"object":if(Array.isArray(q))return q.every($);if(q===null||h(q))return!0;var re=x(q);if(re){var ce=re.call(q),fe;if(re!==q.entries){for(;!(fe=ce.next()).done;)if(!$(fe.value))return!1}else for(;!(fe=ce.next()).done;){var te=fe.value;if(te&&!$(te[1]))return!1}}else return!1;return!0;default:return!1}}function B(q,re){return q==="symbol"?!0:re?re["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&re instanceof Symbol:!1}function J(q){var re=typeof q;return Array.isArray(q)?"array":q instanceof RegExp?"object":B(re,q)?"symbol":re}function ne(q){if(typeof q>"u"||q===null)return""+q;var re=J(q);if(re==="object"){if(q instanceof Date)return"date";if(q instanceof RegExp)return"regexp"}return re}function ie(q){var re=ne(q);switch(re){case"array":case"object":return"an "+re;case"boolean":case"date":case"regexp":return"a "+re;default:return re}}function Y(q){return!q.constructor||!q.constructor.name?R:q.constructor.name}return S.checkPropTypes=t,S.resetWarningCache=t.resetWarningCache,S.PropTypes=S,S},factoryWithTypeCheckers}var factoryWithThrowingShims,hasRequiredFactoryWithThrowingShims;function requireFactoryWithThrowingShims(){if(hasRequiredFactoryWithThrowingShims)return factoryWithThrowingShims;hasRequiredFactoryWithThrowingShims=1;var l=requireReactPropTypesSecret();function e(){}function n(){}return n.resetWarningCache=e,factoryWithThrowingShims=function(){function t(d,h,f,u,p,x){if(x!==l){var R=new Error("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");throw R.name="Invariant Violation",R}}t.isRequired=t;function a(){return t}var o={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:a,element:t,elementType:t,instanceOf:a,node:t,objectOf:a,oneOf:a,oneOfType:a,shape:a,exact:a,checkPropTypes:n,resetWarningCache:e};return o.PropTypes=o,o},factoryWithThrowingShims}if(process.env.NODE_ENV!=="production"){var ReactIs=requireReactIs(),throwOnDirectAccess=!0;propTypes.exports=requireFactoryWithTypeCheckers()(ReactIs.isElement,throwOnDirectAccess)}else propTypes.exports=requireFactoryWithThrowingShims()();var propTypesExports=propTypes.exports;const PropTypes=getDefaultExportFromCjs(propTypesExports);function BufferBar({time:l,setTimePoint:e,mandatory:n,mandatoryHasBeenViewed:t,viewed:a}){const o=Math.trunc(l.current*1e3/l.duration)/10,d=React$2.useRef(),[h,f]=React$2.useState(!1),u=Math.trunc(l.current/60)<10?["0",Math.trunc(l.current/60)].join("").trim():Math.trunc(l.current/60),p=Math.trunc(l.current%60)<10?["0",Math.trunc(l.current%60)].join("").trim():Math.trunc(l.current%60),x=(g,v)=>{f(!0);let T=g.offsetX;g.changedTouches&&(T=g.changedTouches[0].clientX);const b=v.offsetWidth+v.offsetLeft;T<=b&&T>=v.offsetLeft&&e(T,v.offsetWidth,v.offsetLeft)},R=()=>{window.onmousemove=null,window.onmouseup=null,f(!1)},S=g=>{window.onmousemove=v=>x(v,g),window.onmouseup=v=>R()},E=(g,v)=>{(!n||n&&t||a)&&(g.preventDefault(),e(g.clientX,v.offsetWidth,v.offsetLeft),S(v),f(!0))};return jsxRuntimeExports.jsx("div",{id:"buffer",ref:d,className:"video--controls__bar",onMouseDown:g=>{const v=d.current;E(g,v)},onTouchMove:g=>{const v=d.current;x(g,v)},onTouchStart:g=>{const v=d.current;f(!0),e(g.changedTouches[0].clientX,v.offsetWidth,v.offsetLeft)},children:jsxRuntimeExports.jsx("div",{className:"video--controls__progress",style:{width:`${o}%`},children:jsxRuntimeExports.jsx("span",{className:h?"video--controls__handle active":"video--controls__handle",children:h?jsxRuntimeExports.jsxs("div",{className:"video--current__time active",children:[u,":",p]}):null})})})}BufferBar.defaultProps={time:{current:0,duration:0},setTimePoint:()=>{}};BufferBar.propTypes={time:PropTypes.shape({current:PropTypes.number,duration:PropTypes.number}),setTimePoint:PropTypes.func};function Timer({time:l}){const e=Math.trunc(l.current/60)<10?["0",Math.trunc(l.current/60)].join("").trim():Math.trunc(l.current/60),n=Math.trunc(l.current%60)<10?["0",Math.trunc(l.current%60)].join("").trim():Math.trunc(l.current%60),t=Math.trunc(l.duration/60)<10?["0",Math.trunc(l.duration/60)].join("").trim():Math.trunc(l.duration/60),a=Math.trunc(l.duration%60)<10?["0",Math.trunc(l.duration%60)].join("").trim():Math.trunc(l.duration%60);return jsxRuntimeExports.jsxs("div",{className:"video--time",children:[jsxRuntimeExports.jsxs("span",{className:"time",children:[e,":",n]}),jsxRuntimeExports.jsxs("span",{className:"duration",children:[t,":",a]})]})}Timer.defaultProps={time:{current:0,duration:0}};Timer.propTypes={time:PropTypes.shape({current:PropTypes.number,duration:PropTypes.number})};function ControlButtons({pauseVideo:l,paused:e,translate:n}){return jsxRuntimeExports.jsx("div",{className:"video--controls__buttons",children:jsxRuntimeExports.jsx("button",{id:"playPause","aria-label":n(e?"storylines.misc.play":"storylines.misc.pause"),className:e?"unset-button icon-play":"unset-button icon-pause",type:"button",onClick:()=>{l(),document.querySelector("#playPause").blur()}})})}ControlButtons.defaultProps={paused:!1,pauseVideo:()=>{}};function FinishedVideoButtons({restart:l,translate:e}){return jsxRuntimeExports.jsx("div",{className:"video--extra__actions video--extra__actions--widthTransparencyLayer position--absolute z-index1",children:jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>{l()},className:"gat--btn gat--btn__secondary","aria-label":e("video.replay"),children:[jsxRuntimeExports.jsx("span",{className:"icon-rewind"}),jsxRuntimeExports.jsx("span",{id:"video.replay"})]})})}FinishedVideoButtons.defaultProps={restart:()=>{},finished:!1};function PlayInitButton({play:l,finished:e,paused:n}){return e||!n?jsxRuntimeExports.jsx("div",{}):jsxRuntimeExports.jsx("div",{className:"video--extra__actions position--absolute z-index1",children:jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":"play video",onKeyUp:()=>{},onClick:()=>{l()},className:"play--video__button",children:jsxRuntimeExports.jsx("span",{className:"icon-play-outline"})})})}PlayInitButton.defaultProps={play:()=>{},finished:!1,paused:!1};function skipButton({viewed:l,mandatory:e,finished:n,skip:t,mandatoryHasBeenViewed:a,translate:o}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:e&&l||!e||n||a?jsxRuntimeExports.jsx("div",{className:"position--absolute right top z-index2",children:jsxRuntimeExports.jsx("button",{className:"gat--btn__round gat--btn__close",type:"button","aria-label":o("storylines.misc.closePiece"),onKeyUp:()=>{},onClick:()=>{t()},children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})}):null})}skipButton.defaultProps={mandatory:!1,viewed:!1,finished:!1,skip:()=>{}};function VolumeBar({volume:l,muted:e,setVolume:n,mute:t}){const a=React$2.useRef(),o=e?0:Math.floor(l*100),d=(p,x)=>{const R=x.offsetWidth+x.offsetLeft;let S=p.clientX;p.changedTouches&&(S=p.changedTouches[0].clientX),S<=R&&S>=x.offsetLeft&&n(S,x.offsetWidth,x.offsetLeft)},h=()=>{window.onmousemove=null,window.onmouseup=null},f=p=>{window.onmousemove=x=>d(x,p),window.onmouseup=x=>h()},u=(p,x)=>{p.preventDefault(),n(p.clientX,x.offsetWidth,x.offsetLeft),f(x)};return jsxRuntimeExports.jsxs("div",{className:"video--sound",children:[jsxRuntimeExports.jsx("span",{onClick:()=>t(),className:o===0?"icon-sound-off":"icon-sound"}),jsxRuntimeExports.jsx("div",{ref:a,onMouseDown:p=>{const x=a.current;u(p,x)},onTouchMove:p=>{const x=a.current;d(p,x)},onTouchStart:p=>{const x=a.current;n(p.changedTouches[0].clientX,x.offsetWidth,x.offsetLeft)},id:"volume",className:"video--sound__level",children:jsxRuntimeExports.jsx("span",{style:{width:`${o<10?10:o}%`},className:"video--sound__progress",children:jsxRuntimeExports.jsx("span",{className:"video--handle"})})})]})}VolumeBar.defaultProps={volume:0,muted:!1,setVolume:()=>{},mute:()=>{}};VolumeBar.propTypes={volume:PropTypes.number,setVolume:PropTypes.func,mute:PropTypes.func,muted:PropTypes.bool};function VideoControllers({pause:l,mandatory:e,viewed:n,skip:t,rewind:a,paused:o,time:d,finished:h,restart:f,volume:u,muted:p,mute:x,setVolume:R,setTimePoint:S,audioAnimation:E,mandatoryHasBeenViewed:g,translate:v,visibility:T,withoutControls:b,documentType:_}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(skipButton,{mandatory:e,finished:h,viewed:n,skip:t,rewind:a,mandatoryHasBeenViewed:g,translate:v}),b?null:jsxRuntimeExports.jsxs("div",{className:`video--controls-wrap ${T?"video--controls-wrap--hidden":""}`,children:[E?null:jsxRuntimeExports.jsx(PlayInitButton,{play:l,paused:o,finished:h}),h&&(_==="document"||_==="lesson")?jsxRuntimeExports.jsx(FinishedVideoButtons,{restart:f,translate:v}):null,jsxRuntimeExports.jsxs("div",{className:"video--controls",children:[jsxRuntimeExports.jsx(BufferBar,{mandatory:e,mandatoryHasBeenViewed:g,time:d,setTimePoint:S,finished:h,viewed:n}),jsxRuntimeExports.jsxs("div",{className:"video--controls__actions",children:[jsxRuntimeExports.jsx(Timer,{time:d}),E?jsxRuntimeExports.jsx("div",{className:"audio-animation-wrap",children:jsxRuntimeExports.jsx("div",{className:`audio-animation ${o?"audio-animation--notAnimate ":null}`})}):null,jsxRuntimeExports.jsx(ControlButtons,{paused:o,pauseVideo:l,translate:v}),jsxRuntimeExports.jsx(VolumeBar,{muted:p,mute:x,volume:u,setVolume:R})]})]})]})]})}VideoControllers.defaultProps={audioAnimation:!1,paused:!1,mandatory:!1,viewed:!1,volume:0,muted:!1,finished:!1,restart:()=>{},pause:()=>{},skip:()=>{},rewind:()=>{},setTimePoint:()=>{},setVolume:()=>{},mute:()=>{},time:{current:0,duration:0}};VideoControllers.propTypes={audioAnimation:PropTypes.bool,paused:PropTypes.bool,mandatory:PropTypes.bool,muted:PropTypes.bool,volume:PropTypes.number,viewed:PropTypes.bool,pause:PropTypes.func,finished:PropTypes.bool,restart:PropTypes.func,skip:PropTypes.func,rewind:PropTypes.func,mute:PropTypes.func,setTimePoint:PropTypes.func,setVolume:PropTypes.func,time:PropTypes.shape({current:PropTypes.number,duration:PropTypes.number})};const defaultBgImageForAudio="https://min.gamelearn.io/css-resources/gamelearn/resources/bgAudioPiece.jpg";function VideoVisor({documentType:l,url:e,required:n,viewed:t,backgroundImage:a,soundActions:o,endVideo:d,translate:h,autoPlay:f,withoutControls:u}){const[p,x]=React$2.useState(!1),[R]=o,[S,E]=React$2.useState(0),[g,v]=React$2.useState(0),[T,b]=React$2.useState(!1),[_,w]=React$2.useState(!0),[C,P]=React$2.useState(!1),[D,N]=React$2.useState(),[k,F]=React$2.useState(0),[M,U]=React$2.useState(!1),$=e&&e.match(/\.m3u8(\?.+=.+)*$/i)&&Hls.isSupported(),B=e&&(e.match(/youtube/i)||e.match(/vimeo/i)),J=e&&(e.match(/.mp3/i)||e.match(/.ogg/i)||e.match(/.wav/i)||e.match(/.m4a/i)),ne={ref:he=>{N(he)},src:e,style:{height:"100%",width:"100%"}},ie=()=>{n&&x(!0),b(!1),D.pause(),w(!0),P(!0),U(!1),l!=="document"&&l!=="lesson"&&d()},Y=()=>{d()},q=()=>{w(!1),b(!1)},re=()=>{b(!0)},ce=()=>{b(!1),E(D.duration)};React$2.useEffect(()=>{let he;if(D){if($){he=new Hls;const ve=`${e}?v=${Math.floor(Math.random()*99999999)}`;he.loadSource(ve),he.attachMedia(D),he.on(Hls.Events.FRAG_LOAD_PROGRESS,(be,Re)=>{const{stats:Le}=Re;v(Le.loaded*100/Le.total)})}return()=>{he&&he.destroy(),he=null}}},[$,e,D]);const fe=()=>{D.currentTime-=15},te=()=>{R("click-ui"),_?(D.play(),P(!1)):D.pause(),w(!_)},H=(he,ve,be)=>{P(!1),D.currentTime=ve?parseFloat((he-be)/ve*D.duration):0},W=()=>{P(!1),D.currentTime=0,te()},V=()=>{R("click-ui"),D.muted=!D.muted},z=(he,ve,be)=>{D.muted=!1;const Re=he-be>=0?(he-be)/ve:0;D.volume=Re*100>10?Re:0,F(D.volume)};React$2.useEffect(()=>{let he;return!M&&!_&&(he=setTimeout(()=>{U(!0),clearTimeout(he)},3e3)),()=>clearTimeout(he)},[M,_]);const Q=()=>{M&&U(!1)},ee=a||defaultBgImageForAudio,le=ee===defaultBgImageForAudio?"cover":"contain",ue={backgroundImage:`url("${ee}")`,backgroundSize:le,backgroundRepeat:"no-repeat",backgroundPosition:"center center"};return jsxRuntimeExports.jsx("div",{className:`video ${n&&!p&&!t?"forward-disabled":""}`,style:J?ue:null,children:B?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"position--absolute right top z-index2",children:jsxRuntimeExports.jsx("button",{type:"button","aria-label":h("storylines.misc.closePiece"),className:"gat--btn__round gat--btn__close",onClick:()=>{R("click-ui"),d()},children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})}),jsxRuntimeExports.jsx("iframe",{className:"embeddedVideo",title:"title",...ne})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(VideoControllers,{documentType:l,visibility:M,mandatoryHasBeenViewed:p,audioAnimation:!!J,skip:d,mandatory:n,viewed:t,volume:D?D.volume:0,mute:V,muted:D?D.muted:!1,paused:_,finished:C,restart:W,setTimePoint:H,time:{duration:S,current:D?D.currentTime:0},rewind:fe,pause:te,volumeState:k,setVolume:z,translate:h,withoutControls:u}),jsxRuntimeExports.jsx("video",{"data-testid":"video-visor-video",autoPlay:f,onMouseMove:()=>Q(),onClick:()=>{Q()},onFocus:()=>{Q()},onCanPlayThrough:ce,onWaiting:re,onEnded:ie,onError:Y,onPlaying:q,...ne,children:jsxRuntimeExports.jsx("track",{kind:"captions"})}),T?jsxRuntimeExports.jsxs("div",{className:"video-loading-container",style:{top:0,left:0},children:[jsxRuntimeExports.jsx("div",{className:"video-loading-container-bg opacity-wrapper"}),jsxRuntimeExports.jsx("div",{className:"popup-alert warning",children:jsxRuntimeExports.jsx("div",{className:"popup-message",children:jsxRuntimeExports.jsx("p",{children:Math.floor(g)})})})]}):null]})})}VideoVisor.defaultProps={url:"",name:"",backgroundImage:null,documentType:"",required:!1,viewed:!1,endVideo:()=>{}};function VideoComponent({emitEvent:l,name:e,documentType:n,document:t,documentId_labelId:a,soundActions:o,required:d,viewed:h,visible:f,img:u,imgId_labelId:p,withoutControls:x,autoPlay:R,keyboardControl:S}){const E=_=>l({type:"translate",payload:_}),{url:g}=t,v=React$2.useMemo(()=>({documentId:a,imgId:p,required:d,name:e,type:"video",viewed:h,documentType:n}),[a,p,d,e,h,n]),T=React$2.useCallback(()=>{l({type:"finishMedia",payload:v})},[l,v]);React$2.useEffect(()=>{f||T()},[T,f]);const b=S({disabled:h,forward:T,escape:T});return React$2.useEffect(()=>b(),[b]),f?jsxRuntimeExports.jsx(VideoVisor,{autoPlay:R,withoutControls:x,backgroundImage:u==null?void 0:u.url,url:g,soundActions:o,documentType:n,required:d,viewed:h,endVideo:()=>T(),translate:E}):null}function ChangeCamera({targetUid:l,emitEvent:e,success:n=!0,onFinish:t=()=>{},transition:a={type:"pan",speed:10}}){const{change:o}=arcadeThreeCore.CameraControls.useStore(),d=fiber.useThree(f=>f.camera),h=React$2.useRef();return React$2.useEffect(()=>{const f=()=>{e({type:"changeCamera",payload:{targetUid:l,transition:a}}),setTimeout(()=>{n&&e({type:"success"}),t()},200)};return d.addEventListener("transitionEnd",f),()=>{d.removeEventListener("transitionEnd",f)}},[d,e,t,n,l,a]),React$2.useEffect(()=>{o&&h.current!==l&&(o(l,a),h.current=l)},[o,l,a]),null}var htmlReactParser={exports:{}},lib$4={},possibleStandardNamesOptimized$1={},SAME$1=0;possibleStandardNamesOptimized$1.SAME=SAME$1;var CAMELCASE$1=1;possibleStandardNamesOptimized$1.CAMELCASE=CAMELCASE$1;possibleStandardNamesOptimized$1.possibleStandardNames={accept:0,acceptCharset:1,"accept-charset":"acceptCharset",accessKey:1,action:0,allowFullScreen:1,alt:0,as:0,async:0,autoCapitalize:1,autoComplete:1,autoCorrect:1,autoFocus:1,autoPlay:1,autoSave:1,capture:0,cellPadding:1,cellSpacing:1,challenge:0,charSet:1,checked:0,children:0,cite:0,class:"className",classID:1,className:1,cols:0,colSpan:1,content:0,contentEditable:1,contextMenu:1,controls:0,controlsList:1,coords:0,crossOrigin:1,dangerouslySetInnerHTML:1,data:0,dateTime:1,default:0,defaultChecked:1,defaultValue:1,defer:0,dir:0,disabled:0,disablePictureInPicture:1,disableRemotePlayback:1,download:0,draggable:0,encType:1,enterKeyHint:1,for:"htmlFor",form:0,formMethod:1,formAction:1,formEncType:1,formNoValidate:1,formTarget:1,frameBorder:1,headers:0,height:0,hidden:0,high:0,href:0,hrefLang:1,htmlFor:1,httpEquiv:1,"http-equiv":"httpEquiv",icon:0,id:0,innerHTML:1,inputMode:1,integrity:0,is:0,itemID:1,itemProp:1,itemRef:1,itemScope:1,itemType:1,keyParams:1,keyType:1,kind:0,label:0,lang:0,list:0,loop:0,low:0,manifest:0,marginWidth:1,marginHeight:1,max:0,maxLength:1,media:0,mediaGroup:1,method:0,min:0,minLength:1,multiple:0,muted:0,name:0,noModule:1,nonce:0,noValidate:1,open:0,optimum:0,pattern:0,placeholder:0,playsInline:1,poster:0,preload:0,profile:0,radioGroup:1,readOnly:1,referrerPolicy:1,rel:0,required:0,reversed:0,role:0,rows:0,rowSpan:1,sandbox:0,scope:0,scoped:0,scrolling:0,seamless:0,selected:0,shape:0,size:0,sizes:0,span:0,spellCheck:1,src:0,srcDoc:1,srcLang:1,srcSet:1,start:0,step:0,style:0,summary:0,tabIndex:1,target:0,title:0,type:0,useMap:1,value:0,width:0,wmode:0,wrap:0,about:0,accentHeight:1,"accent-height":"accentHeight",accumulate:0,additive:0,alignmentBaseline:1,"alignment-baseline":"alignmentBaseline",allowReorder:1,alphabetic:0,amplitude:0,arabicForm:1,"arabic-form":"arabicForm",ascent:0,attributeName:1,attributeType:1,autoReverse:1,azimuth:0,baseFrequency:1,baselineShift:1,"baseline-shift":"baselineShift",baseProfile:1,bbox:0,begin:0,bias:0,by:0,calcMode:1,capHeight:1,"cap-height":"capHeight",clip:0,clipPath:1,"clip-path":"clipPath",clipPathUnits:1,clipRule:1,"clip-rule":"clipRule",color:0,colorInterpolation:1,"color-interpolation":"colorInterpolation",colorInterpolationFilters:1,"color-interpolation-filters":"colorInterpolationFilters",colorProfile:1,"color-profile":"colorProfile",colorRendering:1,"color-rendering":"colorRendering",contentScriptType:1,contentStyleType:1,cursor:0,cx:0,cy:0,d:0,datatype:0,decelerate:0,descent:0,diffuseConstant:1,direction:0,display:0,divisor:0,dominantBaseline:1,"dominant-baseline":"dominantBaseline",dur:0,dx:0,dy:0,edgeMode:1,elevation:0,enableBackground:1,"enable-background":"enableBackground",end:0,exponent:0,externalResourcesRequired:1,fill:0,fillOpacity:1,"fill-opacity":"fillOpacity",fillRule:1,"fill-rule":"fillRule",filter:0,filterRes:1,filterUnits:1,floodOpacity:1,"flood-opacity":"floodOpacity",floodColor:1,"flood-color":"floodColor",focusable:0,fontFamily:1,"font-family":"fontFamily",fontSize:1,"font-size":"fontSize",fontSizeAdjust:1,"font-size-adjust":"fontSizeAdjust",fontStretch:1,"font-stretch":"fontStretch",fontStyle:1,"font-style":"fontStyle",fontVariant:1,"font-variant":"fontVariant",fontWeight:1,"font-weight":"fontWeight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:1,"glyph-name":"glyphName",glyphOrientationHorizontal:1,"glyph-orientation-horizontal":"glyphOrientationHorizontal",glyphOrientationVertical:1,"glyph-orientation-vertical":"glyphOrientationVertical",glyphRef:1,gradientTransform:1,gradientUnits:1,hanging:0,horizAdvX:1,"horiz-adv-x":"horizAdvX",horizOriginX:1,"horiz-origin-x":"horizOriginX",ideographic:0,imageRendering:1,"image-rendering":"imageRendering",in2:0,in:0,inlist:0,intercept:0,k1:0,k2:0,k3:0,k4:0,k:0,kernelMatrix:1,kernelUnitLength:1,kerning:0,keyPoints:1,keySplines:1,keyTimes:1,lengthAdjust:1,letterSpacing:1,"letter-spacing":"letterSpacing",lightingColor:1,"lighting-color":"lightingColor",limitingConeAngle:1,local:0,markerEnd:1,"marker-end":"markerEnd",markerHeight:1,markerMid:1,"marker-mid":"markerMid",markerStart:1,"marker-start":"markerStart",markerUnits:1,markerWidth:1,mask:0,maskContentUnits:1,maskUnits:1,mathematical:0,mode:0,numOctaves:1,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:1,"overline-position":"overlinePosition",overlineThickness:1,"overline-thickness":"overlineThickness",paintOrder:1,"paint-order":"paintOrder",panose1:0,"panose-1":"panose1",pathLength:1,patternContentUnits:1,patternTransform:1,patternUnits:1,pointerEvents:1,"pointer-events":"pointerEvents",points:0,pointsAtX:1,pointsAtY:1,pointsAtZ:1,prefix:0,preserveAlpha:1,preserveAspectRatio:1,primitiveUnits:1,property:0,r:0,radius:0,refX:1,refY:1,renderingIntent:1,"rendering-intent":"renderingIntent",repeatCount:1,repeatDur:1,requiredExtensions:1,requiredFeatures:1,resource:0,restart:0,result:0,results:0,rotate:0,rx:0,ry:0,scale:0,security:0,seed:0,shapeRendering:1,"shape-rendering":"shapeRendering",slope:0,spacing:0,specularConstant:1,specularExponent:1,speed:0,spreadMethod:1,startOffset:1,stdDeviation:1,stemh:0,stemv:0,stitchTiles:1,stopColor:1,"stop-color":"stopColor",stopOpacity:1,"stop-opacity":"stopOpacity",strikethroughPosition:1,"strikethrough-position":"strikethroughPosition",strikethroughThickness:1,"strikethrough-thickness":"strikethroughThickness",string:0,stroke:0,strokeDasharray:1,"stroke-dasharray":"strokeDasharray",strokeDashoffset:1,"stroke-dashoffset":"strokeDashoffset",strokeLinecap:1,"stroke-linecap":"strokeLinecap",strokeLinejoin:1,"stroke-linejoin":"strokeLinejoin",strokeMiterlimit:1,"stroke-miterlimit":"strokeMiterlimit",strokeWidth:1,"stroke-width":"strokeWidth",strokeOpacity:1,"stroke-opacity":"strokeOpacity",suppressContentEditableWarning:1,suppressHydrationWarning:1,surfaceScale:1,systemLanguage:1,tableValues:1,targetX:1,targetY:1,textAnchor:1,"text-anchor":"textAnchor",textDecoration:1,"text-decoration":"textDecoration",textLength:1,textRendering:1,"text-rendering":"textRendering",to:0,transform:0,typeof:0,u1:0,u2:0,underlinePosition:1,"underline-position":"underlinePosition",underlineThickness:1,"underline-thickness":"underlineThickness",unicode:0,unicodeBidi:1,"unicode-bidi":"unicodeBidi",unicodeRange:1,"unicode-range":"unicodeRange",unitsPerEm:1,"units-per-em":"unitsPerEm",unselectable:0,vAlphabetic:1,"v-alphabetic":"vAlphabetic",values:0,vectorEffect:1,"vector-effect":"vectorEffect",version:0,vertAdvY:1,"vert-adv-y":"vertAdvY",vertOriginX:1,"vert-origin-x":"vertOriginX",vertOriginY:1,"vert-origin-y":"vertOriginY",vHanging:1,"v-hanging":"vHanging",vIdeographic:1,"v-ideographic":"vIdeographic",viewBox:1,viewTarget:1,visibility:0,vMathematical:1,"v-mathematical":"vMathematical",vocab:0,widths:0,wordSpacing:1,"word-spacing":"wordSpacing",writingMode:1,"writing-mode":"writingMode",x1:0,x2:0,x:0,xChannelSelector:1,xHeight:1,"x-height":"xHeight",xlinkActuate:1,"xlink:actuate":"xlinkActuate",xlinkArcrole:1,"xlink:arcrole":"xlinkArcrole",xlinkHref:1,"xlink:href":"xlinkHref",xlinkRole:1,"xlink:role":"xlinkRole",xlinkShow:1,"xlink:show":"xlinkShow",xlinkTitle:1,"xlink:title":"xlinkTitle",xlinkType:1,"xlink:type":"xlinkType",xmlBase:1,"xml:base":"xmlBase",xmlLang:1,"xml:lang":"xmlLang",xmlns:0,"xml:space":"xmlSpace",xmlnsXlink:1,"xmlns:xlink":"xmlnsXlink",xmlSpace:1,y1:0,y2:0,y:0,yChannelSelector:1,z:0,zoomAndPan:1};Object.defineProperty(lib$4,"__esModule",{value:!0});function _slicedToArray(l,e){return _arrayWithHoles(l)||_iterableToArrayLimit(l,e)||_unsupportedIterableToArray(l,e)||_nonIterableRest()}function _arrayWithHoles(l){if(Array.isArray(l))return l}function _iterableToArrayLimit(l,e){var n=l==null?null:typeof Symbol<"u"&&l[Symbol.iterator]||l["@@iterator"];if(n!=null){var t=[],a=!0,o=!1,d,h;try{for(n=n.call(l);!(a=(d=n.next()).done)&&(t.push(d.value),!(e&&t.length===e));a=!0);}catch(f){o=!0,h=f}finally{try{!a&&n.return!=null&&n.return()}finally{if(o)throw h}}return t}}function _unsupportedIterableToArray(l,e){if(l){if(typeof l=="string")return _arrayLikeToArray(l,e);var n=Object.prototype.toString.call(l).slice(8,-1);if(n==="Object"&&l.constructor&&(n=l.constructor.name),n==="Map"||n==="Set")return Array.from(l);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(l,e)}}function _arrayLikeToArray(l,e){(e==null||e>l.length)&&(e=l.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=l[n];return t}function _nonIterableRest(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
65
65
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var RESERVED=0,STRING=1,BOOLEANISH_STRING=2,BOOLEAN=3,OVERLOADED_BOOLEAN=4,NUMERIC=5,POSITIVE_NUMERIC=6;function getPropertyInfo(l){return properties.hasOwnProperty(l)?properties[l]:null}function PropertyInfoRecord(l,e,n,t,a,o,d){this.acceptsBooleans=e===BOOLEANISH_STRING||e===BOOLEAN||e===OVERLOADED_BOOLEAN,this.attributeName=t,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=l,this.type=e,this.sanitizeURL=o,this.removeEmptyString=d}var properties={},reservedProps=["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"];reservedProps.forEach(function(l){properties[l]=new PropertyInfoRecord(l,RESERVED,!1,l,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var e=_slicedToArray(l,2),n=e[0],t=e[1];properties[n]=new PropertyInfoRecord(n,STRING,!1,t,null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEANISH_STRING,!1,l.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEANISH_STRING,!1,l,null,!1,!1)});["allowFullScreen","async","autoFocus","autoPlay","controls","default","defer","disabled","disablePictureInPicture","disableRemotePlayback","formNoValidate","hidden","loop","noModule","noValidate","open","playsInline","readOnly","required","reversed","scoped","seamless","itemScope"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEAN,!1,l.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEAN,!0,l,null,!1,!1)});["capture","download"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,OVERLOADED_BOOLEAN,!1,l,null,!1,!1)});["cols","rows","size","span"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,POSITIVE_NUMERIC,!1,l,null,!1,!1)});["rowSpan","start"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,NUMERIC,!1,l.toLowerCase(),null,!1,!1)});var CAMELIZE=/[\-\:]([a-z])/g,capitalize$1=function l(e){return e[1].toUpperCase()};["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","xmlns:xlink","x-height"].forEach(function(l){var e=l.replace(CAMELIZE,capitalize$1);properties[e]=new PropertyInfoRecord(e,STRING,!1,l,null,!1,!1)});["xlink:actuate","xlink:arcrole","xlink:role","xlink:show","xlink:title","xlink:type"].forEach(function(l){var e=l.replace(CAMELIZE,capitalize$1);properties[e]=new PropertyInfoRecord(e,STRING,!1,l,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(l){var e=l.replace(CAMELIZE,capitalize$1);properties[e]=new PropertyInfoRecord(e,STRING,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,STRING,!1,l.toLowerCase(),null,!1,!1)});var xlinkHref="xlinkHref";properties[xlinkHref]=new PropertyInfoRecord("xlinkHref",STRING,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,STRING,!1,l.toLowerCase(),null,!0,!0)});var _require=possibleStandardNamesOptimized$1,CAMELCASE=_require.CAMELCASE,SAME=_require.SAME,possibleStandardNamesOptimized=_require.possibleStandardNames,ATTRIBUTE_NAME_START_CHAR=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",ATTRIBUTE_NAME_CHAR=ATTRIBUTE_NAME_START_CHAR+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",isCustomAttribute=RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+ATTRIBUTE_NAME_CHAR+"]*$")),possibleStandardNames=Object.keys(possibleStandardNamesOptimized).reduce(function(l,e){var n=possibleStandardNamesOptimized[e];return n===SAME?l[e]=e:n===CAMELCASE?l[e.toLowerCase()]=e:l[e]=n,l},{});lib$4.BOOLEAN=BOOLEAN;lib$4.BOOLEANISH_STRING=BOOLEANISH_STRING;lib$4.NUMERIC=NUMERIC;lib$4.OVERLOADED_BOOLEAN=OVERLOADED_BOOLEAN;lib$4.POSITIVE_NUMERIC=POSITIVE_NUMERIC;lib$4.RESERVED=RESERVED;lib$4.STRING=STRING;lib$4.getPropertyInfo=getPropertyInfo;lib$4.isCustomAttribute=isCustomAttribute;lib$4.possibleStandardNames=possibleStandardNames;var cjs={},COMMENT_REGEX=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,NEWLINE_REGEX=/\n/g,WHITESPACE_REGEX=/^\s*/,PROPERTY_REGEX=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,COLON_REGEX=/^:\s*/,VALUE_REGEX=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,SEMICOLON_REGEX=/^[;\s]*/,TRIM_REGEX=/^\s+|\s+$/g,NEWLINE=`
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(E){var g=E.match(NEWLINE_REGEX);g&&(n+=g.length);var v=E.lastIndexOf(NEWLINE);t=~v?E.length-v:t+E.length}function o(){var E={line:n,column:t};return function(g){return g.position=new d(E),u(),g}}function d(E){this.start=E,this.end={line:n,column:t},this.source=e.source}d.prototype.content=l;function h(E){var g=new Error(e.source+":"+n+":"+t+": "+E);if(g.reason=E,g.filename=e.source,g.line=n,g.column=t,g.source=l,!e.silent)throw g}function f(E){var g=E.exec(l);if(g){var v=g[0];return a(v),l=l.slice(v.length),g}}function u(){f(WHITESPACE_REGEX)}function p(E){var g;for(E=E||[];g=x();)g!==!1&&E.push(g);return E}function x(){var E=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 v=l.slice(2,g-2);return t+=2,a(v),l=l.slice(g),t+=2,E({type:TYPE_COMMENT,comment:v})}}function R(){var E=o(),g=f(PROPERTY_REGEX);if(g){if(x(),!f(COLON_REGEX))return h("property missing ':'");var v=f(VALUE_REGEX),T=E({type:TYPE_DECLARATION,property:trim(g[0].replace(COMMENT_REGEX,EMPTY_STRING$1)),value:v?trim(v[0].replace(COMMENT_REGEX,EMPTY_STRING$1)):EMPTY_STRING$1});return f(SEMICOLON_REGEX),T}}function S(){var E=[];p(E);for(var g;g=R();)g!==!1&&(E.push(g),p(E));return E}return u(),S()};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,x,R,S=e.trim,E=0,g=l.length;E<g;E++){if(h=l[E],u&&(p=e.replace(h),o(p))){g>1&&(p=t(p,{key:p.key||E})),d.push(p);continue}if(h.type==="text"){if(f=!h.data.trim().length,f&&h.parent&&!canTextBeChildOfNode(h.parent)||S&&f)continue;d.push(h.data);continue}switch(x=h.attribs,skipAttributesToProps(h)?setStyleProp(x.style,x):x&&(x=attributesToProps$1(x)),R=null,h.type){case"script":case"style":h.children[0]&&(x.dangerouslySetInnerHTML={__html:h.children[0].data});break;case"tag":h.name==="textarea"&&h.children[0]?x.defaultValue=h.children[0].data:h.children&&h.children.length&&(R=domToReact$1(h.children,e));break;default:continue}g>1&&(x.key=E),d.push(a(h.name,x,R))}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={};(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);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=lib$3,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,x){x===void 0&&(x=p);var R=Object.getOwnPropertyDescriptor(u,p);(!R||("get"in R?!u.__esModule:R.writable||R.configurable))&&(R={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(f,x,R)}:function(f,u,p,x){x===void 0&&(x=p),f[x]=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=lib$3,a=node;n(node,l);var o=/\s+/g,d={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1,xmlMode:!1},h=function(){function f(u,p,x){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"&&(x=p,p=d),typeof u=="object"&&(p=u,u=void 0),this.callback=u??null,this.options=p??d,this.elementCB=x??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 x=this.options.xmlMode?t.ElementType.Tag:void 0,R=new a.Element(u,p,void 0,x);this.addNode(R),this.tagStack.push(R)},f.prototype.ontext=function(u){var p=this.options.normalizeWhitespace,x=this.lastNode;if(x&&x.type===t.ElementType.Text)p?x.data=(x.data+u).replace(o," "):x.data+=u,this.options.withEndIndices&&(x.endIndex=this.parser.endIndex);else{p&&(u=u.replace(o," "));var R=new a.Text(u);this.addNode(R),this.lastNode=R}},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 x=new a.ProcessingInstruction(u,p);this.addNode(x)},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],x=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),x&&(u.prev=x,x.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=()=>{},useEkho=({voice:l,text:e,audioType:n,loop:t=!1,started:a=!0,slide:o=0,audio:d,soundActions:h,emitEvent:f,volume:u=.5,onFinish:p=noop$1,onError:x=noop$1,onStart:R=noop$1,pauseTTS:S})=>{const[E,g,v,T]=h,b=!d&&!l,[_,w]=React$2.useState(!1),C=React$2.useRef({url:"",cc:"tts"}),P=React$2.useCallback(M=>f({type:"translate",payload:M}),[f]),D=React$2.useCallback(({id:M,type:U="base"})=>{var J;const $=P("usedVoices"),B=P("gameCharacters");return U==="base"?$==null?void 0:$[M]:U==="character"?(J=B==null?void 0:B[M])==null?void 0:J.voiceId:null},[P]),N=React$2.useCallback((M,U="tts")=>{C.current.url===M&&o===C.current.slide||(C.current={url:M,cc:U,slide:o},E(M,U,t,u,p,R,x))},[o,E,t,u,p,R,x]),k=React$2.useCallback(async M=>{if(_&&M.voiceId&&M.text){const U=await f({type:"getSpeech",payload:M});U?N(U):x()}else x()},[f,_,x,N]),F=React$2.useCallback(()=>{C.current.url&&g(C.current.cc)},[g]);return React$2.useEffect(()=>(w(!0),()=>{w(!1),F()}),[F]),React$2.useEffect(()=>{S?v():T()},[v,S,T]),React$2.useEffect(()=>{b&&F()},[b,F]),React$2.useEffect(()=>{if(_&&a)if(n==="voice"&&(l!=null&&l.id)){const M=D(l);k({voiceId:M,text:e})}else(n==="file"||!n)&&d?N(d==null?void 0:d.url):x()},[D,k,_,l,e,n,d==null?void 0:d.url,d,N,x,a]),F},cleanTextOfHtmlTags=l=>{const e=/<\/p>|<\/h1>|<\/h2>|<\/h3>|<\/h4>|<\/h5>|<\/h6>|<\/li>/gi,n=/&quot;|&#39;/gi;if(l)return l.replace(e,". </p>").replace(n,"").replace(/(<([^>]+)>)/gi,"")},READING_TIME=.2;function LecturesComponent({emitEvent:l,name:e,name_labelId:n,required:t,text:a,text_labelId:o,visible:d,documentType:h,viewed:f,soundActions:u,backgroundImage:p,hideBackgroundImageTheme:x=!1,keyboardControl:R,audio:S,audioType:E,audioVolume:g,voice:v,pause:T,styles:b}){const[_,w]=React$2.useState(),[C,P]=React$2.useState(!1),[D,N]=React$2.useState(0),k=a,F=Math.trunc(k.split(" ").length*READING_TIME),M=!t||t&&D>=F||t&&!d,[U]=u,$=`${e}. ${cleanTextOfHtmlTags(a)}`;useEkho({audioType:E,voice:v,text:$,audio:S,soundActions:u,emitEvent:l,volume:g,pauseTTS:T});const B=fe=>l({type:"translate",payload:fe}),J=React$2.useCallback(()=>{M&&(U("click-ui"),l({type:"finishMedia",payload:{name:n,type:"text",text:o,documentType:h}}))},[h,l,M,n,o,U]),ne=R({disabled:f,forward:J,escape:J});React$2.useEffect(()=>ne(),[ne]),React$2.useEffect(()=>{if(!d&&!C&&(J(),P(!0)),t&&d){const fe=setInterval(()=>{N(te=>te+1)},1e3);return w(fe),()=>{clearInterval(fe)}}},[J,t,C,d]),React$2.useEffect(()=>{D===F&&clearInterval(_)},[_,D,F]);const ie=F-D,Y=Math.floor(ie/60),q=ie%60,re=React$2.useMemo(()=>{let fe="";return f?fe="notes--results":(fe="lectures--container",b&&(fe+=` lectures--container--${b}`),p!=null&&p.url&&(fe+=" lectures--container--with-custom-bg"),b&&x&&(fe+=" disable-background-image")),fe},[p==null?void 0:p.url,x,b,f]),ce={backgroundImage:p!=null&&p.url?`url('${p.url}')`:""};return d?jsxRuntimeExports.jsx("div",{className:re,style:ce,children:jsxRuntimeExports.jsx("div",{className:f?"":"lectures__overlay",children:jsxRuntimeExports.jsxs("div",{className:f?"notes--results__text":`lectures lectures--${b}`,children:[jsxRuntimeExports.jsx("div",{className:"lectures--title",children:e}),jsxRuntimeExports.jsxs("div",{className:"lectures--text",dir:"auto",children:[jsxRuntimeExports.jsx("div",{children:k?HTMLReactParser$1(k):null}),f?null:jsxRuntimeExports.jsx(LectureButtons,{goToLecture:M,close:J,minutes:Y,seconds:q,btnText:B("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 R;const a=l.type==="image",o=l.type==="character",d=l.type==="object",h=(R=l==null?void 0:l.resource)==null?void 0:R.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":"",x=a||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:p(),backgroundSize:u()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${n}`,style:x,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(x){a&&a(x);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 x=this.pluginCallbacks[p](u);x.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),h[x.name]=x,d[x.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const x=o.extensionsUsed[p],R=o.extensionsRequired||[];switch(x){case EXTENSIONS.KHR_MATERIALS_UNLIT:d[x]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:d[x]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:d[x]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:d[x]=new GLTFMeshQuantizationExtension;break;default:R.indexOf(x)>=0&&h[x]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+x+'".')}}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 x=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=x;break;case"spot":u=new three.SpotLight(p),u.distance=x,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,x=a.byteStride,R=new Uint8Array(h,f,u);return d.decodeGltfBufferAsync?d.decodeGltfBufferAsync(p,x,R,a.mode,a.filter).then(function(S){return S.buffer}):d.ready.then(function(){const S=new ArrayBuffer(p*x);return d.decodeGltfBuffer(new Uint8Array(S),p,x,R,a.mode,a.filter),S})})}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(),x=p.isGroup?p.children:[p],R=u[0].count,S=[];for(const E of x){const g=new three.Matrix4,v=new three.Vector3,T=new three.Quaternion,b=new three.Vector3(1,1,1),_=new three.InstancedMesh(E.geometry,E.material,R);for(let w=0;w<R;w++)f.TRANSLATION&&v.fromBufferAttribute(f.TRANSLATION,w),f.ROTATION&&T.fromBufferAttribute(f.ROTATION,w),f.SCALE&&b.fromBufferAttribute(f.SCALE,w),_.setMatrixAt(w,g.compose(v,T,b));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"&&E.geometry.setAttribute(w,f[w]);three.Object3D.prototype.copy.call(_,E),this.parser.assignFinalMaterial(_),S.push(_)}return p.isGroup?(p.clear(),p.add(...S),p):S[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 x=ATTRIBUTES[p]||p.toLowerCase();h[x]=d[p]}for(const p in e.attributes){const x=ATTRIBUTES[p]||p.toLowerCase();if(d[p]!==void 0){const R=t.accessors[e.attributes[p]],S=WEBGL_COMPONENT_TYPES[R.componentType];u[x]=S.name,f[x]=R.normalized===!0}}return n.getDependency("bufferView",o).then(function(p){return new Promise(function(x,R){a.decodeDracoFile(p,function(S){for(const E in S.attributes){const g=S.attributes[E],v=f[E];v!==void 0&&(g.normalized=v)}x(S)},h,u,three.LinearSRGBColorSpace,R)})})}}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,x=(t-n)/p,R=x*x,S=R*x,E=e*u,g=E-u,v=-2*S+3*R,T=S-R,b=1-v,_=T-R+x;for(let w=0;w!==h;w++){const C=d[g+w+h],P=d[g+w+f]*p,D=d[E+w+h],N=d[E+w]*p;o[w]=b*C+_*P+v*D+T*N}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 x=e[u];if(x.POSITION!==void 0&&(t=!0),x.NORMAL!==void 0&&(a=!0),x.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 x=e[u];if(t){const R=x.POSITION!==void 0?n.getDependency("accessor",x.POSITION):l.attributes.position;d.push(R)}if(a){const R=x.NORMAL!==void 0?n.getDependency("accessor",x.NORMAL):l.attributes.normal;h.push(R)}if(o){const R=x.COLOR_0!==void 0?n.getDependency("accessor",x.COLOR_0):l.attributes.color;f.push(R)}}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f)]).then(function(u){const p=u[0],x=u[1],R=u[2];return t&&(l.morphAttributes.position=p),a&&(l.morphAttributes.normal=x),o&&(l.morphAttributes.color=R),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,x=p*f,R=a.byteOffset||0,S=a.bufferView!==void 0?t.bufferViews[a.bufferView].byteStride:void 0,E=a.normalized===!0;let g,v;if(S&&S!==x){const T=Math.floor(R/S),b="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+T+":"+a.count;let _=n.cache.get(b);_||(g=new u(h,T*S,a.count*S/p),_=new three.InterleavedBuffer(g,S/p),n.cache.add(b,_)),v=new three.InterleavedBufferAttribute(_,f,R%S/p,E)}else h===null?g=new u(a.count*f):g=new u(h,R,a.count*f),v=new three.BufferAttribute(g,f,E);if(a.sparse!==void 0){const T=WEBGL_TYPE_SIZES.SCALAR,b=WEBGL_COMPONENT_TYPES[a.sparse.indices.componentType],_=a.sparse.indices.byteOffset||0,w=a.sparse.values.byteOffset||0,C=new b(d[1],_,a.sparse.count*T),P=new u(d[2],w,a.sparse.count*f);h!==null&&(v=new three.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let D=0,N=C.length;D<N;D++){const k=C[D];if(v.setX(k,P[D*f]),f>=2&&v.setY(k,P[D*f+1]),f>=3&&v.setZ(k,P[D*f+2]),f>=4&&v.setW(k,P[D*f+3]),f>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}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 R=(o.samplers||{})[d.sampler]||{};return p.magFilter=WEBGL_FILTERS[R.magFilter]||three.LinearFilter,p.minFilter=WEBGL_FILTERS[R.minFilter]||three.LinearMipmapLinearFilter,p.wrapS=WEBGL_WRAPPINGS[R.wrapS]||three.RepeatWrapping,p.wrapT=WEBGL_WRAPPINGS[R.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(x=>x.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(x){u=!0;const R=new Blob([x],{type:d.mimeType});return f=h.createObjectURL(R),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(x){return new Promise(function(R,S){let E=R;n.isImageBitmapLoader===!0&&(E=function(g){const v=new three.Texture(g);v.needsUpdate=!0,R(v)}),n.load(three.LoaderUtils.resolveURL(x,o.path),E,void 0,S)})}).then(function(x){return u===!0&&h.revokeObjectURL(f),x.userData.mimeType=d.mimeType||getImageURIMimeType(d.uri),x}).catch(function(x){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),x});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 x=a[EXTENSIONS.KHR_MATERIALS_UNLIT];d=x.getMaterialType(),u.push(x.extendParams(h,o,n))}else{const x=o.pbrMetallicRoughness||{};if(h.color=new three.Color(1,1,1),h.opacity=1,Array.isArray(x.baseColorFactor)){const R=x.baseColorFactor;h.color.setRGB(R[0],R[1],R[2],three.LinearSRGBColorSpace),h.opacity=R[3]}x.baseColorTexture!==void 0&&u.push(n.assignTexture(h,"map",x.baseColorTexture,three.SRGBColorSpace)),h.metalness=x.metallicFactor!==void 0?x.metallicFactor:1,h.roughness=x.roughnessFactor!==void 0?x.roughnessFactor:1,x.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(h,"metalnessMap",x.metallicRoughnessTexture)),u.push(n.assignTexture(h,"roughnessMap",x.metallicRoughnessTexture))),d=this._invokeOne(function(R){return R.getMaterialType&&R.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(R){return R.extendMaterialParams&&R.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 x=o.normalTexture.scale;h.normalScale.set(x,x)}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 x=o.emissiveFactor;h.emissive=new three.Color().setRGB(x[0],x[1],x[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 x=new d(h);return o.name&&(x.name=o.name),assignExtrasToUserData(x,o),n.associations.set(x,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(a,x,o),x})}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),x=a[p];if(x)d.push(x.promise);else{let R;u.extensions&&u.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?R=o(u):R=addPrimitiveAttributes(new three.BufferGeometry,u,n),a[p]={primitive:u,promise:R},d.push(R)}}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],x=[];for(let S=0,E=p.length;S<E;S++){const g=p[S],v=d[S];let T;const b=u[S];if(v.mode===WEBGL_CONSTANTS.TRIANGLES||v.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||v.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||v.mode===void 0)T=o.isSkinnedMesh===!0?new three.SkinnedMesh(g,b):new three.Mesh(g,b),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),v.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?T.geometry=toTrianglesDrawMode(T.geometry,three.TriangleStripDrawMode):v.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(T.geometry=toTrianglesDrawMode(T.geometry,three.TriangleFanDrawMode));else if(v.mode===WEBGL_CONSTANTS.LINES)T=new three.LineSegments(g,b);else if(v.mode===WEBGL_CONSTANTS.LINE_STRIP)T=new three.Line(g,b);else if(v.mode===WEBGL_CONSTANTS.LINE_LOOP)T=new three.LineLoop(g,b);else if(v.mode===WEBGL_CONSTANTS.POINTS)T=new three.Points(g,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(T.geometry.morphAttributes).length>0&&updateMorphTargets(T,o),T.name=n.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(T,o),v.extensions&&addUnknownExtensionsToUserData(a,T,v),n.assignFinalMaterial(T),x.push(T)}for(let S=0,E=x.length;S<E;S++)n.associations.set(x[S],{meshes:e,primitives:S});if(x.length===1)return o.extensions&&addUnknownExtensionsToUserData(a,x[0],o),x[0];const R=new three.Group;o.extensions&&addUnknownExtensionsToUserData(a,R,o),n.associations.set(R,{meshes:e});for(let S=0,E=x.length;S<E;S++)R.add(x[S]);return R})}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 x=d[u];if(x){h.push(x);const R=new three.Matrix4;o!==null&&R.fromArray(o.array,u*16),f.push(R)}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 x=0,R=a.channels.length;x<R;x++){const S=a.channels[x],E=a.samplers[S.sampler],g=S.target,v=g.node,T=a.parameters!==void 0?a.parameters[E.input]:E.input,b=a.parameters!==void 0?a.parameters[E.output]:E.output;g.node!==void 0&&(d.push(this.getDependency("node",v)),h.push(this.getDependency("accessor",T)),f.push(this.getDependency("accessor",b)),u.push(E),p.push(g))}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f),Promise.all(u),Promise.all(p)]).then(function(x){const R=x[0],S=x[1],E=x[2],g=x[3],v=x[4],T=[];for(let b=0,_=R.length;b<_;b++){const w=R[b],C=S[b],P=E[b],D=g[b],N=v[b];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const k=t._createAnimationTracks(w,C,P,D,N);if(k)for(let F=0;F<k.length;F++)T.push(k[F])}return new three.AnimationClip(o,void 0,T)})}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],x=u[1],R=u[2];R!==null&&p.traverse(function(S){S.isSkinnedMesh&&S.bind(R,_identityMatrix)});for(let S=0,E=x.length;S<E;S++)p.add(x[S]);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 x=0,R=u.length;x<R;x++)p.add(u[x]);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 x=new three.Matrix4;x.fromArray(o.matrix),p.applyMatrix4(x)}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,x=f.length;p<x;p++)o.add(f[p]);const u=p=>{const x=new Map;for(const[R,S]of a.associations)(R instanceof three.Material||R instanceof three.Texture)&&x.set(R,S);return p.traverse(R=>{const S=a.associations.get(R);S!=null&&x.set(R,S)}),x};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(R){R.morphTargetInfluences&&f.push(R.name?R.name:R.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,x=this._getArrayFromAccessor(t);for(let R=0,S=f.length;R<S;R++){const E=new u(f[R]+"."+PATH_PROPERTIES[o.path],n.array,x,p);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(E),d.push(E)}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 x=o[u];if(x.POSITION!==void 0){const R=n.json.accessors[x.POSITION],S=R.min,E=R.max;if(S!==void 0&&E!==void 0){if(f.setX(Math.max(Math.abs(S[0]),Math.abs(E[0]))),f.setY(Math.max(Math.abs(S[1]),Math.abs(E[1]))),f.setZ(Math.max(Math.abs(S[2]),Math.abs(E[2]))),R.normalized){const g=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[R.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}){var R,S,E,g,v;const t=React$2.useRef(null),a=React$2.useRef(null),o=l.type==="character",[d,h]=React$2.useState(!1),f=React$2.useRef(),u=React$2.useMemo(()=>{var T,b,_,w,C,P,D,N;return o?l.animationId&&((T=l.animation)!=null&&T.url)?l.animation:(w=(_=(b=l==null?void 0:l.resource)==null?void 0:b.animations)==null?void 0:_[l.emotion])!=null&&w.url?(P=(C=l==null?void 0:l.resource)==null?void 0:C.animations)==null?void 0:P[l.emotion]:(N=(D=l==null?void 0:l.resource)==null?void 0:D.animations)==null?void 0:N.neutral:{}},[l.emotion,l==null?void 0:l.animationId,l==null?void 0:l.animation,(R=l==null?void 0:l.resource)==null?void 0:R.animations,o]),p=React$2.useCallback(()=>{var T;if((T=f.current.userData)!=null&&T.animation){const{clipAction:b,defaultAnim:_}=f.current.userData.animation;_&&b(_)}},[]);React$2.useEffect(()=>{var T,b,_;if(f.current)if(n)if(e){const w=(_=(b=(T=l==null?void 0:l.resource)==null?void 0:T.animations)==null?void 0:b.talking)==null?void 0:_.url;w&&loader$1.load(w,({animations:C})=>{if(!f.current)return;const{defaultAnim:P,clipAction:D}=f.current.userData.animation;D(mixWithTalkingClip(C[0],P)),h(!0)})}else p();else d&&p()},[(g=(E=(S=l==null?void 0:l.resource)==null?void 0:S.animations)==null?void 0:E.talking)==null?void 0:g.url,e,n,p,d]);const x=React$2.useCallback(T=>{if(l.type==="character"){const b=T.getObjectByName("Head_M",!0);b?(b.updateMatrixWorld(!0),box.setFromObject(T),box.getSize(size),b.getWorldPosition(worldPos),t.current.lookAt(worldPos)):t.current.position.setY(size.y-1.5*1.3),t.current.zoom=1.5}else cameraFitAnyObject(T,t.current),t.current.zoom=1;t.current.updateProjectionMatrix()},[l]);return fiber.useFrame(({gl:T,scene:b})=>{if(t.current&&a.current){const _=document.querySelectorAll(".conversation--character__item")[l.slot];if(_){const w=_.getBoundingClientRect(),C=_.parentNode.getBoundingClientRect(),[P,D]=[w.right-w.left,w.bottom-w.top];if(t.current.aspect=P/D,t.current.updateProjectionMatrix(),o&&f.current){box.setFromObject(f.current),box.getSize(size);const F=f.current.getObjectByName("Head_M",!0);F?(F.getWorldPosition(worldPos),t.current.lookAt(worldPos)):t.current.position.setY(size.y-1.5*1.3),t.current.zoom=1.5}const N={top:w.top-C.top,right:w.right-C.right,left:w.left-C.left,bottom:w.bottom-C.bottom},k=isMobile?24:40;N.bottom+=n?-k:k,T.setViewport(N.left,N.bottom,P,D),T.setScissor(N.left,N.bottom,P,D),a.current.environment=b.environment,T.render(a.current,t.current)}}},1),l.type==="image"?null:jsxRuntimeExports.jsxs("scene",{ref:a,children:[(v=l.resource)!=null&&v.url?jsxRuntimeExports.jsx(arcadeThreeCore.SceneResource,{ref:f,name:`char_${l.uid}`,url:l.resource.url,animationUrl:u.url,type:l.type,onLoad:x,texturable:!0,interactive:!0,merge:l.type!=="character"}):null,jsxRuntimeExports.jsx(drei.PerspectiveCamera,{ref:t,fov:35,position:defaultCamPos,rotation:[0,0,0],onUpdate:T=>{T.layers.enableAll()},manual:!0}),jsxRuntimeExports.jsx(LightSet,{})]})}function PanelsWrapper({characters:l,slots:e,ttsStarted:n,flex:t,currentMessage:a,emitEvent:o}){fiber.useFrame(({gl:h})=>{h.setScissorTest(!1),h.clear(!0,!0),h.setScissorTest(!0)});const d=React$2.useMemo(()=>o({type:"currentLod"}),[o]);return jsxRuntimeExports.jsx(arcadeThreeCore.QualityManager,{lod:d,active:!0,children:e.map((h,f)=>{let u=null;const p=l.findIndex(x=>x&&x.uid===h.uid);if(p>=0){const x=t?p:f;return u={...l[p]},u.slot=x,jsxRuntimeExports.jsx(Panel,{character:u,active:a.position===x,ttsStarted:n,emitEvent:o},`${`${u.uid}_${f}`}_${p}`)}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,emitEvent:u}){const p=({character:T,active:b,slot:_})=>({character:T,active:b,emotion:b?a.emotion:"neutral",slot:_}),R=React$2.useMemo(()=>u({type:"currentLod"}),[u])==="divideby64",S=d.reduce((T,b)=>{var C,P;const _=e==null?void 0:e.find(D=>D.uid===b.uid),w={...b};if(b.character)w.name=b.alias||b.character.name,w.resource=w.character.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type="character",T.push(w);else if(_){const{resource:D}=_;w.name=b.alias||b.name,w.position=w.position>=0?w.position:-1,w.resource=D,w.type=_.type,T.push(w)}else b.type?(w.name=b.alias||((C=b.character)==null?void 0:C.name)||b.name,w.resource=((P=w.character)==null?void 0:P.resource)||b.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type=b.type,T.push(w)):o||T.push(null);return T},[]),E=S.length&&S.some(T=>T),g=l.filter(T=>d.find(b=>T.uid===b.uid));function v(){return E?S.map((T,b)=>T?jsxRuntimeExports.jsx(Slot,{emitEvent:u,lowQuality:R,...p({character:T,active:a.position===T.position,slot:b})},`${T.uid+b}`):jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${b}`},`void_${0+b}`)):o?g.map((T,b)=>{const _=a.position===b;return jsxRuntimeExports.jsx(Slot,{...p({character:T,active:_,slot:b})},`${T.uid+b}`)}):d.length>0?d.map((T,b)=>{const _=l.find(w=>w.uid===T.uid);if(_){const w=a.position===b;return _.name=T.alias||_.name,jsxRuntimeExports.jsx(Slot,{...p({character:_,active:w,slot:b})},`${_.uid+b}`)}return jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${b}`},`${0+b}`)}):null}return jsxRuntimeExports.jsxs("div",{className:"conversation--characters",children:[jsxRuntimeExports.jsx(Scene,{characters:E?S:g,slots:d,flex:o,currentMessage:a,lodSettings:n,ttsStarted:t,pause:f,emitEvent:u,lowQuality:R}),h||jsxRuntimeExports.jsx(v,{})]})}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=x=>{o?(f(x),setTimeout(()=>{t(x)},1e3)):t(x)},p=x=>!!(a&&(n==null?void 0:n.id)===x.id||(n==null?void 0:n.right)===!0||a&&!d);return e==null?void 0:e.filter(x=>x.text).map(x=>jsxRuntimeExports.jsxs("div",{className:`${l?"conversation--question custom-radio":"custom-radio"}
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(E){var g=E.match(NEWLINE_REGEX);g&&(n+=g.length);var v=E.lastIndexOf(NEWLINE);t=~v?E.length-v:t+E.length}function o(){var E={line:n,column:t};return function(g){return g.position=new d(E),u(),g}}function d(E){this.start=E,this.end={line:n,column:t},this.source=e.source}d.prototype.content=l;function h(E){var g=new Error(e.source+":"+n+":"+t+": "+E);if(g.reason=E,g.filename=e.source,g.line=n,g.column=t,g.source=l,!e.silent)throw g}function f(E){var g=E.exec(l);if(g){var v=g[0];return a(v),l=l.slice(v.length),g}}function u(){f(WHITESPACE_REGEX)}function p(E){var g;for(E=E||[];g=x();)g!==!1&&E.push(g);return E}function x(){var E=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 v=l.slice(2,g-2);return t+=2,a(v),l=l.slice(g),t+=2,E({type:TYPE_COMMENT,comment:v})}}function R(){var E=o(),g=f(PROPERTY_REGEX);if(g){if(x(),!f(COLON_REGEX))return h("property missing ':'");var v=f(VALUE_REGEX),T=E({type:TYPE_DECLARATION,property:trim(g[0].replace(COMMENT_REGEX,EMPTY_STRING$1)),value:v?trim(v[0].replace(COMMENT_REGEX,EMPTY_STRING$1)):EMPTY_STRING$1});return f(SEMICOLON_REGEX),T}}function S(){var E=[];p(E);for(var g;g=R();)g!==!1&&(E.push(g),p(E));return E}return u(),S()};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,x,R,S=e.trim,E=0,g=l.length;E<g;E++){if(h=l[E],u&&(p=e.replace(h),o(p))){g>1&&(p=t(p,{key:p.key||E})),d.push(p);continue}if(h.type==="text"){if(f=!h.data.trim().length,f&&h.parent&&!canTextBeChildOfNode(h.parent)||S&&f)continue;d.push(h.data);continue}switch(x=h.attribs,skipAttributesToProps(h)?setStyleProp(x.style,x):x&&(x=attributesToProps$1(x)),R=null,h.type){case"script":case"style":h.children[0]&&(x.dangerouslySetInnerHTML={__html:h.children[0].data});break;case"tag":h.name==="textarea"&&h.children[0]?x.defaultValue=h.children[0].data:h.children&&h.children.length&&(R=domToReact$1(h.children,e));break;default:continue}g>1&&(x.key=E),d.push(a(h.name,x,R))}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,x){x===void 0&&(x=p);var R=Object.getOwnPropertyDescriptor(u,p);(!R||("get"in R?!u.__esModule:R.writable||R.configurable))&&(R={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(f,x,R)}:function(f,u,p,x){x===void 0&&(x=p),f[x]=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,x){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"&&(x=p,p=d),typeof u=="object"&&(p=u,u=void 0),this.callback=u??null,this.options=p??d,this.elementCB=x??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 x=this.options.xmlMode?t.ElementType.Tag:void 0,R=new a.Element(u,p,void 0,x);this.addNode(R),this.tagStack.push(R)},f.prototype.ontext=function(u){var p=this.options.normalizeWhitespace,x=this.lastNode;if(x&&x.type===t.ElementType.Text)p?x.data=(x.data+u).replace(o," "):x.data+=u,this.options.withEndIndices&&(x.endIndex=this.parser.endIndex);else{p&&(u=u.replace(o," "));var R=new a.Text(u);this.addNode(R),this.lastNode=R}},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 x=new a.ProcessingInstruction(u,p);this.addNode(x)},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],x=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),x&&(u.prev=x,x.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=()=>{},useEkho=({voice:l,text:e,audioType:n,loop:t=!1,started:a=!0,slide:o=0,audio:d,soundActions:h,emitEvent:f,volume:u=.5,onFinish:p=noop$1,onError:x=noop$1,onStart:R=noop$1,pauseTTS:S})=>{const[E,g,v,T]=h,b=!d&&!l,[_,w]=React$2.useState(!1),C=React$2.useRef({url:"",cc:"tts"}),P=React$2.useCallback(M=>f({type:"translate",payload:M}),[f]),D=React$2.useCallback(({id:M,type:U="base"})=>{var J;const $=P("usedVoices"),B=P("gameCharacters");return U==="base"?$==null?void 0:$[M]:U==="character"?(J=B==null?void 0:B[M])==null?void 0:J.voiceId:null},[P]),N=React$2.useCallback((M,U="tts")=>{C.current.url===M&&o===C.current.slide||(C.current={url:M,cc:U,slide:o},E(M,U,t,u,p,R,x))},[o,E,t,u,p,R,x]),k=React$2.useCallback(async M=>{if(_&&M.voiceId&&M.text){const U=await f({type:"getSpeech",payload:M});U?N(U):x()}else x()},[f,_,x,N]),F=React$2.useCallback(()=>{C.current.url&&g(C.current.cc)},[g]);return React$2.useEffect(()=>(w(!0),()=>{w(!1),F()}),[F]),React$2.useEffect(()=>{S?v():T()},[v,S,T]),React$2.useEffect(()=>{b&&F()},[b,F]),React$2.useEffect(()=>{if(_&&a)if(n==="voice"&&(l!=null&&l.id)){const M=D(l);k({voiceId:M,text:e})}else(n==="file"||!n)&&d?N(d==null?void 0:d.url):x()},[D,k,_,l,e,n,d==null?void 0:d.url,d,N,x,a]),F},cleanTextOfHtmlTags=l=>{const e=/<\/p>|<\/h1>|<\/h2>|<\/h3>|<\/h4>|<\/h5>|<\/h6>|<\/li>/gi,n=/&quot;|&#39;/gi;if(l)return l.replace(e,". </p>").replace(n,"").replace(/(<([^>]+)>)/gi,"")},READING_TIME=.2;function LecturesComponent({emitEvent:l,name:e,name_labelId:n,required:t,text:a,text_labelId:o,visible:d,documentType:h,viewed:f,soundActions:u,backgroundImage:p,hideBackgroundImageTheme:x=!1,keyboardControl:R,audio:S,audioType:E,audioVolume:g,voice:v,pause:T,styles:b}){const[_,w]=React$2.useState(),[C,P]=React$2.useState(!1),[D,N]=React$2.useState(0),k=a,F=Math.trunc(k.split(" ").length*READING_TIME),M=!t||t&&D>=F||t&&!d,[U]=u,$=`${e}. ${cleanTextOfHtmlTags(a)}`;useEkho({audioType:E,voice:v,text:$,audio:S,soundActions:u,emitEvent:l,volume:g,pauseTTS:T});const B=fe=>l({type:"translate",payload:fe}),J=React$2.useCallback(()=>{M&&(U("click-ui"),l({type:"finishMedia",payload:{name:n,type:"text",text:o,documentType:h}}))},[h,l,M,n,o,U]),ne=R({disabled:f,forward:J,escape:J});React$2.useEffect(()=>ne(),[ne]),React$2.useEffect(()=>{if(!d&&!C&&(J(),P(!0)),t&&d){const fe=setInterval(()=>{N(te=>te+1)},1e3);return w(fe),()=>{clearInterval(fe)}}},[J,t,C,d]),React$2.useEffect(()=>{D===F&&clearInterval(_)},[_,D,F]);const ie=F-D,Y=Math.floor(ie/60),q=ie%60,re=React$2.useMemo(()=>{let fe="";return f?fe="notes--results":(fe="lectures--container",b&&(fe+=` lectures--container--${b}`),p!=null&&p.url&&(fe+=" lectures--container--with-custom-bg"),b&&x&&(fe+=" disable-background-image")),fe},[p==null?void 0:p.url,x,b,f]),ce={backgroundImage:p!=null&&p.url?`url('${p.url}')`:""};return d?jsxRuntimeExports.jsx("div",{className:re,style:ce,children:jsxRuntimeExports.jsx("div",{className:f?"":"lectures__overlay",children:jsxRuntimeExports.jsxs("div",{className:f?"notes--results__text":`lectures lectures--${b}`,children:[jsxRuntimeExports.jsx("div",{className:"lectures--title",children:e}),jsxRuntimeExports.jsxs("div",{className:"lectures--text",dir:"auto",children:[jsxRuntimeExports.jsx("div",{children:k?HTMLReactParser$1(k):null}),f?null:jsxRuntimeExports.jsx(LectureButtons,{goToLecture:M,close:J,minutes:Y,seconds:q,btnText:B("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 R;const a=l.type==="image",o=l.type==="character",d=l.type==="object",h=(R=l==null?void 0:l.resource)==null?void 0:R.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":"",x=a||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:p(),backgroundSize:u()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${n}`,style:x,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(x){a&&a(x);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 x=this.pluginCallbacks[p](u);x.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),h[x.name]=x,d[x.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const x=o.extensionsUsed[p],R=o.extensionsRequired||[];switch(x){case EXTENSIONS.KHR_MATERIALS_UNLIT:d[x]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:d[x]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:d[x]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:d[x]=new GLTFMeshQuantizationExtension;break;default:R.indexOf(x)>=0&&h[x]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+x+'".')}}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 x=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=x;break;case"spot":u=new three.SpotLight(p),u.distance=x,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,x=a.byteStride,R=new Uint8Array(h,f,u);return d.decodeGltfBufferAsync?d.decodeGltfBufferAsync(p,x,R,a.mode,a.filter).then(function(S){return S.buffer}):d.ready.then(function(){const S=new ArrayBuffer(p*x);return d.decodeGltfBuffer(new Uint8Array(S),p,x,R,a.mode,a.filter),S})})}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(),x=p.isGroup?p.children:[p],R=u[0].count,S=[];for(const E of x){const g=new three.Matrix4,v=new three.Vector3,T=new three.Quaternion,b=new three.Vector3(1,1,1),_=new three.InstancedMesh(E.geometry,E.material,R);for(let w=0;w<R;w++)f.TRANSLATION&&v.fromBufferAttribute(f.TRANSLATION,w),f.ROTATION&&T.fromBufferAttribute(f.ROTATION,w),f.SCALE&&b.fromBufferAttribute(f.SCALE,w),_.setMatrixAt(w,g.compose(v,T,b));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"&&E.geometry.setAttribute(w,f[w]);three.Object3D.prototype.copy.call(_,E),this.parser.assignFinalMaterial(_),S.push(_)}return p.isGroup?(p.clear(),p.add(...S),p):S[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 x=ATTRIBUTES[p]||p.toLowerCase();h[x]=d[p]}for(const p in e.attributes){const x=ATTRIBUTES[p]||p.toLowerCase();if(d[p]!==void 0){const R=t.accessors[e.attributes[p]],S=WEBGL_COMPONENT_TYPES[R.componentType];u[x]=S.name,f[x]=R.normalized===!0}}return n.getDependency("bufferView",o).then(function(p){return new Promise(function(x,R){a.decodeDracoFile(p,function(S){for(const E in S.attributes){const g=S.attributes[E],v=f[E];v!==void 0&&(g.normalized=v)}x(S)},h,u,three.LinearSRGBColorSpace,R)})})}}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,x=(t-n)/p,R=x*x,S=R*x,E=e*u,g=E-u,v=-2*S+3*R,T=S-R,b=1-v,_=T-R+x;for(let w=0;w!==h;w++){const C=d[g+w+h],P=d[g+w+f]*p,D=d[E+w+h],N=d[E+w]*p;o[w]=b*C+_*P+v*D+T*N}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 x=e[u];if(x.POSITION!==void 0&&(t=!0),x.NORMAL!==void 0&&(a=!0),x.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 x=e[u];if(t){const R=x.POSITION!==void 0?n.getDependency("accessor",x.POSITION):l.attributes.position;d.push(R)}if(a){const R=x.NORMAL!==void 0?n.getDependency("accessor",x.NORMAL):l.attributes.normal;h.push(R)}if(o){const R=x.COLOR_0!==void 0?n.getDependency("accessor",x.COLOR_0):l.attributes.color;f.push(R)}}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f)]).then(function(u){const p=u[0],x=u[1],R=u[2];return t&&(l.morphAttributes.position=p),a&&(l.morphAttributes.normal=x),o&&(l.morphAttributes.color=R),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,x=p*f,R=a.byteOffset||0,S=a.bufferView!==void 0?t.bufferViews[a.bufferView].byteStride:void 0,E=a.normalized===!0;let g,v;if(S&&S!==x){const T=Math.floor(R/S),b="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+T+":"+a.count;let _=n.cache.get(b);_||(g=new u(h,T*S,a.count*S/p),_=new three.InterleavedBuffer(g,S/p),n.cache.add(b,_)),v=new three.InterleavedBufferAttribute(_,f,R%S/p,E)}else h===null?g=new u(a.count*f):g=new u(h,R,a.count*f),v=new three.BufferAttribute(g,f,E);if(a.sparse!==void 0){const T=WEBGL_TYPE_SIZES.SCALAR,b=WEBGL_COMPONENT_TYPES[a.sparse.indices.componentType],_=a.sparse.indices.byteOffset||0,w=a.sparse.values.byteOffset||0,C=new b(d[1],_,a.sparse.count*T),P=new u(d[2],w,a.sparse.count*f);h!==null&&(v=new three.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let D=0,N=C.length;D<N;D++){const k=C[D];if(v.setX(k,P[D*f]),f>=2&&v.setY(k,P[D*f+1]),f>=3&&v.setZ(k,P[D*f+2]),f>=4&&v.setW(k,P[D*f+3]),f>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}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 R=(o.samplers||{})[d.sampler]||{};return p.magFilter=WEBGL_FILTERS[R.magFilter]||three.LinearFilter,p.minFilter=WEBGL_FILTERS[R.minFilter]||three.LinearMipmapLinearFilter,p.wrapS=WEBGL_WRAPPINGS[R.wrapS]||three.RepeatWrapping,p.wrapT=WEBGL_WRAPPINGS[R.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(x=>x.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(x){u=!0;const R=new Blob([x],{type:d.mimeType});return f=h.createObjectURL(R),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(x){return new Promise(function(R,S){let E=R;n.isImageBitmapLoader===!0&&(E=function(g){const v=new three.Texture(g);v.needsUpdate=!0,R(v)}),n.load(three.LoaderUtils.resolveURL(x,o.path),E,void 0,S)})}).then(function(x){return u===!0&&h.revokeObjectURL(f),x.userData.mimeType=d.mimeType||getImageURIMimeType(d.uri),x}).catch(function(x){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),x});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 x=a[EXTENSIONS.KHR_MATERIALS_UNLIT];d=x.getMaterialType(),u.push(x.extendParams(h,o,n))}else{const x=o.pbrMetallicRoughness||{};if(h.color=new three.Color(1,1,1),h.opacity=1,Array.isArray(x.baseColorFactor)){const R=x.baseColorFactor;h.color.setRGB(R[0],R[1],R[2],three.LinearSRGBColorSpace),h.opacity=R[3]}x.baseColorTexture!==void 0&&u.push(n.assignTexture(h,"map",x.baseColorTexture,three.SRGBColorSpace)),h.metalness=x.metallicFactor!==void 0?x.metallicFactor:1,h.roughness=x.roughnessFactor!==void 0?x.roughnessFactor:1,x.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(h,"metalnessMap",x.metallicRoughnessTexture)),u.push(n.assignTexture(h,"roughnessMap",x.metallicRoughnessTexture))),d=this._invokeOne(function(R){return R.getMaterialType&&R.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(R){return R.extendMaterialParams&&R.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 x=o.normalTexture.scale;h.normalScale.set(x,x)}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 x=o.emissiveFactor;h.emissive=new three.Color().setRGB(x[0],x[1],x[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 x=new d(h);return o.name&&(x.name=o.name),assignExtrasToUserData(x,o),n.associations.set(x,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(a,x,o),x})}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),x=a[p];if(x)d.push(x.promise);else{let R;u.extensions&&u.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?R=o(u):R=addPrimitiveAttributes(new three.BufferGeometry,u,n),a[p]={primitive:u,promise:R},d.push(R)}}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],x=[];for(let S=0,E=p.length;S<E;S++){const g=p[S],v=d[S];let T;const b=u[S];if(v.mode===WEBGL_CONSTANTS.TRIANGLES||v.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||v.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||v.mode===void 0)T=o.isSkinnedMesh===!0?new three.SkinnedMesh(g,b):new three.Mesh(g,b),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),v.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?T.geometry=toTrianglesDrawMode(T.geometry,three.TriangleStripDrawMode):v.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(T.geometry=toTrianglesDrawMode(T.geometry,three.TriangleFanDrawMode));else if(v.mode===WEBGL_CONSTANTS.LINES)T=new three.LineSegments(g,b);else if(v.mode===WEBGL_CONSTANTS.LINE_STRIP)T=new three.Line(g,b);else if(v.mode===WEBGL_CONSTANTS.LINE_LOOP)T=new three.LineLoop(g,b);else if(v.mode===WEBGL_CONSTANTS.POINTS)T=new three.Points(g,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(T.geometry.morphAttributes).length>0&&updateMorphTargets(T,o),T.name=n.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(T,o),v.extensions&&addUnknownExtensionsToUserData(a,T,v),n.assignFinalMaterial(T),x.push(T)}for(let S=0,E=x.length;S<E;S++)n.associations.set(x[S],{meshes:e,primitives:S});if(x.length===1)return o.extensions&&addUnknownExtensionsToUserData(a,x[0],o),x[0];const R=new three.Group;o.extensions&&addUnknownExtensionsToUserData(a,R,o),n.associations.set(R,{meshes:e});for(let S=0,E=x.length;S<E;S++)R.add(x[S]);return R})}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 x=d[u];if(x){h.push(x);const R=new three.Matrix4;o!==null&&R.fromArray(o.array,u*16),f.push(R)}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 x=0,R=a.channels.length;x<R;x++){const S=a.channels[x],E=a.samplers[S.sampler],g=S.target,v=g.node,T=a.parameters!==void 0?a.parameters[E.input]:E.input,b=a.parameters!==void 0?a.parameters[E.output]:E.output;g.node!==void 0&&(d.push(this.getDependency("node",v)),h.push(this.getDependency("accessor",T)),f.push(this.getDependency("accessor",b)),u.push(E),p.push(g))}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f),Promise.all(u),Promise.all(p)]).then(function(x){const R=x[0],S=x[1],E=x[2],g=x[3],v=x[4],T=[];for(let b=0,_=R.length;b<_;b++){const w=R[b],C=S[b],P=E[b],D=g[b],N=v[b];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const k=t._createAnimationTracks(w,C,P,D,N);if(k)for(let F=0;F<k.length;F++)T.push(k[F])}return new three.AnimationClip(o,void 0,T)})}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],x=u[1],R=u[2];R!==null&&p.traverse(function(S){S.isSkinnedMesh&&S.bind(R,_identityMatrix)});for(let S=0,E=x.length;S<E;S++)p.add(x[S]);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 x=0,R=u.length;x<R;x++)p.add(u[x]);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 x=new three.Matrix4;x.fromArray(o.matrix),p.applyMatrix4(x)}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,x=f.length;p<x;p++)o.add(f[p]);const u=p=>{const x=new Map;for(const[R,S]of a.associations)(R instanceof three.Material||R instanceof three.Texture)&&x.set(R,S);return p.traverse(R=>{const S=a.associations.get(R);S!=null&&x.set(R,S)}),x};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(R){R.morphTargetInfluences&&f.push(R.name?R.name:R.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,x=this._getArrayFromAccessor(t);for(let R=0,S=f.length;R<S;R++){const E=new u(f[R]+"."+PATH_PROPERTIES[o.path],n.array,x,p);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(E),d.push(E)}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 x=o[u];if(x.POSITION!==void 0){const R=n.json.accessors[x.POSITION],S=R.min,E=R.max;if(S!==void 0&&E!==void 0){if(f.setX(Math.max(Math.abs(S[0]),Math.abs(E[0]))),f.setY(Math.max(Math.abs(S[1]),Math.abs(E[1]))),f.setZ(Math.max(Math.abs(S[2]),Math.abs(E[2]))),R.normalized){const g=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[R.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}){var R,S,E,g,v;const t=React$2.useRef(null),a=React$2.useRef(null),o=l.type==="character",[d,h]=React$2.useState(!1),f=React$2.useRef(),u=React$2.useMemo(()=>{var T,b,_,w,C,P,D,N;return o?l.animationId&&((T=l.animation)!=null&&T.url)?l.animation:(w=(_=(b=l==null?void 0:l.resource)==null?void 0:b.animations)==null?void 0:_[l.emotion])!=null&&w.url?(P=(C=l==null?void 0:l.resource)==null?void 0:C.animations)==null?void 0:P[l.emotion]:(N=(D=l==null?void 0:l.resource)==null?void 0:D.animations)==null?void 0:N.neutral:{}},[l.emotion,l==null?void 0:l.animationId,l==null?void 0:l.animation,(R=l==null?void 0:l.resource)==null?void 0:R.animations,o]),p=React$2.useCallback(()=>{var T;if((T=f.current.userData)!=null&&T.animation){const{clipAction:b,defaultAnim:_}=f.current.userData.animation;_&&b(_)}},[]);React$2.useEffect(()=>{var T,b,_;if(f.current)if(n)if(e){const w=(_=(b=(T=l==null?void 0:l.resource)==null?void 0:T.animations)==null?void 0:b.talking)==null?void 0:_.url;w&&loader$1.load(w,({animations:C})=>{if(!f.current)return;const{defaultAnim:P,clipAction:D}=f.current.userData.animation;D(mixWithTalkingClip(C[0],P)),h(!0)})}else p();else d&&p()},[(g=(E=(S=l==null?void 0:l.resource)==null?void 0:S.animations)==null?void 0:E.talking)==null?void 0:g.url,e,n,p,d]);const x=React$2.useCallback(T=>{if(l.type==="character"){const b=T.getObjectByName("Head_M",!0);b?(b.updateMatrixWorld(!0),box.setFromObject(T),box.getSize(size),b.getWorldPosition(worldPos),t.current.lookAt(worldPos)):t.current.position.setY(size.y-1.5*1.3),t.current.zoom=1.5}else cameraFitAnyObject(T,t.current),t.current.zoom=1;t.current.updateProjectionMatrix()},[l]);return fiber.useFrame(({gl:T,scene:b})=>{if(t.current&&a.current){const _=document.querySelectorAll(".conversation--character__item")[l.slot];if(_){const w=_.getBoundingClientRect(),C=_.parentNode.getBoundingClientRect(),[P,D]=[w.right-w.left,w.bottom-w.top];if(t.current.aspect=P/D,t.current.updateProjectionMatrix(),o&&f.current){box.setFromObject(f.current),box.getSize(size);const F=f.current.getObjectByName("Head_M",!0);F?(F.getWorldPosition(worldPos),t.current.lookAt(worldPos)):t.current.position.setY(size.y-1.5*1.3),t.current.zoom=1.5}const N={top:w.top-C.top,right:w.right-C.right,left:w.left-C.left,bottom:w.bottom-C.bottom},k=isMobile?24:40;N.bottom+=n?-k:k,T.setViewport(N.left,N.bottom,P,D),T.setScissor(N.left,N.bottom,P,D),a.current.environment=b.environment,T.render(a.current,t.current)}}},1),l.type==="image"?null:jsxRuntimeExports.jsxs("scene",{ref:a,children:[(v=l.resource)!=null&&v.url?jsxRuntimeExports.jsx(arcadeThreeCore.SceneResource,{ref:f,name:`char_${l.uid}`,url:l.resource.url,animationUrl:u.url,type:l.type,onLoad:x,texturable:!0,interactive:!0,merge:l.type!=="character"}):null,jsxRuntimeExports.jsx(drei.PerspectiveCamera,{ref:t,fov:35,position:defaultCamPos,rotation:[0,0,0],onUpdate:T=>{T.layers.enableAll()},manual:!0}),jsxRuntimeExports.jsx(LightSet,{})]})}function PanelsWrapper({characters:l,slots:e,ttsStarted:n,flex:t,currentMessage:a,emitEvent:o}){fiber.useFrame(({gl:h})=>{h.setScissorTest(!1),h.clear(!0,!0),h.setScissorTest(!0)});const d=React$2.useMemo(()=>o({type:"currentLod"}),[o]);return jsxRuntimeExports.jsx(arcadeThreeCore.QualityManager,{lod:d,active:!0,children:e.map((h,f)=>{let u=null;const p=l.findIndex(x=>x&&x.uid===h.uid);if(p>=0){const x=t?p:f;return u={...l[p]},u.slot=x,jsxRuntimeExports.jsx(Panel,{character:u,active:a.position===x,ttsStarted:n,emitEvent:o},`${`${u.uid}_${f}`}_${p}`)}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,emitEvent:u}){const p=({character:T,active:b,slot:_})=>({character:T,active:b,emotion:b?a.emotion:"neutral",slot:_}),R=React$2.useMemo(()=>u({type:"currentLod"}),[u])==="divideby64",S=d.reduce((T,b)=>{var C,P;const _=e==null?void 0:e.find(D=>D.uid===b.uid),w={...b};if(b.character)w.name=b.alias||b.character.name,w.resource=w.character.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type="character",T.push(w);else if(_){const{resource:D}=_;w.name=b.alias||b.name,w.position=w.position>=0?w.position:-1,w.resource=D,w.type=_.type,T.push(w)}else b.type?(w.name=b.alias||((C=b.character)==null?void 0:C.name)||b.name,w.resource=((P=w.character)==null?void 0:P.resource)||b.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type=b.type,T.push(w)):o||T.push(null);return T},[]),E=S.length&&S.some(T=>T),g=l.filter(T=>d.find(b=>T.uid===b.uid));function v(){return E?S.map((T,b)=>T?jsxRuntimeExports.jsx(Slot,{emitEvent:u,lowQuality:R,...p({character:T,active:a.position===T.position,slot:b})},`${T.uid+b}`):jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${b}`},`void_${0+b}`)):o?g.map((T,b)=>{const _=a.position===b;return jsxRuntimeExports.jsx(Slot,{...p({character:T,active:_,slot:b})},`${T.uid+b}`)}):d.length>0?d.map((T,b)=>{const _=l.find(w=>w.uid===T.uid);if(_){const w=a.position===b;return _.name=T.alias||_.name,jsxRuntimeExports.jsx(Slot,{...p({character:_,active:w,slot:b})},`${_.uid+b}`)}return jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${b}`},`${0+b}`)}):null}return jsxRuntimeExports.jsxs("div",{className:"conversation--characters",children:[jsxRuntimeExports.jsx(Scene,{characters:E?S:g,slots:d,flex:o,currentMessage:a,lodSettings:n,ttsStarted:t,pause:f,emitEvent:u,lowQuality:R}),h||jsxRuntimeExports.jsx(v,{})]})}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=x=>{o?(f(x),setTimeout(()=>{t(x)},1e3)):t(x)},p=x=>!!(a&&(n==null?void 0:n.id)===x.id||(n==null?void 0:n.right)===!0||a&&!d);return e==null?void 0:e.filter(x=>x.text).map(x=>jsxRuntimeExports.jsxs("div",{className:`${l?"conversation--question custom-radio":"custom-radio"}
67
67
  ${(h==null?void 0:h.id)===x.id?"radio-text-clicked":""}`,children:[jsxRuntimeExports.jsx("input",{onChange:()=>{u(x)},className:"radio",type:"radio",id:x.text_labelId,name:x.id,checked:(n==null?void 0:n.id)===x.id,disabled:p(x)}),jsxRuntimeExports.jsx("label",{className:`${x.right?"radio-text-success":"radio-text-fail"}`,htmlFor:x.text_labelId,children:HTMLReactParser$1(x.text)})]},`${x.id}_${x.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,x]=React$2.useState(!1);function R(){(t==null?void 0:t.id)!==void 0&&!p&&(x(!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",{type:"button",className:`gat--btn__navigation ${p||(t==null?void 0:t.id)===void 0?"disabled":""}`,onClick:()=>R(),"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}){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",{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",{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:x,inScene:R,required:S,simplifiedOptions:E}){const g=b=>{h&&d&&a(b),o(b)},v=!h&&(f==null?void 0:f.id)!==void 0||!d,T={inherited:n,selectedChoice:f,selectChoice:(!S||t)&&(f==null?void 0:f.id)!==void 0||S&&!d?noop:g,options:l,showingResults:h,simplifiedOptions:E,required:S};return n?jsxRuntimeExports.jsx(ComplexDecision,{disabled:!v,question:e,inScene:R,onNext:()=>o(f),children:jsxRuntimeExports.jsx(Options,{...T})}):jsxRuntimeExports.jsx(BasicDecision,{question:e,showingResults:h,selected:f,required:S,failed:d,onNext:()=>o(f),translate:p,hasRewards:x,options:jsxRuntimeExports.jsx(Options,{...T}),children:u})}function Wrapper({children:l,inherit:e,feedback:n}){return e?jsxRuntimeExports.jsx("div",{className:`conversation--feedback ${n?"":"only--rewards"}`,children:l}):n?l:jsxRuntimeExports.jsx("div",{className:"popup__basicDecision__only--rewards only--rewards",children:l})}function FeedBack({choice:l,inherited:e,question:n}){return l.feedback?jsxRuntimeExports.jsx(Wrapper,{inherit:e,feedback:l.feedback,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}):null}function DecisionComponent({emitEvent:l,soundActions:e,keyboardControl:n,inScene:t,...a}){var M,U;const{inheritProps:o={},decisionNumber:d,required:h,question:f,onAddPoints:u,onFinish:p,branched:x,simplifiedOptions:R}=a,S=Object.keys(o).length>0,[E,g]=React$2.useState("options"),[v,T]=React$2.useState({}),[b]=e,_=h&&!(v!=null&&v.right),w=React$2.useRef(),C=$=>{var B;(B=$.audio)!=null&&B.url&&b($.audio.url,"audio_file",!1,$.audioVolume)},P={...o,slots:o.slots?o.slots:o.characters,currentMessage:{position:null,emotion:""},emitEvent:l};o&&o.flex&&P.slots&&(P.characters=P.characters.filter($=>P.slots.find(B=>B.uid===$.uid)));const D=$=>{l({type:"decisionJournal",payload:{choice:$,decisionNumber:d}})},N=$=>{!_&&E==="results"?(b("click-ui"),S?R?p&&(D($),p($,()=>{T({}),g("options")})):(u&&u($),D($),l({type:"addPoints",payload:$.rewards,finish:!1,complex:!0,onFinish:()=>{p?p($,()=>{T({}),g("options")}):l({type:"success"}),T({}),g("options")}})):(D($),l({type:"addPoints",payload:$.rewards,finish:!0,complex:!0}))):Object.keys($).length>0&&(b("click-ui"),R?(D({...$,simplified:!0}),p($,()=>{T({}),g("options")})):($.right?b("score"):(b("fail"),x||(S||h?(D($),l({type:"addPoints",payload:$.rewards,finish:!1,complex:!0})):h||(T({}),g("options")))),T($),C($),g("results")))},k={...a,selectView:g,selectedView:E,emitEvent:l,inherited:S,branched:x,soundActions:e,showingResults:E==="results",currentSelectedChoice:v,hasRewards:(v==null?void 0:v.rewards)||[],failed:_,inScene:t,required:h,simplifiedOptions:R,changeOption:$=>{b("click-ui"),T($),g("options")},onNext:N,translate:$=>l({type:"translate",payload:$})},F=n({disabled:E!=="results",repeat:!1,forward:()=>{if(w.current!==v)w.current=v;else return;N(v)}});return React$2.useEffect(()=>F(),[F]),S?jsxRuntimeExports.jsx("div",{className:`conversation--layer
68
68
  ${v!=null&&v.feedback?"":"conversation--layer__defaultFeedback"}
69
- ${E==="results"?"conversation--layer__feedback":""}`,children:jsxRuntimeExports.jsxs("div",{className:`conversation ${t?"conversation--inScene":""}`,style:(M=o.background)!=null&&M.img?{backgroundImage:`url("${(U=o.background.img)==null?void 0:U.url}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...P,children:E==="results"&&(v!=null&&v.feedback)?jsxRuntimeExports.jsx(FeedBack,{question:f,soundActions:e,inherited:S,choice:v,rewards:(v==null?void 0:v.rewards)||[],emitEvent:l}):null}),jsxRuntimeExports.jsx(DecisionBody,{...k})]})}):jsxRuntimeExports.jsx("div",{className:"popup--layer popup--layer--transparent",children:jsxRuntimeExports.jsx(DecisionBody,{...k,children:jsxRuntimeExports.jsx(FeedBack,{question:f,soundActions:e,inherited:S,choice:v,rewards:(v==null?void 0:v.rewards)||[],emitEvent:l})})})}function ImageComponent({emitEvent:l,img:e,imgName:n,documentType:t,visible:a,viewed:o,imgId_labelId:d,soundActions:h,keyboardControl:f}){const u=v=>l({type:"translate",payload:v}),[p,x]=React$2.useState(!1),R=e.url,[S]=h,E=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]),g=f({disabled:o,forward:E,escape:E});return React$2.useEffect(()=>g(),[g]),React$2.useEffect(()=>{!a&&!p&&(x(!0),E())},[E,a,p]),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:[R&&jsxRuntimeExports.jsx("img",{src:R,alt:n}),o?null:jsxRuntimeExports.jsx("div",{className:R?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:E,"aria-label":u("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 characterMs$3=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:l,emitEvent:e,pause:n,lines:t,edges:a,characters:o,actors:d,background:h,soundActions:f,lodSettings:u,autoPlay:p,autoEnd:x,progress:R}){var xt,Et,Qe;const S=t.length-1<=(R==null?void 0:R.line)?t.length-1:(R==null?void 0:R.line)||0,[E,g]=React$2.useState(!1),[v,T]=React$2.useState(!0),[b,_]=React$2.useState(!!p),[w,C]=React$2.useState(!1),[P,D]=React$2.useState(S),[N,k]=React$2.useState(!1),[F]=f,{start:M,stop:U}=useTimeout(),$=((xt=h==null?void 0:h.img)==null?void 0:xt.url)||null,B=t[P],{voiceOver:J,decision:ne}=B;let{flex:ie}=B,Y=[];const q=!!a,re=J||B.type==="conversationalNarration",ce=ne||B.type==="conversationalDecision",fe=B.type==="conversationalCamera",[te,H]=React$2.useState([]),W=React$2.useMemo(()=>te[te.length-1],[te]),V=React$2.useCallback(()=>{const Be=a.find(Ye=>Ye.fromId===W)||a.find(Ye=>Ye.toId===W),Xe=t.find(Ye=>Ye.id===(Be==null?void 0:Be.fromId));return!W&&(R==null?void 0:R.line)>=0?{decision:!0}:Xe},[a,t,W,R==null?void 0:R.line]),z=React$2.useCallback(()=>{if(q){const Xe=V();return Xe==null?void 0:Xe.decision}const Be=t[P-1]?t[P-1]:{};return P>0&&(Be==null?void 0:Be.decision)},[q,V,t,P]),Q=React$2.useCallback(()=>{if(q){const Xe=V();return(Xe==null?void 0:Xe.type)==="conversationalCamera"}const Be=t[P-1]?t[P-1]:{};return P>0&&(Be==null?void 0:Be.type)==="conversationalCamera"},[q,t,P,V]),ee=React$2.useCallback(Be=>e({type:"translate",payload:Be}),[e]),le=React$2.useMemo(()=>{var Xe,Ye;if(ce)return{};if(re)return B;const Be=(Xe=B==null?void 0:B.slots)==null?void 0:Xe.find(Pe=>Pe.uid&&Pe.talking);return Be||((Ye=B==null?void 0:B.slots)==null?void 0:Ye.find(Pe=>Pe.uid&&Pe.text))},[B,re,ce]),ue=t.slice(0,P+1).reverse().find(Be=>Be.slots),he=!ce&&((Et=B.slots)==null?void 0:Et.filter(Be=>Be.uid).length),ve=characterMs$3*(((Qe=le==null?void 0:le.text)==null?void 0:Qe.length)||0);let be=[];B.slots?be=B.slots:ue&&(be=ue.slots);const Re=be.filter(Be=>Be.uid).map(Be=>{const Xe=(o||d||[]).find(Ye=>Ye.uid===Be.uid);return Xe&&(Be.resource=Xe.resource,Be.type=Xe.type),Be.resource||(Be.resource={}),Be}),Le={characters:Re,lodSettings:u,actors:d,currentMessage:le||{},slots:re?Y:B.slots,flex:ie,pause:n,emitEvent:e};if(re){const Be=t.slice(P).find(Ye=>Ye.slots),Xe=ue||Be;Xe&&(Y=Xe.slots,ie=Xe.flex)}else if(!ce&&he&&(B.slots.forEach(Be=>{const Xe=Re.findIndex(Ye=>Ye.uid===Be.uid);Xe>=0&&(Re[Xe].emotion=Be.emotion)}),le&&le.uid)){const Be=B.slots.findIndex(Ye=>Ye.uid===le.uid),Xe=Re.findIndex(Ye=>Ye.uid===le.uid);Re.forEach(Ye=>{Ye.uid===le.uid&&(Ye.name=le.alias)}),le.position=ie?Xe:Be}const Oe=React$2.useCallback(()=>{e({type:"success"})},[e]),Ke=React$2.useCallback((Be,Xe)=>{const Ye=[3,2,1][Be.id],Ae=a.filter(_e=>_e.fromId===B.id).find(_e=>parseInt(_e.fromPointIndex)===Ye);if(Ae){const _e=t.findIndex(Ie=>Ie.id===Ae.toId);Ae.fromId===Ae.toId?Xe():_e>=0?(D(_e),e({type:"notifyProgress",payload:{line:_e}})):Oe()}else Oe()},[B.id,a,e,Oe,t]),St=React$2.useCallback((Be=!0)=>{const Xe=Be?["fromId","toId"]:["toId","fromId"],Ye=a.filter(_e=>_e[Xe[0]]===B.id),Pe=Ye.length===1?Ye[0]:Ye.find(_e=>_e[Xe[1]]===W);if(!(Pe!=null&&Pe[Xe[0]])){Oe();return}Be||H(te.slice(0,-1));const Ae=t.findIndex(_e=>_e.id===Pe[Xe[1]]);Ae>=0?(D(Ae),e({type:"notifyProgress",payload:{line:Ae}})):Oe()},[B.id,a,te,e,Oe,W,t]),it=React$2.useCallback(Be=>{if(q){if(Be){const Xe=[3,2,1][Be.id],Pe=a.filter(Ae=>Ae.fromId===B.id).find(Ae=>parseInt(Ae.fromPointIndex)===Xe);if(Pe){const Ae=t.findIndex(_e=>_e.id===Pe.toId);Ae>=0&&e({type:"notifyProgress",payload:{line:Ae}})}else e({type:"saveNode"})}}else if(P<t.length-1){const Ye=P+1;e({type:"notifyProgress",payload:{line:Ye}})}else e({type:"saveNode"})},[a,t,e,P,B.id,q]),gt=React$2.useCallback((Be,Xe)=>{let Ye=!1;if(k(!1),H([...te,B.id]),T(!1),C(!1),q)Be?Ke(Be,Xe):St();else if(P<t.length-1){const Ae=P+1;D(Ae),e({type:"notifyProgress",payload:{line:Ae}}),Xe&&Xe()}else x||ce||fe?Oe():Ye=!0;Ye||T(!0)},[te,B.id,q,P,t.length,x,ce,fe,Ke,St,e,Oe]),Ge=()=>{if(T(!1),k(!1),C(!1),q)St(!1);else if(!z()){const Be=P-1;D(Be),e({type:"notifyProgress",payload:{line:Be}})}T(!0)},Me=React$2.useCallback(()=>q?B&&B.type!=="conversationalDecision"&&!a.find(Be=>Be.fromId===B.id):P===t.length-1,[P,B,a,q,t.length]),De=()=>{F("click-ui"),Me()?Oe():(_(!1),gt())},Ve=()=>{F("click-ui"),_(!1),Ge()},ct=b&&!ce&&!n&&!fe,dt=React$2.useMemo(()=>P===0||z()||Q(),[P,z,Q]);useEkho({audioType:B==null?void 0:B.audioType,volume:B==null?void 0:B.audioVolume,voice:B==null?void 0:B.voice,started:v,slide:P,text:cleanTextOfHtmlTags(le==null?void 0:le.text),audio:B==null?void 0:B.audio,soundActions:f,emitEvent:e,pauseTTS:n,onStart:()=>{var Be;(Be=le==null?void 0:le.emotion)!=null&&Be.includes("think")||k(!0)},onError:()=>{C(!0)},onFinish:()=>{k(!1),ct&&gt()}}),React$2.useEffect(()=>{var Xe;let Be;return ce?()=>{}:(((B==null?void 0:B.audioType)==="none"||w)&&!((Xe=le==null?void 0:le.emotion)!=null&&Xe.includes("think"))&&(k(!0),Be=setTimeout(()=>{k(!1)},ve<minMs$1?minMs$1:ve)),()=>{Be&&clearTimeout(Be)})},[w,B,le==null?void 0:le.emotion,ve,ce]),React$2.useEffect(()=>(ct&&((B==null?void 0:B.audioType)==="none"||w)&&(!Me()||Me()&&x)&&M(gt,ve<minMs$1?minMs$1:ve),()=>{U()}),[le,M,U,gt,B==null?void 0:B.audioType,ct,w,x,t,Me,ve]),React$2.useEffect(()=>{if(fe){const{targetUid:Be}=B;e({type:"changeCamera",payload:{targetUid:Be,transition:{type:"none"}}}),gt()}},[fe,gt,e,B]),React$2.useEffect(()=>{if(q&&!E){const Be=R==null?void 0:R.line;if(Be>=0){g(!0),D(Be);return}const Xe=t.filter(Ye=>!a.find(Pe=>Pe.toId===Ye.id));if(Xe.length){const Ye=Xe[0],Pe=t.indexOf(Ye);Pe>=0&&(g(!0),D(Pe))}}},[a,q,t,E,R==null?void 0:R.line]);const rt=l({disabled:ce,repeat:!1,forward:De,rewind:dt?null:Ve});if(React$2.useEffect(()=>rt(),[rt]),ce){const Be=t[P].id?t.filter(Ye=>Ye.decision).findIndex(Ye=>Ye.id===t[P].id)+1:t.filter(Ye=>Ye.decision).findIndex(Ye=>Ye===t[P])+1,Xe={...B.payload,decisionNumber:Be,required:!q,branched:q,onAddPoints:it,onFinish:gt,keyboardControl:l,emitEvent:e,soundActions:f,inheritProps:{characters:Re,background:h,flex:ue?ue.flex:!0,slots:ue?ue.slots:[]}};return jsxRuntimeExports.jsx(DecisionComponent,{...Xe})}return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversational-pro-image",className:"conversation",style:$?{backgroundImage:`url("${$}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...Le,ttsStarted:N}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[le?jsxRuntimeExports.jsx(Message,{current:le,translate:ee}):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:Ve,"aria-label":LangIsRtl()?ee("storylines.misc.forward"):ee("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 ${b&&Me()?"glowing-animation":""}`,type:"button",onClick:De,"aria-label":LangIsRtl()?ee("storylines.misc.rewind"):ee("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:l,soundActions:e,messages:n,characters:t,alias:a,background:o,lodSettings:d}){var g;const[h,f]=React$2.useState(0),[u]=e,p=((g=o==null?void 0:o.img)==null?void 0:g.url)||null,x=n[h],R=t.map((v,T)=>({...v,name:a[T]?a[T]:v.name,uid:T})),S=()=>{const v=n.length-1;u("click-ui"),h+1<=v?f(h+1):l({type:"success"})},E=()=>{h>0&&(f(h-1),u("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversation-component",className:"conversation arcade-conversation",style:p?{backgroundImage:`url("${p}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:R,lodSettings:d,currentMessage:x,slots:R,emitEvent:l,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[x?jsxRuntimeExports.jsx(Message,{current:x,voiceOver:x.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 ${h>0?"":"visibility--hidden"}`,type:"button",onClick:E,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",{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",{className:`comic-collapsable ${d?"comic-collapsable--opened":""}`,children:[jsxRuntimeExports.jsx("button",{id:"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",tabIndex:d?"-1":"0","aria-hidden":d,className:`unset-button comic-buttonup
69
+ ${E==="results"?"conversation--layer__feedback":""}`,children:jsxRuntimeExports.jsxs("div",{className:`conversation ${t?"conversation--inScene":""}`,style:(M=o.background)!=null&&M.img?{backgroundImage:`url("${(U=o.background.img)==null?void 0:U.url}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...P,children:E==="results"&&(v!=null&&v.feedback)?jsxRuntimeExports.jsx(FeedBack,{question:f,soundActions:e,inherited:S,choice:v,rewards:(v==null?void 0:v.rewards)||[],emitEvent:l}):null}),jsxRuntimeExports.jsx(DecisionBody,{...k})]})}):jsxRuntimeExports.jsx("div",{className:"popup--layer popup--layer--transparent",children:jsxRuntimeExports.jsx(DecisionBody,{...k,children:jsxRuntimeExports.jsx(FeedBack,{question:f,soundActions:e,inherited:S,choice:v,rewards:(v==null?void 0:v.rewards)||[],emitEvent:l})})})}function ImageComponent({emitEvent:l,img:e,imgName:n,documentType:t,visible:a,viewed:o,imgId_labelId:d,soundActions:h,keyboardControl:f}){const u=v=>l({type:"translate",payload:v}),[p,x]=React$2.useState(!1),R=e.url,[S]=h,E=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]),g=f({disabled:o,forward:E,escape:E});return React$2.useEffect(()=>g(),[g]),React$2.useEffect(()=>{!a&&!p&&(x(!0),E())},[E,a,p]),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:[R&&jsxRuntimeExports.jsx("img",{src:R,alt:n}),o?null:jsxRuntimeExports.jsx("div",{className:R?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:E,"aria-label":u("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 characterMs$3=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:l,emitEvent:e,pause:n,lines:t,edges:a,characters:o,actors:d,background:h,soundActions:f,lodSettings:u,autoPlay:p,autoEnd:x,progress:R}){var xt,Et,Qe;const S=t.length-1<=(R==null?void 0:R.line)?t.length-1:(R==null?void 0:R.line)||0,[E,g]=React$2.useState(!1),[v,T]=React$2.useState(!0),[b,_]=React$2.useState(!!p),[w,C]=React$2.useState(!1),[P,D]=React$2.useState(S),[N,k]=React$2.useState(!1),[F]=f,{start:M,stop:U}=useTimeout(),$=((xt=h==null?void 0:h.img)==null?void 0:xt.url)||null,B=t[P],{voiceOver:J,decision:ne}=B;let{flex:ie}=B,Y=[];const q=!!a,re=J||B.type==="conversationalNarration",ce=ne||B.type==="conversationalDecision",fe=B.type==="conversationalCamera",[te,H]=React$2.useState([]),W=React$2.useMemo(()=>te[te.length-1],[te]),V=React$2.useCallback(()=>{const Be=a.find(Ye=>Ye.fromId===W)||a.find(Ye=>Ye.toId===W),Xe=t.find(Ye=>Ye.id===(Be==null?void 0:Be.fromId));return!W&&(R==null?void 0:R.line)>=0?{decision:!0}:Xe},[a,t,W,R==null?void 0:R.line]),z=React$2.useCallback(()=>{if(q){const Xe=V();return Xe==null?void 0:Xe.decision}const Be=t[P-1]?t[P-1]:{};return P>0&&(Be==null?void 0:Be.decision)},[q,V,t,P]),Q=React$2.useCallback(()=>{if(q){const Xe=V();return(Xe==null?void 0:Xe.type)==="conversationalCamera"}const Be=t[P-1]?t[P-1]:{};return P>0&&(Be==null?void 0:Be.type)==="conversationalCamera"},[q,t,P,V]),ee=React$2.useCallback(Be=>e({type:"translate",payload:Be}),[e]),le=React$2.useMemo(()=>{var Xe,Ye;if(ce)return{};if(re)return B;const Be=(Xe=B==null?void 0:B.slots)==null?void 0:Xe.find(Pe=>Pe.uid&&Pe.talking);return Be||((Ye=B==null?void 0:B.slots)==null?void 0:Ye.find(Pe=>Pe.uid&&Pe.text))},[B,re,ce]),ue=t.slice(0,P+1).reverse().find(Be=>Be.slots),he=!ce&&((Et=B.slots)==null?void 0:Et.filter(Be=>Be.uid).length),ve=characterMs$3*(((Qe=le==null?void 0:le.text)==null?void 0:Qe.length)||0);let be=[];B.slots?be=B.slots:ue&&(be=ue.slots);const Re=be.filter(Be=>Be.uid).map(Be=>{const Xe=(o||d||[]).find(Ye=>Ye.uid===Be.uid);return Xe&&(Be.resource=Xe.resource,Be.type=Xe.type),Be.resource||(Be.resource={}),Be}),Le={characters:Re,lodSettings:u,actors:d,currentMessage:le||{},slots:re?Y:B.slots,flex:ie,pause:n,emitEvent:e};if(re){const Be=t.slice(P).find(Ye=>Ye.slots),Xe=ue||Be;Xe&&(Y=Xe.slots,ie=Xe.flex)}else if(!ce&&he&&(B.slots.forEach(Be=>{const Xe=Re.findIndex(Ye=>Ye.uid===Be.uid);Xe>=0&&(Re[Xe].emotion=Be.emotion)}),le&&le.uid)){const Be=B.slots.findIndex(Ye=>Ye.uid===le.uid),Xe=Re.findIndex(Ye=>Ye.uid===le.uid);Re.forEach(Ye=>{Ye.uid===le.uid&&(Ye.name=le.alias)}),le.position=ie?Xe:Be}const Oe=React$2.useCallback(()=>{e({type:"success"})},[e]),Ke=React$2.useCallback((Be,Xe)=>{const Ye=[3,2,1][Be.id],Ae=a.filter(_e=>_e.fromId===B.id).find(_e=>parseInt(_e.fromPointIndex)===Ye);if(Ae){const _e=t.findIndex(Ie=>Ie.id===Ae.toId);Ae.fromId===Ae.toId?Xe():_e>=0?(D(_e),e({type:"notifyProgress",payload:{line:_e}})):Oe()}else Oe()},[B.id,a,e,Oe,t]),St=React$2.useCallback((Be=!0)=>{const Xe=Be?["fromId","toId"]:["toId","fromId"],Ye=a.filter(_e=>_e[Xe[0]]===B.id),Pe=Ye.length===1?Ye[0]:Ye.find(_e=>_e[Xe[1]]===W);if(!(Pe!=null&&Pe[Xe[0]])){Oe();return}Be||H(te.slice(0,-1));const Ae=t.findIndex(_e=>_e.id===Pe[Xe[1]]);Ae>=0?(D(Ae),e({type:"notifyProgress",payload:{line:Ae}})):Oe()},[B.id,a,te,e,Oe,W,t]),it=React$2.useCallback(Be=>{if(q){if(Be){const Xe=[3,2,1][Be.id],Pe=a.filter(Ae=>Ae.fromId===B.id).find(Ae=>parseInt(Ae.fromPointIndex)===Xe);if(Pe){const Ae=t.findIndex(_e=>_e.id===Pe.toId);Ae>=0&&e({type:"notifyProgress",payload:{line:Ae}})}else e({type:"saveNode"})}}else if(P<t.length-1){const Ye=P+1;e({type:"notifyProgress",payload:{line:Ye}})}else e({type:"saveNode"})},[a,t,e,P,B.id,q]),gt=React$2.useCallback((Be,Xe)=>{let Ye=!1;if(k(!1),H([...te,B.id]),T(!1),C(!1),q)Be?Ke(Be,Xe):St();else if(P<t.length-1){const Ae=P+1;D(Ae),e({type:"notifyProgress",payload:{line:Ae}}),Xe&&Xe()}else x||ce||fe?Oe():Ye=!0;Ye||T(!0)},[te,B.id,q,P,t.length,x,ce,fe,Ke,St,e,Oe]),Ge=()=>{if(T(!1),k(!1),C(!1),q)St(!1);else if(!z()){const Be=P-1;D(Be),e({type:"notifyProgress",payload:{line:Be}})}T(!0)},Me=React$2.useCallback(()=>q?B&&B.type!=="conversationalDecision"&&!a.find(Be=>Be.fromId===B.id):P===t.length-1,[P,B,a,q,t.length]),De=()=>{F("click-ui"),Me()?Oe():(_(!1),gt())},Ve=()=>{F("click-ui"),_(!1),Ge()},ct=b&&!ce&&!n&&!fe,dt=React$2.useMemo(()=>P===0||z()||Q(),[P,z,Q]);useEkho({audioType:B==null?void 0:B.audioType,volume:B==null?void 0:B.audioVolume,voice:B==null?void 0:B.voice,started:v,slide:P,text:cleanTextOfHtmlTags(le==null?void 0:le.text),audio:B==null?void 0:B.audio,soundActions:f,emitEvent:e,pauseTTS:n,onStart:()=>{var Be;(Be=le==null?void 0:le.emotion)!=null&&Be.includes("think")||k(!0)},onError:()=>{C(!0)},onFinish:()=>{k(!1),ct&&gt()}}),React$2.useEffect(()=>{var Xe;let Be;return ce?()=>{}:(((B==null?void 0:B.audioType)==="none"||w)&&!((Xe=le==null?void 0:le.emotion)!=null&&Xe.includes("think"))&&(k(!0),Be=setTimeout(()=>{k(!1)},ve<minMs$1?minMs$1:ve)),()=>{Be&&clearTimeout(Be)})},[w,B,le==null?void 0:le.emotion,ve,ce]),React$2.useEffect(()=>(ct&&((B==null?void 0:B.audioType)==="none"||w)&&(!Me()||Me()&&x)&&M(gt,ve<minMs$1?minMs$1:ve),()=>{U()}),[le,M,U,gt,B==null?void 0:B.audioType,ct,w,x,t,Me,ve]),React$2.useEffect(()=>{if(fe){const{targetUid:Be}=B;e({type:"changeCamera",payload:{targetUid:Be,transition:{type:"none"}}}),gt()}},[fe,gt,e,B]),React$2.useEffect(()=>{if(q&&!E){const Be=R==null?void 0:R.line;if(Be>=0){g(!0),D(Be);return}const Xe=t.filter(Ye=>!a.find(Pe=>Pe.toId===Ye.id));if(Xe.length){const Ye=Xe[0],Pe=t.indexOf(Ye);Pe>=0&&(g(!0),D(Pe))}}},[a,q,t,E,R==null?void 0:R.line]);const rt=l({disabled:ce,repeat:!1,forward:De,rewind:dt?null:Ve});if(React$2.useEffect(()=>rt(),[rt]),ce){const Be=t[P].id?t.filter(Ye=>Ye.decision).findIndex(Ye=>Ye.id===t[P].id)+1:t.filter(Ye=>Ye.decision).findIndex(Ye=>Ye===t[P])+1,Xe={...B.payload,decisionNumber:Be,required:!q,branched:q,onAddPoints:it,onFinish:gt,keyboardControl:l,emitEvent:e,soundActions:f,inheritProps:{characters:Re,background:h,flex:ue?ue.flex:!0,slots:ue?ue.slots:[]}};return jsxRuntimeExports.jsx(DecisionComponent,{...Xe})}return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversational-pro-image",className:"conversation",style:$?{backgroundImage:`url("${$}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...Le,ttsStarted:N}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[le?jsxRuntimeExports.jsx(Message,{current:le,translate:ee}):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:Ve,"aria-label":LangIsRtl()?ee("storylines.misc.forward"):ee("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 ${b&&Me()?"glowing-animation":""}`,type:"button",onClick:De,"aria-label":LangIsRtl()?ee("storylines.misc.rewind"):ee("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:l,soundActions:e,messages:n,characters:t,alias:a,background:o,lodSettings:d}){var g;const[h,f]=React$2.useState(0),[u]=e,p=((g=o==null?void 0:o.img)==null?void 0:g.url)||null,x=n[h],R=t.map((v,T)=>({...v,name:a[T]?a[T]:v.name,uid:T})),S=()=>{const v=n.length-1;u("click-ui"),h+1<=v?f(h+1):l({type:"success"})},E=()=>{h>0&&(f(h-1),u("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversation-component",className:"conversation arcade-conversation",style:p?{backgroundImage:`url("${p}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:R,lodSettings:d,currentMessage:x,slots:R,emitEvent:l,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[x?jsxRuntimeExports.jsx(Message,{current:x,voiceOver:x.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 ${h>0?"":"visibility--hidden"}`,type:"button",onClick:E,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,soundActions:n=[()=>{},()=>{}],autoPlay:t,autoEnd:a,pause:o,progress:d,keyboardControl:h,backgroundImageCover:f=!1}){var J,ne,ie,Y,q,re,ce,fe;const u=(d==null?void 0:d.slide)||0,p=te=>e({type:"translate",payload:te}),[x,R]=React$2.useState(!0),[S,E]=React$2.useState(!!t),[g,v]=React$2.useState(!1),{start:T,stop:b}=useTimeout(),[_,w]=React$2.useState(u),[C,P]=React$2.useState("slide-animation"),[D]=n,N=l==null?void 0:l[_],k=React$2.useCallback(()=>{R(!1),e({type:"success"})},[e]),F=React$2.useCallback(()=>{if(R(!1),v(!1),_+1<l.length&&!o){const te=_+1;P("slide-animation"),w(te),R(!0),e({type:"notifyProgress",payload:{slide:te}})}else a&&!o&&k()},[_,l.length,o,a,e,k]),M=React$2.useCallback(()=>{if(R(!1),v(!1),_-1>=0){const te=_-1;P("slide-animation"),w(te),R(!0),D("click-ui"),e({type:"notifyProgress",payload:{slide:te}})}},[D,_,e]),U=()=>{D("click-ui"),E(!1),F()},$=()=>{D("click-ui"),E(!1),M()},B=h({repeat:!1,rewind:_>0?$:null,forward:_+1>=l.length?k:U,escape:_+1>=l.length?k:null});return React$2.useEffect(()=>B(),[B]),useEkho({audioType:(J=l==null?void 0:l[_])==null?void 0:J.audioType,voice:(ne=l==null?void 0:l[_])==null?void 0:ne.voice,text:cleanTextOfHtmlTags((Y=(ie=l==null?void 0:l[_])==null?void 0:ie.vignettes[0].textData)==null?void 0:Y.text),audio:(q=l==null?void 0:l[_])==null?void 0:q.audio,slide:_,started:x,soundActions:n,emitEvent:e,pauseTTS:o,volume:(re=l==null?void 0:l[_])!=null&&re.audioVolume||((ce=l==null?void 0:l[_])==null?void 0:ce.audioVolume)===0?(fe=l==null?void 0:l[_])==null?void 0:fe.audioVolume:.5,onError:()=>{v(!0)},onFinish:()=>{S&&!(N!=null&&N.slideTimer)&&F()}}),React$2.useEffect(()=>{var te,H;if(S){if(N!=null&&N.slideTimer)T(F,N.slideTimer*1e3);else if((N==null?void 0:N.audioType)==="none"&&!o||g&&!o){const W=characterMs$2*(((H=(te=N==null?void 0:N.vignettes[0])==null?void 0:te.textData)==null?void 0:H.text.length)||0);T(F,W<1400?1400:W)}}return()=>{b()}},[g,S,F,o,N==null?void 0:N.audio,N==null?void 0:N.audioType,N==null?void 0:N.slideTimer,N==null?void 0:N.vignettes,T,b]),l!=null&&l.length?jsxRuntimeExports.jsx("div",{dir:LangIsRtl()?"rtl":"auto",className:"comic component growIn-animation",role:"main","aria-label":"Comic",children:jsxRuntimeExports.jsxs("div",{className:"comic-slider",role:"navigation","aria-label":"Slider",children:[l[_]&&jsxRuntimeExports.jsx(Slide,{slide:l[_],transition:C,soundActions:n,emitEvent:e,role:"complementary","aria-hidden":"true",translate:p,backgroundImageCover:f},`comic page ${l[_].slideOrder}`),_>0&&jsxRuntimeExports.jsx("button",{type:"button",className:"comic-control comic-control--left gat--btn__round","data-testid":"btn-bck",onClick:$,"aria-label":LangIsRtl()?p("comic.next"):p("comic.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),_<l.length&&jsxRuntimeExports.jsx("button",{type:"button",className:`comic-control comic-control--right gat--btn__round
71
- ${S&&_+1>=l.length?"glowing-animation":""}`,"data-testid":"btn-nxt",onClick:()=>{_+1<l.length?U():(D("click-ui"),k())},"aria-label":LangIsRtl()?p("comic.previous"):p("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,soundActions:d,audioVolume:h,pause:f,keyboardControl:u,backgroundImageCover:p=!1,autoEnd:x=!1}){const[R,S]=React$2.useState(!1),E=k=>o({type:"translate",payload:k}),g=(l==null?void 0:l.url)||"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg",v=React$2.useRef(),T=React$2.useRef(),[b]=d,{start:_,stop:w}=useTimeout();useEkho({audioType:t,voice:a,text:e,audio:n,soundActions:d,emitEvent:o,volume:h,pauseTTS:f,onError:()=>{S(!0)},onFinish:()=>{x&&C()}});const C=React$2.useCallback(()=>{b("click-ui"),o({type:"success"})},[o,b]),P=u({repeat:!1,forward:C,escape:C});React$2.useEffect(()=>P(),[P]);const D=(k,F)=>window.matchMedia("(min-width: 1280px)").matches?F:k,N=React$2.useCallback(()=>{if(p!==!0&&e&&T.current){const k=T.current.naturalWidth/T.current.naturalHeight;let F=T.current.height*k,M=T.current.height;if(F>T.current.width&&(F=T.current.width,M=T.current.width/k),v.current.style.width=`${F}px`,window.innerHeight<T.current.width)v.current.style.bottom=`${D(24,48)+D(36,100)}px`;else{const U=(window.innerHeight-M)/2+D(36,100);v.current.style.bottom=`${U}px`}}},[p,e]);return React$2.useEffect(()=>{T.current&&new ResizeObserver(()=>{D(24,48),N()}).observe(T.current)},[N]),React$2.useEffect(()=>{if(x&&!f&&(!n||R)){const k=characterMs$1*(e.length||0);_(()=>{C()},k<2400?2400:k)}return()=>{w()}},[n,R,x,C,f,_,w,e]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:`cartel ${p?"cartel--cover":""}`,children:jsxRuntimeExports.jsxs("div",{className:"cartel__imagewrap",children:[jsxRuntimeExports.jsx("img",{ref:T,onLoad:N,className:"cartel__image",src:g,alt:"cartel pic"}),e?jsxRuntimeExports.jsx("div",{ref:v,className:"cartel__textwrap",children:jsxRuntimeExports.jsx("div",{className:"cartel__text",children:jsxRuntimeExports.jsx("span",{children:e})})}):null]})}),jsxRuntimeExports.jsx("div",{className:"position--absolute center right",children:jsxRuntimeExports.jsx("button",{"data-testid":"cartel-close-button",type:"button",className:"gat--btn__round",onClick:()=>C(),"aria-label":E("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 U in M)Object.prototype.hasOwnProperty.call(M,U)&&(k[U]=M[U])}return k},o=function(){function k(F,M){for(var U=0;U<M.length;U++){var $=M[U];$.enumerable=$.enumerable||!1,$.configurable=!0,"value"in $&&($.writable=!0),Object.defineProperty(F,$.key,$)}}return function(F,M,U){return M&&k(F.prototype,M),U&&k(F,U),F}}(),d=t(1),h=_(d),f=t(2),u=_(f),p=t(10),x=_(p),R=t(12),S=_(R),E=t(13),g=_(E),v=t(14),T=b(v);function b(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 P(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 D=["🔙","⏰"],N=function(k){P(F,k);function F(M){w(this,F);var U=C(this,(F.__proto__||Object.getPrototypeOf(F)).call(this,M));return U.state={textLines:[],isDone:!1},U.onTypingDone=function(){U.mounted&&(U.setState({isDone:!0}),U.props.onTypingDone())},U.delayGenerator=function($,B,J,ne){var ie=U.props.avgTypingDelay,Y=U.props.stdTypingDelay;return U.props.delayGenerator(ie,Y,{line:$,lineIdx:B,character:J,charIdx:ne,defDelayGenerator:function(){var re=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ie,ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Y;return T.gaussianRnd(re,ce)}})},U.typeLine=function($,B){if(!U.mounted)return Promise.resolve();var J=$,ne=U.props.onLineTyped;return T.isBackspaceElement($)?($.props.delay>0&&(U.introducedDelay=$.props.delay),J="🔙".repeat($.props.count)):T.isDelayElement($)&&(U.introducedDelay=$.props.ms,J="⏰"),new Promise(function(ie,Y){U.setState({textLines:U.state.textLines.concat([""])},function(){T.eachPromise(J,U.typeCharacter,J,B).then(function(){return ne(J,B)}).then(ie).catch(Y)})})},U.typeCharacter=function($,B,J,ne){if(!U.mounted)return Promise.resolve();var ie=U.props.onCharacterTyped;return new Promise(function(Y){var q=U.state.textLines.slice();T.sleep(U.introducedDelay).then(function(){U.introducedDelay=null;var re=$==="🔙",ce=$==="⏰";if(ce){Y();return}if(re&&ne>0){for(var fe=ne-1,te=q[fe],H=fe;H>=0&&!(te.length>0&&!D.includes(te[0]));H--)fe=H,te=q[fe];q[fe]=te.substr(0,te.length-1)}else q[ne]+=$;U.setState({textLines:q},function(){var W=U.delayGenerator(J,ne,$,B);ie($,B),setTimeout(Y,W)})})})},U.mounted=!1,U.linesToType=[],U.introducedDelay=null,M.children&&(U.linesToType=T.extractTextFromElement(M.children)),U}return o(F,[{key:"componentDidMount",value:function(){this.mounted=!0;var U=this.props,$=U.children,B=U.startDelay;$?B>0&&typeof window<"u"?setTimeout(this.typeAllLines.bind(this),B):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(U,$){if($.textLines.length!==this.state.textLines.length)return!0;for(var B=0;B<$.textLines.length;B++){var J=this.state.textLines[B],ne=$.textLines[B];if(J!==ne)return!0}return this.state.isDone!==$.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var U=this,$=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.linesToType;return T.eachPromise($,this.typeLine).then(function(){return U.onTypingDone()})}},{key:"render",value:function(){var U=this.props,$=U.className,B=U.cursor,J=this.state.isDone,ne=T.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return h.default.createElement("div",{className:"Typist "+$},ne,h.default.createElement(x.default,a({isDone:J},B)))}}]),F}(d.Component);N.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},N.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:T.gaussianRnd},n.default=N,N.Backspace=S.default,N.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 x=typeof Symbol=="function"&&Symbol.iterator,R="@@iterator";function S(q){var re=q&&(x&&q[x]||q[R]);if(typeof re=="function")return re}var E="<<anonymous>>",g={array:_("array"),bool:_("boolean"),func:_("function"),number:_("number"),object:_("object"),string:_("string"),symbol:_("symbol"),any:w(),arrayOf:C,element:P(),instanceOf:D,node:M(),objectOf:k,oneOf:N,oneOfType:F,shape:U};function v(q,re){return q===re?q!==0||1/q===1/re:q!==q&&re!==re}function T(q){this.message=q,this.stack=""}T.prototype=Error.prototype;function b(q){if(process.env.NODE_ENV!=="production")var re={},ce=0;function fe(H,W,V,z,Q,ee,le){if(z=z||E,ee=ee||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 ue=z+":"+V;!re[ue]&&ce<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.",ee,z),re[ue]=!0,ce++)}}return W[V]==null?H?W[V]===null?new T("The "+Q+" `"+ee+"` is marked as required "+("in `"+z+"`, but its value is `null`.")):new T("The "+Q+" `"+ee+"` is marked as required in "+("`"+z+"`, but its value is `undefined`.")):null:q(W,V,z,Q,ee)}var te=fe.bind(null,!1);return te.isRequired=fe.bind(null,!0),te}function _(q){function re(ce,fe,te,H,W,V){var z=ce[fe],Q=J(z);if(Q!==q){var ee=ne(z);return new T("Invalid "+H+" `"+W+"` of type "+("`"+ee+"` supplied to `"+te+"`, expected ")+("`"+q+"`."))}return null}return b(re)}function w(){return b(a.thatReturnsNull)}function C(q){function re(ce,fe,te,H,W){if(typeof q!="function")return new T("Property `"+W+"` of component `"+te+"` has invalid PropType notation inside arrayOf.");var V=ce[fe];if(!Array.isArray(V)){var z=J(V);return new T("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+te+"`, expected an array."))}for(var Q=0;Q<V.length;Q++){var ee=q(V,Q,te,H,W+"["+Q+"]",h);if(ee instanceof Error)return ee}return null}return b(re)}function P(){function q(re,ce,fe,te,H){var W=re[ce];if(!u(W)){var V=J(W);return new T("Invalid "+te+" `"+H+"` of type "+("`"+V+"` supplied to `"+fe+"`, expected a single ReactElement."))}return null}return b(q)}function D(q){function re(ce,fe,te,H,W){if(!(ce[fe]instanceof q)){var V=q.name||E,z=Y(ce[fe]);return new T("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+te+"`, expected ")+("instance of `"+V+"`."))}return null}return b(re)}function N(q){if(!Array.isArray(q))return process.env.NODE_ENV!=="production"&&d(!1,"Invalid argument supplied to oneOf, expected an instance of array."),a.thatReturnsNull;function re(ce,fe,te,H,W){for(var V=ce[fe],z=0;z<q.length;z++)if(v(V,q[z]))return null;var Q=JSON.stringify(q);return new T("Invalid "+H+" `"+W+"` of value `"+V+"` "+("supplied to `"+te+"`, expected one of "+Q+"."))}return b(re)}function k(q){function re(ce,fe,te,H,W){if(typeof q!="function")return new T("Property `"+W+"` of component `"+te+"` has invalid PropType notation inside objectOf.");var V=ce[fe],z=J(V);if(z!=="object")return new T("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+te+"`, expected an object."));for(var Q in V)if(V.hasOwnProperty(Q)){var ee=q(V,Q,te,H,W+"."+Q,h);if(ee instanceof Error)return ee}return null}return b(re)}function F(q){if(!Array.isArray(q))return process.env.NODE_ENV!=="production"&&d(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),a.thatReturnsNull;for(var re=0;re<q.length;re++){var ce=q[re];if(typeof ce!="function")return d(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",ie(ce),re),a.thatReturnsNull}function fe(te,H,W,V,z){for(var Q=0;Q<q.length;Q++){var ee=q[Q];if(ee(te,H,W,V,z,h)==null)return null}return new T("Invalid "+V+" `"+z+"` supplied to "+("`"+W+"`."))}return b(fe)}function M(){function q(re,ce,fe,te,H){return $(re[ce])?null:new T("Invalid "+te+" `"+H+"` supplied to "+("`"+fe+"`, expected a ReactNode."))}return b(q)}function U(q){function re(ce,fe,te,H,W){var V=ce[fe],z=J(V);if(z!=="object")return new T("Invalid "+H+" `"+W+"` of type `"+z+"` "+("supplied to `"+te+"`, expected `object`."));for(var Q in q){var ee=q[Q];if(ee){var le=ee(V,Q,te,H,W+"."+Q,h);if(le)return le}}return null}return b(re)}function $(q){switch(typeof q){case"number":case"string":case"undefined":return!0;case"boolean":return!q;case"object":if(Array.isArray(q))return q.every($);if(q===null||u(q))return!0;var re=S(q);if(re){var ce=re.call(q),fe;if(re!==q.entries){for(;!(fe=ce.next()).done;)if(!$(fe.value))return!1}else for(;!(fe=ce.next()).done;){var te=fe.value;if(te&&!$(te[1]))return!1}}else return!1;return!0;default:return!1}}function B(q,re){return q==="symbol"||re["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&re instanceof Symbol}function J(q){var re=typeof q;return Array.isArray(q)?"array":q instanceof RegExp?"object":B(re,q)?"symbol":re}function ne(q){if(typeof q>"u"||q===null)return""+q;var re=J(q);if(re==="object"){if(q instanceof Date)return"date";if(q instanceof RegExp)return"regexp"}return re}function ie(q){var re=ne(q);switch(re){case"array":case"object":return"an "+re;case"boolean":case"date":case"regexp":return"a "+re;default:return re}}function Y(q){return!q.constructor||!q.constructor.name?E:q.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,x,R){if(t(d),!o){var S;if(d===void 0)S=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var E=[h,f,u,p,x,R],g=0;S=new Error(d.replace(/%s/g,function(){return E[g++]})),S.name="Invariant Violation"}throw S.framesToPop=1,S}}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),x=1;x<u;x++)p[x-1]=arguments[x];var R=0,S="Warning: "+f.replace(/%s/g,function(){return p[R++]});typeof console<"u"&&console.error(S);try{throw new Error(S)}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,x=Array(p>2?p-2:0),R=2;R<p;R++)x[R-2]=arguments[R];d.apply(void 0,[u].concat(x))}}}(),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,x,R,S){if(process.env.NODE_ENV!=="production"){for(var E in u)if(u.hasOwnProperty(E)){var g;try{a(typeof u[E]=="function","%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",R||"React class",x,E),g=u[E](p,E,R,x,null,d)}catch(T){g=T}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).",R||"React class",x,E,typeof g),g instanceof Error&&!(g.message in h)){h[g.message]=!0;var v=S?S():"";o(!1,"Failed %s type: %s%s",x,g.message,v??"")}}}}e.exports=f},function(e,n,t){var a=t(4),o=t(5),d=t(7);e.exports=function(){function h(p,x,R,S,E,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 E(g,v){for(var T=0;T<v.length;T++){var b=v[T];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}return function(g,v,T){return v&&E(g.prototype,v),T&&E(g,T),g}}(),o=t(1),d=u(o),h=t(2),f=u(h);t(11);function u(E){return E&&E.__esModule?E:{default:E}}function p(E,g){if(!(E instanceof g))throw new TypeError("Cannot call a class as a function")}function x(E,g){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:E}function R(E,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);E.prototype=Object.create(g&&g.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(E,g):E.__proto__=g)}var S=function(E){R(g,E);function g(v){p(this,g);var T=x(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,v));return T._isReRenderingCursor=!1,T.state={shouldRender:T.props.show},T}return a(g,[{key:"componentWillReceiveProps",value:function(T){var b=this,_=!this.props.isDone&&T.isDone&&this.props.hideWhenDone;_&&setTimeout(function(){return b.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var T=this.props,b=T.show,_=T.isDone;b&&(_||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var T=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){T.setState({shouldRender:!0},function(){T._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var T=this.props.blink?" Cursor--blinking":"";return d.default.createElement("span",{className:"Cursor"+T},this.props.element)}return null}}]),g}(o.Component);S.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},S.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},n.default=S},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 b(_,w){var C=[],P=!0,D=!1,N=void 0;try{for(var k=_[Symbol.iterator](),F;!(P=(F=k.next()).done)&&(C.push(F.value),!(w&&C.length===w));P=!0);}catch(M){D=!0,N=M}finally{try{!P&&k.return&&k.return()}finally{if(D)throw N}}return C}return function(_,w){if(Array.isArray(_))return _;if(Symbol.iterator in Object(_))return b(_,w);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.gaussianRnd=u,n.eachPromise=p,n.exclude=x,n.isBackspaceElement=R,n.isDelayElement=S,n.extractTextFromElement=E,n.cloneElement=g,n.cloneElementWithSpecifiedText=T;var o=t(1),d=h(o);function h(b){return b&&b.__esModule?b:{default:b}}function f(b){if(Array.isArray(b)){for(var _=0,w=Array(b.length);_<b.length;_++)w[_]=b[_];return w}else return Array.from(b)}n.sleep=function(_){return new Promise(function(w){return _!=null?setTimeout(w,_):w()})};function u(b,_){for(var w=12,C=0,P=0;P<w;P++)C+=Math.random();return C-=w/2,Math.round(C*_)+b}function p(b,_){for(var w=arguments.length,C=Array(w>2?w-2:0),P=2;P<w;P++)C[P-2]=arguments[P];var D=function(k,F,M){return k.then(function(){return _.apply(void 0,[F,M].concat(C))})};return Array.from(b).reduce(D,Promise.resolve())}function x(b,_){var w={};for(var C in b)_.indexOf(C)===-1&&(w[C]=b[C]);return w}function R(b){return b&&b.type&&b.type.componentName==="Backspace"}function S(b){return b&&b.type&&b.type.componentName==="Delay"}function E(b){for(var _=b?[b]:[],w=[];_.length>0;){var C=_.pop();if(d.default.isValidElement(C))R(C)||S(C)?w.unshift(C):d.default.Children.forEach(C.props.children,function(U){_.push(U)});else if(Array.isArray(C)){var P=!0,D=!1,N=void 0;try{for(var k=C[Symbol.iterator](),F;!(P=(F=k.next()).done);P=!0){var M=F.value;_.push(M)}}catch(U){D=!0,N=U}finally{try{!P&&k.return&&k.return()}finally{if(D)throw N}}}else w.unshift(C)}return w}function g(b,_){var w=b.type,C=x(b.props,["children"]),P=new Date().getUTCMilliseconds(),D=P+Math.random()+Math.random();return C.key="Typist-element-"+w+"-"+D,d.default.createElement.apply(d.default,[w,C].concat(f(_)))}function v(b,_,w){if(w>=_.length)return[null,w];var C=w,P=function(M){var U=v(M,_,C),$=a(U,2),B=$[0],J=$[1];return C=J,B},D=d.default.isValidElement(b)&&!(R(b)||S(b));if(D){var N=d.default.Children.map(b.props.children,P)||[];return[g(b,N),C]}if(Array.isArray(b)){var k=b.map(P);return[k,C]}return[_[C],C+1]}function T(b){var _=b.element,w=b.textLines;if(_)return v(_,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,soundActions:e,info:n,themeNumber:t,type:a,writingSpeed:o,disableExit:d,setResolveAction:h}){const f=B=>l({type:"translate",payload:B}),[u]=e,{solution:p}=n,R=themes[`theme${t||1}`],[S,E]=React$2.useState(""),[g,v]=React$2.useState(0),[T,b]=React$2.useState(0),[_,w]=React$2.useState(!1),[C,P]=React$2.useState({start:0,end:0}),D=React$2.useRef(),N=React$2.useRef(),k=f("puzzle.hacker.congratulations"),F=(B,J)=>B>J.length?J.length:B,M=()=>{u("click-ui");const{rewards:B}=p.right;l({type:"addPoints",complex:!0,finish:!0,payload:B}),l({type:"passPuzzle"})};React$2.useEffect(()=>{D.current.focus(),_&&d(!0)},[_]),React$2.useEffect(()=>{h(B=>{u("score"),w(!0),l({type:"hidePuzzleButtons",payload:!1}),B()})},[h]);const U=()=>{if(languages[a]&&!_){N.current&&(N.current.scrollTop=D.current.scrollHeight);const B=languages[a],J=B[g],ne=B.reduce((Y,q)=>(Y.length?Y.length:Y)+q.length),ie=o>0?o:Math.floor(ne/50)+g;if(J){const Y=J.split(""),q=F(C.end,Y),re=Y.slice(C.start,q),ce=S+re.join("");b(T+re.join("").length),E(ce),q===Y.length?g+1>=B.length?(u("score"),w(!0)):(v(g+1),E(`${S+re.join("")}<br>`),P({start:0,end:F(ie,Y)})):P({start:q,end:F(q+ie,Y)})}}},$=B=>{B.preventDefault(),U()};return jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,"data-testid":"hacker",ref:D,onKeyDown:$,onTouchStart:$,className:`puzzle--hacker__container background-hacker-${R.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-${R.color} typography-hacker-${R.typo}`,children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--hacker__code",ref:N,children:[jsxRuntimeExports.jsx(Code,{codeContainer:S}),_?jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,onCharacterTyped:()=>{N.current&&(N.current.scrollTop=D.current.scrollHeight)},cursor:{hideWhenDone:!0},className:"puzzle--hacker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),p.right.desc?`// ${p.right.desc}`:`${k}`]}):null]}),jsxRuntimeExports.jsx(ProgressBar,{type:a,progress:T})]}),_?jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:M,children:f("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,info:n,user:t,login:a,password:o,image:d,setResolveAction:h,nodeId:f}){var q;const u=re=>l({type:"translate",payload:re}),p=`login-puzzle_${f}`,x=LangIsRtl(),[R,S]=React$2.useState(""),[E,g]=React$2.useState(""),[v,T]=React$2.useState(!1),[b,_]=React$2.useState(""),[w,C]=React$2.useState(""),[P,D]=React$2.useState(!1),[N,k]=React$2.useState(!1),[F,M]=React$2.useState(!1),[U]=e,[$,B]=React$2.useState([]),J=((q=d.img)==null?void 0:q.url)||imagenPorDefecto,ne=()=>{const{rewards:re}=n.solution.right,ce=[...$,...re];l({type:"addPoints",complex:!0,finish:!0,payload:ce}),l({type:"passPuzzle"})},ie=()=>{U("click-ui");const re={login:!0,password:!1};a&&(re.login=t===R),re.password=o===E,re.login&&re.password?(C("success"),D(!0),k(!1),U("score"),setTimeout(()=>{ne()},2e3)):(B([...$,...n.solution.wrong.rewards]),U("fail"),C("failed"),k(!0),l({type:"failPuzzle"}))},Y=re=>{let ce="";if(re.length>=0){for(let fe=0;fe<re.length;fe+=1)ce+="•";_(ce)}};return React$2.useEffect(()=>{h(()=>{const re=[...$,...n.resolve.rewards];M(!0),setTimeout(()=>{l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:p,rewards:re,finish:!0}})},2e3)})},[$,n.resolve.rewards,l,h,p]),jsxRuntimeExports.jsx("div",{className:"puzzle--layer",style:{backgroundImage:`url("${J}")`},children:jsxRuntimeExports.jsxs("div",{className:`puzzle--login ${t?"puzzle--login--withuser":""}`,children:[jsxRuntimeExports.jsx("span",{className:"icon-login-puzzle",children:" "}),jsxRuntimeExports.jsx("span",{className:"puzzle--login__title",children:u("puzzle.initSession")}),jsxRuntimeExports.jsxs("div",{children:[a&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--login__label",children:u("puzzle.user")}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[F?jsxRuntimeExports.jsx("input",{dir:x?"rtl":"auto",disabled:P,"data-testid":"username",className:"puzzle--login__input success",type:"text",placeholder:t,value:t}):jsxRuntimeExports.jsx("input",{dir:x?"rtl":"auto",disabled:P,"data-testid":"username",className:`puzzle--login__input ${w}`,type:"text",placeholder:u("puzzle.user"),onChange:re=>{S(re.target.value),C(""),k(!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:u("puzzle.password")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[F?jsxRuntimeExports.jsx("input",{dir:x?"rtl":"auto",disabled:!0,"data-testid":"password",className:"puzzle--login__input puzzle--login__input--fakepassword success",type:"text",placeholder:o,value:o,style:{opacity:1}}):jsxRuntimeExports.jsx("input",{dir:x?"rtl":"auto",disabled:P,"data-testid":"password",className:`puzzle--login__input puzzle--login__input--fakepassword ${w}`,type:"text",placeholder:u("puzzle.password"),onFocus:()=>{T(!0)},onBlur:()=>{T(!1)},onChange:re=>{g(re.target.value),Y(re.target.value),C(""),k(!1)}}),F?null:jsxRuntimeExports.jsx("div",{dir:x?"rtl":"auto",className:`login-fakepassword${v?" login-fakepassword--focus":""}${b.length?" login-fakepassword--fill":""} ${w||""}`,children:E?b:u("puzzle.password")}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check",children:" "})]})]})]}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${E.length!==0&&!P?"":"disabled"}`,onClick:ie,children:u("puzzle.loginIn")}),!F&&N&&n.solution.wrong.desc!==""&&jsxRuntimeExports.jsx("div",{className:"puzzle--login__label--error",children:n.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:x}){const[R,S]=React$2.useState();React$2.useEffect(()=>{let T;return n&&n(e?"score":"fail"),l&&!h&&(T=setTimeout(()=>{S(!0)},1e3)),()=>{T&&clearTimeout(T)}},[n,e,h,l]),React$2.useEffect(()=>{let T;return f&&a&&(T=setTimeout(a,u)),()=>{T&&clearTimeout(T)}},[u,a,f]);const E=()=>e?"success":"failed",g=()=>e?"icon-correct-thumb":p?"icon-times-up":"icon-incorrect-thumb",v=x({disabled:!(l&&a&&R),repeat:!1,forward:a,close:a});return React$2.useEffect(()=>v(),[v]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:`feedback-layer ${R?"feedback-layer--withexplain":""}`,children:[jsxRuntimeExports.jsxs("div",{className:`feedback-layer__header ${h?"feedback-layer__header--in-shortText":""} ${t||""} ${E()}`,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()}`}):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&&R&&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,image:e,password:n,keyboard:t,info:a,disableExit:o,soundActions:d,setResolveAction:h,nodeId:f,keyboardControl:u,styles:p="default-theme"}){var ie,Y;const[x,R]=React$2.useState(""),[S,E]=React$2.useState(""),[g,v]=React$2.useState(!1),[T,b]=React$2.useState(""),[_,w]=React$2.useState(!1),[C,P]=React$2.useState([]),D=q=>l({type:"translate",payload:q}),N=`keyboard-puzzle_${f}`,[k]=d,F=React$2.useCallback(q=>{v(!1),w(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:q})},[l]),M=()=>{if(g){const{rewards:q}=a.solution.right,re=[...C,...q];k("score"),F(re)}else l({type:"hidePuzzleButtons",payload:!1}),v(!1),o(!1),w(!1);b("")},U=q=>{q===n?(o(!1),R("success"),k("score"),l({type:"passPuzzle"}),v(!0),w(!0),a.solution.right.desc?b(a.solution.right.desc):setTimeout(()=>{const{rewards:re}=a.solution.right,ce=[...C,...re];F(ce)},3e3)):(w(!0),R("failed"),k("fail"),l({type:"failPuzzle"}),v(!1),P([...C,...a.solution.wrong.rewards]),l({type:"hidePuzzleButtons",payload:!1}),R(""),E(""),w(!0),a.solution.wrong.desc?b(a.solution.wrong.desc):setTimeout(()=>{M()},3e3))};React$2.useEffect(()=>{h(()=>{o(!1),k("score"),R("success"),v(!0),b(a.solution.right.desc),E(n);const q=[...C,...a.resolve.rewards];setTimeout(()=>{v(!1),w(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:N,rewards:q,finish:!0}})},2e3)})},[h,o,a.solution.right.desc,k,a.resolve.rewards,C,n,l,N]);const $=(q,re)=>{const ce=t[q][re];k("click-ui"),S.length<n.length+1&&(E(S+ce),S.length+1===n.length&&U(S+ce))},B=()=>{k("click-ui"),E(S.substring(0,S.length-1))},ne={backgroundImage:`url("${((ie=e.img)==null?void 0:ie.url)||""}")`,backgroudPosition:"center center"};return jsxRuntimeExports.jsxs("div",{className:`puzzle-keyboard puzzle-keyboard--${p}`,style:(Y=e.img)!=null&&Y.url?ne:null,children:[jsxRuntimeExports.jsx("div",{className:"puzzle-keyboard__header",children:jsxRuntimeExports.jsxs("div",{className:"puzzle-keyboard__digits",children:[n.split("").map((q,re)=>jsxRuntimeExports.jsx("div",{className:`puzzle-keyboard__digit ${x}`,children:S.split("")[re]?S.split("")[re]:""},`${q+re}`)),x!==""?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:x==="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:B,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:[p==="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--${p}`,children:t.map((q,re)=>(Array.isArray(q)?q:Object.values(q)).map((ce,fe)=>jsxRuntimeExports.jsx("button",{className:`keyboard-key keyboard-key--${p} ${ce==="*"?"keyboard-key--star":""}`,type:"button",onClick:()=>$(re,fe),children:jsxRuntimeExports.jsx("div",{children:ce})},ce)))}),p==="scifi-theme"&&jsxRuntimeExports.jsx("hr",{"aria-hidden":!0,className:"puzzle-keyboard__scifi-line"})]}),_&&jsxRuntimeExports.jsx(FeedbackComponent$1,{translate:D,text:T,success:g,functionOnClose:M,keyboardControl:u})]})}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),P=Math.sin(w),D=this.m[0]*C+this.m[2]*P,N=this.m[1]*C+this.m[3]*P,k=this.m[0]*-P+this.m[2]*C,F=this.m[1]*-P+this.m[3]*C;return this.m[0]=D,this.m[1]=N,this.m[2]=k,this.m[3]=F,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(w,C){var P=this.m[0]+this.m[2]*C,D=this.m[1]+this.m[3]*C,N=this.m[2]+this.m[0]*w,k=this.m[3]+this.m[1]*w;return this.m[0]=P,this.m[1]=D,this.m[2]=N,this.m[3]=k,this}multiply(w){var C=this.m[0]*w.m[0]+this.m[2]*w.m[1],P=this.m[1]*w.m[0]+this.m[3]*w.m[1],D=this.m[0]*w.m[2]+this.m[2]*w.m[3],N=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]=P,this.m[2]=D,this.m[3]=N,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,P=-this.m[1]*w,D=-this.m[2]*w,N=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]=P,this.m[2]=D,this.m[3]=N,this.m[4]=k,this.m[5]=F,this}getMatrix(){return this.m}decompose(){var w=this.m[0],C=this.m[1],P=this.m[2],D=this.m[3],N=this.m[4],k=this.m[5],F=w*D-C*P;let M={x:N,y:k,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(w!=0||C!=0){var U=Math.sqrt(w*w+C*C);M.rotation=C>0?Math.acos(w/U):-Math.acos(w/U),M.scaleX=U,M.scaleY=F/U,M.skewX=(w*P+C*D)/F,M.skewY=0}else if(P!=0||D!=0){var $=Math.sqrt(P*P+D*D);M.rotation=Math.PI/2-(D>0?Math.acos(-P/$):-Math.acos(P/$)),M.scaleX=F/$,M.scaleY=$,M.skewX=0,M.skewY=(w*P+C*D)/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="",x="0",R="Konva warning: ",S="Konva error: ",E="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]},v=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,T=[];const b=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(_){T.push(_),T.length===1&&b(function(){const w=T;T=[],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;)_=x+_;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)===E?(w=v.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,P)=>C.slice(-1)==="%"?P===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(_),P=Number(C[0])/360,D=Number(C[1])/100,N=Number(C[2])/100;let k,F,M;if(D===0)return M=N*255,{r:Math.round(M),g:Math.round(M),b:Math.round(M),a:1};N<.5?k=N*(1+D):k=N+D-N*D;const U=2*N-k,$=[0,0,0];for(let B=0;B<3;B++)F=P+1/3*-(B-1),F<0&&F++,F>1&&F--,6*F<1?M=U+(k-U)*6*F:2*F<1?M=k:3*F<2?M=U+(k-U)*(2/3-F)*6:M=U,$[B]=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(S+_)},error(_){console.error(S+_)},warn(_){e.Konva.showWarnings&&console.warn(R+_)},each(_,w){for(var C in _)w(C,_[C])},_inRange(_,w,C){return w<=_&&_<C},_getProjectionToSegment(_,w,C,P,D,N){var k,F,M,U=(_-C)*(_-C)+(w-P)*(w-P);if(U==0)k=_,F=w,M=(D-C)*(D-C)+(N-P)*(N-P);else{var $=((D-_)*(C-_)+(N-w)*(P-w))/U;$<0?(k=_,F=w,M=(_-D)*(_-D)+(w-N)*(w-N)):$>1?(k=C,F=P,M=(C-D)*(C-D)+(P-N)*(P-N)):(k=_+$*(C-_),F=w+$*(P-w),M=(k-D)*(k-D)+(F-N)*(F-N))}return[k,F,M]},_getProjectionToLine(_,w,C){var P=l.Util.cloneObject(_),D=Number.MAX_VALUE;return w.forEach(function(N,k){if(!(!C&&k===w.length-1)){var F=w[(k+1)%w.length],M=l.Util._getProjectionToSegment(N.x,N.y,F.x,F.y,_.x,_.y),U=M[0],$=M[1],B=M[2];B<D&&(P.x=U,P.y=$,D=B)}}),P},_prepareArrayForTween(_,w,C){var P,D=[],N=[];if(_.length>w.length){var k=w;w=_,_=k}for(P=0;P<_.length;P+=2)D.push({x:_[P],y:_[P+1]});for(P=0;P<w.length;P+=2)N.push({x:w[P],y:w[P+1]});var F=[];return N.forEach(function(M){var U=l.Util._getProjectionToLine(M,D,C);F.push(U.x),F.push(U.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,P){let D=0,N=0,k=0,F=0;typeof P=="number"?D=N=k=F=Math.min(P,w/2,C/2):(D=Math.min(P[0]||0,w/2,C/2),N=Math.min(P[1]||0,w/2,C/2),F=Math.min(P[2]||0,w/2,C/2),k=Math.min(P[3]||0,w/2,C/2)),_.moveTo(D,0),_.lineTo(w-N,0),_.arc(w-N,N,N,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,D),_.arc(D,D,D,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,x=e.Util._capitalize,R=t+x(d),S=a+x(d),E,g;o.prototype[R]=function(){var T={};for(E=0;E<p;E++)g=h[E],T[g]=this.getAttr(d+x(g));return T};var v=(0,n.getComponentValidator)(h);o.prototype[S]=function(T){var b=this.attrs[d],_;f&&(T=f.call(this,T)),v&&v.call(this,T,d);for(_ in T)T.hasOwnProperty(_)&&this._setAttr(d+x(_),T[_]);return T||h.forEach(w=>{this._setAttr(d+x(w),void 0)}),this._fireChangeEvent(d,b,T),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 x=this.attrs[d];return x===void 0?h:x},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),x=a+e.Util._capitalize(h);function R(){u.apply(this,arguments),e.Util.error('"'+h+'" method is deprecated and will be removed soon. Use ""'+f+'" instead.')}o.prototype[h]=R,o.prototype[p]=R,o.prototype[x]=R})},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,x=this._context;p.length===3?x.drawImage(e,n,t):p.length===5?x.drawImage(e,n,t,a,o):p.length===9&&x.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,x=f.y*u;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",d*Math.min(Math.abs(p),Math.abs(x))),this.setAttr("shadowOffsetX",h.x*p),this.setAttr("shadowOffsetY",h.y*x)}}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(R=>R.id===o.pointerId);if(u){if(o.dragStatus!=="dragging"){var p=h.dragDistance(),x=Math.max(Math.abs(u.x-o.startPointerPos.x),Math.abs(u.y-o.startPointerPos.y));if(x<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,x=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 R=new Canvas_1$1.SceneCanvas({pixelRatio:d,width:a,height:o}),S=new Canvas_1$1.SceneCanvas({pixelRatio:d,width:0,height:0,willReadFrequently:!0}),E=new Canvas_1$1.HitCanvas({pixelRatio:x,width:a,height:o}),g=R.getContext(),v=E.getContext();return E.isCache=!0,R.isCache=!0,this._cache.delete(CANVAS),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(R.getContext()._context.imageSmoothingEnabled=!1,S.getContext()._context.imageSmoothingEnabled=!1),g.save(),v.save(),g.translate(-h,-f),v.translate(-h,-f),this._isUnderCache=!0,this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this.drawScene(R,this),this.drawHit(E,this),this._isUnderCache=!1,g.restore(),v.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:R,filter:S,hit:E,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(x){Util_1$c.Util.error("Unable to apply filter. "+x.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,x=this.attrs.offsetX||0,R=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),(x!==0||R!==0)&&t.translate(-1*x,-1*R),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 x=this.getAbsoluteTransform(t),R=x.getMatrix();o.transform(R[0],R[1],R[2],R[3],R[4],R[5]),o.beginPath();let v;if(f)v=f.call(this,o,this);else{var S=this.clipX(),E=this.clipY();o.rect(S,E,d,h)}o.clip.apply(o,v),R=x.copy().invert().getMatrix(),o.transform(R[0],R[1],R[2],R[3],R[4],R[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(v){v[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 v=g.getClientRect({relativeTo:p,skipShadow:e.skipShadow,skipStroke:e.skipStroke});v.width===0&&v.height===0||(o===void 0?(o=v.x,d=v.y,h=v.x+v.width,f=v.y+v.height):(o=Math.min(o,v.x),d=Math.min(d,v.y),h=Math.max(h,v.x+v.width),f=Math.max(f,v.y+v.height)))}});for(var x=this.find("Shape"),R=!1,S=0;S<x.length;S++){var E=x[S];if(E._isVisible(this)){R=!0;break}}return R&&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",x="px",R="mouseout",S="mouseleave",E="mouseover",g="mouseenter",v="mousemove",T="mousedown",b="mouseup",_="pointermove",w="pointerdown",C="pointerup",P="pointercancel",D="lostpointercapture",N="pointerout",k="pointerleave",F="pointerover",M="pointerenter",U="contextmenu",$="touchstart",B="touchend",J="touchmove",ne="touchcancel",ie="wheel",Y=5,q=[[g,"_pointerenter"],[T,"_pointerdown"],[v,"_pointermove"],[b,"_pointerup"],[S,"_pointerleave"],[$,"_pointerdown"],[J,"_pointermove"],[B,"_pointerup"],[ne,"_pointercancel"],[E,"_pointerover"],[ie,"_wheel"],[U,"_contextmenu"],[w,"_pointerdown"],[_,"_pointermove"],[C,"_pointerup"],[P,"_pointercancel"],[D,"_lostpointercapture"]];const re={mouse:{[N]:R,[k]:S,[F]:E,[M]:g,[_]:v,[w]:T,[C]:b,[P]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[N]:"touchout",[k]:"touchleave",[F]:"touchover",[M]:"touchenter",[_]:J,[w]:$,[C]:B,[P]:ne,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[N]:N,[k]:k,[F]:F,[M]:M,[_]:_,[w]:w,[C]:C,[P]:P,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},ce=V=>V.indexOf("pointer")>=0?"pointer":V.indexOf("touch")>=0?"touch":"mouse",fe=V=>{const z=ce(V);if(z==="pointer")return a.Konva.pointerEventsEnabled&&re.pointer;if(z==="touch")return re.touch;if(z==="mouse")return re.mouse};function te(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(z){super(te(z)),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",()=>{te(this.attrs)}),this._checkVisibility()}_validateAdd(z){const Q=z.getType()==="Layer",ee=z.getType()==="FastLayer";Q||ee||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const z=this.visible()?"":"none";this.content.style.display=z}setContainer(z){if(typeof z===p){if(z.charAt(0)==="."){var Q=z.slice(1);z=document.getElementsByClassName(Q)[0]}else{var ee;z.charAt(0)!=="#"?ee=z:ee=z.slice(1),z=document.getElementById(ee)}if(!z)throw"Can not find container in document with id "+ee}return this._setAttr("container",z),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),z.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var z=this.children,Q=z.length,ee;for(ee=0;ee<Q;ee++)z[ee].clear();return this}clone(z){return z||(z={}),z.container=typeof document<"u"&&document.createElement("div"),t.Container.prototype.clone.call(this,z)}destroy(){super.destroy();var z=this.content;z&&e.Util._isInDocument(z)&&this.container().removeChild(z);var Q=l.stages.indexOf(this);return Q>-1&&l.stages.splice(Q,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const z=this._pointerPositions[0]||this._changedPointerPositions[0];return z?{x:z.x,y:z.y}:(e.Util.warn(H),null)}_getPointerById(z){return this._pointerPositions.find(Q=>Q.id===z)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(z){z=z||{},z.x=z.x||0,z.y=z.y||0,z.width=z.width||this.width(),z.height=z.height||this.height();var Q=new o.SceneCanvas({width:z.width,height:z.height,pixelRatio:z.pixelRatio||1}),ee=Q.getContext()._context,le=this.children;return(z.x||z.y)&&ee.translate(-1*z.x,-1*z.y),le.forEach(function(ue){if(ue.isVisible()){var he=ue._toKonvaCanvas(z);ee.drawImage(he._canvas,z.x,z.y,he.getWidth()/he.getPixelRatio(),he.getHeight()/he.getPixelRatio())}}),Q}getIntersection(z){if(!z)return null;var Q=this.children,ee=Q.length,le=ee-1,ue;for(ue=le;ue>=0;ue--){const he=Q[ue].getIntersection(z);if(he)return he}return null}_resizeDOM(){var z=this.width(),Q=this.height();this.content&&(this.content.style.width=z+x,this.content.style.height=Q+x),this.bufferCanvas.setSize(z,Q),this.bufferHitCanvas.setSize(z,Q),this.children.forEach(ee=>{ee.setSize({width:z,height:Q}),ee.draw()})}add(z,...Q){if(arguments.length>1){for(var ee=0;ee<arguments.length;ee++)this.add(arguments[ee]);return this}super.add(z);var le=this.children.length;return le>Y&&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."),z.setSize({width:this.width(),height:this.height()}),z.draw(),a.Konva.isBrowser&&this.content.appendChild(z.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(z){return f.hasPointerCapture(z,this)}setPointerCapture(z){f.setPointerCapture(z,this)}releaseCapture(z){f.releaseCapture(z,this)}getLayers(){return this.children}_bindContentEvents(){a.Konva.isBrowser&&q.forEach(([z,Q])=>{this.content.addEventListener(z,ee=>{this[Q](ee)},{passive:!1})})}_pointerenter(z){this.setPointersPositions(z);const Q=fe(z.type);Q&&this._fire(Q.pointerenter,{evt:z,target:this,currentTarget:this})}_pointerover(z){this.setPointersPositions(z);const Q=fe(z.type);Q&&this._fire(Q.pointerover,{evt:z,target:this,currentTarget:this})}_getTargetShape(z){let Q=this[z+"targetShape"];return Q&&!Q.getStage()&&(Q=null),Q}_pointerleave(z){const Q=fe(z.type),ee=ce(z.type);if(Q){this.setPointersPositions(z);var le=this._getTargetShape(ee),ue=!d.DD.isDragging||a.Konva.hitOnDragEnabled;le&&ue?(le._fireAndBubble(Q.pointerout,{evt:z}),le._fireAndBubble(Q.pointerleave,{evt:z}),this._fire(Q.pointerleave,{evt:z,target:this,currentTarget:this}),this[ee+"targetShape"]=null):ue&&(this._fire(Q.pointerleave,{evt:z,target:this,currentTarget:this}),this._fire(Q.pointerout,{evt:z,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(z){const Q=fe(z.type),ee=ce(z.type);if(Q){this.setPointersPositions(z);var le=!1;this._changedPointerPositions.forEach(ue=>{var he=this.getIntersection(ue);if(d.DD.justDragged=!1,a.Konva["_"+ee+"ListenClick"]=!0,!he||!he.isListening())return;a.Konva.capturePointerEventsEnabled&&he.setPointerCapture(ue.id),this[ee+"ClickStartShape"]=he,he._fireAndBubble(Q.pointerdown,{evt:z,pointerId:ue.id}),le=!0;const ve=z.type.indexOf("touch")>=0;he.preventDefault()&&z.cancelable&&ve&&z.preventDefault()}),le||this._fire(Q.pointerdown,{evt:z,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(z){const Q=fe(z.type),ee=ce(z.type);if(!Q)return;d.DD.isDragging&&d.DD.node.preventDefault()&&z.cancelable&&z.preventDefault(),this.setPointersPositions(z);var le=!d.DD.isDragging||a.Konva.hitOnDragEnabled;if(!le)return;var ue={};let he=!1;var ve=this._getTargetShape(ee);this._changedPointerPositions.forEach(be=>{const Re=f.getCapturedShape(be.id)||this.getIntersection(be),Le=be.id,Oe={evt:z,pointerId:Le};var Ke=ve!==Re;if(Ke&&ve&&(ve._fireAndBubble(Q.pointerout,{...Oe},Re),ve._fireAndBubble(Q.pointerleave,{...Oe},Re)),Re){if(ue[Re._id])return;ue[Re._id]=!0}Re&&Re.isListening()?(he=!0,Ke&&(Re._fireAndBubble(Q.pointerover,{...Oe},ve),Re._fireAndBubble(Q.pointerenter,{...Oe},ve),this[ee+"targetShape"]=Re),Re._fireAndBubble(Q.pointermove,{...Oe})):ve&&(this._fire(Q.pointerover,{evt:z,target:this,currentTarget:this,pointerId:Le}),this[ee+"targetShape"]=null)}),he||this._fire(Q.pointermove,{evt:z,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(z){const Q=fe(z.type),ee=ce(z.type);if(!Q)return;this.setPointersPositions(z);const le=this[ee+"ClickStartShape"],ue=this[ee+"ClickEndShape"];var he={};let ve=!1;this._changedPointerPositions.forEach(be=>{const Re=f.getCapturedShape(be.id)||this.getIntersection(be);if(Re){if(Re.releaseCapture(be.id),he[Re._id])return;he[Re._id]=!0}const Le=be.id,Oe={evt:z,pointerId:Le};let Ke=!1;a.Konva["_"+ee+"InDblClickWindow"]?(Ke=!0,clearTimeout(this[ee+"DblTimeout"])):d.DD.justDragged||(a.Konva["_"+ee+"InDblClickWindow"]=!0,clearTimeout(this[ee+"DblTimeout"])),this[ee+"DblTimeout"]=setTimeout(function(){a.Konva["_"+ee+"InDblClickWindow"]=!1},a.Konva.dblClickWindow),Re&&Re.isListening()?(ve=!0,this[ee+"ClickEndShape"]=Re,Re._fireAndBubble(Q.pointerup,{...Oe}),a.Konva["_"+ee+"ListenClick"]&&le&&le===Re&&(Re._fireAndBubble(Q.pointerclick,{...Oe}),Ke&&ue&&ue===Re&&Re._fireAndBubble(Q.pointerdblclick,{...Oe}))):(this[ee+"ClickEndShape"]=null,a.Konva["_"+ee+"ListenClick"]&&this._fire(Q.pointerclick,{evt:z,target:this,currentTarget:this,pointerId:Le}),Ke&&this._fire(Q.pointerdblclick,{evt:z,target:this,currentTarget:this,pointerId:Le}))}),ve||this._fire(Q.pointerup,{evt:z,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a.Konva["_"+ee+"ListenClick"]=!1,z.cancelable&&ee!=="touch"&&z.preventDefault()}_contextmenu(z){this.setPointersPositions(z);var Q=this.getIntersection(this.getPointerPosition());Q&&Q.isListening()?Q._fireAndBubble(U,{evt:z}):this._fire(U,{evt:z,target:this,currentTarget:this})}_wheel(z){this.setPointersPositions(z);var Q=this.getIntersection(this.getPointerPosition());Q&&Q.isListening()?Q._fireAndBubble(ie,{evt:z}):this._fire(ie,{evt:z,target:this,currentTarget:this})}_pointercancel(z){this.setPointersPositions(z);const Q=f.getCapturedShape(z.pointerId)||this.getIntersection(this.getPointerPosition());Q&&Q._fireAndBubble(C,f.createEvent(z)),f.releaseCapture(z.pointerId)}_lostpointercapture(z){f.releaseCapture(z.pointerId)}setPointersPositions(z){var Q=this._getContentPosition(),ee=null,le=null;z=z||window.event,z.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(z.touches,ue=>{this._pointerPositions.push({id:ue.identifier,x:(ue.clientX-Q.left)/Q.scaleX,y:(ue.clientY-Q.top)/Q.scaleY})}),Array.prototype.forEach.call(z.changedTouches||z.touches,ue=>{this._changedPointerPositions.push({id:ue.identifier,x:(ue.clientX-Q.left)/Q.scaleX,y:(ue.clientY-Q.top)/Q.scaleY})})):(ee=(z.clientX-Q.left)/Q.scaleX,le=(z.clientY-Q.top)/Q.scaleY,this.pointerPos={x:ee,y:le},this._pointerPositions=[{x:ee,y:le,id:e.Util._getFirstPointerId(z)}],this._changedPointerPositions=[{x:ee,y:le,id:e.Util._getFirstPointerId(z)}])}_setPointerPosition(z){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(z)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var z=this.content.getBoundingClientRect();return{top:z.top,left:z.left,scaleX:z.width/this.content.clientWidth||1,scaleY:z.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 z=this.container();if(!z)throw"Stage has no container. A container is required.";z.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"),z.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(z){z.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",x="linearGradient",R="radialGradient";let S;function E(){return S||(S=n.Util.createCanvasElement().getContext("2d"),S)}l.shapes={};function g(k){const F=this.attrs.fillRule;F?k.fill(F):k.fill()}function v(k){k.stroke()}function T(k){k.fill()}function b(k){k.stroke()}function _(){this._clearCache(f)}function w(){this._clearCache(u)}function C(){this._clearCache(p)}function P(){this._clearCache(x)}function D(){this._clearCache(R)}class N 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=E();const M=F.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(M&&M.setTransform){const U=new n.Transform;U.translate(this.fillPatternX(),this.fillPatternY()),U.rotate(e.Konva.getAngle(this.fillPatternRotation())),U.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),U.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const $=U.getMatrix(),B=typeof DOMMatrix>"u"?{a:$[0],b:$[1],c:$[2],d:$[3],e:$[4],f:$[5]}:new DOMMatrix($);M.setTransform(B)}return M}}_getLinearGradient(){return this._getCache(x,this.__getLinearGradient)}__getLinearGradient(){var F=this.fillLinearGradientColorStops();if(F){for(var M=E(),U=this.fillLinearGradientStartPoint(),$=this.fillLinearGradientEndPoint(),B=M.createLinearGradient(U.x,U.y,$.x,$.y),J=0;J<F.length;J+=2)B.addColorStop(F[J],F[J+1]);return B}}_getRadialGradient(){return this._getCache(R,this.__getRadialGradient)}__getRadialGradient(){var F=this.fillRadialGradientColorStops();if(F){for(var M=E(),U=this.fillRadialGradientStartPoint(),$=this.fillRadialGradientEndPoint(),B=M.createRadialGradient(U.x,U.y,this.fillRadialGradientStartRadius(),$.x,$.y,this.fillRadialGradientEndRadius()),J=0;J<F.length;J+=2)B.addColorStop(F[J],F[J+1]);return B}}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 U=M.bufferHitCanvas;return U.getContext().clear(),this.drawHit(U,void 0,!0),U.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(),B=this.hasStroke(),J=this.getAbsoluteOpacity()!==1;if($&&B&&J)return!0;const ne=this.hasShadow(),ie=this.shadowForStrokeEnabled();return!!($&&B&&ne&&ie)}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,U=F.relativeTo,$=this.getSelfRect(),J=!F.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,ne=$.width+J,ie=$.height+J,Y=!F.skipShadow&&this.hasShadow(),q=Y?this.shadowOffsetX():0,re=Y?this.shadowOffsetY():0,ce=ne+Math.abs(q),fe=ie+Math.abs(re),te=Y&&this.shadowBlur()||0,H=ce+te*2,W=fe+te*2,V={width:H,height:W,x:-(J/2+te)+Math.min(q,0)+$.x,y:-(J/2+te)+Math.min(re,0)+$.y};return M?V:this._transformedRect(V,U)}drawScene(F,M){var U=this.getLayer(),$=F||U.getCanvas(),B=$.getContext(),J=this._getCanvasCache(),ne=this.getSceneFunc(),ie=this.hasShadow(),Y,q,re,ce=$.isCache,fe=M===this;if(!this.isVisible()&&!fe)return this;if(J){B.save();var te=this.getAbsoluteTransform(M).getMatrix();return B.transform(te[0],te[1],te[2],te[3],te[4],te[5]),this._drawCachedSceneCanvas(B),B.restore(),this}if(!ne)return this;if(B.save(),this._useBufferCanvas()&&!ce){Y=this.getStage(),q=Y.bufferCanvas,re=q.getContext(),re.clear(),re.save(),re._applyLineJoin(this);var H=this.getAbsoluteTransform(M).getMatrix();re.transform(H[0],H[1],H[2],H[3],H[4],H[5]),ne.call(this,re,this),re.restore();var W=q.pixelRatio;ie&&B._applyShadow(this),B._applyOpacity(this),B._applyGlobalCompositeOperation(this),B.drawImage(q._canvas,0,0,q.width/W,q.height/W)}else{if(B._applyLineJoin(this),!fe){var H=this.getAbsoluteTransform(M).getMatrix();B.transform(H[0],H[1],H[2],H[3],H[4],H[5]),B._applyOpacity(this),B._applyGlobalCompositeOperation(this)}ie&&B._applyShadow(this),ne.call(this,B,this)}return B.restore(),this}drawHit(F,M,U=!1){if(!this.shouldDrawHit(M,U))return this;var $=this.getLayer(),B=F||$.hitCanvas,J=B&&B.getContext(),ne=this.hitFunc()||this.sceneFunc(),ie=this._getCanvasCache(),Y=ie&&ie.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()"),Y){J.save();var q=this.getAbsoluteTransform(M).getMatrix();return J.transform(q[0],q[1],q[2],q[3],q[4],q[5]),this._drawCachedHitCanvas(J),J.restore(),this}if(!ne)return this;if(J.save(),J._applyLineJoin(this),!(this===M)){var ce=this.getAbsoluteTransform(M).getMatrix();J.transform(ce[0],ce[1],ce[2],ce[3],ce[4],ce[5])}return ne.call(this,J,this),J.restore(),this}drawHitFromCache(F=0){var M=this._getCanvasCache(),U=this._getCachedSceneCanvas(),$=M.hit,B=$.getContext(),J=$.getWidth(),ne=$.getHeight(),ie,Y,q,re,ce,fe;B.clear(),B.drawImage(U._canvas,0,0,J,ne);try{for(ie=B.getImageData(0,0,J,ne),Y=ie.data,q=Y.length,re=n.Util._hexToRgb(this.colorKey),ce=0;ce<q;ce+=4)fe=Y[ce+3],fe>F?(Y[ce]=re.r,Y[ce+1]=re.g,Y[ce+2]=re.b,Y[ce+3]=255):Y[ce+3]=0;B.putImageData(ie,0,0)}catch(te){n.Util.error("Unable to draw hit graph from cached scene canvas. "+te.message)}return this}hasPointerCapture(F){return h.hasPointerCapture(F,this)}setPointerCapture(F){h.setPointerCapture(F,this)}releaseCapture(F){h.releaseCapture(F,this)}}l.Shape=N,N.prototype._fillFunc=g,N.prototype._strokeFunc=v,N.prototype._fillFuncHit=T,N.prototype._strokeFuncHit=b,N.prototype._centroid=!1,N.prototype.nodeType="Shape",(0,d._registerNode)(N),N.prototype.eventListeners={},N.prototype.on.call(N.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",_),N.prototype.on.call(N.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",w),N.prototype.on.call(N.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",C),N.prototype.on.call(N.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",P),N.prototype.on.call(N.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",D),t.Factory.addGetterSetter(N,"stroke",void 0,(0,o.getStringOrGradientValidator)()),t.Factory.addGetterSetter(N,"strokeWidth",2,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillAfterStrokeEnabled",!1),t.Factory.addGetterSetter(N,"hitStrokeWidth","auto",(0,o.getNumberOrAutoValidator)()),t.Factory.addGetterSetter(N,"strokeHitEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(N,"perfectDrawEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(N,"shadowForStrokeEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(N,"lineJoin"),t.Factory.addGetterSetter(N,"lineCap"),t.Factory.addGetterSetter(N,"sceneFunc"),t.Factory.addGetterSetter(N,"hitFunc"),t.Factory.addGetterSetter(N,"dash"),t.Factory.addGetterSetter(N,"dashOffset",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"shadowColor",void 0,(0,o.getStringValidator)()),t.Factory.addGetterSetter(N,"shadowBlur",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"shadowOpacity",1,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(N,"shadowOffset",["x","y"]),t.Factory.addGetterSetter(N,"shadowOffsetX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"shadowOffsetY",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillPatternImage"),t.Factory.addGetterSetter(N,"fill",void 0,(0,o.getStringOrGradientValidator)()),t.Factory.addGetterSetter(N,"fillPatternX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillPatternY",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillLinearGradientColorStops"),t.Factory.addGetterSetter(N,"strokeLinearGradientColorStops"),t.Factory.addGetterSetter(N,"fillRadialGradientStartRadius",0),t.Factory.addGetterSetter(N,"fillRadialGradientEndRadius",0),t.Factory.addGetterSetter(N,"fillRadialGradientColorStops"),t.Factory.addGetterSetter(N,"fillPatternRepeat","repeat"),t.Factory.addGetterSetter(N,"fillEnabled",!0),t.Factory.addGetterSetter(N,"strokeEnabled",!0),t.Factory.addGetterSetter(N,"shadowEnabled",!0),t.Factory.addGetterSetter(N,"dashEnabled",!0),t.Factory.addGetterSetter(N,"strokeScaleEnabled",!0),t.Factory.addGetterSetter(N,"fillPriority","color"),t.Factory.addComponentsGetterSetter(N,"fillPatternOffset",["x","y"]),t.Factory.addGetterSetter(N,"fillPatternOffsetX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillPatternOffsetY",0,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(N,"fillPatternScale",["x","y"]),t.Factory.addGetterSetter(N,"fillPatternScaleX",1,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillPatternScaleY",1,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(N,"fillLinearGradientStartPoint",["x","y"]),t.Factory.addComponentsGetterSetter(N,"strokeLinearGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(N,"fillLinearGradientStartPointX",0),t.Factory.addGetterSetter(N,"strokeLinearGradientStartPointX",0),t.Factory.addGetterSetter(N,"fillLinearGradientStartPointY",0),t.Factory.addGetterSetter(N,"strokeLinearGradientStartPointY",0),t.Factory.addComponentsGetterSetter(N,"fillLinearGradientEndPoint",["x","y"]),t.Factory.addComponentsGetterSetter(N,"strokeLinearGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(N,"fillLinearGradientEndPointX",0),t.Factory.addGetterSetter(N,"strokeLinearGradientEndPointX",0),t.Factory.addGetterSetter(N,"fillLinearGradientEndPointY",0),t.Factory.addGetterSetter(N,"strokeLinearGradientEndPointY",0),t.Factory.addComponentsGetterSetter(N,"fillRadialGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(N,"fillRadialGradientStartPointX",0),t.Factory.addGetterSetter(N,"fillRadialGradientStartPointY",0),t.Factory.addComponentsGetterSetter(N,"fillRadialGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(N,"fillRadialGradientEndPointX",0),t.Factory.addGetterSetter(N,"fillRadialGradientEndPointY",0),t.Factory.addGetterSetter(N,"fillPatternRotation",0),t.Factory.addGetterSetter(N,"fillRule",void 0,(0,o.getStringValidator)()),t.Factory.backCompat(N,{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$2={};Object.defineProperty(Animation$2,"__esModule",{value:!0});Animation$2.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$1=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$2.Animation=Animation$1;Animation$1.animations=[];Animation$1.animIdCounter=0;Animation$1.animRunning=!1;var Tween$1={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Easings=l.Tween=void 0;const e=Util,n=Animation$2,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 x{constructor(E,g,v,T,b,_,w){this.prop=E,this.propFunc=g,this.begin=T,this._pos=T,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=v,this._change=b-this.begin,this.pause()}fire(E){var g=this[E];g&&g()}setTime(E){E>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():E<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=E,this.update())}getTime(){return this._time}setPosition(E){this.prevPos=this._pos,this.propFunc(E),this._pos=E}getPosition(E){return E===void 0&&(E=this._time),this.func(E,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(E){this.pause(),this._time=E,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 E=this.getTimer()-this._startTime;this.state===h?this.setTime(E):this.state===f&&this.setTime(this.duration-E)}pause(){this.state=d,this.fire("onPause")}getTimer(){return new Date().getTime()}}class R{constructor(E){var g=this,v=E.node,T=v._id,b,_=E.easing||l.Easings.Linear,w=!!E.yoyo,C;typeof E.duration>"u"?b=.3:E.duration===0?b=.001:b=E.duration,this.node=v,this._id=u++;var P=v.getLayer()||(v instanceof a.Konva.Stage?v.getLayers():null);P||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()},P),this.tween=new x(C,function(D){g._tweenFunc(D)},_,0,1,b*1e3,w),this._addListeners(),R.attrs[T]||(R.attrs[T]={}),R.attrs[T][this._id]||(R.attrs[T][this._id]={}),R.tweens[T]||(R.tweens[T]={});for(C in E)o[C]===void 0&&this._addAttr(C,E[C]);this.reset(),this.onFinish=E.onFinish,this.onReset=E.onReset,this.onUpdate=E.onUpdate}_addAttr(E,g){var v=this.node,T=v._id,b,_,w,C,P,D,N,k;if(w=R.tweens[T][E],w&&delete R.attrs[T][w][E],b=v.getAttr(E),e.Util._isArray(g))if(_=[],P=Math.max(g.length,b.length),E==="points"&&g.length!==b.length&&(g.length>b.length?(N=b,b=e.Util._prepareArrayForTween(b,g,v.closed())):(D=g,g=e.Util._prepareArrayForTween(g,b,v.closed()))),E.indexOf("fill")===0)for(C=0;C<P;C++)if(C%2===0)_.push(g[C]-b[C]);else{var F=e.Util.colorToRGBA(b[C]);k=e.Util.colorToRGBA(g[C]),b[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<P;C++)_.push(g[C]-b[C]);else p.indexOf(E)!==-1?(b=e.Util.colorToRGBA(b),k=e.Util.colorToRGBA(g),_={r:k.r-b.r,g:k.g-b.g,b:k.b-b.b,a:k.a-b.a}):_=g-b;R.attrs[T][this._id][E]={start:b,diff:_,end:g,trueEnd:D,trueStart:N},R.tweens[T][E]=this._id}_tweenFunc(E){var g=this.node,v=R.attrs[g._id][this._id],T,b,_,w,C,P,D,N;for(T in v){if(b=v[T],_=b.start,w=b.diff,N=b.end,e.Util._isArray(_))if(C=[],D=Math.max(_.length,N.length),T.indexOf("fill")===0)for(P=0;P<D;P++)P%2===0?C.push((_[P]||0)+w[P]*E):C.push("rgba("+Math.round(_[P].r+w[P].r*E)+","+Math.round(_[P].g+w[P].g*E)+","+Math.round(_[P].b+w[P].b*E)+","+(_[P].a+w[P].a*E)+")");else for(P=0;P<D;P++)C.push((_[P]||0)+w[P]*E);else p.indexOf(T)!==-1?C="rgba("+Math.round(_.r+w.r*E)+","+Math.round(_.g+w.g*E)+","+Math.round(_.b+w.b*E)+","+(_.a+w.a*E)+")":C=_+w*E;g.setAttr(T,C)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var E=this.node,g=R.attrs[E._id][this._id];g.points&&g.points.trueEnd&&E.setAttr("points",g.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var E=this.node,g=R.attrs[E._id][this._id];g.points&&g.points.trueStart&&E.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(E){return this.tween.seek(E*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var E=this.node._id,g=this._id,v=R.tweens[E],T;this.pause();for(T in v)delete R.tweens[E][T];delete R.attrs[E][g]}}l.Tween=R,R.attrs={},R.tweens={},t.Node.prototype.to=function(S){var E=S.onFinish;S.node=this,S.onFinish=function(){this.destroy(),E&&E()};var g=new R(S);g.play()},l.Easings={BackEaseIn(S,E,g,v){var T=1.70158;return g*(S/=v)*S*((T+1)*S-T)+E},BackEaseOut(S,E,g,v){var T=1.70158;return g*((S=S/v-1)*S*((T+1)*S+T)+1)+E},BackEaseInOut(S,E,g,v){var T=1.70158;return(S/=v/2)<1?g/2*(S*S*(((T*=1.525)+1)*S-T))+E:g/2*((S-=2)*S*(((T*=1.525)+1)*S+T)+2)+E},ElasticEaseIn(S,E,g,v,T,b){var _=0;return S===0?E:(S/=v)===1?E+g:(b||(b=v*.3),!T||T<Math.abs(g)?(T=g,_=b/4):_=b/(2*Math.PI)*Math.asin(g/T),-(T*Math.pow(2,10*(S-=1))*Math.sin((S*v-_)*(2*Math.PI)/b))+E)},ElasticEaseOut(S,E,g,v,T,b){var _=0;return S===0?E:(S/=v)===1?E+g:(b||(b=v*.3),!T||T<Math.abs(g)?(T=g,_=b/4):_=b/(2*Math.PI)*Math.asin(g/T),T*Math.pow(2,-10*S)*Math.sin((S*v-_)*(2*Math.PI)/b)+g+E)},ElasticEaseInOut(S,E,g,v,T,b){var _=0;return S===0?E:(S/=v/2)===2?E+g:(b||(b=v*(.3*1.5)),!T||T<Math.abs(g)?(T=g,_=b/4):_=b/(2*Math.PI)*Math.asin(g/T),S<1?-.5*(T*Math.pow(2,10*(S-=1))*Math.sin((S*v-_)*(2*Math.PI)/b))+E:T*Math.pow(2,-10*(S-=1))*Math.sin((S*v-_)*(2*Math.PI)/b)*.5+g+E)},BounceEaseOut(S,E,g,v){return(S/=v)<1/2.75?g*(7.5625*S*S)+E:S<2/2.75?g*(7.5625*(S-=1.5/2.75)*S+.75)+E:S<2.5/2.75?g*(7.5625*(S-=2.25/2.75)*S+.9375)+E:g*(7.5625*(S-=2.625/2.75)*S+.984375)+E},BounceEaseIn(S,E,g,v){return g-l.Easings.BounceEaseOut(v-S,0,g,v)+E},BounceEaseInOut(S,E,g,v){return S<v/2?l.Easings.BounceEaseIn(S*2,0,g,v)*.5+E:l.Easings.BounceEaseOut(S*2-v,0,g,v)*.5+g*.5+E},EaseIn(S,E,g,v){return g*(S/=v)*S+E},EaseOut(S,E,g,v){return-g*(S/=v)*(S-2)+E},EaseInOut(S,E,g,v){return(S/=v/2)<1?g/2*S*S+E:-g/2*(--S*(S-2)-1)+E},StrongEaseIn(S,E,g,v){return g*(S/=v)*S*S*S*S+E},StrongEaseOut(S,E,g,v){return g*((S=S/v-1)*S*S*S*S+1)+E},StrongEaseInOut(S,E,g,v){return(S/=v/2)<1?g/2*S*S*S*S*S+E:g/2*((S-=2)*S*S*S*S+2)+E},Linear(S,E,g,v){return g*S/v+E}}})(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,x=Animation$2,R=Tween$1,S=Context$2,E=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:x.Animation,Tween:R.Tween,Easings:R.Easings,Context:S.Context,Canvas:E.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,x=h*(h>0?e:n),R=f*(f>0?n:e);return{x:u,y:t?-1*R:x,width:p-u,height:R-x}}}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),x=n-u*(a-l),R=t-u*(o-e),S=n+p*(a-l),E=t+p*(o-e);return[x,R,S,E]}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,x;u=f/2,p=0;for(let S=0;S<20;S++)x=u*l.tValues[20][S]+u,p+=l.cValues[20][S]*t(d,h,x);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],x=2*d[1]-2*d[0],R=2*h[1]-2*h[0],S=4*(u*u+p*p),E=4*(u*x+p*R),g=x*x+R*R;if(S===0)return f*Math.sqrt(Math.pow(d[2]-d[0],2)+Math.pow(h[2]-h[0],2));const v=E/(2*S),T=g/S,b=f+v,_=T-v*v,w=b*b+_>0?Math.sqrt(b*b+_):0,C=v*v+_>0?Math.sqrt(v*v+_):0,P=v+Math.sqrt(v*v+_)!==0?_*Math.log(Math.abs((b+w)/(v+C))):0;return Math.sqrt(S)/2*(b*w-v*C+P)};l.getQuadraticArcLength=n;function t(d,h,f){const u=a(1,f,d),p=a(1,f,h),x=u*u+p*p;return Math.sqrt(x)}const a=(d,h,f)=>{const u=f.length-1;let p,x;if(u===0)return 0;if(d===0){x=0;for(let R=0;R<=u;R++)x+=l.binomialCoefficients[u][R]*Math.pow(1-h,u-R)*Math.pow(h,R)*f[R];return x}else{p=new Array(u);for(let R=0;R<u;R++)p[R]=u*(f[R+1]-f[R]);return a(d-1,h,p)}},o=(d,h,f)=>{let u=1,p=d/h,x=(d-f(p))/h,R=0;for(;u>.001;){const S=f(p+x),E=Math.abs(d-S)/h;if(E<u)u=E,p+=x;else{const g=f(p-x),v=Math.abs(d-g)/h;v<u?(u=v,p-=x):x/=2}if(R++,R>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],x=d[4],R=d[5],S=d[6],E=d[7],g=u>p?u:p,v=u>p?1:u/p,T=u>p?p/u:1;e.translate(h,f),e.rotate(S),e.scale(v,T),e.arc(0,0,g,x,x+R,1-E),e.scale(1/v,1/T),e.rotate(-S),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],x=u.points[5],R=u.points[4]+x,S=Math.PI/180;if(Math.abs(p-R)<S&&(S=Math.abs(p-R)),x<0)for(let E=p-S;E>R;E-=S){const g=Path.getPointOnEllipticalArc(u.points[0],u.points[1],u.points[2],u.points[3],E,0);e.push(g.x,g.y)}else for(let E=p+S;E<R;E+=S){const g=Path.getPointOnEllipticalArc(u.points[0],u.points[1],u.points[2],u.points[3],E,0);e.push(g.x,g.y)}}else if(u.command==="C")for(let E=0;E<=1;E+=.01){const g=Path.getPointOnCubicBezier(E,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],x=h[3],R=h[4],S=h[5],E=h[6];return R+=S*e/d.pathLength,Path.getPointOnEllipticalArc(f,u,p,x,R,E)}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,x;if(a===n)x={x:d,y:h+p};else if((h-t)/(d-n+1e-8)===f)x={x:d+u,y:h+p};else{var R,S,E=this.getLineLength(n,t,a,o),g=(d-n)*(a-n)+(h-t)*(o-t);g=g/(E*E),R=n+g*(a-n),S=t+g*(o-t);var v=this.getLineLength(d,h,R,S),T=Math.sqrt(e*e-v*v);u=Math.sqrt(T*T/(1+f*f)),a<n&&(u*=-1),p=f*u,x={x:R+u,y:S+p}}return x}static getPointOnCubicBezier(e,n,t,a,o,d,h,f,u){function p(v){return v*v*v}function x(v){return 3*v*v*(1-v)}function R(v){return 3*v*(1-v)*(1-v)}function S(v){return(1-v)*(1-v)*(1-v)}var E=f*p(e)+d*x(e)+a*R(e)+n*S(e),g=u*p(e)+h*x(e)+o*R(e)+t*S(e);return{x:E,y:g}}static getPointOnQuadraticBezier(e,n,t,a,o,d,h){function f(S){return S*S}function u(S){return 2*S*(1-S)}function p(S){return(1-S)*(1-S)}var x=d*f(e)+a*u(e)+n*p(e),R=h*f(e)+o*u(e)+t*p(e);return{x,y:R}}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,x;for(a=1;a<o.length;a++){var R=o[a],S=R.charAt(0);for(R=R.slice(1),h.length=0;x=p.exec(R);)h.push(x[0]);for(var E=[],g=0,v=h.length;g<v;g++){if(h[g]==="00"){E.push(0,0);continue}var T=parseFloat(h[g]);isNaN(T)?E.push(0):E.push(T)}for(;E.length>0&&!isNaN(E[0]);){var b="",_=[],w=f,C=u,P,D,N,k,F,M,U,$,B,J;switch(S){case"l":f+=E.shift(),u+=E.shift(),b="L",_.push(f,u);break;case"L":f=E.shift(),u=E.shift(),_.push(f,u);break;case"m":var ne=E.shift(),ie=E.shift();if(f+=ne,u+=ie,b="M",d.length>2&&d[d.length-1].command==="z"){for(var Y=d.length-2;Y>=0;Y--)if(d[Y].command==="M"){f=d[Y].points[0]+ne,u=d[Y].points[1]+ie;break}}_.push(f,u),S="l";break;case"M":f=E.shift(),u=E.shift(),b="M",_.push(f,u),S="L";break;case"h":f+=E.shift(),b="L",_.push(f,u);break;case"H":f=E.shift(),b="L",_.push(f,u);break;case"v":u+=E.shift(),b="L",_.push(f,u);break;case"V":u=E.shift(),b="L",_.push(f,u);break;case"C":_.push(E.shift(),E.shift(),E.shift(),E.shift()),f=E.shift(),u=E.shift(),_.push(f,u);break;case"c":_.push(f+E.shift(),u+E.shift(),f+E.shift(),u+E.shift()),f+=E.shift(),u+=E.shift(),b="C",_.push(f,u);break;case"S":D=f,N=u,P=d[d.length-1],P.command==="C"&&(D=f+(f-P.points[2]),N=u+(u-P.points[3])),_.push(D,N,E.shift(),E.shift()),f=E.shift(),u=E.shift(),b="C",_.push(f,u);break;case"s":D=f,N=u,P=d[d.length-1],P.command==="C"&&(D=f+(f-P.points[2]),N=u+(u-P.points[3])),_.push(D,N,f+E.shift(),u+E.shift()),f+=E.shift(),u+=E.shift(),b="C",_.push(f,u);break;case"Q":_.push(E.shift(),E.shift()),f=E.shift(),u=E.shift(),_.push(f,u);break;case"q":_.push(f+E.shift(),u+E.shift()),f+=E.shift(),u+=E.shift(),b="Q",_.push(f,u);break;case"T":D=f,N=u,P=d[d.length-1],P.command==="Q"&&(D=f+(f-P.points[0]),N=u+(u-P.points[1])),f=E.shift(),u=E.shift(),b="Q",_.push(D,N,f,u);break;case"t":D=f,N=u,P=d[d.length-1],P.command==="Q"&&(D=f+(f-P.points[0]),N=u+(u-P.points[1])),f+=E.shift(),u+=E.shift(),b="Q",_.push(D,N,f,u);break;case"A":k=E.shift(),F=E.shift(),M=E.shift(),U=E.shift(),$=E.shift(),B=f,J=u,f=E.shift(),u=E.shift(),b="A",_=this.convertEndpointToCenterParameterization(B,J,f,u,U,$,k,F,M);break;case"a":k=E.shift(),F=E.shift(),M=E.shift(),U=E.shift(),$=E.shift(),B=f,J=u,f+=E.shift(),u+=E.shift(),b="A",_=this.convertEndpointToCenterParameterization(B,J,f,u,U,$,k,F,M);break}d.push({command:b||S,points:_,start:{x:w,y:C},pathLength:this.calcLength(w,C,b||S,_)})}(S==="z"||S==="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],x=a[5],R=a[4]+x,S=Math.PI/180;if(Math.abs(p-R)<S&&(S=Math.abs(p-R)),d=u.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],p,0),x<0)for(f=p-S;f>R;f-=S)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+S;f<R;f+=S)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],R,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),x=Math.cos(p)*(e-t)/2+Math.sin(p)*(n-a)/2,R=-1*Math.sin(p)*(e-t)/2+Math.cos(p)*(n-a)/2,S=x*x/(h*h)+R*R/(f*f);S>1&&(h*=Math.sqrt(S),f*=Math.sqrt(S));var E=Math.sqrt((h*h*(f*f)-h*h*(R*R)-f*f*(x*x))/(h*h*(R*R)+f*f*(x*x)));o===d&&(E*=-1),isNaN(E)&&(E=0);var g=E*h*R/f,v=E*-f*x/h,T=(e+t)/2+Math.cos(p)*g-Math.sin(p)*v,b=(n+a)/2+Math.sin(p)*g+Math.cos(p)*v,_=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))},P=C([1,0],[(x-g)/h,(R-v)/f]),D=[(x-g)/h,(R-v)/f],N=[(-1*x-g)/h,(-1*R-v)/f],k=C(D,N);return w(D,N)<=-1&&(k=Math.PI),w(D,N)>=1&&(k=0),d===0&&k>0&&(k=k-2*Math.PI),d===1&&k<0&&(k=k+2*Math.PI),[T,b,h,f,P,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 R=[a[a.length-4],a[a.length-3],a[a.length-2],a[a.length-1],t[h-2],t[h-1]],S=Path_1$2.Path.calcLength(a[a.length-4],a[a.length-3],"C",R),E=Path_1$2.Path.getPointOnQuadraticBezier(Math.min(1,1-d/S),R[0],R[1],R[2],R[3],R[4],R[5]);f=t[h-2]-E.x,u=t[h-1]-E.y}else f=t[h-2]-t[h-4],u=t[h-1]-t[h-3];var p=(Math.atan2(u,f)+n)%n,x=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,x/2),e.lineTo(-d,-x/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,x/2),e.lineTo(-d,-x/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,x=0;typeof h=="number"?f=u=p=x=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),x=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-x),e.arc(n-x,t-x,x,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$2,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],x=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,u,p),e.closePath(),e.fillStrokeShape(this)),x)if(d){var R=d[n],S=t*2;e.drawImage(x,h,f,u,p,R[S+0],R[S+1],u,p)}else e.drawImage(x,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(),x=this.getWidth(),R=this.letterSpacing(),S=this.fill(),E=this.textDecoration(),g=E.indexOf("underline")!==-1,v=E.indexOf("line-through")!==-1,T;f=f===INHERIT?e.direction:f;var b=0,b=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),T=0;T<t;T++){var _=0,w=0,C=n[T],P=C.text,D=C.width,N=C.lastInParagraph,k,F,M;if(e.save(),p===RIGHT?_+=x-D-a*2:p===CENTER&&(_+=(x-D-a*2)/2),g){e.save(),e.beginPath(),e.moveTo(_,b+w+Math.round(o/2)),k=P.split(" ").length-1,F=k===0,M=p===JUSTIFY&&!N?x-a*2:D,e.lineTo(_+Math.round(M),b+w+Math.round(o/2)),e.lineWidth=o/15;const ie=this._getLinearGradient();e.strokeStyle=ie||S,e.stroke(),e.restore()}if(v){e.save(),e.beginPath(),e.moveTo(_,b+w),k=P.split(" ").length-1,F=k===0,M=p===JUSTIFY&&N&&!F?x-a*2:D,e.lineTo(_+Math.round(M),b+w),e.lineWidth=o/15;const ie=this._getLinearGradient();e.strokeStyle=ie||S,e.stroke(),e.restore()}if(f!==RTL&&(R!==0||p===JUSTIFY)){k=P.split(" ").length-1;for(var U=stringToArray(P),$=0;$<U.length;$++){var B=U[$];B===" "&&!N&&p===JUSTIFY&&(_+=(x-a*2-D)/k),this._partialTextX=_,this._partialTextY=b+w,this._partialText=B,e.fillStrokeShape(this),_+=this.measureSize(B).width+R}}else R!==0&&e.setAttr("letterSpacing",`${R}px`),this._partialTextX=_,this._partialTextY=b+w,this._partialText=P,e.fillStrokeShape(this);e.restore(),t>1&&(b+=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(`
71
+ ${S&&_+1>=l.length?"glowing-animation":""}`,"data-testid":"btn-nxt",onClick:()=>{_+1<l.length?U():(D("click-ui"),k())},"aria-label":LangIsRtl()?p("comic.previous"):p("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,soundActions:d,audioVolume:h,pause:f,keyboardControl:u,backgroundImageCover:p=!1,autoEnd:x=!1}){const[R,S]=React$2.useState(!1),E=k=>o({type:"translate",payload:k}),g=(l==null?void 0:l.url)||"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg",v=React$2.useRef(),T=React$2.useRef(),[b]=d,{start:_,stop:w}=useTimeout();useEkho({audioType:t,voice:a,text:e,audio:n,soundActions:d,emitEvent:o,volume:h,pauseTTS:f,onError:()=>{S(!0)},onFinish:()=>{x&&C()}});const C=React$2.useCallback(()=>{b("click-ui"),o({type:"success"})},[o,b]),P=u({repeat:!1,forward:C,escape:C});React$2.useEffect(()=>P(),[P]);const D=(k,F)=>window.matchMedia("(min-width: 1280px)").matches?F:k,N=React$2.useCallback(()=>{if(p!==!0&&e&&T.current){const k=T.current.naturalWidth/T.current.naturalHeight;let F=T.current.height*k,M=T.current.height;if(F>T.current.width&&(F=T.current.width,M=T.current.width/k),v.current.style.width=`${F}px`,window.innerHeight<T.current.width)v.current.style.bottom=`${D(24,48)+D(36,100)}px`;else{const U=(window.innerHeight-M)/2+D(36,100);v.current.style.bottom=`${U}px`}}},[p,e]);return React$2.useEffect(()=>{T.current&&new ResizeObserver(()=>{D(24,48),N()}).observe(T.current)},[N]),React$2.useEffect(()=>{if(x&&!f&&(!n||R)){const k=characterMs$1*(e.length||0);_(()=>{C()},k<2400?2400:k)}return()=>{w()}},[n,R,x,C,f,_,w,e]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:`cartel ${p?"cartel--cover":""}`,children:jsxRuntimeExports.jsxs("div",{className:"cartel__imagewrap",children:[jsxRuntimeExports.jsx("img",{ref:T,onLoad:N,className:"cartel__image",src:g,alt:"cartel pic"}),e?jsxRuntimeExports.jsx("div",{ref:v,className:"cartel__textwrap",children:jsxRuntimeExports.jsx("div",{className:"cartel__text",children:jsxRuntimeExports.jsx("span",{children:e})})}):null]})}),jsxRuntimeExports.jsx("div",{className:"position--absolute center right",children:jsxRuntimeExports.jsx("button",{"data-testid":"cartel-close-button",type:"button",className:"gat--btn__round",onClick:()=>C(),"aria-label":E("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 U in M)Object.prototype.hasOwnProperty.call(M,U)&&(k[U]=M[U])}return k},o=function(){function k(F,M){for(var U=0;U<M.length;U++){var $=M[U];$.enumerable=$.enumerable||!1,$.configurable=!0,"value"in $&&($.writable=!0),Object.defineProperty(F,$.key,$)}}return function(F,M,U){return M&&k(F.prototype,M),U&&k(F,U),F}}(),d=t(1),h=_(d),f=t(2),u=_(f),p=t(10),x=_(p),R=t(12),S=_(R),E=t(13),g=_(E),v=t(14),T=b(v);function b(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 P(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 D=["🔙","⏰"],N=function(k){P(F,k);function F(M){w(this,F);var U=C(this,(F.__proto__||Object.getPrototypeOf(F)).call(this,M));return U.state={textLines:[],isDone:!1},U.onTypingDone=function(){U.mounted&&(U.setState({isDone:!0}),U.props.onTypingDone())},U.delayGenerator=function($,B,J,ne){var ie=U.props.avgTypingDelay,Y=U.props.stdTypingDelay;return U.props.delayGenerator(ie,Y,{line:$,lineIdx:B,character:J,charIdx:ne,defDelayGenerator:function(){var re=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ie,ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Y;return T.gaussianRnd(re,ce)}})},U.typeLine=function($,B){if(!U.mounted)return Promise.resolve();var J=$,ne=U.props.onLineTyped;return T.isBackspaceElement($)?($.props.delay>0&&(U.introducedDelay=$.props.delay),J="🔙".repeat($.props.count)):T.isDelayElement($)&&(U.introducedDelay=$.props.ms,J="⏰"),new Promise(function(ie,Y){U.setState({textLines:U.state.textLines.concat([""])},function(){T.eachPromise(J,U.typeCharacter,J,B).then(function(){return ne(J,B)}).then(ie).catch(Y)})})},U.typeCharacter=function($,B,J,ne){if(!U.mounted)return Promise.resolve();var ie=U.props.onCharacterTyped;return new Promise(function(Y){var q=U.state.textLines.slice();T.sleep(U.introducedDelay).then(function(){U.introducedDelay=null;var re=$==="🔙",ce=$==="⏰";if(ce){Y();return}if(re&&ne>0){for(var fe=ne-1,te=q[fe],H=fe;H>=0&&!(te.length>0&&!D.includes(te[0]));H--)fe=H,te=q[fe];q[fe]=te.substr(0,te.length-1)}else q[ne]+=$;U.setState({textLines:q},function(){var W=U.delayGenerator(J,ne,$,B);ie($,B),setTimeout(Y,W)})})})},U.mounted=!1,U.linesToType=[],U.introducedDelay=null,M.children&&(U.linesToType=T.extractTextFromElement(M.children)),U}return o(F,[{key:"componentDidMount",value:function(){this.mounted=!0;var U=this.props,$=U.children,B=U.startDelay;$?B>0&&typeof window<"u"?setTimeout(this.typeAllLines.bind(this),B):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(U,$){if($.textLines.length!==this.state.textLines.length)return!0;for(var B=0;B<$.textLines.length;B++){var J=this.state.textLines[B],ne=$.textLines[B];if(J!==ne)return!0}return this.state.isDone!==$.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var U=this,$=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.linesToType;return T.eachPromise($,this.typeLine).then(function(){return U.onTypingDone()})}},{key:"render",value:function(){var U=this.props,$=U.className,B=U.cursor,J=this.state.isDone,ne=T.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return h.default.createElement("div",{className:"Typist "+$},ne,h.default.createElement(x.default,a({isDone:J},B)))}}]),F}(d.Component);N.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},N.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:T.gaussianRnd},n.default=N,N.Backspace=S.default,N.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 x=typeof Symbol=="function"&&Symbol.iterator,R="@@iterator";function S(q){var re=q&&(x&&q[x]||q[R]);if(typeof re=="function")return re}var E="<<anonymous>>",g={array:_("array"),bool:_("boolean"),func:_("function"),number:_("number"),object:_("object"),string:_("string"),symbol:_("symbol"),any:w(),arrayOf:C,element:P(),instanceOf:D,node:M(),objectOf:k,oneOf:N,oneOfType:F,shape:U};function v(q,re){return q===re?q!==0||1/q===1/re:q!==q&&re!==re}function T(q){this.message=q,this.stack=""}T.prototype=Error.prototype;function b(q){if(process.env.NODE_ENV!=="production")var re={},ce=0;function fe(H,W,V,z,Q,ee,le){if(z=z||E,ee=ee||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 ue=z+":"+V;!re[ue]&&ce<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.",ee,z),re[ue]=!0,ce++)}}return W[V]==null?H?W[V]===null?new T("The "+Q+" `"+ee+"` is marked as required "+("in `"+z+"`, but its value is `null`.")):new T("The "+Q+" `"+ee+"` is marked as required in "+("`"+z+"`, but its value is `undefined`.")):null:q(W,V,z,Q,ee)}var te=fe.bind(null,!1);return te.isRequired=fe.bind(null,!0),te}function _(q){function re(ce,fe,te,H,W,V){var z=ce[fe],Q=J(z);if(Q!==q){var ee=ne(z);return new T("Invalid "+H+" `"+W+"` of type "+("`"+ee+"` supplied to `"+te+"`, expected ")+("`"+q+"`."))}return null}return b(re)}function w(){return b(a.thatReturnsNull)}function C(q){function re(ce,fe,te,H,W){if(typeof q!="function")return new T("Property `"+W+"` of component `"+te+"` has invalid PropType notation inside arrayOf.");var V=ce[fe];if(!Array.isArray(V)){var z=J(V);return new T("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+te+"`, expected an array."))}for(var Q=0;Q<V.length;Q++){var ee=q(V,Q,te,H,W+"["+Q+"]",h);if(ee instanceof Error)return ee}return null}return b(re)}function P(){function q(re,ce,fe,te,H){var W=re[ce];if(!u(W)){var V=J(W);return new T("Invalid "+te+" `"+H+"` of type "+("`"+V+"` supplied to `"+fe+"`, expected a single ReactElement."))}return null}return b(q)}function D(q){function re(ce,fe,te,H,W){if(!(ce[fe]instanceof q)){var V=q.name||E,z=Y(ce[fe]);return new T("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+te+"`, expected ")+("instance of `"+V+"`."))}return null}return b(re)}function N(q){if(!Array.isArray(q))return process.env.NODE_ENV!=="production"&&d(!1,"Invalid argument supplied to oneOf, expected an instance of array."),a.thatReturnsNull;function re(ce,fe,te,H,W){for(var V=ce[fe],z=0;z<q.length;z++)if(v(V,q[z]))return null;var Q=JSON.stringify(q);return new T("Invalid "+H+" `"+W+"` of value `"+V+"` "+("supplied to `"+te+"`, expected one of "+Q+"."))}return b(re)}function k(q){function re(ce,fe,te,H,W){if(typeof q!="function")return new T("Property `"+W+"` of component `"+te+"` has invalid PropType notation inside objectOf.");var V=ce[fe],z=J(V);if(z!=="object")return new T("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+te+"`, expected an object."));for(var Q in V)if(V.hasOwnProperty(Q)){var ee=q(V,Q,te,H,W+"."+Q,h);if(ee instanceof Error)return ee}return null}return b(re)}function F(q){if(!Array.isArray(q))return process.env.NODE_ENV!=="production"&&d(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),a.thatReturnsNull;for(var re=0;re<q.length;re++){var ce=q[re];if(typeof ce!="function")return d(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",ie(ce),re),a.thatReturnsNull}function fe(te,H,W,V,z){for(var Q=0;Q<q.length;Q++){var ee=q[Q];if(ee(te,H,W,V,z,h)==null)return null}return new T("Invalid "+V+" `"+z+"` supplied to "+("`"+W+"`."))}return b(fe)}function M(){function q(re,ce,fe,te,H){return $(re[ce])?null:new T("Invalid "+te+" `"+H+"` supplied to "+("`"+fe+"`, expected a ReactNode."))}return b(q)}function U(q){function re(ce,fe,te,H,W){var V=ce[fe],z=J(V);if(z!=="object")return new T("Invalid "+H+" `"+W+"` of type `"+z+"` "+("supplied to `"+te+"`, expected `object`."));for(var Q in q){var ee=q[Q];if(ee){var le=ee(V,Q,te,H,W+"."+Q,h);if(le)return le}}return null}return b(re)}function $(q){switch(typeof q){case"number":case"string":case"undefined":return!0;case"boolean":return!q;case"object":if(Array.isArray(q))return q.every($);if(q===null||u(q))return!0;var re=S(q);if(re){var ce=re.call(q),fe;if(re!==q.entries){for(;!(fe=ce.next()).done;)if(!$(fe.value))return!1}else for(;!(fe=ce.next()).done;){var te=fe.value;if(te&&!$(te[1]))return!1}}else return!1;return!0;default:return!1}}function B(q,re){return q==="symbol"||re["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&re instanceof Symbol}function J(q){var re=typeof q;return Array.isArray(q)?"array":q instanceof RegExp?"object":B(re,q)?"symbol":re}function ne(q){if(typeof q>"u"||q===null)return""+q;var re=J(q);if(re==="object"){if(q instanceof Date)return"date";if(q instanceof RegExp)return"regexp"}return re}function ie(q){var re=ne(q);switch(re){case"array":case"object":return"an "+re;case"boolean":case"date":case"regexp":return"a "+re;default:return re}}function Y(q){return!q.constructor||!q.constructor.name?E:q.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,x,R){if(t(d),!o){var S;if(d===void 0)S=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var E=[h,f,u,p,x,R],g=0;S=new Error(d.replace(/%s/g,function(){return E[g++]})),S.name="Invariant Violation"}throw S.framesToPop=1,S}}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),x=1;x<u;x++)p[x-1]=arguments[x];var R=0,S="Warning: "+f.replace(/%s/g,function(){return p[R++]});typeof console<"u"&&console.error(S);try{throw new Error(S)}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,x=Array(p>2?p-2:0),R=2;R<p;R++)x[R-2]=arguments[R];d.apply(void 0,[u].concat(x))}}}(),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,x,R,S){if(process.env.NODE_ENV!=="production"){for(var E in u)if(u.hasOwnProperty(E)){var g;try{a(typeof u[E]=="function","%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",R||"React class",x,E),g=u[E](p,E,R,x,null,d)}catch(T){g=T}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).",R||"React class",x,E,typeof g),g instanceof Error&&!(g.message in h)){h[g.message]=!0;var v=S?S():"";o(!1,"Failed %s type: %s%s",x,g.message,v??"")}}}}e.exports=f},function(e,n,t){var a=t(4),o=t(5),d=t(7);e.exports=function(){function h(p,x,R,S,E,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 E(g,v){for(var T=0;T<v.length;T++){var b=v[T];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}return function(g,v,T){return v&&E(g.prototype,v),T&&E(g,T),g}}(),o=t(1),d=u(o),h=t(2),f=u(h);t(11);function u(E){return E&&E.__esModule?E:{default:E}}function p(E,g){if(!(E instanceof g))throw new TypeError("Cannot call a class as a function")}function x(E,g){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:E}function R(E,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);E.prototype=Object.create(g&&g.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(E,g):E.__proto__=g)}var S=function(E){R(g,E);function g(v){p(this,g);var T=x(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,v));return T._isReRenderingCursor=!1,T.state={shouldRender:T.props.show},T}return a(g,[{key:"componentWillReceiveProps",value:function(T){var b=this,_=!this.props.isDone&&T.isDone&&this.props.hideWhenDone;_&&setTimeout(function(){return b.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var T=this.props,b=T.show,_=T.isDone;b&&(_||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var T=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){T.setState({shouldRender:!0},function(){T._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var T=this.props.blink?" Cursor--blinking":"";return d.default.createElement("span",{className:"Cursor"+T},this.props.element)}return null}}]),g}(o.Component);S.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},S.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},n.default=S},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 b(_,w){var C=[],P=!0,D=!1,N=void 0;try{for(var k=_[Symbol.iterator](),F;!(P=(F=k.next()).done)&&(C.push(F.value),!(w&&C.length===w));P=!0);}catch(M){D=!0,N=M}finally{try{!P&&k.return&&k.return()}finally{if(D)throw N}}return C}return function(_,w){if(Array.isArray(_))return _;if(Symbol.iterator in Object(_))return b(_,w);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.gaussianRnd=u,n.eachPromise=p,n.exclude=x,n.isBackspaceElement=R,n.isDelayElement=S,n.extractTextFromElement=E,n.cloneElement=g,n.cloneElementWithSpecifiedText=T;var o=t(1),d=h(o);function h(b){return b&&b.__esModule?b:{default:b}}function f(b){if(Array.isArray(b)){for(var _=0,w=Array(b.length);_<b.length;_++)w[_]=b[_];return w}else return Array.from(b)}n.sleep=function(_){return new Promise(function(w){return _!=null?setTimeout(w,_):w()})};function u(b,_){for(var w=12,C=0,P=0;P<w;P++)C+=Math.random();return C-=w/2,Math.round(C*_)+b}function p(b,_){for(var w=arguments.length,C=Array(w>2?w-2:0),P=2;P<w;P++)C[P-2]=arguments[P];var D=function(k,F,M){return k.then(function(){return _.apply(void 0,[F,M].concat(C))})};return Array.from(b).reduce(D,Promise.resolve())}function x(b,_){var w={};for(var C in b)_.indexOf(C)===-1&&(w[C]=b[C]);return w}function R(b){return b&&b.type&&b.type.componentName==="Backspace"}function S(b){return b&&b.type&&b.type.componentName==="Delay"}function E(b){for(var _=b?[b]:[],w=[];_.length>0;){var C=_.pop();if(d.default.isValidElement(C))R(C)||S(C)?w.unshift(C):d.default.Children.forEach(C.props.children,function(U){_.push(U)});else if(Array.isArray(C)){var P=!0,D=!1,N=void 0;try{for(var k=C[Symbol.iterator](),F;!(P=(F=k.next()).done);P=!0){var M=F.value;_.push(M)}}catch(U){D=!0,N=U}finally{try{!P&&k.return&&k.return()}finally{if(D)throw N}}}else w.unshift(C)}return w}function g(b,_){var w=b.type,C=x(b.props,["children"]),P=new Date().getUTCMilliseconds(),D=P+Math.random()+Math.random();return C.key="Typist-element-"+w+"-"+D,d.default.createElement.apply(d.default,[w,C].concat(f(_)))}function v(b,_,w){if(w>=_.length)return[null,w];var C=w,P=function(M){var U=v(M,_,C),$=a(U,2),B=$[0],J=$[1];return C=J,B},D=d.default.isValidElement(b)&&!(R(b)||S(b));if(D){var N=d.default.Children.map(b.props.children,P)||[];return[g(b,N),C]}if(Array.isArray(b)){var k=b.map(P);return[k,C]}return[_[C],C+1]}function T(b){var _=b.element,w=b.textLines;if(_)return v(_,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,soundActions:e,info:n,themeNumber:t,type:a,writingSpeed:o,disableExit:d,setResolveAction:h}){const f=B=>l({type:"translate",payload:B}),[u]=e,{solution:p}=n,R=themes[`theme${t||1}`],[S,E]=React$2.useState(""),[g,v]=React$2.useState(0),[T,b]=React$2.useState(0),[_,w]=React$2.useState(!1),[C,P]=React$2.useState({start:0,end:0}),D=React$2.useRef(),N=React$2.useRef(),k=f("puzzle.hacker.congratulations"),F=(B,J)=>B>J.length?J.length:B,M=()=>{u("click-ui");const{rewards:B}=p.right;l({type:"addPoints",complex:!0,finish:!0,payload:B}),l({type:"passPuzzle"})};React$2.useEffect(()=>{D.current.focus(),_&&d(!0)},[_]),React$2.useEffect(()=>{h(B=>{u("score"),w(!0),l({type:"hidePuzzleButtons",payload:!1}),B()})},[h]);const U=()=>{if(languages[a]&&!_){N.current&&(N.current.scrollTop=D.current.scrollHeight);const B=languages[a],J=B[g],ne=B.reduce((Y,q)=>(Y.length?Y.length:Y)+q.length),ie=o>0?o:Math.floor(ne/50)+g;if(J){const Y=J.split(""),q=F(C.end,Y),re=Y.slice(C.start,q),ce=S+re.join("");b(T+re.join("").length),E(ce),q===Y.length?g+1>=B.length?(u("score"),w(!0)):(v(g+1),E(`${S+re.join("")}<br>`),P({start:0,end:F(ie,Y)})):P({start:q,end:F(q+ie,Y)})}}},$=B=>{B.preventDefault(),U()};return jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,"data-testid":"hacker",ref:D,onKeyDown:$,onTouchStart:$,className:`puzzle--hacker__container background-hacker-${R.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-${R.color} typography-hacker-${R.typo}`,children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--hacker__code",ref:N,children:[jsxRuntimeExports.jsx(Code,{codeContainer:S}),_?jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,onCharacterTyped:()=>{N.current&&(N.current.scrollTop=D.current.scrollHeight)},cursor:{hideWhenDone:!0},className:"puzzle--hacker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),p.right.desc?`// ${p.right.desc}`:`${k}`]}):null]}),jsxRuntimeExports.jsx(ProgressBar,{type:a,progress:T})]}),_?jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:M,children:f("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,info:n,user:t,login:a,password:o,image:d,setResolveAction:h,nodeId:f}){var q;const u=re=>l({type:"translate",payload:re}),p=`login-puzzle_${f}`,x=LangIsRtl(),[R,S]=React$2.useState(""),[E,g]=React$2.useState(""),[v,T]=React$2.useState(!1),[b,_]=React$2.useState(""),[w,C]=React$2.useState(""),[P,D]=React$2.useState(!1),[N,k]=React$2.useState(!1),[F,M]=React$2.useState(!1),[U]=e,[$,B]=React$2.useState([]),J=((q=d.img)==null?void 0:q.url)||imagenPorDefecto,ne=()=>{const{rewards:re}=n.solution.right,ce=[...$,...re];l({type:"addPoints",complex:!0,finish:!0,payload:ce}),l({type:"passPuzzle"})},ie=()=>{U("click-ui");const re={login:!0,password:!1};a&&(re.login=t===R),re.password=o===E,re.login&&re.password?(C("success"),D(!0),k(!1),U("score"),setTimeout(()=>{ne()},2e3)):(B([...$,...n.solution.wrong.rewards]),U("fail"),C("failed"),k(!0),l({type:"failPuzzle"}))},Y=re=>{let ce="";if(re.length>=0){for(let fe=0;fe<re.length;fe+=1)ce+="•";_(ce)}};return React$2.useEffect(()=>{h(()=>{const re=[...$,...n.resolve.rewards];M(!0),setTimeout(()=>{l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:p,rewards:re,finish:!0}})},2e3)})},[$,n.resolve.rewards,l,h,p]),jsxRuntimeExports.jsx("div",{className:"puzzle--layer",style:{backgroundImage:`url("${J}")`},children:jsxRuntimeExports.jsxs("div",{className:`puzzle--login ${t?"puzzle--login--withuser":""}`,children:[jsxRuntimeExports.jsx("span",{className:"icon-login-puzzle",children:" "}),jsxRuntimeExports.jsx("span",{className:"puzzle--login__title",children:u("puzzle.initSession")}),jsxRuntimeExports.jsxs("div",{children:[a&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--login__label",children:u("puzzle.user")}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[F?jsxRuntimeExports.jsx("input",{dir:x?"rtl":"auto",disabled:P,"data-testid":"username",className:"puzzle--login__input success",type:"text",placeholder:t,value:t}):jsxRuntimeExports.jsx("input",{dir:x?"rtl":"auto",disabled:P,"data-testid":"username",className:`puzzle--login__input ${w}`,type:"text",placeholder:u("puzzle.user"),onChange:re=>{S(re.target.value),C(""),k(!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:u("puzzle.password")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[F?jsxRuntimeExports.jsx("input",{dir:x?"rtl":"auto",disabled:!0,"data-testid":"password",className:"puzzle--login__input puzzle--login__input--fakepassword success",type:"text",placeholder:o,value:o,style:{opacity:1}}):jsxRuntimeExports.jsx("input",{dir:x?"rtl":"auto",disabled:P,"data-testid":"password",className:`puzzle--login__input puzzle--login__input--fakepassword ${w}`,type:"text",placeholder:u("puzzle.password"),onFocus:()=>{T(!0)},onBlur:()=>{T(!1)},onChange:re=>{g(re.target.value),Y(re.target.value),C(""),k(!1)}}),F?null:jsxRuntimeExports.jsx("div",{dir:x?"rtl":"auto",className:`login-fakepassword${v?" login-fakepassword--focus":""}${b.length?" login-fakepassword--fill":""} ${w||""}`,children:E?b:u("puzzle.password")}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check",children:" "})]})]})]}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${E.length!==0&&!P?"":"disabled"}`,onClick:ie,children:u("puzzle.loginIn")}),!F&&N&&n.solution.wrong.desc!==""&&jsxRuntimeExports.jsx("div",{className:"puzzle--login__label--error",children:n.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:x}){const[R,S]=React$2.useState();React$2.useEffect(()=>{let T;return n&&n(e?"score":"fail"),l&&!h&&(T=setTimeout(()=>{S(!0)},1e3)),()=>{T&&clearTimeout(T)}},[n,e,h,l]),React$2.useEffect(()=>{let T;return f&&a&&(T=setTimeout(a,u)),()=>{T&&clearTimeout(T)}},[u,a,f]);const E=()=>e?"success":"failed",g=()=>e?"icon-correct-thumb":p?"icon-times-up":"icon-incorrect-thumb",v=x({disabled:!(l&&a&&R),repeat:!1,forward:a,close:a});return React$2.useEffect(()=>v(),[v]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{"data-testid":"feedback-layer",className:`feedback-layer ${R?"feedback-layer--withexplain":""}`,children:[jsxRuntimeExports.jsxs("div",{className:`feedback-layer__header ${h?"feedback-layer__header--in-shortText":""} ${t||""} ${E()}`,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()}`}):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&&R&&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,image:e,password:n,keyboard:t,info:a,disableExit:o,soundActions:d,setResolveAction:h,nodeId:f,keyboardControl:u,styles:p="default-theme"}){var ie,Y;const[x,R]=React$2.useState(""),[S,E]=React$2.useState(""),[g,v]=React$2.useState(!1),[T,b]=React$2.useState(""),[_,w]=React$2.useState(!1),[C,P]=React$2.useState([]),D=q=>l({type:"translate",payload:q}),N=`keyboard-puzzle_${f}`,[k]=d,F=React$2.useCallback(q=>{v(!1),w(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:q})},[l]),M=()=>{if(g){const{rewards:q}=a.solution.right,re=[...C,...q];k("score"),F(re)}else l({type:"hidePuzzleButtons",payload:!1}),v(!1),o(!1),w(!1);b("")},U=q=>{q===n?(o(!1),R("success"),k("score"),l({type:"passPuzzle"}),v(!0),w(!0),a.solution.right.desc?b(a.solution.right.desc):setTimeout(()=>{const{rewards:re}=a.solution.right,ce=[...C,...re];F(ce)},3e3)):(w(!0),R("failed"),k("fail"),l({type:"failPuzzle"}),v(!1),P([...C,...a.solution.wrong.rewards]),l({type:"hidePuzzleButtons",payload:!1}),R(""),E(""),w(!0),a.solution.wrong.desc?b(a.solution.wrong.desc):setTimeout(()=>{M()},3e3))};React$2.useEffect(()=>{h(()=>{o(!1),k("score"),R("success"),v(!0),b(a.solution.right.desc),E(n);const q=[...C,...a.resolve.rewards];setTimeout(()=>{v(!1),w(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:N,rewards:q,finish:!0}})},2e3)})},[h,o,a.solution.right.desc,k,a.resolve.rewards,C,n,l,N]);const $=(q,re)=>{const ce=t[q][re];k("click-ui"),S.length<n.length+1&&(E(S+ce),S.length+1===n.length&&U(S+ce))},B=()=>{k("click-ui"),E(S.substring(0,S.length-1))},ne={backgroundImage:`url("${((ie=e.img)==null?void 0:ie.url)||""}")`,backgroudPosition:"center center"};return jsxRuntimeExports.jsxs("div",{className:`puzzle-keyboard puzzle-keyboard--${p}`,style:(Y=e.img)!=null&&Y.url?ne:null,children:[jsxRuntimeExports.jsx("div",{className:"puzzle-keyboard__header",children:jsxRuntimeExports.jsxs("div",{className:"puzzle-keyboard__digits",children:[n.split("").map((q,re)=>jsxRuntimeExports.jsx("div",{className:`puzzle-keyboard__digit ${x}`,children:S.split("")[re]?S.split("")[re]:""},`${q+re}`)),x!==""?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:x==="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:B,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:[p==="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--${p}`,children:t.map((q,re)=>(Array.isArray(q)?q:Object.values(q)).map((ce,fe)=>jsxRuntimeExports.jsx("button",{className:`keyboard-key keyboard-key--${p} ${ce==="*"?"keyboard-key--star":""}`,type:"button",onClick:()=>$(re,fe),children:jsxRuntimeExports.jsx("div",{children:ce})},ce)))}),p==="scifi-theme"&&jsxRuntimeExports.jsx("hr",{"aria-hidden":!0,className:"puzzle-keyboard__scifi-line"})]}),_&&jsxRuntimeExports.jsx(FeedbackComponent$1,{translate:D,text:T,success:g,functionOnClose:M,keyboardControl:u})]})}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),P=Math.sin(w),D=this.m[0]*C+this.m[2]*P,N=this.m[1]*C+this.m[3]*P,k=this.m[0]*-P+this.m[2]*C,F=this.m[1]*-P+this.m[3]*C;return this.m[0]=D,this.m[1]=N,this.m[2]=k,this.m[3]=F,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(w,C){var P=this.m[0]+this.m[2]*C,D=this.m[1]+this.m[3]*C,N=this.m[2]+this.m[0]*w,k=this.m[3]+this.m[1]*w;return this.m[0]=P,this.m[1]=D,this.m[2]=N,this.m[3]=k,this}multiply(w){var C=this.m[0]*w.m[0]+this.m[2]*w.m[1],P=this.m[1]*w.m[0]+this.m[3]*w.m[1],D=this.m[0]*w.m[2]+this.m[2]*w.m[3],N=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]=P,this.m[2]=D,this.m[3]=N,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,P=-this.m[1]*w,D=-this.m[2]*w,N=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]=P,this.m[2]=D,this.m[3]=N,this.m[4]=k,this.m[5]=F,this}getMatrix(){return this.m}decompose(){var w=this.m[0],C=this.m[1],P=this.m[2],D=this.m[3],N=this.m[4],k=this.m[5],F=w*D-C*P;let M={x:N,y:k,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(w!=0||C!=0){var U=Math.sqrt(w*w+C*C);M.rotation=C>0?Math.acos(w/U):-Math.acos(w/U),M.scaleX=U,M.scaleY=F/U,M.skewX=(w*P+C*D)/F,M.skewY=0}else if(P!=0||D!=0){var $=Math.sqrt(P*P+D*D);M.rotation=Math.PI/2-(D>0?Math.acos(-P/$):-Math.acos(P/$)),M.scaleX=F/$,M.scaleY=$,M.skewX=0,M.skewY=(w*P+C*D)/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="",x="0",R="Konva warning: ",S="Konva error: ",E="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]},v=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,T=[];const b=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(_){T.push(_),T.length===1&&b(function(){const w=T;T=[],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;)_=x+_;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)===E?(w=v.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,P)=>C.slice(-1)==="%"?P===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(_),P=Number(C[0])/360,D=Number(C[1])/100,N=Number(C[2])/100;let k,F,M;if(D===0)return M=N*255,{r:Math.round(M),g:Math.round(M),b:Math.round(M),a:1};N<.5?k=N*(1+D):k=N+D-N*D;const U=2*N-k,$=[0,0,0];for(let B=0;B<3;B++)F=P+1/3*-(B-1),F<0&&F++,F>1&&F--,6*F<1?M=U+(k-U)*6*F:2*F<1?M=k:3*F<2?M=U+(k-U)*(2/3-F)*6:M=U,$[B]=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(S+_)},error(_){console.error(S+_)},warn(_){e.Konva.showWarnings&&console.warn(R+_)},each(_,w){for(var C in _)w(C,_[C])},_inRange(_,w,C){return w<=_&&_<C},_getProjectionToSegment(_,w,C,P,D,N){var k,F,M,U=(_-C)*(_-C)+(w-P)*(w-P);if(U==0)k=_,F=w,M=(D-C)*(D-C)+(N-P)*(N-P);else{var $=((D-_)*(C-_)+(N-w)*(P-w))/U;$<0?(k=_,F=w,M=(_-D)*(_-D)+(w-N)*(w-N)):$>1?(k=C,F=P,M=(C-D)*(C-D)+(P-N)*(P-N)):(k=_+$*(C-_),F=w+$*(P-w),M=(k-D)*(k-D)+(F-N)*(F-N))}return[k,F,M]},_getProjectionToLine(_,w,C){var P=l.Util.cloneObject(_),D=Number.MAX_VALUE;return w.forEach(function(N,k){if(!(!C&&k===w.length-1)){var F=w[(k+1)%w.length],M=l.Util._getProjectionToSegment(N.x,N.y,F.x,F.y,_.x,_.y),U=M[0],$=M[1],B=M[2];B<D&&(P.x=U,P.y=$,D=B)}}),P},_prepareArrayForTween(_,w,C){var P,D=[],N=[];if(_.length>w.length){var k=w;w=_,_=k}for(P=0;P<_.length;P+=2)D.push({x:_[P],y:_[P+1]});for(P=0;P<w.length;P+=2)N.push({x:w[P],y:w[P+1]});var F=[];return N.forEach(function(M){var U=l.Util._getProjectionToLine(M,D,C);F.push(U.x),F.push(U.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,P){let D=0,N=0,k=0,F=0;typeof P=="number"?D=N=k=F=Math.min(P,w/2,C/2):(D=Math.min(P[0]||0,w/2,C/2),N=Math.min(P[1]||0,w/2,C/2),F=Math.min(P[2]||0,w/2,C/2),k=Math.min(P[3]||0,w/2,C/2)),_.moveTo(D,0),_.lineTo(w-N,0),_.arc(w-N,N,N,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,D),_.arc(D,D,D,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,x=e.Util._capitalize,R=t+x(d),S=a+x(d),E,g;o.prototype[R]=function(){var T={};for(E=0;E<p;E++)g=h[E],T[g]=this.getAttr(d+x(g));return T};var v=(0,n.getComponentValidator)(h);o.prototype[S]=function(T){var b=this.attrs[d],_;f&&(T=f.call(this,T)),v&&v.call(this,T,d);for(_ in T)T.hasOwnProperty(_)&&this._setAttr(d+x(_),T[_]);return T||h.forEach(w=>{this._setAttr(d+x(w),void 0)}),this._fireChangeEvent(d,b,T),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 x=this.attrs[d];return x===void 0?h:x},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),x=a+e.Util._capitalize(h);function R(){u.apply(this,arguments),e.Util.error('"'+h+'" method is deprecated and will be removed soon. Use ""'+f+'" instead.')}o.prototype[h]=R,o.prototype[p]=R,o.prototype[x]=R})},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,x=this._context;p.length===3?x.drawImage(e,n,t):p.length===5?x.drawImage(e,n,t,a,o):p.length===9&&x.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,x=f.y*u;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",d*Math.min(Math.abs(p),Math.abs(x))),this.setAttr("shadowOffsetX",h.x*p),this.setAttr("shadowOffsetY",h.y*x)}}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(R=>R.id===o.pointerId);if(u){if(o.dragStatus!=="dragging"){var p=h.dragDistance(),x=Math.max(Math.abs(u.x-o.startPointerPos.x),Math.abs(u.y-o.startPointerPos.y));if(x<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,x=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 R=new Canvas_1$1.SceneCanvas({pixelRatio:d,width:a,height:o}),S=new Canvas_1$1.SceneCanvas({pixelRatio:d,width:0,height:0,willReadFrequently:!0}),E=new Canvas_1$1.HitCanvas({pixelRatio:x,width:a,height:o}),g=R.getContext(),v=E.getContext();return E.isCache=!0,R.isCache=!0,this._cache.delete(CANVAS),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(R.getContext()._context.imageSmoothingEnabled=!1,S.getContext()._context.imageSmoothingEnabled=!1),g.save(),v.save(),g.translate(-h,-f),v.translate(-h,-f),this._isUnderCache=!0,this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this.drawScene(R,this),this.drawHit(E,this),this._isUnderCache=!1,g.restore(),v.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:R,filter:S,hit:E,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(x){Util_1$c.Util.error("Unable to apply filter. "+x.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,x=this.attrs.offsetX||0,R=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),(x!==0||R!==0)&&t.translate(-1*x,-1*R),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 x=this.getAbsoluteTransform(t),R=x.getMatrix();o.transform(R[0],R[1],R[2],R[3],R[4],R[5]),o.beginPath();let v;if(f)v=f.call(this,o,this);else{var S=this.clipX(),E=this.clipY();o.rect(S,E,d,h)}o.clip.apply(o,v),R=x.copy().invert().getMatrix(),o.transform(R[0],R[1],R[2],R[3],R[4],R[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(v){v[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 v=g.getClientRect({relativeTo:p,skipShadow:e.skipShadow,skipStroke:e.skipStroke});v.width===0&&v.height===0||(o===void 0?(o=v.x,d=v.y,h=v.x+v.width,f=v.y+v.height):(o=Math.min(o,v.x),d=Math.min(d,v.y),h=Math.max(h,v.x+v.width),f=Math.max(f,v.y+v.height)))}});for(var x=this.find("Shape"),R=!1,S=0;S<x.length;S++){var E=x[S];if(E._isVisible(this)){R=!0;break}}return R&&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",x="px",R="mouseout",S="mouseleave",E="mouseover",g="mouseenter",v="mousemove",T="mousedown",b="mouseup",_="pointermove",w="pointerdown",C="pointerup",P="pointercancel",D="lostpointercapture",N="pointerout",k="pointerleave",F="pointerover",M="pointerenter",U="contextmenu",$="touchstart",B="touchend",J="touchmove",ne="touchcancel",ie="wheel",Y=5,q=[[g,"_pointerenter"],[T,"_pointerdown"],[v,"_pointermove"],[b,"_pointerup"],[S,"_pointerleave"],[$,"_pointerdown"],[J,"_pointermove"],[B,"_pointerup"],[ne,"_pointercancel"],[E,"_pointerover"],[ie,"_wheel"],[U,"_contextmenu"],[w,"_pointerdown"],[_,"_pointermove"],[C,"_pointerup"],[P,"_pointercancel"],[D,"_lostpointercapture"]];const re={mouse:{[N]:R,[k]:S,[F]:E,[M]:g,[_]:v,[w]:T,[C]:b,[P]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[N]:"touchout",[k]:"touchleave",[F]:"touchover",[M]:"touchenter",[_]:J,[w]:$,[C]:B,[P]:ne,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[N]:N,[k]:k,[F]:F,[M]:M,[_]:_,[w]:w,[C]:C,[P]:P,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},ce=V=>V.indexOf("pointer")>=0?"pointer":V.indexOf("touch")>=0?"touch":"mouse",fe=V=>{const z=ce(V);if(z==="pointer")return a.Konva.pointerEventsEnabled&&re.pointer;if(z==="touch")return re.touch;if(z==="mouse")return re.mouse};function te(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(z){super(te(z)),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",()=>{te(this.attrs)}),this._checkVisibility()}_validateAdd(z){const Q=z.getType()==="Layer",ee=z.getType()==="FastLayer";Q||ee||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const z=this.visible()?"":"none";this.content.style.display=z}setContainer(z){if(typeof z===p){if(z.charAt(0)==="."){var Q=z.slice(1);z=document.getElementsByClassName(Q)[0]}else{var ee;z.charAt(0)!=="#"?ee=z:ee=z.slice(1),z=document.getElementById(ee)}if(!z)throw"Can not find container in document with id "+ee}return this._setAttr("container",z),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),z.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var z=this.children,Q=z.length,ee;for(ee=0;ee<Q;ee++)z[ee].clear();return this}clone(z){return z||(z={}),z.container=typeof document<"u"&&document.createElement("div"),t.Container.prototype.clone.call(this,z)}destroy(){super.destroy();var z=this.content;z&&e.Util._isInDocument(z)&&this.container().removeChild(z);var Q=l.stages.indexOf(this);return Q>-1&&l.stages.splice(Q,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const z=this._pointerPositions[0]||this._changedPointerPositions[0];return z?{x:z.x,y:z.y}:(e.Util.warn(H),null)}_getPointerById(z){return this._pointerPositions.find(Q=>Q.id===z)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(z){z=z||{},z.x=z.x||0,z.y=z.y||0,z.width=z.width||this.width(),z.height=z.height||this.height();var Q=new o.SceneCanvas({width:z.width,height:z.height,pixelRatio:z.pixelRatio||1}),ee=Q.getContext()._context,le=this.children;return(z.x||z.y)&&ee.translate(-1*z.x,-1*z.y),le.forEach(function(ue){if(ue.isVisible()){var he=ue._toKonvaCanvas(z);ee.drawImage(he._canvas,z.x,z.y,he.getWidth()/he.getPixelRatio(),he.getHeight()/he.getPixelRatio())}}),Q}getIntersection(z){if(!z)return null;var Q=this.children,ee=Q.length,le=ee-1,ue;for(ue=le;ue>=0;ue--){const he=Q[ue].getIntersection(z);if(he)return he}return null}_resizeDOM(){var z=this.width(),Q=this.height();this.content&&(this.content.style.width=z+x,this.content.style.height=Q+x),this.bufferCanvas.setSize(z,Q),this.bufferHitCanvas.setSize(z,Q),this.children.forEach(ee=>{ee.setSize({width:z,height:Q}),ee.draw()})}add(z,...Q){if(arguments.length>1){for(var ee=0;ee<arguments.length;ee++)this.add(arguments[ee]);return this}super.add(z);var le=this.children.length;return le>Y&&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."),z.setSize({width:this.width(),height:this.height()}),z.draw(),a.Konva.isBrowser&&this.content.appendChild(z.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(z){return f.hasPointerCapture(z,this)}setPointerCapture(z){f.setPointerCapture(z,this)}releaseCapture(z){f.releaseCapture(z,this)}getLayers(){return this.children}_bindContentEvents(){a.Konva.isBrowser&&q.forEach(([z,Q])=>{this.content.addEventListener(z,ee=>{this[Q](ee)},{passive:!1})})}_pointerenter(z){this.setPointersPositions(z);const Q=fe(z.type);Q&&this._fire(Q.pointerenter,{evt:z,target:this,currentTarget:this})}_pointerover(z){this.setPointersPositions(z);const Q=fe(z.type);Q&&this._fire(Q.pointerover,{evt:z,target:this,currentTarget:this})}_getTargetShape(z){let Q=this[z+"targetShape"];return Q&&!Q.getStage()&&(Q=null),Q}_pointerleave(z){const Q=fe(z.type),ee=ce(z.type);if(Q){this.setPointersPositions(z);var le=this._getTargetShape(ee),ue=!d.DD.isDragging||a.Konva.hitOnDragEnabled;le&&ue?(le._fireAndBubble(Q.pointerout,{evt:z}),le._fireAndBubble(Q.pointerleave,{evt:z}),this._fire(Q.pointerleave,{evt:z,target:this,currentTarget:this}),this[ee+"targetShape"]=null):ue&&(this._fire(Q.pointerleave,{evt:z,target:this,currentTarget:this}),this._fire(Q.pointerout,{evt:z,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(z){const Q=fe(z.type),ee=ce(z.type);if(Q){this.setPointersPositions(z);var le=!1;this._changedPointerPositions.forEach(ue=>{var he=this.getIntersection(ue);if(d.DD.justDragged=!1,a.Konva["_"+ee+"ListenClick"]=!0,!he||!he.isListening())return;a.Konva.capturePointerEventsEnabled&&he.setPointerCapture(ue.id),this[ee+"ClickStartShape"]=he,he._fireAndBubble(Q.pointerdown,{evt:z,pointerId:ue.id}),le=!0;const ve=z.type.indexOf("touch")>=0;he.preventDefault()&&z.cancelable&&ve&&z.preventDefault()}),le||this._fire(Q.pointerdown,{evt:z,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(z){const Q=fe(z.type),ee=ce(z.type);if(!Q)return;d.DD.isDragging&&d.DD.node.preventDefault()&&z.cancelable&&z.preventDefault(),this.setPointersPositions(z);var le=!d.DD.isDragging||a.Konva.hitOnDragEnabled;if(!le)return;var ue={};let he=!1;var ve=this._getTargetShape(ee);this._changedPointerPositions.forEach(be=>{const Re=f.getCapturedShape(be.id)||this.getIntersection(be),Le=be.id,Oe={evt:z,pointerId:Le};var Ke=ve!==Re;if(Ke&&ve&&(ve._fireAndBubble(Q.pointerout,{...Oe},Re),ve._fireAndBubble(Q.pointerleave,{...Oe},Re)),Re){if(ue[Re._id])return;ue[Re._id]=!0}Re&&Re.isListening()?(he=!0,Ke&&(Re._fireAndBubble(Q.pointerover,{...Oe},ve),Re._fireAndBubble(Q.pointerenter,{...Oe},ve),this[ee+"targetShape"]=Re),Re._fireAndBubble(Q.pointermove,{...Oe})):ve&&(this._fire(Q.pointerover,{evt:z,target:this,currentTarget:this,pointerId:Le}),this[ee+"targetShape"]=null)}),he||this._fire(Q.pointermove,{evt:z,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(z){const Q=fe(z.type),ee=ce(z.type);if(!Q)return;this.setPointersPositions(z);const le=this[ee+"ClickStartShape"],ue=this[ee+"ClickEndShape"];var he={};let ve=!1;this._changedPointerPositions.forEach(be=>{const Re=f.getCapturedShape(be.id)||this.getIntersection(be);if(Re){if(Re.releaseCapture(be.id),he[Re._id])return;he[Re._id]=!0}const Le=be.id,Oe={evt:z,pointerId:Le};let Ke=!1;a.Konva["_"+ee+"InDblClickWindow"]?(Ke=!0,clearTimeout(this[ee+"DblTimeout"])):d.DD.justDragged||(a.Konva["_"+ee+"InDblClickWindow"]=!0,clearTimeout(this[ee+"DblTimeout"])),this[ee+"DblTimeout"]=setTimeout(function(){a.Konva["_"+ee+"InDblClickWindow"]=!1},a.Konva.dblClickWindow),Re&&Re.isListening()?(ve=!0,this[ee+"ClickEndShape"]=Re,Re._fireAndBubble(Q.pointerup,{...Oe}),a.Konva["_"+ee+"ListenClick"]&&le&&le===Re&&(Re._fireAndBubble(Q.pointerclick,{...Oe}),Ke&&ue&&ue===Re&&Re._fireAndBubble(Q.pointerdblclick,{...Oe}))):(this[ee+"ClickEndShape"]=null,a.Konva["_"+ee+"ListenClick"]&&this._fire(Q.pointerclick,{evt:z,target:this,currentTarget:this,pointerId:Le}),Ke&&this._fire(Q.pointerdblclick,{evt:z,target:this,currentTarget:this,pointerId:Le}))}),ve||this._fire(Q.pointerup,{evt:z,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a.Konva["_"+ee+"ListenClick"]=!1,z.cancelable&&ee!=="touch"&&z.preventDefault()}_contextmenu(z){this.setPointersPositions(z);var Q=this.getIntersection(this.getPointerPosition());Q&&Q.isListening()?Q._fireAndBubble(U,{evt:z}):this._fire(U,{evt:z,target:this,currentTarget:this})}_wheel(z){this.setPointersPositions(z);var Q=this.getIntersection(this.getPointerPosition());Q&&Q.isListening()?Q._fireAndBubble(ie,{evt:z}):this._fire(ie,{evt:z,target:this,currentTarget:this})}_pointercancel(z){this.setPointersPositions(z);const Q=f.getCapturedShape(z.pointerId)||this.getIntersection(this.getPointerPosition());Q&&Q._fireAndBubble(C,f.createEvent(z)),f.releaseCapture(z.pointerId)}_lostpointercapture(z){f.releaseCapture(z.pointerId)}setPointersPositions(z){var Q=this._getContentPosition(),ee=null,le=null;z=z||window.event,z.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(z.touches,ue=>{this._pointerPositions.push({id:ue.identifier,x:(ue.clientX-Q.left)/Q.scaleX,y:(ue.clientY-Q.top)/Q.scaleY})}),Array.prototype.forEach.call(z.changedTouches||z.touches,ue=>{this._changedPointerPositions.push({id:ue.identifier,x:(ue.clientX-Q.left)/Q.scaleX,y:(ue.clientY-Q.top)/Q.scaleY})})):(ee=(z.clientX-Q.left)/Q.scaleX,le=(z.clientY-Q.top)/Q.scaleY,this.pointerPos={x:ee,y:le},this._pointerPositions=[{x:ee,y:le,id:e.Util._getFirstPointerId(z)}],this._changedPointerPositions=[{x:ee,y:le,id:e.Util._getFirstPointerId(z)}])}_setPointerPosition(z){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(z)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var z=this.content.getBoundingClientRect();return{top:z.top,left:z.left,scaleX:z.width/this.content.clientWidth||1,scaleY:z.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 z=this.container();if(!z)throw"Stage has no container. A container is required.";z.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"),z.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(z){z.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",x="linearGradient",R="radialGradient";let S;function E(){return S||(S=n.Util.createCanvasElement().getContext("2d"),S)}l.shapes={};function g(k){const F=this.attrs.fillRule;F?k.fill(F):k.fill()}function v(k){k.stroke()}function T(k){k.fill()}function b(k){k.stroke()}function _(){this._clearCache(f)}function w(){this._clearCache(u)}function C(){this._clearCache(p)}function P(){this._clearCache(x)}function D(){this._clearCache(R)}class N 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=E();const M=F.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(M&&M.setTransform){const U=new n.Transform;U.translate(this.fillPatternX(),this.fillPatternY()),U.rotate(e.Konva.getAngle(this.fillPatternRotation())),U.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),U.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const $=U.getMatrix(),B=typeof DOMMatrix>"u"?{a:$[0],b:$[1],c:$[2],d:$[3],e:$[4],f:$[5]}:new DOMMatrix($);M.setTransform(B)}return M}}_getLinearGradient(){return this._getCache(x,this.__getLinearGradient)}__getLinearGradient(){var F=this.fillLinearGradientColorStops();if(F){for(var M=E(),U=this.fillLinearGradientStartPoint(),$=this.fillLinearGradientEndPoint(),B=M.createLinearGradient(U.x,U.y,$.x,$.y),J=0;J<F.length;J+=2)B.addColorStop(F[J],F[J+1]);return B}}_getRadialGradient(){return this._getCache(R,this.__getRadialGradient)}__getRadialGradient(){var F=this.fillRadialGradientColorStops();if(F){for(var M=E(),U=this.fillRadialGradientStartPoint(),$=this.fillRadialGradientEndPoint(),B=M.createRadialGradient(U.x,U.y,this.fillRadialGradientStartRadius(),$.x,$.y,this.fillRadialGradientEndRadius()),J=0;J<F.length;J+=2)B.addColorStop(F[J],F[J+1]);return B}}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 U=M.bufferHitCanvas;return U.getContext().clear(),this.drawHit(U,void 0,!0),U.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(),B=this.hasStroke(),J=this.getAbsoluteOpacity()!==1;if($&&B&&J)return!0;const ne=this.hasShadow(),ie=this.shadowForStrokeEnabled();return!!($&&B&&ne&&ie)}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,U=F.relativeTo,$=this.getSelfRect(),J=!F.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,ne=$.width+J,ie=$.height+J,Y=!F.skipShadow&&this.hasShadow(),q=Y?this.shadowOffsetX():0,re=Y?this.shadowOffsetY():0,ce=ne+Math.abs(q),fe=ie+Math.abs(re),te=Y&&this.shadowBlur()||0,H=ce+te*2,W=fe+te*2,V={width:H,height:W,x:-(J/2+te)+Math.min(q,0)+$.x,y:-(J/2+te)+Math.min(re,0)+$.y};return M?V:this._transformedRect(V,U)}drawScene(F,M){var U=this.getLayer(),$=F||U.getCanvas(),B=$.getContext(),J=this._getCanvasCache(),ne=this.getSceneFunc(),ie=this.hasShadow(),Y,q,re,ce=$.isCache,fe=M===this;if(!this.isVisible()&&!fe)return this;if(J){B.save();var te=this.getAbsoluteTransform(M).getMatrix();return B.transform(te[0],te[1],te[2],te[3],te[4],te[5]),this._drawCachedSceneCanvas(B),B.restore(),this}if(!ne)return this;if(B.save(),this._useBufferCanvas()&&!ce){Y=this.getStage(),q=Y.bufferCanvas,re=q.getContext(),re.clear(),re.save(),re._applyLineJoin(this);var H=this.getAbsoluteTransform(M).getMatrix();re.transform(H[0],H[1],H[2],H[3],H[4],H[5]),ne.call(this,re,this),re.restore();var W=q.pixelRatio;ie&&B._applyShadow(this),B._applyOpacity(this),B._applyGlobalCompositeOperation(this),B.drawImage(q._canvas,0,0,q.width/W,q.height/W)}else{if(B._applyLineJoin(this),!fe){var H=this.getAbsoluteTransform(M).getMatrix();B.transform(H[0],H[1],H[2],H[3],H[4],H[5]),B._applyOpacity(this),B._applyGlobalCompositeOperation(this)}ie&&B._applyShadow(this),ne.call(this,B,this)}return B.restore(),this}drawHit(F,M,U=!1){if(!this.shouldDrawHit(M,U))return this;var $=this.getLayer(),B=F||$.hitCanvas,J=B&&B.getContext(),ne=this.hitFunc()||this.sceneFunc(),ie=this._getCanvasCache(),Y=ie&&ie.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()"),Y){J.save();var q=this.getAbsoluteTransform(M).getMatrix();return J.transform(q[0],q[1],q[2],q[3],q[4],q[5]),this._drawCachedHitCanvas(J),J.restore(),this}if(!ne)return this;if(J.save(),J._applyLineJoin(this),!(this===M)){var ce=this.getAbsoluteTransform(M).getMatrix();J.transform(ce[0],ce[1],ce[2],ce[3],ce[4],ce[5])}return ne.call(this,J,this),J.restore(),this}drawHitFromCache(F=0){var M=this._getCanvasCache(),U=this._getCachedSceneCanvas(),$=M.hit,B=$.getContext(),J=$.getWidth(),ne=$.getHeight(),ie,Y,q,re,ce,fe;B.clear(),B.drawImage(U._canvas,0,0,J,ne);try{for(ie=B.getImageData(0,0,J,ne),Y=ie.data,q=Y.length,re=n.Util._hexToRgb(this.colorKey),ce=0;ce<q;ce+=4)fe=Y[ce+3],fe>F?(Y[ce]=re.r,Y[ce+1]=re.g,Y[ce+2]=re.b,Y[ce+3]=255):Y[ce+3]=0;B.putImageData(ie,0,0)}catch(te){n.Util.error("Unable to draw hit graph from cached scene canvas. "+te.message)}return this}hasPointerCapture(F){return h.hasPointerCapture(F,this)}setPointerCapture(F){h.setPointerCapture(F,this)}releaseCapture(F){h.releaseCapture(F,this)}}l.Shape=N,N.prototype._fillFunc=g,N.prototype._strokeFunc=v,N.prototype._fillFuncHit=T,N.prototype._strokeFuncHit=b,N.prototype._centroid=!1,N.prototype.nodeType="Shape",(0,d._registerNode)(N),N.prototype.eventListeners={},N.prototype.on.call(N.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",_),N.prototype.on.call(N.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",w),N.prototype.on.call(N.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",C),N.prototype.on.call(N.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",P),N.prototype.on.call(N.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",D),t.Factory.addGetterSetter(N,"stroke",void 0,(0,o.getStringOrGradientValidator)()),t.Factory.addGetterSetter(N,"strokeWidth",2,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillAfterStrokeEnabled",!1),t.Factory.addGetterSetter(N,"hitStrokeWidth","auto",(0,o.getNumberOrAutoValidator)()),t.Factory.addGetterSetter(N,"strokeHitEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(N,"perfectDrawEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(N,"shadowForStrokeEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(N,"lineJoin"),t.Factory.addGetterSetter(N,"lineCap"),t.Factory.addGetterSetter(N,"sceneFunc"),t.Factory.addGetterSetter(N,"hitFunc"),t.Factory.addGetterSetter(N,"dash"),t.Factory.addGetterSetter(N,"dashOffset",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"shadowColor",void 0,(0,o.getStringValidator)()),t.Factory.addGetterSetter(N,"shadowBlur",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"shadowOpacity",1,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(N,"shadowOffset",["x","y"]),t.Factory.addGetterSetter(N,"shadowOffsetX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"shadowOffsetY",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillPatternImage"),t.Factory.addGetterSetter(N,"fill",void 0,(0,o.getStringOrGradientValidator)()),t.Factory.addGetterSetter(N,"fillPatternX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillPatternY",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillLinearGradientColorStops"),t.Factory.addGetterSetter(N,"strokeLinearGradientColorStops"),t.Factory.addGetterSetter(N,"fillRadialGradientStartRadius",0),t.Factory.addGetterSetter(N,"fillRadialGradientEndRadius",0),t.Factory.addGetterSetter(N,"fillRadialGradientColorStops"),t.Factory.addGetterSetter(N,"fillPatternRepeat","repeat"),t.Factory.addGetterSetter(N,"fillEnabled",!0),t.Factory.addGetterSetter(N,"strokeEnabled",!0),t.Factory.addGetterSetter(N,"shadowEnabled",!0),t.Factory.addGetterSetter(N,"dashEnabled",!0),t.Factory.addGetterSetter(N,"strokeScaleEnabled",!0),t.Factory.addGetterSetter(N,"fillPriority","color"),t.Factory.addComponentsGetterSetter(N,"fillPatternOffset",["x","y"]),t.Factory.addGetterSetter(N,"fillPatternOffsetX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillPatternOffsetY",0,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(N,"fillPatternScale",["x","y"]),t.Factory.addGetterSetter(N,"fillPatternScaleX",1,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(N,"fillPatternScaleY",1,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(N,"fillLinearGradientStartPoint",["x","y"]),t.Factory.addComponentsGetterSetter(N,"strokeLinearGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(N,"fillLinearGradientStartPointX",0),t.Factory.addGetterSetter(N,"strokeLinearGradientStartPointX",0),t.Factory.addGetterSetter(N,"fillLinearGradientStartPointY",0),t.Factory.addGetterSetter(N,"strokeLinearGradientStartPointY",0),t.Factory.addComponentsGetterSetter(N,"fillLinearGradientEndPoint",["x","y"]),t.Factory.addComponentsGetterSetter(N,"strokeLinearGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(N,"fillLinearGradientEndPointX",0),t.Factory.addGetterSetter(N,"strokeLinearGradientEndPointX",0),t.Factory.addGetterSetter(N,"fillLinearGradientEndPointY",0),t.Factory.addGetterSetter(N,"strokeLinearGradientEndPointY",0),t.Factory.addComponentsGetterSetter(N,"fillRadialGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(N,"fillRadialGradientStartPointX",0),t.Factory.addGetterSetter(N,"fillRadialGradientStartPointY",0),t.Factory.addComponentsGetterSetter(N,"fillRadialGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(N,"fillRadialGradientEndPointX",0),t.Factory.addGetterSetter(N,"fillRadialGradientEndPointY",0),t.Factory.addGetterSetter(N,"fillPatternRotation",0),t.Factory.addGetterSetter(N,"fillRule",void 0,(0,o.getStringValidator)()),t.Factory.backCompat(N,{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$2={};Object.defineProperty(Animation$2,"__esModule",{value:!0});Animation$2.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$1=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$2.Animation=Animation$1;Animation$1.animations=[];Animation$1.animIdCounter=0;Animation$1.animRunning=!1;var Tween$1={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Easings=l.Tween=void 0;const e=Util,n=Animation$2,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 x{constructor(E,g,v,T,b,_,w){this.prop=E,this.propFunc=g,this.begin=T,this._pos=T,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=v,this._change=b-this.begin,this.pause()}fire(E){var g=this[E];g&&g()}setTime(E){E>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():E<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=E,this.update())}getTime(){return this._time}setPosition(E){this.prevPos=this._pos,this.propFunc(E),this._pos=E}getPosition(E){return E===void 0&&(E=this._time),this.func(E,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(E){this.pause(),this._time=E,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 E=this.getTimer()-this._startTime;this.state===h?this.setTime(E):this.state===f&&this.setTime(this.duration-E)}pause(){this.state=d,this.fire("onPause")}getTimer(){return new Date().getTime()}}class R{constructor(E){var g=this,v=E.node,T=v._id,b,_=E.easing||l.Easings.Linear,w=!!E.yoyo,C;typeof E.duration>"u"?b=.3:E.duration===0?b=.001:b=E.duration,this.node=v,this._id=u++;var P=v.getLayer()||(v instanceof a.Konva.Stage?v.getLayers():null);P||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()},P),this.tween=new x(C,function(D){g._tweenFunc(D)},_,0,1,b*1e3,w),this._addListeners(),R.attrs[T]||(R.attrs[T]={}),R.attrs[T][this._id]||(R.attrs[T][this._id]={}),R.tweens[T]||(R.tweens[T]={});for(C in E)o[C]===void 0&&this._addAttr(C,E[C]);this.reset(),this.onFinish=E.onFinish,this.onReset=E.onReset,this.onUpdate=E.onUpdate}_addAttr(E,g){var v=this.node,T=v._id,b,_,w,C,P,D,N,k;if(w=R.tweens[T][E],w&&delete R.attrs[T][w][E],b=v.getAttr(E),e.Util._isArray(g))if(_=[],P=Math.max(g.length,b.length),E==="points"&&g.length!==b.length&&(g.length>b.length?(N=b,b=e.Util._prepareArrayForTween(b,g,v.closed())):(D=g,g=e.Util._prepareArrayForTween(g,b,v.closed()))),E.indexOf("fill")===0)for(C=0;C<P;C++)if(C%2===0)_.push(g[C]-b[C]);else{var F=e.Util.colorToRGBA(b[C]);k=e.Util.colorToRGBA(g[C]),b[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<P;C++)_.push(g[C]-b[C]);else p.indexOf(E)!==-1?(b=e.Util.colorToRGBA(b),k=e.Util.colorToRGBA(g),_={r:k.r-b.r,g:k.g-b.g,b:k.b-b.b,a:k.a-b.a}):_=g-b;R.attrs[T][this._id][E]={start:b,diff:_,end:g,trueEnd:D,trueStart:N},R.tweens[T][E]=this._id}_tweenFunc(E){var g=this.node,v=R.attrs[g._id][this._id],T,b,_,w,C,P,D,N;for(T in v){if(b=v[T],_=b.start,w=b.diff,N=b.end,e.Util._isArray(_))if(C=[],D=Math.max(_.length,N.length),T.indexOf("fill")===0)for(P=0;P<D;P++)P%2===0?C.push((_[P]||0)+w[P]*E):C.push("rgba("+Math.round(_[P].r+w[P].r*E)+","+Math.round(_[P].g+w[P].g*E)+","+Math.round(_[P].b+w[P].b*E)+","+(_[P].a+w[P].a*E)+")");else for(P=0;P<D;P++)C.push((_[P]||0)+w[P]*E);else p.indexOf(T)!==-1?C="rgba("+Math.round(_.r+w.r*E)+","+Math.round(_.g+w.g*E)+","+Math.round(_.b+w.b*E)+","+(_.a+w.a*E)+")":C=_+w*E;g.setAttr(T,C)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var E=this.node,g=R.attrs[E._id][this._id];g.points&&g.points.trueEnd&&E.setAttr("points",g.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var E=this.node,g=R.attrs[E._id][this._id];g.points&&g.points.trueStart&&E.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(E){return this.tween.seek(E*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var E=this.node._id,g=this._id,v=R.tweens[E],T;this.pause();for(T in v)delete R.tweens[E][T];delete R.attrs[E][g]}}l.Tween=R,R.attrs={},R.tweens={},t.Node.prototype.to=function(S){var E=S.onFinish;S.node=this,S.onFinish=function(){this.destroy(),E&&E()};var g=new R(S);g.play()},l.Easings={BackEaseIn(S,E,g,v){var T=1.70158;return g*(S/=v)*S*((T+1)*S-T)+E},BackEaseOut(S,E,g,v){var T=1.70158;return g*((S=S/v-1)*S*((T+1)*S+T)+1)+E},BackEaseInOut(S,E,g,v){var T=1.70158;return(S/=v/2)<1?g/2*(S*S*(((T*=1.525)+1)*S-T))+E:g/2*((S-=2)*S*(((T*=1.525)+1)*S+T)+2)+E},ElasticEaseIn(S,E,g,v,T,b){var _=0;return S===0?E:(S/=v)===1?E+g:(b||(b=v*.3),!T||T<Math.abs(g)?(T=g,_=b/4):_=b/(2*Math.PI)*Math.asin(g/T),-(T*Math.pow(2,10*(S-=1))*Math.sin((S*v-_)*(2*Math.PI)/b))+E)},ElasticEaseOut(S,E,g,v,T,b){var _=0;return S===0?E:(S/=v)===1?E+g:(b||(b=v*.3),!T||T<Math.abs(g)?(T=g,_=b/4):_=b/(2*Math.PI)*Math.asin(g/T),T*Math.pow(2,-10*S)*Math.sin((S*v-_)*(2*Math.PI)/b)+g+E)},ElasticEaseInOut(S,E,g,v,T,b){var _=0;return S===0?E:(S/=v/2)===2?E+g:(b||(b=v*(.3*1.5)),!T||T<Math.abs(g)?(T=g,_=b/4):_=b/(2*Math.PI)*Math.asin(g/T),S<1?-.5*(T*Math.pow(2,10*(S-=1))*Math.sin((S*v-_)*(2*Math.PI)/b))+E:T*Math.pow(2,-10*(S-=1))*Math.sin((S*v-_)*(2*Math.PI)/b)*.5+g+E)},BounceEaseOut(S,E,g,v){return(S/=v)<1/2.75?g*(7.5625*S*S)+E:S<2/2.75?g*(7.5625*(S-=1.5/2.75)*S+.75)+E:S<2.5/2.75?g*(7.5625*(S-=2.25/2.75)*S+.9375)+E:g*(7.5625*(S-=2.625/2.75)*S+.984375)+E},BounceEaseIn(S,E,g,v){return g-l.Easings.BounceEaseOut(v-S,0,g,v)+E},BounceEaseInOut(S,E,g,v){return S<v/2?l.Easings.BounceEaseIn(S*2,0,g,v)*.5+E:l.Easings.BounceEaseOut(S*2-v,0,g,v)*.5+g*.5+E},EaseIn(S,E,g,v){return g*(S/=v)*S+E},EaseOut(S,E,g,v){return-g*(S/=v)*(S-2)+E},EaseInOut(S,E,g,v){return(S/=v/2)<1?g/2*S*S+E:-g/2*(--S*(S-2)-1)+E},StrongEaseIn(S,E,g,v){return g*(S/=v)*S*S*S*S+E},StrongEaseOut(S,E,g,v){return g*((S=S/v-1)*S*S*S*S+1)+E},StrongEaseInOut(S,E,g,v){return(S/=v/2)<1?g/2*S*S*S*S*S+E:g/2*((S-=2)*S*S*S*S+2)+E},Linear(S,E,g,v){return g*S/v+E}}})(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,x=Animation$2,R=Tween$1,S=Context$2,E=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:x.Animation,Tween:R.Tween,Easings:R.Easings,Context:S.Context,Canvas:E.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,x=h*(h>0?e:n),R=f*(f>0?n:e);return{x:u,y:t?-1*R:x,width:p-u,height:R-x}}}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),x=n-u*(a-l),R=t-u*(o-e),S=n+p*(a-l),E=t+p*(o-e);return[x,R,S,E]}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,x;u=f/2,p=0;for(let S=0;S<20;S++)x=u*l.tValues[20][S]+u,p+=l.cValues[20][S]*t(d,h,x);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],x=2*d[1]-2*d[0],R=2*h[1]-2*h[0],S=4*(u*u+p*p),E=4*(u*x+p*R),g=x*x+R*R;if(S===0)return f*Math.sqrt(Math.pow(d[2]-d[0],2)+Math.pow(h[2]-h[0],2));const v=E/(2*S),T=g/S,b=f+v,_=T-v*v,w=b*b+_>0?Math.sqrt(b*b+_):0,C=v*v+_>0?Math.sqrt(v*v+_):0,P=v+Math.sqrt(v*v+_)!==0?_*Math.log(Math.abs((b+w)/(v+C))):0;return Math.sqrt(S)/2*(b*w-v*C+P)};l.getQuadraticArcLength=n;function t(d,h,f){const u=a(1,f,d),p=a(1,f,h),x=u*u+p*p;return Math.sqrt(x)}const a=(d,h,f)=>{const u=f.length-1;let p,x;if(u===0)return 0;if(d===0){x=0;for(let R=0;R<=u;R++)x+=l.binomialCoefficients[u][R]*Math.pow(1-h,u-R)*Math.pow(h,R)*f[R];return x}else{p=new Array(u);for(let R=0;R<u;R++)p[R]=u*(f[R+1]-f[R]);return a(d-1,h,p)}},o=(d,h,f)=>{let u=1,p=d/h,x=(d-f(p))/h,R=0;for(;u>.001;){const S=f(p+x),E=Math.abs(d-S)/h;if(E<u)u=E,p+=x;else{const g=f(p-x),v=Math.abs(d-g)/h;v<u?(u=v,p-=x):x/=2}if(R++,R>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],x=d[4],R=d[5],S=d[6],E=d[7],g=u>p?u:p,v=u>p?1:u/p,T=u>p?p/u:1;e.translate(h,f),e.rotate(S),e.scale(v,T),e.arc(0,0,g,x,x+R,1-E),e.scale(1/v,1/T),e.rotate(-S),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],x=u.points[5],R=u.points[4]+x,S=Math.PI/180;if(Math.abs(p-R)<S&&(S=Math.abs(p-R)),x<0)for(let E=p-S;E>R;E-=S){const g=Path.getPointOnEllipticalArc(u.points[0],u.points[1],u.points[2],u.points[3],E,0);e.push(g.x,g.y)}else for(let E=p+S;E<R;E+=S){const g=Path.getPointOnEllipticalArc(u.points[0],u.points[1],u.points[2],u.points[3],E,0);e.push(g.x,g.y)}}else if(u.command==="C")for(let E=0;E<=1;E+=.01){const g=Path.getPointOnCubicBezier(E,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],x=h[3],R=h[4],S=h[5],E=h[6];return R+=S*e/d.pathLength,Path.getPointOnEllipticalArc(f,u,p,x,R,E)}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,x;if(a===n)x={x:d,y:h+p};else if((h-t)/(d-n+1e-8)===f)x={x:d+u,y:h+p};else{var R,S,E=this.getLineLength(n,t,a,o),g=(d-n)*(a-n)+(h-t)*(o-t);g=g/(E*E),R=n+g*(a-n),S=t+g*(o-t);var v=this.getLineLength(d,h,R,S),T=Math.sqrt(e*e-v*v);u=Math.sqrt(T*T/(1+f*f)),a<n&&(u*=-1),p=f*u,x={x:R+u,y:S+p}}return x}static getPointOnCubicBezier(e,n,t,a,o,d,h,f,u){function p(v){return v*v*v}function x(v){return 3*v*v*(1-v)}function R(v){return 3*v*(1-v)*(1-v)}function S(v){return(1-v)*(1-v)*(1-v)}var E=f*p(e)+d*x(e)+a*R(e)+n*S(e),g=u*p(e)+h*x(e)+o*R(e)+t*S(e);return{x:E,y:g}}static getPointOnQuadraticBezier(e,n,t,a,o,d,h){function f(S){return S*S}function u(S){return 2*S*(1-S)}function p(S){return(1-S)*(1-S)}var x=d*f(e)+a*u(e)+n*p(e),R=h*f(e)+o*u(e)+t*p(e);return{x,y:R}}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,x;for(a=1;a<o.length;a++){var R=o[a],S=R.charAt(0);for(R=R.slice(1),h.length=0;x=p.exec(R);)h.push(x[0]);for(var E=[],g=0,v=h.length;g<v;g++){if(h[g]==="00"){E.push(0,0);continue}var T=parseFloat(h[g]);isNaN(T)?E.push(0):E.push(T)}for(;E.length>0&&!isNaN(E[0]);){var b="",_=[],w=f,C=u,P,D,N,k,F,M,U,$,B,J;switch(S){case"l":f+=E.shift(),u+=E.shift(),b="L",_.push(f,u);break;case"L":f=E.shift(),u=E.shift(),_.push(f,u);break;case"m":var ne=E.shift(),ie=E.shift();if(f+=ne,u+=ie,b="M",d.length>2&&d[d.length-1].command==="z"){for(var Y=d.length-2;Y>=0;Y--)if(d[Y].command==="M"){f=d[Y].points[0]+ne,u=d[Y].points[1]+ie;break}}_.push(f,u),S="l";break;case"M":f=E.shift(),u=E.shift(),b="M",_.push(f,u),S="L";break;case"h":f+=E.shift(),b="L",_.push(f,u);break;case"H":f=E.shift(),b="L",_.push(f,u);break;case"v":u+=E.shift(),b="L",_.push(f,u);break;case"V":u=E.shift(),b="L",_.push(f,u);break;case"C":_.push(E.shift(),E.shift(),E.shift(),E.shift()),f=E.shift(),u=E.shift(),_.push(f,u);break;case"c":_.push(f+E.shift(),u+E.shift(),f+E.shift(),u+E.shift()),f+=E.shift(),u+=E.shift(),b="C",_.push(f,u);break;case"S":D=f,N=u,P=d[d.length-1],P.command==="C"&&(D=f+(f-P.points[2]),N=u+(u-P.points[3])),_.push(D,N,E.shift(),E.shift()),f=E.shift(),u=E.shift(),b="C",_.push(f,u);break;case"s":D=f,N=u,P=d[d.length-1],P.command==="C"&&(D=f+(f-P.points[2]),N=u+(u-P.points[3])),_.push(D,N,f+E.shift(),u+E.shift()),f+=E.shift(),u+=E.shift(),b="C",_.push(f,u);break;case"Q":_.push(E.shift(),E.shift()),f=E.shift(),u=E.shift(),_.push(f,u);break;case"q":_.push(f+E.shift(),u+E.shift()),f+=E.shift(),u+=E.shift(),b="Q",_.push(f,u);break;case"T":D=f,N=u,P=d[d.length-1],P.command==="Q"&&(D=f+(f-P.points[0]),N=u+(u-P.points[1])),f=E.shift(),u=E.shift(),b="Q",_.push(D,N,f,u);break;case"t":D=f,N=u,P=d[d.length-1],P.command==="Q"&&(D=f+(f-P.points[0]),N=u+(u-P.points[1])),f+=E.shift(),u+=E.shift(),b="Q",_.push(D,N,f,u);break;case"A":k=E.shift(),F=E.shift(),M=E.shift(),U=E.shift(),$=E.shift(),B=f,J=u,f=E.shift(),u=E.shift(),b="A",_=this.convertEndpointToCenterParameterization(B,J,f,u,U,$,k,F,M);break;case"a":k=E.shift(),F=E.shift(),M=E.shift(),U=E.shift(),$=E.shift(),B=f,J=u,f+=E.shift(),u+=E.shift(),b="A",_=this.convertEndpointToCenterParameterization(B,J,f,u,U,$,k,F,M);break}d.push({command:b||S,points:_,start:{x:w,y:C},pathLength:this.calcLength(w,C,b||S,_)})}(S==="z"||S==="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],x=a[5],R=a[4]+x,S=Math.PI/180;if(Math.abs(p-R)<S&&(S=Math.abs(p-R)),d=u.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],p,0),x<0)for(f=p-S;f>R;f-=S)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+S;f<R;f+=S)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],R,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),x=Math.cos(p)*(e-t)/2+Math.sin(p)*(n-a)/2,R=-1*Math.sin(p)*(e-t)/2+Math.cos(p)*(n-a)/2,S=x*x/(h*h)+R*R/(f*f);S>1&&(h*=Math.sqrt(S),f*=Math.sqrt(S));var E=Math.sqrt((h*h*(f*f)-h*h*(R*R)-f*f*(x*x))/(h*h*(R*R)+f*f*(x*x)));o===d&&(E*=-1),isNaN(E)&&(E=0);var g=E*h*R/f,v=E*-f*x/h,T=(e+t)/2+Math.cos(p)*g-Math.sin(p)*v,b=(n+a)/2+Math.sin(p)*g+Math.cos(p)*v,_=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))},P=C([1,0],[(x-g)/h,(R-v)/f]),D=[(x-g)/h,(R-v)/f],N=[(-1*x-g)/h,(-1*R-v)/f],k=C(D,N);return w(D,N)<=-1&&(k=Math.PI),w(D,N)>=1&&(k=0),d===0&&k>0&&(k=k-2*Math.PI),d===1&&k<0&&(k=k+2*Math.PI),[T,b,h,f,P,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 R=[a[a.length-4],a[a.length-3],a[a.length-2],a[a.length-1],t[h-2],t[h-1]],S=Path_1$2.Path.calcLength(a[a.length-4],a[a.length-3],"C",R),E=Path_1$2.Path.getPointOnQuadraticBezier(Math.min(1,1-d/S),R[0],R[1],R[2],R[3],R[4],R[5]);f=t[h-2]-E.x,u=t[h-1]-E.y}else f=t[h-2]-t[h-4],u=t[h-1]-t[h-3];var p=(Math.atan2(u,f)+n)%n,x=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,x/2),e.lineTo(-d,-x/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,x/2),e.lineTo(-d,-x/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,x=0;typeof h=="number"?f=u=p=x=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),x=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-x),e.arc(n-x,t-x,x,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$2,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],x=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,u,p),e.closePath(),e.fillStrokeShape(this)),x)if(d){var R=d[n],S=t*2;e.drawImage(x,h,f,u,p,R[S+0],R[S+1],u,p)}else e.drawImage(x,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(),x=this.getWidth(),R=this.letterSpacing(),S=this.fill(),E=this.textDecoration(),g=E.indexOf("underline")!==-1,v=E.indexOf("line-through")!==-1,T;f=f===INHERIT?e.direction:f;var b=0,b=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),T=0;T<t;T++){var _=0,w=0,C=n[T],P=C.text,D=C.width,N=C.lastInParagraph,k,F,M;if(e.save(),p===RIGHT?_+=x-D-a*2:p===CENTER&&(_+=(x-D-a*2)/2),g){e.save(),e.beginPath(),e.moveTo(_,b+w+Math.round(o/2)),k=P.split(" ").length-1,F=k===0,M=p===JUSTIFY&&!N?x-a*2:D,e.lineTo(_+Math.round(M),b+w+Math.round(o/2)),e.lineWidth=o/15;const ie=this._getLinearGradient();e.strokeStyle=ie||S,e.stroke(),e.restore()}if(v){e.save(),e.beginPath(),e.moveTo(_,b+w),k=P.split(" ").length-1,F=k===0,M=p===JUSTIFY&&N&&!F?x-a*2:D,e.lineTo(_+Math.round(M),b+w),e.lineWidth=o/15;const ie=this._getLinearGradient();e.strokeStyle=ie||S,e.stroke(),e.restore()}if(f!==RTL&&(R!==0||p===JUSTIFY)){k=P.split(" ").length-1;for(var U=stringToArray(P),$=0;$<U.length;$++){var B=U[$];B===" "&&!N&&p===JUSTIFY&&(_+=(x-a*2-D)/k),this._partialTextX=_,this._partialTextY=b+w,this._partialText=B,e.fillStrokeShape(this),_+=this.measureSize(B).width+R}}else R!==0&&e.setAttr("letterSpacing",`${R}px`),this._partialTextX=_,this._partialTextY=b+w,this._partialText=P,e.fillStrokeShape(this);e.restore(),t>1&&(b+=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,x=d-u*2,R=0,S=this.wrap(),E=S!==NONE,g=S!==CHAR&&E,v=this.ellipsis();this.textArr=[],getDummyContext().font=this._getContextFont();for(var T=v?this._getTextWidth(ELLIPSIS):0,b=0,_=e.length;b<_;++b){var w=e[b],C=this._getTextWidth(w);if(h&&C>p)for(;w.length>0;){for(var P=0,D=w.length,N="",k=0;P<D;){var F=P+D>>>1,M=w.slice(0,F+1),U=this._getTextWidth(M)+T;U<=p?(P=F+1,N=M,k=U):D=F}if(N){if(g){var $,B=w[N.length],J=B===SPACE||B===DASH;J&&k<=p?$=N.length:$=Math.max(N.lastIndexOf(SPACE),N.lastIndexOf(DASH))+1,$>0&&(P=$,N=N.slice(0,P),k=this._getTextWidth(N))}N=N.trimRight(),this._addTextLine(N),t=Math.max(t,k),R+=a;var ne=this._shouldHandleEllipsis(R);if(ne){this._tryToAddEllipsisToLastLine();break}if(w=w.slice(P),w=w.trimLeft(),w.length>0&&(C=this._getTextWidth(w),C<=p)){this._addTextLine(w),R+=a,t=Math.max(t,C);break}}else break}else this._addTextLine(w),R+=a,t=Math.max(t,C),this._shouldHandleEllipsis(R)&&b<_-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),f&&R+a>x)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 x=this._getPointAtLength(u);if(!x)return;let R=this._getTextSize(f[p]).width+t;if(f[p]===" "&&a==="justify"){const b=this.text().split(" ").length-1;R+=(this.pathLength-d)/b}const S=this._getPointAtLength(u+R);if(!S)return;const E=Path_1$1.Path.getLineLength(x.x,x.y,S.x,S.y);let g=0;if(o)try{g=o(f[p-1],f[p])*this.fontSize()}catch{g=0}x.x+=g,S.x+=g,this.textWidth+=g;const v=Path_1$1.Path.getPointOnLine(g+E/2,x.x,x.y,S.x,S.y),T=Math.atan2(S.y-x.y,S.x-x.x);this.glyphInfo.push({transposeX:v.x,transposeY:v.y,text:f[p],rotation:T,p0:x,p1:S}),u+=R}}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 x=[{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}],R=u.getAbsoluteTransform();x.forEach(function(S){var E=R.point(S);n.push(E)})});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 x=this._getNodeRect();n=o.x()-x.width/2,t=-o.y()+x.height/2;let $=Math.atan2(-t,n)+Math.PI/2;x.height<0&&($-=Math.PI);var R=Global_1$1.Konva.getAngle(this.rotation());const B=R+$,J=Global_1$1.Konva.getAngle(this.rotationSnapTolerance()),ie=getSnap(this.rotationSnaps(),B,J)-x.rotation,Y=rotateAroundCenter(x,ie);this._fitNodesInto(Y,e);return}var S=this.shiftBehavior(),E;S==="inverted"?E=this.keepRatio()&&!e.shiftKey:S==="none"?E=this.keepRatio():E=this.keepRatio()||e.shiftKey;var _=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(E){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 v=this.findOne(".top-left").x()>g.x?-1:1,T=this.findOne(".top-left").y()>g.y?-1:1;n=a*this.cos*v,t=a*this.sin*T,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(E){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 v=this.findOne(".top-right").x()<g.x?-1:1,T=this.findOne(".top-right").y()>g.y?-1:1;n=a*this.cos*v,t=a*this.sin*T,this.findOne(".top-right").x(g.x+n),this.findOne(".top-right").y(g.y-t)}var b=o.position();this.findOne(".top-left").y(b.y),this.findOne(".bottom-right").x(b.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(E){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 v=g.x<o.x()?-1:1,T=o.y()<g.y?-1:1;n=a*this.cos*v,t=a*this.sin*T,o.x(g.x-n),o.y(g.y+t)}b=o.position(),this.findOne(".top-left").x(b.x),this.findOne(".bottom-right").y(b.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(E){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 v=this.findOne(".bottom-right").x()<g.x?-1:1,T=this.findOne(".bottom-right").y()<g.y?-1:1;n=a*this.cos*v,t=a*this.sin*T,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"),P=w.x(),D=w.y(),N=this.getWidth()-C.x(),k=this.getHeight()-C.y();C.move({x:-P,y:-D}),w.move({x:N,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(),U=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:n,y:t,width:M,height:U,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 R=o.point({x:-this.padding()*2,y:0});e.x+=R.x,e.y+=R.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=R.x,this._anchorDragOffset.y-=R.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const R=o.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=R.x,this._anchorDragOffset.y-=R.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const R=o.point({x:0,y:-this.padding()*2});e.x+=R.x,e.y+=R.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=R.x,this._anchorDragOffset.y-=R.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const R=o.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=R.x,this._anchorDragOffset.y-=R.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const R=this.boundBoxFunc()(t,e);R?e=R: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 x=f.multiply(h.invert());this._nodes.forEach(R=>{var S;const E=R.getParent().getAbsoluteTransform(),g=R.getTransform().copy();g.translate(R.offsetX(),R.offsetY());const v=new Util_1$3.Transform;v.multiply(E.copy().invert()).multiply(x).multiply(E).multiply(g);const T=v.decompose();R.setAttrs(T),this._fire("transform",{evt:n,target:R}),R._fire("transform",{evt:n,target:R}),(S=R.getLayer())===null||S===void 0||S.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(x=>{x.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(x=>{p(x)}),(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,x,R,S,E,g,v,T,b,_,w,C,P,D,N,k,F,M,U,$=e+e+1,B=t-1,J=a-1,ne=e+1,ie=ne*(ne+1)/2,Y=new BlurStack,q=null,re=Y,ce=null,fe=null,te=mul_table[e],H=shg_table[e];for(h=1;h<$;h++)re=re.next=new BlurStack,h===ne&&(q=re);for(re.next=Y,x=p=0,d=0;d<a;d++){for(w=C=P=D=R=S=E=g=0,v=ne*(N=n[p]),T=ne*(k=n[p+1]),b=ne*(F=n[p+2]),_=ne*(M=n[p+3]),R+=ie*N,S+=ie*k,E+=ie*F,g+=ie*M,re=Y,h=0;h<ne;h++)re.r=N,re.g=k,re.b=F,re.a=M,re=re.next;for(h=1;h<ne;h++)f=p+((B<h?B:h)<<2),R+=(re.r=N=n[f])*(U=ne-h),S+=(re.g=k=n[f+1])*U,E+=(re.b=F=n[f+2])*U,g+=(re.a=M=n[f+3])*U,w+=N,C+=k,P+=F,D+=M,re=re.next;for(ce=Y,fe=q,o=0;o<t;o++)n[p+3]=M=g*te>>H,M!==0?(M=255/M,n[p]=(R*te>>H)*M,n[p+1]=(S*te>>H)*M,n[p+2]=(E*te>>H)*M):n[p]=n[p+1]=n[p+2]=0,R-=v,S-=T,E-=b,g-=_,v-=ce.r,T-=ce.g,b-=ce.b,_-=ce.a,f=x+((f=o+e+1)<B?f:B)<<2,w+=ce.r=n[f],C+=ce.g=n[f+1],P+=ce.b=n[f+2],D+=ce.a=n[f+3],R+=w,S+=C,E+=P,g+=D,ce=ce.next,v+=N=fe.r,T+=k=fe.g,b+=F=fe.b,_+=M=fe.a,w-=N,C-=k,P-=F,D-=M,fe=fe.next,p+=4;x+=t}for(o=0;o<t;o++){for(C=P=D=w=S=E=g=R=0,p=o<<2,v=ne*(N=n[p]),T=ne*(k=n[p+1]),b=ne*(F=n[p+2]),_=ne*(M=n[p+3]),R+=ie*N,S+=ie*k,E+=ie*F,g+=ie*M,re=Y,h=0;h<ne;h++)re.r=N,re.g=k,re.b=F,re.a=M,re=re.next;for(u=t,h=1;h<=e;h++)p=u+o<<2,R+=(re.r=N=n[p])*(U=ne-h),S+=(re.g=k=n[p+1])*U,E+=(re.b=F=n[p+2])*U,g+=(re.a=M=n[p+3])*U,w+=N,C+=k,P+=F,D+=M,re=re.next,h<J&&(u+=t);for(p=o,ce=Y,fe=q,d=0;d<a;d++)f=p<<2,n[f+3]=M=g*te>>H,M>0?(M=255/M,n[f]=(R*te>>H)*M,n[f+1]=(S*te>>H)*M,n[f+2]=(E*te>>H)*M):n[f]=n[f+1]=n[f+2]=0,R-=v,S-=T,E-=b,g-=_,v-=ce.r,T-=ce.g,b-=ce.b,_-=ce.a,f=o+((f=d+ne)<J?f:J)*t<<2,R+=w+=ce.r=n[f],S+=C+=ce.g=n[f+1],E+=P+=ce.b=n[f+2],g+=D+=ce.a=n[f+3],ce=ce.next,v+=N=fe.r,T+=k=fe.g,b+=F=fe.b,_+=M=fe.a,w-=N,C-=k,P-=F,D-=M,fe=fe.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,x=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 R=(x-1)*p,S=o;x+S<1&&(S=0),x+S>u&&(S=0);var E=(x-1+S)*f*4,g=f;do{var v=R+(g-1)*4,T=d;g+T<1&&(T=0),g+T>f&&(T=0);var b=E+(g-1+T)*4,_=h[v]-h[b],w=h[v+1]-h[b+1],C=h[v+2]-h[b+2],P=_,D=P>0?P:-P,N=w>0?w:-w,k=C>0?C:-C;if(N>D&&(P=w),k>D&&(P=C),P*=e,a){var F=h[v]+P,M=h[v+1]+P,U=h[v+2]+P;h[v]=F>255?255:F<0?0:F,h[v+1]=M>255?255:M<0?0:M,h[v+2]=U>255?255:U<0?0:U}else{var $=n-P;$<0?$=0:$>255&&($=255),h[v]=h[v+1]=h[v+2]=$}}while(--g)}while(--x)};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,x,R,S=this.enhance();if(S!==0){for(R=0;R<n;R+=4)o=e[R+0],o<t?t=o:o>a&&(a=o),f=e[R+1],f<d?d=f:f>h&&(h=f),x=e[R+2],x<u?u=x:x>p&&(p=x);a===t&&(a=255,t=0),h===d&&(h=255,d=0),p===u&&(p=255,u=0);var E,g,v,T,b,_,w,C,P;for(S>0?(g=a+S*(255-a),v=t-S*(t-0),b=h+S*(255-h),_=d-S*(d-0),C=p+S*(255-p),P=u-S*(u-0)):(E=(a+t)*.5,g=a+S*(a-E),v=t+S*(t-E),T=(h+d)*.5,b=h+S*(h-T),_=d+S*(d-T),w=(p+u)*.5,C=p+S*(p-w),P=u+S*(u-w)),R=0;R<n;R+=4)e[R+0]=remap(e[R+0],t,a,v,g),e[R+1]=remap(e[R+1],d,h,_,b),e[R+2]=remap(e[R+2],u,p,P,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,x=.587*t-.587*f+.33*u,R=.114*t-.114*f-.497*u,S=.299*t-.299*f-.328*u,E=.587*t+.413*f+.035*u,g=.114*t-.114*f+.293*u,v=.299*t-.3*f+1.25*u,T=.587*t-.586*f-1.05*u,b=.114*t+.886*f-.2*u,_,w,C,P;for(h=0;h<n;h+=4)_=e[h+0],w=e[h+1],C=e[h+2],P=e[h+3],e[h+0]=p*_+x*w+R*C+d,e[h+1]=S*_+E*w+g*C+d,e[h+2]=v*_+T*w+b*C+d,e[h+3]=P};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,x=.114*t-.114*h-.497*f,R=.299*t-.299*h-.328*f,S=.587*t+.413*h+.035*f,E=.114*t-.114*h+.293*f,g=.299*t-.3*h+1.25*f,v=.587*t-.586*h-1.05*f,T=.114*t+.886*h-.2*f,b,_,w,C;for(d=0;d<n;d+=4)b=e[d+0],_=e[d+1],w=e[d+2],C=e[d+3],e[d+0]=u*b+p*_+x*w,e[d+1]=R*b+S*_+E*w,e[d+2]=g*b+v*_+T*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,x,R=0,S=0,E=0,g=0,v,T=Math.sqrt(h*h+f*f);p=o-h,x=d-f,v=Math.sqrt(p*p+x*x),T=v>T?v:T;var b=d,_=o,w,C,P=360/_*Math.PI/180,D,N;for(C=0;C<_;C+=1)for(D=Math.sin(C*P),N=Math.cos(C*P),w=0;w<b;w+=1)p=Math.floor(h+T*w/b*N),x=Math.floor(f+T*w/b*D),u=(x*o+p)*4,R=t[u+0],S=t[u+1],E=t[u+2],g=t[u+3],u=(C+w*o)*4,a[u+0]=R,a[u+1]=S,a[u+2]=E,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,x,R,S,E=0,g=0,v=0,T=0,b,_=Math.sqrt(h*h+f*f);p=o-h,x=d-f,b=Math.sqrt(p*p+x*x),_=b>_?b:_;var w=d,C=o,P,D,N=n.polarRotation||0,k,F;for(p=0;p<o;p+=1)for(x=0;x<d;x+=1)R=p-h,S=x-f,P=Math.sqrt(R*R+S*S)*w/_,D=(Math.atan2(S,R)*180/Math.PI+360+N)%360,D=D*C/360,k=Math.floor(D),F=Math.floor(P),u=(F*o+k)*4,E=t[u+0],g=t[u+1],v=t[u+2],T=t[u+3],u=(x*o+p)*4,a[u+0]=E,a[u+1]=g,a[u+2]=v,a[u+3]=T};const Kaleidoscope=function(l){var e=l.width,n=l.height,t,a,o,d,h,f,u,p,x,R,S=Math.round(this.kaleidoscopePower()),E=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(E%360)/360);if(!(S<1)){var v=Util_1$1.Util.createCanvasElement();v.width=e,v.height=n;var T=v.getContext("2d").getImageData(0,0,e,n);Util_1$1.Util.releaseCanvas(v),ToPolar(l,T,{polarCenterX:e/2,polarCenterY:n/2});for(var b=e/Math.pow(2,S);b<=8;)b=b*2,S-=1;b=Math.ceil(b);var _=b,w=0,C=_,P=1;for(g+b>e&&(w=_,C=0,P=-1),a=0;a<n;a+=1)for(t=w;t!==C;t+=P)o=Math.round(t+g)%e,x=(e*a+o)*4,h=T.data[x+0],f=T.data[x+1],u=T.data[x+2],p=T.data[x+3],R=(e*a+t)*4,T.data[R+0]=h,T.data[R+1]=f,T.data[R+2]=u,T.data[R+3]=p;for(a=0;a<n;a+=1)for(_=Math.floor(b),d=0;d<S;d+=1){for(t=0;t<_+1;t+=1)x=(e*a+t)*4,h=T.data[x+0],f=T.data[x+1],u=T.data[x+2],p=T.data[x+3],R=(e*a+_*2-t-1)*4,T.data[R+0]=h,T.data[R+1]=f,T.data[R+2]=u,T.data[R+3]=p;_*=2}FromPolar(T,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,x=0;x<a;x++)for(var R=0;R<a;R++){var S=h+x-o,E=f+R-o;if(S>=0&&S<n&&E>=0&&E<e){var g=S*e+E,v=t[x*a+R];p+=l[g]*v}}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,x=0;x<a;x++)for(var R=0;R<a;R++){var S=h+x-o,E=f+R-o;if(S>=0&&S<n&&E>=0&&E<e){var g=S*e+E,v=t[x*a+R];p+=l[g]*v}}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,x=0;x<a;x++)for(var R=0;R<a;R++){var S=h+x-o,E=f+R-o;if(S>=0&&S<n&&E>=0&&E<e){var g=S*e+E,v=t[x*a+R];p+=l[g]*v}}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,x=Math.ceil(n/e),R=Math.ceil(t/e),S,E,g,v,T,b,_,w=l.data;if(e<=0){Util_1.Util.error("pixelSize value can not be <= 0");return}for(T=0;T<x;T+=1)for(b=0;b<R;b+=1){for(h=0,f=0,u=0,p=0,S=T*e,E=S+e,g=b*e,v=g+e,_=0,a=S;a<E;a+=1)if(!(a>=n))for(o=g;o<v;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=S;a<E;a+=1)if(!(a>=n))for(o=g;o<v;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],x=e[f+2];u>127&&(u=255-u),p>127&&(p=255-p),x>127&&(x=255-x),e[f]=u,e[f+1]=p,e[f+2]=x}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={};/**
73
73
  * @license React
74
74
  * scheduler.production.min.js