@gamelearn/arcade-components 3.0.3 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,7 @@ object-assign
49
49
  */var objectAssign,hasRequiredObjectAssign;function requireObjectAssign(){if(hasRequiredObjectAssign)return objectAssign;hasRequiredObjectAssign=1;var o=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function t(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function n(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var l={},u=0;u<10;u++)l["_"+String.fromCharCode(u)]=u;var f=Object.getOwnPropertyNames(l).map(function(h){return l[h]});if(f.join("")!=="0123456789")return!1;var d={};return"abcdefghijklmnopqrst".split("").forEach(function(h){d[h]=h}),Object.keys(Object.assign({},d)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return objectAssign=n()?Object.assign:function(a,l){for(var u,f=t(a),d,h=1;h<arguments.length;h++){u=Object(arguments[h]);for(var y in u)e.call(u,y)&&(f[y]=u[y]);if(o){d=o(u);for(var E=0;E<d.length;E++)r.call(u,d[E])&&(f[d[E]]=u[d[E]])}}return f},objectAssign}var ReactPropTypesSecret_1$1,hasRequiredReactPropTypesSecret$1;function requireReactPropTypesSecret$1(){if(hasRequiredReactPropTypesSecret$1)return ReactPropTypesSecret_1$1;hasRequiredReactPropTypesSecret$1=1;var o="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ReactPropTypesSecret_1$1=o,ReactPropTypesSecret_1$1}var has,hasRequiredHas;function requireHas(){return hasRequiredHas||(hasRequiredHas=1,has=Function.call.bind(Object.prototype.hasOwnProperty)),has}var checkPropTypes_1$1,hasRequiredCheckPropTypes$1;function requireCheckPropTypes$1(){if(hasRequiredCheckPropTypes$1)return checkPropTypes_1$1;hasRequiredCheckPropTypes$1=1;var o=function(){};if(process.env.NODE_ENV!=="production"){var e=requireReactPropTypesSecret$1(),r={},t=requireHas();o=function(a){var l="Warning: "+a;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}}}function n(a,l,u,f,d){if(process.env.NODE_ENV!=="production"){for(var h in a)if(t(a,h)){var y;try{if(typeof a[h]!="function"){var E=Error((f||"React class")+": "+u+" type `"+h+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[h]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw E.name="Invariant Violation",E}y=a[h](l,h,f,u,null,e)}catch(_){y=_}if(y&&!(y instanceof Error)&&o((f||"React class")+": type specification of "+u+" `"+h+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof y+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),y instanceof Error&&!(y.message in r)){r[y.message]=!0;var p=d?d():"";o("Failed "+u+" type: "+y.message+(p??""))}}}}return n.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(r={})},checkPropTypes_1$1=n,checkPropTypes_1$1}var factoryWithTypeCheckers$1,hasRequiredFactoryWithTypeCheckers$1;function requireFactoryWithTypeCheckers$1(){if(hasRequiredFactoryWithTypeCheckers$1)return factoryWithTypeCheckers$1;hasRequiredFactoryWithTypeCheckers$1=1;var o=requireReactIs(),e=requireObjectAssign(),r=requireReactPropTypesSecret$1(),t=requireHas(),n=requireCheckPropTypes$1(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(u){var f="Warning: "+u;typeof console<"u"&&console.error(f);try{throw new Error(f)}catch{}});function l(){return null}return factoryWithTypeCheckers$1=function(u,f){var d=typeof Symbol=="function"&&Symbol.iterator,h="@@iterator";function y(I){var B=I&&(d&&I[d]||I[h]);if(typeof B=="function")return B}var E="<<anonymous>>",p={array:C("array"),bigint:C("bigint"),bool:C("boolean"),func:C("function"),number:C("number"),object:C("object"),string:C("string"),symbol:C("symbol"),any:R(),arrayOf:S,element:A(),elementType:T(),instanceOf:w,node:D(),objectOf:O,oneOf:P,oneOfType:k,shape:G,exact:V};function _(I,B){return I===B?I!==0||1/I===1/B:I!==I&&B!==B}function g(I,B){this.message=I,this.data=B&&typeof B=="object"?B:{},this.stack=""}g.prototype=Error.prototype;function x(I){if(process.env.NODE_ENV!=="production")var B={},X=0;function Q(ne,ae,Z,se,oe,fe,de){if(se=se||E,fe=fe||Z,de!==r){if(f){var ce=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 ce.name="Invariant Violation",ce}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Ee=se+":"+Z;!B[Ee]&&X<3&&(a("You are manually calling a React.PropTypes validation function for the `"+fe+"` prop on `"+se+"`. 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."),B[Ee]=!0,X++)}}return ae[Z]==null?ne?ae[Z]===null?new g("The "+oe+" `"+fe+"` is marked as required "+("in `"+se+"`, but its value is `null`.")):new g("The "+oe+" `"+fe+"` is marked as required in "+("`"+se+"`, but its value is `undefined`.")):null:I(ae,Z,se,oe,fe)}var J=Q.bind(null,!1);return J.isRequired=Q.bind(null,!0),J}function C(I){function B(X,Q,J,ne,ae,Z){var se=X[Q],oe=q(se);if(oe!==I){var fe=z(se);return new g("Invalid "+ne+" `"+ae+"` of type "+("`"+fe+"` supplied to `"+J+"`, expected ")+("`"+I+"`."),{expectedType:I})}return null}return x(B)}function R(){return x(l)}function S(I){function B(X,Q,J,ne,ae){if(typeof I!="function")return new g("Property `"+ae+"` of component `"+J+"` has invalid PropType notation inside arrayOf.");var Z=X[Q];if(!Array.isArray(Z)){var se=q(Z);return new g("Invalid "+ne+" `"+ae+"` of type "+("`"+se+"` supplied to `"+J+"`, expected an array."))}for(var oe=0;oe<Z.length;oe++){var fe=I(Z,oe,J,ne,ae+"["+oe+"]",r);if(fe instanceof Error)return fe}return null}return x(B)}function A(){function I(B,X,Q,J,ne){var ae=B[X];if(!u(ae)){var Z=q(ae);return new g("Invalid "+J+" `"+ne+"` of type "+("`"+Z+"` supplied to `"+Q+"`, expected a single ReactElement."))}return null}return x(I)}function T(){function I(B,X,Q,J,ne){var ae=B[X];if(!o.isValidElementType(ae)){var Z=q(ae);return new g("Invalid "+J+" `"+ne+"` of type "+("`"+Z+"` supplied to `"+Q+"`, expected a single ReactElement type."))}return null}return x(I)}function w(I){function B(X,Q,J,ne,ae){if(!(X[Q]instanceof I)){var Z=I.name||E,se=$(X[Q]);return new g("Invalid "+ne+" `"+ae+"` of type "+("`"+se+"` supplied to `"+J+"`, expected ")+("instance of `"+Z+"`."))}return null}return x(B)}function P(I){if(!Array.isArray(I))return process.env.NODE_ENV!=="production"&&(arguments.length>1?a("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])."):a("Invalid argument supplied to oneOf, expected an array.")),l;function B(X,Q,J,ne,ae){for(var Z=X[Q],se=0;se<I.length;se++)if(_(Z,I[se]))return null;var oe=JSON.stringify(I,function(de,ce){var Ee=z(ce);return Ee==="symbol"?String(ce):ce});return new g("Invalid "+ne+" `"+ae+"` of value `"+String(Z)+"` "+("supplied to `"+J+"`, expected one of "+oe+"."))}return x(B)}function O(I){function B(X,Q,J,ne,ae){if(typeof I!="function")return new g("Property `"+ae+"` of component `"+J+"` has invalid PropType notation inside objectOf.");var Z=X[Q],se=q(Z);if(se!=="object")return new g("Invalid "+ne+" `"+ae+"` of type "+("`"+se+"` supplied to `"+J+"`, expected an object."));for(var oe in Z)if(t(Z,oe)){var fe=I(Z,oe,J,ne,ae+"."+oe,r);if(fe instanceof Error)return fe}return null}return x(B)}function k(I){if(!Array.isArray(I))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),l;for(var B=0;B<I.length;B++){var X=I[B];if(typeof X!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+U(X)+" at index "+B+"."),l}function Q(J,ne,ae,Z,se){for(var oe=[],fe=0;fe<I.length;fe++){var de=I[fe],ce=de(J,ne,ae,Z,se,r);if(ce==null)return null;ce.data&&t(ce.data,"expectedType")&&oe.push(ce.data.expectedType)}var Ee=oe.length>0?", expected one of type ["+oe.join(", ")+"]":"";return new g("Invalid "+Z+" `"+se+"` supplied to "+("`"+ae+"`"+Ee+"."))}return x(Q)}function D(){function I(B,X,Q,J,ne){return W(B[X])?null:new g("Invalid "+J+" `"+ne+"` supplied to "+("`"+Q+"`, expected a ReactNode."))}return x(I)}function F(I,B,X,Q,J){return new g((I||"React class")+": "+B+" type `"+X+"."+Q+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+J+"`.")}function G(I){function B(X,Q,J,ne,ae){var Z=X[Q],se=q(Z);if(se!=="object")return new g("Invalid "+ne+" `"+ae+"` of type `"+se+"` "+("supplied to `"+J+"`, expected `object`."));for(var oe in I){var fe=I[oe];if(typeof fe!="function")return F(J,ne,ae,oe,z(fe));var de=fe(Z,oe,J,ne,ae+"."+oe,r);if(de)return de}return null}return x(B)}function V(I){function B(X,Q,J,ne,ae){var Z=X[Q],se=q(Z);if(se!=="object")return new g("Invalid "+ne+" `"+ae+"` of type `"+se+"` "+("supplied to `"+J+"`, expected `object`."));var oe=e({},X[Q],I);for(var fe in oe){var de=I[fe];if(t(I,fe)&&typeof de!="function")return F(J,ne,ae,fe,z(de));if(!de)return new g("Invalid "+ne+" `"+ae+"` key `"+fe+"` supplied to `"+J+"`.\nBad object: "+JSON.stringify(X[Q],null," ")+`
50
50
  Valid keys: `+JSON.stringify(Object.keys(I),null," "));var ce=de(Z,fe,J,ne,ae+"."+fe,r);if(ce)return ce}return null}return x(B)}function W(I){switch(typeof I){case"number":case"string":case"undefined":return!0;case"boolean":return!I;case"object":if(Array.isArray(I))return I.every(W);if(I===null||u(I))return!0;var B=y(I);if(B){var X=B.call(I),Q;if(B!==I.entries){for(;!(Q=X.next()).done;)if(!W(Q.value))return!1}else for(;!(Q=X.next()).done;){var J=Q.value;if(J&&!W(J[1]))return!1}}else return!1;return!0;default:return!1}}function ee(I,B){return I==="symbol"?!0:B?B["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&B instanceof Symbol:!1}function q(I){var B=typeof I;return Array.isArray(I)?"array":I instanceof RegExp?"object":ee(B,I)?"symbol":B}function z(I){if(typeof I>"u"||I===null)return""+I;var B=q(I);if(B==="object"){if(I instanceof Date)return"date";if(I instanceof RegExp)return"regexp"}return B}function U(I){var B=z(I);switch(B){case"array":case"object":return"an "+B;case"boolean":case"date":case"regexp":return"a "+B;default:return B}}function $(I){return!I.constructor||!I.constructor.name?E:I.constructor.name}return p.checkPropTypes=n,p.resetWarningCache=n.resetWarningCache,p.PropTypes=p,p},factoryWithTypeCheckers$1}var factoryWithThrowingShims$1,hasRequiredFactoryWithThrowingShims$1;function requireFactoryWithThrowingShims$1(){if(hasRequiredFactoryWithThrowingShims$1)return factoryWithThrowingShims$1;hasRequiredFactoryWithThrowingShims$1=1;var o=requireReactPropTypesSecret$1();function e(){}function r(){}return r.resetWarningCache=e,factoryWithThrowingShims$1=function(){function t(l,u,f,d,h,y){if(y!==o){var E=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 E.name="Invariant Violation",E}}t.isRequired=t;function n(){return t}var a={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:n,element:t,elementType:t,instanceOf:n,node:t,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:r,resetWarningCache:e};return a.PropTypes=a,a},factoryWithThrowingShims$1}if(process.env.NODE_ENV!=="production"){var ReactIs$1=requireReactIs(),throwOnDirectAccess$1=!0;propTypes$1.exports=requireFactoryWithTypeCheckers$1()(ReactIs$1.isElement,throwOnDirectAccess$1)}else propTypes$1.exports=requireFactoryWithThrowingShims$1()();var propTypesExports$1=propTypes$1.exports;const PropTypes$1=getDefaultExportFromCjs(propTypesExports$1);var __spreadArray=globalThis&&globalThis.__spreadArray||function(o,e,r){if(r||arguments.length===2)for(var t=0,n=e.length,a;t<n;t++)(a||!(t in e))&&(a||(a=Array.prototype.slice.call(e,0,t)),a[t]=e[t]);return o.concat(a||Array.prototype.slice.call(e))},clipboardEvents=["onCopy","onCut","onPaste"],compositionEvents=["onCompositionEnd","onCompositionStart","onCompositionUpdate"],focusEvents=["onFocus","onBlur"],formEvents=["onInput","onInvalid","onReset","onSubmit"],imageEvents=["onLoad","onError"],keyboardEvents=["onKeyDown","onKeyPress","onKeyUp"],mediaEvents=["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],mouseEvents=["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],dragEvents=["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],selectionEvents=["onSelect"],touchEvents=["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],pointerEvents=["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],uiEvents=["onScroll"],wheelEvents=["onWheel"],animationEvents=["onAnimationStart","onAnimationEnd","onAnimationIteration"],transitionEvents=["onTransitionEnd"],otherEvents=["onToggle"],changeEvents=["onChange"],allEvents=__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([],clipboardEvents,!0),compositionEvents,!0),focusEvents,!0),formEvents,!0),imageEvents,!0),keyboardEvents,!0),mediaEvents,!0),mouseEvents,!0),dragEvents,!0),selectionEvents,!0),touchEvents,!0),pointerEvents,!0),uiEvents,!0),wheelEvents,!0),animationEvents,!0),transitionEvents,!0),changeEvents,!0),otherEvents,!0);function makeEventProps(o,e){var r={};return allEvents.forEach(function(t){var n=o[t];n&&(e?r[t]=function(a){return n(a,e(t))}:r[t]=n)}),r}function makeCancellablePromise(o){var e=!1,r=new Promise(function(t,n){o.then(function(a){return!e&&t(a)}).catch(function(a){return!e&&n(a)})});return{promise:r,cancel:function(){e=!0}}}function mergeClassNames(){return Array.prototype.slice.call(arguments).reduce(function(o,e){return o.concat(e)},[]).filter(function(o){return typeof o=="string"}).join(" ")}const DocumentContext=React$2.createContext(null);function Message$1(o){var e=o.children,r=o.type;return React$2.createElement("div",{className:"react-pdf__message react-pdf__message--".concat(r)},e)}Message$1.propTypes={children:PropTypes$1.node,type:PropTypes$1.oneOf(["error","loading","no-data"]).isRequired};var pdf_link_service={},ui_utils={};Object.defineProperty(ui_utils,"__esModule",{value:!0});ui_utils.isValidRotation=isValidRotation;ui_utils.isValidScrollMode=isValidScrollMode;ui_utils.isValidSpreadMode=isValidSpreadMode;ui_utils.isPortraitOrientation=isPortraitOrientation;ui_utils.clamp=clamp$1;ui_utils.getPDFFileNameFromURL=getPDFFileNameFromURL;ui_utils.noContextMenuHandler=noContextMenuHandler;ui_utils.parseQueryString=parseQueryString;ui_utils.backtrackBeforeAllVisibleElements=backtrackBeforeAllVisibleElements;ui_utils.getVisibleElements=getVisibleElements;ui_utils.roundToDivide=roundToDivide;ui_utils.getPageSizeInches=getPageSizeInches;ui_utils.approximateFraction=approximateFraction;ui_utils.getOutputScale=getOutputScale;ui_utils.scrollIntoView=scrollIntoView;ui_utils.watchScroll=watchScroll;ui_utils.binarySearchFirstItem=binarySearchFirstItem;ui_utils.normalizeWheelEventDelta=normalizeWheelEventDelta;ui_utils.waitOnEventOrTimeout=waitOnEventOrTimeout;ui_utils.moveToEndOfArray=moveToEndOfArray;ui_utils.WaitOnType=ui_utils.animationStarted=ui_utils.ProgressBar=EventBus_1=ui_utils.EventBus=ui_utils.NullL10n=ui_utils.SpreadMode=ui_utils.ScrollMode=ui_utils.TextLayerMode=ui_utils.RendererType=ui_utils.PresentationModeState=ui_utils.VERTICAL_PADDING=ui_utils.SCROLLBAR_PADDING=ui_utils.MAX_AUTO_SCALE=ui_utils.UNKNOWN_SCALE=ui_utils.MAX_SCALE=ui_utils.MIN_SCALE=ui_utils.DEFAULT_SCALE=ui_utils.DEFAULT_SCALE_VALUE=ui_utils.CSS_UNITS=ui_utils.AutoPrintRegExp=void 0;const CSS_UNITS=96/72;ui_utils.CSS_UNITS=CSS_UNITS;const DEFAULT_SCALE_VALUE="auto";ui_utils.DEFAULT_SCALE_VALUE=DEFAULT_SCALE_VALUE;const DEFAULT_SCALE=1;ui_utils.DEFAULT_SCALE=DEFAULT_SCALE;const MIN_SCALE=.1;ui_utils.MIN_SCALE=MIN_SCALE;const MAX_SCALE=10;ui_utils.MAX_SCALE=MAX_SCALE;const UNKNOWN_SCALE=0;ui_utils.UNKNOWN_SCALE=UNKNOWN_SCALE;const MAX_AUTO_SCALE=1.25;ui_utils.MAX_AUTO_SCALE=MAX_AUTO_SCALE;const SCROLLBAR_PADDING=40;ui_utils.SCROLLBAR_PADDING=SCROLLBAR_PADDING;const VERTICAL_PADDING=5;ui_utils.VERTICAL_PADDING=VERTICAL_PADDING;const PresentationModeState={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3};ui_utils.PresentationModeState=PresentationModeState;const RendererType={CANVAS:"canvas",SVG:"svg"};ui_utils.RendererType=RendererType;const TextLayerMode={DISABLE:0,ENABLE:1,ENABLE_ENHANCE:2};ui_utils.TextLayerMode=TextLayerMode;const ScrollMode={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2};ui_utils.ScrollMode=ScrollMode;const SpreadMode={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};ui_utils.SpreadMode=SpreadMode;const AutoPrintRegExp=/\bprint\s*\(/;ui_utils.AutoPrintRegExp=AutoPrintRegExp;function formatL10nValue(o,e){return e?o.replace(/\{\{\s*(\w+)\s*\}\}/g,(r,t)=>t in e?e[t]:"{{"+t+"}}"):o}const NullL10n={async getLanguage(){return"en-us"},async getDirection(){return"ltr"},async get(o,e,r){return formatL10nValue(r,e)},async translate(o){}};ui_utils.NullL10n=NullL10n;function getOutputScale(o){const e=window.devicePixelRatio||1,r=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1,t=e/r;return{sx:t,sy:t,scaled:t!==1}}function scrollIntoView(o,e,r=!1){let t=o.offsetParent;if(!t){console.error("offsetParent is not set -- cannot scroll");return}let n=o.offsetTop+o.clientTop,a=o.offsetLeft+o.clientLeft;for(;t.clientHeight===t.scrollHeight&&t.clientWidth===t.scrollWidth||r&&getComputedStyle(t).overflow==="hidden";)if(t.dataset._scaleY&&(n/=t.dataset._scaleY,a/=t.dataset._scaleX),n+=t.offsetTop,a+=t.offsetLeft,t=t.offsetParent,!t)return;e&&(e.top!==void 0&&(n+=e.top),e.left!==void 0&&(a+=e.left,t.scrollLeft=a)),t.scrollTop=n}function watchScroll(o,e){const r=function(a){n||(n=window.requestAnimationFrame(function(){n=null;const u=o.scrollLeft,f=t.lastX;u!==f&&(t.right=u>f),t.lastX=u;const d=o.scrollTop,h=t.lastY;d!==h&&(t.down=d>h),t.lastY=d,e(t)}))},t={right:!0,down:!0,lastX:o.scrollLeft,lastY:o.scrollTop,_eventHandler:r};let n=null;return o.addEventListener("scroll",r,!0),t}function parseQueryString(o){const e=o.split("&"),r=Object.create(null);for(let t=0,n=e.length;t<n;++t){const a=e[t].split("="),l=a[0].toLowerCase(),u=a.length>1?a[1]:null;r[decodeURIComponent(l)]=decodeURIComponent(u)}return r}function binarySearchFirstItem(o,e){let r=0,t=o.length-1;if(t<0||!e(o[t]))return o.length;if(e(o[r]))return r;for(;r<t;){const n=r+t>>1,a=o[n];e(a)?t=n:r=n+1}return r}function approximateFraction(o){if(Math.floor(o)===o)return[o,1];const e=1/o,r=8;if(e>r)return[1,r];if(Math.floor(e)===e)return[1,e];const t=o>1?e:o;let n=0,a=1,l=1,u=1;for(;;){const d=n+l,h=a+u;if(h>r)break;t<=d/h?(l=d,u=h):(n=d,a=h)}let f;return t-n/a<l/u-t?f=t===o?[n,a]:[a,n]:f=t===o?[l,u]:[u,l],f}function roundToDivide(o,e){const r=o%e;return r===0?o:Math.round(o-r+e)}function getPageSizeInches({view:o,userUnit:e,rotate:r}){const[t,n,a,l]=o,u=r%180!==0,f=(a-t)/72*e,d=(l-n)/72*e;return{width:u?d:f,height:u?f:d}}function backtrackBeforeAllVisibleElements(o,e,r){if(o<2)return o;let t=e[o].div,n=t.offsetTop+t.clientTop;n>=r&&(t=e[o-1].div,n=t.offsetTop+t.clientTop);for(let a=o-2;a>=0&&(t=e[a].div,!(t.offsetTop+t.clientTop+t.clientHeight<=n));--a)o=a;return o}function getVisibleElements(o,e,r=!1,t=!1){const n=o.scrollTop,a=n+o.clientHeight,l=o.scrollLeft,u=l+o.clientWidth;function f(x){const C=x.div;return C.offsetTop+C.clientTop+C.clientHeight>n}function d(x){const C=x.div;return C.offsetLeft+C.clientLeft+C.clientWidth>l}const h=[],y=e.length;let E=y===0?0:binarySearchFirstItem(e,t?d:f);E>0&&E<y&&!t&&(E=backtrackBeforeAllVisibleElements(E,e,n));let p=t?u:-1;for(let x=E;x<y;x++){const C=e[x],R=C.div,S=R.offsetLeft+R.clientLeft,A=R.offsetTop+R.clientTop,T=R.clientWidth,w=R.clientHeight,P=S+T,O=A+w;if(p===-1)O>=a&&(p=O);else if((t?S:A)>p)break;if(O<=n||A>=a||P<=l||S>=u)continue;const k=Math.max(0,n-A)+Math.max(0,O-a),D=Math.max(0,l-S)+Math.max(0,P-u),F=(w-k)*(T-D)*100/w/T|0;h.push({id:C.id,x:S,y:A,view:C,percent:F})}const _=h[0],g=h[h.length-1];return r&&h.sort(function(x,C){const R=x.percent-C.percent;return Math.abs(R)>.001?-R:x.id-C.id}),{first:_,last:g,views:h}}function noContextMenuHandler(o){o.preventDefault()}function isDataSchema(o){let e=0;const r=o.length;for(;e<r&&o[e].trim()==="";)e++;return o.substring(e,e+5).toLowerCase()==="data:"}function getPDFFileNameFromURL(o,e="document.pdf"){if(typeof o!="string")return e;if(isDataSchema(o))return console.warn('getPDFFileNameFromURL: ignoring "data:" URL for performance reasons.'),e;const r=/^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,t=/[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=r.exec(o);let a=t.exec(n[1])||t.exec(n[2])||t.exec(n[3]);if(a&&(a=a[0],a.includes("%")))try{a=t.exec(decodeURIComponent(a))[0]}catch{}return a||e}function normalizeWheelEventDelta(o){let e=Math.sqrt(o.deltaX*o.deltaX+o.deltaY*o.deltaY);const r=Math.atan2(o.deltaY,o.deltaX);-.25*Math.PI<r&&r<.75*Math.PI&&(e=-e);const t=0,n=1,a=30,l=30;return o.deltaMode===t?e/=a*l:o.deltaMode===n&&(e/=l),e}function isValidRotation(o){return Number.isInteger(o)&&o%90===0}function isValidScrollMode(o){return Number.isInteger(o)&&Object.values(ScrollMode).includes(o)&&o!==ScrollMode.UNKNOWN}function isValidSpreadMode(o){return Number.isInteger(o)&&Object.values(SpreadMode).includes(o)&&o!==SpreadMode.UNKNOWN}function isPortraitOrientation(o){return o.width<=o.height}const WaitOnType={EVENT:"event",TIMEOUT:"timeout"};ui_utils.WaitOnType=WaitOnType;function waitOnEventOrTimeout({target:o,name:e,delay:r=0}){return new Promise(function(t,n){if(typeof o!="object"||!(e&&typeof e=="string")||!(Number.isInteger(r)&&r>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");function a(d){o instanceof EventBus?o._off(e,l):o.removeEventListener(e,l),f&&clearTimeout(f),t(d)}const l=a.bind(null,WaitOnType.EVENT);o instanceof EventBus?o._on(e,l):o.addEventListener(e,l);const u=a.bind(null,WaitOnType.TIMEOUT),f=setTimeout(u,r)})}const animationStarted=new Promise(function(o){window.requestAnimationFrame(o)});ui_utils.animationStarted=animationStarted;class EventBus{constructor(e){this._listeners=Object.create(null)}on(e,r){this._on(e,r,{external:!0})}off(e,r){this._off(e,r,{external:!0})}dispatch(e){const r=this._listeners[e];if(!r||r.length===0)return;const t=Array.prototype.slice.call(arguments,1);let n;r.slice(0).forEach(function({listener:a,external:l}){if(l){n||(n=[]),n.push(a);return}a.apply(null,t)}),n&&(n.forEach(function(a){a.apply(null,t)}),n=null)}_on(e,r,t=null){let n=this._listeners[e];n||(this._listeners[e]=n=[]),n.push({listener:r,external:(t&&t.external)===!0})}_off(e,r,t=null){const n=this._listeners[e];if(n){for(let a=0,l=n.length;a<l;a++)if(n[a].listener===r){n.splice(a,1);return}}}}var EventBus_1=ui_utils.EventBus=EventBus;function clamp$1(o,e,r){return Math.min(Math.max(o,e),r)}let ProgressBar$1=class{constructor(e,{height:r,width:t,units:n}={}){this.visible=!0,this.div=document.querySelector(e+" .progress"),this.bar=this.div.parentNode,this.height=r||100,this.width=t||100,this.units=n||"%",this.div.style.height=this.height+this.units,this.percent=0}_updateBar(){if(this._indeterminate){this.div.classList.add("indeterminate"),this.div.style.width=this.width+this.units;return}this.div.classList.remove("indeterminate");const e=this.width*this._percent/100;this.div.style.width=e+this.units}get percent(){return this._percent}set percent(e){this._indeterminate=isNaN(e),this._percent=clamp$1(e,0,100),this._updateBar()}setWidth(e){if(!e)return;const t=e.parentNode.offsetWidth-e.offsetWidth;t>0&&(this.bar.style.width=`calc(100% - ${t}px)`)}hide(){this.visible&&(this.visible=!1,this.bar.classList.add("hidden"),document.body.classList.remove("loadingInProgress"))}show(){this.visible||(this.visible=!0,document.body.classList.add("loadingInProgress"),this.bar.classList.remove("hidden"))}};ui_utils.ProgressBar=ProgressBar$1;function moveToEndOfArray(o,e){const r=[],t=o.length;let n=0;for(let a=0;a<t;++a)e(o[a])?r.push(o[a]):(o[n]=o[a],++n);for(let a=0;n<t;++a,++n)o[n]=r[a]}Object.defineProperty(pdf_link_service,"__esModule",{value:!0});pdf_link_service.SimpleLinkService=PDFLinkService_1=pdf_link_service.PDFLinkService=void 0;var _ui_utils=ui_utils;class PDFLinkService{constructor({eventBus:e,externalLinkTarget:r=null,externalLinkRel:t=null,externalLinkEnabled:n=!0,ignoreDestinationZoom:a=!1}={}){this.eventBus=e,this.externalLinkTarget=r,this.externalLinkRel=t,this.externalLinkEnabled=n,this._ignoreDestinationZoom=a,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null,this._pagesRefCache=null}setDocument(e,r=null){this.baseUrl=r,this.pdfDocument=e,this._pagesRefCache=Object.create(null)}setViewer(e){this.pdfViewer=e}setHistory(e){this.pdfHistory=e}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfViewer.currentPageNumber}set page(e){this.pdfViewer.currentPageNumber=e}get rotation(){return this.pdfViewer.pagesRotation}set rotation(e){this.pdfViewer.pagesRotation=e}navigateTo(e){const r=({namedDest:t,explicitDest:n})=>{const a=n[0];let l;if(a instanceof Object){if(l=this._cachedPageNumber(a),l===null){this.pdfDocument.getPageIndex(a).then(u=>{this.cachePageRef(u+1,a),r({namedDest:t,explicitDest:n})}).catch(()=>{console.error(`PDFLinkService.navigateTo: "${a}" is not a valid page reference, for dest="${e}".`)});return}}else if(Number.isInteger(a))l=a+1;else{console.error(`PDFLinkService.navigateTo: "${a}" is not a valid destination reference, for dest="${e}".`);return}if(!l||l<1||l>this.pagesCount){console.error(`PDFLinkService.navigateTo: "${l}" is not a valid page number, for dest="${e}".`);return}this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:t,explicitDest:n,pageNumber:l})),this.pdfViewer.scrollPageIntoView({pageNumber:l,destArray:n,ignoreDestinationZoom:this._ignoreDestinationZoom})};new Promise((t,n)=>{if(typeof e=="string"){this.pdfDocument.getDestination(e).then(a=>{t({namedDest:e,explicitDest:a})});return}t({namedDest:"",explicitDest:e})}).then(t=>{if(!Array.isArray(t.explicitDest)){console.error(`PDFLinkService.navigateTo: "${t.explicitDest}" is not a valid destination array, for dest="${e}".`);return}r(t)})}getDestinationHash(e){if(typeof e=="string")return this.getAnchorUrl("#"+escape(e));if(Array.isArray(e)){const r=JSON.stringify(e);return this.getAnchorUrl("#"+escape(r))}return this.getAnchorUrl("")}getAnchorUrl(e){return(this.baseUrl||"")+e}setHash(e){let r,t;if(e.includes("=")){const n=(0,_ui_utils.parseQueryString)(e);if("search"in n&&this.eventBus.dispatch("findfromurlhash",{source:this,query:n.search.replace(/"/g,""),phraseSearch:n.phrase==="true"}),"page"in n&&(r=n.page|0||1),"zoom"in n){const a=n.zoom.split(","),l=a[0],u=parseFloat(l);l.includes("Fit")?l==="Fit"||l==="FitB"?t=[null,{name:l}]:l==="FitH"||l==="FitBH"||l==="FitV"||l==="FitBV"?t=[null,{name:l},a.length>1?a[1]|0:null]:l==="FitR"?a.length!==5?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):t=[null,{name:l},a[1]|0,a[2]|0,a[3]|0,a[4]|0]:console.error(`PDFLinkService.setHash: "${l}" is not a valid zoom value.`):t=[null,{name:"XYZ"},a.length>1?a[1]|0:null,a.length>2?a[2]|0:null,u?u/100:l]}t?this.pdfViewer.scrollPageIntoView({pageNumber:r||this.page,destArray:t,allowNegativeOffset:!0}):r&&(this.page=r),"pagemode"in n&&this.eventBus.dispatch("pagemode",{source:this,mode:n.pagemode}),"nameddest"in n&&this.navigateTo(n.nameddest)}else{t=unescape(e);try{t=JSON.parse(t),Array.isArray(t)||(t=t.toString())}catch{}if(typeof t=="string"||isValidExplicitDestination(t)){this.navigateTo(t);return}console.error(`PDFLinkService.setHash: "${unescape(e)}" is not a valid destination.`)}}executeNamedAction(e){switch(e){case"GoBack":this.pdfHistory&&this.pdfHistory.back();break;case"GoForward":this.pdfHistory&&this.pdfHistory.forward();break;case"NextPage":this.page<this.pagesCount&&this.page++;break;case"PrevPage":this.page>1&&this.page--;break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1;break}this.eventBus.dispatch("namedaction",{source:this,action:e})}cachePageRef(e,r){if(!r)return;const t=r.gen===0?`${r.num}R`:`${r.num}R${r.gen}`;this._pagesRefCache[t]=e}_cachedPageNumber(e){const r=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return this._pagesRefCache&&this._pagesRefCache[r]||null}isPageVisible(e){return this.pdfViewer.isPageVisible(e)}}var PDFLinkService_1=pdf_link_service.PDFLinkService=PDFLinkService;function isValidExplicitDestination(o){if(!Array.isArray(o))return!1;const e=o.length;if(e<2)return!1;const r=o[0];if(!(typeof r=="object"&&Number.isInteger(r.num)&&Number.isInteger(r.gen))&&!(Number.isInteger(r)&&r>=0))return!1;const t=o[1];if(!(typeof t=="object"&&typeof t.name=="string"))return!1;let n=!0;switch(t.name){case"XYZ":if(e!==5)return!1;break;case"Fit":case"FitB":return e===2;case"FitH":case"FitBH":case"FitV":case"FitBV":if(e!==3)return!1;break;case"FitR":if(e!==6)return!1;n=!1;break;default:return!1}for(let a=2;a<e;a++){const l=o[a];if(!(typeof l=="number"||n&&l===null))return!1}return!0}class SimpleLinkService{constructor(){this.externalLinkTarget=null,this.externalLinkRel=null,this.externalLinkEnabled=!0,this._ignoreDestinationZoom=!1}get pagesCount(){return 0}get page(){return 0}set page(e){}get rotation(){return 0}set rotation(e){}navigateTo(e){}getDestinationHash(e){return"#"}getAnchorUrl(e){return"#"}setHash(e){}executeNamedAction(e){}cachePageRef(e,r){}isPageVisible(e){return!0}}pdf_link_service.SimpleLinkService=SimpleLinkService;const LinkService=PDFLinkService_1;var PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};const eventBus=new EventBus_1;function _arrayWithHoles$1(o){if(Array.isArray(o))return o}function _iterableToArrayLimit$1(o,e){var r=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(r!=null){var t,n,a,l,u=[],f=!0,d=!1;try{if(a=(r=r.call(o)).next,e===0){if(Object(r)!==r)return;f=!1}else for(;!(f=(t=a.call(r)).done)&&(u.push(t.value),u.length!==e);f=!0);}catch(h){d=!0,n=h}finally{try{if(!f&&r.return!=null&&(l=r.return(),Object(l)!==l))return}finally{if(d)throw n}}return u}}function _arrayLikeToArray$1(o,e){(e==null||e>o.length)&&(e=o.length);for(var r=0,t=new Array(e);r<e;r++)t[r]=o[r];return t}function _unsupportedIterableToArray$1(o,e){if(o){if(typeof o=="string")return _arrayLikeToArray$1(o,e);var r=Object.prototype.toString.call(o).slice(8,-1);if(r==="Object"&&o.constructor&&(r=o.constructor.name),r==="Map"||r==="Set")return Array.from(o);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _arrayLikeToArray$1(o,e)}}function _nonIterableRest$1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
51
51
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _slicedToArray$1(o,e){return _arrayWithHoles$1(o)||_iterableToArrayLimit$1(o,e)||_unsupportedIterableToArray$1(o,e)||_nonIterableRest$1()}var isBrowser=typeof window<"u",isLocalFileSystem=isBrowser&&window.location.protocol==="file:",isProduction=process.env.NODE_ENV==="production",isDefined=function o(e){return typeof e<"u"},isProvided=function o(e){return isDefined(e)&&e!==null},isString=function o(e){return typeof e=="string"},isArrayBuffer=function o(e){return e instanceof ArrayBuffer},isBlob=function o(e){if(!isBrowser)throw new Error("Attempted to check if a variable is a Blob on a non-browser environment.");return e instanceof Blob},isFile=function o(e){if(!isBrowser)throw new Error("Attempted to check if a variable is a File on a non-browser environment.");return e instanceof File},isDataURI=function o(e){return isString(e)&&/^data:/.test(e)},dataURItoByteString=function o(e){if(!isDataURI(e))throw new Error("Invalid data URI.");var r=e.split(";"),t=_slicedToArray$1(r,2),n=t[1];return n.indexOf("base64")===0?atob(n.slice(7)):unescape(n)},getPixelRatio=function o(){return isBrowser&&window.devicePixelRatio||1},consoleOnDev=function o(e){if(!isProduction){for(var r,t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];(r=console)[e].apply(r,n)}},warnOnDev=function o(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return consoleOnDev.apply(void 0,["warn"].concat(r))},errorOnDev=function o(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return consoleOnDev.apply(void 0,["error"].concat(r))},displayCORSWarning=function o(){isLocalFileSystem&&warnOnDev("Loading PDF as base64 strings/URLs might not work on protocols other than HTTP/HTTPS. On Google Chrome, you can use --allow-file-access-from-files flag for debugging purposes.")},cancelRunningTask=function o(e){e&&e.cancel&&e.cancel()},makePageCallback=function o(e,r){return Object.defineProperty(e,"width",{get:function(){return this.view[2]*r},configurable:!0}),Object.defineProperty(e,"height",{get:function(){return this.view[3]*r},configurable:!0}),Object.defineProperty(e,"originalWidth",{get:function(){return this.view[2]},configurable:!0}),Object.defineProperty(e,"originalHeight",{get:function(){return this.view[3]},configurable:!0}),e},isCancelException=function o(e){return e.name==="RenderingCancelledException"},loadFromFile=function o(e){return new Promise(function(r,t){var n=new FileReader;return n.onload=function(){return r(new Uint8Array(n.result))},n.onerror=function(a){switch(a.target.error.code){case a.target.error.NOT_FOUND_ERR:return t(new Error("Error while reading a file: File not found."));case a.target.error.NOT_READABLE_ERR:return t(new Error("Error while reading a file: File not readable."));case a.target.error.SECURITY_ERR:return t(new Error("Error while reading a file: Security error."));case a.target.error.ABORT_ERR:return t(new Error("Error while reading a file: Aborted."));default:return t(new Error("Error while reading a file."))}},n.readAsArrayBuffer(e),null})};function _arrayWithoutHoles(o){if(Array.isArray(o))return _arrayLikeToArray$1(o)}function _iterableToArray(o){if(typeof Symbol<"u"&&o[Symbol.iterator]!=null||o["@@iterator"]!=null)return Array.from(o)}function _nonIterableSpread(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
52
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _toConsumableArray(o){return _arrayWithoutHoles(o)||_iterableToArray(o)||_unsupportedIterableToArray$1(o)||_nonIterableSpread()}var eventProps=function(){var o={};return[].concat(_toConsumableArray(mouseEvents),_toConsumableArray(touchEvents),_toConsumableArray(keyboardEvents)).forEach(function(e){o[e]=PropTypes$1.func}),o}(),fileTypes=[PropTypes$1.string,PropTypes$1.instanceOf(ArrayBuffer),PropTypes$1.shape({data:PropTypes$1.object,httpHeaders:PropTypes$1.object,range:PropTypes$1.object,url:PropTypes$1.string,withCredentials:PropTypes$1.bool})];typeof File<"u"&&fileTypes.push(PropTypes$1.instanceOf(File));typeof Blob<"u"&&fileTypes.push(PropTypes$1.instanceOf(Blob));var isClassName=PropTypes$1.oneOfType([PropTypes$1.string,PropTypes$1.arrayOf(PropTypes$1.string)]);PropTypes$1.oneOfType(fileTypes);var isLinkService=PropTypes$1.instanceOf(LinkService);PropTypes$1.oneOf(["_self","_blank","_parent","_top"]);var isPage=PropTypes$1.shape({_transport:PropTypes$1.shape({fontLoader:PropTypes$1.object.isRequired}).isRequired,commonObjs:PropTypes$1.shape({_objs:PropTypes$1.object.isRequired}).isRequired,getAnnotations:PropTypes$1.func.isRequired,getTextContent:PropTypes$1.func.isRequired,getViewport:PropTypes$1.func.isRequired,render:PropTypes$1.func.isRequired}),isPageIndex=function o(e,r,t){var n=e[r],a=e.pageNumber,l=e.pdf;if(!isDefined(l))return null;if(isDefined(n)){if(typeof n!="number")return new Error("`".concat(r,"` of type `").concat(_typeof$1(n),"` supplied to `").concat(t,"`, expected `number`."));if(n<0)return new Error("Expected `".concat(r,"` to be greater or equal to 0."));var u=l.numPages;if(n+1>u)return new Error("Expected `".concat(r,"` to be less or equal to ").concat(u-1,"."))}else if(!isDefined(a))return new Error("`".concat(r,"` not supplied. Either pageIndex or pageNumber must be supplied to `").concat(t,"`."));return null},isPageNumber=function o(e,r,t){var n=e[r],a=e.pageIndex,l=e.pdf;if(!isDefined(l))return null;if(isDefined(n)){if(typeof n!="number")return new Error("`".concat(r,"` of type `").concat(_typeof$1(n),"` supplied to `").concat(t,"`, expected `number`."));if(n<1)return new Error("Expected `".concat(r,"` to be greater or equal to 1."));var u=l.numPages;if(n>u)return new Error("Expected `".concat(r,"` to be less or equal to ").concat(u,"."))}else if(!isDefined(a))return new Error("`".concat(r,"` not supplied. Either pageIndex or pageNumber must be supplied to `").concat(t,"`."));return null},isPdf=PropTypes$1.oneOfType([PropTypes$1.shape({getDestination:PropTypes$1.func.isRequired,getOutline:PropTypes$1.func.isRequired,getPage:PropTypes$1.func.isRequired,numPages:PropTypes$1.number.isRequired}),PropTypes$1.bool]),isRef=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.shape({current:PropTypes$1.any})]),isRenderMode=PropTypes$1.oneOf(["canvas","none","svg"]),isRotate=PropTypes$1.oneOf([0,90,180,270]);function ownKeys$2(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread$2(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$2(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys$2(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}function _createSuper$6(o){var e=_isNativeReflectConstruct$6();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$6(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PDFDataRangeTransport=pdfExports.PDFDataRangeTransport,Document$1=function(o){_inherits(r,o);var e=_createSuper$6(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{pdf:null}),_defineProperty(_assertThisInitialized$1(t),"viewer",{scrollPageIntoView:function(f){var d=f.pageNumber,h=t.props.onItemClick;if(h){h({pageNumber:d});return}var y=t.pages[d-1];if(y){y.scrollIntoView();return}warnOnDev("Warning: An internal link leading to page ".concat(d," was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>."))}}),_defineProperty(_assertThisInitialized$1(t),"linkService",new LinkService({eventBus})),_defineProperty(_assertThisInitialized$1(t),"loadDocument",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y,E,p,_;return _regeneratorRuntime.wrap(function(x){for(;;)switch(x.prev=x.next){case 0:return f=null,x.prev=1,x.next=4,t.findDocumentSource();case 4:f=x.sent,t.onSourceSuccess(),x.next=11;break;case 8:x.prev=8,x.t0=x.catch(1),t.onSourceError(x.t0);case 11:if(f){x.next=13;break}return x.abrupt("return");case 13:return t.setState(function(C){return C.pdf?{pdf:null}:null}),d=t.props,h=d.options,y=d.onLoadProgress,E=d.onPassword,x.prev=15,cancelRunningTask(t.runningTask),t.loadingTask=pdfExports.getDocument(_objectSpread$2(_objectSpread$2({},f),h)),t.loadingTask.onPassword=E,y&&(t.loadingTask.onProgress=y),p=makeCancellablePromise(t.loadingTask.promise),t.runningTask=p,x.next=24,p.promise;case 24:_=x.sent,t.setState(function(C){return C.pdf&&C.pdf.fingerprint===_.fingerprint?null:{pdf:_}},t.onLoadSuccess),x.next=31;break;case 28:x.prev=28,x.t1=x.catch(15),t.onLoadError(x.t1);case 31:case"end":return x.stop()}},u,null,[[1,8],[15,28]])}))),_defineProperty(_assertThisInitialized$1(t),"setupLinkService",function(){t.linkService.setViewer(t.viewer);var u=_assertThisInitialized$1(t);Object.defineProperty(t.linkService,"externalLinkTarget",{get:function(){var d=u.props.externalLinkTarget;switch(d){case"_self":return 1;case"_blank":return 2;case"_parent":return 3;case"_top":return 4;default:return 0}}})}),_defineProperty(_assertThisInitialized$1(t),"onSourceSuccess",function(){var u=t.props.onSourceSuccess;u&&u()}),_defineProperty(_assertThisInitialized$1(t),"onSourceError",function(u){errorOnDev(u);var f=t.props.onSourceError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onLoadSuccess,f=t.state.pdf;u&&u(f),t.pages=new Array(f.numPages),t.linkService.setDocument(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({pdf:!1}),errorOnDev(u);var f=t.props.onLoadError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"findDocumentSource",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y,E;return _regeneratorRuntime.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(f=t.props.file,f){_.next=3;break}return _.abrupt("return",null);case 3:if(typeof f!="string"){_.next=9;break}if(!isDataURI(f)){_.next=7;break}return d=dataURItoByteString(f),_.abrupt("return",{data:d});case 7:return displayCORSWarning(),_.abrupt("return",{url:f});case 9:if(!(f instanceof PDFDataRangeTransport)){_.next=11;break}return _.abrupt("return",{range:f});case 11:if(!isArrayBuffer(f)){_.next=13;break}return _.abrupt("return",{data:f});case 13:if(!isBrowser){_.next=19;break}if(!(isBlob(f)||isFile(f))){_.next=19;break}return _.next=17,loadFromFile(f);case 17:return _.t0=_.sent,_.abrupt("return",{data:_.t0});case 19:if(_typeof$1(f)==="object"){_.next=21;break}throw new Error("Invalid parameter in file, need either Uint8Array, string or a parameter object");case 21:if(!(!f.url&&!f.data&&!f.range)){_.next=23;break}throw new Error("Invalid parameter object: need either .data, .range or .url");case 23:if(typeof f.url!="string"){_.next=29;break}if(!isDataURI(f.url)){_.next=28;break}return h=f.url,y=_objectWithoutProperties(f,["url"]),E=dataURItoByteString(h),_.abrupt("return",_objectSpread$2({data:E},y));case 28:displayCORSWarning();case 29:return _.abrupt("return",f);case 30:case"end":return _.stop()}},u)}))),_defineProperty(_assertThisInitialized$1(t),"registerPage",function(u,f){t.pages[u]=f}),_defineProperty(_assertThisInitialized$1(t),"unregisterPage",function(u){delete t.pages[u]}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.loadDocument(),this.setupLinkService()}},{key:"componentDidUpdate",value:function(n){var a=this.props.file;a!==n.file&&this.loadDocument()}},{key:"componentWillUnmount",value:function(){this.loadingTask&&this.loadingTask.destroy(),cancelRunningTask(this.runningTask)}},{key:"renderChildren",value:function(){var n=this.props.children;return React$2.createElement(DocumentContext.Provider,{value:this.childContext},n)}},{key:"renderContent",value:function(){var n=this.props.file,a=this.state.pdf;if(!n){var l=this.props.noData;return React$2.createElement(Message$1,{type:"no-data"},typeof l=="function"?l():l)}if(a===null){var u=this.props.loading;return React$2.createElement(Message$1,{type:"loading"},typeof u=="function"?u():u)}if(a===!1){var f=this.props.error;return React$2.createElement(Message$1,{type:"error"},typeof f=="function"?f():f)}return this.renderChildren()}},{key:"render",value:function(){var n=this.props,a=n.className,l=n.inputRef;return React$2.createElement("div",_extends({className:mergeClassNames("react-pdf__Document",a),ref:l},this.eventProps),this.renderContent())}},{key:"childContext",get:function(){var n=this.linkService,a=this.registerPage,l=this.unregisterPage,u=this.props,f=u.imageResourcesPath,d=u.renderMode,h=u.rotate,y=this.state.pdf;return{imageResourcesPath:f,linkService:n,pdf:y,registerPage:a,renderMode:d,rotate:h,unregisterPage:l}}},{key:"eventProps",get:function(){var n=this;return makeEventProps(this.props,function(){return n.state.pdf})}}]),r}(React$2.PureComponent);Document$1.defaultProps={error:"Failed to load PDF file.",loading:"Loading PDF…",noData:"No PDF file specified.",onPassword:function o(e,r){switch(r){case PasswordResponses.NEED_PASSWORD:{var t=prompt("Enter the password to open this PDF file.");e(t);break}case PasswordResponses.INCORRECT_PASSWORD:{var n=prompt("Invalid password. Please try again.");e(n);break}}}};var isFunctionOrNode$1=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.node]);Document$1.propTypes=_objectSpread$2(_objectSpread$2({},eventProps),{},{children:PropTypes$1.node,className:isClassName,error:isFunctionOrNode$1,file:isFile,imageResourcesPath:PropTypes$1.string,inputRef:isRef,loading:isFunctionOrNode$1,noData:isFunctionOrNode$1,onItemClick:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadProgress:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,onPassword:PropTypes$1.func,onSourceError:PropTypes$1.func,onSourceSuccess:PropTypes$1.func,rotate:PropTypes$1.number});var isDestination=PropTypes$1.oneOfType([PropTypes$1.string,PropTypes$1.arrayOf(PropTypes$1.any)]);PropTypes$1.shape({dest:isDestination,items:PropTypes$1.arrayOf(PropTypes$1.shape({dest:isDestination,title:PropTypes$1.string})),title:PropTypes$1.string}).isRequired,PropTypes$1.func,isPdf.isRequired;function ownKeys$1(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread$1(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$1(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys$1(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}_objectSpread$1({className:isClassName,inputRef:isRef,onItemClick:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,pdf:isPdf},eventProps);function mergeRefs(){for(var o=[],e=0;e<arguments.length;e++)o[e]=arguments[e];var r=o.filter(Boolean);if(r.length<=1){var t=r[0];return t||null}return function(a){r.forEach(function(l){typeof l=="function"?l(a):l&&(l.current=a)})}}const PageContext=React$2.createContext(null);function _createSuper$5(o){var e=_isNativeReflectConstruct$5();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$5(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PageCanvasInternal=function(o){_inherits(r,o);var e=_createSuper$5(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){t.renderer=null;var u=t.props,f=u.onRenderSuccess,d=u.page,h=u.scale;f&&f(makePageCallback(d,h))}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){if(!isCancelException(u)){errorOnDev(u);var f=t.props.onRenderError;f&&f(u)}}),_defineProperty(_assertThisInitialized$1(t),"drawPageOnCanvas",function(){var u=_assertThisInitialized$1(t),f=u.canvasLayer;if(!f)return null;var d=_assertThisInitialized$1(t),h=d.renderViewport,y=d.viewport,E=t.props,p=E.page,_=E.renderInteractiveForms;f.width=h.width,f.height=h.height,f.style.width="".concat(Math.floor(y.width),"px"),f.style.height="".concat(Math.floor(y.height),"px");var g={get canvasContext(){return f.getContext("2d")},viewport:h,renderInteractiveForms:_};return t.cancelRenderingTask(),t.renderer=p.render(g),t.renderer.promise.then(t.onRenderSuccess).catch(t.onRenderError)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.drawPageOnCanvas()}},{key:"componentDidUpdate",value:function(n){var a=this.props,l=a.page,u=a.renderInteractiveForms;u!==n.renderInteractiveForms&&(l.cleanup(),this.drawPageOnCanvas())}},{key:"componentWillUnmount",value:function(){this.cancelRenderingTask(),this.canvasLayer&&(this.canvasLayer.width=0,this.canvasLayer.height=0,this.canvasLayer=null)}},{key:"cancelRenderingTask",value:function(){this.renderer&&this.renderer._internalRenderTask.running&&this.renderer._internalRenderTask.cancel()}},{key:"render",value:function(){var n=this,a=this.props.canvasRef;return React$2.createElement("canvas",{className:"react-pdf__Page__canvas",dir:"ltr",ref:mergeRefs(a,function(l){n.canvasLayer=l}),style:{display:"block",userSelect:"none"}})}},{key:"renderViewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale,f=getPixelRatio();return a.getViewport({scale:u*f,rotation:l})}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);PageCanvasInternal.propTypes={canvasRef:isRef,onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,page:isPage.isRequired,renderInteractiveForms:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number};function PageCanvas(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(PageCanvasInternal,_extends({},e,o))})}function _createSuper$4(o){var e=_isNativeReflectConstruct$4();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$4(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PageSVGInternal=function(o){_inherits(r,o);var e=_createSuper$4(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{svg:null}),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){t.renderer=null;var u=t.props,f=u.onRenderSuccess,d=u.page,h=u.scale;f&&f(makePageCallback(d,h))}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){if(!isCancelException(u)){errorOnDev(u);var f=t.props.onRenderError;f&&f(u)}}),_defineProperty(_assertThisInitialized$1(t),"renderSVG",function(){var u=t.props.page;return t.renderer=u.getOperatorList(),t.renderer.then(function(f){var d=new pdfExports.SVGGraphics(u.commonObjs,u.objs);t.renderer=d.getSVG(f,t.viewport).then(function(h){t.setState({svg:h},t.onRenderSuccess)}).catch(t.onRenderError)}).catch(t.onRenderError)}),_defineProperty(_assertThisInitialized$1(t),"drawPageOnContainer",function(u){var f=t.state.svg;if(!(!u||!f)){u.firstElementChild||u.appendChild(f);var d=t.viewport,h=d.width,y=d.height;f.setAttribute("width",h),f.setAttribute("height",y)}}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.renderSVG()}},{key:"render",value:function(){var n=this,a=this.viewport,l=a.width,u=a.height;return React$2.createElement("div",{className:"react-pdf__Page__svg",ref:function(d){return n.drawPageOnContainer(d)},style:{display:"block",backgroundColor:"white",overflow:"hidden",width:l,height:u,userSelect:"none"}})}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);PageSVGInternal.propTypes={onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number};function PageSVG(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(PageSVGInternal,_extends({},e,o))})}function _createSuper$3(o){var e=_isNativeReflectConstruct$3();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$3(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var TextLayerItemInternal=function(o){_inherits(r,o);var e=_createSuper$3(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"getElementWidth",function(u){var f=_assertThisInitialized$1(t),d=f.sideways;return u.getBoundingClientRect()[d?"height":"width"]}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.alignTextItem()}},{key:"componentDidUpdate",value:function(){this.alignTextItem()}},{key:"getFontData",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function a(l){var u,f;return _regeneratorRuntime.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return u=this.props.page,h.next=3,new Promise(function(y){u.commonObjs.get(l,y)});case 3:return f=h.sent,h.abrupt("return",f);case 5:case"end":return h.stop()}},a,this)}));function n(a){return t.apply(this,arguments)}return n}()},{key:"alignTextItem",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function a(){var l,u,f,d,h,y,E,p,_,g,x;return _regeneratorRuntime.wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(l=this.item,l){R.next=3;break}return R.abrupt("return");case 3:return l.style.transform="",u=this.props,f=u.fontName,d=u.scale,h=u.width,l.style.fontFamily="".concat(f,", sans-serif"),R.next=8,this.getFontData(f);case 8:y=R.sent,E=y?y.fallbackName:"sans-serif",l.style.fontFamily="".concat(f,", ").concat(E),p=h*d,_=this.getElementWidth(l),g="scaleX(".concat(p/_,")"),x=y?y.ascent:0,x&&(g+=" translateY(".concat((1-x)*100,"%)")),l.style.transform=g,l.style.WebkitTransform=g;case 18:case"end":return R.stop()}},a,this)}));function n(){return t.apply(this,arguments)}return n}()},{key:"render",value:function(){var n=this,a=this.fontSize,l=this.top,u=this.left,f=this.props,d=f.customTextRenderer,h=f.scale,y=f.str;return React$2.createElement("span",{ref:function(p){n.item=p},style:{height:"1em",fontFamily:"sans-serif",fontSize:"".concat(a*h,"px"),position:"absolute",top:"".concat(l*h,"px"),left:"".concat(u*h,"px"),transformOrigin:"left bottom",whiteSpace:"pre",pointerEvents:"all"}},d?d(this.props):y)}},{key:"unrotatedViewport",get:function(){var n=this.props,a=n.page,l=n.scale;return a.getViewport({scale:l})}},{key:"rotate",get:function(){var n=this.props,a=n.page,l=n.rotate;return l-a.rotate}},{key:"sideways",get:function(){var n=this.rotate;return n%180!==0}},{key:"defaultSideways",get:function(){var n=this.unrotatedViewport.rotation;return n%180!==0}},{key:"fontSize",get:function(){var n=this.props.transform,a=this.defaultSideways,l=_slicedToArray$1(n,2),u=l[0],f=l[1];return a?f:u}},{key:"top",get:function(){var n=this.props.transform,a=this.unrotatedViewport,l=this.defaultSideways,u=_slicedToArray$1(n,6),f=u[2],d=u[3],h=u[4],y=u[5],E=_slicedToArray$1(a.viewBox,4),p=E[1],_=E[3];return l?h+f+p:_-(y+d)}},{key:"left",get:function(){var n=this.props.transform,a=this.unrotatedViewport,l=this.defaultSideways,u=_slicedToArray$1(n,6),f=u[4],d=u[5],h=_slicedToArray$1(a.viewBox,1),y=h[0];return l?d-y:f-y}}]),r}(React$2.PureComponent);TextLayerItemInternal.propTypes={customTextRenderer:PropTypes$1.func,fontName:PropTypes$1.string.isRequired,itemIndex:PropTypes$1.number.isRequired,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number,str:PropTypes$1.string.isRequired,transform:PropTypes$1.arrayOf(PropTypes$1.number).isRequired,width:PropTypes$1.number.isRequired};function TextLayerItem(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(TextLayerItemInternal,_extends({},e,o))})}function _createSuper$2(o){var e=_isNativeReflectConstruct$2();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$2(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var TextLayerInternal=function(o){_inherits(r,o);var e=_createSuper$2(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{textItems:null}),_defineProperty(_assertThisInitialized$1(t),"loadTextItems",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y;return _regeneratorRuntime.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return f=t.props.page,p.prev=1,d=makeCancellablePromise(f.getTextContent()),t.runningTask=d,p.next=6,d.promise;case 6:h=p.sent,y=h.items,t.setState({textItems:y},t.onLoadSuccess),p.next=14;break;case 11:p.prev=11,p.t0=p.catch(1),t.onLoadError(p.t0);case 14:case"end":return p.stop()}},u,null,[[1,11]])}))),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onGetTextSuccess,f=t.state.textItems;u&&u(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({textItems:!1}),errorOnDev(u);var f=t.props.onGetTextError;f&&f(u)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.page;if(!n)throw new Error("Attempted to load page text content, but no page was specified.");this.loadTextItems()}},{key:"componentDidUpdate",value:function(n){var a=this.props.page;n.page&&a!==n.page&&this.loadTextItems()}},{key:"componentWillUnmount",value:function(){cancelRunningTask(this.runningTask)}},{key:"renderTextItems",value:function(){var n=this.state.textItems;return n?n.map(function(a,l){return React$2.createElement(TextLayerItem,_extends({key:l,itemIndex:l},a))}):null}},{key:"render",value:function(){var n=this.unrotatedViewport,a=this.rotate;return React$2.createElement("div",{className:"react-pdf__Page__textContent",style:{position:"absolute",top:"50%",left:"50%",width:"".concat(n.width,"px"),height:"".concat(n.height,"px"),color:"transparent",transform:"translate(-50%, -50%) rotate(".concat(a,"deg)"),WebkitTransform:"translate(-50%, -50%) rotate(".concat(a,"deg)"),pointerEvents:"none"}},this.renderTextItems())}},{key:"unrotatedViewport",get:function(){var n=this.props,a=n.page,l=n.scale;return a.getViewport({scale:l})}},{key:"rotate",get:function(){var n=this.props,a=n.page,l=n.rotate;return l-a.rotate}}]),r}(React$2.PureComponent);TextLayerInternal.propTypes={onGetTextError:PropTypes$1.func,onGetTextSuccess:PropTypes$1.func,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number};function TextLayer(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(TextLayerInternal,_extends({},e,o))})}function _createSuper$1(o){var e=_isNativeReflectConstruct$1();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$1(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var AnnotationLayerInternal=function(o){_inherits(r,o);var e=_createSuper$1(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{annotations:null}),_defineProperty(_assertThisInitialized$1(t),"loadAnnotations",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h;return _regeneratorRuntime.wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return f=t.props.page,E.prev=1,d=makeCancellablePromise(f.getAnnotations()),t.runningTask=d,E.next=6,d.promise;case 6:h=E.sent,t.setState({annotations:h},t.onLoadSuccess),E.next=13;break;case 10:E.prev=10,E.t0=E.catch(1),t.onLoadError(E.t0);case 13:case"end":return E.stop()}},u,null,[[1,10]])}))),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onGetAnnotationsSuccess,f=t.state.annotations;u&&u(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({annotations:!1}),errorOnDev(u);var f=t.props.onGetAnnotationsError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){var u=t.props.onRenderAnnotationLayerSuccess;u&&u()}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){errorOnDev(u);var f=t.props.onRenderAnnotationLayerError;f&&f(u)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.page;if(!n)throw new Error("Attempted to load page annotations, but no page was specified.");this.loadAnnotations()}},{key:"componentDidUpdate",value:function(n){var a=this.props,l=a.page,u=a.renderInteractiveForms;(n.page&&l!==n.page||u!==n.renderInteractiveForms)&&this.loadAnnotations()}},{key:"componentWillUnmount",value:function(){cancelRunningTask(this.runningTask)}},{key:"renderAnnotationLayer",value:function(){var n=this.state.annotations;if(n){var a=this.props,l=a.imageResourcesPath,u=a.linkService,f=a.page,d=a.renderInteractiveForms,h=this.viewport.clone({dontFlip:!0}),y={annotations:n,div:this.annotationLayer,imageResourcesPath:l,linkService:u,page:f,renderInteractiveForms:d,viewport:h};this.annotationLayer.innerHTML="";try{pdfExports.AnnotationLayer.render(y),this.onRenderSuccess()}catch(E){this.onRenderError(E)}}}},{key:"render",value:function(){var n=this;return React$2.createElement("div",{className:"react-pdf__Page__annotations annotationLayer",ref:function(l){n.annotationLayer=l}},this.renderAnnotationLayer())}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);AnnotationLayerInternal.propTypes={imageResourcesPath:PropTypes$1.string,linkService:isLinkService.isRequired,onGetAnnotationsError:PropTypes$1.func,onGetAnnotationsSuccess:PropTypes$1.func,onRenderAnnotationLayerError:PropTypes$1.func,onRenderAnnotationLayerSuccess:PropTypes$1.func,page:isPage,renderInteractiveForms:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number};var AnnotationLayer=function o(e){return React$2.createElement(DocumentContext.Consumer,null,function(r){return React$2.createElement(PageContext.Consumer,null,function(t){return React$2.createElement(AnnotationLayerInternal,_extends({},r,t,e))})})};function ownKeys(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}function _createSuper(o){var e=_isNativeReflectConstruct();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var defaultScale=1,PageInternal=function(o){_inherits(r,o);var e=_createSuper(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{page:null}),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props,f=u.onLoadSuccess,d=u.registerPage,h=t.state.page;f&&f(makePageCallback(h,t.scale)),d&&d(t.pageIndex,t.ref)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){errorOnDev(u);var f=t.props.onLoadError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"loadPage",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y;return _regeneratorRuntime.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(f=t.props.pdf,d=t.getPageNumber(),d){p.next=4;break}return p.abrupt("return");case 4:return t.setState(function(_){return _.page?{page:null}:null}),p.prev=5,h=makeCancellablePromise(f.getPage(d)),t.runningTask=h,p.next=10,h.promise;case 10:y=p.sent,t.setState({page:y},t.onLoadSuccess),p.next=18;break;case 14:p.prev=14,p.t0=p.catch(5),t.setState({page:!1}),t.onLoadError(p.t0);case 18:case"end":return p.stop()}},u,null,[[5,14]])}))),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.pdf;if(!n)throw new Error("Attempted to load a page, but no document was specified.");this.loadPage()}},{key:"componentDidUpdate",value:function(n){var a=this.props.pdf;if(n.pdf&&a!==n.pdf||this.getPageNumber()!==this.getPageNumber(n)){var l=this.props.unregisterPage;l&&l(this.getPageIndex(n)),this.loadPage()}}},{key:"componentWillUnmount",value:function(){var n=this.props.unregisterPage;n&&n(this.pageIndex),cancelRunningTask(this.runningTask)}},{key:"getPageIndex",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return isProvided(n.pageNumber)?n.pageNumber-1:isProvided(n.pageIndex)?n.pageIndex:null}},{key:"getPageNumber",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return isProvided(n.pageNumber)?n.pageNumber:isProvided(n.pageIndex)?n.pageIndex+1:null}},{key:"renderMainLayer",value:function(){var n=this.props,a=n.canvasRef,l=n.renderMode;switch(l){case"none":return null;case"svg":return React$2.createElement(PageSVG,{key:"".concat(this.pageKeyNoScale,"_svg")});case"canvas":default:return React$2.createElement(PageCanvas,{key:"".concat(this.pageKey,"_canvas"),canvasRef:a})}}},{key:"renderTextLayer",value:function(){var n=this.props.renderTextLayer;return n?React$2.createElement(TextLayer,{key:"".concat(this.pageKey,"_text")}):null}},{key:"renderAnnotationLayer",value:function(){var n=this.props.renderAnnotationLayer;return n?React$2.createElement(AnnotationLayer,{key:"".concat(this.pageKey,"_annotations")}):null}},{key:"renderChildren",value:function(){var n=this.props.children;return React$2.createElement(PageContext.Provider,{value:this.childContext},this.renderMainLayer(),this.renderTextLayer(),this.renderAnnotationLayer(),n)}},{key:"renderContent",value:function(){var n=this.pageNumber,a=this.props.pdf,l=this.state.page;if(!n){var u=this.props.noData;return React$2.createElement(Message$1,{type:"no-data"},typeof u=="function"?u():u)}if(a===null||l===null){var f=this.props.loading;return React$2.createElement(Message$1,{type:"loading"},typeof f=="function"?f():f)}if(a===!1||l===!1){var d=this.props.error;return React$2.createElement(Message$1,{type:"error"},typeof d=="function"?d():d)}return this.renderChildren()}},{key:"render",value:function(){var n=this.pageNumber,a=this.props,l=a.className,u=a.inputRef;return React$2.createElement("div",_extends({className:mergeClassNames("react-pdf__Page",l),"data-page-number":n,ref:mergeRefs(u,this.ref),style:{position:"relative"}},this.eventProps),this.renderContent())}},{key:"childContext",get:function(){var n=this.state.page;if(!n)return{};var a=this.props,l=a.customTextRenderer,u=a.onGetAnnotationsError,f=a.onGetAnnotationsSuccess,d=a.onGetTextError,h=a.onGetTextSuccess,y=a.onRenderAnnotationLayerError,E=a.onRenderAnnotationLayerSuccess,p=a.onRenderError,_=a.onRenderSuccess,g=a.renderInteractiveForms;return{customTextRenderer:l,onGetAnnotationsError:u,onGetAnnotationsSuccess:f,onGetTextError:d,onGetTextSuccess:h,onRenderAnnotationLayerError:y,onRenderAnnotationLayerSuccess:E,onRenderError:p,onRenderSuccess:_,page:n,renderInteractiveForms:g,rotate:this.rotate,scale:this.scale}}},{key:"pageIndex",get:function(){return this.getPageIndex()}},{key:"pageNumber",get:function(){return this.getPageNumber()}},{key:"rotate",get:function(){var n=this.props.rotate;if(isProvided(n))return n;var a=this.state.page;return a?a.rotate:null}},{key:"scale",get:function(){var n=this.state.page;if(!n)return null;var a=this.props,l=a.scale,u=a.width,f=a.height,d=this.rotate,h=1,y=l===null?defaultScale:l;if(u||f){var E=n.getViewport({scale:1,rotation:d});h=u?u/E.width:f/E.height}return y*h}},{key:"eventProps",get:function(){var n=this;return makeEventProps(this.props,function(){var a=n.state.page;return a&&makePageCallback(a,n.scale)})}},{key:"pageKey",get:function(){var n=this.state.page;return"".concat(n.pageIndex,"@").concat(this.scale,"/").concat(this.rotate)}},{key:"pageKeyNoScale",get:function(){var n=this.state.page;return"".concat(n.pageIndex,"/").concat(this.rotate)}}]),r}(React$2.PureComponent);PageInternal.defaultProps={error:"Failed to load the page.",loading:"Loading page…",noData:"No page specified.",renderAnnotationLayer:!0,renderInteractiveForms:!1,renderMode:"canvas",renderTextLayer:!0,scale:defaultScale};var isFunctionOrNode=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.node]);PageInternal.propTypes=_objectSpread(_objectSpread({},eventProps),{},{children:PropTypes$1.node,className:isClassName,customTextRenderer:PropTypes$1.func,error:isFunctionOrNode,height:PropTypes$1.number,imageResourcesPath:PropTypes$1.string,inputRef:isRef,loading:isFunctionOrNode,noData:isFunctionOrNode,onGetTextError:PropTypes$1.func,onGetTextSuccess:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,pageIndex:isPageIndex,pageNumber:isPageNumber,pdf:isPdf,registerPage:PropTypes$1.func,renderAnnotationLayer:PropTypes$1.bool,renderInteractiveForms:PropTypes$1.bool,renderMode:isRenderMode,renderTextLayer:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number,unregisterPage:PropTypes$1.func,width:PropTypes$1.number});function Page(o,e){return React$2.createElement(DocumentContext.Consumer,null,function(r){return React$2.createElement(PageInternal,_extends({ref:e},r,o))})}const Page$1=React$2.forwardRef(Page);isLocalFileSystem&&warnOnDev("You are running React-PDF from your local file system. PDF.js Worker may fail to load due to browser's security policies. If you're on Google Chrome, you can use --allow-file-access-from-files flag for debugging purposes.");pdfExports.GlobalWorkerOptions.workerSrc="pdf.worker.js";const DeviceDetection=()=>navigator.userAgent.match(/(android)/i)||["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,BrowserDetection=()=>{const o=navigator.userAgent.toLowerCase(),e=o.indexOf("firefox")>-1,r=o.indexOf("safari")>-1&&o.indexOf("chrome")<=-1;let t="default";return e?t="firefox":r&&(t="safari"),t};pdfExports.GlobalWorkerOptions.workerSrc=`//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfExports.version}/pdf.worker.js`;const SCALE_LIMIT=2,maxValues={default:{area:268435456,sideBig:65535},firefox:{area:124992400,sideBig:32767},safari:{area:16777216,sideBig:4194303}},getMaxPermitted=()=>{const o=BrowserDetection();return maxValues[o]},formatScale=o=>o>1?Math.floor(o):Math.floor(o*100)/100,getMaxScaleByArea=(o,e,r)=>{const t=e*r*window.devicePixelRatio**2,n=Math.sqrt(o/t);return formatScale(n)},getMaxScaleBySide=(o,e,r)=>{const t=e>r?e:r,a=o/window.devicePixelRatio/t;return formatScale(a)};function PdfVisor({url:o,endPdf:e,emitNumberOfPages:r,translate:t,soundActions:n,keyboardControl:a}){const l=React$2.useRef(),[u,f]=React$2.useState(1),[d,h]=React$2.useState(!0),[y,E]=React$2.useState(),[p,_]=React$2.useState(1),[g]=n,x=React$2.useCallback(A=>{A.getPage(1).then(w=>{const P=w.getViewport(1),O=P.viewBox[2]-P.viewBox[0],k=P.viewBox[3]-P.viewBox[1],D=getMaxPermitted(),F=getMaxScaleByArea(D.area,O,k),G=getMaxScaleBySide(D.sideBig,O,k),V=F<G?F:G;_(V>SCALE_LIMIT?SCALE_LIMIT:V)}),f(A.numPages),A.numPages&&r({numPages:A.numPages,currentPage:y});const T=()=>(setTimeout(()=>{l.current&&l.current.scrollHeight<=l.current.offsetHeight&&h(!1)},1e3),()=>{T&&clearTimeout(T)});T()},[y,r]);React$2.useEffect(()=>{E(1)},[]);const C={file:o,loading:"Loading file...",onLoadSuccess:x,onLoadError:A=>console.error(A)},R=A=>{g("click-ui"),l.current.scrollTo(0,0),h(!1),E(y+A),r({numPages:u,currentPage:y+A}),y===u-1&&e()};a(u>1&&y!==1?()=>R(-1):null,u>1&&y!==u?()=>R(1):null);const S=()=>{h(!1)};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"pdf-box",dir:LangIsRtl()?"rtl":"auto",children:[jsxRuntimeExports.jsxs("div",{className:"pdf-box__scrollwrap",children:[jsxRuntimeExports.jsxs("div",{tabIndex:"0",onScroll:S,ref:l,className:`pdf-box__scroll ${d?"pdf-box__scroll--overlay":""}`,children:[jsxRuntimeExports.jsx(Document$1,{...C,children:jsxRuntimeExports.jsx(Page$1,{renderTextLayer:!1,scale:p,pageNumber:y})}),jsxRuntimeExports.jsx("div",{className:"pdf-box__mouse icon-scroll-down-black"})]}),u>1&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:"pdf-box__paginator",children:jsxRuntimeExports.jsxs("span",{children:[t("storylines.misc.page")," ",y," ",t("storylines.misc.of")," ",u]})})})]}),u>1&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("button",{className:`pdf-box__arrow pdf-box__arrow--left gat--btn__round ${y===1?"pdf-box__arrow--hidden":""}`,type:"button",disabled:y===1,onClick:()=>R(-1),"aria-label":LangIsRtl()?t("storylines.misc.nextPage"):t("storylines.misc.previousPage"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{className:`pdf-box__arrow pdf-box__arrow--right gat--btn__round ${y===u?"pdf-box__arrow--hidden":""}`,type:"button",disabled:y===u,onClick:()=>R(1),"aria-label":LangIsRtl()?t("storylines.misc.previousPage"):t("storylines.misc.nextPage"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})})}function PdfComponent({emitEvent:o,soundActions:e,keyboardControl:r,documentType:t,name:n,required:a,viewed:l,visible:u,documentId:f,documentId_labelId:d,...h}){const y=k=>o({type:"translate",payload:k}),[E]=e,p=h.document,{url:_}=p||"",[g,x]=React$2.useState(!1),C=React$2.useMemo(()=>({documentType:t,name:n,documentId:d,type:"pdf"}),[t,n,d]),R=React$2.useCallback(()=>{o({type:"finishMedia",payload:C})},[C,o]),[S,A]=React$2.useState(!1),[T,w]=React$2.useState(!1);if(React$2.useEffect(()=>{u||R(),a||x(!0)},[u,R,a]),!u)return null;const P=()=>{x(!0)},O=k=>{k.numPages===k.currentPage?w(!0):w(!1),k.numPages===1&&A(!0)};return r(null,S||!l&&T||T&&!a?R:null,S||!l&&T||!a?R:null),jsxRuntimeExports.jsxs("div",{className:`${l?"notes--results":""}`,children:[(S||!l&&g)&&jsxRuntimeExports.jsx("div",{className:"position--absolute top right z-index1",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:()=>{R(),E("click-ui")},"aria-label":y("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})}),_&&jsxRuntimeExports.jsx(PdfVisor,{soundActions:e,emitNumberOfPages:k=>O(k),url:_,endPdf:P,translate:y,keyboardControl:r})]})}function UrlComponent({emitEvent:o,name:e,name_labelId:r,link:t,link_labelId:n,text:a,text_labelId:l,textForLink:u,viewed:f,documentType:d,soundActions:h,keyboardControl:y}){const E=S=>o({type:"translate",payload:S}),p={documentType:d,name:r,text:l,link:n,type:"url"},[_]=h,g=()=>{_("click-ui"),o({type:"finishMedia",payload:p})},[x,C]=React$2.useState(!1);y(null,!f&&x?g:null,!f&&x?g:null);const R=t.indexOf("http")!==0?`http://${t}`:t;return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup popup--link",children:[!f&&x?jsxRuntimeExports.jsx("button",{className:"popup--close unset-button","data-testid":"close",type:"button","aria-label":E("storylines.misc.closePiece"),onClick:()=>g(),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})}):null,jsxRuntimeExports.jsx("span",{className:"popup--link__title",children:e}),jsxRuntimeExports.jsx("span",{className:"popup--link__desc",children:a}),jsxRuntimeExports.jsx("a",{className:"popup--link__lineclamp popup--link__url",href:R,target:"_blank",rel:"noopener noreferrer",onClick:()=>{_("click-ui"),C(!0)},children:u||t})]})})}var hls={exports:{}};(function(o,e){typeof window<"u"&&function(t,n){o.exports=n()}(commonjsGlobal,function(){return function(r){var t={};function n(a){if(t[a])return t[a].exports;var l=t[a]={i:a,l:!1,exports:{}};return r[a].call(l.exports,l,l.exports,n),l.l=!0,l.exports}return n.m=r,n.c=t,n.d=function(a,l,u){n.o(a,l)||Object.defineProperty(a,l,{enumerable:!0,get:u})},n.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},n.t=function(a,l){if(l&1&&(a=n(a)),l&8||l&4&&typeof a=="object"&&a&&a.__esModule)return a;var u=Object.create(null);if(n.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:a}),l&2&&typeof a!="string")for(var f in a)n.d(u,f,(function(d){return a[d]}).bind(null,f));return u},n.n=function(a){var l=a&&a.__esModule?function(){return a.default}:function(){return a};return n.d(l,"a",l),l},n.o=function(a,l){return Object.prototype.hasOwnProperty.call(a,l)},n.p="/dist/",n(n.s="./src/hls.js")}({"./node_modules/eventemitter3/index.js":function(r,t,n){var a=Object.prototype.hasOwnProperty,l="~";function u(){}Object.create&&(u.prototype=Object.create(null),new u().__proto__||(l=!1));function f(E,p,_){this.fn=E,this.context=p,this.once=_||!1}function d(E,p,_,g,x){if(typeof _!="function")throw new TypeError("The listener must be a function");var C=new f(_,g||E,x),R=l?l+p:p;return E._events[R]?E._events[R].fn?E._events[R]=[E._events[R],C]:E._events[R].push(C):(E._events[R]=C,E._eventsCount++),E}function h(E,p){--E._eventsCount===0?E._events=new u:delete E._events[p]}function y(){this._events=new u,this._eventsCount=0}y.prototype.eventNames=function(){var p=[],_,g;if(this._eventsCount===0)return p;for(g in _=this._events)a.call(_,g)&&p.push(l?g.slice(1):g);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(_)):p},y.prototype.listeners=function(p){var _=l?l+p:p,g=this._events[_];if(!g)return[];if(g.fn)return[g.fn];for(var x=0,C=g.length,R=new Array(C);x<C;x++)R[x]=g[x].fn;return R},y.prototype.listenerCount=function(p){var _=l?l+p:p,g=this._events[_];return g?g.fn?1:g.length:0},y.prototype.emit=function(p,_,g,x,C,R){var S=l?l+p:p;if(!this._events[S])return!1;var A=this._events[S],T=arguments.length,w,P;if(A.fn){switch(A.once&&this.removeListener(p,A.fn,void 0,!0),T){case 1:return A.fn.call(A.context),!0;case 2:return A.fn.call(A.context,_),!0;case 3:return A.fn.call(A.context,_,g),!0;case 4:return A.fn.call(A.context,_,g,x),!0;case 5:return A.fn.call(A.context,_,g,x,C),!0;case 6:return A.fn.call(A.context,_,g,x,C,R),!0}for(P=1,w=new Array(T-1);P<T;P++)w[P-1]=arguments[P];A.fn.apply(A.context,w)}else{var O=A.length,k;for(P=0;P<O;P++)switch(A[P].once&&this.removeListener(p,A[P].fn,void 0,!0),T){case 1:A[P].fn.call(A[P].context);break;case 2:A[P].fn.call(A[P].context,_);break;case 3:A[P].fn.call(A[P].context,_,g);break;case 4:A[P].fn.call(A[P].context,_,g,x);break;default:if(!w)for(k=1,w=new Array(T-1);k<T;k++)w[k-1]=arguments[k];A[P].fn.apply(A[P].context,w)}}return!0},y.prototype.on=function(p,_,g){return d(this,p,_,g,!1)},y.prototype.once=function(p,_,g){return d(this,p,_,g,!0)},y.prototype.removeListener=function(p,_,g,x){var C=l?l+p:p;if(!this._events[C])return this;if(!_)return h(this,C),this;var R=this._events[C];if(R.fn)R.fn===_&&(!x||R.once)&&(!g||R.context===g)&&h(this,C);else{for(var S=0,A=[],T=R.length;S<T;S++)(R[S].fn!==_||x&&!R[S].once||g&&R[S].context!==g)&&A.push(R[S]);A.length?this._events[C]=A.length===1?A[0]:A:h(this,C)}return this},y.prototype.removeAllListeners=function(p){var _;return p?(_=l?l+p:p,this._events[_]&&h(this,_)):(this._events=new u,this._eventsCount=0),this},y.prototype.off=y.prototype.removeListener,y.prototype.addListener=y.prototype.on,y.prefixed=l,y.EventEmitter=y,r.exports=y},"./node_modules/node-libs-browser/node_modules/events/events.js":function(r,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}r.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(d){if(!l(d)||d<0||isNaN(d))throw TypeError("n must be a positive number");return this._maxListeners=d,this},n.prototype.emit=function(d){var h,y,E,p,_,g;if(this._events||(this._events={}),d==="error"&&(!this._events.error||u(this._events.error)&&!this._events.error.length)){if(h=arguments[1],h instanceof Error)throw h;var x=new Error('Uncaught, unspecified "error" event. ('+h+")");throw x.context=h,x}if(y=this._events[d],f(y))return!1;if(a(y))switch(arguments.length){case 1:y.call(this);break;case 2:y.call(this,arguments[1]);break;case 3:y.call(this,arguments[1],arguments[2]);break;default:p=Array.prototype.slice.call(arguments,1),y.apply(this,p)}else if(u(y))for(p=Array.prototype.slice.call(arguments,1),g=y.slice(),E=g.length,_=0;_<E;_++)g[_].apply(this,p);return!0},n.prototype.addListener=function(d,h){var y;if(!a(h))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",d,a(h.listener)?h.listener:h),this._events[d]?u(this._events[d])?this._events[d].push(h):this._events[d]=[this._events[d],h]:this._events[d]=h,u(this._events[d])&&!this._events[d].warned&&(f(this._maxListeners)?y=n.defaultMaxListeners:y=this._maxListeners,y&&y>0&&this._events[d].length>y&&(this._events[d].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[d].length),typeof console.trace=="function"&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(d,h){if(!a(h))throw TypeError("listener must be a function");var y=!1;function E(){this.removeListener(d,E),y||(y=!0,h.apply(this,arguments))}return E.listener=h,this.on(d,E),this},n.prototype.removeListener=function(d,h){var y,E,p,_;if(!a(h))throw TypeError("listener must be a function");if(!this._events||!this._events[d])return this;if(y=this._events[d],p=y.length,E=-1,y===h||a(y.listener)&&y.listener===h)delete this._events[d],this._events.removeListener&&this.emit("removeListener",d,h);else if(u(y)){for(_=p;_-- >0;)if(y[_]===h||y[_].listener&&y[_].listener===h){E=_;break}if(E<0)return this;y.length===1?(y.length=0,delete this._events[d]):y.splice(E,1),this._events.removeListener&&this.emit("removeListener",d,h)}return this},n.prototype.removeAllListeners=function(d){var h,y;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[d]&&delete this._events[d],this;if(arguments.length===0){for(h in this._events)h!=="removeListener"&&this.removeAllListeners(h);return this.removeAllListeners("removeListener"),this._events={},this}if(y=this._events[d],a(y))this.removeListener(d,y);else if(y)for(;y.length;)this.removeListener(d,y[y.length-1]);return delete this._events[d],this},n.prototype.listeners=function(d){var h;return!this._events||!this._events[d]?h=[]:a(this._events[d])?h=[this._events[d]]:h=this._events[d].slice(),h},n.prototype.listenerCount=function(d){if(this._events){var h=this._events[d];if(a(h))return 1;if(h)return h.length}return 0},n.listenerCount=function(d,h){return d.listenerCount(h)};function a(d){return typeof d=="function"}function l(d){return typeof d=="number"}function u(d){return typeof d=="object"&&d!==null}function f(d){return d===void 0}},"./node_modules/url-toolkit/src/url-toolkit.js":function(r,t,n){(function(a){var l=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,u=/^([^\/?#]*)(.*)$/,f=/(?:\/|^)\.(?=\/)/g,d=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,h={buildAbsoluteURL:function(y,E,p){if(p=p||{},y=y.trim(),E=E.trim(),!E){if(!p.alwaysNormalize)return y;var _=h.parseURL(y);if(!_)throw new Error("Error trying to parse base URL.");return _.path=h.normalizePath(_.path),h.buildURLFromParts(_)}var g=h.parseURL(E);if(!g)throw new Error("Error trying to parse relative URL.");if(g.scheme)return p.alwaysNormalize?(g.path=h.normalizePath(g.path),h.buildURLFromParts(g)):E;var x=h.parseURL(y);if(!x)throw new Error("Error trying to parse base URL.");if(!x.netLoc&&x.path&&x.path[0]!=="/"){var C=u.exec(x.path);x.netLoc=C[1],x.path=C[2]}x.netLoc&&!x.path&&(x.path="/");var R={scheme:x.scheme,netLoc:g.netLoc,path:null,params:g.params,query:g.query,fragment:g.fragment};if(!g.netLoc&&(R.netLoc=x.netLoc,g.path[0]!=="/"))if(!g.path)R.path=x.path,g.params||(R.params=x.params,g.query||(R.query=x.query));else{var S=x.path,A=S.substring(0,S.lastIndexOf("/")+1)+g.path;R.path=h.normalizePath(A)}return R.path===null&&(R.path=p.alwaysNormalize?h.normalizePath(g.path):g.path),h.buildURLFromParts(R)},parseURL:function(y){var E=l.exec(y);return E?{scheme:E[1]||"",netLoc:E[2]||"",path:E[3]||"",params:E[4]||"",query:E[5]||"",fragment:E[6]||""}:null},normalizePath:function(y){for(y=y.split("").reverse().join("").replace(f,"");y.length!==(y=y.replace(d,"")).length;);return y.split("").reverse().join("")},buildURLFromParts:function(y){return y.scheme+y.netLoc+y.path+y.params+y.query+y.fragment}};r.exports=h})()},"./node_modules/webworkify-webpack/index.js":function(r,t,n){function a(p){var _={};function g(C){if(_[C])return _[C].exports;var R=_[C]={i:C,l:!1,exports:{}};return p[C].call(R.exports,R,R.exports,g),R.l=!0,R.exports}g.m=p,g.c=_,g.i=function(C){return C},g.d=function(C,R,S){g.o(C,R)||Object.defineProperty(C,R,{configurable:!1,enumerable:!0,get:S})},g.r=function(C){Object.defineProperty(C,"__esModule",{value:!0})},g.n=function(C){var R=C&&C.__esModule?function(){return C.default}:function(){return C};return g.d(R,"a",R),R},g.o=function(C,R){return Object.prototype.hasOwnProperty.call(C,R)},g.p="/",g.oe=function(C){throw console.error(C),C};var x=g(g.s=ENTRY_MODULE);return x.default||x}var l="[\\.|\\-|\\+|\\w|/|@]+",u="\\((/\\*.*?\\*/)?s?.*?("+l+").*?\\)";function f(p){return(p+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function d(p){return!isNaN(1*p)}function h(p,_,g){var x={};x[g]=[];var C=_.toString(),R=C.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!R)return x;for(var S=R[1],A=new RegExp("(\\\\n|\\W)"+f(S)+u,"g"),T;T=A.exec(C);)T[3]!=="dll-reference"&&x[g].push(T[3]);for(A=new RegExp("\\("+f(S)+'\\("(dll-reference\\s('+l+'))"\\)\\)'+u,"g");T=A.exec(C);)p[T[2]]||(x[g].push(T[1]),p[T[2]]=n(T[1]).m),x[T[2]]=x[T[2]]||[],x[T[2]].push(T[4]);for(var w=Object.keys(x),P=0;P<w.length;P++)for(var O=0;O<x[w[P]].length;O++)d(x[w[P]][O])&&(x[w[P]][O]=1*x[w[P]][O]);return x}function y(p){var _=Object.keys(p);return _.reduce(function(g,x){return g||p[x].length>0},!1)}function E(p,_){for(var g={main:[_]},x={main:[]},C={main:{}};y(g);)for(var R=Object.keys(g),S=0;S<R.length;S++){var A=R[S],T=g[A],w=T.pop();if(C[A]=C[A]||{},!(C[A][w]||!p[A][w])){C[A][w]=!0,x[A]=x[A]||[],x[A].push(w);for(var P=h(p,p[A][w],A),O=Object.keys(P),k=0;k<O.length;k++)g[O[k]]=g[O[k]]||[],g[O[k]]=g[O[k]].concat(P[O[k]])}}return x}r.exports=function(p,_){_=_||{};var g={main:n.m},x=_.all?{main:Object.keys(g.main)}:E(g,p),C="";Object.keys(x).filter(function(w){return w!=="main"}).forEach(function(w){for(var P=0;x[w][P];)P++;x[w].push(P),g[w][P]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",C=C+"var "+w+" = ("+a.toString().replace("ENTRY_MODULE",JSON.stringify(P))+")({"+x[w].map(function(O){return""+JSON.stringify(O)+": "+g[w][O].toString()}).join(",")+`});
52
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _toConsumableArray(o){return _arrayWithoutHoles(o)||_iterableToArray(o)||_unsupportedIterableToArray$1(o)||_nonIterableSpread()}var eventProps=function(){var o={};return[].concat(_toConsumableArray(mouseEvents),_toConsumableArray(touchEvents),_toConsumableArray(keyboardEvents)).forEach(function(e){o[e]=PropTypes$1.func}),o}(),fileTypes=[PropTypes$1.string,PropTypes$1.instanceOf(ArrayBuffer),PropTypes$1.shape({data:PropTypes$1.object,httpHeaders:PropTypes$1.object,range:PropTypes$1.object,url:PropTypes$1.string,withCredentials:PropTypes$1.bool})];typeof File<"u"&&fileTypes.push(PropTypes$1.instanceOf(File));typeof Blob<"u"&&fileTypes.push(PropTypes$1.instanceOf(Blob));var isClassName=PropTypes$1.oneOfType([PropTypes$1.string,PropTypes$1.arrayOf(PropTypes$1.string)]);PropTypes$1.oneOfType(fileTypes);var isLinkService=PropTypes$1.instanceOf(LinkService);PropTypes$1.oneOf(["_self","_blank","_parent","_top"]);var isPage=PropTypes$1.shape({_transport:PropTypes$1.shape({fontLoader:PropTypes$1.object.isRequired}).isRequired,commonObjs:PropTypes$1.shape({_objs:PropTypes$1.object.isRequired}).isRequired,getAnnotations:PropTypes$1.func.isRequired,getTextContent:PropTypes$1.func.isRequired,getViewport:PropTypes$1.func.isRequired,render:PropTypes$1.func.isRequired}),isPageIndex=function o(e,r,t){var n=e[r],a=e.pageNumber,l=e.pdf;if(!isDefined(l))return null;if(isDefined(n)){if(typeof n!="number")return new Error("`".concat(r,"` of type `").concat(_typeof$1(n),"` supplied to `").concat(t,"`, expected `number`."));if(n<0)return new Error("Expected `".concat(r,"` to be greater or equal to 0."));var u=l.numPages;if(n+1>u)return new Error("Expected `".concat(r,"` to be less or equal to ").concat(u-1,"."))}else if(!isDefined(a))return new Error("`".concat(r,"` not supplied. Either pageIndex or pageNumber must be supplied to `").concat(t,"`."));return null},isPageNumber=function o(e,r,t){var n=e[r],a=e.pageIndex,l=e.pdf;if(!isDefined(l))return null;if(isDefined(n)){if(typeof n!="number")return new Error("`".concat(r,"` of type `").concat(_typeof$1(n),"` supplied to `").concat(t,"`, expected `number`."));if(n<1)return new Error("Expected `".concat(r,"` to be greater or equal to 1."));var u=l.numPages;if(n>u)return new Error("Expected `".concat(r,"` to be less or equal to ").concat(u,"."))}else if(!isDefined(a))return new Error("`".concat(r,"` not supplied. Either pageIndex or pageNumber must be supplied to `").concat(t,"`."));return null},isPdf=PropTypes$1.oneOfType([PropTypes$1.shape({getDestination:PropTypes$1.func.isRequired,getOutline:PropTypes$1.func.isRequired,getPage:PropTypes$1.func.isRequired,numPages:PropTypes$1.number.isRequired}),PropTypes$1.bool]),isRef=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.shape({current:PropTypes$1.any})]),isRenderMode=PropTypes$1.oneOf(["canvas","none","svg"]),isRotate=PropTypes$1.oneOf([0,90,180,270]);function ownKeys$2(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread$2(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$2(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys$2(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}function _createSuper$6(o){var e=_isNativeReflectConstruct$6();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$6(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PDFDataRangeTransport=pdfExports.PDFDataRangeTransport,Document$1=function(o){_inherits(r,o);var e=_createSuper$6(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{pdf:null}),_defineProperty(_assertThisInitialized$1(t),"viewer",{scrollPageIntoView:function(f){var d=f.pageNumber,h=t.props.onItemClick;if(h){h({pageNumber:d});return}var y=t.pages[d-1];if(y){y.scrollIntoView();return}warnOnDev("Warning: An internal link leading to page ".concat(d," was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>."))}}),_defineProperty(_assertThisInitialized$1(t),"linkService",new LinkService({eventBus})),_defineProperty(_assertThisInitialized$1(t),"loadDocument",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y,E,p,_;return _regeneratorRuntime.wrap(function(x){for(;;)switch(x.prev=x.next){case 0:return f=null,x.prev=1,x.next=4,t.findDocumentSource();case 4:f=x.sent,t.onSourceSuccess(),x.next=11;break;case 8:x.prev=8,x.t0=x.catch(1),t.onSourceError(x.t0);case 11:if(f){x.next=13;break}return x.abrupt("return");case 13:return t.setState(function(C){return C.pdf?{pdf:null}:null}),d=t.props,h=d.options,y=d.onLoadProgress,E=d.onPassword,x.prev=15,cancelRunningTask(t.runningTask),t.loadingTask=pdfExports.getDocument(_objectSpread$2(_objectSpread$2({},f),h)),t.loadingTask.onPassword=E,y&&(t.loadingTask.onProgress=y),p=makeCancellablePromise(t.loadingTask.promise),t.runningTask=p,x.next=24,p.promise;case 24:_=x.sent,t.setState(function(C){return C.pdf&&C.pdf.fingerprint===_.fingerprint?null:{pdf:_}},t.onLoadSuccess),x.next=31;break;case 28:x.prev=28,x.t1=x.catch(15),t.onLoadError(x.t1);case 31:case"end":return x.stop()}},u,null,[[1,8],[15,28]])}))),_defineProperty(_assertThisInitialized$1(t),"setupLinkService",function(){t.linkService.setViewer(t.viewer);var u=_assertThisInitialized$1(t);Object.defineProperty(t.linkService,"externalLinkTarget",{get:function(){var d=u.props.externalLinkTarget;switch(d){case"_self":return 1;case"_blank":return 2;case"_parent":return 3;case"_top":return 4;default:return 0}}})}),_defineProperty(_assertThisInitialized$1(t),"onSourceSuccess",function(){var u=t.props.onSourceSuccess;u&&u()}),_defineProperty(_assertThisInitialized$1(t),"onSourceError",function(u){errorOnDev(u);var f=t.props.onSourceError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onLoadSuccess,f=t.state.pdf;u&&u(f),t.pages=new Array(f.numPages),t.linkService.setDocument(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({pdf:!1}),errorOnDev(u);var f=t.props.onLoadError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"findDocumentSource",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y,E;return _regeneratorRuntime.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(f=t.props.file,f){_.next=3;break}return _.abrupt("return",null);case 3:if(typeof f!="string"){_.next=9;break}if(!isDataURI(f)){_.next=7;break}return d=dataURItoByteString(f),_.abrupt("return",{data:d});case 7:return displayCORSWarning(),_.abrupt("return",{url:f});case 9:if(!(f instanceof PDFDataRangeTransport)){_.next=11;break}return _.abrupt("return",{range:f});case 11:if(!isArrayBuffer(f)){_.next=13;break}return _.abrupt("return",{data:f});case 13:if(!isBrowser){_.next=19;break}if(!(isBlob(f)||isFile(f))){_.next=19;break}return _.next=17,loadFromFile(f);case 17:return _.t0=_.sent,_.abrupt("return",{data:_.t0});case 19:if(_typeof$1(f)==="object"){_.next=21;break}throw new Error("Invalid parameter in file, need either Uint8Array, string or a parameter object");case 21:if(!(!f.url&&!f.data&&!f.range)){_.next=23;break}throw new Error("Invalid parameter object: need either .data, .range or .url");case 23:if(typeof f.url!="string"){_.next=29;break}if(!isDataURI(f.url)){_.next=28;break}return h=f.url,y=_objectWithoutProperties(f,["url"]),E=dataURItoByteString(h),_.abrupt("return",_objectSpread$2({data:E},y));case 28:displayCORSWarning();case 29:return _.abrupt("return",f);case 30:case"end":return _.stop()}},u)}))),_defineProperty(_assertThisInitialized$1(t),"registerPage",function(u,f){t.pages[u]=f}),_defineProperty(_assertThisInitialized$1(t),"unregisterPage",function(u){delete t.pages[u]}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.loadDocument(),this.setupLinkService()}},{key:"componentDidUpdate",value:function(n){var a=this.props.file;a!==n.file&&this.loadDocument()}},{key:"componentWillUnmount",value:function(){this.loadingTask&&this.loadingTask.destroy(),cancelRunningTask(this.runningTask)}},{key:"renderChildren",value:function(){var n=this.props.children;return React$2.createElement(DocumentContext.Provider,{value:this.childContext},n)}},{key:"renderContent",value:function(){var n=this.props.file,a=this.state.pdf;if(!n){var l=this.props.noData;return React$2.createElement(Message$1,{type:"no-data"},typeof l=="function"?l():l)}if(a===null){var u=this.props.loading;return React$2.createElement(Message$1,{type:"loading"},typeof u=="function"?u():u)}if(a===!1){var f=this.props.error;return React$2.createElement(Message$1,{type:"error"},typeof f=="function"?f():f)}return this.renderChildren()}},{key:"render",value:function(){var n=this.props,a=n.className,l=n.inputRef;return React$2.createElement("div",_extends({className:mergeClassNames("react-pdf__Document",a),ref:l},this.eventProps),this.renderContent())}},{key:"childContext",get:function(){var n=this.linkService,a=this.registerPage,l=this.unregisterPage,u=this.props,f=u.imageResourcesPath,d=u.renderMode,h=u.rotate,y=this.state.pdf;return{imageResourcesPath:f,linkService:n,pdf:y,registerPage:a,renderMode:d,rotate:h,unregisterPage:l}}},{key:"eventProps",get:function(){var n=this;return makeEventProps(this.props,function(){return n.state.pdf})}}]),r}(React$2.PureComponent);Document$1.defaultProps={error:"Failed to load PDF file.",loading:"Loading PDF…",noData:"No PDF file specified.",onPassword:function o(e,r){switch(r){case PasswordResponses.NEED_PASSWORD:{var t=prompt("Enter the password to open this PDF file.");e(t);break}case PasswordResponses.INCORRECT_PASSWORD:{var n=prompt("Invalid password. Please try again.");e(n);break}}}};var isFunctionOrNode$1=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.node]);Document$1.propTypes=_objectSpread$2(_objectSpread$2({},eventProps),{},{children:PropTypes$1.node,className:isClassName,error:isFunctionOrNode$1,file:isFile,imageResourcesPath:PropTypes$1.string,inputRef:isRef,loading:isFunctionOrNode$1,noData:isFunctionOrNode$1,onItemClick:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadProgress:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,onPassword:PropTypes$1.func,onSourceError:PropTypes$1.func,onSourceSuccess:PropTypes$1.func,rotate:PropTypes$1.number});var isDestination=PropTypes$1.oneOfType([PropTypes$1.string,PropTypes$1.arrayOf(PropTypes$1.any)]);PropTypes$1.shape({dest:isDestination,items:PropTypes$1.arrayOf(PropTypes$1.shape({dest:isDestination,title:PropTypes$1.string})),title:PropTypes$1.string}).isRequired,PropTypes$1.func,isPdf.isRequired;function ownKeys$1(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread$1(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$1(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys$1(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}_objectSpread$1({className:isClassName,inputRef:isRef,onItemClick:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,pdf:isPdf},eventProps);function mergeRefs(){for(var o=[],e=0;e<arguments.length;e++)o[e]=arguments[e];var r=o.filter(Boolean);if(r.length<=1){var t=r[0];return t||null}return function(a){r.forEach(function(l){typeof l=="function"?l(a):l&&(l.current=a)})}}const PageContext=React$2.createContext(null);function _createSuper$5(o){var e=_isNativeReflectConstruct$5();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$5(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PageCanvasInternal=function(o){_inherits(r,o);var e=_createSuper$5(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){t.renderer=null;var u=t.props,f=u.onRenderSuccess,d=u.page,h=u.scale;f&&f(makePageCallback(d,h))}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){if(!isCancelException(u)){errorOnDev(u);var f=t.props.onRenderError;f&&f(u)}}),_defineProperty(_assertThisInitialized$1(t),"drawPageOnCanvas",function(){var u=_assertThisInitialized$1(t),f=u.canvasLayer;if(!f)return null;var d=_assertThisInitialized$1(t),h=d.renderViewport,y=d.viewport,E=t.props,p=E.page,_=E.renderInteractiveForms;f.width=h.width,f.height=h.height,f.style.width="".concat(Math.floor(y.width),"px"),f.style.height="".concat(Math.floor(y.height),"px");var g={get canvasContext(){return f.getContext("2d")},viewport:h,renderInteractiveForms:_};return t.cancelRenderingTask(),t.renderer=p.render(g),t.renderer.promise.then(t.onRenderSuccess).catch(t.onRenderError)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.drawPageOnCanvas()}},{key:"componentDidUpdate",value:function(n){var a=this.props,l=a.page,u=a.renderInteractiveForms;u!==n.renderInteractiveForms&&(l.cleanup(),this.drawPageOnCanvas())}},{key:"componentWillUnmount",value:function(){this.cancelRenderingTask(),this.canvasLayer&&(this.canvasLayer.width=0,this.canvasLayer.height=0,this.canvasLayer=null)}},{key:"cancelRenderingTask",value:function(){this.renderer&&this.renderer._internalRenderTask.running&&this.renderer._internalRenderTask.cancel()}},{key:"render",value:function(){var n=this,a=this.props.canvasRef;return React$2.createElement("canvas",{className:"react-pdf__Page__canvas",dir:"ltr",ref:mergeRefs(a,function(l){n.canvasLayer=l}),style:{display:"block",userSelect:"none"}})}},{key:"renderViewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale,f=getPixelRatio();return a.getViewport({scale:u*f,rotation:l})}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);PageCanvasInternal.propTypes={canvasRef:isRef,onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,page:isPage.isRequired,renderInteractiveForms:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number};function PageCanvas(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(PageCanvasInternal,_extends({},e,o))})}function _createSuper$4(o){var e=_isNativeReflectConstruct$4();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$4(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PageSVGInternal=function(o){_inherits(r,o);var e=_createSuper$4(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{svg:null}),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){t.renderer=null;var u=t.props,f=u.onRenderSuccess,d=u.page,h=u.scale;f&&f(makePageCallback(d,h))}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){if(!isCancelException(u)){errorOnDev(u);var f=t.props.onRenderError;f&&f(u)}}),_defineProperty(_assertThisInitialized$1(t),"renderSVG",function(){var u=t.props.page;return t.renderer=u.getOperatorList(),t.renderer.then(function(f){var d=new pdfExports.SVGGraphics(u.commonObjs,u.objs);t.renderer=d.getSVG(f,t.viewport).then(function(h){t.setState({svg:h},t.onRenderSuccess)}).catch(t.onRenderError)}).catch(t.onRenderError)}),_defineProperty(_assertThisInitialized$1(t),"drawPageOnContainer",function(u){var f=t.state.svg;if(!(!u||!f)){u.firstElementChild||u.appendChild(f);var d=t.viewport,h=d.width,y=d.height;f.setAttribute("width",h),f.setAttribute("height",y)}}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.renderSVG()}},{key:"render",value:function(){var n=this,a=this.viewport,l=a.width,u=a.height;return React$2.createElement("div",{className:"react-pdf__Page__svg",ref:function(d){return n.drawPageOnContainer(d)},style:{display:"block",backgroundColor:"white",overflow:"hidden",width:l,height:u,userSelect:"none"}})}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);PageSVGInternal.propTypes={onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number};function PageSVG(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(PageSVGInternal,_extends({},e,o))})}function _createSuper$3(o){var e=_isNativeReflectConstruct$3();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$3(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var TextLayerItemInternal=function(o){_inherits(r,o);var e=_createSuper$3(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"getElementWidth",function(u){var f=_assertThisInitialized$1(t),d=f.sideways;return u.getBoundingClientRect()[d?"height":"width"]}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.alignTextItem()}},{key:"componentDidUpdate",value:function(){this.alignTextItem()}},{key:"getFontData",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function a(l){var u,f;return _regeneratorRuntime.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return u=this.props.page,h.next=3,new Promise(function(y){u.commonObjs.get(l,y)});case 3:return f=h.sent,h.abrupt("return",f);case 5:case"end":return h.stop()}},a,this)}));function n(a){return t.apply(this,arguments)}return n}()},{key:"alignTextItem",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function a(){var l,u,f,d,h,y,E,p,_,g,x;return _regeneratorRuntime.wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(l=this.item,l){R.next=3;break}return R.abrupt("return");case 3:return l.style.transform="",u=this.props,f=u.fontName,d=u.scale,h=u.width,l.style.fontFamily="".concat(f,", sans-serif"),R.next=8,this.getFontData(f);case 8:y=R.sent,E=y?y.fallbackName:"sans-serif",l.style.fontFamily="".concat(f,", ").concat(E),p=h*d,_=this.getElementWidth(l),g="scaleX(".concat(p/_,")"),x=y?y.ascent:0,x&&(g+=" translateY(".concat((1-x)*100,"%)")),l.style.transform=g,l.style.WebkitTransform=g;case 18:case"end":return R.stop()}},a,this)}));function n(){return t.apply(this,arguments)}return n}()},{key:"render",value:function(){var n=this,a=this.fontSize,l=this.top,u=this.left,f=this.props,d=f.customTextRenderer,h=f.scale,y=f.str;return React$2.createElement("span",{ref:function(p){n.item=p},style:{height:"1em",fontFamily:"sans-serif",fontSize:"".concat(a*h,"px"),position:"absolute",top:"".concat(l*h,"px"),left:"".concat(u*h,"px"),transformOrigin:"left bottom",whiteSpace:"pre",pointerEvents:"all"}},d?d(this.props):y)}},{key:"unrotatedViewport",get:function(){var n=this.props,a=n.page,l=n.scale;return a.getViewport({scale:l})}},{key:"rotate",get:function(){var n=this.props,a=n.page,l=n.rotate;return l-a.rotate}},{key:"sideways",get:function(){var n=this.rotate;return n%180!==0}},{key:"defaultSideways",get:function(){var n=this.unrotatedViewport.rotation;return n%180!==0}},{key:"fontSize",get:function(){var n=this.props.transform,a=this.defaultSideways,l=_slicedToArray$1(n,2),u=l[0],f=l[1];return a?f:u}},{key:"top",get:function(){var n=this.props.transform,a=this.unrotatedViewport,l=this.defaultSideways,u=_slicedToArray$1(n,6),f=u[2],d=u[3],h=u[4],y=u[5],E=_slicedToArray$1(a.viewBox,4),p=E[1],_=E[3];return l?h+f+p:_-(y+d)}},{key:"left",get:function(){var n=this.props.transform,a=this.unrotatedViewport,l=this.defaultSideways,u=_slicedToArray$1(n,6),f=u[4],d=u[5],h=_slicedToArray$1(a.viewBox,1),y=h[0];return l?d-y:f-y}}]),r}(React$2.PureComponent);TextLayerItemInternal.propTypes={customTextRenderer:PropTypes$1.func,fontName:PropTypes$1.string.isRequired,itemIndex:PropTypes$1.number.isRequired,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number,str:PropTypes$1.string.isRequired,transform:PropTypes$1.arrayOf(PropTypes$1.number).isRequired,width:PropTypes$1.number.isRequired};function TextLayerItem(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(TextLayerItemInternal,_extends({},e,o))})}function _createSuper$2(o){var e=_isNativeReflectConstruct$2();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$2(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var TextLayerInternal=function(o){_inherits(r,o);var e=_createSuper$2(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{textItems:null}),_defineProperty(_assertThisInitialized$1(t),"loadTextItems",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y;return _regeneratorRuntime.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return f=t.props.page,p.prev=1,d=makeCancellablePromise(f.getTextContent()),t.runningTask=d,p.next=6,d.promise;case 6:h=p.sent,y=h.items,t.setState({textItems:y},t.onLoadSuccess),p.next=14;break;case 11:p.prev=11,p.t0=p.catch(1),t.onLoadError(p.t0);case 14:case"end":return p.stop()}},u,null,[[1,11]])}))),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onGetTextSuccess,f=t.state.textItems;u&&u(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({textItems:!1}),errorOnDev(u);var f=t.props.onGetTextError;f&&f(u)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.page;if(!n)throw new Error("Attempted to load page text content, but no page was specified.");this.loadTextItems()}},{key:"componentDidUpdate",value:function(n){var a=this.props.page;n.page&&a!==n.page&&this.loadTextItems()}},{key:"componentWillUnmount",value:function(){cancelRunningTask(this.runningTask)}},{key:"renderTextItems",value:function(){var n=this.state.textItems;return n?n.map(function(a,l){return React$2.createElement(TextLayerItem,_extends({key:l,itemIndex:l},a))}):null}},{key:"render",value:function(){var n=this.unrotatedViewport,a=this.rotate;return React$2.createElement("div",{className:"react-pdf__Page__textContent",style:{position:"absolute",top:"50%",left:"50%",width:"".concat(n.width,"px"),height:"".concat(n.height,"px"),color:"transparent",transform:"translate(-50%, -50%) rotate(".concat(a,"deg)"),WebkitTransform:"translate(-50%, -50%) rotate(".concat(a,"deg)"),pointerEvents:"none"}},this.renderTextItems())}},{key:"unrotatedViewport",get:function(){var n=this.props,a=n.page,l=n.scale;return a.getViewport({scale:l})}},{key:"rotate",get:function(){var n=this.props,a=n.page,l=n.rotate;return l-a.rotate}}]),r}(React$2.PureComponent);TextLayerInternal.propTypes={onGetTextError:PropTypes$1.func,onGetTextSuccess:PropTypes$1.func,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number};function TextLayer(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(TextLayerInternal,_extends({},e,o))})}function _createSuper$1(o){var e=_isNativeReflectConstruct$1();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$1(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var AnnotationLayerInternal=function(o){_inherits(r,o);var e=_createSuper$1(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{annotations:null}),_defineProperty(_assertThisInitialized$1(t),"loadAnnotations",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h;return _regeneratorRuntime.wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return f=t.props.page,E.prev=1,d=makeCancellablePromise(f.getAnnotations()),t.runningTask=d,E.next=6,d.promise;case 6:h=E.sent,t.setState({annotations:h},t.onLoadSuccess),E.next=13;break;case 10:E.prev=10,E.t0=E.catch(1),t.onLoadError(E.t0);case 13:case"end":return E.stop()}},u,null,[[1,10]])}))),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onGetAnnotationsSuccess,f=t.state.annotations;u&&u(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({annotations:!1}),errorOnDev(u);var f=t.props.onGetAnnotationsError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){var u=t.props.onRenderAnnotationLayerSuccess;u&&u()}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){errorOnDev(u);var f=t.props.onRenderAnnotationLayerError;f&&f(u)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.page;if(!n)throw new Error("Attempted to load page annotations, but no page was specified.");this.loadAnnotations()}},{key:"componentDidUpdate",value:function(n){var a=this.props,l=a.page,u=a.renderInteractiveForms;(n.page&&l!==n.page||u!==n.renderInteractiveForms)&&this.loadAnnotations()}},{key:"componentWillUnmount",value:function(){cancelRunningTask(this.runningTask)}},{key:"renderAnnotationLayer",value:function(){var n=this.state.annotations;if(n){var a=this.props,l=a.imageResourcesPath,u=a.linkService,f=a.page,d=a.renderInteractiveForms,h=this.viewport.clone({dontFlip:!0}),y={annotations:n,div:this.annotationLayer,imageResourcesPath:l,linkService:u,page:f,renderInteractiveForms:d,viewport:h};this.annotationLayer.innerHTML="";try{pdfExports.AnnotationLayer.render(y),this.onRenderSuccess()}catch(E){this.onRenderError(E)}}}},{key:"render",value:function(){var n=this;return React$2.createElement("div",{className:"react-pdf__Page__annotations annotationLayer",ref:function(l){n.annotationLayer=l}},this.renderAnnotationLayer())}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);AnnotationLayerInternal.propTypes={imageResourcesPath:PropTypes$1.string,linkService:isLinkService.isRequired,onGetAnnotationsError:PropTypes$1.func,onGetAnnotationsSuccess:PropTypes$1.func,onRenderAnnotationLayerError:PropTypes$1.func,onRenderAnnotationLayerSuccess:PropTypes$1.func,page:isPage,renderInteractiveForms:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number};var AnnotationLayer=function o(e){return React$2.createElement(DocumentContext.Consumer,null,function(r){return React$2.createElement(PageContext.Consumer,null,function(t){return React$2.createElement(AnnotationLayerInternal,_extends({},r,t,e))})})};function ownKeys(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}function _createSuper(o){var e=_isNativeReflectConstruct();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var defaultScale=1,PageInternal=function(o){_inherits(r,o);var e=_createSuper(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{page:null}),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props,f=u.onLoadSuccess,d=u.registerPage,h=t.state.page;f&&f(makePageCallback(h,t.scale)),d&&d(t.pageIndex,t.ref)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){errorOnDev(u);var f=t.props.onLoadError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"loadPage",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y;return _regeneratorRuntime.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(f=t.props.pdf,d=t.getPageNumber(),d){p.next=4;break}return p.abrupt("return");case 4:return t.setState(function(_){return _.page?{page:null}:null}),p.prev=5,h=makeCancellablePromise(f.getPage(d)),t.runningTask=h,p.next=10,h.promise;case 10:y=p.sent,t.setState({page:y},t.onLoadSuccess),p.next=18;break;case 14:p.prev=14,p.t0=p.catch(5),t.setState({page:!1}),t.onLoadError(p.t0);case 18:case"end":return p.stop()}},u,null,[[5,14]])}))),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.pdf;if(!n)throw new Error("Attempted to load a page, but no document was specified.");this.loadPage()}},{key:"componentDidUpdate",value:function(n){var a=this.props.pdf;if(n.pdf&&a!==n.pdf||this.getPageNumber()!==this.getPageNumber(n)){var l=this.props.unregisterPage;l&&l(this.getPageIndex(n)),this.loadPage()}}},{key:"componentWillUnmount",value:function(){var n=this.props.unregisterPage;n&&n(this.pageIndex),cancelRunningTask(this.runningTask)}},{key:"getPageIndex",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return isProvided(n.pageNumber)?n.pageNumber-1:isProvided(n.pageIndex)?n.pageIndex:null}},{key:"getPageNumber",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return isProvided(n.pageNumber)?n.pageNumber:isProvided(n.pageIndex)?n.pageIndex+1:null}},{key:"renderMainLayer",value:function(){var n=this.props,a=n.canvasRef,l=n.renderMode;switch(l){case"none":return null;case"svg":return React$2.createElement(PageSVG,{key:"".concat(this.pageKeyNoScale,"_svg")});case"canvas":default:return React$2.createElement(PageCanvas,{key:"".concat(this.pageKey,"_canvas"),canvasRef:a})}}},{key:"renderTextLayer",value:function(){var n=this.props.renderTextLayer;return n?React$2.createElement(TextLayer,{key:"".concat(this.pageKey,"_text")}):null}},{key:"renderAnnotationLayer",value:function(){var n=this.props.renderAnnotationLayer;return n?React$2.createElement(AnnotationLayer,{key:"".concat(this.pageKey,"_annotations")}):null}},{key:"renderChildren",value:function(){var n=this.props.children;return React$2.createElement(PageContext.Provider,{value:this.childContext},this.renderMainLayer(),this.renderTextLayer(),this.renderAnnotationLayer(),n)}},{key:"renderContent",value:function(){var n=this.pageNumber,a=this.props.pdf,l=this.state.page;if(!n){var u=this.props.noData;return React$2.createElement(Message$1,{type:"no-data"},typeof u=="function"?u():u)}if(a===null||l===null){var f=this.props.loading;return React$2.createElement(Message$1,{type:"loading"},typeof f=="function"?f():f)}if(a===!1||l===!1){var d=this.props.error;return React$2.createElement(Message$1,{type:"error"},typeof d=="function"?d():d)}return this.renderChildren()}},{key:"render",value:function(){var n=this.pageNumber,a=this.props,l=a.className,u=a.inputRef;return React$2.createElement("div",_extends({className:mergeClassNames("react-pdf__Page",l),"data-page-number":n,ref:mergeRefs(u,this.ref),style:{position:"relative"}},this.eventProps),this.renderContent())}},{key:"childContext",get:function(){var n=this.state.page;if(!n)return{};var a=this.props,l=a.customTextRenderer,u=a.onGetAnnotationsError,f=a.onGetAnnotationsSuccess,d=a.onGetTextError,h=a.onGetTextSuccess,y=a.onRenderAnnotationLayerError,E=a.onRenderAnnotationLayerSuccess,p=a.onRenderError,_=a.onRenderSuccess,g=a.renderInteractiveForms;return{customTextRenderer:l,onGetAnnotationsError:u,onGetAnnotationsSuccess:f,onGetTextError:d,onGetTextSuccess:h,onRenderAnnotationLayerError:y,onRenderAnnotationLayerSuccess:E,onRenderError:p,onRenderSuccess:_,page:n,renderInteractiveForms:g,rotate:this.rotate,scale:this.scale}}},{key:"pageIndex",get:function(){return this.getPageIndex()}},{key:"pageNumber",get:function(){return this.getPageNumber()}},{key:"rotate",get:function(){var n=this.props.rotate;if(isProvided(n))return n;var a=this.state.page;return a?a.rotate:null}},{key:"scale",get:function(){var n=this.state.page;if(!n)return null;var a=this.props,l=a.scale,u=a.width,f=a.height,d=this.rotate,h=1,y=l===null?defaultScale:l;if(u||f){var E=n.getViewport({scale:1,rotation:d});h=u?u/E.width:f/E.height}return y*h}},{key:"eventProps",get:function(){var n=this;return makeEventProps(this.props,function(){var a=n.state.page;return a&&makePageCallback(a,n.scale)})}},{key:"pageKey",get:function(){var n=this.state.page;return"".concat(n.pageIndex,"@").concat(this.scale,"/").concat(this.rotate)}},{key:"pageKeyNoScale",get:function(){var n=this.state.page;return"".concat(n.pageIndex,"/").concat(this.rotate)}}]),r}(React$2.PureComponent);PageInternal.defaultProps={error:"Failed to load the page.",loading:"Loading page…",noData:"No page specified.",renderAnnotationLayer:!0,renderInteractiveForms:!1,renderMode:"canvas",renderTextLayer:!0,scale:defaultScale};var isFunctionOrNode=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.node]);PageInternal.propTypes=_objectSpread(_objectSpread({},eventProps),{},{children:PropTypes$1.node,className:isClassName,customTextRenderer:PropTypes$1.func,error:isFunctionOrNode,height:PropTypes$1.number,imageResourcesPath:PropTypes$1.string,inputRef:isRef,loading:isFunctionOrNode,noData:isFunctionOrNode,onGetTextError:PropTypes$1.func,onGetTextSuccess:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,pageIndex:isPageIndex,pageNumber:isPageNumber,pdf:isPdf,registerPage:PropTypes$1.func,renderAnnotationLayer:PropTypes$1.bool,renderInteractiveForms:PropTypes$1.bool,renderMode:isRenderMode,renderTextLayer:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number,unregisterPage:PropTypes$1.func,width:PropTypes$1.number});function Page(o,e){return React$2.createElement(DocumentContext.Consumer,null,function(r){return React$2.createElement(PageInternal,_extends({ref:e},r,o))})}const Page$1=React$2.forwardRef(Page);isLocalFileSystem&&warnOnDev("You are running React-PDF from your local file system. PDF.js Worker may fail to load due to browser's security policies. If you're on Google Chrome, you can use --allow-file-access-from-files flag for debugging purposes.");pdfExports.GlobalWorkerOptions.workerSrc="pdf.worker.js";const DeviceDetection=()=>navigator.userAgent.match(/(android)/i)||["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,BrowserDetection=()=>{const o=navigator.userAgent.toLowerCase(),e=o.indexOf("firefox")>-1,r=o.indexOf("safari")>-1&&o.indexOf("chrome")<=-1;let t="default";return e?t="firefox":r&&(t="safari"),t};pdfExports.GlobalWorkerOptions.workerSrc=`//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfExports.version}/pdf.worker.js`;const SCALE_LIMIT=2,maxValues={default:{area:268435456,sideBig:65535},firefox:{area:124992400,sideBig:32767},safari:{area:16777216,sideBig:4194303}},getMaxPermitted=()=>{const o=BrowserDetection();return maxValues[o]},formatScale=o=>o>1?Math.floor(o):Math.floor(o*100)/100,getMaxScaleByArea=(o,e,r)=>{const t=e*r*window.devicePixelRatio**2,n=Math.sqrt(o/t);return formatScale(n)},getMaxScaleBySide=(o,e,r)=>{const t=e>r?e:r,a=o/window.devicePixelRatio/t;return formatScale(a)};function PdfVisor({url:o,endPdf:e,emitNumberOfPages:r,translate:t,soundActions:n,keyboardControl:a}){const l=React$2.useRef(),[u,f]=React$2.useState(1),[d,h]=React$2.useState(!0),[y,E]=React$2.useState(),[p,_]=React$2.useState(1),[g]=n,x=React$2.useCallback(A=>{A.getPage(1).then(w=>{const P=w.getViewport(1),O=P.viewBox[2]-P.viewBox[0],k=P.viewBox[3]-P.viewBox[1],D=getMaxPermitted(),F=getMaxScaleByArea(D.area,O,k),G=getMaxScaleBySide(D.sideBig,O,k),V=F<G?F:G;_(V>SCALE_LIMIT?SCALE_LIMIT:V)}),f(A.numPages),A.numPages&&r({numPages:A.numPages,currentPage:y});const T=()=>(setTimeout(()=>{l.current&&l.current.scrollHeight<=l.current.offsetHeight&&h(!1)},1e3),()=>{T&&clearTimeout(T)});T()},[y,r]);React$2.useEffect(()=>{E(1)},[]);const C={file:o,loading:"Loading file...",onLoadSuccess:x,onLoadError:A=>console.error(A)},R=A=>{g("click-ui"),l.current.scrollTo(0,0),h(!1),E(y+A),r({numPages:u,currentPage:y+A}),y===u-1&&e()};a(u>1&&y!==1?()=>R(-1):null,u>1&&y!==u?()=>R(1):null);const S=()=>{h(!1)};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"pdf-box",dir:LangIsRtl()?"rtl":"auto",children:[jsxRuntimeExports.jsxs("div",{className:"pdf-box__scrollwrap",children:[jsxRuntimeExports.jsxs("div",{tabIndex:"0",onScroll:S,ref:l,className:`pdf-box__scroll ${d?"pdf-box__scroll--overlay":""}`,children:[jsxRuntimeExports.jsx(Document$1,{...C,children:jsxRuntimeExports.jsx(Page$1,{renderTextLayer:!1,scale:p,pageNumber:y})}),jsxRuntimeExports.jsx("div",{className:"pdf-box__mouse icon-scroll-down-black"})]}),u>1&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:"pdf-box__paginator",children:jsxRuntimeExports.jsxs("span",{children:[t("storylines.misc.page")," ",y," ",t("storylines.misc.of")," ",u]})})})]}),u>1&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("button",{className:`pdf-box__arrow pdf-box__arrow--left gat--btn__round ${y===1?"pdf-box__arrow--hidden":""}`,type:"button",disabled:y===1,onClick:()=>R(-1),"aria-label":LangIsRtl()?t("storylines.misc.nextPage"):t("storylines.misc.previousPage"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{className:`pdf-box__arrow pdf-box__arrow--right gat--btn__round ${y===u?"pdf-box__arrow--hidden":""}`,type:"button",disabled:y===u,onClick:()=>R(1),"aria-label":LangIsRtl()?t("storylines.misc.previousPage"):t("storylines.misc.nextPage"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})})}function PdfComponent({emitEvent:o,soundActions:e,keyboardControl:r,documentType:t,name:n,required:a,viewed:l,visible:u,documentId:f,documentId_labelId:d,...h}){const y=k=>o({type:"translate",payload:k}),[E]=e,p=h.document,{url:_}=p||"",[g,x]=React$2.useState(!1),C=React$2.useMemo(()=>({documentType:t,name:n,documentId:d,type:"pdf"}),[t,n,d]),R=React$2.useCallback(()=>{o({type:"finishMedia",payload:C})},[C,o]),[S,A]=React$2.useState(!1),[T,w]=React$2.useState(!1);if(React$2.useEffect(()=>{u||R(),a||x(!0)},[u,R,a]),!u)return null;const P=()=>{x(!0)},O=k=>{k.numPages===k.currentPage?w(!0):w(!1),k.numPages===1&&A(!0)};return r(null,S||!l&&T||T&&!a?R:null,S||!l&&T||!a?R:null),jsxRuntimeExports.jsxs("div",{className:`${l?"notes--results":""}`,children:[(S||!l&&g)&&jsxRuntimeExports.jsx("div",{className:"position--absolute top right z-index1",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:()=>{R(),E("click-ui")},"aria-label":y("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})}),_&&jsxRuntimeExports.jsx(PdfVisor,{soundActions:e,emitNumberOfPages:k=>O(k),url:_,endPdf:P,translate:y,keyboardControl:r})]})}function UrlComponent({emitEvent:o,name:e,name_labelId:r,link:t,link_labelId:n,text:a,text_labelId:l,textForLink:u,viewed:f,documentType:d,soundActions:h,keyboardControl:y,visible:E}){const p=A=>o({type:"translate",payload:A}),_={documentType:d,name:r,text:l,link:n,type:"url"},[g]=h,x=()=>{g("click-ui"),o({type:"finishMedia",payload:_})},[C,R]=React$2.useState(!1);y(null,!f&&C?x:null,!f&&C?x:null);const S=t.indexOf("http")!==0?`http://${t}`:t;return React$2.useEffect(()=>{E||x()}),E&&jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup popup--link",children:[!f&&C?jsxRuntimeExports.jsx("button",{className:"popup--close unset-button","data-testid":"close",type:"button","aria-label":p("storylines.misc.closePiece"),onClick:()=>x(),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})}):null,jsxRuntimeExports.jsx("span",{className:"popup--link__title",children:e}),jsxRuntimeExports.jsx("span",{className:"popup--link__desc",children:a}),jsxRuntimeExports.jsx("a",{className:"popup--link__lineclamp popup--link__url",href:S,target:"_blank",rel:"noopener noreferrer",onClick:()=>{g("click-ui"),R(!0)},children:u||t})]})})}var hls={exports:{}};(function(o,e){typeof window<"u"&&function(t,n){o.exports=n()}(commonjsGlobal,function(){return function(r){var t={};function n(a){if(t[a])return t[a].exports;var l=t[a]={i:a,l:!1,exports:{}};return r[a].call(l.exports,l,l.exports,n),l.l=!0,l.exports}return n.m=r,n.c=t,n.d=function(a,l,u){n.o(a,l)||Object.defineProperty(a,l,{enumerable:!0,get:u})},n.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},n.t=function(a,l){if(l&1&&(a=n(a)),l&8||l&4&&typeof a=="object"&&a&&a.__esModule)return a;var u=Object.create(null);if(n.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:a}),l&2&&typeof a!="string")for(var f in a)n.d(u,f,(function(d){return a[d]}).bind(null,f));return u},n.n=function(a){var l=a&&a.__esModule?function(){return a.default}:function(){return a};return n.d(l,"a",l),l},n.o=function(a,l){return Object.prototype.hasOwnProperty.call(a,l)},n.p="/dist/",n(n.s="./src/hls.js")}({"./node_modules/eventemitter3/index.js":function(r,t,n){var a=Object.prototype.hasOwnProperty,l="~";function u(){}Object.create&&(u.prototype=Object.create(null),new u().__proto__||(l=!1));function f(E,p,_){this.fn=E,this.context=p,this.once=_||!1}function d(E,p,_,g,x){if(typeof _!="function")throw new TypeError("The listener must be a function");var C=new f(_,g||E,x),R=l?l+p:p;return E._events[R]?E._events[R].fn?E._events[R]=[E._events[R],C]:E._events[R].push(C):(E._events[R]=C,E._eventsCount++),E}function h(E,p){--E._eventsCount===0?E._events=new u:delete E._events[p]}function y(){this._events=new u,this._eventsCount=0}y.prototype.eventNames=function(){var p=[],_,g;if(this._eventsCount===0)return p;for(g in _=this._events)a.call(_,g)&&p.push(l?g.slice(1):g);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(_)):p},y.prototype.listeners=function(p){var _=l?l+p:p,g=this._events[_];if(!g)return[];if(g.fn)return[g.fn];for(var x=0,C=g.length,R=new Array(C);x<C;x++)R[x]=g[x].fn;return R},y.prototype.listenerCount=function(p){var _=l?l+p:p,g=this._events[_];return g?g.fn?1:g.length:0},y.prototype.emit=function(p,_,g,x,C,R){var S=l?l+p:p;if(!this._events[S])return!1;var A=this._events[S],T=arguments.length,w,P;if(A.fn){switch(A.once&&this.removeListener(p,A.fn,void 0,!0),T){case 1:return A.fn.call(A.context),!0;case 2:return A.fn.call(A.context,_),!0;case 3:return A.fn.call(A.context,_,g),!0;case 4:return A.fn.call(A.context,_,g,x),!0;case 5:return A.fn.call(A.context,_,g,x,C),!0;case 6:return A.fn.call(A.context,_,g,x,C,R),!0}for(P=1,w=new Array(T-1);P<T;P++)w[P-1]=arguments[P];A.fn.apply(A.context,w)}else{var O=A.length,k;for(P=0;P<O;P++)switch(A[P].once&&this.removeListener(p,A[P].fn,void 0,!0),T){case 1:A[P].fn.call(A[P].context);break;case 2:A[P].fn.call(A[P].context,_);break;case 3:A[P].fn.call(A[P].context,_,g);break;case 4:A[P].fn.call(A[P].context,_,g,x);break;default:if(!w)for(k=1,w=new Array(T-1);k<T;k++)w[k-1]=arguments[k];A[P].fn.apply(A[P].context,w)}}return!0},y.prototype.on=function(p,_,g){return d(this,p,_,g,!1)},y.prototype.once=function(p,_,g){return d(this,p,_,g,!0)},y.prototype.removeListener=function(p,_,g,x){var C=l?l+p:p;if(!this._events[C])return this;if(!_)return h(this,C),this;var R=this._events[C];if(R.fn)R.fn===_&&(!x||R.once)&&(!g||R.context===g)&&h(this,C);else{for(var S=0,A=[],T=R.length;S<T;S++)(R[S].fn!==_||x&&!R[S].once||g&&R[S].context!==g)&&A.push(R[S]);A.length?this._events[C]=A.length===1?A[0]:A:h(this,C)}return this},y.prototype.removeAllListeners=function(p){var _;return p?(_=l?l+p:p,this._events[_]&&h(this,_)):(this._events=new u,this._eventsCount=0),this},y.prototype.off=y.prototype.removeListener,y.prototype.addListener=y.prototype.on,y.prefixed=l,y.EventEmitter=y,r.exports=y},"./node_modules/node-libs-browser/node_modules/events/events.js":function(r,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}r.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(d){if(!l(d)||d<0||isNaN(d))throw TypeError("n must be a positive number");return this._maxListeners=d,this},n.prototype.emit=function(d){var h,y,E,p,_,g;if(this._events||(this._events={}),d==="error"&&(!this._events.error||u(this._events.error)&&!this._events.error.length)){if(h=arguments[1],h instanceof Error)throw h;var x=new Error('Uncaught, unspecified "error" event. ('+h+")");throw x.context=h,x}if(y=this._events[d],f(y))return!1;if(a(y))switch(arguments.length){case 1:y.call(this);break;case 2:y.call(this,arguments[1]);break;case 3:y.call(this,arguments[1],arguments[2]);break;default:p=Array.prototype.slice.call(arguments,1),y.apply(this,p)}else if(u(y))for(p=Array.prototype.slice.call(arguments,1),g=y.slice(),E=g.length,_=0;_<E;_++)g[_].apply(this,p);return!0},n.prototype.addListener=function(d,h){var y;if(!a(h))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",d,a(h.listener)?h.listener:h),this._events[d]?u(this._events[d])?this._events[d].push(h):this._events[d]=[this._events[d],h]:this._events[d]=h,u(this._events[d])&&!this._events[d].warned&&(f(this._maxListeners)?y=n.defaultMaxListeners:y=this._maxListeners,y&&y>0&&this._events[d].length>y&&(this._events[d].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[d].length),typeof console.trace=="function"&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(d,h){if(!a(h))throw TypeError("listener must be a function");var y=!1;function E(){this.removeListener(d,E),y||(y=!0,h.apply(this,arguments))}return E.listener=h,this.on(d,E),this},n.prototype.removeListener=function(d,h){var y,E,p,_;if(!a(h))throw TypeError("listener must be a function");if(!this._events||!this._events[d])return this;if(y=this._events[d],p=y.length,E=-1,y===h||a(y.listener)&&y.listener===h)delete this._events[d],this._events.removeListener&&this.emit("removeListener",d,h);else if(u(y)){for(_=p;_-- >0;)if(y[_]===h||y[_].listener&&y[_].listener===h){E=_;break}if(E<0)return this;y.length===1?(y.length=0,delete this._events[d]):y.splice(E,1),this._events.removeListener&&this.emit("removeListener",d,h)}return this},n.prototype.removeAllListeners=function(d){var h,y;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[d]&&delete this._events[d],this;if(arguments.length===0){for(h in this._events)h!=="removeListener"&&this.removeAllListeners(h);return this.removeAllListeners("removeListener"),this._events={},this}if(y=this._events[d],a(y))this.removeListener(d,y);else if(y)for(;y.length;)this.removeListener(d,y[y.length-1]);return delete this._events[d],this},n.prototype.listeners=function(d){var h;return!this._events||!this._events[d]?h=[]:a(this._events[d])?h=[this._events[d]]:h=this._events[d].slice(),h},n.prototype.listenerCount=function(d){if(this._events){var h=this._events[d];if(a(h))return 1;if(h)return h.length}return 0},n.listenerCount=function(d,h){return d.listenerCount(h)};function a(d){return typeof d=="function"}function l(d){return typeof d=="number"}function u(d){return typeof d=="object"&&d!==null}function f(d){return d===void 0}},"./node_modules/url-toolkit/src/url-toolkit.js":function(r,t,n){(function(a){var l=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,u=/^([^\/?#]*)(.*)$/,f=/(?:\/|^)\.(?=\/)/g,d=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,h={buildAbsoluteURL:function(y,E,p){if(p=p||{},y=y.trim(),E=E.trim(),!E){if(!p.alwaysNormalize)return y;var _=h.parseURL(y);if(!_)throw new Error("Error trying to parse base URL.");return _.path=h.normalizePath(_.path),h.buildURLFromParts(_)}var g=h.parseURL(E);if(!g)throw new Error("Error trying to parse relative URL.");if(g.scheme)return p.alwaysNormalize?(g.path=h.normalizePath(g.path),h.buildURLFromParts(g)):E;var x=h.parseURL(y);if(!x)throw new Error("Error trying to parse base URL.");if(!x.netLoc&&x.path&&x.path[0]!=="/"){var C=u.exec(x.path);x.netLoc=C[1],x.path=C[2]}x.netLoc&&!x.path&&(x.path="/");var R={scheme:x.scheme,netLoc:g.netLoc,path:null,params:g.params,query:g.query,fragment:g.fragment};if(!g.netLoc&&(R.netLoc=x.netLoc,g.path[0]!=="/"))if(!g.path)R.path=x.path,g.params||(R.params=x.params,g.query||(R.query=x.query));else{var S=x.path,A=S.substring(0,S.lastIndexOf("/")+1)+g.path;R.path=h.normalizePath(A)}return R.path===null&&(R.path=p.alwaysNormalize?h.normalizePath(g.path):g.path),h.buildURLFromParts(R)},parseURL:function(y){var E=l.exec(y);return E?{scheme:E[1]||"",netLoc:E[2]||"",path:E[3]||"",params:E[4]||"",query:E[5]||"",fragment:E[6]||""}:null},normalizePath:function(y){for(y=y.split("").reverse().join("").replace(f,"");y.length!==(y=y.replace(d,"")).length;);return y.split("").reverse().join("")},buildURLFromParts:function(y){return y.scheme+y.netLoc+y.path+y.params+y.query+y.fragment}};r.exports=h})()},"./node_modules/webworkify-webpack/index.js":function(r,t,n){function a(p){var _={};function g(C){if(_[C])return _[C].exports;var R=_[C]={i:C,l:!1,exports:{}};return p[C].call(R.exports,R,R.exports,g),R.l=!0,R.exports}g.m=p,g.c=_,g.i=function(C){return C},g.d=function(C,R,S){g.o(C,R)||Object.defineProperty(C,R,{configurable:!1,enumerable:!0,get:S})},g.r=function(C){Object.defineProperty(C,"__esModule",{value:!0})},g.n=function(C){var R=C&&C.__esModule?function(){return C.default}:function(){return C};return g.d(R,"a",R),R},g.o=function(C,R){return Object.prototype.hasOwnProperty.call(C,R)},g.p="/",g.oe=function(C){throw console.error(C),C};var x=g(g.s=ENTRY_MODULE);return x.default||x}var l="[\\.|\\-|\\+|\\w|/|@]+",u="\\((/\\*.*?\\*/)?s?.*?("+l+").*?\\)";function f(p){return(p+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function d(p){return!isNaN(1*p)}function h(p,_,g){var x={};x[g]=[];var C=_.toString(),R=C.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!R)return x;for(var S=R[1],A=new RegExp("(\\\\n|\\W)"+f(S)+u,"g"),T;T=A.exec(C);)T[3]!=="dll-reference"&&x[g].push(T[3]);for(A=new RegExp("\\("+f(S)+'\\("(dll-reference\\s('+l+'))"\\)\\)'+u,"g");T=A.exec(C);)p[T[2]]||(x[g].push(T[1]),p[T[2]]=n(T[1]).m),x[T[2]]=x[T[2]]||[],x[T[2]].push(T[4]);for(var w=Object.keys(x),P=0;P<w.length;P++)for(var O=0;O<x[w[P]].length;O++)d(x[w[P]][O])&&(x[w[P]][O]=1*x[w[P]][O]);return x}function y(p){var _=Object.keys(p);return _.reduce(function(g,x){return g||p[x].length>0},!1)}function E(p,_){for(var g={main:[_]},x={main:[]},C={main:{}};y(g);)for(var R=Object.keys(g),S=0;S<R.length;S++){var A=R[S],T=g[A],w=T.pop();if(C[A]=C[A]||{},!(C[A][w]||!p[A][w])){C[A][w]=!0,x[A]=x[A]||[],x[A].push(w);for(var P=h(p,p[A][w],A),O=Object.keys(P),k=0;k<O.length;k++)g[O[k]]=g[O[k]]||[],g[O[k]]=g[O[k]].concat(P[O[k]])}}return x}r.exports=function(p,_){_=_||{};var g={main:n.m},x=_.all?{main:Object.keys(g.main)}:E(g,p),C="";Object.keys(x).filter(function(w){return w!=="main"}).forEach(function(w){for(var P=0;x[w][P];)P++;x[w].push(P),g[w][P]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",C=C+"var "+w+" = ("+a.toString().replace("ENTRY_MODULE",JSON.stringify(P))+")({"+x[w].map(function(O){return""+JSON.stringify(O)+": "+g[w][O].toString()}).join(",")+`});
53
53
  `}),C=C+"new (("+a.toString().replace("ENTRY_MODULE",JSON.stringify(p))+")({"+x.main.map(function(w){return""+JSON.stringify(w)+": "+g.main[w].toString()}).join(",")+"}))(self);";var R=new window.Blob([C],{type:"text/javascript"});if(_.bare)return R;var S=window.URL||window.webkitURL||window.mozURL||window.msURL,A=S.createObjectURL(R),T=new window.Worker(A);return T.objectURL=A,T}},"./src/config.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/controller/abr-controller.js"),l=n("./src/controller/buffer-controller.js"),u=n("./src/controller/cap-level-controller.js"),f=n("./src/controller/fps-controller.js"),d=n("./src/utils/xhr-loader.js"),h=n("./src/controller/audio-track-controller.js"),y=n("./src/controller/audio-stream-controller.js"),E=n("./src/utils/cues.js"),p=n("./src/controller/timeline-controller.js"),_=n("./src/controller/subtitle-track-controller.js"),g=n("./src/controller/subtitle-stream-controller.js"),x=n("./src/controller/eme-controller.js"),C=n("./src/utils/mediakeys-helper.js");t.hlsDefaultConfig={autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:60*1e3*1e3,maxBufferHole:.5,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,liveDurationInfinity:!1,liveBackBufferLength:1/0,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:d.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,abrController:a.default,bufferController:l.default,capLevelController:u.default,fpsController:f.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,requestMediaKeySystemAccessFunc:C.requestMediaKeySystemAccess},t.hlsDefaultConfig.subtitleStreamController=g.SubtitleStreamController,t.hlsDefaultConfig.subtitleTrackController=_.default,t.hlsDefaultConfig.timelineController=p.default,t.hlsDefaultConfig.cueHandler=E,t.hlsDefaultConfig.enableCEA708Captions=!0,t.hlsDefaultConfig.enableWebVTT=!0,t.hlsDefaultConfig.captionsTextTrack1Label="English",t.hlsDefaultConfig.captionsTextTrack1LanguageCode="en",t.hlsDefaultConfig.captionsTextTrack2Label="Spanish",t.hlsDefaultConfig.captionsTextTrack2LanguageCode="es",t.hlsDefaultConfig.audioStreamController=y.default,t.hlsDefaultConfig.audioTrackController=h.default,t.hlsDefaultConfig.emeController=x.default},"./src/controller/abr-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,C){x.__proto__=C}||function(x,C){for(var R in C)C.hasOwnProperty(R)&&(x[R]=C[R])};return function(x,C){g(x,C);function R(){this.constructor=x}x.prototype=C===null?Object.create(C):(R.prototype=C.prototype,new R)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/utils/buffer-helper.js"),h=n("./src/errors.js"),y=n("./src/utils/logger.js"),E=n("./src/utils/ewma-bandwidth-estimator.js"),p=window.performance,_=function(g){l(x,g);function x(C){var R=g.call(this,C,u.default.FRAG_LOADING,u.default.FRAG_LOADED,u.default.FRAG_BUFFERED,u.default.ERROR)||this;return R.lastLoadedFragLevel=0,R._nextAutoLevel=-1,R.hls=C,R.timer=null,R._bwEstimator=null,R.onCheck=R._abandonRulesCheck.bind(R),R}return x.prototype.destroy=function(){this.clearTimer(),f.default.prototype.destroy.call(this)},x.prototype.onFragLoading=function(C){var R=C.frag;if(R.type==="main"&&(this.timer||(this.fragCurrent=R,this.timer=setInterval(this.onCheck,100)),!this._bwEstimator)){var S=this.hls,A=S.config,T=R.level,w=S.levels[T].details.live,P=void 0,O=void 0;w?(P=A.abrEwmaFastLive,O=A.abrEwmaSlowLive):(P=A.abrEwmaFastVoD,O=A.abrEwmaSlowVoD),this._bwEstimator=new E.default(S,O,P,A.abrEwmaDefaultEstimate)}},x.prototype._abandonRulesCheck=function(){var C=this.hls,R=C.media,S=this.fragCurrent;if(S){var A=S.loader,T=C.minAutoLevel;if(!A||A.stats&&A.stats.aborted){y.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}var w=A.stats;if(R&&w&&(!R.paused&&R.playbackRate!==0||!R.readyState)&&S.autoLevel&&S.level){var P=p.now()-w.trequest,O=Math.abs(R.playbackRate);if(P>500*S.duration/O){var k=C.levels,D=Math.max(1,w.bw?w.bw/8:w.loaded*1e3/P),F=k[S.level],G=F.realBitrate?Math.max(F.realBitrate,F.bitrate):F.bitrate,V=w.total?w.total:Math.max(w.loaded,Math.round(S.duration*G/8)),W=R.currentTime,ee=(V-w.loaded)/D,q=(d.BufferHelper.bufferInfo(R,W,C.config.maxBufferHole).end-W)/O;if(q<2*S.duration/O&&ee>q){var z=void 0,U=void 0;for(U=S.level-1;U>T;U--){var $=k[U].realBitrate?Math.max(k[U].realBitrate,k[U].bitrate):k[U].bitrate;if(z=S.duration*$/(8*.8*D),z<q)break}z<ee&&(y.logger.warn("loading too slow, abort fragment loading and switch to level "+U+":fragLoadedDelay["+U+"]<fragLoadedDelay["+(S.level-1)+"];bufferStarvationDelay:"+z.toFixed(1)+"<"+ee.toFixed(1)+":"+q.toFixed(1)),C.nextLoadLevel=U,this._bwEstimator.sample(P,w.loaded),A.abort(),this.clearTimer(),C.trigger(u.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:S,stats:w}))}}}}},x.prototype.onFragLoaded=function(C){var R=C.frag;if(R.type==="main"&&a.isFinite(R.sn)){if(this.clearTimer(),this.lastLoadedFragLevel=R.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var S=this.hls.levels[R.level],A=(S.loaded?S.loaded.bytes:0)+C.stats.loaded,T=(S.loaded?S.loaded.duration:0)+C.frag.duration;S.loaded={bytes:A,duration:T},S.realBitrate=Math.round(8*A/T)}if(C.frag.bitrateTest){var w=C.stats;w.tparsed=w.tbuffered=w.tload,this.onFragBuffered(C)}}},x.prototype.onFragBuffered=function(C){var R=C.stats,S=C.frag;if(R.aborted!==!0&&S.type==="main"&&a.isFinite(S.sn)&&(!S.bitrateTest||R.tload===R.tbuffered)){var A=R.tparsed-R.trequest;y.logger.log("latency/loading/parsing/append/kbps:"+Math.round(R.tfirst-R.trequest)+"/"+Math.round(R.tload-R.tfirst)+"/"+Math.round(R.tparsed-R.tload)+"/"+Math.round(R.tbuffered-R.tparsed)+"/"+Math.round(8*R.loaded/(R.tbuffered-R.trequest))),this._bwEstimator.sample(A,R.loaded),R.bwEstimate=this._bwEstimator.getEstimate(),S.bitrateTest?this.bitrateTestDelay=A/1e3:this.bitrateTestDelay=0}},x.prototype.onError=function(C){switch(C.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break}},x.prototype.clearTimer=function(){clearInterval(this.timer),this.timer=null},Object.defineProperty(x.prototype,"nextAutoLevel",{get:function(){var C=this._nextAutoLevel,R=this._bwEstimator;if(C!==-1&&(!R||!R.canEstimate()))return C;var S=this._nextABRAutoLevel;return C!==-1&&(S=Math.min(C,S)),S},set:function(C){this._nextAutoLevel=C},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"_nextABRAutoLevel",{get:function(){var C=this.hls,R=C.maxAutoLevel,S=C.levels,A=C.config,T=C.minAutoLevel,w=C.media,P=this.lastLoadedFragLevel,O=this.fragCurrent?this.fragCurrent.duration:0,k=w?w.currentTime:0,D=w&&w.playbackRate!==0?Math.abs(w.playbackRate):1,F=this._bwEstimator?this._bwEstimator.getEstimate():A.abrEwmaDefaultEstimate,G=(d.BufferHelper.bufferInfo(w,k,A.maxBufferHole).end-k)/D,V=this._findBestLevel(P,O,F,T,R,G,A.abrBandWidthFactor,A.abrBandWidthUpFactor,S);if(V>=0)return V;y.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var W=O?Math.min(O,A.maxStarvationDelay):A.maxStarvationDelay,ee=A.abrBandWidthFactor,q=A.abrBandWidthUpFactor;if(G===0){var z=this.bitrateTestDelay;if(z){var U=O?Math.min(O,A.maxLoadingDelay):A.maxLoadingDelay;W=U-z,y.logger.trace("bitrate test took "+Math.round(1e3*z)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*W)+" ms"),ee=q=1}}return V=this._findBestLevel(P,O,F,T,R,G+W,ee,q,S),Math.max(V,0)},enumerable:!0,configurable:!0}),x.prototype._findBestLevel=function(C,R,S,A,T,w,P,O,k){for(var D=T;D>=A;D--){var F=k[D];if(F){var G=F.details,V=G?G.totalduration/G.fragments.length:R,W=G?G.live:!1,ee=void 0;D<=C?ee=P*S:ee=O*S;var q=k[D].realBitrate?Math.max(k[D].realBitrate,k[D].bitrate):k[D].bitrate,z=q*V/ee;if(y.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+D+"/"+Math.round(ee)+"/"+q+"/"+V+"/"+w+"/"+z),ee>q&&(!z||W&&!this.bitrateTestDelay||z<w))return D}}return-1},x}(f.default);t.default=_}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/audio-stream-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(P,O){P.__proto__=O}||function(P,O){for(var k in O)O.hasOwnProperty(k)&&(P[k]=O[k])};return function(P,O){w(P,O);function k(){this.constructor=P}P.prototype=O===null?Object.create(O):(k.prototype=O.prototype,new k)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/utils/binary-search.js"),f=n("./src/utils/buffer-helper.js"),d=n("./src/demux/demuxer.js"),h=n("./src/events.js"),y=n("./src/controller/level-helper.js"),E=n("./src/utils/time-ranges.js"),p=n("./src/errors.js"),_=n("./src/utils/logger.js"),g=n("./src/utils/discontinuities.js"),x=n("./src/controller/fragment-tracker.js"),C=n("./src/loader/fragment.js"),R=n("./src/controller/base-stream-controller.js"),S=window.performance,A=100,T=function(w){l(P,w);function P(O,k){var D=w.call(this,O,h.default.MEDIA_ATTACHED,h.default.MEDIA_DETACHING,h.default.AUDIO_TRACKS_UPDATED,h.default.AUDIO_TRACK_SWITCHING,h.default.AUDIO_TRACK_LOADED,h.default.KEY_LOADED,h.default.FRAG_LOADED,h.default.FRAG_PARSING_INIT_SEGMENT,h.default.FRAG_PARSING_DATA,h.default.FRAG_PARSED,h.default.ERROR,h.default.BUFFER_RESET,h.default.BUFFER_CREATED,h.default.BUFFER_APPENDED,h.default.BUFFER_FLUSHED,h.default.INIT_PTS_FOUND)||this;return D.fragmentTracker=k,D.config=O.config,D.audioCodecSwap=!1,D._state=R.State.STOPPED,D.initPTS=[],D.waitingFragment=null,D.videoTrackCC=null,D}return P.prototype.onInitPtsFound=function(O){var k=O.id,D=O.frag.cc,F=O.initPTS;k==="main"&&(this.initPTS[D]=F,this.videoTrackCC=D,_.logger.log("InitPTS for cc: "+D+" found from video track: "+F),this.state===R.State.WAITING_INIT_PTS&&this.tick())},P.prototype.startLoad=function(O){if(this.tracks){var k=this.lastCurrentTime;this.stopLoad(),this.setInterval(A),this.fragLoadError=0,k>0&&O===-1?(_.logger.log("audio:override startPosition with lastCurrentTime @"+k.toFixed(3)),this.state=R.State.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:O,this.state=R.State.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=O,this.state=R.State.STOPPED},Object.defineProperty(P.prototype,"state",{get:function(){return this._state},set:function(O){if(this.state!==O){var k=this.state;this._state=O,_.logger.log("audio stream:"+k+"->"+O)}},enumerable:!0,configurable:!0}),P.prototype.doTick=function(){var O,k,D,F=this.hls,G=F.config;switch(this.state){case R.State.ERROR:case R.State.PAUSED:case R.State.BUFFER_FLUSHING:break;case R.State.STARTING:this.state=R.State.WAITING_TRACK,this.loadedmetadata=!1;break;case R.State.IDLE:var V=this.tracks;if(!V||!this.media&&(this.startFragRequested||!G.startFragPrefetch))break;if(this.loadedmetadata)O=this.media.currentTime;else if(O=this.nextLoadPosition,O===void 0)break;var W=this.mediaBuffer?this.mediaBuffer:this.media,ee=this.videoBuffer?this.videoBuffer:this.media,q=f.BufferHelper.bufferInfo(W,O,G.maxBufferHole),z=f.BufferHelper.bufferInfo(ee,O,G.maxBufferHole),U=q.len,$=q.end,I=this.fragPrevious,B=Math.min(G.maxBufferLength,G.maxMaxBufferLength),X=Math.max(B,z.len),Q=this.audioSwitch,J=this.trackId;if((U<X||Q)&&J<V.length){if(D=V[J].details,typeof D>"u"){this.state=R.State.WAITING_TRACK;break}if(!Q&&this._streamEnded(q,D)){this.hls.trigger(h.default.BUFFER_EOS,{type:"audio"}),this.state=R.State.ENDED;return}var ne=D.fragments,ae=ne.length,Z=ne[0].start,se=ne[ae-1].start+ne[ae-1].duration,oe=void 0;if(Q){if(D.live&&!D.PTSKnown)_.logger.log("switching audiotrack, live stream, unknown PTS,load first fragment"),$=0;else if($=O,D.PTSKnown&&O<Z)if(q.end>Z||q.nextStart)_.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=Z+.05;else return}if(D.initSegment&&!D.initSegment.data)oe=D.initSegment;else if($<=Z){if(oe=ne[0],this.videoTrackCC!==null&&oe.cc!==this.videoTrackCC&&(oe=g.findFragWithCC(ne,this.videoTrackCC)),D.live&&oe.loadIdx&&oe.loadIdx===this.fragLoadIdx){var fe=q.nextStart?q.nextStart:Z;_.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(fe+.05)),this.media.currentTime=fe+.05;return}}else{var de=void 0,ce=G.maxFragLookUpTolerance,Ee=I?ne[I.sn-ne[0].sn+1]:void 0,De=function(ut){var ft=Math.min(ce,ut.duration);return ut.start+ut.duration-ft<=$?1:ut.start-ft>$&&ut.start?-1:0};$<se?($>se-ce&&(ce=0),Ee&&!De(Ee)?de=Ee:de=u.default.search(ne,De)):de=ne[ae-1],de&&(oe=de,Z=de.start,I&&oe.level===I.level&&oe.sn===I.sn&&(oe.sn<D.endSN?(oe=ne[oe.sn+1-D.startSN],_.logger.log("SN just loaded, load next one: "+oe.sn)):oe=null))}oe&&(oe.encrypted?(_.logger.log("Loading key for "+oe.sn+" of ["+D.startSN+" ,"+D.endSN+"],track "+J),this.state=R.State.KEY_LOADING,F.trigger(h.default.KEY_LOADING,{frag:oe})):(_.logger.log("Loading "+oe.sn+", cc: "+oe.cc+" of ["+D.startSN+" ,"+D.endSN+"],track "+J+", currentTime:"+O+",bufferEnd:"+$.toFixed(3)),this.fragCurrent=oe,(Q||this.fragmentTracker.getState(oe)===x.FragmentState.NOT_LOADED)&&(this.startFragRequested=!0,a.isFinite(oe.sn)&&(this.nextLoadPosition=oe.start+oe.duration),F.trigger(h.default.FRAG_LOADING,{frag:oe}),this.state=R.State.FRAG_LOADING)))}break;case R.State.WAITING_TRACK:k=this.tracks[this.trackId],k&&k.details&&(this.state=R.State.IDLE);break;case R.State.FRAG_LOADING_WAITING_RETRY:var we=S.now(),He=this.retryDate;W=this.media;var Xe=W&&W.seeking;(!He||we>=He||Xe)&&(_.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=R.State.IDLE);break;case R.State.WAITING_INIT_PTS:var Qe=this.videoTrackCC;if(this.initPTS[Qe]===void 0)break;var dt=this.waitingFragment;if(dt){var _t=dt.frag.cc;Qe!==_t?(k=this.tracks[this.trackId],k.details&&k.details.live&&(_.logger.warn("Waiting fragment CC ("+_t+") does not match video track CC ("+Qe+")"),this.waitingFragment=null,this.state=R.State.IDLE)):(this.state=R.State.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=R.State.IDLE;break;case R.State.STOPPED:case R.State.FRAG_LOADING:case R.State.PARSING:case R.State.PARSED:case R.State.ENDED:break}},P.prototype.onMediaAttached=function(O){var k=this.media=this.mediaBuffer=O.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),k.addEventListener("seeking",this.onvseeking),k.addEventListener("ended",this.onvended);var D=this.config;this.tracks&&D.autoStartLoad&&this.startLoad(D.startPosition)},P.prototype.onMediaDetaching=function(){var O=this.media;O&&O.ended&&(_.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),O&&(O.removeEventListener("seeking",this.onvseeking),O.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.stopLoad()},P.prototype.onAudioTracksUpdated=function(O){_.logger.log("audio tracks updated"),this.tracks=O.audioTracks},P.prototype.onAudioTrackSwitching=function(O){var k=!!O.url;this.trackId=O.id,this.fragCurrent=null,this.state=R.State.PAUSED,this.waitingFragment=null,k?this.setInterval(A):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),k&&(this.audioSwitch=!0,this.state=R.State.IDLE),this.tick()},P.prototype.onAudioTrackLoaded=function(O){var k=O.details,D=O.id,F=this.tracks[D],G=k.totalduration,V=0;if(_.logger.log("track "+D+" loaded ["+k.startSN+","+k.endSN+"],duration:"+G),k.live){var W=F.details;W&&k.fragments.length>0?(y.mergeDetails(W,k),V=k.fragments[0].start,k.PTSKnown?_.logger.log("live audio playlist sliding:"+V.toFixed(3)):_.logger.log("live audio playlist - outdated PTS, unknown sliding")):(k.PTSKnown=!1,_.logger.log("live audio playlist - first load, unknown sliding"))}else k.PTSKnown=!1;if(F.details=k,!this.startFragRequested){if(this.startPosition===-1){var ee=k.startTimeOffset;a.isFinite(ee)?(_.logger.log("start time offset found in playlist, adjust startPosition to "+ee),this.startPosition=ee):this.startPosition=0}this.nextLoadPosition=this.startPosition}this.state===R.State.WAITING_TRACK&&(this.state=R.State.IDLE),this.tick()},P.prototype.onKeyLoaded=function(){this.state===R.State.KEY_LOADING&&(this.state=R.State.IDLE,this.tick())},P.prototype.onFragLoaded=function(O){var k=this.fragCurrent,D=O.frag;if(this.state===R.State.FRAG_LOADING&&k&&D.type==="audio"&&D.level===k.level&&D.sn===k.sn){var F=this.tracks[this.trackId],G=F.details,V=G.totalduration,W=k.level,ee=k.sn,q=k.cc,z=this.config.defaultAudioCodec||F.audioCodec||"mp4a.40.2",U=this.stats=O.stats;if(ee==="initSegment")this.state=R.State.IDLE,U.tparsed=U.tbuffered=S.now(),G.initSegment.data=O.payload,this.hls.trigger(h.default.FRAG_BUFFERED,{stats:U,frag:k,id:"audio"}),this.tick();else{this.state=R.State.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new d.default(this.hls,"audio"));var $=this.initPTS[q],I=G.initSegment?G.initSegment.data:[];if(G.initSegment||$!==void 0){this.pendingBuffering=!0,_.logger.log("Demuxing "+ee+" of ["+G.startSN+" ,"+G.endSN+"],track "+W);var B=!1;this.demuxer.push(O.payload,I,z,null,k,V,B,$)}else _.logger.log("unknown video PTS for continuity counter "+q+", waiting for video PTS before demuxing audio frag "+ee+" of ["+G.startSN+" ,"+G.endSN+"],track "+W),this.waitingFragment=O,this.state=R.State.WAITING_INIT_PTS}}this.fragLoadError=0},P.prototype.onFragParsingInitSegment=function(O){var k=this.fragCurrent,D=O.frag;if(k&&O.id==="audio"&&D.sn===k.sn&&D.level===k.level&&this.state===R.State.PARSING){var F=O.tracks,G=void 0;if(F.video&&delete F.video,G=F.audio,G){G.levelCodec=G.codec,G.id=O.id,this.hls.trigger(h.default.BUFFER_CODECS,F),_.logger.log("audio track:audio,container:"+G.container+",codecs[level/parsed]=["+G.levelCodec+"/"+G.codec+"]");var V=G.initSegment;if(V){var W={type:"audio",data:V,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[W]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(h.default.BUFFER_APPENDING,W))}this.tick()}}},P.prototype.onFragParsingData=function(O){var k=this,D=this.fragCurrent,F=O.frag;if(D&&O.id==="audio"&&O.type==="audio"&&F.sn===D.sn&&F.level===D.level&&this.state===R.State.PARSING){var G=this.trackId,V=this.tracks[G],W=this.hls;a.isFinite(O.endPTS)||(O.endPTS=O.startPTS+D.duration,O.endDTS=O.startDTS+D.duration),D.addElementaryStream(C.default.ElementaryStreamTypes.AUDIO),_.logger.log("parsed "+O.type+",PTS:["+O.startPTS.toFixed(3)+","+O.endPTS.toFixed(3)+"],DTS:["+O.startDTS.toFixed(3)+"/"+O.endDTS.toFixed(3)+"],nb:"+O.nb),y.updateFragPTSDTS(V.details,D,O.startPTS,O.endPTS);var ee=this.audioSwitch,q=this.media,z=!1;if(ee&&q)if(q.readyState){var U=q.currentTime;_.logger.log("switching audio track : currentTime:"+U),U>=O.startPTS&&(_.logger.log("switching audio track : flushing all audio"),this.state=R.State.BUFFER_FLUSHING,W.trigger(h.default.BUFFER_FLUSHING,{startOffset:0,endOffset:a.POSITIVE_INFINITY,type:"audio"}),z=!0,this.audioSwitch=!1,W.trigger(h.default.AUDIO_TRACK_SWITCHED,{id:G}))}else this.audioSwitch=!1,W.trigger(h.default.AUDIO_TRACK_SWITCHED,{id:G});var $=this.pendingData;if(!$){_.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),W.trigger(h.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});return}this.audioSwitch||([O.data1,O.data2].forEach(function(I){I&&I.length&&$.push({type:O.type,data:I,parent:"audio",content:"data"})}),!z&&$.length&&($.forEach(function(I){k.state===R.State.PARSING&&(k.pendingBuffering=!0,k.hls.trigger(h.default.BUFFER_APPENDING,I))}),this.pendingData=[],this.appended=!0)),this.tick()}},P.prototype.onFragParsed=function(O){var k=this.fragCurrent,D=O.frag;k&&O.id==="audio"&&D.sn===k.sn&&D.level===k.level&&this.state===R.State.PARSING&&(this.stats.tparsed=S.now(),this.state=R.State.PARSED,this._checkAppendedParsed())},P.prototype.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},P.prototype.onBufferCreated=function(O){var k=O.tracks.audio;k&&(this.mediaBuffer=k.buffer,this.loadedmetadata=!0),O.tracks.video&&(this.videoBuffer=O.tracks.video.buffer)},P.prototype.onBufferAppended=function(O){if(O.parent==="audio"){var k=this.state;(k===R.State.PARSING||k===R.State.PARSED)&&(this.pendingBuffering=O.pending>0,this._checkAppendedParsed())}},P.prototype._checkAppendedParsed=function(){if(this.state===R.State.PARSED&&(!this.appended||!this.pendingBuffering)){var O=this.fragCurrent,k=this.stats,D=this.hls;if(O){this.fragPrevious=O,k.tbuffered=S.now(),D.trigger(h.default.FRAG_BUFFERED,{stats:k,frag:O,id:"audio"});var F=this.mediaBuffer?this.mediaBuffer:this.media;_.logger.log("audio buffered : "+E.default.toString(F.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,D.trigger(h.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=R.State.IDLE}this.tick()}},P.prototype.onError=function(O){var k=O.frag;if(!(k&&k.type!=="audio"))switch(O.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:var D=O.frag;if(D&&D.type!=="audio")break;if(!O.fatal){var F=this.fragLoadError;F?F++:F=1;var G=this.config;if(F<=G.fragLoadingMaxRetry){this.fragLoadError=F;var V=Math.min(Math.pow(2,F-1)*G.fragLoadingRetryDelay,G.fragLoadingMaxRetryTimeout);_.logger.warn("AudioStreamController: frag loading failed, retry in "+V+" ms"),this.retryDate=S.now()+V,this.state=R.State.FRAG_LOADING_WAITING_RETRY}else _.logger.error("AudioStreamController: "+O.details+" reaches max retry, redispatch as fatal ..."),O.fatal=!0,this.state=R.State.ERROR}break;case p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case p.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==R.State.ERROR&&(this.state=O.fatal?R.State.ERROR:R.State.IDLE,_.logger.warn("AudioStreamController: "+O.details+" while loading frag, now switching to "+this.state+" state ..."));break;case p.ErrorDetails.BUFFER_FULL_ERROR:if(O.parent==="audio"&&(this.state===R.State.PARSING||this.state===R.State.PARSED)){var W=this.mediaBuffer,ee=this.media.currentTime,q=W&&f.BufferHelper.isBuffered(W,ee)&&f.BufferHelper.isBuffered(W,ee+.5);if(q){var G=this.config;G.maxMaxBufferLength>=G.maxBufferLength&&(G.maxMaxBufferLength/=2,_.logger.warn("AudioStreamController: reduce max buffer length to "+G.maxMaxBufferLength+"s")),this.state=R.State.IDLE}else _.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=R.State.BUFFER_FLUSHING,this.hls.trigger(h.default.BUFFER_FLUSHING,{startOffset:0,endOffset:a.POSITIVE_INFINITY,type:"audio"})}break}},P.prototype.onBufferFlushed=function(){var O=this,k=this.pendingData;k&&k.length?(_.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),k.forEach(function(D){O.hls.trigger(h.default.BUFFER_APPENDING,D)}),this.appended=!0,this.pendingData=[],this.state=R.State.PARSED):(this.state=R.State.IDLE,this.fragPrevious=null,this.tick())},P}(R.default);t.default=T}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/audio-track-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,p){E.__proto__=p}||function(E,p){for(var _ in p)p.hasOwnProperty(_)&&(E[_]=p[_])};return function(E,p){y(E,p);function _(){this.constructor=E}E.prototype=p===null?Object.create(p):(_.prototype=p.prototype,new _)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/task-loop.js"),f=n("./src/utils/logger.js"),d=n("./src/errors.js"),h=function(y){a(E,y);function E(p){var _=y.call(this,p,l.default.MANIFEST_LOADING,l.default.MANIFEST_PARSED,l.default.AUDIO_TRACK_LOADED,l.default.AUDIO_TRACK_SWITCHED,l.default.LEVEL_LOADED,l.default.ERROR)||this;return _._trackId=-1,_._selectDefaultTrack=!0,_.tracks=[],_.trackIdBlacklist=Object.create(null),_.audioGroupId=null,_}return E.prototype.onManifestLoading=function(){this.tracks=[],this._trackId=-1,this._selectDefaultTrack=!0},E.prototype.onManifestParsed=function(p){var _=this.tracks=p.audioTracks||[];this.hls.trigger(l.default.AUDIO_TRACKS_UPDATED,{audioTracks:_})},E.prototype.onAudioTrackLoaded=function(p){if(p.id>=this.tracks.length){f.logger.warn("Invalid audio track id:",p.id);return}if(f.logger.log("audioTrack "+p.id+" loaded"),this.tracks[p.id].details=p.details,p.details.live&&!this.hasInterval()){var _=p.details.targetduration*1e3;this.setInterval(_)}!p.details.live&&this.hasInterval()&&this.clearInterval()},E.prototype.onAudioTrackSwitched=function(p){var _=this.tracks[p.id].groupId;_&&this.audioGroupId!==_&&(this.audioGroupId=_)},E.prototype.onLevelLoaded=function(p){var _=this.hls.levels[p.level];if(_.audioGroupIds){var g=_.audioGroupIds[_.urlId];this.audioGroupId!==g&&(this.audioGroupId=g,this._selectInitialAudioTrack())}},E.prototype.onError=function(p){p.type===d.ErrorTypes.NETWORK_ERROR&&(p.fatal&&this.clearInterval(),p.details===d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(f.logger.warn("Network failure on audio-track id:",p.context.id),this._handleLoadError()))},Object.defineProperty(E.prototype,"audioTracks",{get:function(){return this.tracks},enumerable:!0,configurable:!0}),Object.defineProperty(E.prototype,"audioTrack",{get:function(){return this._trackId},set:function(p){this._setAudioTrack(p),this._selectDefaultTrack=!1},enumerable:!0,configurable:!0}),E.prototype._setAudioTrack=function(p){if(this._trackId===p&&this.tracks[this._trackId].details){f.logger.debug("Same id as current audio-track passed, and track details available -> no-op");return}if(p<0||p>=this.tracks.length){f.logger.warn("Invalid id passed to audio-track controller");return}var _=this.tracks[p];f.logger.log("Now switching to audio-track index "+p),this.clearInterval(),this._trackId=p;var g=_.url,x=_.type,C=_.id;this.hls.trigger(l.default.AUDIO_TRACK_SWITCHING,{id:C,type:x,url:g}),this._loadTrackDetailsIfNeeded(_)},E.prototype.doTick=function(){this._updateTrack(this._trackId)},E.prototype._selectInitialAudioTrack=function(){var p=this,_=this.tracks;if(_.length){var g=this.tracks[this._trackId],x=null;if(g&&(x=g.name),this._selectDefaultTrack){var C=_.filter(function(A){return A.default});C.length?_=C:f.logger.warn("No default audio tracks defined")}var R=!1,S=function(){_.forEach(function(A){R||(!p.audioGroupId||A.groupId===p.audioGroupId)&&(!x||x===A.name)&&(p._setAudioTrack(A.id),R=!0)})};S(),R||(x=null,S()),R||(f.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(l.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))}},E.prototype._needsTrackLoading=function(p){var _=p.details,g=p.url;return!_||_.live?!!g:!1},E.prototype._loadTrackDetailsIfNeeded=function(p){if(this._needsTrackLoading(p)){var _=p.url,g=p.id;f.logger.log("loading audio-track playlist for id: "+g),this.hls.trigger(l.default.AUDIO_TRACK_LOADING,{url:_,id:g})}},E.prototype._updateTrack=function(p){if(!(p<0||p>=this.tracks.length)){this.clearInterval(),this._trackId=p,f.logger.log("trying to update audio-track "+p);var _=this.tracks[p];this._loadTrackDetailsIfNeeded(_)}},E.prototype._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;var p=this._trackId,_=this.tracks[p],g=_.name,x=_.language,C=_.groupId;f.logger.warn("Loading failed on audio track id: "+p+", group-id: "+C+', name/language: "'+g+'" / "'+x+'"');for(var R=p,S=0;S<this.tracks.length;S++)if(!this.trackIdBlacklist[S]){var A=this.tracks[S];if(A.name===g){R=S;break}}if(R===p){f.logger.warn('No fallback audio-track found for name/language: "'+g+'" / "'+x+'"');return}f.logger.log("Attempting audio-track fallback id:",R,"group-id:",this.tracks[R].groupId),this._setAudioTrack(R)},E}(u.default);t.default=h},"./src/controller/base-stream-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,_){p.__proto__=_}||function(p,_){for(var g in _)_.hasOwnProperty(g)&&(p[g]=_[g])};return function(p,_){E(p,_);function g(){this.constructor=p}p.prototype=_===null?Object.create(_):(g.prototype=_.prototype,new g)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/task-loop.js"),f=n("./src/controller/fragment-tracker.js"),d=n("./src/utils/buffer-helper.js"),h=n("./src/utils/logger.js");t.State={STOPPED:"STOPPED",STARTING:"STARTING",IDLE:"IDLE",PAUSED:"PAUSED",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BUFFER_FLUSHING:"BUFFER_FLUSHING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};var y=function(E){l(p,E);function p(){return E!==null&&E.apply(this,arguments)||this}return p.prototype.doTick=function(){},p.prototype.startLoad=function(){},p.prototype.stopLoad=function(){var _=this.fragCurrent;_&&(_.loader&&_.loader.abort(),this.fragmentTracker.removeFragment(_)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=t.State.STOPPED},p.prototype._streamEnded=function(_,g){var x=this,C=x.fragCurrent,R=x.fragmentTracker;if(!g.live&&C&&!C.backtracked&&C.sn===g.endSN&&!_.nextStart){var S=R.getState(C);return S===f.FragmentState.PARTIAL||S===f.FragmentState.OK}return!1},p.prototype.onMediaSeeking=function(){var _=this,g=_.config,x=_.media,C=_.mediaBuffer,R=_.state,S=x?x.currentTime:null,A=d.BufferHelper.bufferInfo(C||x,S,this.config.maxBufferHole);if(a.isFinite(S)&&h.logger.log("media seeking to "+S.toFixed(3)),R===t.State.FRAG_LOADING){var T=this.fragCurrent;if(A.len===0&&T){var w=g.maxFragLookUpTolerance,P=T.start-w,O=T.start+T.duration+w;S<P||S>O?(T.loader&&(h.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),T.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=t.State.IDLE):h.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else R===t.State.ENDED&&(A.len===0&&(this.fragPrevious=null,this.fragCurrent=null),this.state=t.State.IDLE);x&&(this.lastCurrentTime=S),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=S),this.tick()},p.prototype.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},p.prototype.onHandlerDestroying=function(){this.stopLoad(),E.prototype.onHandlerDestroying.call(this)},p.prototype.onHandlerDestroyed=function(){this.state=t.State.STOPPED,this.fragmentTracker=null},p}(u.default);t.default=y}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/buffer-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,x){g.__proto__=x}||function(g,x){for(var C in x)x.hasOwnProperty(C)&&(g[C]=x[C])};return function(g,x){_(g,x);function C(){this.constructor=g}g.prototype=x===null?Object.create(x):(C.prototype=x.prototype,new C)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/utils/logger.js"),h=n("./src/errors.js"),y=n("./src/utils/mediasource-helper.js"),E=y.getMediaSource(),p=function(_){l(g,_);function g(x){var C=_.call(this,x,u.default.MEDIA_ATTACHING,u.default.MEDIA_DETACHING,u.default.MANIFEST_PARSED,u.default.BUFFER_RESET,u.default.BUFFER_APPENDING,u.default.BUFFER_CODECS,u.default.BUFFER_EOS,u.default.BUFFER_FLUSHING,u.default.LEVEL_PTS_UPDATED,u.default.LEVEL_UPDATED)||this;return C._msDuration=null,C._levelDuration=null,C._levelTargetDuration=10,C._live=null,C._objectUrl=null,C.bufferCodecEventsExpected=0,C.onsbue=C.onSBUpdateEnd.bind(C),C.onsbe=C.onSBUpdateError.bind(C),C.pendingTracks={},C.tracks={},C}return g.prototype.destroy=function(){f.default.prototype.destroy.call(this)},g.prototype.onLevelPtsUpdated=function(x){var C=x.type,R=this.tracks.audio;if(C==="audio"&&R&&R.container==="audio/mpeg"){var S=this.sourceBuffer.audio,A=Math.abs(S.timestampOffset-x.start);if(A>.1){var T=S.updating;try{S.abort()}catch(w){d.logger.warn("can not abort audio buffer: "+w)}T?this.audioTimestampOffset=x.start:(d.logger.warn("change mpeg audio timestamp offset from "+S.timestampOffset+" to "+x.start),S.timestampOffset=x.start)}}},g.prototype.onManifestParsed=function(x){this.bufferCodecEventsExpected=x.altAudio?2:1,d.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},g.prototype.onMediaAttaching=function(x){var C=this.media=x.media;if(C){var R=this.mediaSource=new E;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),R.addEventListener("sourceopen",this.onmso),R.addEventListener("sourceended",this.onmse),R.addEventListener("sourceclose",this.onmsc),C.src=window.URL.createObjectURL(R),this._objectUrl=C.src}},g.prototype.onMediaDetaching=function(){d.logger.log("media source detaching");var x=this.mediaSource;if(x){if(x.readyState==="open")try{x.endOfStream()}catch(C){d.logger.warn("onMediaDetaching:"+C.message+" while calling endOfStream")}x.removeEventListener("sourceopen",this.onmso),x.removeEventListener("sourceended",this.onmse),x.removeEventListener("sourceclose",this.onmsc),this.media&&(window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):d.logger.warn("media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(u.default.MEDIA_DETACHED)},g.prototype.onMediaSourceOpen=function(){d.logger.log("media source opened"),this.hls.trigger(u.default.MEDIA_ATTACHED,{media:this.media});var x=this.mediaSource;x&&x.removeEventListener("sourceopen",this.onmso),this.checkPendingTracks()},g.prototype.checkPendingTracks=function(){var x=this,C=x.bufferCodecEventsExpected,R=x.pendingTracks,S=Object.keys(R).length;(S&&!C||S===2)&&(this.createSourceBuffers(R),this.pendingTracks={},this.doAppending())},g.prototype.onMediaSourceClose=function(){d.logger.log("media source closed")},g.prototype.onMediaSourceEnded=function(){d.logger.log("media source ended")},g.prototype.onSBUpdateEnd=function(){if(this.audioTimestampOffset){var x=this.sourceBuffer.audio;d.logger.warn("change mpeg audio timestamp offset from "+x.timestampOffset+" to "+this.audioTimestampOffset),x.timestampOffset=this.audioTimestampOffset,delete this.audioTimestampOffset}this._needsFlush&&this.doFlush(),this._needsEos&&this.checkEos(),this.appending=!1;var C=this.parent,R=this.segments.reduce(function(w,P){return P.parent===C?w+1:w},0),S={},A=this.sourceBuffer;for(var T in A)S[T]=A[T].buffered;this.hls.trigger(u.default.BUFFER_APPENDED,{parent:C,pending:R,timeRanges:S}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration(),R===0&&this.flushLiveBackBuffer()},g.prototype.onSBUpdateError=function(x){d.logger.error("sourceBuffer error:",x),this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},g.prototype.onBufferReset=function(){var x=this.sourceBuffer;for(var C in x){var R=x[C];try{this.mediaSource.removeSourceBuffer(R),R.removeEventListener("updateend",this.onsbue),R.removeEventListener("error",this.onsbe)}catch{}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},g.prototype.onBufferCodecs=function(x){var C=this;if(!Object.keys(this.sourceBuffer).length){Object.keys(x).forEach(function(S){C.pendingTracks[S]=x[S]});var R=this.mediaSource;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),R&&R.readyState==="open"&&this.checkPendingTracks()}},g.prototype.createSourceBuffers=function(x){var C=this.sourceBuffer,R=this.mediaSource;for(var S in x)if(!C[S]){var A=x[S],T=A.levelCodec||A.codec,w=A.container+";codecs="+T;d.logger.log("creating sourceBuffer("+w+")");try{var P=C[S]=R.addSourceBuffer(w);P.addEventListener("updateend",this.onsbue),P.addEventListener("error",this.onsbe),this.tracks[S]={codec:T,container:A.container},A.buffer=P}catch(O){d.logger.error("error while trying to add sourceBuffer:"+O.message),this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:O,mimeType:w})}}this.hls.trigger(u.default.BUFFER_CREATED,{tracks:x})},g.prototype.onBufferAppending=function(x){this._needsFlush||(this.segments?this.segments.push(x):this.segments=[x],this.doAppending())},g.prototype.onBufferAppendFail=function(x){d.logger.error("sourceBuffer error:",x.event),this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},g.prototype.onBufferEos=function(x){var C=this.sourceBuffer,R=x.type;for(var S in C)(!R||S===R)&&(C[S].ended||(C[S].ended=!0,d.logger.log(S+" sourceBuffer now EOS")));this.checkEos()},g.prototype.checkEos=function(){var x=this.sourceBuffer,C=this.mediaSource;if(!C||C.readyState!=="open"){this._needsEos=!1;return}for(var R in x){var S=x[R];if(!S.ended)return;if(S.updating){this._needsEos=!0;return}}d.logger.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{C.endOfStream()}catch{d.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1},g.prototype.onBufferFlushing=function(x){this.flushRange.push({start:x.startOffset,end:x.endOffset,type:x.type}),this.flushBufferCounter=0,this.doFlush()},g.prototype.flushLiveBackBuffer=function(){if(this._live){var x=this.hls.config.liveBackBufferLength;if(!(!isFinite(x)||x<0))for(var C=this.media.currentTime,R=this.sourceBuffer,S=Object.keys(R),A=C-Math.max(x,this._levelTargetDuration),T=S.length-1;T>=0;T--){var w=S[T],P=R[w].buffered;P.length>0&&A>P.start(0)&&this.removeBufferRange(w,R[w],0,A)}}},g.prototype.onLevelUpdated=function(x){var C=x.details;C.fragments.length>0&&(this._levelDuration=C.totalduration+C.fragments[0].start,this._levelTargetDuration=C.averagetargetduration||C.targetduration||10,this._live=C.live,this.updateMediaElementDuration())},g.prototype.updateMediaElementDuration=function(){var x=this.hls.config,C;if(!(this._levelDuration===null||!this.media||!this.mediaSource||!this.sourceBuffer||this.media.readyState===0||this.mediaSource.readyState!=="open")){for(var R in this.sourceBuffer)if(this.sourceBuffer[R].updating===!0)return;C=this.media.duration,this._msDuration===null&&(this._msDuration=this.mediaSource.duration),this._live===!0&&x.liveDurationInfinity===!0?(d.logger.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>C||!a.isFinite(C))&&(d.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},g.prototype.doFlush=function(){for(;this.flushRange.length;){var x=this.flushRange[0];if(this.flushBuffer(x.start,x.end,x.type))this.flushRange.shift(),this.flushBufferCounter=0;else{this._needsFlush=!0;return}}if(this.flushRange.length===0){this._needsFlush=!1;var C=0,R=this.sourceBuffer;try{for(var S in R)C+=R[S].buffered.length}catch{d.logger.error("error while accessing sourceBuffer.buffered")}this.appended=C,this.hls.trigger(u.default.BUFFER_FLUSHED)}},g.prototype.doAppending=function(){var x=this,C=x.hls,R=x.segments,S=x.sourceBuffer;if(Object.keys(S).length){if(this.media.error){this.segments=[],d.logger.error("trying to append although a media error occured, flush segment and abort");return}if(this.appending)return;if(R&&R.length){var A=R.shift();try{var T=A.type,w=S[T];w?w.updating?R.unshift(A):(w.ended=!1,this.parent=A.parent,w.appendBuffer(A.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(O){d.logger.error("error while trying to append buffer:"+O.message),R.unshift(A);var P={type:h.ErrorTypes.MEDIA_ERROR,parent:A.parent};O.code!==22?(this.appendError?this.appendError++:this.appendError=1,P.details=h.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>C.config.appendErrorMaxRetry?(d.logger.log("fail "+C.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],P.fatal=!0,C.trigger(u.default.ERROR,P)):(P.fatal=!1,C.trigger(u.default.ERROR,P))):(this.segments=[],P.details=h.ErrorDetails.BUFFER_FULL_ERROR,P.fatal=!1,C.trigger(u.default.ERROR,P))}}}},g.prototype.flushBuffer=function(x,C,R){var S,A=this.sourceBuffer;if(Object.keys(A).length){if(d.logger.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+x+"/"+C),this.flushBufferCounter<this.appended){for(var T in A)if(!(R&&T!==R)){if(S=A[T],S.ended=!1,S.updating)return d.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(T,S,x,C))return this.flushBufferCounter++,!1}}else d.logger.warn("abort flushing too many retries");d.logger.log("buffer flushed")}return!0},g.prototype.removeBufferRange=function(x,C,R,S){try{for(var A=0;A<C.buffered.length;A++){var T=C.buffered.start(A),w=C.buffered.end(A),P=Math.max(T,R),O=Math.min(w,S);if(Math.min(O,w)-P>.5)return d.logger.log("sb remove "+x+" ["+P+","+O+"], of ["+T+","+w+"], pos:"+this.media.currentTime),C.remove(P,O),!0}}catch(k){d.logger.warn("removeBufferRange failed",k)}return!1},g}(f.default);t.default=p}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/cap-level-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,E){y.__proto__=E}||function(y,E){for(var p in E)E.hasOwnProperty(p)&&(y[p]=E[p])};return function(y,E){h(y,E);function p(){this.constructor=y}y.prototype=E===null?Object.create(E):(p.prototype=E.prototype,new p)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=function(h){l(y,h);function y(E){var p=h.call(this,E,u.default.FPS_DROP_LEVEL_CAPPING,u.default.MEDIA_ATTACHING,u.default.MANIFEST_PARSED,u.default.BUFFER_CODECS,u.default.MEDIA_DETACHING)||this;return p.autoLevelCapping=a.POSITIVE_INFINITY,p.firstLevel=null,p.levels=[],p.media=null,p.restrictedLevels=[],p.timer=null,p}return y.prototype.destroy=function(){this.hls.config.capLevelToPlayerSize&&(this.media=null,this._stopCapping())},y.prototype.onFpsDropLevelCapping=function(E){y.isLevelAllowed(E.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(E.droppedLevel)},y.prototype.onMediaAttaching=function(E){this.media=E.media instanceof window.HTMLVideoElement?E.media:null},y.prototype.onManifestParsed=function(E){var p=this.hls;this.restrictedLevels=[],this.levels=E.levels,this.firstLevel=E.firstLevel,p.config.capLevelToPlayerSize&&E.video&&this._startCapping()},y.prototype.onBufferCodecs=function(E){var p=this.hls;p.config.capLevelToPlayerSize&&E.video&&this._startCapping()},y.prototype.onLevelsUpdated=function(E){this.levels=E.levels},y.prototype.onMediaDetaching=function(){this._stopCapping()},y.prototype.detectPlayerSize=function(){if(this.media){var E=this.levels?this.levels.length:0;if(E){var p=this.hls;p.autoLevelCapping=this.getMaxLevel(E-1),p.autoLevelCapping>this.autoLevelCapping&&p.streamController.nextLevelSwitch(),this.autoLevelCapping=p.autoLevelCapping}}},y.prototype.getMaxLevel=function(E){var p=this;if(!this.levels)return-1;var _=this.levels.filter(function(g,x){return y.isLevelAllowed(x,p.restrictedLevels)&&x<=E});return y.getMaxLevelByMediaSize(_,this.mediaWidth,this.mediaHeight)},y.prototype._startCapping=function(){this.timer||(this.autoLevelCapping=a.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},y.prototype._stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=a.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},Object.defineProperty(y.prototype,"mediaWidth",{get:function(){var E,p=this.media;return p&&(E=p.width||p.clientWidth||p.offsetWidth,E*=y.contentScaleFactor),E},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"mediaHeight",{get:function(){var E,p=this.media;return p&&(E=p.height||p.clientHeight||p.offsetHeight,E*=y.contentScaleFactor),E},enumerable:!0,configurable:!0}),Object.defineProperty(y,"contentScaleFactor",{get:function(){var E=1;try{E=window.devicePixelRatio}catch{}return E},enumerable:!0,configurable:!0}),y.isLevelAllowed=function(E,p){return p===void 0&&(p=[]),p.indexOf(E)===-1},y.getMaxLevelByMediaSize=function(E,p,_){if(!E||E&&!E.length)return-1;for(var g=function(S,A){return A?S.width!==A.width||S.height!==A.height:!0},x=E.length-1,C=0;C<E.length;C+=1){var R=E[C];if((R.width>=p||R.height>=_)&&g(R,E[C+1])){x=C;break}}return x},y}(f.default);t.default=d}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/eme-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,R){C.__proto__=R}||function(C,R){for(var S in R)R.hasOwnProperty(S)&&(C[S]=R[S])};return function(C,R){x(C,R);function S(){this.constructor=C}C.prototype=R===null?Object.create(R):(S.prototype=R.prototype,new S)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/event-handler.js"),u=n("./src/events.js"),f=n("./src/errors.js"),d=n("./src/utils/logger.js"),h=window.XMLHttpRequest,y=3,E={WIDEVINE:"com.widevine.alpha",PLAYREADY:"com.microsoft.playready"},p=function(x,C,R){var S={videoCapabilities:[]};return C.forEach(function(A){S.videoCapabilities.push({contentType:'video/mp4; codecs="'+A+'"'})}),[S]},_=function(x,C,R){switch(x){case E.WIDEVINE:return p(C,R);default:throw Error("Unknown key-system: "+x)}},g=function(x){a(C,x);function C(R){var S=x.call(this,R,u.default.MEDIA_ATTACHED,u.default.MANIFEST_PARSED)||this;return S._widevineLicenseUrl=R.config.widevineLicenseUrl,S._licenseXhrSetup=R.config.licenseXhrSetup,S._emeEnabled=R.config.emeEnabled,S._requestMediaKeySystemAccess=R.config.requestMediaKeySystemAccessFunc,S._mediaKeysList=[],S._media=null,S._hasSetMediaKeys=!1,S._isMediaEncrypted=!1,S._requestLicenseFailureCount=0,S}return C.prototype.getLicenseServerUrl=function(R){var S;switch(R){case E.WIDEVINE:S=this._widevineLicenseUrl;break;default:S=null;break}return S||(d.logger.error('No license server URL configured for key-system "'+R+'"'),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})),S},C.prototype._attemptKeySystemAccess=function(R,S,A){var T=this,w=_(R,S,A);if(!w){d.logger.warn("Can not create config for key-system (maybe because platform is not supported):",R);return}d.logger.log("Requesting encrypted media key-system access"),this.requestMediaKeySystemAccess(R,w).then(function(P){T._onMediaKeySystemAccessObtained(R,P)}).catch(function(P){d.logger.error('Failed to obtain key-system "'+R+'" access:',P)})},Object.defineProperty(C.prototype,"requestMediaKeySystemAccess",{get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess},enumerable:!0,configurable:!0}),C.prototype._onMediaKeySystemAccessObtained=function(R,S){var A=this;d.logger.log('Access for key-system "'+R+'" obtained');var T={mediaKeys:null,mediaKeysSession:null,mediaKeysSessionInitialized:!1,mediaKeySystemAccess:S,mediaKeySystemDomain:R};this._mediaKeysList.push(T),S.createMediaKeys().then(function(w){T.mediaKeys=w,d.logger.log('Media-keys created for key-system "'+R+'"'),A._onMediaKeysCreated()}).catch(function(w){d.logger.error("Failed to create media-keys:",w)})},C.prototype._onMediaKeysCreated=function(){var R=this;this._mediaKeysList.forEach(function(S){S.mediaKeysSession||(S.mediaKeysSession=S.mediaKeys.createSession(),R._onNewMediaKeySession(S.mediaKeysSession))})},C.prototype._onNewMediaKeySession=function(R){var S=this;d.logger.log("New key-system session "+R.sessionId),R.addEventListener("message",function(A){S._onKeySessionMessage(R,A.message)},!1)},C.prototype._onKeySessionMessage=function(R,S){d.logger.log("Got EME message event, creating license request"),this._requestLicense(S,function(A){d.logger.log("Received license data, updating key-session"),R.update(A)})},C.prototype._onMediaEncrypted=function(R,S){d.logger.log('Media is encrypted using "'+R+'" init data type'),this._isMediaEncrypted=!0,this._mediaEncryptionInitDataType=R,this._mediaEncryptionInitData=S,this._attemptSetMediaKeys(),this._generateRequestWithPreferredKeySession()},C.prototype._attemptSetMediaKeys=function(){if(!this._hasSetMediaKeys){var R=this._mediaKeysList[0];if(!R||!R.mediaKeys){d.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}d.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(R.mediaKeys),this._hasSetMediaKeys=!0}},C.prototype._generateRequestWithPreferredKeySession=function(){var R=this,S=this._mediaKeysList[0];if(!S){d.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(S.mediaKeysSessionInitialized){d.logger.warn("Key-Session already initialized but requested again");return}var A=S.mediaKeysSession;A||(d.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0}));var T=this._mediaEncryptionInitDataType,w=this._mediaEncryptionInitData;d.logger.log('Generating key-session request for "'+T+'" init data type'),S.mediaKeysSessionInitialized=!0,A.generateRequest(T,w).then(function(){d.logger.debug("Key-session generation succeeded")}).catch(function(P){d.logger.error("Error generating key-session request:",P),R.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},C.prototype._createLicenseXhr=function(R,S,A){var T=new h,w=this._licenseXhrSetup;try{if(w)try{w(T,R)}catch{T.open("POST",R,!0),w(T,R)}T.readyState||T.open("POST",R,!0)}catch(P){d.logger.error("Error setting up key-system license XHR",P),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}return T.responseType="arraybuffer",T.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,T,R,S,A),T},C.prototype._onLicenseRequestReadyStageChange=function(R,S,A,T){switch(R.readyState){case 4:if(R.status===200)this._requestLicenseFailureCount=0,d.logger.log("License request succeeded"),T(R.response);else{if(d.logger.error("License Request XHR failed ("+S+"). Status: "+R.status+" ("+R.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount<=y){var w=y-this._requestLicenseFailureCount+1;d.logger.warn("Retrying license request, "+w+" attempts left"),this._requestLicense(A,T);return}this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}break}},C.prototype._generateLicenseRequestChallenge=function(R,S){var A;return R.mediaKeySystemDomain===E.PLAYREADY?d.logger.error("PlayReady is not supported (yet)"):R.mediaKeySystemDomain===E.WIDEVINE?A=S:d.logger.error("Unsupported key-system:",R.mediaKeySystemDomain),A},C.prototype._requestLicense=function(R,S){d.logger.log("Requesting content license for key-system");var A=this._mediaKeysList[0];if(!A){d.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}var T=this.getLicenseServerUrl(A.mediaKeySystemDomain),w=this._createLicenseXhr(T,R,S);d.logger.log("Sending license request to URL: "+T),w.send(this._generateLicenseRequestChallenge(A,R))},C.prototype.onMediaAttached=function(R){var S=this;if(this._emeEnabled){var A=R.media;this._media=A,A.addEventListener("encrypted",function(T){S._onMediaEncrypted(T.initDataType,T.initData)})}},C.prototype.onManifestParsed=function(R){if(this._emeEnabled){var S=R.levels.map(function(T){return T.audioCodec}),A=R.levels.map(function(T){return T.videoCodec});this._attemptKeySystemAccess(E.WIDEVINE,S,A)}},C}(l.default);t.default=g},"./src/controller/fps-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,p){E.__proto__=p}||function(E,p){for(var _ in p)p.hasOwnProperty(_)&&(E[_]=p[_])};return function(E,p){y(E,p);function _(){this.constructor=E}E.prototype=p===null?Object.create(p):(_.prototype=p.prototype,new _)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/event-handler.js"),f=n("./src/utils/logger.js"),d=window.performance,h=function(y){a(E,y);function E(p){return y.call(this,p,l.default.MEDIA_ATTACHING)||this}return E.prototype.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},E.prototype.onMediaAttaching=function(p){var _=this.hls.config;if(_.capLevelOnFPSDrop){var g=this.video=p.media instanceof window.HTMLVideoElement?p.media:null;typeof g.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),_.fpsDroppedMonitoringPeriod)}},E.prototype.checkFPS=function(p,_,g){var x=d.now();if(_){if(this.lastTime){var C=x-this.lastTime,R=g-this.lastDroppedFrames,S=_-this.lastDecodedFrames,A=1e3*R/C,T=this.hls;if(T.trigger(l.default.FPS_DROP,{currentDropped:R,currentDecoded:S,totalDroppedFrames:g}),A>0&&R>T.config.fpsDroppedMonitoringThreshold*S){var w=T.currentLevel;f.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+w),w>0&&(T.autoLevelCapping===-1||T.autoLevelCapping>=w)&&(w=w-1,T.trigger(l.default.FPS_DROP_LEVEL_CAPPING,{level:w,droppedLevel:T.currentLevel}),T.autoLevelCapping=w,T.streamController.nextLevelSwitch())}}this.lastTime=x,this.lastDroppedFrames=g,this.lastDecodedFrames=_}},E.prototype.checkFPSInterval=function(){var p=this.video;if(p)if(this.isVideoPlaybackQualityAvailable){var _=p.getVideoPlaybackQuality();this.checkFPS(p,_.totalVideoFrames,_.droppedVideoFrames)}else this.checkFPS(p,p.webkitDecodedFrameCount,p.webkitDroppedFrameCount)},E}(u.default);t.default=h},"./src/controller/fragment-finders.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/utils/binary-search.js");function u(y,E,p){if(!Array.isArray(y)||!y.length||!a.isFinite(E)||E<y[0].programDateTime||E>=y[y.length-1].endProgramDateTime)return null;p=p||0;for(var _=0;_<y.length;++_){var g=y[_];if(h(E,p,g))return g}return null}t.findFragmentByPDT=u;function f(y,E,p,_){p===void 0&&(p=0),_===void 0&&(_=0);var g=y?E[y.sn-E[0].sn+1]:null;return g&&!d(p,_,g)?g:l.default.search(E,d.bind(null,p,_))}t.findFragmentByPTS=f;function d(y,E,p){y===void 0&&(y=0),E===void 0&&(E=0);var _=Math.min(E,p.duration+(p.deltaPTS?p.deltaPTS:0));return p.start+p.duration-_<=y?1:p.start-_>y&&p.start?-1:0}t.fragmentWithinToleranceTest=d;function h(y,E,p){var _=Math.min(E,p.duration+(p.deltaPTS?p.deltaPTS:0))*1e3;return p.endProgramDateTime-_>y}t.pdtWithinToleranceTest=h}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/fragment-tracker.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,E){y.__proto__=E}||function(y,E){for(var p in E)E.hasOwnProperty(p)&&(y[p]=E[p])};return function(y,E){h(y,E);function p(){this.constructor=y}y.prototype=E===null?Object.create(E):(p.prototype=E.prototype,new p)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/event-handler.js"),f=n("./src/events.js");t.FragmentState={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};var d=function(h){l(y,h);function y(E){var p=h.call(this,E,f.default.BUFFER_APPENDED,f.default.FRAG_BUFFERED,f.default.FRAG_LOADED)||this;return p.bufferPadding=.2,p.fragments=Object.create(null),p.timeRanges=Object.create(null),p.config=E.config,p}return y.prototype.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,u.default.prototype.destroy.call(this),h.prototype.destroy.call(this)},y.prototype.getBufferedFrag=function(E,p){var _=this.fragments,g=Object.keys(_).filter(function(C){var R=_[C];if(R.body.type!==p||!R.buffered)return!1;var S=R.body;return S.startPTS<=E&&E<=S.endPTS});if(g.length===0)return null;var x=g.pop();return _[x].body},y.prototype.detectEvictedFragments=function(E,p){var _=this,g,x;Object.keys(this.fragments).forEach(function(C){var R=_.fragments[C];if(R.buffered===!0){var S=R.range[E];if(S){g=S.time;for(var A=0;A<g.length;A++)if(x=g[A],_.isTimeBuffered(x.startPTS,x.endPTS,p)===!1){_.removeFragment(R.body);break}}}})},y.prototype.detectPartialFragments=function(E){var p=this,_=this.getFragmentKey(E),g=this.fragments[_];g&&(g.buffered=!0,Object.keys(this.timeRanges).forEach(function(x){if(E.hasElementaryStream(x)){var C=p.timeRanges[x];g.range[x]=p.getBufferedTimes(E.startPTS,E.endPTS,C)}}))},y.prototype.getBufferedTimes=function(E,p,_){for(var g=[],x,C,R=!1,S=0;S<_.length;S++)if(x=_.start(S)-this.bufferPadding,C=_.end(S)+this.bufferPadding,E>=x&&p<=C){g.push({startPTS:Math.max(E,_.start(S)),endPTS:Math.min(p,_.end(S))});break}else if(E<C&&p>x)g.push({startPTS:Math.max(E,_.start(S)),endPTS:Math.min(p,_.end(S))}),R=!0;else if(p<=x)break;return{time:g,partial:R}},y.prototype.getFragmentKey=function(E){return E.type+"_"+E.level+"_"+E.urlId+"_"+E.sn},y.prototype.getPartialFragment=function(E){var p=this,_,g,x,C=null,R=0;return Object.keys(this.fragments).forEach(function(S){var A=p.fragments[S];p.isPartial(A)&&(g=A.body.startPTS-p.bufferPadding,x=A.body.endPTS+p.bufferPadding,E>=g&&E<=x&&(_=Math.min(E-g,x-E),R<=_&&(C=A.body,R=_)))}),C},y.prototype.getState=function(E){var p=this.getFragmentKey(E),_=this.fragments[p],g=t.FragmentState.NOT_LOADED;return _!==void 0&&(_.buffered?this.isPartial(_)===!0?g=t.FragmentState.PARTIAL:g=t.FragmentState.OK:g=t.FragmentState.APPENDING),g},y.prototype.isPartial=function(E){return E.buffered===!0&&(E.range.video!==void 0&&E.range.video.partial===!0||E.range.audio!==void 0&&E.range.audio.partial===!0)},y.prototype.isTimeBuffered=function(E,p,_){for(var g,x,C=0;C<_.length;C++){if(g=_.start(C)-this.bufferPadding,x=_.end(C)+this.bufferPadding,E>=g&&p<=x)return!0;if(p<=g)return!1}return!1},y.prototype.onFragLoaded=function(E){var p=E.frag;!a.isFinite(p.sn)||p.bitrateTest||(this.fragments[this.getFragmentKey(p)]={body:p,range:Object.create(null),buffered:!1})},y.prototype.onBufferAppended=function(E){var p=this;this.timeRanges=E.timeRanges,Object.keys(this.timeRanges).forEach(function(_){var g=p.timeRanges[_];p.detectEvictedFragments(_,g)})},y.prototype.onFragBuffered=function(E){this.detectPartialFragments(E.frag)},y.prototype.hasFragment=function(E){var p=this.getFragmentKey(E);return this.fragments[p]!==void 0},y.prototype.removeFragment=function(E){var p=this.getFragmentKey(E);delete this.fragments[p]},y.prototype.removeAllFragments=function(){this.fragments=Object.create(null)},y}(u.default);t.FragmentTracker=d}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/gap-controller.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/buffer-helper.js"),l=n("./src/errors.js"),u=n("./src/events.js"),f=n("./src/utils/logger.js"),d=1e3,h=.5,y=function(){function E(p,_,g,x){this.config=p,this.media=_,this.fragmentTracker=g,this.hls=x,this.stallReported=!1}return E.prototype.poll=function(p,_){var g=this,x=g.config,C=g.media,R=C.currentTime,S=window.performance.now();if(R!==p){this.stallReported&&(f.logger.warn("playback not stuck anymore @"+R+", after "+Math.round(S-this.stalled)+"ms"),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0;return}if(!(C.ended||!C.buffered.length||C.readyState>2)&&!(C.seeking&&a.BufferHelper.isBuffered(C,R))){var A=S-this.stalled,T=a.BufferHelper.bufferInfo(C,R,x.maxBufferHole);if(this.stalled)A>=d&&this._reportStall(T.len);else{this.stalled=S;return}this._tryFixBufferStall(T,A)}},E.prototype._tryFixBufferStall=function(p,_){var g=this,x=g.config,C=g.fragmentTracker,R=g.media,S=R.currentTime,A=C.getPartialFragment(S);A&&this._trySkipBufferHole(A),p.len>h&&_>x.highBufferWatchdogPeriod*1e3&&(this.stalled=null,this._tryNudgeBuffer())},E.prototype._reportStall=function(p){var _=this,g=_.hls,x=_.media,C=_.stallReported;C||(this.stallReported=!0,f.logger.warn("Playback stalling at @"+x.currentTime+" due to low buffer"),g.trigger(u.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p}))},E.prototype._trySkipBufferHole=function(p){for(var _=this,g=_.hls,x=_.media,C=x.currentTime,R=0,S=0;S<x.buffered.length;S++){var A=x.buffered.start(S);if(C>=R&&C<A){x.currentTime=Math.max(A,x.currentTime+.1),f.logger.warn("skipping hole, adjusting currentTime from "+C+" to "+x.currentTime),this.stalled=null,g.trigger(u.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+C+" to "+x.currentTime,frag:p});return}R=x.buffered.end(S)}},E.prototype._tryNudgeBuffer=function(){var p=this,_=p.config,g=p.hls,x=p.media,C=x.currentTime,R=(this.nudgeRetry||0)+1;if(this.nudgeRetry=R,R<_.nudgeMaxRetry){var S=C+R*_.nudgeOffset;f.logger.log("adjust currentTime from "+C+" to "+S),x.currentTime=S,g.trigger(u.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else f.logger.error("still stuck in high buffer @"+C+" after "+_.nudgeMaxRetry+", raise fatal error"),g.trigger(u.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},E}();t.default=y},"./src/controller/id3-track-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,p){E.__proto__=p}||function(E,p){for(var _ in p)p.hasOwnProperty(_)&&(E[_]=p[_])};return function(E,p){y(E,p);function _(){this.constructor=E}E.prototype=p===null?Object.create(p):(_.prototype=p.prototype,new _)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/event-handler.js"),f=n("./src/demux/id3.js"),d=n("./src/utils/texttrack-utils.js"),h=function(y){a(E,y);function E(p){var _=y.call(this,p,l.default.MEDIA_ATTACHED,l.default.MEDIA_DETACHING,l.default.FRAG_PARSING_METADATA)||this;return _.id3Track=void 0,_.media=void 0,_}return E.prototype.destroy=function(){u.default.prototype.destroy.call(this)},E.prototype.onMediaAttached=function(p){this.media=p.media,this.media},E.prototype.onMediaDetaching=function(){d.clearCurrentCues(this.id3Track),this.id3Track=void 0,this.media=void 0},E.prototype.getID3Track=function(p){for(var _=0;_<p.length;_++){var g=p[_];if(g.kind==="metadata"&&g.label==="id3")return d.sendAddTrackEvent(g,this.media),g}return this.media.addTextTrack("metadata","id3")},E.prototype.onFragParsingMetadata=function(p){var _=p.frag,g=p.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var x=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,C=0;C<g.length;C++){var R=f.default.getID3Frames(g[C].data);if(R){var S=g[C].pts,A=C<g.length-1?g[C+1].pts:_.endPTS;S===A&&(A+=1e-4);for(var T=0;T<R.length;T++){var w=R[T];if(!f.default.isTimeStampFrame(w)){var P=new x(S,A,"");P.value=w,this.id3Track.addCue(P)}}}}},E}(u.default);t.default=h},"./src/controller/level-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,x){g.__proto__=x}||function(g,x){for(var C in x)x.hasOwnProperty(C)&&(g[C]=x[C])};return function(g,x){_(g,x);function C(){this.constructor=g}g.prototype=x===null?Object.create(x):(C.prototype=x.prototype,new C)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/event-handler.js"),f=n("./src/utils/logger.js"),d=n("./src/errors.js"),h=n("./src/utils/codecs.js"),y=n("./src/controller/level-helper.js"),E,p=function(_){a(g,_);function g(x){var C=_.call(this,x,l.default.MANIFEST_LOADED,l.default.LEVEL_LOADED,l.default.AUDIO_TRACK_SWITCHED,l.default.FRAG_LOADED,l.default.ERROR)||this;return C.canload=!1,C.currentLevelIndex=null,C.manualLevelIndex=-1,C.timer=null,E=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),C}return g.prototype.onHandlerDestroying=function(){this.clearTimer(),this.manualLevelIndex=-1},g.prototype.clearTimer=function(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)},g.prototype.startLoad=function(){var x=this._levels;this.canload=!0,this.levelRetryCount=0,x&&x.forEach(function(C){C.loadError=0;var R=C.details;R&&R.live&&(C.details=void 0)}),this.timer!==null&&this.loadLevel()},g.prototype.stopLoad=function(){this.canload=!1},g.prototype.onManifestLoaded=function(x){var C=[],R=[],S,A={},T=null,w=!1,P=!1;if(x.levels.forEach(function(k){var D=k.attrs;k.loadError=0,k.fragmentError=!1,w=w||!!k.videoCodec,P=P||!!k.audioCodec,E&&k.audioCodec&&k.audioCodec.indexOf("mp4a.40.34")!==-1&&(k.audioCodec=void 0),T=A[k.bitrate],T?T.url.push(k.url):(k.url=[k.url],k.urlId=0,A[k.bitrate]=k,C.push(k)),D&&(D.AUDIO&&(P=!0,y.addGroupId(T||k,"audio",D.AUDIO)),D.SUBTITLES&&y.addGroupId(T||k,"text",D.SUBTITLES))}),w&&P&&(C=C.filter(function(k){var D=k.videoCodec;return!!D})),C=C.filter(function(k){var D=k.audioCodec,F=k.videoCodec;return(!D||h.isCodecSupportedInMp4(D,"audio"))&&(!F||h.isCodecSupportedInMp4(F,"video"))}),x.audioTracks&&(R=x.audioTracks.filter(function(k){return!k.audioCodec||h.isCodecSupportedInMp4(k.audioCodec,"audio")}),R.forEach(function(k,D){k.id=D})),C.length>0){S=C[0].bitrate,C.sort(function(k,D){return k.bitrate-D.bitrate}),this._levels=C;for(var O=0;O<C.length;O++)if(C[O].bitrate===S){this._firstLevel=O,f.logger.log("manifest loaded,"+C.length+" level(s) found, first bitrate:"+S);break}this.hls.trigger(l.default.MANIFEST_PARSED,{levels:C,audioTracks:R,firstLevel:this._firstLevel,stats:x.stats,audio:P,video:w,altAudio:R.some(function(k){return!!k.url})})}else this.hls.trigger(l.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})},Object.defineProperty(g.prototype,"levels",{get:function(){return this._levels},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"level",{get:function(){return this.currentLevelIndex},set:function(x){var C=this._levels;C&&(x=Math.min(x,C.length-1),(this.currentLevelIndex!==x||!C[x].details)&&this.setLevelInternal(x))},enumerable:!0,configurable:!0}),g.prototype.setLevelInternal=function(x){var C=this._levels,R=this.hls;if(x>=0&&x<C.length){if(this.clearTimer(),this.currentLevelIndex!==x){f.logger.log("switching to level "+x),this.currentLevelIndex=x;var S=C[x];S.level=x,R.trigger(l.default.LEVEL_SWITCHING,S)}var A=C[x],T=A.details;if(!T||T.live){var w=A.urlId;R.trigger(l.default.LEVEL_LOADING,{url:A.url[w],level:x,id:w})}}else R.trigger(l.default.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.LEVEL_SWITCH_ERROR,level:x,fatal:!1,reason:"invalid level idx"})},Object.defineProperty(g.prototype,"manualLevel",{get:function(){return this.manualLevelIndex},set:function(x){this.manualLevelIndex=x,this._startLevel===void 0&&(this._startLevel=x),x!==-1&&(this.level=x)},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"firstLevel",{get:function(){return this._firstLevel},set:function(x){this._firstLevel=x},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"startLevel",{get:function(){if(this._startLevel===void 0){var x=this.hls.config.startLevel;return x!==void 0?x:this._firstLevel}else return this._startLevel},set:function(x){this._startLevel=x},enumerable:!0,configurable:!0}),g.prototype.onError=function(x){if(x.fatal){x.type===d.ErrorTypes.NETWORK_ERROR&&this.clearTimer();return}var C=!1,R=!1,S;switch(x.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:S=x.frag.level,R=!0;break;case d.ErrorDetails.LEVEL_LOAD_ERROR:case d.ErrorDetails.LEVEL_LOAD_TIMEOUT:S=x.context.level,C=!0;break;case d.ErrorDetails.REMUX_ALLOC_ERROR:S=x.level,C=!0;break}S!==void 0&&this.recoverLevel(x,S,C,R)},g.prototype.recoverLevel=function(x,C,R,S){var A=this,T=this.hls.config,w=x.details,P=this._levels[C],O,k,D;if(P.loadError++,P.fragmentError=S,R)if(this.levelRetryCount+1<=T.levelLoadingMaxRetry)k=Math.min(Math.pow(2,this.levelRetryCount)*T.levelLoadingRetryDelay,T.levelLoadingMaxRetryTimeout),this.timer=setTimeout(function(){return A.loadLevel()},k),x.levelRetry=!0,this.levelRetryCount++,f.logger.warn("level controller, "+w+", retry in "+k+" ms, current retry count is "+this.levelRetryCount);else{f.logger.error("level controller, cannot recover from "+w+" error"),this.currentLevelIndex=null,this.clearTimer(),x.fatal=!0;return}(R||S)&&(O=P.url.length,O>1&&P.loadError<O?(P.urlId=(P.urlId+1)%O,P.details=void 0,f.logger.warn("level controller, "+w+" for level "+C+": switching to redundant URL-id "+P.urlId)):this.manualLevelIndex===-1?(D=C===0?this._levels.length-1:C-1,f.logger.warn("level controller, "+w+": switch to "+D),this.hls.nextAutoLevel=this.currentLevelIndex=D):S&&(f.logger.warn("level controller, "+w+": reload a fragment"),this.currentLevelIndex=null))},g.prototype.onFragLoaded=function(x){var C=x.frag;if(C!==void 0&&C.type==="main"){var R=this._levels[C.level];R!==void 0&&(R.fragmentError=!1,R.loadError=0,this.levelRetryCount=0)}},g.prototype.onLevelLoaded=function(x){var C=this,R=x.level,S=x.details;if(R===this.currentLevelIndex){var A=this._levels[R];if(A.fragmentError||(A.loadError=0,this.levelRetryCount=0),S.live){var T=y.computeReloadInterval(A.details,S,x.stats.trequest);f.logger.log("live playlist, reload in "+Math.round(T)+" ms"),this.timer=setTimeout(function(){return C.loadLevel()},T)}else this.clearTimer()}},g.prototype.onAudioTrackSwitched=function(x){var C=this.hls.audioTracks[x.id].groupId,R=this.hls.levels[this.currentLevelIndex];if(R&&R.audioGroupIds){for(var S=-1,A=0;A<R.audioGroupIds.length;A++)if(R.audioGroupIds[A]===C){S=A;break}S!==R.urlId&&(R.urlId=S,this.startLoad())}},g.prototype.loadLevel=function(){if(f.logger.debug("call to loadLevel"),this.currentLevelIndex!==null&&this.canload){var x=this._levels[this.currentLevelIndex];if(typeof x=="object"&&x.url.length>0){var C=this.currentLevelIndex,R=x.urlId,S=x.url[R];f.logger.log("Attempt loading level index "+C+" with URL-id "+R),this.hls.trigger(l.default.LEVEL_LOADING,{url:S,level:C,id:R})}}},Object.defineProperty(g.prototype,"nextLoadLevel",{get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(x){this.level=x,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=x)},enumerable:!0,configurable:!0}),g}(u.default);t.default=p},"./src/controller/level-helper.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/utils/logger.js");function u(g,x,C){switch(x){case"audio":g.audioGroupIds||(g.audioGroupIds=[]),g.audioGroupIds.push(C);break;case"text":g.textGroupIds||(g.textGroupIds=[]),g.textGroupIds.push(C);break}}t.addGroupId=u;function f(g,x,C){var R=g[x],S=g[C],A=S.startPTS;a.isFinite(A)?C>x?(R.duration=A-R.start,R.duration<0&&l.logger.warn("negative duration computed for frag "+R.sn+",level "+R.level+", there should be some duration drift between playlist and fragment!")):(S.duration=R.start-A,S.duration<0&&l.logger.warn("negative duration computed for frag "+S.sn+",level "+S.level+", there should be some duration drift between playlist and fragment!")):C>x?S.start=R.start+R.duration:S.start=Math.max(R.start-S.duration,0)}t.updatePTS=f;function d(g,x,C,R,S,A){var T=C;if(a.isFinite(x.startPTS)){var w=Math.abs(x.startPTS-C);a.isFinite(x.deltaPTS)?x.deltaPTS=Math.max(w,x.deltaPTS):x.deltaPTS=w,T=Math.max(C,x.startPTS),C=Math.min(C,x.startPTS),R=Math.max(R,x.endPTS),S=Math.min(S,x.startDTS),A=Math.max(A,x.endDTS)}var P=C-x.start;x.start=x.startPTS=C,x.maxStartPTS=T,x.endPTS=R,x.startDTS=S,x.endDTS=A,x.duration=R-C;var O=x.sn;if(!g||O<g.startSN||O>g.endSN)return 0;var k,D,F;for(k=O-g.startSN,D=g.fragments,D[k]=x,F=k;F>0;F--)f(D,F,F-1);for(F=k;F<D.length-1;F++)f(D,F,F+1);return g.PTSKnown=!0,P}t.updateFragPTSDTS=d;function h(g,x){x.initSegment&&g.initSegment&&(x.initSegment=g.initSegment);var C=0,R;if(E(g,x,function(T,w){C=T.cc-w.cc,a.isFinite(T.startPTS)&&(w.start=w.startPTS=T.startPTS,w.endPTS=T.endPTS,w.duration=T.duration,w.backtracked=T.backtracked,w.dropped=T.dropped,R=w),x.PTSKnown=!0}),!!x.PTSKnown){if(C){l.logger.log("discontinuity sliding from playlist, take drift into account");for(var S=x.fragments,A=0;A<S.length;A++)S[A].cc+=C}R?d(x,R,R.startPTS,R.endPTS,R.startDTS,R.endDTS):p(g,x),x.PTSKnown=g.PTSKnown}}t.mergeDetails=h;function y(g,x,C){C===void 0&&(C=0);var R=-1;E(g,x,function(T,w,P){w.start=T.start,R=P});var S=x.fragments;if(R<0){S.forEach(function(T){T.start+=C});return}for(var A=R+1;A<S.length;A++)S[A].start=S[A-1].start+S[A-1].duration}t.mergeSubtitlePlaylists=y;function E(g,x,C){if(!(!g||!x))for(var R=Math.max(g.startSN,x.startSN)-x.startSN,S=Math.min(g.endSN,x.endSN)-x.startSN,A=x.startSN-g.startSN,T=R;T<=S;T++){var w=g.fragments[A+T],P=x.fragments[T];if(!w||!P)break;C(w,P,T)}}t.mapFragmentIntersection=E;function p(g,x){var C=x.startSN-g.startSN,R=g.fragments,S=x.fragments;if(!(C<0||C>R.length))for(var A=0;A<S.length;A++)S[A].start+=R[C].start}t.adjustSliding=p;function _(g,x,C){var R=1e3*(x.averagetargetduration?x.averagetargetduration:x.targetduration),S=R/2;return g&&x.endSN===g.endSN&&(R=S),C&&(R=Math.max(S,R-(window.performance.now()-C))),Math.round(R)}t.computeReloadInterval=_}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/stream-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(k,D){k.__proto__=D}||function(k,D){for(var F in D)D.hasOwnProperty(F)&&(k[F]=D[F])};return function(k,D){O(k,D);function F(){this.constructor=k}k.prototype=D===null?Object.create(D):(F.prototype=D.prototype,new F)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/utils/binary-search.js"),f=n("./src/utils/buffer-helper.js"),d=n("./src/demux/demuxer.js"),h=n("./src/events.js"),y=n("./src/controller/fragment-tracker.js"),E=n("./src/loader/fragment.js"),p=n("./src/loader/playlist-loader.js"),_=n("./src/controller/level-helper.js"),g=n("./src/utils/time-ranges.js"),x=n("./src/errors.js"),C=n("./src/utils/logger.js"),R=n("./src/utils/discontinuities.js"),S=n("./src/controller/fragment-finders.js"),A=n("./src/controller/gap-controller.js"),T=n("./src/controller/base-stream-controller.js"),w=100,P=function(O){l(k,O);function k(D,F){var G=O.call(this,D,h.default.MEDIA_ATTACHED,h.default.MEDIA_DETACHING,h.default.MANIFEST_LOADING,h.default.MANIFEST_PARSED,h.default.LEVEL_LOADED,h.default.KEY_LOADED,h.default.FRAG_LOADED,h.default.FRAG_LOAD_EMERGENCY_ABORTED,h.default.FRAG_PARSING_INIT_SEGMENT,h.default.FRAG_PARSING_DATA,h.default.FRAG_PARSED,h.default.ERROR,h.default.AUDIO_TRACK_SWITCHING,h.default.AUDIO_TRACK_SWITCHED,h.default.BUFFER_CREATED,h.default.BUFFER_APPENDED,h.default.BUFFER_FLUSHED)||this;return G.fragmentTracker=F,G.config=D.config,G.audioCodecSwap=!1,G._state=T.State.STOPPED,G.stallReported=!1,G.gapController=null,G}return k.prototype.startLoad=function(D){if(this.levels){var F=this.lastCurrentTime,G=this.hls;if(this.stopLoad(),this.setInterval(w),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var V=G.startLevel;V===-1&&(V=0,this.bitrateTest=!0),this.level=G.nextLoadLevel=V,this.loadedmetadata=!1}F>0&&D===-1&&(C.logger.log("override startPosition with lastCurrentTime @"+F.toFixed(3)),D=F),this.state=T.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=D,this.tick()}else this.forceStartLoad=!0,this.state=T.State.STOPPED},k.prototype.stopLoad=function(){this.forceStartLoad=!1,O.prototype.stopLoad.call(this)},k.prototype.doTick=function(){switch(this.state){case T.State.BUFFER_FLUSHING:this.fragLoadError=0;break;case T.State.IDLE:this._doTickIdle();break;case T.State.WAITING_LEVEL:var D=this.levels[this.level];D&&D.details&&(this.state=T.State.IDLE);break;case T.State.FRAG_LOADING_WAITING_RETRY:var F=window.performance.now(),G=this.retryDate;(!G||F>=G||this.media&&this.media.seeking)&&(C.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=T.State.IDLE);break;case T.State.ERROR:case T.State.STOPPED:case T.State.FRAG_LOADING:case T.State.PARSING:case T.State.PARSED:case T.State.ENDED:break}this._checkBuffer(),this._checkFragmentChanged()},k.prototype._doTickIdle=function(){var D=this.hls,F=D.config,G=this.media;if(!(this.levelLastLoaded===void 0||!G&&(this.startFragRequested||!F.startFragPrefetch))){var V;this.loadedmetadata?V=G.currentTime:V=this.nextLoadPosition;var W=D.nextLoadLevel,ee=this.levels[W];if(ee){var q=ee.bitrate,z;q?z=Math.max(8*F.maxBufferSize/q,F.maxBufferLength):z=F.maxBufferLength,z=Math.min(z,F.maxMaxBufferLength);var U=f.BufferHelper.bufferInfo(this.mediaBuffer?this.mediaBuffer:G,V,F.maxBufferHole),$=U.len;if(!($>=z)){C.logger.trace("buffer length of "+$.toFixed(3)+" is below max of "+z.toFixed(3)+". checking for more payload ..."),this.level=D.nextLoadLevel=W;var I=ee.details;if(!I||I.live&&this.levelLastLoaded!==W){this.state=T.State.WAITING_LEVEL;return}if(this._streamEnded(U,I)){var B={};this.altAudio&&(B.type="video"),this.hls.trigger(h.default.BUFFER_EOS,B),this.state=T.State.ENDED;return}this._fetchPayloadOrEos(V,U,I)}}}},k.prototype._fetchPayloadOrEos=function(D,F,G){var V=this.fragPrevious,W=this.level,ee=G.fragments,q=ee.length;if(q!==0){var z=ee[0].start,U=ee[q-1].start+ee[q-1].duration,$=F.end,I;if(G.initSegment&&!G.initSegment.data)I=G.initSegment;else if(G.live){var B=this.config.initialLiveManifestSize;if(q<B){C.logger.warn("Can not start playback of a level, reason: not enough fragments "+q+" < "+B);return}if(I=this._ensureFragmentAtLivePoint(G,$,z,U,V,ee,q),I===null)return}else $<z&&(I=ee[0]);I||(I=this._findFragment(z,V,q,ee,$,U,G)),I&&(I.encrypted?(C.logger.log("Loading key for "+I.sn+" of ["+G.startSN+" ,"+G.endSN+"],level "+W),this._loadKey(I)):(C.logger.log("Loading "+I.sn+" of ["+G.startSN+" ,"+G.endSN+"],level "+W+", currentTime:"+D.toFixed(3)+",bufferEnd:"+$.toFixed(3)),this._loadFragment(I)))}},k.prototype._ensureFragmentAtLivePoint=function(D,F,G,V,W,ee,q){var z=this.hls.config,U=this.media,$,I=z.liveMaxLatencyDuration!==void 0?z.liveMaxLatencyDuration:z.liveMaxLatencyDurationCount*D.targetduration;if(F<Math.max(G-z.maxFragLookUpTolerance,V-I)){var B=this.liveSyncPosition=this.computeLivePosition(G,D);C.logger.log("buffer end: "+F.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+B.toFixed(3)),F=B,U&&U.readyState&&U.duration>B&&(U.currentTime=B),this.nextLoadPosition=B}if(D.PTSKnown&&F>V&&U&&U.readyState)return null;if(this.startFragRequested&&!D.PTSKnown){if(W)if(D.hasProgramDateTime)C.logger.log("live playlist, switching playlist, load frag with same PDT: "+W.programDateTime),$=S.findFragmentByPDT(ee,W.endProgramDateTime,z.maxFragLookUpTolerance);else{var X=W.sn+1;if(X>=D.startSN&&X<=D.endSN){var Q=ee[X-D.startSN];W.cc===Q.cc&&($=Q,C.logger.log("live playlist, switching playlist, load frag with next SN: "+$.sn))}$||($=u.default.search(ee,function(J){return W.cc-J.cc}),$&&C.logger.log("live playlist, switching playlist, load frag with same CC: "+$.sn))}$||($=ee[Math.min(q-1,Math.round(q/2))],C.logger.log("live playlist, switching playlist, unknown, load middle frag : "+$.sn))}return $},k.prototype._findFragment=function(D,F,G,V,W,ee,q){var z=this.hls.config,U;if(W<ee){var $=W>ee-z.maxFragLookUpTolerance?0:z.maxFragLookUpTolerance;U=S.findFragmentByPTS(F,V,W,$)}else U=V[G-1];if(U){var I=U.sn-q.startSN,B=F&&U.level===F.level,X=V[I-1],Q=V[I+1];if(F&&U.sn===F.sn)if(B&&!U.backtracked)if(U.sn<q.endSN){var J=F.deltaPTS;J&&J>z.maxBufferHole&&F.dropped&&I?(U=X,C.logger.warn("SN just loaded, with large PTS gap between audio and video, maybe frag is not starting with a keyframe ? load previous one to try to overcome this")):(U=Q,C.logger.log("SN just loaded, load next one: "+U.sn,U))}else U=null;else U.backtracked&&(Q&&Q.backtracked?(C.logger.warn("Already backtracked from fragment "+Q.sn+", will not backtrack to fragment "+U.sn+". Loading fragment "+Q.sn),U=Q):(C.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),U.dropped=0,X?(U=X,U.backtracked=!0):I&&(U=null)))}return U},k.prototype._loadKey=function(D){this.state=T.State.KEY_LOADING,this.hls.trigger(h.default.KEY_LOADING,{frag:D})},k.prototype._loadFragment=function(D){var F=this.fragmentTracker.getState(D);this.fragCurrent=D,this.startFragRequested=!0,a.isFinite(D.sn)&&!D.bitrateTest&&(this.nextLoadPosition=D.start+D.duration),D.backtracked||F===y.FragmentState.NOT_LOADED||F===y.FragmentState.PARTIAL?(D.autoLevel=this.hls.autoLevelEnabled,D.bitrateTest=this.bitrateTest,this.hls.trigger(h.default.FRAG_LOADING,{frag:D}),this.demuxer||(this.demuxer=new d.default(this.hls,"main")),this.state=T.State.FRAG_LOADING):F===y.FragmentState.APPENDING&&this._reduceMaxBufferLength(D.duration)&&this.fragmentTracker.removeFragment(D)},Object.defineProperty(k.prototype,"state",{get:function(){return this._state},set:function(D){if(this.state!==D){var F=this.state;this._state=D,C.logger.log("main stream:"+F+"->"+D),this.hls.trigger(h.default.STREAM_STATE_TRANSITION,{previousState:F,nextState:D})}},enumerable:!0,configurable:!0}),k.prototype.getBufferedFrag=function(D){return this.fragmentTracker.getBufferedFrag(D,p.default.LevelType.MAIN)},Object.defineProperty(k.prototype,"currentLevel",{get:function(){var D=this.media;if(D){var F=this.getBufferedFrag(D.currentTime);if(F)return F.level}return-1},enumerable:!0,configurable:!0}),Object.defineProperty(k.prototype,"nextBufferedFrag",{get:function(){var D=this.media;return D?this.followingBufferedFrag(this.getBufferedFrag(D.currentTime)):null},enumerable:!0,configurable:!0}),k.prototype.followingBufferedFrag=function(D){return D?this.getBufferedFrag(D.endPTS+.5):null},Object.defineProperty(k.prototype,"nextLevel",{get:function(){var D=this.nextBufferedFrag;return D?D.level:-1},enumerable:!0,configurable:!0}),k.prototype._checkFragmentChanged=function(){var D,F,G=this.media;if(G&&G.readyState&&G.seeking===!1&&(F=G.currentTime,F>this.lastCurrentTime&&(this.lastCurrentTime=F),f.BufferHelper.isBuffered(G,F)?D=this.getBufferedFrag(F):f.BufferHelper.isBuffered(G,F+.1)&&(D=this.getBufferedFrag(F+.1)),D)){var V=D;if(V!==this.fragPlaying){this.hls.trigger(h.default.FRAG_CHANGED,{frag:V});var W=V.level;(!this.fragPlaying||this.fragPlaying.level!==W)&&this.hls.trigger(h.default.LEVEL_SWITCHED,{level:W}),this.fragPlaying=V}}},k.prototype.immediateLevelSwitch=function(){if(C.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var D=this.media,F=void 0;D?(F=D.paused,D.pause()):F=!0,this.previouslyPaused=F}var G=this.fragCurrent;G&&G.loader&&G.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,a.POSITIVE_INFINITY)},k.prototype.immediateLevelSwitchEnd=function(){var D=this.media;D&&D.buffered.length&&(this.immediateSwitch=!1,f.BufferHelper.isBuffered(D,D.currentTime)&&(D.currentTime-=1e-4),this.previouslyPaused||D.play())},k.prototype.nextLevelSwitch=function(){var D=this.media;if(D&&D.readyState){var F=void 0,G=void 0,V=void 0;if(G=this.getBufferedFrag(D.currentTime),G&&G.startPTS>1&&this.flushMainBuffer(0,G.startPTS-1),D.paused)F=0;else{var W=this.hls.nextLoadLevel,ee=this.levels[W],q=this.fragLastKbps;q&&this.fragCurrent?F=this.fragCurrent.duration*ee.bitrate/(1e3*q)+1:F=0}if(V=this.getBufferedFrag(D.currentTime+F),V&&(V=this.followingBufferedFrag(V),V)){var z=this.fragCurrent;z&&z.loader&&z.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(V.maxStartPTS,a.POSITIVE_INFINITY)}}},k.prototype.flushMainBuffer=function(D,F){this.state=T.State.BUFFER_FLUSHING;var G={startOffset:D,endOffset:F};this.altAudio&&(G.type="video"),this.hls.trigger(h.default.BUFFER_FLUSHING,G)},k.prototype.onMediaAttached=function(D){var F=this.media=this.mediaBuffer=D.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),F.addEventListener("seeking",this.onvseeking),F.addEventListener("seeked",this.onvseeked),F.addEventListener("ended",this.onvended);var G=this.config;this.levels&&G.autoStartLoad&&this.hls.startLoad(G.startPosition),this.gapController=new A.default(G,F,this.fragmentTracker,this.hls)},k.prototype.onMediaDetaching=function(){var D=this.media;D&&D.ended&&(C.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var F=this.levels;F&&F.forEach(function(G){G.details&&G.details.fragments.forEach(function(V){V.backtracked=void 0})}),D&&(D.removeEventListener("seeking",this.onvseeking),D.removeEventListener("seeked",this.onvseeked),D.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},k.prototype.onMediaSeeked=function(){var D=this.media,F=D?D.currentTime:void 0;a.isFinite(F)&&C.logger.log("media seeked to "+F.toFixed(3)),this.tick()},k.prototype.onManifestLoading=function(){C.logger.log("trigger BUFFER_RESET"),this.hls.trigger(h.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},k.prototype.onManifestParsed=function(D){var F=!1,G=!1,V;D.levels.forEach(function(ee){V=ee.audioCodec,V&&(V.indexOf("mp4a.40.2")!==-1&&(F=!0),V.indexOf("mp4a.40.5")!==-1&&(G=!0))}),this.audioCodecSwitch=F&&G,this.audioCodecSwitch&&C.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=D.levels,this.startFragRequested=!1;var W=this.config;(W.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(W.startPosition)},k.prototype.onLevelLoaded=function(D){var F=D.details,G=D.level,V=this.levels[this.levelLastLoaded],W=this.levels[G],ee=F.totalduration,q=0;if(C.logger.log("level "+G+" loaded ["+F.startSN+","+F.endSN+"],duration:"+ee),F.live){var z=W.details;z&&F.fragments.length>0?(_.mergeDetails(z,F),q=F.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(q,z),F.PTSKnown&&a.isFinite(q)?C.logger.log("live playlist sliding:"+q.toFixed(3)):(C.logger.log("live playlist - outdated PTS, unknown sliding"),R.alignStream(this.fragPrevious,V,F))):(C.logger.log("live playlist - first load, unknown sliding"),F.PTSKnown=!1,R.alignStream(this.fragPrevious,V,F))}else F.PTSKnown=!1;if(W.details=F,this.levelLastLoaded=G,this.hls.trigger(h.default.LEVEL_UPDATED,{details:F,level:G}),this.startFragRequested===!1){if(this.startPosition===-1||this.lastCurrentTime===-1){var U=F.startTimeOffset;a.isFinite(U)?(U<0&&(C.logger.log("negative start time offset "+U+", count from end of last fragment"),U=q+ee+U),C.logger.log("start time offset found in playlist, adjust startPosition to "+U),this.startPosition=U):F.live?(this.startPosition=this.computeLivePosition(q,F),C.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===T.State.WAITING_LEVEL&&(this.state=T.State.IDLE),this.tick()},k.prototype.onKeyLoaded=function(){this.state===T.State.KEY_LOADING&&(this.state=T.State.IDLE,this.tick())},k.prototype.onFragLoaded=function(D){var F=this,G=F.fragCurrent,V=F.hls,W=F.levels,ee=F.media,q=D.frag;if(this.state===T.State.FRAG_LOADING&&G&&q.type==="main"&&q.level===G.level&&q.sn===G.sn){var z=D.stats,U=W[G.level],$=U.details;if(this.bitrateTest=!1,this.stats=z,C.logger.log("Loaded "+G.sn+" of ["+$.startSN+" ,"+$.endSN+"],level "+G.level),q.bitrateTest&&V.nextLoadLevel)this.state=T.State.IDLE,this.startFragRequested=!1,z.tparsed=z.tbuffered=window.performance.now(),V.trigger(h.default.FRAG_BUFFERED,{stats:z,frag:G,id:"main"}),this.tick();else if(q.sn==="initSegment")this.state=T.State.IDLE,z.tparsed=z.tbuffered=window.performance.now(),$.initSegment.data=D.payload,V.trigger(h.default.FRAG_BUFFERED,{stats:z,frag:G,id:"main"}),this.tick();else{C.logger.log("Parsing "+G.sn+" of ["+$.startSN+" ,"+$.endSN+"],level "+G.level+", cc "+G.cc),this.state=T.State.PARSING,this.pendingBuffering=!0,this.appended=!1,q.bitrateTest&&(q.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:q}));var I=!(ee&&ee.seeking)&&($.PTSKnown||!$.live),B=$.initSegment?$.initSegment.data:[],X=this._getAudioCodec(U),Q=this.demuxer=this.demuxer||new d.default(this.hls,"main");Q.push(D.payload,B,X,U.videoCodec,G,$.totalduration,I)}}this.fragLoadError=0},k.prototype.onFragParsingInitSegment=function(D){var F=this.fragCurrent,G=D.frag;if(F&&D.id==="main"&&G.sn===F.sn&&G.level===F.level&&this.state===T.State.PARSING){var V=D.tracks,W=void 0,ee=void 0;if(V.audio&&this.altAudio&&delete V.audio,ee=V.audio,ee){var q=this.levels[this.level].audioCodec,z=navigator.userAgent.toLowerCase();q&&this.audioCodecSwap&&(C.logger.log("swapping playlist audio codec"),q.indexOf("mp4a.40.5")!==-1?q="mp4a.40.2":q="mp4a.40.5"),this.audioCodecSwitch&&ee.metadata.channelCount!==1&&z.indexOf("firefox")===-1&&(q="mp4a.40.5"),z.indexOf("android")!==-1&&ee.container!=="audio/mpeg"&&(q="mp4a.40.2",C.logger.log("Android: force audio codec to "+q)),ee.levelCodec=q,ee.id=D.id}ee=V.video,ee&&(ee.levelCodec=this.levels[this.level].videoCodec,ee.id=D.id),this.hls.trigger(h.default.BUFFER_CODECS,V);for(W in V){ee=V[W],C.logger.log("main track:"+W+",container:"+ee.container+",codecs[level/parsed]=["+ee.levelCodec+"/"+ee.codec+"]");var U=ee.initSegment;U&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(h.default.BUFFER_APPENDING,{type:W,data:U,parent:"main",content:"initSegment"}))}this.tick()}},k.prototype.onFragParsingData=function(D){var F=this,G=this.fragCurrent,V=D.frag;if(G&&D.id==="main"&&V.sn===G.sn&&V.level===G.level&&!(D.type==="audio"&&this.altAudio)&&this.state===T.State.PARSING){var W=this.levels[this.level],ee=G;if(a.isFinite(D.endPTS)||(D.endPTS=D.startPTS+G.duration,D.endDTS=D.startDTS+G.duration),D.hasAudio===!0&&ee.addElementaryStream(E.default.ElementaryStreamTypes.AUDIO),D.hasVideo===!0&&ee.addElementaryStream(E.default.ElementaryStreamTypes.VIDEO),C.logger.log("Parsed "+D.type+",PTS:["+D.startPTS.toFixed(3)+","+D.endPTS.toFixed(3)+"],DTS:["+D.startDTS.toFixed(3)+"/"+D.endDTS.toFixed(3)+"],nb:"+D.nb+",dropped:"+(D.dropped||0)),D.type==="video")if(ee.dropped=D.dropped,ee.dropped)if(ee.backtracked)C.logger.warn("Already backtracked on this fragment, appending with the gap",ee.sn);else{var q=W.details;if(q&&ee.sn===q.startSN)C.logger.warn("missing video frame(s) on first frag, appending with gap",ee.sn);else{C.logger.warn("missing video frame(s), backtracking fragment",ee.sn),this.fragmentTracker.removeFragment(ee),ee.backtracked=!0,this.nextLoadPosition=D.startPTS,this.state=T.State.IDLE,this.fragPrevious=ee,this.tick();return}}else ee.backtracked=!1;var z=_.updateFragPTSDTS(W.details,ee,D.startPTS,D.endPTS,D.startDTS,D.endDTS),U=this.hls;U.trigger(h.default.LEVEL_PTS_UPDATED,{details:W.details,level:this.level,drift:z,type:D.type,start:D.startPTS,end:D.endPTS}),[D.data1,D.data2].forEach(function($){$&&$.length&&F.state===T.State.PARSING&&(F.appended=!0,F.pendingBuffering=!0,U.trigger(h.default.BUFFER_APPENDING,{type:D.type,data:$,parent:"main",content:"data"}))}),this.tick()}},k.prototype.onFragParsed=function(D){var F=this.fragCurrent,G=D.frag;F&&D.id==="main"&&G.sn===F.sn&&G.level===F.level&&this.state===T.State.PARSING&&(this.stats.tparsed=window.performance.now(),this.state=T.State.PARSED,this._checkAppendedParsed())},k.prototype.onAudioTrackSwitching=function(D){var F=!!D.url,G=D.id;if(!F){if(this.mediaBuffer!==this.media){C.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var V=this.fragCurrent;V.loader&&(C.logger.log("switching to main audio track, cancel main fragment load"),V.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=T.State.IDLE}var W=this.hls;W.trigger(h.default.BUFFER_FLUSHING,{startOffset:0,endOffset:a.POSITIVE_INFINITY,type:"audio"}),W.trigger(h.default.AUDIO_TRACK_SWITCHED,{id:G}),this.altAudio=!1}},k.prototype.onAudioTrackSwitched=function(D){var F=D.id,G=!!this.hls.audioTracks[F].url;if(G){var V=this.videoBuffer;V&&this.mediaBuffer!==V&&(C.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=V)}this.altAudio=G,this.tick()},k.prototype.onBufferCreated=function(D){var F=D.tracks,G,V,W=!1;for(var ee in F){var q=F[ee];q.id==="main"?(V=ee,G=q,ee==="video"&&(this.videoBuffer=F[ee].buffer)):W=!0}W&&G?(C.logger.log("alternate track found, use "+V+".buffered to schedule main fragment loading"),this.mediaBuffer=G.buffer):this.mediaBuffer=this.media},k.prototype.onBufferAppended=function(D){if(D.parent==="main"){var F=this.state;(F===T.State.PARSING||F===T.State.PARSED)&&(this.pendingBuffering=D.pending>0,this._checkAppendedParsed())}},k.prototype._checkAppendedParsed=function(){if(this.state===T.State.PARSED&&(!this.appended||!this.pendingBuffering)){var D=this.fragCurrent;if(D){var F=this.mediaBuffer?this.mediaBuffer:this.media;C.logger.log("main buffered : "+g.default.toString(F.buffered)),this.fragPrevious=D;var G=this.stats;G.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*G.total/(G.tbuffered-G.tfirst)),this.hls.trigger(h.default.FRAG_BUFFERED,{stats:G,frag:D,id:"main"}),this.state=T.State.IDLE}this.tick()}},k.prototype.onError=function(D){var F=D.frag||this.fragCurrent;if(!(F&&F.type!=="main")){var G=!!this.media&&f.BufferHelper.isBuffered(this.media,this.media.currentTime)&&f.BufferHelper.isBuffered(this.media,this.media.currentTime+.5);switch(D.details){case x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:case x.ErrorDetails.KEY_LOAD_ERROR:case x.ErrorDetails.KEY_LOAD_TIMEOUT:if(!D.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var V=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);C.logger.warn("mediaController: frag loading failed, retry in "+V+" ms"),this.retryDate=window.performance.now()+V,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=T.State.FRAG_LOADING_WAITING_RETRY}else C.logger.error("mediaController: "+D.details+" reaches max retry, redispatch as fatal ..."),D.fatal=!0,this.state=T.State.ERROR;break;case x.ErrorDetails.LEVEL_LOAD_ERROR:case x.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==T.State.ERROR&&(D.fatal?(this.state=T.State.ERROR,C.logger.warn("streamController: "+D.details+",switch to "+this.state+" state ...")):!D.levelRetry&&this.state===T.State.WAITING_LEVEL&&(this.state=T.State.IDLE));break;case x.ErrorDetails.BUFFER_FULL_ERROR:D.parent==="main"&&(this.state===T.State.PARSING||this.state===T.State.PARSED)&&(G?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=T.State.IDLE):(C.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,a.POSITIVE_INFINITY)));break}}},k.prototype._reduceMaxBufferLength=function(D){var F=this.config;return F.maxMaxBufferLength>=D?(F.maxMaxBufferLength/=2,C.logger.warn("main:reduce max buffer length to "+F.maxMaxBufferLength+"s"),!0):!1},k.prototype._checkBuffer=function(){var D=this.media;if(!(!D||D.readyState===0)){var F=this.mediaBuffer?this.mediaBuffer:D,G=F.buffered;!this.loadedmetadata&&G.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,G)}},k.prototype.onFragLoadEmergencyAborted=function(){this.state=T.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},k.prototype.onBufferFlushed=function(){var D=this.mediaBuffer?this.mediaBuffer:this.media;D&&this.fragmentTracker.detectEvictedFragments(E.default.ElementaryStreamTypes.VIDEO,D.buffered),this.state=T.State.IDLE,this.fragPrevious=null},k.prototype.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},k.prototype.computeLivePosition=function(D,F){var G=this.config.liveSyncDuration!==void 0?this.config.liveSyncDuration:this.config.liveSyncDurationCount*F.targetduration;return D+Math.max(0,F.totalduration-G)},k.prototype._seekToStartPos=function(){var D=this.media,F=D.currentTime,G=D.seeking?F:this.startPosition;F!==G&&(C.logger.log("target start position not buffered, seek to buffered.start(0) "+G+" from current time "+F+" "),D.currentTime=G)},k.prototype._getAudioCodec=function(D){var F=this.config.defaultAudioCodec||D.audioCodec;return this.audioCodecSwap&&(C.logger.log("swapping playlist audio codec"),F&&(F.indexOf("mp4a.40.5")!==-1?F="mp4a.40.2":F="mp4a.40.5")),F},Object.defineProperty(k.prototype,"liveSyncPosition",{get:function(){return this._liveSyncPosition},set:function(D){this._liveSyncPosition=D},enumerable:!0,configurable:!0}),k}(T.default);t.default=P}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/subtitle-stream-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(R,S){R.__proto__=S}||function(R,S){for(var A in S)S.hasOwnProperty(A)&&(R[A]=S[A])};return function(R,S){C(R,S);function A(){this.constructor=R}R.prototype=S===null?Object.create(S):(A.prototype=S.prototype,new A)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/utils/logger.js"),f=n("./src/crypt/decrypter.js"),d=n("./src/utils/buffer-helper.js"),h=n("./src/controller/fragment-finders.js"),y=n("./src/controller/fragment-tracker.js"),E=n("./src/controller/base-stream-controller.js"),p=n("./src/controller/level-helper.js"),_=window.performance,g=500,x=function(C){a(R,C);function R(S,A){var T=C.call(this,S,l.default.MEDIA_ATTACHED,l.default.MEDIA_DETACHING,l.default.ERROR,l.default.KEY_LOADED,l.default.FRAG_LOADED,l.default.SUBTITLE_TRACKS_UPDATED,l.default.SUBTITLE_TRACK_SWITCH,l.default.SUBTITLE_TRACK_LOADED,l.default.SUBTITLE_FRAG_PROCESSED,l.default.LEVEL_UPDATED)||this;return T.fragmentTracker=A,T.config=S.config,T.state=E.State.STOPPED,T.tracks=[],T.tracksBuffered=[],T.currentTrackId=-1,T.decrypter=new f.default(S,S.config),T.lastAVStart=0,T._onMediaSeeking=T.onMediaSeeking.bind(T),T}return R.prototype.onSubtitleFragProcessed=function(S){var A=S.frag,T=S.success;if(this.fragPrevious=A,this.state=E.State.IDLE,!!T){var w=this.tracksBuffered[this.currentTrackId];if(w){for(var P,O=A.start,k=0;k<w.length;k++)if(O>=w[k].start&&O<=w[k].end){P=w[k];break}var D=A.start+A.duration;P?P.end=D:(P={start:O,end:D},w.push(P))}}},R.prototype.onMediaAttached=function(S){var A=S.media;this.media=A,A.addEventListener("seeking",this._onMediaSeeking),this.state=E.State.IDLE},R.prototype.onMediaDetaching=function(){this.media.removeEventListener("seeking",this._onMediaSeeking),this.media=null,this.state=E.State.STOPPED},R.prototype.onError=function(S){var A=S.frag;!A||A.type!=="subtitle"||(this.state=E.State.IDLE)},R.prototype.onSubtitleTracksUpdated=function(S){var A=this;u.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=S.subtitleTracks,this.tracks.forEach(function(T){A.tracksBuffered[T.id]=[]})},R.prototype.onSubtitleTrackSwitch=function(S){if(this.currentTrackId=S.id,!this.tracks||this.currentTrackId===-1){this.clearInterval();return}var A=this.tracks[this.currentTrackId];A&&A.details&&this.setInterval(g)},R.prototype.onSubtitleTrackLoaded=function(S){var A=S.id,T=S.details,w=this,P=w.currentTrackId,O=w.tracks,k=O[P];A>=O.length||A!==P||!k||(T.live&&p.mergeSubtitlePlaylists(k.details,T,this.lastAVStart),k.details=T,this.setInterval(g))},R.prototype.onKeyLoaded=function(){this.state===E.State.KEY_LOADING&&(this.state=E.State.IDLE)},R.prototype.onFragLoaded=function(S){var A=this.fragCurrent,T=S.frag.decryptdata,w=S.frag,P=this.hls;if(this.state===E.State.FRAG_LOADING&&A&&S.frag.type==="subtitle"&&A.sn===S.frag.sn&&S.payload.byteLength>0&&T&&T.key&&T.method==="AES-128"){var O=_.now();this.decrypter.decrypt(S.payload,T.key.buffer,T.iv.buffer,function(k){var D=_.now();P.trigger(l.default.FRAG_DECRYPTED,{frag:w,payload:k,stats:{tstart:O,tdecrypt:D}})})}},R.prototype.onLevelUpdated=function(S){var A=S.details,T=A.fragments;this.lastAVStart=T.length?T[0].start:0},R.prototype.doTick=function(){if(!this.media){this.state=E.State.IDLE;return}switch(this.state){case E.State.IDLE:{var S=this,A=S.config,T=S.currentTrackId,w=S.fragmentTracker,P=S.media,O=S.tracks;if(!O||!O[T]||!O[T].details)break;var k=A.maxBufferHole,D=A.maxFragLookUpTolerance,F=Math.min(A.maxBufferLength,A.maxMaxBufferLength),G=d.BufferHelper.bufferedInfo(this._getBuffered(),P.currentTime,k),V=G.end,W=G.len,ee=O[T].details,q=ee.fragments,z=q.length,U=q[z-1].start+q[z-1].duration;if(W>F)return;var $=void 0,I=this.fragPrevious;V<U?(I&&ee.hasProgramDateTime&&($=h.findFragmentByPDT(q,I.endProgramDateTime,D)),$||($=h.findFragmentByPTS(I,q,V,D))):$=q[z-1],$&&$.encrypted?(u.logger.log("Loading key for "+$.sn),this.state=E.State.KEY_LOADING,this.hls.trigger(l.default.KEY_LOADING,{frag:$})):$&&w.getState($)===y.FragmentState.NOT_LOADED&&(this.fragCurrent=$,this.state=E.State.FRAG_LOADING,this.hls.trigger(l.default.FRAG_LOADING,{frag:$}))}}},R.prototype.stopLoad=function(){this.lastAVStart=0,C.prototype.stopLoad.call(this)},R.prototype._getBuffered=function(){return this.tracksBuffered[this.currentTrackId]||[]},R.prototype.onMediaSeeking=function(){this.fragPrevious=null},R}(E.default);t.SubtitleStreamController=x},"./src/controller/subtitle-track-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,g){_.__proto__=g}||function(_,g){for(var x in g)g.hasOwnProperty(x)&&(_[x]=g[x])};return function(_,g){p(_,g);function x(){this.constructor=_}_.prototype=g===null?Object.create(g):(x.prototype=g.prototype,new x)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/utils/logger.js"),h=n("./src/controller/level-helper.js"),y=function(p){l(_,p);function _(g){var x=p.call(this,g,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.MANIFEST_LOADED,u.default.SUBTITLE_TRACK_LOADED)||this;return x.tracks=[],x.trackId=-1,x.media=null,x.stopped=!0,x.subtitleDisplay=!0,x}return _.prototype.destroy=function(){f.default.prototype.destroy.call(this)},_.prototype.onMediaAttached=function(g){var x=this;this.media=g.media,this.media&&(this.queuedDefaultTrack&&(this.subtitleTrack=this.queuedDefaultTrack,delete this.queuedDefaultTrack),this.trackChangeListener=this._onTextTracksChanged.bind(this),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.subtitlePollingInterval=setInterval(function(){x.trackChangeListener()},500):this.media.textTracks.addEventListener("change",this.trackChangeListener))},_.prototype.onMediaDetaching=function(){this.media&&(this.useTextTrackPolling?clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),this.media=null)},_.prototype.onManifestLoaded=function(g){var x=this,C=g.subtitles||[];this.tracks=C,this.hls.trigger(u.default.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:C}),C.forEach(function(R){R.default&&(x.media?x.subtitleTrack=R.id:x.queuedDefaultTrack=R.id)})},_.prototype.onSubtitleTrackLoaded=function(g){var x=this,C=g.id,R=g.details,S=this,A=S.trackId,T=S.tracks,w=T[A];if(C>=T.length||C!==A||!w||this.stopped){this._clearReloadTimer();return}if(d.logger.log("subtitle track "+C+" loaded"),R.live){var P=h.computeReloadInterval(w.details,R,g.stats.trequest);d.logger.log("Reloading live subtitle playlist in "+P+"ms"),this.timer=setTimeout(function(){x._loadCurrentTrack()},P)}else this._clearReloadTimer()},_.prototype.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},_.prototype.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},Object.defineProperty(_.prototype,"subtitleTracks",{get:function(){return this.tracks},enumerable:!0,configurable:!0}),Object.defineProperty(_.prototype,"subtitleTrack",{get:function(){return this.trackId},set:function(g){this.trackId!==g&&(this._toggleTrackModes(g),this._setSubtitleTrackInternal(g))},enumerable:!0,configurable:!0}),_.prototype._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},_.prototype._loadCurrentTrack=function(){var g=this,x=g.trackId,C=g.tracks,R=g.hls,S=C[x];x<0||!S||S.details&&!S.details.live||(d.logger.log("Loading subtitle track "+x),R.trigger(u.default.SUBTITLE_TRACK_LOADING,{url:S.url,id:x}))},_.prototype._toggleTrackModes=function(g){var x=this,C=x.media,R=x.subtitleDisplay,S=x.trackId;if(C){var A=E(C.textTracks);if(g===-1)[].slice.call(A).forEach(function(P){P.mode="disabled"});else{var T=A[S];T&&(T.mode="disabled")}var w=A[g];w&&(w.mode=R?"showing":"hidden")}},_.prototype._setSubtitleTrackInternal=function(g){var x=this,C=x.hls,R=x.tracks;!a.isFinite(g)||g<-1||g>=R.length||(this.trackId=g,d.logger.log("Switching to subtitle track "+g),C.trigger(u.default.SUBTITLE_TRACK_SWITCH,{id:g}),this._loadCurrentTrack())},_.prototype._onTextTracksChanged=function(){if(this.media){for(var g=-1,x=E(this.media.textTracks),C=0;C<x.length;C++)if(x[C].mode==="hidden")g=C;else if(x[C].mode==="showing"){g=C;break}this.subtitleTrack=g}},_}(f.default);function E(p){for(var _=[],g=0;g<p.length;g++){var x=p[g];x.kind==="subtitles"&&x.label&&_.push(p[g])}return _}t.default=y}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/timeline-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(R,S){R.__proto__=S}||function(R,S){for(var A in S)S.hasOwnProperty(A)&&(R[A]=S[A])};return function(R,S){C(R,S);function A(){this.constructor=R}R.prototype=S===null?Object.create(S):(A.prototype=S.prototype,new A)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/utils/cea-608-parser.js"),h=n("./src/utils/output-filter.js"),y=n("./src/utils/webvtt-parser.js"),E=n("./src/utils/logger.js"),p=n("./src/utils/texttrack-utils.js");function _(C,R){return C&&C.label===R.name&&!(C.textTrack1||C.textTrack2)}function g(C,R,S,A){return Math.min(R,A)-Math.max(C,S)}var x=function(C){l(R,C);function R(S){var A=C.call(this,S,u.default.MEDIA_ATTACHING,u.default.MEDIA_DETACHING,u.default.FRAG_PARSING_USERDATA,u.default.FRAG_DECRYPTED,u.default.MANIFEST_LOADING,u.default.MANIFEST_LOADED,u.default.FRAG_LOADED,u.default.LEVEL_SWITCHING,u.default.INIT_PTS_FOUND)||this;if(A.hls=S,A.config=S.config,A.enabled=!0,A.Cues=S.config.cueHandler,A.textTracks=[],A.tracks=[],A.unparsedVttFrags=[],A.initPTS=[],A.cueRanges=[],A.captionsTracks={},A.captionsProperties={textTrack1:{label:A.config.captionsTextTrack1Label,languageCode:A.config.captionsTextTrack1LanguageCode},textTrack2:{label:A.config.captionsTextTrack2Label,languageCode:A.config.captionsTextTrack2LanguageCode}},A.config.enableCEA708Captions){var T=new h.default(A,"textTrack1"),w=new h.default(A,"textTrack2");A.cea608Parser=new d.default(0,T,w)}return A}return R.prototype.addCues=function(S,A,T,w){for(var P=this.cueRanges,O=!1,k=P.length;k--;){var D=P[k],F=g(D[0],D[1],A,T);if(F>=0&&(D[0]=Math.min(D[0],A),D[1]=Math.max(D[1],T),O=!0,F/(T-A)>.5))return}O||P.push([A,T]),this.Cues.newCue(this.captionsTracks[S],A,T,w)},R.prototype.onInitPtsFound=function(S){var A=this;if(S.id==="main"&&(this.initPTS[S.frag.cc]=S.initPTS),this.unparsedVttFrags.length){var T=this.unparsedVttFrags;this.unparsedVttFrags=[],T.forEach(function(w){A.onFragLoaded(w)})}},R.prototype.getExistingTrack=function(S){var A=this.media;if(A)for(var T=0;T<A.textTracks.length;T++){var w=A.textTracks[T];if(w[S])return w}return null},R.prototype.createCaptionsTrack=function(S){var A=this.captionsProperties[S],T=A.label,w=A.languageCode,P=this.captionsTracks;if(!P[S]){var O=this.getExistingTrack(S);if(O)P[S]=O,p.clearCurrentCues(P[S]),p.sendAddTrackEvent(P[S],this.media);else{var k=this.createTextTrack("captions",T,w);k&&(k[S]=!0,P[S]=k)}}},R.prototype.createTextTrack=function(S,A,T){var w=this.media;if(w)return w.addTextTrack(S,A,T)},R.prototype.destroy=function(){f.default.prototype.destroy.call(this)},R.prototype.onMediaAttaching=function(S){this.media=S.media,this._cleanTracks()},R.prototype.onMediaDetaching=function(){var S=this.captionsTracks;Object.keys(S).forEach(function(A){p.clearCurrentCues(S[A]),delete S[A]})},R.prototype.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks()},R.prototype._cleanTracks=function(){var S=this.media;if(S){var A=S.textTracks;if(A)for(var T=0;T<A.length;T++)p.clearCurrentCues(A[T])}},R.prototype.onManifestLoaded=function(S){var A=this;if(this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cueRanges=[],this.config.enableWebVTT){this.tracks=S.subtitles||[];var T=this.media?this.media.textTracks:[];this.tracks.forEach(function(w,P){var O;if(P<T.length){for(var k=null,D=0;D<T.length;D++)if(_(T[D],w)){k=T[D];break}k&&(O=k)}O||(O=A.createTextTrack("subtitles",w.name,w.lang)),w.default?O.mode=A.hls.subtitleDisplay?"showing":"hidden":O.mode="disabled",A.textTracks.push(O)})}},R.prototype.onLevelSwitching=function(){this.enabled=this.hls.currentLevel.closedCaptions!=="NONE"},R.prototype.onFragLoaded=function(S){var A=S.frag,T=S.payload;if(A.type==="main"){var w=A.sn;if(w!==this.lastSn+1){var P=this.cea608Parser;P&&P.reset()}this.lastSn=w}else if(A.type==="subtitle")if(T.byteLength){if(!a.isFinite(this.initPTS[A.cc])){this.unparsedVttFrags.push(S),this.initPTS.length&&this.hls.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:A});return}var O=A.decryptdata;(O==null||O.key==null||O.method!=="AES-128")&&this._parseVTTs(A,T)}else this.hls.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:A})},R.prototype._parseVTTs=function(S,A){var T=this.vttCCs;T[S.cc]||(T[S.cc]={start:S.start,prevCC:this.prevCC,new:!0},this.prevCC=S.cc);var w=this.textTracks,P=this.hls;y.default.parse(A,this.initPTS[S.cc],T,S.cc,function(O){var k=w[S.level];if(k.mode==="disabled"){P.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:S});return}O.forEach(function(D){if(!k.cues.getCueById(D.id))try{k.addCue(D)}catch{var F=new window.TextTrackCue(D.startTime,D.endTime,D.text);F.id=D.id,k.addCue(F)}}),P.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:S})},function(O){E.logger.log("Failed to parse VTT cue: "+O),P.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:S})})},R.prototype.onFragDecrypted=function(S){var A=S.payload,T=S.frag;if(T.type==="subtitle"){if(!a.isFinite(this.initPTS[T.cc])){this.unparsedVttFrags.push(S);return}this._parseVTTs(T,A)}},R.prototype.onFragParsingUserdata=function(S){if(this.enabled&&this.config.enableCEA708Captions)for(var A=0;A<S.samples.length;A++){var T=this.extractCea608Data(S.samples[A].bytes);this.cea608Parser.addData(S.samples[A].pts,T)}},R.prototype.extractCea608Data=function(S){for(var A=S[0]&31,T=2,w,P,O,k,D,F=[],G=0;G<A;G++)w=S[T++],P=127&S[T++],O=127&S[T++],k=(4&w)!==0,D=3&w,!(P===0&&O===0)&&k&&D===0&&(F.push(P),F.push(O));return F},R}(f.default);t.default=x}).call(this,n("./src/polyfills/number.js").Number)},"./src/crypt/aes-crypto.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(u,f){this.subtle=u,this.aesIV=f}return l.prototype.decrypt=function(u,f){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},f,u)},l}();t.default=a},"./src/crypt/aes-decryptor.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});function a(u){var f=u.byteLength,d=f&&new DataView(u).getUint8(f-1);return d?u.slice(0,f-d):u}t.removePadding=a;var l=function(){function u(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.initTable()}return u.prototype.uint8ArrayToUint32Array_=function(f){for(var d=new DataView(f),h=new Uint32Array(4),y=0;y<4;y++)h[y]=d.getUint32(y*4);return h},u.prototype.initTable=function(){var f=this.sBox,d=this.invSBox,h=this.subMix,y=h[0],E=h[1],p=h[2],_=h[3],g=this.invSubMix,x=g[0],C=g[1],R=g[2],S=g[3],A=new Uint32Array(256),T=0,w=0,P=0;for(P=0;P<256;P++)P<128?A[P]=P<<1:A[P]=P<<1^283;for(P=0;P<256;P++){var O=w^w<<1^w<<2^w<<3^w<<4;O=O>>>8^O&255^99,f[T]=O,d[O]=T;var k=A[T],D=A[k],F=A[D],G=A[O]*257^O*16843008;y[T]=G<<24|G>>>8,E[T]=G<<16|G>>>16,p[T]=G<<8|G>>>24,_[T]=G,G=F*16843009^D*65537^k*257^T*16843008,x[O]=G<<24|G>>>8,C[O]=G<<16|G>>>16,R[O]=G<<8|G>>>24,S[O]=G,T?(T=k^A[A[A[F^k]]],w^=A[A[w]]):T=w=1}},u.prototype.expandKey=function(f){for(var d=this.uint8ArrayToUint32Array_(f),h=!0,y=0;y<d.length&&h;)h=d[y]===this.key[y],y++;if(!h){this.key=d;var E=this.keySize=d.length;if(E!==4&&E!==6&&E!==8)throw new Error("Invalid aes key size="+E);var p=this.ksRows=(E+6+1)*4,_,g,x=this.keySchedule=new Uint32Array(p),C=this.invKeySchedule=new Uint32Array(p),R=this.sBox,S=this.rcon,A=this.invSubMix,T=A[0],w=A[1],P=A[2],O=A[3],k,D;for(_=0;_<p;_++){if(_<E){k=x[_]=d[_];continue}D=k,_%E===0?(D=D<<8|D>>>24,D=R[D>>>24]<<24|R[D>>>16&255]<<16|R[D>>>8&255]<<8|R[D&255],D^=S[_/E|0]<<24):E>6&&_%E===4&&(D=R[D>>>24]<<24|R[D>>>16&255]<<16|R[D>>>8&255]<<8|R[D&255]),x[_]=k=(x[_-E]^D)>>>0}for(g=0;g<p;g++)_=p-g,g&3?D=x[_]:D=x[_-4],g<4||_<=4?C[g]=D:C[g]=T[R[D>>>24]]^w[R[D>>>16&255]]^P[R[D>>>8&255]]^O[R[D&255]],C[g]=C[g]>>>0}},u.prototype.networkToHostOrderSwap=function(f){return f<<24|(f&65280)<<8|(f&16711680)>>8|f>>>24},u.prototype.decrypt=function(f,d,h,y){for(var E=this.keySize+6,p=this.invKeySchedule,_=this.invSBox,g=this.invSubMix,x=g[0],C=g[1],R=g[2],S=g[3],A=this.uint8ArrayToUint32Array_(h),T=A[0],w=A[1],P=A[2],O=A[3],k=new Int32Array(f),D=new Int32Array(k.length),F,G,V,W,ee,q,z,U,$,I,B,X,Q,J,ne=this.networkToHostOrderSwap;d<k.length;){for($=ne(k[d]),I=ne(k[d+1]),B=ne(k[d+2]),X=ne(k[d+3]),ee=$^p[0],q=X^p[1],z=B^p[2],U=I^p[3],Q=4,J=1;J<E;J++)F=x[ee>>>24]^C[q>>16&255]^R[z>>8&255]^S[U&255]^p[Q],G=x[q>>>24]^C[z>>16&255]^R[U>>8&255]^S[ee&255]^p[Q+1],V=x[z>>>24]^C[U>>16&255]^R[ee>>8&255]^S[q&255]^p[Q+2],W=x[U>>>24]^C[ee>>16&255]^R[q>>8&255]^S[z&255]^p[Q+3],ee=F,q=G,z=V,U=W,Q=Q+4;F=_[ee>>>24]<<24^_[q>>16&255]<<16^_[z>>8&255]<<8^_[U&255]^p[Q],G=_[q>>>24]<<24^_[z>>16&255]<<16^_[U>>8&255]<<8^_[ee&255]^p[Q+1],V=_[z>>>24]<<24^_[U>>16&255]<<16^_[ee>>8&255]<<8^_[q&255]^p[Q+2],W=_[U>>>24]<<24^_[ee>>16&255]<<16^_[q>>8&255]<<8^_[z&255]^p[Q+3],Q=Q+3,D[d]=ne(F^T),D[d+1]=ne(W^w),D[d+2]=ne(V^P),D[d+3]=ne(G^O),T=$,w=I,P=B,O=X,d=d+4}return y?a(D.buffer):D.buffer},u.prototype.destroy=function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0},u}();t.default=l},"./src/crypt/decrypter.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/crypt/aes-crypto.js"),l=n("./src/crypt/fast-aes-key.js"),u=n("./src/crypt/aes-decryptor.js"),f=n("./src/errors.js"),d=n("./src/utils/logger.js"),h=n("./src/events.js"),y=n("./src/utils/get-self-scope.js"),E=y.getSelfScope(),p=function(){function _(g,x,C){var R=(C===void 0?{}:C).removePKCS7Padding,S=R===void 0?!0:R;if(this.logEnabled=!0,this.observer=g,this.config=x,this.removePKCS7Padding=S,S)try{var A=E.crypto;A&&(this.subtle=A.subtle||A.webkitSubtle)}catch{}this.disableWebCrypto=!this.subtle}return _.prototype.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},_.prototype.decrypt=function(g,x,C,R){var S=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(d.logger.log("JS AES decrypt"),this.logEnabled=!1);var A=this.decryptor;A||(this.decryptor=A=new u.default),A.expandKey(x),R(A.decrypt(g,0,C,this.removePKCS7Padding))}else{this.logEnabled&&(d.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1);var T=this.subtle;this.key!==x&&(this.key=x,this.fastAesKey=new l.default(T,x)),this.fastAesKey.expandKey().then(function(w){var P=new a.default(T,C);P.decrypt(g,w).catch(function(O){S.onWebCryptoError(O,g,x,C,R)}).then(function(O){R(O)})}).catch(function(w){S.onWebCryptoError(w,g,x,C,R)})}},_.prototype.onWebCryptoError=function(g,x,C,R,S){this.config.enableSoftwareAES?(d.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(x,C,R,S)):(d.logger.error("decrypting error : "+g.message),this.observer.trigger(h.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:g.message}))},_.prototype.destroy=function(){var g=this.decryptor;g&&(g.destroy(),this.decryptor=void 0)},_}();t.default=p},"./src/crypt/fast-aes-key.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(u,f){this.subtle=u,this.key=f}return l.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},l}();t.default=a},"./src/demux/aacdemuxer.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/demux/adts.js"),u=n("./src/utils/logger.js"),f=n("./src/demux/id3.js"),d=function(){function h(y,E,p){this.observer=y,this.config=p,this.remuxer=E}return h.prototype.resetInitSegment=function(y,E,p,_){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:E,duration:_,inputTimeScale:9e4}},h.prototype.resetTimeStamp=function(){},h.probe=function(y){if(!y)return!1;for(var E=f.default.getID3Data(y,0)||[],p=E.length,_=y.length;p<_;p++)if(l.probe(y,p))return u.logger.log("ADTS sync word found !"),!0;return!1},h.prototype.append=function(y,E,p,_){for(var g=this._audioTrack,x=f.default.getID3Data(y,0)||[],C=f.default.getTimeStamp(x),R=a.isFinite(C)?C*90:E*9e4,S=0,A=R,T=y.length,w=x.length,P=[{pts:A,dts:A,data:x}];w<T-1;)if(l.isHeader(y,w)&&w+5<T){l.initTrackConfig(g,this.observer,y,w,g.manifestCodec);var O=l.appendFrame(g,y,w,R,S);if(O)w+=O.length,A=O.sample.pts,S++;else{u.logger.log("Unable to parse AAC frame");break}}else f.default.isHeader(y,w)?(x=f.default.getID3Data(y,w),P.push({pts:A,dts:A,data:x}),w+=x.length):w++;this.remuxer.remux(g,{samples:[]},{samples:P,inputTimeScale:9e4},{samples:[]},E,p,_)},h.prototype.destroy=function(){},h}();t.default=d}).call(this,n("./src/polyfills/number.js").Number)},"./src/demux/adts.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/logger.js"),l=n("./src/errors.js"),u=n("./src/events.js");function f(R,S,A,T){var w,P,O,k,D,F=navigator.userAgent.toLowerCase(),G=T,V=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];if(w=((S[A+2]&192)>>>6)+1,P=(S[A+2]&60)>>>2,P>V.length-1){R.trigger(u.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+P});return}return k=(S[A+2]&1)<<2,k|=(S[A+3]&192)>>>6,a.logger.log("manifest codec:"+T+",ADTS data:type:"+w+",sampleingIndex:"+P+"["+V[P]+"Hz],channelConfig:"+k),/firefox/i.test(F)?P>=6?(w=5,D=new Array(4),O=P-3):(w=2,D=new Array(2),O=P):F.indexOf("android")!==-1?(w=2,D=new Array(2),O=P):(w=5,D=new Array(4),T&&(T.indexOf("mp4a.40.29")!==-1||T.indexOf("mp4a.40.5")!==-1)||!T&&P>=6?O=P-3:((T&&T.indexOf("mp4a.40.2")!==-1&&(P>=6&&k===1||/vivaldi/i.test(F))||!T&&k===1)&&(w=2,D=new Array(2)),O=P)),D[0]=w<<3,D[0]|=(P&14)>>1,D[1]|=(P&1)<<7,D[1]|=k<<3,w===5&&(D[1]|=(O&14)>>1,D[2]=(O&1)<<7,D[2]|=8,D[3]=0),{config:D,samplerate:V[P],channelCount:k,codec:"mp4a.40."+w,manifestCodec:G}}t.getAudioConfig=f;function d(R,S){return R[S]===255&&(R[S+1]&246)===240}t.isHeaderPattern=d;function h(R,S){return R[S+1]&1?7:9}t.getHeaderLength=h;function y(R,S){return(R[S+3]&3)<<11|R[S+4]<<3|(R[S+5]&224)>>>5}t.getFullFrameLength=y;function E(R,S){return!!(S+1<R.length&&d(R,S))}t.isHeader=E;function p(R,S){if(S+1<R.length&&d(R,S)){var A=h(R,S),T=A;S+5<R.length&&(T=y(R,S));var w=S+T;if(w===R.length||w+1<R.length&&d(R,w))return!0}return!1}t.probe=p;function _(R,S,A,T,w){if(!R.samplerate){var P=f(S,A,T,w);R.config=P.config,R.samplerate=P.samplerate,R.channelCount=P.channelCount,R.codec=P.codec,R.manifestCodec=P.manifestCodec,a.logger.log("parsed codec:"+R.codec+",rate:"+P.samplerate+",nb channel:"+P.channelCount)}}t.initTrackConfig=_;function g(R){return 1024*9e4/R}t.getFrameDuration=g;function x(R,S,A,T,w){var P,O,k,D=R.length;if(P=h(R,S),O=y(R,S),O-=P,O>0&&S+P+O<=D)return k=A+T*w,{headerLength:P,frameLength:O,stamp:k}}t.parseFrameHeader=x;function C(R,S,A,T,w){var P=g(R.samplerate),O=x(S,A,T,w,P);if(O){var k=O.stamp,D=O.headerLength,F=O.frameLength,G={unit:S.subarray(A+D,A+D+F),pts:k,dts:k};return R.samples.push(G),R.len+=F,{sample:G,length:F+D}}}t.appendFrame=C},"./src/demux/demuxer-inline.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/events.js"),l=n("./src/errors.js"),u=n("./src/crypt/decrypter.js"),f=n("./src/demux/aacdemuxer.js"),d=n("./src/demux/mp4demuxer.js"),h=n("./src/demux/tsdemuxer.js"),y=n("./src/demux/mp3demuxer.js"),E=n("./src/remux/mp4-remuxer.js"),p=n("./src/remux/passthrough-remuxer.js"),_=n("./src/utils/get-self-scope.js"),g=n("./src/utils/logger.js"),x=_.getSelfScope(),C;try{C=x.performance.now.bind(x.performance)}catch{g.logger.debug("Unable to use Performance API on this environment"),C=x.Date.now}var R=function(){function S(A,T,w,P){this.observer=A,this.typeSupported=T,this.config=w,this.vendor=P}return S.prototype.destroy=function(){var A=this.demuxer;A&&A.destroy()},S.prototype.push=function(A,T,w,P,O,k,D,F,G,V,W,ee){var q=this;if(A.byteLength>0&&T!=null&&T.key!=null&&T.method==="AES-128"){var z=this.decrypter;z==null&&(z=this.decrypter=new u.default(this.observer,this.config));var U=C();z.decrypt(A,T.key.buffer,T.iv.buffer,function($){var I=C();q.observer.trigger(a.default.FRAG_DECRYPTED,{stats:{tstart:U,tdecrypt:I}}),q.pushDecrypted(new Uint8Array($),T,new Uint8Array(w),P,O,k,D,F,G,V,W,ee)})}else this.pushDecrypted(new Uint8Array(A),T,new Uint8Array(w),P,O,k,D,F,G,V,W,ee)},S.prototype.pushDecrypted=function(A,T,w,P,O,k,D,F,G,V,W,ee){var q=this.demuxer;if(!q||(D||F)&&!this.probe(A)){for(var z=this.observer,U=this.typeSupported,$=this.config,I=[{demux:h.default,remux:E.default},{demux:d.default,remux:p.default},{demux:f.default,remux:E.default},{demux:y.default,remux:E.default}],B=0,X=I.length;B<X;B++){var Q=I[B],J=Q.demux.probe;if(J(A)){var ne=this.remuxer=new Q.remux(z,$,U,this.vendor);q=new Q.demux(z,ne,$,U),this.probe=J;break}}if(!q){z.trigger(a.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});return}this.demuxer=q}var ae=this.remuxer;(D||F)&&(q.resetInitSegment(w,P,O,V),ae.resetInitSegment()),D&&(q.resetTimeStamp(ee),ae.resetTimeStamp(ee)),typeof q.setDecryptData=="function"&&q.setDecryptData(T),q.append(A,k,G,W)},S}();t.default=R},"./src/demux/demuxer-worker.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/demux/demuxer-inline.js"),l=n("./src/events.js"),u=n("./src/utils/logger.js"),f=n("./node_modules/node-libs-browser/node_modules/events/events.js"),d=function(h){var y=new f.EventEmitter;y.trigger=function(_){for(var g=[],x=1;x<arguments.length;x++)g[x-1]=arguments[x];y.emit.apply(y,[_,_].concat(g))},y.off=function(_){for(var g=[],x=1;x<arguments.length;x++)g[x-1]=arguments[x];y.removeListener.apply(y,[_].concat(g))};var E=function(p,_){h.postMessage({event:p,data:_})};h.addEventListener("message",function(p){var _=p.data;switch(_.cmd){case"init":var g=JSON.parse(_.config);h.demuxer=new a.default(y,_.typeSupported,g,_.vendor),u.enableLogs(g.debug),E("init",null);break;case"demux":h.demuxer.push(_.data,_.decryptdata,_.initSegment,_.audioCodec,_.videoCodec,_.timeOffset,_.discontinuity,_.trackSwitch,_.contiguous,_.duration,_.accurateTimeOffset,_.defaultInitPTS);break}}),y.on(l.default.FRAG_DECRYPTED,E),y.on(l.default.FRAG_PARSING_INIT_SEGMENT,E),y.on(l.default.FRAG_PARSED,E),y.on(l.default.ERROR,E),y.on(l.default.FRAG_PARSING_METADATA,E),y.on(l.default.FRAG_PARSING_USERDATA,E),y.on(l.default.INIT_PTS_FOUND,E),y.on(l.default.FRAG_PARSING_DATA,function(p,_){var g=[],x={event:p,data:_};_.data1&&(x.data1=_.data1.buffer,g.push(_.data1.buffer),delete _.data1),_.data2&&(x.data2=_.data2.buffer,g.push(_.data2.buffer),delete _.data2),h.postMessage(x,g)})};t.default=d},"./src/demux/demuxer.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./node_modules/webworkify-webpack/index.js"),u=n("./src/events.js"),f=n("./src/demux/demuxer-inline.js"),d=n("./src/utils/logger.js"),h=n("./src/errors.js"),y=n("./src/utils/mediasource-helper.js"),E=n("./src/utils/get-self-scope.js"),p=n("./src/observer.js"),_=E.getSelfScope(),g=y.getMediaSource(),x=function(){function C(R,S){var A=this;this.hls=R,this.id=S;var T=this.observer=new p.Observer,w=R.config,P=function(F,G){G=G||{},G.frag=A.frag,G.id=A.id,R.trigger(F,G)};T.on(u.default.FRAG_DECRYPTED,P),T.on(u.default.FRAG_PARSING_INIT_SEGMENT,P),T.on(u.default.FRAG_PARSING_DATA,P),T.on(u.default.FRAG_PARSED,P),T.on(u.default.ERROR,P),T.on(u.default.FRAG_PARSING_METADATA,P),T.on(u.default.FRAG_PARSING_USERDATA,P),T.on(u.default.INIT_PTS_FOUND,P);var O={mp4:g.isTypeSupported("video/mp4"),mpeg:g.isTypeSupported("audio/mpeg"),mp3:g.isTypeSupported('audio/mp4; codecs="mp3"')},k=navigator.vendor;if(w.enableWorker&&typeof Worker<"u"){d.logger.log("demuxing in webworker");var D=void 0;try{D=this.w=l("./src/demux/demuxer-worker.js"),this.onwmsg=this.onWorkerMessage.bind(this),D.addEventListener("message",this.onwmsg),D.onerror=function(F){R.trigger(u.default.ERROR,{type:h.ErrorTypes.OTHER_ERROR,details:h.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:F.message+" ("+F.filename+":"+F.lineno+")"}})},D.postMessage({cmd:"init",typeSupported:O,vendor:k,id:S,config:JSON.stringify(w)})}catch(F){d.logger.warn("Error in worker:",F),d.logger.error("Error while initializing DemuxerWorker, fallback on DemuxerInline"),D&&_.URL.revokeObjectURL(D.objectURL),this.demuxer=new f.default(T,O,w,k),this.w=void 0}}else this.demuxer=new f.default(T,O,w,k)}return C.prototype.destroy=function(){var R=this.w;if(R)R.removeEventListener("message",this.onwmsg),R.terminate(),this.w=null;else{var S=this.demuxer;S&&(S.destroy(),this.demuxer=null)}var A=this.observer;A&&(A.removeAllListeners(),this.observer=null)},C.prototype.push=function(R,S,A,T,w,P,O,k){var D=this.w,F=a.isFinite(w.startPTS)?w.startPTS:w.start,G=w.decryptdata,V=this.frag,W=!(V&&w.cc===V.cc),ee=!(V&&w.level===V.level),q=V&&w.sn===V.sn+1,z=!ee&&q;if(W&&d.logger.log(this.id+":discontinuity detected"),ee&&d.logger.log(this.id+":switch detected"),this.frag=w,D)D.postMessage({cmd:"demux",data:R,decryptdata:G,initSegment:S,audioCodec:A,videoCodec:T,timeOffset:F,discontinuity:W,trackSwitch:ee,contiguous:z,duration:P,accurateTimeOffset:O,defaultInitPTS:k},R instanceof ArrayBuffer?[R]:[]);else{var U=this.demuxer;U&&U.push(R,G,S,A,T,F,W,ee,z,P,O,k)}},C.prototype.onWorkerMessage=function(R){var S=R.data,A=this.hls;switch(S.event){case"init":_.URL.revokeObjectURL(this.w.objectURL);break;case u.default.FRAG_PARSING_DATA:S.data.data1=new Uint8Array(S.data1),S.data2&&(S.data.data2=new Uint8Array(S.data2));default:S.data=S.data||{},S.data.frag=this.frag,S.data.id=this.id,A.trigger(S.event,S.data);break}},C}();t.default=x}).call(this,n("./src/polyfills/number.js").Number)},"./src/demux/exp-golomb.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/logger.js"),l=function(){function u(f){this.data=f,this.bytesAvailable=f.byteLength,this.word=0,this.bitsAvailable=0}return u.prototype.loadWord=function(){var f=this.data,d=this.bytesAvailable,h=f.byteLength-d,y=new Uint8Array(4),E=Math.min(4,d);if(E===0)throw new Error("no bytes available");y.set(f.subarray(h,h+E)),this.word=new DataView(y.buffer).getUint32(0),this.bitsAvailable=E*8,this.bytesAvailable-=E},u.prototype.skipBits=function(f){var d;this.bitsAvailable>f?(this.word<<=f,this.bitsAvailable-=f):(f-=this.bitsAvailable,d=f>>3,f-=d>>3,this.bytesAvailable-=d,this.loadWord(),this.word<<=f,this.bitsAvailable-=f)},u.prototype.readBits=function(f){var d=Math.min(this.bitsAvailable,f),h=this.word>>>32-d;return f>32&&a.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=d,this.bitsAvailable>0?this.word<<=d:this.bytesAvailable>0&&this.loadWord(),d=f-d,d>0&&this.bitsAvailable?h<<d|this.readBits(d):h},u.prototype.skipLZ=function(){var f;for(f=0;f<this.bitsAvailable;++f)if(this.word&2147483648>>>f)return this.word<<=f,this.bitsAvailable-=f,f;return this.loadWord(),f+this.skipLZ()},u.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},u.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},u.prototype.readUEG=function(){var f=this.skipLZ();return this.readBits(f+1)-1},u.prototype.readEG=function(){var f=this.readUEG();return 1&f?1+f>>>1:-1*(f>>>1)},u.prototype.readBoolean=function(){return this.readBits(1)===1},u.prototype.readUByte=function(){return this.readBits(8)},u.prototype.readUShort=function(){return this.readBits(16)},u.prototype.readUInt=function(){return this.readBits(32)},u.prototype.skipScalingList=function(f){var d=8,h=8,y,E;for(y=0;y<f;y++)h!==0&&(E=this.readEG(),h=(d+E+256)%256),d=h===0?d:h},u.prototype.readSPS=function(){var f=0,d=0,h=0,y=0,E,p,_,g,x,C,R,S=this.readUByte.bind(this),A=this.readBits.bind(this),T=this.readUEG.bind(this),w=this.readBoolean.bind(this),P=this.skipBits.bind(this),O=this.skipEG.bind(this),k=this.skipUEG.bind(this),D=this.skipScalingList.bind(this);if(S(),E=S(),A(5),P(3),S(),k(),E===100||E===110||E===122||E===244||E===44||E===83||E===86||E===118||E===128){var F=T();if(F===3&&P(1),k(),k(),P(1),w())for(C=F!==3?8:12,R=0;R<C;R++)w()&&(R<6?D(16):D(64))}k();var G=T();if(G===0)T();else if(G===1)for(P(1),O(),O(),p=T(),R=0;R<p;R++)O();k(),P(1),_=T(),g=T(),x=A(1),x===0&&P(1),P(1),w()&&(f=T(),d=T(),h=T(),y=T());var V=[1,1];if(w()&&w()){var W=S();switch(W){case 1:V=[1,1];break;case 2:V=[12,11];break;case 3:V=[10,11];break;case 4:V=[16,11];break;case 5:V=[40,33];break;case 6:V=[24,11];break;case 7:V=[20,11];break;case 8:V=[32,11];break;case 9:V=[80,33];break;case 10:V=[18,11];break;case 11:V=[15,11];break;case 12:V=[64,33];break;case 13:V=[160,99];break;case 14:V=[4,3];break;case 15:V=[3,2];break;case 16:V=[2,1];break;case 255:{V=[S()<<8|S(),S()<<8|S()];break}}}return{width:Math.ceil((_+1)*16-f*2-d*2),height:(2-x)*(g+1)*16-(x?2:4)*(h+y),pixelRatio:V}},u.prototype.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},u}();t.default=l},"./src/demux/id3.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function u(){}return u.isHeader=function(f,d){return d+10<=f.length&&f[d]===73&&f[d+1]===68&&f[d+2]===51&&f[d+3]<255&&f[d+4]<255&&f[d+6]<128&&f[d+7]<128&&f[d+8]<128&&f[d+9]<128},u.isFooter=function(f,d){return d+10<=f.length&&f[d]===51&&f[d+1]===68&&f[d+2]===73&&f[d+3]<255&&f[d+4]<255&&f[d+6]<128&&f[d+7]<128&&f[d+8]<128&&f[d+9]<128},u.getID3Data=function(f,d){for(var h=d,y=0;u.isHeader(f,d);){y+=10;var E=u._readSize(f,d+6);y+=E,u.isFooter(f,d+10)&&(y+=10),d+=y}if(y>0)return f.subarray(h,h+y)},u._readSize=function(f,d){var h=0;return h=(f[d]&127)<<21,h|=(f[d+1]&127)<<14,h|=(f[d+2]&127)<<7,h|=f[d+3]&127,h},u.getTimeStamp=function(f){for(var d=u.getID3Frames(f),h=0;h<d.length;h++){var y=d[h];if(u.isTimeStampFrame(y))return u._readTimeStamp(y)}},u.isTimeStampFrame=function(f){return f&&f.key==="PRIV"&&f.info==="com.apple.streaming.transportStreamTimestamp"},u._getFrameData=function(f){var d=String.fromCharCode(f[0],f[1],f[2],f[3]),h=u._readSize(f,4),y=10;return{type:d,size:h,data:f.subarray(y,y+h)}},u.getID3Frames=function(f){for(var d=0,h=[];u.isHeader(f,d);){var y=u._readSize(f,d+6);d+=10;for(var E=d+y;d+8<E;){var p=u._getFrameData(f.subarray(d)),_=u._decodeFrame(p);_&&h.push(_),d+=p.size+10}u.isFooter(f,d)&&(d+=10)}return h},u._decodeFrame=function(f){if(f.type==="PRIV")return u._decodePrivFrame(f);if(f.type[0]==="T")return u._decodeTextFrame(f);if(f.type[0]==="W")return u._decodeURLFrame(f)},u._readTimeStamp=function(f){if(f.data.byteLength===8){var d=new Uint8Array(f.data),h=d[3]&1,y=(d[4]<<23)+(d[5]<<15)+(d[6]<<7)+d[7];return y/=45,h&&(y+=4772185884e-2),Math.round(y)}},u._decodePrivFrame=function(f){if(!(f.size<2)){var d=u._utf8ArrayToStr(f.data,!0),h=new Uint8Array(f.data.subarray(d.length+1));return{key:f.type,info:d,data:h.buffer}}},u._decodeTextFrame=function(f){if(!(f.size<2))if(f.type==="TXXX"){var d=1,h=u._utf8ArrayToStr(f.data.subarray(d));d+=h.length+1;var y=u._utf8ArrayToStr(f.data.subarray(d));return{key:f.type,info:h,data:y}}else{var E=u._utf8ArrayToStr(f.data.subarray(1));return{key:f.type,data:E}}},u._decodeURLFrame=function(f){if(f.type==="WXXX"){if(f.size<2)return;var d=1,h=u._utf8ArrayToStr(f.data.subarray(d));d+=h.length+1;var y=u._utf8ArrayToStr(f.data.subarray(d));return{key:f.type,info:h,data:y}}else{var E=u._utf8ArrayToStr(f.data);return{key:f.type,data:E}}},u._utf8ArrayToStr=function(f,d){d===void 0&&(d=!1);for(var h=f.length,y,E,p,_="",g=0;g<h;){if(y=f[g++],y===0&&d)return _;if(y===0||y===3)continue;switch(y>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:_+=String.fromCharCode(y);break;case 12:case 13:E=f[g++],_+=String.fromCharCode((y&31)<<6|E&63);break;case 14:E=f[g++],p=f[g++],_+=String.fromCharCode((y&15)<<12|(E&63)<<6|(p&63)<<0);break}}return _},u}(),l=a._utf8ArrayToStr;t.utf8ArrayToStr=l,t.default=a},"./src/demux/mp3demuxer.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/demux/id3.js"),l=n("./src/utils/logger.js"),u=n("./src/demux/mpegaudio.js"),f=function(){function d(h,y,E){this.observer=h,this.config=E,this.remuxer=y}return d.prototype.resetInitSegment=function(h,y,E,p){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:y,duration:p,inputTimeScale:9e4}},d.prototype.resetTimeStamp=function(){},d.probe=function(h){var y,E,p=a.default.getID3Data(h,0);if(p&&a.default.getTimeStamp(p)!==void 0){for(y=p.length,E=Math.min(h.length-1,y+100);y<E;y++)if(u.default.probe(h,y))return l.logger.log("MPEG Audio sync word found !"),!0}return!1},d.prototype.append=function(h,y,E,p){for(var _=a.default.getID3Data(h,0),g=a.default.getTimeStamp(_),x=g?90*g:y*9e4,C=_.length,R=h.length,S=0,A=0,T=this._audioTrack,w=[{pts:x,dts:x,data:_}];C<R;)if(u.default.isHeader(h,C)){var P=u.default.appendFrame(T,h,C,x,S);if(P)C+=P.length,A=P.sample.pts,S++;else break}else a.default.isHeader(h,C)?(_=a.default.getID3Data(h,C),w.push({pts:A,dts:A,data:_}),C+=_.length):C++;this.remuxer.remux(T,{samples:[]},{samples:w,inputTimeScale:9e4},{samples:[]},y,E,p)},d.prototype.destroy=function(){},d}();t.default=f},"./src/demux/mp4demuxer.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/logger.js"),l=n("./src/events.js"),u=Math.pow(2,32)-1,f=function(){function d(h,y){this.observer=h,this.remuxer=y}return d.prototype.resetTimeStamp=function(h){this.initPTS=h},d.prototype.resetInitSegment=function(h,y,E,p){if(h&&h.byteLength){var _=this.initData=d.parseInitSegment(h);y==null&&(y="mp4a.40.5"),E==null&&(E="avc1.42e01e");var g={};_.audio&&_.video?g.audiovideo={container:"video/mp4",codec:y+","+E,initSegment:p?h:null}:(_.audio&&(g.audio={container:"audio/mp4",codec:y,initSegment:p?h:null}),_.video&&(g.video={container:"video/mp4",codec:E,initSegment:p?h:null})),this.observer.trigger(l.default.FRAG_PARSING_INIT_SEGMENT,{tracks:g})}else y&&(this.audioCodec=y),E&&(this.videoCodec=E)},d.probe=function(h){return d.findBox({data:h,start:0,end:Math.min(h.length,16384)},["moof"]).length>0},d.bin2str=function(h){return String.fromCharCode.apply(null,h)},d.readUint16=function(h,y){h.data&&(y+=h.start,h=h.data);var E=h[y]<<8|h[y+1];return E<0?65536+E:E},d.readUint32=function(h,y){h.data&&(y+=h.start,h=h.data);var E=h[y]<<24|h[y+1]<<16|h[y+2]<<8|h[y+3];return E<0?4294967296+E:E},d.writeUint32=function(h,y,E){h.data&&(y+=h.start,h=h.data),h[y]=E>>24,h[y+1]=E>>16&255,h[y+2]=E>>8&255,h[y+3]=E&255},d.findBox=function(h,y){var E=[],p,_,g,x,C,R,S;if(h.data?(R=h.start,x=h.end,h=h.data):(R=0,x=h.byteLength),!y.length)return null;for(p=R;p<x;)_=d.readUint32(h,p),g=d.bin2str(h.subarray(p+4,p+8)),S=_>1?p+_:x,g===y[0]&&(y.length===1?E.push({data:h,start:p+8,end:S}):(C=d.findBox({data:h,start:p+8,end:S},y.slice(1)),C.length&&(E=E.concat(C)))),p=S;return E},d.parseSegmentIndex=function(h){var y=d.findBox(h,["moov"])[0],E=y?y.end:null,p=0,_=d.findBox(h,["sidx"]),g;if(!_||!_[0])return null;g=[],_=_[0];var x=_.data[0];p=x===0?8:16;var C=d.readUint32(_,p);p+=4;var R=0,S=0;x===0?p+=8:p+=16,p+=2;var A=_.end+S,T=d.readUint16(_,p);p+=2;for(var w=0;w<T;w++){var P=p,O=d.readUint32(_,P);P+=4;var k=O&2147483647,D=(O&2147483648)>>>31;if(D===1){console.warn("SIDX has hierarchical references (not supported)");return}var F=d.readUint32(_,P);P+=4,g.push({referenceSize:k,subsegmentDuration:F,info:{duration:F/C,start:A,end:A+k-1}}),A+=k,P+=4,p=P}return{earliestPresentationTime:R,timescale:C,version:x,referencesCount:T,references:g,moovEndOffset:E}},d.parseInitSegment=function(h){var y=[],E=d.findBox(h,["moov","trak"]);return E.forEach(function(p){var _=d.findBox(p,["tkhd"])[0];if(_){var g=_.data[_.start],x=g===0?12:20,C=d.readUint32(_,x),R=d.findBox(p,["mdia","mdhd"])[0];if(R){g=R.data[R.start],x=g===0?12:20;var S=d.readUint32(R,x),A=d.findBox(p,["mdia","hdlr"])[0];if(A){var T=d.bin2str(A.data.subarray(A.start+8,A.start+12)),w={soun:"audio",vide:"video"}[T];if(w){var P=d.findBox(p,["mdia","minf","stbl","stsd"]);if(P.length){P=P[0];var O=d.bin2str(P.data.subarray(P.start+12,P.start+16));a.logger.log("MP4Demuxer:"+w+":"+O+" found")}y[C]={timescale:S,type:w},y[w]={timescale:S,id:C}}}}}}),y},d.getStartDTS=function(h,y){var E,p,_;return E=d.findBox(y,["moof","traf"]),p=[].concat.apply([],E.map(function(g){return d.findBox(g,["tfhd"]).map(function(x){var C,R,S;return C=d.readUint32(x,4),R=h[C].timescale||9e4,S=d.findBox(g,["tfdt"]).map(function(A){var T,w;return T=A.data[A.start],w=d.readUint32(A,4),T===1&&(w*=Math.pow(2,32),w+=d.readUint32(A,8)),w})[0],S/R})})),_=Math.min.apply(null,p),isFinite(_)?_:0},d.offsetStartDTS=function(h,y,E){d.findBox(y,["moof","traf"]).map(function(p){return d.findBox(p,["tfhd"]).map(function(_){var g=d.readUint32(_,4),x=h[g].timescale||9e4;d.findBox(p,["tfdt"]).map(function(C){var R=C.data[C.start],S=d.readUint32(C,4);if(R===0)d.writeUint32(C,4,S-E*x);else{S*=Math.pow(2,32),S+=d.readUint32(C,8),S-=E*x,S=Math.max(S,0);var A=Math.floor(S/(u+1)),T=Math.floor(S%(u+1));d.writeUint32(C,4,A),d.writeUint32(C,8,T)}})})})},d.prototype.append=function(h,y,E,p){var _=this.initData;_||(this.resetInitSegment(h,this.audioCodec,this.videoCodec,!1),_=this.initData);var g,x=this.initPTS;if(x===void 0){var C=d.getStartDTS(_,h);this.initPTS=x=C-y,this.observer.trigger(l.default.INIT_PTS_FOUND,{initPTS:x})}d.offsetStartDTS(_,h,x),g=d.getStartDTS(_,h),this.remuxer.remux(_.audio,_.video,null,null,g,E,p,h)},d.prototype.destroy=function(){},d}();t.default=f},"./src/demux/mpegaudio.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={BitratesMap:[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],SamplingRateMap:[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],SamplesCoefficients:[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],BytesInSlot:[0,1,1,4],appendFrame:function(l,u,f,d,h){if(!(f+24>u.length)){var y=this.parseHeader(u,f);if(y&&f+y.frameLength<=u.length){var E=y.samplesPerFrame*9e4/y.sampleRate,p=d+h*E,_={unit:u.subarray(f,f+y.frameLength),pts:p,dts:p};return l.config=[],l.channelCount=y.channelCount,l.samplerate=y.sampleRate,l.samples.push(_),l.len+=y.frameLength,{sample:_,length:y.frameLength}}}},parseHeader:function(l,u){var f=l[u+1]>>3&3,d=l[u+1]>>1&3,h=l[u+2]>>4&15,y=l[u+2]>>2&3,E=l[u+2]>>1&1;if(f!==1&&h!==0&&h!==15&&y!==3){var p=f===3?3-d:d===3?3:4,_=a.BitratesMap[p*14+h-1]*1e3,g=f===3?0:f===2?1:2,x=a.SamplingRateMap[g*3+y],C=l[u+3]>>6===3?1:2,R=a.SamplesCoefficients[f][d],S=a.BytesInSlot[d],A=R*8*S,T=parseInt(R*_/x+E,10)*S;return{sampleRate:x,channelCount:C,frameLength:T,samplesPerFrame:A}}},isHeaderPattern:function(l,u){return l[u]===255&&(l[u+1]&224)===224&&(l[u+1]&6)!==0},isHeader:function(l,u){return!!(u+1<l.length&&this.isHeaderPattern(l,u))},probe:function(l,u){if(u+1<l.length&&this.isHeaderPattern(l,u)){var f=4,d=this.parseHeader(l,u),h=f;d&&d.frameLength&&(h=d.frameLength);var y=u+h;if(y===l.length||y+1<l.length&&this.isHeaderPattern(l,y))return!0}return!1}};t.default=a},"./src/demux/sample-aes.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/crypt/decrypter.js"),l=function(){function u(f,d,h,y){this.decryptdata=h,this.discardEPB=y,this.decrypter=new a.default(f,d,{removePKCS7Padding:!1})}return u.prototype.decryptBuffer=function(f,d){this.decrypter.decrypt(f,this.decryptdata.key.buffer,this.decryptdata.iv.buffer,d)},u.prototype.decryptAacSample=function(f,d,h,y){var E=f[d].unit,p=E.subarray(16,E.length-E.length%16),_=p.buffer.slice(p.byteOffset,p.byteOffset+p.length),g=this;this.decryptBuffer(_,function(x){x=new Uint8Array(x),E.set(x,16),y||g.decryptAacSamples(f,d+1,h)})},u.prototype.decryptAacSamples=function(f,d,h){for(;;d++){if(d>=f.length){h();return}if(!(f[d].unit.length<32)){var y=this.decrypter.isSync();if(this.decryptAacSample(f,d,h,y),!y)return}}},u.prototype.getAvcEncryptedData=function(f){for(var d=Math.floor((f.length-48)/160)*16+16,h=new Int8Array(d),y=0,E=32;E<=f.length-16;E+=160,y+=16)h.set(f.subarray(E,E+16),y);return h},u.prototype.getAvcDecryptedUnit=function(f,d){d=new Uint8Array(d);for(var h=0,y=32;y<=f.length-16;y+=160,h+=16)f.set(d.subarray(h,h+16),y);return f},u.prototype.decryptAvcSample=function(f,d,h,y,E,p){var _=this.discardEPB(E.data),g=this.getAvcEncryptedData(_),x=this;this.decryptBuffer(g.buffer,function(C){E.data=x.getAvcDecryptedUnit(_,C),p||x.decryptAvcSamples(f,d,h+1,y)})},u.prototype.decryptAvcSamples=function(f,d,h,y){for(;;d++,h=0){if(d>=f.length){y();return}for(var E=f[d].units;!(h>=E.length);h++){var p=E[h];if(!(p.length<=48||p.type!==1&&p.type!==5)){var _=this.decrypter.isSync();if(this.decryptAvcSample(f,d,h,y,p,_),!_)return}}}},u}();t.default=l},"./src/demux/tsdemuxer.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/demux/adts.js"),l=n("./src/demux/mpegaudio.js"),u=n("./src/events.js"),f=n("./src/demux/exp-golomb.js"),d=n("./src/demux/sample-aes.js"),h=n("./src/utils/logger.js"),y=n("./src/errors.js"),E={video:1,audio:2,id3:3,text:4},p=function(){function _(g,x,C,R){this.observer=g,this.config=C,this.typeSupported=R,this.remuxer=x,this.sampleAes=null}return _.prototype.setDecryptData=function(g){g!=null&&g.key!=null&&g.method==="SAMPLE-AES"?this.sampleAes=new d.default(this.observer,this.config,g,this.discardEPB):this.sampleAes=null},_.probe=function(g){var x=_._syncOffset(g);return x<0?!1:(x&&h.logger.warn("MPEG2-TS detected but first sync word found @ offset "+x+", junk ahead ?"),!0)},_._syncOffset=function(g){for(var x=Math.min(1e3,g.length-564),C=0;C<x;){if(g[C]===71&&g[C+188]===71&&g[C+2*188]===71)return C;C++}return-1},_.createTrack=function(g,x){return{container:g==="video"||g==="audio"?"video/mp2t":void 0,type:g,id:E[g],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0,dropped:g==="video"?0:void 0,isAAC:g==="audio"?!0:void 0,duration:g==="audio"?x:void 0}},_.prototype.resetInitSegment=function(g,x,C,R){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=_.createTrack("video",R),this._audioTrack=_.createTrack("audio",R),this._id3Track=_.createTrack("id3",R),this._txtTrack=_.createTrack("text",R),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=x,this.videoCodec=C,this._duration=R},_.prototype.resetTimeStamp=function(){},_.prototype.append=function(g,x,C,R){var S,A=g.length,T,w,P,O,k,D=!1;this.contiguous=C;var F=this.pmtParsed,G=this._avcTrack,V=this._audioTrack,W=this._id3Track,ee=G.pid,q=V.pid,z=W.pid,U=this._pmtId,$=G.pesData,I=V.pesData,B=W.pesData,X=this._parsePAT,Q=this._parsePMT,J=this._parsePES,ne=this._parseAVCPES.bind(this),ae=this._parseAACPES.bind(this),Z=this._parseMPEGPES.bind(this),se=this._parseID3PES.bind(this),oe=_._syncOffset(g);for(A-=(A+oe)%188,S=oe;S<A;S+=188)if(g[S]===71){if(T=!!(g[S+1]&64),w=((g[S+1]&31)<<8)+g[S+2],P=(g[S+3]&48)>>4,P>1){if(O=S+5+g[S+4],O===S+188)continue}else O=S+4;switch(w){case ee:T&&($&&(k=J($))&&k.pts!==void 0&&ne(k,!1),$={data:[],size:0}),$&&($.data.push(g.subarray(O,S+188)),$.size+=S+188-O);break;case q:T&&(I&&(k=J(I))&&k.pts!==void 0&&(V.isAAC?ae(k):Z(k)),I={data:[],size:0}),I&&(I.data.push(g.subarray(O,S+188)),I.size+=S+188-O);break;case z:T&&(B&&(k=J(B))&&k.pts!==void 0&&se(k),B={data:[],size:0}),B&&(B.data.push(g.subarray(O,S+188)),B.size+=S+188-O);break;case 0:T&&(O+=g[O]+1),U=this._pmtId=X(g,O);break;case U:T&&(O+=g[O]+1);var fe=Q(g,O,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,this.sampleAes!=null);ee=fe.avc,ee>0&&(G.pid=ee),q=fe.audio,q>0&&(V.pid=q,V.isAAC=fe.isAAC),z=fe.id3,z>0&&(W.pid=z),D&&!F&&(h.logger.log("reparse from beginning"),D=!1,S=oe-188),F=this.pmtParsed=!0;break;case 17:case 8191:break;default:D=!0;break}}else this.observer.trigger(u.default.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});$&&(k=J($))&&k.pts!==void 0?(ne(k,!0),G.pesData=null):G.pesData=$,I&&(k=J(I))&&k.pts!==void 0?(V.isAAC?ae(k):Z(k),V.pesData=null):(I&&I.size&&h.logger.log("last AAC PES packet truncated,might overlap between fragments"),V.pesData=I),B&&(k=J(B))&&k.pts!==void 0?(se(k),W.pesData=null):W.pesData=B,this.sampleAes==null?this.remuxer.remux(V,G,W,this._txtTrack,x,C,R):this.decryptAndRemux(V,G,W,this._txtTrack,x,C,R)},_.prototype.decryptAndRemux=function(g,x,C,R,S,A,T){if(g.samples&&g.isAAC){var w=this;this.sampleAes.decryptAacSamples(g.samples,0,function(){w.decryptAndRemuxAvc(g,x,C,R,S,A,T)})}else this.decryptAndRemuxAvc(g,x,C,R,S,A,T)},_.prototype.decryptAndRemuxAvc=function(g,x,C,R,S,A,T){if(x.samples){var w=this;this.sampleAes.decryptAvcSamples(x.samples,0,0,function(){w.remuxer.remux(g,x,C,R,S,A,T)})}else this.remuxer.remux(g,x,C,R,S,A,T)},_.prototype.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},_.prototype._parsePAT=function(g,x){return(g[x+10]&31)<<8|g[x+11]},_.prototype._parsePMT=function(g,x,C,R){var S,A,T,w,P={audio:-1,avc:-1,id3:-1,isAAC:!0};for(S=(g[x+1]&15)<<8|g[x+2],A=x+3+S-4,T=(g[x+10]&15)<<8|g[x+11],x+=12+T;x<A;){switch(w=(g[x+1]&31)<<8|g[x+2],g[x]){case 207:if(!R){h.logger.log("unkown stream type:"+g[x]);break}case 15:P.audio===-1&&(P.audio=w);break;case 21:P.id3===-1&&(P.id3=w);break;case 219:if(!R){h.logger.log("unkown stream type:"+g[x]);break}case 27:P.avc===-1&&(P.avc=w);break;case 3:case 4:C?P.audio===-1&&(P.audio=w,P.isAAC=!1):h.logger.log("MPEG audio found, not supported in this browser for now");break;case 36:h.logger.warn("HEVC stream type found, not supported for now");break;default:h.logger.log("unkown stream type:"+g[x]);break}x+=((g[x+3]&15)<<8|g[x+4])+5}return P},_.prototype._parsePES=function(g){var x=0,C,R,S,A,T,w,P,O,k,D=g.data;if(!g||g.size===0)return null;for(;D[0].length<19&&D.length>1;){var F=new Uint8Array(D[0].length+D[1].length);F.set(D[0]),F.set(D[1],D[0].length),D[0]=F,D.splice(1,1)}if(C=D[0],S=(C[0]<<16)+(C[1]<<8)+C[2],S===1){if(A=(C[4]<<8)+C[5],A&&A>g.size-6)return null;R=C[7],R&192&&(P=(C[9]&14)*536870912+(C[10]&255)*4194304+(C[11]&254)*16384+(C[12]&255)*128+(C[13]&254)/2,P>4294967295&&(P-=8589934592),R&64?(O=(C[14]&14)*536870912+(C[15]&255)*4194304+(C[16]&254)*16384+(C[17]&255)*128+(C[18]&254)/2,O>4294967295&&(O-=8589934592),P-O>60*9e4&&(h.logger.warn(Math.round((P-O)/9e4)+"s delta between PTS and DTS, align them"),P=O)):O=P),T=C[8],k=T+9,g.size-=k,w=new Uint8Array(g.size);for(var G=0,V=D.length;G<V;G++){C=D[G];var W=C.byteLength;if(k)if(k>W){k-=W;continue}else C=C.subarray(k),W-=k,k=0;w.set(C,x),x+=W}return A&&(A-=T+3),{data:w,pts:P,dts:O,len:A}}else return null},_.prototype.pushAccesUnit=function(g,x){if(g.units.length&&g.frame){var C=x.samples,R=C.length;!this.config.forceKeyFrameOnDiscontinuity||g.key===!0||x.sps&&(R||this.contiguous)?(g.id=R,C.push(g)):x.dropped++}g.debug.length&&h.logger.log(g.pts+"/"+g.dts+":"+g.debug)},_.prototype._parseAVCPES=function(g,x){var C=this,R=this._avcTrack,S=this._parseAVCNALu(g.data),A,T=this.avcSample,w,P=!1,O,k=this.pushAccesUnit.bind(this),D=function(F,G,V,W){return{key:F,pts:G,dts:V,units:[],debug:W}};g.data=null,T&&S.length&&!R.audFound&&(k(T,R),T=this.avcSample=D(!1,g.pts,g.dts,"")),S.forEach(function(F){switch(F.type){case 1:w=!0,T||(T=C.avcSample=D(!0,g.pts,g.dts,"")),T.frame=!0;var G=F.data;if(P&&G.length>4){var V=new f.default(G).readSliceType();(V===2||V===4||V===7||V===9)&&(T.key=!0)}break;case 5:w=!0,T||(T=C.avcSample=D(!0,g.pts,g.dts,"")),T.key=!0,T.frame=!0;break;case 6:w=!0,A=new f.default(C.discardEPB(F.data)),A.readUByte();for(var W=0,ee=0,q=!1,z=0;!q&&A.bytesAvailable>1;){W=0;do z=A.readUByte(),W+=z;while(z===255);ee=0;do z=A.readUByte(),ee+=z;while(z===255);if(W===4&&A.bytesAvailable!==0){q=!0;var U=A.readUByte();if(U===181){var $=A.readUShort();if($===49){var I=A.readUInt();if(I===1195456820){var B=A.readUByte();if(B===3){var X=A.readUByte(),Q=A.readUByte(),J=31&X,ne=[X,Q];for(O=0;O<J;O++)ne.push(A.readUByte()),ne.push(A.readUByte()),ne.push(A.readUByte());C._insertSampleInOrder(C._txtTrack.samples,{type:3,pts:g.pts,bytes:ne})}}}}}else if(ee<A.bytesAvailable)for(O=0;O<ee;O++)A.readUByte()}break;case 7:if(w=!0,P=!0,!R.sps){A=new f.default(F.data);var ae=A.readSPS();R.width=ae.width,R.height=ae.height,R.pixelRatio=ae.pixelRatio,R.sps=[F.data],R.duration=C._duration;var Z=F.data.subarray(1,4),se="avc1.";for(O=0;O<3;O++){var oe=Z[O].toString(16);oe.length<2&&(oe="0"+oe),se+=oe}R.codec=se}break;case 8:w=!0,R.pps||(R.pps=[F.data]);break;case 9:w=!1,R.audFound=!0,T&&k(T,R),T=C.avcSample=D(!1,g.pts,g.dts,"");break;case 12:w=!1;break;default:w=!1,T&&(T.debug+="unknown NAL "+F.type+" ");break}if(T&&w){var fe=T.units;fe.push(F)}}),x&&T&&(k(T,R),this.avcSample=null)},_.prototype._insertSampleInOrder=function(g,x){var C=g.length;if(C>0){if(x.pts>=g[C-1].pts)g.push(x);else for(var R=C-1;R>=0;R--)if(x.pts<g[R].pts){g.splice(R,0,x);break}}else g.push(x)},_.prototype._getLastNalUnit=function(){var g=this.avcSample,x;if(!g||g.units.length===0){var C=this._avcTrack,R=C.samples;g=R[R.length-1]}if(g){var S=g.units;x=S[S.length-1]}return x},_.prototype._parseAVCNALu=function(g){var x=0,C=g.byteLength,R,S,A=this._avcTrack,T=A.naluState||0,w=T,P=[],O,k,D=-1,F;for(T===-1&&(D=0,F=g[0]&31,T=0,x=1);x<C;){if(R=g[x++],!T){T=R?0:1;continue}if(T===1){T=R?0:2;continue}if(!R)T=3;else if(R===1){if(D>=0)O={data:g.subarray(D,x-T-1),type:F},P.push(O);else{var G=this._getLastNalUnit();if(G&&(w&&x<=4-w&&G.state&&(G.data=G.data.subarray(0,G.data.byteLength-w)),S=x-T-1,S>0)){var V=new Uint8Array(G.data.byteLength+S);V.set(G.data,0),V.set(g.subarray(0,S),G.data.byteLength),G.data=V}}x<C?(k=g[x]&31,D=x,F=k,T=0):T=-1}else T=0}if(D>=0&&T>=0&&(O={data:g.subarray(D,C),type:F,state:T},P.push(O)),P.length===0){var G=this._getLastNalUnit();if(G){var V=new Uint8Array(G.data.byteLength+g.byteLength);V.set(G.data,0),V.set(g,G.data.byteLength),G.data=V}}return A.naluState=T,P},_.prototype.discardEPB=function(g){for(var x=g.byteLength,C=[],R=1,S,A;R<x-2;)g[R]===0&&g[R+1]===0&&g[R+2]===3?(C.push(R+2),R+=2):R++;if(C.length===0)return g;S=x-C.length,A=new Uint8Array(S);var T=0;for(R=0;R<S;T++,R++)T===C[0]&&(T++,C.shift()),A[R]=g[T];return A},_.prototype._parseAACPES=function(g){var x=this._audioTrack,C=g.data,R=g.pts,S=0,A=this.aacOverFlow,T=this.aacLastPTS,w,P,O,k,D;if(A){var F=new Uint8Array(A.byteLength+C.byteLength);F.set(A,0),F.set(C,A.byteLength),C=F}for(O=S,D=C.length;O<D-1&&!a.isHeader(C,O);O++);if(O){var G=void 0,V=void 0;if(O<D-1?(G="AAC PES did not start with ADTS header,offset:"+O,V=!1):(G="no ADTS header found in AAC PES",V=!0),h.logger.warn("parsing error:"+G),this.observer.trigger(u.default.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:V,reason:G}),V)return}if(a.initTrackConfig(x,this.observer,C,O,this.audioCodec),P=0,w=a.getFrameDuration(x.samplerate),A&&T){var W=T+w;Math.abs(W-R)>1&&(h.logger.log("AAC: align PTS for overlapping frames by "+Math.round((W-R)/90)),R=W)}for(;O<D;)if(a.isHeader(C,O)&&O+5<D){var ee=a.appendFrame(x,C,O,R,P);if(ee)O+=ee.length,k=ee.sample.pts,P++;else break}else O++;O<D?A=C.subarray(O,D):A=null,this.aacOverFlow=A,this.aacLastPTS=k},_.prototype._parseMPEGPES=function(g){for(var x=g.data,C=x.length,R=0,S=0,A=g.pts;S<C;)if(l.default.isHeader(x,S)){var T=l.default.appendFrame(this._audioTrack,x,S,A,R);if(T)S+=T.length,R++;else break}else S++},_.prototype._parseID3PES=function(g){this._id3Track.samples.push(g)},_}();t.default=p},"./src/errors.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",KEY_SYSTEM_ERROR:"keySystemError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},t.ErrorDetails={KEY_SYSTEM_NO_KEYS:"keySystemNoKeys",KEY_SYSTEM_NO_ACCESS:"keySystemNoAccess",KEY_SYSTEM_NO_SESSION:"keySystemNoSession",KEY_SYSTEM_LICENSE_REQUEST_FAILED:"keySystemLicenseRequestFailed",MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",AUDIO_TRACK_LOAD_ERROR:"audioTrackLoadError",AUDIO_TRACK_LOAD_TIMEOUT:"audioTrackLoadTimeOut",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",REMUX_ALLOC_ERROR:"remuxAllocError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_ADD_CODEC_ERROR:"bufferAddCodecError",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole",BUFFER_NUDGE_ON_STALL:"bufferNudgeOnStall",INTERNAL_EXCEPTION:"internalException"}},"./src/event-handler.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/logger.js"),l=n("./src/errors.js"),u=n("./src/events.js"),f={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},d=function(){function h(y){for(var E=[],p=1;p<arguments.length;p++)E[p-1]=arguments[p];this.hls=y,this.onEvent=this.onEvent.bind(this),this.handledEvents=E,this.useGenericHandler=!0,this.registerListeners()}return h.prototype.destroy=function(){this.onHandlerDestroying(),this.unregisterListeners(),this.onHandlerDestroyed()},h.prototype.onHandlerDestroying=function(){},h.prototype.onHandlerDestroyed=function(){},h.prototype.isEventHandler=function(){return typeof this.handledEvents=="object"&&this.handledEvents.length&&typeof this.onEvent=="function"},h.prototype.registerListeners=function(){this.isEventHandler()&&this.handledEvents.forEach(function(y){if(f[y])throw new Error("Forbidden event-name: "+y);this.hls.on(y,this.onEvent)},this)},h.prototype.unregisterListeners=function(){this.isEventHandler()&&this.handledEvents.forEach(function(y){this.hls.off(y,this.onEvent)},this)},h.prototype.onEvent=function(y,E){this.onEventGeneric(y,E)},h.prototype.onEventGeneric=function(y,E){var p=function(_,g){var x="on"+_.replace("hls","");if(typeof this[x]!="function")throw new Error("Event "+_+" has no generic handler in this "+this.constructor.name+" class (tried "+x+")");return this[x].bind(this,g)};try{p.call(this,y,E).call()}catch(_){a.logger.error("An internal error happened while handling event "+y+'. Error message: "'+_.message+'". Here is a stacktrace:',_),this.hls.trigger(u.default.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:y,err:_})}},h}();t.default=d},"./src/events.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition"};t.default=a},"./src/hls.js":function(r,t,n){var a=this&&this.__extends||function(){var T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(w,P){w.__proto__=P}||function(w,P){for(var O in P)P.hasOwnProperty(O)&&(w[O]=P[O])};return function(w,P){T(w,P);function O(){this.constructor=w}w.prototype=P===null?Object.create(P):(O.prototype=P.prototype,new O)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./node_modules/url-toolkit/src/url-toolkit.js"),u=n("./src/errors.js"),f=n("./src/loader/playlist-loader.js"),d=n("./src/loader/fragment-loader.js"),h=n("./src/loader/key-loader.js"),y=n("./src/controller/fragment-tracker.js"),E=n("./src/controller/stream-controller.js"),p=n("./src/controller/level-controller.js"),_=n("./src/controller/id3-track-controller.js"),g=n("./src/is-supported.js"),x=n("./src/utils/logger.js"),C=n("./src/config.js"),R=n("./src/events.js"),S=n("./src/observer.js"),A=function(T){a(w,T);function w(P){P===void 0&&(P={});var O=T.call(this)||this,k=w.DefaultConfig;if((P.liveSyncDurationCount||P.liveMaxLatencyDurationCount)&&(P.liveSyncDuration||P.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");for(var D in k)D in P||(P[D]=k[D]);if(P.liveMaxLatencyDurationCount!==void 0&&P.liveMaxLatencyDurationCount<=P.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(P.liveMaxLatencyDuration!==void 0&&(P.liveMaxLatencyDuration<=P.liveSyncDuration||P.liveSyncDuration===void 0))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');x.enableLogs(P.debug),O.config=P,O._autoLevelCapping=-1;var F=O.abrController=new P.abrController(O),G=new P.bufferController(O),V=new P.capLevelController(O),W=new P.fpsController(O),ee=new f.default(O),q=new d.default(O),z=new h.default(O),U=new _.default(O),$=O.levelController=new p.default(O),I=new y.FragmentTracker(O),B=O.streamController=new E.default(O,I),X=[$,B],Q=P.audioStreamController;Q&&X.push(new Q(O,I)),O.networkControllers=X;var J=[ee,q,z,F,G,V,W,U,I];if(Q=P.audioTrackController,Q){var ne=new Q(O);O.audioTrackController=ne,J.push(ne)}if(Q=P.subtitleTrackController,Q){var ae=new Q(O);O.subtitleTrackController=ae,X.push(ae)}if(Q=P.emeController,Q){var Z=new Q(O);O.emeController=Z,J.push(Z)}return Q=P.subtitleStreamController,Q&&X.push(new Q(O,I)),Q=P.timelineController,Q&&J.push(new Q(O)),O.coreComponents=J,O}return Object.defineProperty(w,"version",{get:function(){return"0.12.4"},enumerable:!0,configurable:!0}),w.isSupported=function(){return g.isSupported()},Object.defineProperty(w,"Events",{get:function(){return R.default},enumerable:!0,configurable:!0}),Object.defineProperty(w,"ErrorTypes",{get:function(){return u.ErrorTypes},enumerable:!0,configurable:!0}),Object.defineProperty(w,"ErrorDetails",{get:function(){return u.ErrorDetails},enumerable:!0,configurable:!0}),Object.defineProperty(w,"DefaultConfig",{get:function(){return w.defaultConfig?w.defaultConfig:C.hlsDefaultConfig},set:function(P){w.defaultConfig=P},enumerable:!0,configurable:!0}),w.prototype.destroy=function(){x.logger.log("destroy"),this.trigger(R.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach(function(P){P.destroy()}),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1},w.prototype.attachMedia=function(P){x.logger.log("attachMedia"),this.media=P,this.trigger(R.default.MEDIA_ATTACHING,{media:P})},w.prototype.detachMedia=function(){x.logger.log("detachMedia"),this.trigger(R.default.MEDIA_DETACHING),this.media=null},w.prototype.loadSource=function(P){P=l.buildAbsoluteURL(window.location.href,P,{alwaysNormalize:!0}),x.logger.log("loadSource:"+P),this.url=P,this.trigger(R.default.MANIFEST_LOADING,{url:P})},w.prototype.startLoad=function(P){P===void 0&&(P=-1),x.logger.log("startLoad("+P+")"),this.networkControllers.forEach(function(O){O.startLoad(P)})},w.prototype.stopLoad=function(){x.logger.log("stopLoad"),this.networkControllers.forEach(function(P){P.stopLoad()})},w.prototype.swapAudioCodec=function(){x.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},w.prototype.recoverMediaError=function(){x.logger.log("recoverMediaError");var P=this.media;this.detachMedia(),this.attachMedia(P)},Object.defineProperty(w.prototype,"levels",{get:function(){return this.levelController.levels},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"currentLevel",{get:function(){return this.streamController.currentLevel},set:function(P){x.logger.log("set currentLevel:"+P),this.loadLevel=P,this.streamController.immediateLevelSwitch()},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"nextLevel",{get:function(){return this.streamController.nextLevel},set:function(P){x.logger.log("set nextLevel:"+P),this.levelController.manualLevel=P,this.streamController.nextLevelSwitch()},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"loadLevel",{get:function(){return this.levelController.level},set:function(P){x.logger.log("set loadLevel:"+P),this.levelController.manualLevel=P},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"nextLoadLevel",{get:function(){return this.levelController.nextLoadLevel},set:function(P){this.levelController.nextLoadLevel=P},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"firstLevel",{get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(P){x.logger.log("set firstLevel:"+P),this.levelController.firstLevel=P},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"startLevel",{get:function(){return this.levelController.startLevel},set:function(P){x.logger.log("set startLevel:"+P);var O=this;P!==-1&&(P=Math.max(P,O.minAutoLevel)),O.levelController.startLevel=P},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"autoLevelCapping",{get:function(){return this._autoLevelCapping},set:function(P){x.logger.log("set autoLevelCapping:"+P),this._autoLevelCapping=P},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"autoLevelEnabled",{get:function(){return this.levelController.manualLevel===-1},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"manualLevel",{get:function(){return this.levelController.manualLevel},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"minAutoLevel",{get:function(){for(var P=this,O=P.levels,k=P.config.minAutoBitrate,D=O?O.length:0,F=0;F<D;F++){var G=O[F].realBitrate?Math.max(O[F].realBitrate,O[F].bitrate):O[F].bitrate;if(G>k)return F}return 0},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"maxAutoLevel",{get:function(){var P=this,O=P.levels,k=P.autoLevelCapping,D;return k===-1&&O&&O.length?D=O.length-1:D=k,D},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"nextAutoLevel",{get:function(){var P=this;return Math.min(Math.max(P.abrController.nextAutoLevel,P.minAutoLevel),P.maxAutoLevel)},set:function(P){var O=this;O.abrController.nextAutoLevel=Math.max(O.minAutoLevel,P)},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"audioTracks",{get:function(){var P=this.audioTrackController;return P?P.audioTracks:[]},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"audioTrack",{get:function(){var P=this.audioTrackController;return P?P.audioTrack:-1},set:function(P){var O=this.audioTrackController;O&&(O.audioTrack=P)},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"liveSyncPosition",{get:function(){return this.streamController.liveSyncPosition},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"subtitleTracks",{get:function(){var P=this.subtitleTrackController;return P?P.subtitleTracks:[]},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"subtitleTrack",{get:function(){var P=this.subtitleTrackController;return P?P.subtitleTrack:-1},set:function(P){var O=this.subtitleTrackController;O&&(O.subtitleTrack=P)},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"subtitleDisplay",{get:function(){var P=this.subtitleTrackController;return P?P.subtitleDisplay:!1},set:function(P){var O=this.subtitleTrackController;O&&(O.subtitleDisplay=P)},enumerable:!0,configurable:!0}),w}(S.Observer);t.default=A},"./src/is-supported.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/mediasource-helper.js");function l(){var u=a.getMediaSource(),f=window.SourceBuffer||window.WebKitSourceBuffer,d=u&&typeof u.isTypeSupported=="function"&&u.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),h=!f||f.prototype&&typeof f.prototype.appendBuffer=="function"&&typeof f.prototype.remove=="function";return!!d&&!!h}t.isSupported=l},"./src/loader/fragment-loader.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,_){p.__proto__=_}||function(p,_){for(var g in _)_.hasOwnProperty(g)&&(p[g]=_[g])};return function(p,_){E(p,_);function g(){this.constructor=p}p.prototype=_===null?Object.create(_):(g.prototype=_.prototype,new g)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/errors.js"),h=n("./src/utils/logger.js"),y=function(E){l(p,E);function p(_){var g=E.call(this,_,u.default.FRAG_LOADING)||this;return g.loaders={},g}return p.prototype.destroy=function(){var _=this.loaders;for(var g in _){var x=_[g];x&&x.destroy()}this.loaders={},E.prototype.destroy.call(this)},p.prototype.onFragLoading=function(_){var g=_.frag,x=g.type,C=this.loaders,R=this.hls.config,S=R.fLoader,A=R.loader;g.loaded=0;var T=C[x];T&&(h.logger.warn("abort previous fragment loader for type: "+x),T.abort()),T=C[x]=g.loader=R.fLoader?new S(R):new A(R);var w,P,O;w={url:g.url,frag:g,responseType:"arraybuffer",progressData:!1};var k=g.byteRangeStartOffset,D=g.byteRangeEndOffset;a.isFinite(k)&&a.isFinite(D)&&(w.rangeStart=k,w.rangeEnd=D),P={timeout:R.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:R.fragLoadingMaxRetryTimeout},O={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},T.load(w,P,O)},p.prototype.loadsuccess=function(_,g,x,C){C===void 0&&(C=null);var R=_.data,S=x.frag;S.loader=void 0,this.loaders[S.type]=void 0,this.hls.trigger(u.default.FRAG_LOADED,{payload:R,frag:S,stats:g,networkDetails:C})},p.prototype.loaderror=function(_,g,x){x===void 0&&(x=null);var C=g.frag,R=C.loader;R&&R.abort(),this.loaders[C.type]=void 0,this.hls.trigger(u.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:g.frag,response:_,networkDetails:x})},p.prototype.loadtimeout=function(_,g,x){x===void 0&&(x=null);var C=g.frag,R=C.loader;R&&R.abort(),this.loaders[C.type]=void 0,this.hls.trigger(u.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:g.frag,networkDetails:x})},p.prototype.loadprogress=function(_,g,x,C){C===void 0&&(C=null);var R=g.frag;R.loaded=_.loaded,this.hls.trigger(u.default.FRAG_LOAD_PROGRESS,{frag:R,stats:_,networkDetails:C})},p}(f.default);t.default=y}).call(this,n("./src/polyfills/number.js").Number)},"./src/loader/fragment.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./node_modules/url-toolkit/src/url-toolkit.js"),u=n("./src/loader/level-key.js"),f=function(){function d(){var h;this._url=null,this._byteRange=null,this._decryptdata=null,this.tagList=[],this.programDateTime=null,this.rawProgramDateTime=null,this._elementaryStreams=(h={},h[d.ElementaryStreamTypes.AUDIO]=!1,h[d.ElementaryStreamTypes.VIDEO]=!1,h)}return Object.defineProperty(d,"ElementaryStreamTypes",{get:function(){return{AUDIO:"audio",VIDEO:"video"}},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"url",{get:function(){return!this._url&&this.relurl&&(this._url=l.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(h){this._url=h},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"byteRange",{get:function(){if(!this._byteRange&&!this.rawByteRange)return[];if(this._byteRange)return this._byteRange;var h=[];if(this.rawByteRange){var y=this.rawByteRange.split("@",2);if(y.length===1){var E=this.lastByteRangeEndOffset;h[0]=E||0}else h[0]=parseInt(y[1]);h[1]=parseInt(y[0])+h[0],this._byteRange=h}return h},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"byteRangeStartOffset",{get:function(){return this.byteRange[0]},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"byteRangeEndOffset",{get:function(){return this.byteRange[1]},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"decryptdata",{get:function(){return this._decryptdata||(this._decryptdata=this.fragmentDecryptdataFromLevelkey(this.levelkey,this.sn)),this._decryptdata},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"endProgramDateTime",{get:function(){if(!a.isFinite(this.programDateTime))return null;var h=a.isFinite(this.duration)?this.duration:0;return this.programDateTime+h*1e3},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"encrypted",{get:function(){return!!(this.decryptdata&&this.decryptdata.uri!==null&&this.decryptdata.key===null)},enumerable:!0,configurable:!0}),d.prototype.addElementaryStream=function(h){this._elementaryStreams[h]=!0},d.prototype.hasElementaryStream=function(h){return this._elementaryStreams[h]===!0},d.prototype.createInitializationVector=function(h){for(var y=new Uint8Array(16),E=12;E<16;E++)y[E]=h>>8*(15-E)&255;return y},d.prototype.fragmentDecryptdataFromLevelkey=function(h,y){var E=h;return h&&h.method&&h.uri&&!h.iv&&(E=new u.default,E.method=h.method,E.baseuri=h.baseuri,E.reluri=h.reluri,E.iv=this.createInitializationVector(y)),E},d}();t.default=f}).call(this,n("./src/polyfills/number.js").Number)},"./src/loader/key-loader.js":function(r,t,n){var a=this&&this.__extends||function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,p){E.__proto__=p}||function(E,p){for(var _ in p)p.hasOwnProperty(_)&&(E[_]=p[_])};return function(E,p){y(E,p);function _(){this.constructor=E}E.prototype=p===null?Object.create(p):(_.prototype=p.prototype,new _)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/event-handler.js"),f=n("./src/errors.js"),d=n("./src/utils/logger.js"),h=function(y){a(E,y);function E(p){var _=y.call(this,p,l.default.KEY_LOADING)||this;return _.loaders={},_.decryptkey=null,_.decrypturl=null,_}return E.prototype.destroy=function(){for(var p in this.loaders){var _=this.loaders[p];_&&_.destroy()}this.loaders={},u.default.prototype.destroy.call(this)},E.prototype.onKeyLoading=function(p){var _=p.frag,g=_.type,x=this.loaders[g],C=_.decryptdata,R=C.uri;if(R!==this.decrypturl||this.decryptkey===null){var S=this.hls.config;x&&(d.logger.warn("abort previous key loader for type:"+g),x.abort()),_.loader=this.loaders[g]=new S.loader(S),this.decrypturl=R,this.decryptkey=null;var A=void 0,T=void 0,w=void 0;A={url:R,frag:_,responseType:"arraybuffer"},T={timeout:S.fragLoadingTimeOut,maxRetry:0,retryDelay:S.fragLoadingRetryDelay,maxRetryDelay:S.fragLoadingMaxRetryTimeout},w={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},_.loader.load(A,T,w)}else this.decryptkey&&(C.key=this.decryptkey,this.hls.trigger(l.default.KEY_LOADED,{frag:_}))},E.prototype.loadsuccess=function(p,_,g){var x=g.frag;this.decryptkey=x.decryptdata.key=new Uint8Array(p.data),x.loader=void 0,this.loaders[x.type]=void 0,this.hls.trigger(l.default.KEY_LOADED,{frag:x})},E.prototype.loaderror=function(p,_){var g=_.frag,x=g.loader;x&&x.abort(),this.loaders[_.type]=void 0,this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:g,response:p})},E.prototype.loadtimeout=function(p,_){var g=_.frag,x=g.loader;x&&x.abort(),this.loaders[_.type]=void 0,this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:g})},E}(u.default);t.default=h},"./src/loader/level-key.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./node_modules/url-toolkit/src/url-toolkit.js"),l=function(){function u(){this.method=null,this.key=null,this.iv=null,this._uri=null}return Object.defineProperty(u.prototype,"uri",{get:function(){return!this._uri&&this.reluri&&(this._uri=a.buildAbsoluteURL(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri},enumerable:!0,configurable:!0}),u}();t.default=l},"./src/loader/level.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function u(f){this.endCC=0,this.endSN=0,this.fragments=[],this.initSegment=null,this.live=!0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=f,this.version=null}return Object.defineProperty(u.prototype,"hasProgramDateTime",{get:function(){return!!(this.fragments[0]&&a.isFinite(this.fragments[0].programDateTime))},enumerable:!0,configurable:!0}),u}();t.default=l}).call(this,n("./src/polyfills/number.js").Number)},"./src/loader/m3u8-parser.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./node_modules/url-toolkit/src/url-toolkit.js"),u=n("./src/loader/fragment.js"),f=n("./src/loader/level.js"),d=n("./src/loader/level-key.js"),h=n("./src/utils/attr-list.js"),y=n("./src/utils/logger.js"),E=n("./src/utils/codecs.js"),p=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,_=/#EXT-X-MEDIA:(.*)/g,g=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),x=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,C=/\.(mp4|m4s|m4v|m4a)$/i,R=function(){function T(){}return T.findGroup=function(w,P){if(!w)return null;for(var O=null,k=0;k<w.length;k++){var D=w[k];D.id===P&&(O=D)}return O},T.convertAVC1ToAVCOTI=function(w){var P,O=w.split(".");return O.length>2?(P=O.shift()+".",P+=parseInt(O.shift()).toString(16),P+=("000"+parseInt(O.shift()).toString(16)).substr(-4)):P=w,P},T.resolve=function(w,P){return l.buildAbsoluteURL(P,w,{alwaysNormalize:!0})},T.parseMasterPlaylist=function(w,P){var O=[],k;p.lastIndex=0;function D(W,ee){["video","audio"].forEach(function(q){var z=W.filter(function($){return E.isCodecType($,q)});if(z.length){var U=z.filter(function($){return $.lastIndexOf("avc1",0)===0||$.lastIndexOf("mp4a",0)===0});ee[q+"Codec"]=U.length>0?U[0]:z[0],W=W.filter(function($){return z.indexOf($)===-1})}}),ee.unknownCodecs=W}for(;(k=p.exec(w))!=null;){var F={},G=F.attrs=new h.default(k[1]);F.url=T.resolve(k[2],P);var V=G.decimalResolution("RESOLUTION");V&&(F.width=V.width,F.height=V.height),F.bitrate=G.decimalInteger("AVERAGE-BANDWIDTH")||G.decimalInteger("BANDWIDTH"),F.name=G.NAME,D([].concat((G.CODECS||"").split(/[ ,]+/)),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=T.convertAVC1ToAVCOTI(F.videoCodec)),O.push(F)}return O},T.parseMasterPlaylistMedia=function(w,P,O,k){k===void 0&&(k=[]);var D,F=[],G=0;for(_.lastIndex=0;(D=_.exec(w))!==null;){var V={},W=new h.default(D[1]);if(W.TYPE===O){if(V.groupId=W["GROUP-ID"],V.name=W.NAME,V.type=O,V.default=W.DEFAULT==="YES",V.autoselect=W.AUTOSELECT==="YES",V.forced=W.FORCED==="YES",W.URI&&(V.url=T.resolve(W.URI,P)),V.lang=W.LANGUAGE,V.name||(V.name=V.lang),k.length){var ee=T.findGroup(k,V.groupId);V.audioCodec=ee?ee.codec:k[0].codec}V.id=G++,F.push(V)}}return F},T.parseLevelPlaylist=function(w,P,O,k,D){var F=0,G=0,V=new f.default(P),W=new d.default,ee=0,q=null,z=new u.default,U,$,I=null;for(g.lastIndex=0;(U=g.exec(w))!==null;){var B=U[1];if(B){z.duration=parseFloat(B);var X=(" "+U[2]).slice(1);z.title=X||null,z.tagList.push(X?["INF",B,X]:["INF",B])}else if(U[3]){if(a.isFinite(z.duration)){var Q=F++;z.type=k,z.start=G,z.levelkey=W,z.sn=Q,z.level=O,z.cc=ee,z.urlId=D,z.baseurl=P,z.relurl=(" "+U[3]).slice(1),A(z,q),V.fragments.push(z),q=z,G+=z.duration,z=new u.default}}else if(U[4]){if(z.rawByteRange=(" "+U[4]).slice(1),q){var J=q.byteRangeEndOffset;J&&(z.lastByteRangeEndOffset=J)}}else if(U[5])z.rawProgramDateTime=(" "+U[5]).slice(1),z.tagList.push(["PROGRAM-DATE-TIME",z.rawProgramDateTime]),I===null&&(I=V.fragments.length);else{for(U=U[0].match(x),$=1;$<U.length&&U[$]===void 0;$++);var ne=(" "+U[$+1]).slice(1),ae=(" "+U[$+2]).slice(1);switch(U[$]){case"#":z.tagList.push(ae?[ne,ae]:[ne]);break;case"PLAYLIST-TYPE":V.type=ne.toUpperCase();break;case"MEDIA-SEQUENCE":F=V.startSN=parseInt(ne);break;case"TARGETDURATION":V.targetduration=parseFloat(ne);break;case"VERSION":V.version=parseInt(ne);break;case"EXTM3U":break;case"ENDLIST":V.live=!1;break;case"DIS":ee++,z.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":ee=parseInt(ne);break;case"KEY":var Z=ne,se=new h.default(Z),oe=se.enumeratedString("METHOD"),fe=se.URI,de=se.hexadecimalInteger("IV");oe&&(W=new d.default,fe&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(oe)>=0&&(W.method=oe,W.baseuri=P,W.reluri=fe,W.key=null,W.iv=de));break;case"START":var ce=ne,Ee=new h.default(ce),De=Ee.decimalFloatingPoint("TIME-OFFSET");a.isFinite(De)&&(V.startTimeOffset=De);break;case"MAP":var we=new h.default(ne);z.relurl=we.URI,z.rawByteRange=we.BYTERANGE,z.baseurl=P,z.level=O,z.type=k,z.sn="initSegment",V.initSegment=z,z=new u.default,z.rawProgramDateTime=V.initSegment.rawProgramDateTime;break;default:y.logger.warn("line parsed but not handled: "+U);break}}}return z=q,z&&!z.relurl&&(V.fragments.pop(),G-=z.duration),V.totalduration=G,V.averagetargetduration=G/V.fragments.length,V.endSN=F-1,V.startCC=V.fragments[0]?V.fragments[0].cc:0,V.endCC=ee,!V.initSegment&&V.fragments.length&&V.fragments.every(function(He){return C.test(He.relurl)})&&(y.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),z=new u.default,z.relurl=V.fragments[0].relurl,z.baseurl=P,z.level=O,z.type=k,z.sn="initSegment",V.initSegment=z,V.needSidxRanges=!0),I&&S(V.fragments,I),V},T}();t.default=R;function S(T,w){for(var P=T[w],O=w-1;O>=0;O--){var k=T[O];k.programDateTime=P.programDateTime-k.duration*1e3,P=k}}function A(T,w){T.rawProgramDateTime?T.programDateTime=Date.parse(T.rawProgramDateTime):w&&w.programDateTime&&(T.programDateTime=w.endProgramDateTime),a.isFinite(T.programDateTime)||(T.programDateTime=null,T.rawProgramDateTime=null)}}).call(this,n("./src/polyfills/number.js").Number)},"./src/loader/playlist-loader.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(R,S){R.__proto__=S}||function(R,S){for(var A in S)S.hasOwnProperty(A)&&(R[A]=S[A])};return function(R,S){C(R,S);function A(){this.constructor=R}R.prototype=S===null?Object.create(S):(A.prototype=S.prototype,new A)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/errors.js"),h=n("./src/utils/logger.js"),y=n("./src/demux/mp4demuxer.js"),E=n("./src/loader/m3u8-parser.js"),p=window.performance,_={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},g={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},x=function(C){l(R,C);function R(S){var A=C.call(this,S,u.default.MANIFEST_LOADING,u.default.LEVEL_LOADING,u.default.AUDIO_TRACK_LOADING,u.default.SUBTITLE_TRACK_LOADING)||this;return A.loaders={},A}return Object.defineProperty(R,"ContextType",{get:function(){return _},enumerable:!0,configurable:!0}),Object.defineProperty(R,"LevelType",{get:function(){return g},enumerable:!0,configurable:!0}),R.canHaveQualityLevels=function(S){return S!==_.AUDIO_TRACK&&S!==_.SUBTITLE_TRACK},R.mapContextToLevelType=function(S){var A=S.type;switch(A){case _.AUDIO_TRACK:return g.AUDIO;case _.SUBTITLE_TRACK:return g.SUBTITLE;default:return g.MAIN}},R.getResponseUrl=function(S,A){var T=S.url;return(T===void 0||T.indexOf("data:")===0)&&(T=A.url),T},R.prototype.createInternalLoader=function(S){var A=this.hls.config,T=A.pLoader,w=A.loader,P=T||w,O=new P(A);return S.loader=O,this.loaders[S.type]=O,O},R.prototype.getInternalLoader=function(S){return this.loaders[S.type]},R.prototype.resetInternalLoader=function(S){this.loaders[S]&&delete this.loaders[S]},R.prototype.destroyInternalLoaders=function(){for(var S in this.loaders){var A=this.loaders[S];A&&A.destroy(),this.resetInternalLoader(S)}},R.prototype.destroy=function(){this.destroyInternalLoaders(),C.prototype.destroy.call(this)},R.prototype.onManifestLoading=function(S){this.load(S.url,{type:_.MANIFEST,level:0,id:null})},R.prototype.onLevelLoading=function(S){this.load(S.url,{type:_.LEVEL,level:S.level,id:S.id})},R.prototype.onAudioTrackLoading=function(S){this.load(S.url,{type:_.AUDIO_TRACK,level:null,id:S.id})},R.prototype.onSubtitleTrackLoading=function(S){this.load(S.url,{type:_.SUBTITLE_TRACK,level:null,id:S.id})},R.prototype.load=function(S,A){var T=this.hls.config;h.logger.debug("Loading playlist of type "+A.type+", level: "+A.level+", id: "+A.id);var w=this.getInternalLoader(A);if(w){var P=w.context;if(P&&P.url===S)return h.logger.trace("playlist request ongoing"),!1;h.logger.warn("aborting previous loader for type: "+A.type),w.abort()}var O,k,D,F;switch(A.type){case _.MANIFEST:O=T.manifestLoadingMaxRetry,k=T.manifestLoadingTimeOut,D=T.manifestLoadingRetryDelay,F=T.manifestLoadingMaxRetryTimeout;break;case _.LEVEL:O=0,k=T.levelLoadingTimeOut;break;default:O=T.levelLoadingMaxRetry,k=T.levelLoadingTimeOut,D=T.levelLoadingRetryDelay,F=T.levelLoadingMaxRetryTimeout;break}w=this.createInternalLoader(A),A.url=S,A.responseType=A.responseType||"";var G={timeout:k,maxRetry:O,retryDelay:D,maxRetryDelay:F},V={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return h.logger.debug("Calling internal loader delegate for URL: "+S),w.load(A,G,V),!0},R.prototype.loadsuccess=function(S,A,T,w){if(w===void 0&&(w=null),T.isSidxRequest){this._handleSidxRequest(S,T),this._handlePlaylistLoaded(S,A,T,w);return}this.resetInternalLoader(T.type);var P=S.data;if(A.tload=p.now(),P.indexOf("#EXTM3U")!==0){this._handleManifestParsingError(S,T,"no EXTM3U delimiter",w);return}P.indexOf("#EXTINF:")>0||P.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(S,A,T,w):this._handleMasterPlaylist(S,A,T,w)},R.prototype.loaderror=function(S,A,T){T===void 0&&(T=null),this._handleNetworkError(A,T,!1,S)},R.prototype.loadtimeout=function(S,A,T){T===void 0&&(T=null),this._handleNetworkError(A,T,!0)},R.prototype._handleMasterPlaylist=function(S,A,T,w){var P=this.hls,O=S.data,k=R.getResponseUrl(S,T),D=E.default.parseMasterPlaylist(O,k);if(!D.length){this._handleManifestParsingError(S,T,"no level found in manifest",w);return}var F=D.map(function(ee){return{id:ee.attrs.AUDIO,codec:ee.audioCodec}}),G=E.default.parseMasterPlaylistMedia(O,k,"AUDIO",F),V=E.default.parseMasterPlaylistMedia(O,k,"SUBTITLES");if(G.length){var W=!1;G.forEach(function(ee){ee.url||(W=!0)}),W===!1&&D[0].audioCodec&&!D[0].attrs.AUDIO&&(h.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),G.unshift({type:"main",name:"main"}))}P.trigger(u.default.MANIFEST_LOADED,{levels:D,audioTracks:G,subtitles:V,url:k,stats:A,networkDetails:w})},R.prototype._handleTrackOrLevelPlaylist=function(S,A,T,w){var P=this.hls,O=T.id,k=T.level,D=T.type,F=R.getResponseUrl(S,T),G=a.isFinite(O)?O:0,V=a.isFinite(k)?k:G,W=R.mapContextToLevelType(T),ee=E.default.parseLevelPlaylist(S.data,F,V,W,G);if(ee.tload=A.tload,D===_.MANIFEST){var q={url:F,details:ee};P.trigger(u.default.MANIFEST_LOADED,{levels:[q],audioTracks:[],url:F,stats:A,networkDetails:w})}if(A.tparsed=p.now(),ee.needSidxRanges){var z=ee.initSegment.url;this.load(z,{isSidxRequest:!0,type:D,level:k,levelDetails:ee,id:O,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"});return}T.levelDetails=ee,this._handlePlaylistLoaded(S,A,T,w)},R.prototype._handleSidxRequest=function(S,A){var T=y.default.parseSegmentIndex(new Uint8Array(S.data));if(T){var w=T.references,P=A.levelDetails;w.forEach(function(O,k){var D=O.info,F=P.fragments[k];F.byteRange.length===0&&(F.rawByteRange=String(1+D.end-D.start)+"@"+String(D.start))}),P.initSegment.rawByteRange=String(T.moovEndOffset)+"@0"}},R.prototype._handleManifestParsingError=function(S,A,T,w){this.hls.trigger(u.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:S.url,reason:T,networkDetails:w})},R.prototype._handleNetworkError=function(S,A,T,w){T===void 0&&(T=!1),w===void 0&&(w=null),h.logger.info("A network error occured while loading a "+S.type+"-type playlist");var P,O,k=this.getInternalLoader(S);switch(S.type){case _.MANIFEST:P=T?d.ErrorDetails.MANIFEST_LOAD_TIMEOUT:d.ErrorDetails.MANIFEST_LOAD_ERROR,O=!0;break;case _.LEVEL:P=T?d.ErrorDetails.LEVEL_LOAD_TIMEOUT:d.ErrorDetails.LEVEL_LOAD_ERROR,O=!1;break;case _.AUDIO_TRACK:P=T?d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,O=!1;break;default:O=!1}k&&(k.abort(),this.resetInternalLoader(S.type));var D={type:d.ErrorTypes.NETWORK_ERROR,details:P,fatal:O,url:k.url,loader:k,context:S,networkDetails:A};w&&(D.response=w),this.hls.trigger(u.default.ERROR,D)},R.prototype._handlePlaylistLoaded=function(S,A,T,w){var P=T.type,O=T.level,k=T.id,D=T.levelDetails;if(!D.targetduration){this._handleManifestParsingError(S,T,"invalid target duration",w);return}var F=R.canHaveQualityLevels(T.type);if(F)this.hls.trigger(u.default.LEVEL_LOADED,{details:D,level:O||0,id:k||0,stats:A,networkDetails:w});else switch(P){case _.AUDIO_TRACK:this.hls.trigger(u.default.AUDIO_TRACK_LOADED,{details:D,id:k,stats:A,networkDetails:w});break;case _.SUBTITLE_TRACK:this.hls.trigger(u.default.SUBTITLE_TRACK_LOADED,{details:D,id:k,stats:A,networkDetails:w});break}},R}(f.default);t.default=x}).call(this,n("./src/polyfills/number.js").Number)},"./src/observer.js":function(r,t,n){var a=this&&this.__extends||function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,h){d.__proto__=h}||function(d,h){for(var y in h)h.hasOwnProperty(y)&&(d[y]=h[y])};return function(d,h){f(d,h);function y(){this.constructor=d}d.prototype=h===null?Object.create(h):(y.prototype=h.prototype,new y)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./node_modules/eventemitter3/index.js"),u=function(f){a(d,f);function d(){return f!==null&&f.apply(this,arguments)||this}return d.prototype.trigger=function(h){for(var y=[],E=1;E<arguments.length;E++)y[E-1]=arguments[E];this.emit.apply(this,[h,h].concat(y))},d}(l.EventEmitter);t.Observer=u},"./src/polyfills/number.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/get-self-scope.js"),l=a.getSelfScope(),u=l.Number;t.Number=u,u.isFinite=u.isFinite||function(f){return typeof f=="number"&&isFinite(f)}},"./src/remux/aac-helper.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(){}return l.getSilentFrame=function(u,f){switch(u){case"mp4a.40.2":if(f===1)return new Uint8Array([0,200,0,128,35,128]);if(f===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(f===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(f===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(f===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(f===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(f===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(f===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(f===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return null},l}();t.default=a},"./src/remux/mp4-generator.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=Math.pow(2,32)-1,l=function(){function u(){}return u.init=function(){u.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var f;for(f in u.types)u.types.hasOwnProperty(f)&&(u.types[f]=[f.charCodeAt(0),f.charCodeAt(1),f.charCodeAt(2),f.charCodeAt(3)]);var d=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),h=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);u.HDLR_TYPES={video:d,audio:h};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),E=new Uint8Array([0,0,0,0,0,0,0,0]);u.STTS=u.STSC=u.STCO=E,u.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),u.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),u.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),u.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var p=new Uint8Array([105,115,111,109]),_=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);u.FTYP=u.box(u.types.ftyp,p,g,p,_),u.DINF=u.box(u.types.dinf,u.box(u.types.dref,y))},u.box=function(f){for(var d=Array.prototype.slice.call(arguments,1),h=8,y=d.length,E=y,p;y--;)h+=d[y].byteLength;for(p=new Uint8Array(h),p[0]=h>>24&255,p[1]=h>>16&255,p[2]=h>>8&255,p[3]=h&255,p.set(f,4),y=0,h=8;y<E;y++)p.set(d[y],h),h+=d[y].byteLength;return p},u.hdlr=function(f){return u.box(u.types.hdlr,u.HDLR_TYPES[f])},u.mdat=function(f){return u.box(u.types.mdat,f)},u.mdhd=function(f,d){d*=f;var h=Math.floor(d/(a+1)),y=Math.floor(d%(a+1));return u.box(u.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,f>>24&255,f>>16&255,f>>8&255,f&255,h>>24,h>>16&255,h>>8&255,h&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},u.mdia=function(f){return u.box(u.types.mdia,u.mdhd(f.timescale,f.duration),u.hdlr(f.type),u.minf(f))},u.mfhd=function(f){return u.box(u.types.mfhd,new Uint8Array([0,0,0,0,f>>24,f>>16&255,f>>8&255,f&255]))},u.minf=function(f){return f.type==="audio"?u.box(u.types.minf,u.box(u.types.smhd,u.SMHD),u.DINF,u.stbl(f)):u.box(u.types.minf,u.box(u.types.vmhd,u.VMHD),u.DINF,u.stbl(f))},u.moof=function(f,d,h){return u.box(u.types.moof,u.mfhd(f),u.traf(h,d))},u.moov=function(f){for(var d=f.length,h=[];d--;)h[d]=u.trak(f[d]);return u.box.apply(null,[u.types.moov,u.mvhd(f[0].timescale,f[0].duration)].concat(h).concat(u.mvex(f)))},u.mvex=function(f){for(var d=f.length,h=[];d--;)h[d]=u.trex(f[d]);return u.box.apply(null,[u.types.mvex].concat(h))},u.mvhd=function(f,d){d*=f;var h=Math.floor(d/(a+1)),y=Math.floor(d%(a+1)),E=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,f>>24&255,f>>16&255,f>>8&255,f&255,h>>24,h>>16&255,h>>8&255,h&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return u.box(u.types.mvhd,E)},u.sdtp=function(f){var d=f.samples||[],h=new Uint8Array(4+d.length),y,E;for(E=0;E<d.length;E++)y=d[E].flags,h[E+4]=y.dependsOn<<4|y.isDependedOn<<2|y.hasRedundancy;return u.box(u.types.sdtp,h)},u.stbl=function(f){return u.box(u.types.stbl,u.stsd(f),u.box(u.types.stts,u.STTS),u.box(u.types.stsc,u.STSC),u.box(u.types.stsz,u.STSZ),u.box(u.types.stco,u.STCO))},u.avc1=function(f){var d=[],h=[],y,E,p;for(y=0;y<f.sps.length;y++)E=f.sps[y],p=E.byteLength,d.push(p>>>8&255),d.push(p&255),d=d.concat(Array.prototype.slice.call(E));for(y=0;y<f.pps.length;y++)E=f.pps[y],p=E.byteLength,h.push(p>>>8&255),h.push(p&255),h=h.concat(Array.prototype.slice.call(E));var _=u.box(u.types.avcC,new Uint8Array([1,d[3],d[4],d[5],255,224|f.sps.length].concat(d).concat([f.pps.length]).concat(h))),g=f.width,x=f.height,C=f.pixelRatio[0],R=f.pixelRatio[1];return u.box(u.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,g>>8&255,g&255,x>>8&255,x&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),_,u.box(u.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),u.box(u.types.pasp,new Uint8Array([C>>24,C>>16&255,C>>8&255,C&255,R>>24,R>>16&255,R>>8&255,R&255])))},u.esds=function(f){var d=f.config.length;return new Uint8Array([0,0,0,0,3,23+d,0,1,0,4,15+d,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([d]).concat(f.config).concat([6,1,2]))},u.mp4a=function(f){var d=f.samplerate;return u.box(u.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,f.channelCount,0,16,0,0,0,0,d>>8&255,d&255,0,0]),u.box(u.types.esds,u.esds(f)))},u.mp3=function(f){var d=f.samplerate;return u.box(u.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,f.channelCount,0,16,0,0,0,0,d>>8&255,d&255,0,0]))},u.stsd=function(f){return f.type==="audio"?!f.isAAC&&f.codec==="mp3"?u.box(u.types.stsd,u.STSD,u.mp3(f)):u.box(u.types.stsd,u.STSD,u.mp4a(f)):u.box(u.types.stsd,u.STSD,u.avc1(f))},u.tkhd=function(f){var d=f.id,h=f.duration*f.timescale,y=f.width,E=f.height,p=Math.floor(h/(a+1)),_=Math.floor(h%(a+1));return u.box(u.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,d>>24&255,d>>16&255,d>>8&255,d&255,0,0,0,0,p>>24,p>>16&255,p>>8&255,p&255,_>>24,_>>16&255,_>>8&255,_&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,E>>8&255,E&255,0,0]))},u.traf=function(f,d){var h=u.sdtp(f),y=f.id,E=Math.floor(d/(a+1)),p=Math.floor(d%(a+1));return u.box(u.types.traf,u.box(u.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),u.box(u.types.tfdt,new Uint8Array([1,0,0,0,E>>24,E>>16&255,E>>8&255,E&255,p>>24,p>>16&255,p>>8&255,p&255])),u.trun(f,h.length+16+20+8+16+8+8),h)},u.trak=function(f){return f.duration=f.duration||4294967295,u.box(u.types.trak,u.tkhd(f),u.mdia(f))},u.trex=function(f){var d=f.id;return u.box(u.types.trex,new Uint8Array([0,0,0,0,d>>24,d>>16&255,d>>8&255,d&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},u.trun=function(f,d){var h=f.samples||[],y=h.length,E=12+16*y,p=new Uint8Array(E),_,g,x,C,R,S;for(d+=8+E,p.set([0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255],0),_=0;_<y;_++)g=h[_],x=g.duration,C=g.size,R=g.flags,S=g.cts,p.set([x>>>24&255,x>>>16&255,x>>>8&255,x&255,C>>>24&255,C>>>16&255,C>>>8&255,C&255,R.isLeading<<2|R.dependsOn,R.isDependedOn<<6|R.hasRedundancy<<4|R.paddingValue<<1|R.isNonSync,R.degradPrio&61440,R.degradPrio&15,S>>>24&255,S>>>16&255,S>>>8&255,S&255],12+16*_);return u.box(u.types.trun,p)},u.initSegment=function(f){u.types||u.init();var d=u.moov(f),h;return h=new Uint8Array(u.FTYP.byteLength+d.byteLength),h.set(u.FTYP),h.set(d,u.FTYP.byteLength),h},u}();t.default=l},"./src/remux/mp4-remuxer.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/remux/aac-helper.js"),l=n("./src/remux/mp4-generator.js"),u=n("./src/events.js"),f=n("./src/errors.js"),d=n("./src/utils/logger.js"),h=10*1e3,y=function(){function E(p,_,g,x){this.observer=p,this.config=_,this.typeSupported=g;var C=navigator.userAgent;this.isSafari=x&&x.indexOf("Apple")>-1&&C&&!C.match("CriOS"),this.ISGenerated=!1}return E.prototype.destroy=function(){},E.prototype.resetTimeStamp=function(p){this._initPTS=this._initDTS=p},E.prototype.resetInitSegment=function(){this.ISGenerated=!1},E.prototype.remux=function(p,_,g,x,C,R,S){if(this.ISGenerated||this.generateIS(p,_,C),this.ISGenerated){var A=p.samples.length,T=_.samples.length,w=C,P=C;if(A&&T){var O=(p.samples[0].pts-_.samples[0].pts)/_.inputTimeScale;w+=Math.max(0,O),P+=Math.max(0,-O)}if(A){p.timescale||(d.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(p,_,C));var k=this.remuxAudio(p,w,R,S);if(T){var D=void 0;k&&(D=k.endPTS-k.startPTS),_.timescale||(d.logger.warn("regenerate InitSegment as video detected"),this.generateIS(p,_,C)),this.remuxVideo(_,P,R,D,S)}}else if(T){var F=this.remuxVideo(_,P,R,0,S);F&&p.codec&&this.remuxEmptyAudio(p,w,R,F)}}g.samples.length&&this.remuxID3(g,C),x.samples.length&&this.remuxText(x,C),this.observer.trigger(u.default.FRAG_PARSED)},E.prototype.generateIS=function(p,_,g){var x=this.observer,C=p.samples,R=_.samples,S=this.typeSupported,A="audio/mp4",T={},w={tracks:T},P=this._initPTS===void 0,O,k;if(P&&(O=k=1/0),p.config&&C.length&&(p.timescale=p.samplerate,d.logger.log("audio sampling rate : "+p.samplerate),p.isAAC||(S.mpeg?(A="audio/mpeg",p.codec=""):S.mp3&&(p.codec="mp3")),T.audio={container:A,codec:p.codec,initSegment:!p.isAAC&&S.mpeg?new Uint8Array:l.default.initSegment([p]),metadata:{channelCount:p.channelCount}},P&&(O=k=C[0].pts-p.inputTimeScale*g)),_.sps&&_.pps&&R.length){var D=_.inputTimeScale;_.timescale=D,T.video={container:"video/mp4",codec:_.codec,initSegment:l.default.initSegment([_]),metadata:{width:_.width,height:_.height}},P&&(O=Math.min(O,R[0].pts-D*g),k=Math.min(k,R[0].dts-D*g),this.observer.trigger(u.default.INIT_PTS_FOUND,{initPTS:O}))}Object.keys(T).length?(x.trigger(u.default.FRAG_PARSING_INIT_SEGMENT,w),this.ISGenerated=!0,P&&(this._initPTS=O,this._initDTS=k)):x.trigger(u.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},E.prototype.remuxVideo=function(p,_,g,x,C){var R=8,S,A,T,w,P,O,k,D=p.timescale,F=p.samples,G=[],V=F.length,W=this._PTSNormalize,ee=this._initPTS,q=this.nextAvcDts,z=this.isSafari;if(V!==0){z&&(g|=F.length&&q&&(C&&Math.abs(_-q/D)<.1||Math.abs(F[0].pts-q-ee)<D/5)),g||(q=_*D),F.forEach(function(et){et.pts=W(et.pts-ee,q),et.dts=W(et.dts-ee,q)}),F.sort(function(et,nt){var qt=et.dts-nt.dts,We=et.pts-nt.pts;return qt||We||et.id-nt.id});var U=F.reduce(function(et,nt){return Math.max(Math.min(et,nt.pts-nt.dts),-18e3)},0);if(U<0){d.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(U/90)+" ms to overcome this issue");for(var $=0;$<F.length;$++)F[$].dts+=U}var I=F[0];P=Math.max(I.dts,0),w=Math.max(I.pts,0);var B=Math.round((P-q)/90);g&&B&&(B>1?d.logger.log("AVC:"+B+" ms hole between fragments detected,filling it"):B<-1&&d.logger.log("AVC:"+-B+" ms overlapping between fragments detected"),P=q,F[0].dts=P,w=Math.max(w-B,q),F[0].pts=w,d.logger.log("Video/PTS/DTS adjusted: "+Math.round(w/90)+"/"+Math.round(P/90)+",delta:"+B+" ms")),I=F[F.length-1],k=Math.max(I.dts,0),O=Math.max(I.pts,0,k),z&&(S=Math.round((k-P)/(F.length-1)));for(var X=0,Q=0,$=0;$<V;$++){for(var J=F[$],ne=J.units,ae=ne.length,Z=0,se=0;se<ae;se++)Z+=ne[se].data.length;Q+=Z,X+=ae,J.length=Z,z?J.dts=P+$*S:J.dts=Math.max(J.dts,P),J.pts=Math.max(J.pts,J.dts)}var oe=Q+4*X+8;try{A=new Uint8Array(oe)}catch{this.observer.trigger(u.default.ERROR,{type:f.ErrorTypes.MUX_ERROR,details:f.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:oe,reason:"fail allocating video mdat "+oe});return}var fe=new DataView(A.buffer);fe.setUint32(0,oe),A.set(l.default.types.mdat,4);for(var $=0;$<V;$++){for(var de=F[$],ce=de.units,Ee=0,De=void 0,se=0,ae=ce.length;se<ae;se++){var we=ce[se],He=we.data,Xe=we.data.byteLength;fe.setUint32(R,Xe),R+=4,A.set(He,R),R+=Xe,Ee+=4+Xe}if(z)De=Math.max(0,S*Math.round((de.pts-de.dts)/S));else{if($<V-1)S=F[$+1].dts-de.dts;else{var Qe=this.config,dt=de.dts-F[$>0?$-1:$].dts;if(Qe.stretchShortVideoTrack){var _t=Qe.maxBufferHole,ut=Math.floor(_t*D),ft=(x?w+x*D:this.nextAudioPts)-de.pts;ft>ut?(S=ft-dt,S<0&&(S=dt),d.logger.log("It is approximately "+ft/90+" ms to the next segment; using duration "+S/90+" ms for the last video frame.")):S=dt}else S=dt}De=Math.round(de.pts-de.dts)}G.push({size:Ee,duration:S,cts:De,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:de.key?2:1,isNonSync:de.key?0:1}})}this.nextAvcDts=k+S;var Xt=p.dropped;if(p.len=0,p.nbNalu=0,p.dropped=0,G.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var kt=G[0].flags;kt.dependsOn=2,kt.isNonSync=0}p.samples=G,T=l.default.moof(p.sequenceNumber++,P,p),p.samples=[];var Ue={data1:T,data2:A,startPTS:w/D,endPTS:(O+S)/D,startDTS:P/D,endDTS:this.nextAvcDts/D,type:"video",hasAudio:!1,hasVideo:!0,nb:G.length,dropped:Xt};return this.observer.trigger(u.default.FRAG_PARSING_DATA,Ue),Ue}},E.prototype.remuxAudio=function(p,_,g,x){var C=p.inputTimeScale,R=p.timescale,S=C/R,A=p.isAAC?1024:1152,T=A*S,w=this._PTSNormalize,P=this._initPTS,O=!p.isAAC&&this.typeSupported.mpeg,k,D,F,G,V,W,ee,q=p.samples,z=[],U=this.nextAudioPts;if(g|=q.length&&U&&(x&&Math.abs(_-U/C)<.1||Math.abs(q[0].pts-U-P)<20*T),q.forEach(function(ft){ft.pts=ft.dts=w(ft.pts-P,_*C)}),q=q.filter(function(ft){return ft.pts>=0}),q.length!==0){if(g||(x?U=_*C:U=q[0].pts),p.isAAC)for(var $=this.config.maxAudioFramesDrift,I=0,B=U;I<q.length;){var X=q[I],Q,J=X.pts;Q=J-B;var ne=Math.abs(1e3*Q/C);if(Q<=-$*T)d.logger.warn("Dropping 1 audio frame @ "+(B/C).toFixed(3)+"s due to "+Math.round(ne)+" ms overlap."),q.splice(I,1),p.len-=X.unit.length;else if(Q>=$*T&&ne<h&&B){var ae=Math.round(Q/T);d.logger.warn("Injecting "+ae+" audio frame @ "+(B/C).toFixed(3)+"s due to "+Math.round(1e3*Q/C)+" ms gap.");for(var Z=0;Z<ae;Z++){var se=Math.max(B,0);F=a.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount),F||(d.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),F=X.unit.subarray()),q.splice(I,0,{unit:F,pts:se,dts:se}),p.len+=F.length,B+=T,I++}X.pts=X.dts=B,B+=T,I++}else X.pts=X.dts=B,B+=T,I++}for(var Z=0,oe=q.length;Z<oe;Z++){var fe=q[Z],de=fe.unit,J=fe.pts;if(ee!==void 0)D.duration=Math.round((J-ee)/S);else{var ce=Math.round(1e3*(J-U)/C),Ee=0;if(g&&p.isAAC&&ce){if(ce>0&&ce<h)Ee=Math.round((J-U)/T),d.logger.log(ce+" ms hole between AAC samples detected,filling it"),Ee>0&&(F=a.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount),F||(F=de.subarray()),p.len+=Ee*F.length);else if(ce<-12){d.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(U/C).toFixed(3)+"s/"+(J/C).toFixed(3)+"s/"+-ce+"ms"),p.len-=de.byteLength;continue}J=U}if(W=J,p.len>0){var De=O?p.len:p.len+8;k=O?0:8;try{G=new Uint8Array(De)}catch{this.observer.trigger(u.default.ERROR,{type:f.ErrorTypes.MUX_ERROR,details:f.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:De,reason:"fail allocating audio mdat "+De});return}if(!O){var we=new DataView(G.buffer);we.setUint32(0,De),G.set(l.default.types.mdat,4)}}else return;for(var I=0;I<Ee;I++)F=a.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount),F||(d.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),F=de.subarray()),G.set(F,k),k+=F.byteLength,D={size:F.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},z.push(D)}G.set(de,k);var He=de.byteLength;k+=He,D={size:He,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},z.push(D),ee=J}var Xe=0,Qe=z.length;if(Qe>=2&&(Xe=z[Qe-2].duration,D.duration=Xe),Qe){this.nextAudioPts=U=ee+S*Xe,p.len=0,p.samples=z,O?V=new Uint8Array:V=l.default.moof(p.sequenceNumber++,W/S,p),p.samples=[];var dt=W/C,_t=U/C,ut={data1:V,data2:G,startPTS:dt,endPTS:_t,startDTS:dt,endDTS:_t,type:"audio",hasAudio:!0,hasVideo:!1,nb:Qe};return this.observer.trigger(u.default.FRAG_PARSING_DATA,ut),ut}return null}},E.prototype.remuxEmptyAudio=function(p,_,g,x){var C=p.inputTimeScale,R=p.samplerate?p.samplerate:C,S=C/R,A=this.nextAudioPts,T=(A!==void 0?A:x.startDTS*C)+this._initDTS,w=x.endDTS*C+this._initDTS,P=1024,O=S*P,k=Math.ceil((w-T)/O),D=a.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);if(d.logger.warn("remux empty Audio"),!D){d.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!");return}for(var F=[],G=0;G<k;G++){var V=T+G*O;F.push({unit:D,pts:V,dts:V}),p.len+=D.length}p.samples=F,this.remuxAudio(p,_,g)},E.prototype.remuxID3=function(p){var _=p.samples.length,g,x=p.inputTimeScale,C=this._initPTS,R=this._initDTS;if(_){for(var S=0;S<_;S++)g=p.samples[S],g.pts=(g.pts-C)/x,g.dts=(g.dts-R)/x;this.observer.trigger(u.default.FRAG_PARSING_METADATA,{samples:p.samples})}p.samples=[]},E.prototype.remuxText=function(p){p.samples.sort(function(S,A){return S.pts-A.pts});var _=p.samples.length,g,x=p.inputTimeScale,C=this._initPTS;if(_){for(var R=0;R<_;R++)g=p.samples[R],g.pts=(g.pts-C)/x;this.observer.trigger(u.default.FRAG_PARSING_USERDATA,{samples:p.samples})}p.samples=[]},E.prototype._PTSNormalize=function(p,_){var g;if(_===void 0)return p;for(_<p?g=-8589934592:g=8589934592;Math.abs(p-_)>4294967296;)p+=g;return p},E}();t.default=y},"./src/remux/passthrough-remuxer.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/events.js"),l=function(){function u(f){this.observer=f}return u.prototype.destroy=function(){},u.prototype.resetTimeStamp=function(){},u.prototype.resetInitSegment=function(){},u.prototype.remux=function(f,d,h,y,E,p,_,g){var x=this.observer,C="";f&&(C+="audio"),d&&(C+="video"),x.trigger(a.default.FRAG_PARSING_DATA,{data1:g,startPTS:E,startDTS:E,type:C,hasAudio:!!f,hasVideo:!!d,nb:1,dropped:0}),x.trigger(a.default.FRAG_PARSED)},u}();t.default=l},"./src/task-loop.js":function(r,t,n){var a=this&&this.__extends||function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,h){d.__proto__=h}||function(d,h){for(var y in h)h.hasOwnProperty(y)&&(d[y]=h[y])};return function(d,h){f(d,h);function y(){this.constructor=d}d.prototype=h===null?Object.create(h):(y.prototype=h.prototype,new y)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/event-handler.js"),u=function(f){a(d,f);function d(h){for(var y=[],E=1;E<arguments.length;E++)y[E-1]=arguments[E];var p=f.apply(this,[h].concat(y))||this;return p._tickInterval=null,p._tickTimer=null,p._tickCallCount=0,p._boundTick=p.tick.bind(p),p}return d.prototype.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},d.prototype.hasInterval=function(){return!!this._tickInterval},d.prototype.hasNextTick=function(){return!!this._tickTimer},d.prototype.setInterval=function(h){return this._tickInterval?!1:(this._tickInterval=setInterval(this._boundTick,h),!0)},d.prototype.clearInterval=function(){return this._tickInterval?(clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},d.prototype.clearNextTick=function(){return this._tickTimer?(clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},d.prototype.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&(this.clearNextTick(),this._tickTimer=setTimeout(this._boundTick,0)),this._tickCallCount=0)},d.prototype.doTick=function(){},d}(l.default);t.default=u},"./src/utils/attr-list.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=/^(\d+)x(\d+)$/,u=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,f=function(){function d(h){typeof h=="string"&&(h=d.parseAttrList(h));for(var y in h)h.hasOwnProperty(y)&&(this[y]=h[y])}return d.prototype.decimalInteger=function(h){var y=parseInt(this[h],10);return y>a.MAX_SAFE_INTEGER?1/0:y},d.prototype.hexadecimalInteger=function(h){if(this[h]){var y=(this[h]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var E=new Uint8Array(y.length/2),p=0;p<y.length/2;p++)E[p]=parseInt(y.slice(p*2,p*2+2),16);return E}else return null},d.prototype.hexadecimalIntegerAsNumber=function(h){var y=parseInt(this[h],16);return y>a.MAX_SAFE_INTEGER?1/0:y},d.prototype.decimalFloatingPoint=function(h){return parseFloat(this[h])},d.prototype.enumeratedString=function(h){return this[h]},d.prototype.decimalResolution=function(h){var y=l.exec(this[h]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},d.parseAttrList=function(h){var y,E={};for(u.lastIndex=0;(y=u.exec(h))!==null;){var p=y[2],_='"';p.indexOf(_)===0&&p.lastIndexOf(_)===p.length-1&&(p=p.slice(1,-1)),E[y[1]]=p}return E},d}();t.default=f}).call(this,n("./src/polyfills/number.js").Number)},"./src/utils/binary-search.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={search:function(l,u){for(var f=0,d=l.length-1,h=null,y=null;f<=d;){h=(f+d)/2|0,y=l[h];var E=u(y);if(E>0)f=h+1;else if(E<0)d=h-1;else return y}return null}};t.default=a},"./src/utils/buffer-helper.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(){}return l.isBuffered=function(u,f){try{if(u){for(var d=u.buffered,h=0;h<d.length;h++)if(f>=d.start(h)&&f<=d.end(h))return!0}}catch{}return!1},l.bufferInfo=function(u,f,d){try{if(u){var h=u.buffered,y=[],E=void 0;for(E=0;E<h.length;E++)y.push({start:h.start(E),end:h.end(E)});return this.bufferedInfo(y,f,d)}}catch{}return{len:0,start:f,end:f,nextStart:void 0}},l.bufferedInfo=function(u,f,d){var h=[],y,E,p,_,g;for(u.sort(function(A,T){var w=A.start-T.start;return w||T.end-A.end}),g=0;g<u.length;g++){var x=h.length;if(x){var C=h[x-1].end;u[g].start-C<d?u[g].end>C&&(h[x-1].end=u[g].end):h.push(u[g])}else h.push(u[g])}for(g=0,y=0,E=p=f;g<h.length;g++){var R=h[g].start,S=h[g].end;if(f+d>=R&&f<S)E=R,p=S,y=p-f;else if(f+d<R){_=R;break}}return{len:y,start:E,end:p,nextStart:_}},l}();t.BufferHelper=a},"./src/utils/cea-608-parser.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},l=function(w){var P=w;return a.hasOwnProperty(w)&&(P=a[w]),String.fromCharCode(P)},u=15,f=100,d={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},h={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},E={25:2,26:4,29:6,30:8,31:10,27:13,28:15},p=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],_={verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(w){this.time=w},log:function(w,P){var O=this.verboseFilter[w];this.verboseLevel>=O}},g=function(w){for(var P=[],O=0;O<w.length;O++)P.push(w[O].toString(16));return P},x=function(){function w(P,O,k,D,F){this.foreground=P||"white",this.underline=O||!1,this.italics=k||!1,this.background=D||"black",this.flash=F||!1}return w.prototype.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},w.prototype.setStyles=function(P){for(var O=["foreground","underline","italics","background","flash"],k=0;k<O.length;k++){var D=O[k];P.hasOwnProperty(D)&&(this[D]=P[D])}},w.prototype.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},w.prototype.equals=function(P){return this.foreground===P.foreground&&this.underline===P.underline&&this.italics===P.italics&&this.background===P.background&&this.flash===P.flash},w.prototype.copy=function(P){this.foreground=P.foreground,this.underline=P.underline,this.italics=P.italics,this.background=P.background,this.flash=P.flash},w.prototype.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},w}(),C=function(){function w(P,O,k,D,F,G){this.uchar=P||" ",this.penState=new x(O,k,D,F,G)}return w.prototype.reset=function(){this.uchar=" ",this.penState.reset()},w.prototype.setChar=function(P,O){this.uchar=P,this.penState.copy(O)},w.prototype.setPenState=function(P){this.penState.copy(P)},w.prototype.equals=function(P){return this.uchar===P.uchar&&this.penState.equals(P.penState)},w.prototype.copy=function(P){this.uchar=P.uchar,this.penState.copy(P.penState)},w.prototype.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},w}(),R=function(){function w(){this.chars=[];for(var P=0;P<f;P++)this.chars.push(new C);this.pos=0,this.currPenState=new x}return w.prototype.equals=function(P){for(var O=!0,k=0;k<f;k++)if(!this.chars[k].equals(P.chars[k])){O=!1;break}return O},w.prototype.copy=function(P){for(var O=0;O<f;O++)this.chars[O].copy(P.chars[O])},w.prototype.isEmpty=function(){for(var P=!0,O=0;O<f;O++)if(!this.chars[O].isEmpty()){P=!1;break}return P},w.prototype.setCursor=function(P){this.pos!==P&&(this.pos=P),this.pos<0?(_.log("ERROR","Negative cursor position "+this.pos),this.pos=0):this.pos>f&&(_.log("ERROR","Too large cursor position "+this.pos),this.pos=f)},w.prototype.moveCursor=function(P){var O=this.pos+P;if(P>1)for(var k=this.pos+1;k<O+1;k++)this.chars[k].setPenState(this.currPenState);this.setCursor(O)},w.prototype.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},w.prototype.insertChar=function(P){P>=144&&this.backSpace();var O=l(P);if(this.pos>=f){_.log("ERROR","Cannot insert "+P.toString(16)+" ("+O+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(O,this.currPenState),this.moveCursor(1)},w.prototype.clearFromPos=function(P){var O;for(O=P;O<f;O++)this.chars[O].reset()},w.prototype.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},w.prototype.clearToEndOfRow=function(){this.clearFromPos(this.pos)},w.prototype.getTextString=function(){for(var P=[],O=!0,k=0;k<f;k++){var D=this.chars[k].uchar;D!==" "&&(O=!1),P.push(D)}return O?"":P.join("")},w.prototype.setPenStyles=function(P){this.currPenState.setStyles(P);var O=this.chars[this.pos];O.setPenState(this.currPenState)},w}(),S=function(){function w(){this.rows=[];for(var P=0;P<u;P++)this.rows.push(new R);this.currRow=u-1,this.nrRollUpRows=null,this.reset()}return w.prototype.reset=function(){for(var P=0;P<u;P++)this.rows[P].clear();this.currRow=u-1},w.prototype.equals=function(P){for(var O=!0,k=0;k<u;k++)if(!this.rows[k].equals(P.rows[k])){O=!1;break}return O},w.prototype.copy=function(P){for(var O=0;O<u;O++)this.rows[O].copy(P.rows[O])},w.prototype.isEmpty=function(){for(var P=!0,O=0;O<u;O++)if(!this.rows[O].isEmpty()){P=!1;break}return P},w.prototype.backSpace=function(){var P=this.rows[this.currRow];P.backSpace()},w.prototype.clearToEndOfRow=function(){var P=this.rows[this.currRow];P.clearToEndOfRow()},w.prototype.insertChar=function(P){var O=this.rows[this.currRow];O.insertChar(P)},w.prototype.setPen=function(P){var O=this.rows[this.currRow];O.setPenStyles(P)},w.prototype.moveCursor=function(P){var O=this.rows[this.currRow];O.moveCursor(P)},w.prototype.setCursor=function(P){_.log("INFO","setCursor: "+P);var O=this.rows[this.currRow];O.setCursor(P)},w.prototype.setPAC=function(P){_.log("INFO","pacData = "+JSON.stringify(P));var O=P.row-1;if(this.nrRollUpRows&&O<this.nrRollUpRows-1&&(O=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==O){for(var k=0;k<u;k++)this.rows[k].clear();var D=this.currRow+1-this.nrRollUpRows,F=this.lastOutputScreen;if(F){var G=F.rows[D].cueStartTime;if(G&&G<_.time)for(var k=0;k<this.nrRollUpRows;k++)this.rows[O-this.nrRollUpRows+k+1].copy(F.rows[D+k])}}this.currRow=O;var V=this.rows[this.currRow];if(P.indent!==null){var W=P.indent,ee=Math.max(W-1,0);V.setCursor(P.indent),P.color=V.chars[ee].penState.foreground}var q={foreground:P.color,underline:P.underline,italics:P.italics,background:"black",flash:!1};this.setPen(q)},w.prototype.setBkgData=function(P){_.log("INFO","bkgData = "+JSON.stringify(P)),this.backSpace(),this.setPen(P),this.insertChar(32)},w.prototype.setRollUpRows=function(P){this.nrRollUpRows=P},w.prototype.rollUp=function(){if(this.nrRollUpRows===null){_.log("DEBUG","roll_up but nrRollUpRows not set yet");return}_.log("TEXT",this.getDisplayText());var P=this.currRow+1-this.nrRollUpRows,O=this.rows.splice(P,1)[0];O.clear(),this.rows.splice(this.currRow,0,O),_.log("INFO","Rolling up")},w.prototype.getDisplayText=function(P){P=P||!1;for(var O=[],k="",D=-1,F=0;F<u;F++){var G=this.rows[F].getTextString();G&&(D=F+1,P?O.push("Row "+D+": '"+G+"'"):O.push(G.trim()))}return O.length>0&&(P?k="["+O.join(" | ")+"]":k=O.join(`
54
54
  `)),k},w.prototype.getTextAndFormat=function(){return this.rows},w}(),A=function(){function w(P,O){this.chNr=P,this.outputFilter=O,this.mode=null,this.verbose=0,this.displayedMemory=new S,this.nonDisplayedMemory=new S,this.lastOutputScreen=new S,this.currRollUpRow=this.displayedMemory.rows[u-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return w.prototype.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[u-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null},w.prototype.getHandler=function(){return this.outputFilter},w.prototype.setHandler=function(P){this.outputFilter=P},w.prototype.setPAC=function(P){this.writeScreen.setPAC(P)},w.prototype.setBkgData=function(P){this.writeScreen.setBkgData(P)},w.prototype.setMode=function(P){P!==this.mode&&(this.mode=P,_.log("INFO","MODE="+P),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=P)},w.prototype.insertChars=function(P){for(var O=0;O<P.length;O++)this.writeScreen.insertChar(P[O]);var k=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";_.log("INFO",k+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(_.log("TEXT","DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},w.prototype.ccRCL=function(){_.log("INFO","RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},w.prototype.ccBS=function(){_.log("INFO","BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},w.prototype.ccAOF=function(){},w.prototype.ccAON=function(){},w.prototype.ccDER=function(){_.log("INFO","DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},w.prototype.ccRU=function(P){_.log("INFO","RU("+P+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(P)},w.prototype.ccFON=function(){_.log("INFO","FON - Flash On"),this.writeScreen.setPen({flash:!0})},w.prototype.ccRDC=function(){_.log("INFO","RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},w.prototype.ccTR=function(){_.log("INFO","TR"),this.setMode("MODE_TEXT")},w.prototype.ccRTD=function(){_.log("INFO","RTD"),this.setMode("MODE_TEXT")},w.prototype.ccEDM=function(){_.log("INFO","EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},w.prototype.ccCR=function(){_.log("CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},w.prototype.ccENM=function(){_.log("INFO","ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},w.prototype.ccEOC=function(){if(_.log("INFO","EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var P=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=P,this.writeScreen=this.nonDisplayedMemory,_.log("TEXT","DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},w.prototype.ccTO=function(P){_.log("INFO","TO("+P+") - Tab Offset"),this.writeScreen.moveCursor(P)},w.prototype.ccMIDROW=function(P){var O={flash:!1};if(O.underline=P%2===1,O.italics=P>=46,O.italics)O.foreground="white";else{var k=Math.floor(P/2)-16,D=["white","green","blue","cyan","red","yellow","magenta"];O.foreground=D[k]}_.log("INFO","MIDROW: "+JSON.stringify(O)),this.writeScreen.setPen(O)},w.prototype.outputDataUpdate=function(P){P===void 0&&(P=!1);var O=_.time;O!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=O:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&(this.outputFilter.newCue(this.cueStartTime,O,this.lastOutputScreen),P===!0&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue()),this.cueStartTime=this.displayedMemory.isEmpty()?null:O),this.lastOutputScreen.copy(this.displayedMemory))},w.prototype.cueSplitAtTime=function(P){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,P,this.displayedMemory),this.cueStartTime=P))},w}(),T=function(){function w(P,O,k){this.field=P||1,this.outputs=[O,k],this.channels=[new A(1,O),new A(2,k)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}return w.prototype.getHandler=function(P){return this.channels[P].getHandler()},w.prototype.setHandler=function(P,O){this.channels[P].setHandler(O)},w.prototype.addData=function(P,O){var k,D,F,G=!1;this.lastTime=P,_.setTime(P);for(var V=0;V<O.length;V+=2){if(D=O[V]&127,F=O[V+1]&127,D===0&&F===0){this.dataCounters.padding+=2;continue}else _.log("DATA","["+g([O[V],O[V+1]])+"] -> ("+g([D,F])+")");if(k=this.parseCmd(D,F),k||(k=this.parseMidrow(D,F)),k||(k=this.parsePAC(D,F)),k||(k=this.parseBackgroundAttributes(D,F)),!k&&(G=this.parseChars(D,F),G))if(this.currChNr&&this.currChNr>=0){var W=this.channels[this.currChNr-1];W.insertChars(G)}else _.log("WARNING","No channel found yet. TEXT-MODE?");k?this.dataCounters.cmd+=2:G?this.dataCounters.char+=2:(this.dataCounters.other+=2,_.log("WARNING","Couldn't parse cleaned data "+g([D,F])+" orig: "+g([O[V],O[V+1]])))}},w.prototype.parseCmd=function(P,O){var k=null,D=(P===20||P===28)&&O>=32&&O<=47,F=(P===23||P===31)&&O>=33&&O<=35;if(!(D||F))return!1;if(P===this.lastCmdA&&O===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,_.log("DEBUG","Repeated command ("+g([P,O])+") is dropped"),!0;P===20||P===23?k=1:k=2;var G=this.channels[k-1];return P===20||P===28?O===32?G.ccRCL():O===33?G.ccBS():O===34?G.ccAOF():O===35?G.ccAON():O===36?G.ccDER():O===37?G.ccRU(2):O===38?G.ccRU(3):O===39?G.ccRU(4):O===40?G.ccFON():O===41?G.ccRDC():O===42?G.ccTR():O===43?G.ccRTD():O===44?G.ccEDM():O===45?G.ccCR():O===46?G.ccENM():O===47&&G.ccEOC():G.ccTO(O-32),this.lastCmdA=P,this.lastCmdB=O,this.currChNr=k,!0},w.prototype.parseMidrow=function(P,O){var k=null;if((P===17||P===25)&&O>=32&&O<=47){if(P===17?k=1:k=2,k!==this.currChNr)return _.log("ERROR","Mismatch channel in midrow parsing"),!1;var D=this.channels[k-1];return D.ccMIDROW(O),_.log("DEBUG","MIDROW ("+g([P,O])+")"),!0}return!1},w.prototype.parsePAC=function(P,O){var k=null,D=null,F=(P>=17&&P<=23||P>=25&&P<=31)&&O>=64&&O<=127,G=(P===16||P===24)&&O>=64&&O<=95;if(!(F||G))return!1;if(P===this.lastCmdA&&O===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;k=P<=23?1:2,O>=64&&O<=95?D=k===1?d[P]:y[P]:D=k===1?h[P]:E[P];var V=this.interpretPAC(D,O),W=this.channels[k-1];return W.setPAC(V),this.lastCmdA=P,this.lastCmdB=O,this.currChNr=k,!0},w.prototype.interpretPAC=function(P,O){var k=O,D={color:null,italics:!1,indent:null,underline:!1,row:P};return O>95?k=O-96:k=O-64,D.underline=(k&1)===1,k<=13?D.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(k/2)]:k<=15?(D.italics=!0,D.color="white"):D.indent=Math.floor((k-16)/2)*4,D},w.prototype.parseChars=function(P,O){var k=null,D=null,F=null;if(P>=25?(k=2,F=P-8):(k=1,F=P),F>=17&&F<=19){var G=O;F===17?G=O+80:F===18?G=O+112:G=O+144,_.log("INFO","Special char '"+l(G)+"' in channel "+k),D=[G]}else P>=32&&P<=127&&(D=O===0?[P]:[P,O]);if(D){var V=g(D);_.log("DEBUG","Char codes = "+V.join(",")),this.lastCmdA=null,this.lastCmdB=null}return D},w.prototype.parseBackgroundAttributes=function(P,O){var k,D,F,G,V=(P===16||P===24)&&O>=32&&O<=47,W=(P===23||P===31)&&O>=45&&O<=47;return V||W?(k={},P===16||P===24?(D=Math.floor((O-32)/2),k.background=p[D],O%2===1&&(k.background=k.background+"_semi")):O===45?k.background="transparent":(k.foreground="black",O===47&&(k.underline=!0)),F=P<24?1:2,G=this.channels[F-1],G.setBkgData(k),this.lastCmdA=null,this.lastCmdB=null,!0):!1},w.prototype.reset=function(){for(var P=0;P<this.channels.length;P++)this.channels[P]&&this.channels[P].reset();this.lastCmdA=null,this.lastCmdB=null},w.prototype.cueSplitAtTime=function(P){for(var O=0;O<this.channels.length;O++)this.channels[O]&&this.channels[O].cueSplitAtTime(P)},w}();t.default=T},"./src/utils/codecs.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}};function l(f,d){var h=a[d];return!!h&&h[f.slice(0,4)]===!0}t.isCodecType=l;function u(f,d){return window.MediaSource.isTypeSupported((d||"video")+'/mp4;codecs="'+f+'"')}t.isCodecSupportedInMp4=u},"./src/utils/cues.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/vttparser.js");function l(u,f,d,h){for(var y,E,p,_,g,x=window.VTTCue||window.TextTrackCue,C=0;C<h.rows.length;C++)if(y=h.rows[C],p=!0,_=0,g="",!y.isEmpty()){for(var R=0;R<y.chars.length;R++)y.chars[R].uchar.match(/\s/)&&p?_++:(g+=y.chars[R].uchar,p=!1);y.cueStartTime=f,f===d&&(d+=1e-4),E=new x(f,d,a.fixLineBreaks(g.trim())),_>=16?_--:_++,navigator.userAgent.match(/Firefox\//)?E.line=C+1:E.line=C>7?C-2:C+1,E.align="left",E.position=Math.max(0,Math.min(100,100*(_/32)+(navigator.userAgent.match(/Firefox\//)?50:0))),u.addCue(E)}}t.newCue=l},"./src/utils/discontinuities.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/utils/binary-search.js"),u=n("./src/utils/logger.js");function f(x,C){for(var R=null,S=0;S<x.length;S+=1){var A=x[S];if(A&&A.cc===C){R=A;break}}return R}t.findFirstFragWithCC=f;function d(x,C){return l.default.search(x,function(R){return R.cc<C?1:R.cc>C?-1:0})}t.findFragWithCC=d;function h(x,C,R){var S=!1;return C&&C.details&&R&&(R.endCC>R.startCC||x&&x.cc<R.startCC)&&(S=!0),S}t.shouldAlignOnDiscontinuities=h;function y(x,C){var R=x.fragments,S=C.fragments;if(!S.length||!R.length){u.logger.log("No fragments to align");return}var A=f(R,S[0].cc);if(!A||A&&!A.startPTS){u.logger.log("No frag in previous level to align on");return}return A}t.findDiscontinuousReferenceFrag=y;function E(x,C){C.fragments.forEach(function(R){if(R){var S=R.start+x;R.start=R.startPTS=S,R.endPTS=S+R.duration}}),C.PTSKnown=!0}t.adjustPts=E;function p(x,C,R){_(x,R,C),!R.PTSKnown&&C&&g(R,C.details)}t.alignStream=p;function _(x,C,R){if(h(x,R,C)){var S=y(R.details,C);S&&(u.logger.log("Adjusting PTS using last level due to CC increase within current level"),E(S.start,C))}}t.alignDiscontinuities=_;function g(x,C){if(C&&C.fragments.length){if(!x.hasProgramDateTime||!C.hasProgramDateTime)return;var R=C.fragments[0].programDateTime,S=x.fragments[0].programDateTime,A=(S-R)/1e3+C.fragments[0].start;a.isFinite(A)&&(u.logger.log("adjusting PTS using programDateTime delta, sliding:"+A.toFixed(3)),E(A,x))}}t.alignPDT=g}).call(this,n("./src/polyfills/number.js").Number)},"./src/utils/ewma-bandwidth-estimator.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/ewma.js"),l=function(){function u(f,d,h,y){this.hls=f,this.defaultEstimate_=y,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new a.default(d),this.fast_=new a.default(h)}return u.prototype.sample=function(f,d){f=Math.max(f,this.minDelayMs_);var h=8e3*d/f,y=f/1e3;this.fast_.sample(y,h),this.slow_.sample(y,h)},u.prototype.canEstimate=function(){var f=this.fast_;return f&&f.getTotalWeight()>=this.minWeight_},u.prototype.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},u.prototype.destroy=function(){},u}();t.default=l},"./src/utils/ewma.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(u){this.alpha_=u?Math.exp(Math.log(.5)/u):0,this.estimate_=0,this.totalWeight_=0}return l.prototype.sample=function(u,f){var d=Math.pow(this.alpha_,u);this.estimate_=f*(1-d)+d*this.estimate_,this.totalWeight_+=u},l.prototype.getTotalWeight=function(){return this.totalWeight_},l.prototype.getEstimate=function(){if(this.alpha_){var u=1-Math.pow(this.alpha_,this.totalWeight_);return this.estimate_/u}else return this.estimate_},l}();t.default=a},"./src/utils/get-self-scope.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});function a(){return typeof window>"u"?self:window}t.getSelfScope=a},"./src/utils/logger.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/get-self-scope.js");function l(){}var u={trace:l,debug:l,log:l,warn:l,info:l,error:l},f=u;function d(p,_){return _="["+p+"] > "+_,_}var h=a.getSelfScope();function y(p){var _=h.console[p];return _?function(){for(var g=[],x=0;x<arguments.length;x++)g[x]=arguments[x];g[0]&&(g[0]=d(p,g[0])),_.apply(h.console,g)}:l}function E(p){for(var _=[],g=1;g<arguments.length;g++)_[g-1]=arguments[g];_.forEach(function(x){f[x]=p[x]?p[x].bind(p):y(x)})}t.enableLogs=function(p){if(p===!0||typeof p=="object"){E(p,"debug","log","info","warn","error");try{f.log()}catch{f=u}}else f=u},t.logger=f},"./src/utils/mediakeys-helper.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){return typeof window<"u"&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null}();t.requestMediaKeySystemAccess=a},"./src/utils/mediasource-helper.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});function a(){if(typeof window<"u")return window.MediaSource||window.WebKitMediaSource}t.getMediaSource=a},"./src/utils/output-filter.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(u,f){this.timelineController=u,this.trackName=f,this.startTime=null,this.endTime=null,this.screen=null}return l.prototype.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen),this.startTime=null)},l.prototype.newCue=function(u,f,d){(this.startTime===null||this.startTime>u)&&(this.startTime=u),this.endTime=f,this.screen=d,this.timelineController.createCaptionsTrack(this.trackName)},l}();t.default=a},"./src/utils/texttrack-utils.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});function a(u,f){var d=null;try{d=new window.Event("addtrack")}catch{d=document.createEvent("Event"),d.initEvent("addtrack",!1,!1)}d.track=u,f.dispatchEvent(d)}t.sendAddTrackEvent=a;function l(u){if(u&&u.cues)for(;u.cues.length>0;)u.removeCue(u.cues[0])}t.clearCurrentCues=l},"./src/utils/time-ranges.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={toString:function(l){for(var u="",f=l.length,d=0;d<f;d++)u+="["+l.start(d).toFixed(3)+","+l.end(d).toFixed(3)+"]";return u}};t.default=a},"./src/utils/vttcue.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if(typeof window<"u"&&window.VTTCue)return window.VTTCue;var a="auto",l={"":!0,lr:!0,rl:!0},u={start:!0,middle:!0,end:!0,left:!0,right:!0};function f(E){if(typeof E!="string")return!1;var p=l[E.toLowerCase()];return p?E.toLowerCase():!1}function d(E){if(typeof E!="string")return!1;var p=u[E.toLowerCase()];return p?E.toLowerCase():!1}function h(E){for(var p=1;p<arguments.length;p++){var _=arguments[p];for(var g in _)E[g]=_[g]}return E}function y(E,p,_){var g=this,x=function(){if(!(typeof navigator>"u"))return/MSIE\s8\.0/.test(navigator.userAgent)}(),C={};x?g=document.createElement("custom"):C.enumerable=!0,g.hasBeenReset=!1;var R="",S=!1,A=E,T=p,w=_,P=null,O="",k=!0,D="auto",F="start",G=50,V="middle",W=50,ee="middle";if(Object.defineProperty(g,"id",h({},C,{get:function(){return R},set:function(q){R=""+q}})),Object.defineProperty(g,"pauseOnExit",h({},C,{get:function(){return S},set:function(q){S=!!q}})),Object.defineProperty(g,"startTime",h({},C,{get:function(){return A},set:function(q){if(typeof q!="number")throw new TypeError("Start time must be set to a number.");A=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",h({},C,{get:function(){return T},set:function(q){if(typeof q!="number")throw new TypeError("End time must be set to a number.");T=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",h({},C,{get:function(){return w},set:function(q){w=""+q,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",h({},C,{get:function(){return P},set:function(q){P=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",h({},C,{get:function(){return O},set:function(q){var z=f(q);if(z===!1)throw new SyntaxError("An invalid or illegal string was specified.");O=z,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",h({},C,{get:function(){return k},set:function(q){k=!!q,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",h({},C,{get:function(){return D},set:function(q){if(typeof q!="number"&&q!==a)throw new SyntaxError("An invalid number or illegal string was specified.");D=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",h({},C,{get:function(){return F},set:function(q){var z=d(q);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");F=z,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",h({},C,{get:function(){return G},set:function(q){if(q<0||q>100)throw new Error("Position must be between 0 and 100.");G=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",h({},C,{get:function(){return V},set:function(q){var z=d(q);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");V=z,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",h({},C,{get:function(){return W},set:function(q){if(q<0||q>100)throw new Error("Size must be between 0 and 100.");W=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",h({},C,{get:function(){return ee},set:function(q){var z=d(q);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");ee=z,this.hasBeenReset=!0}})),g.displayState=void 0,x)return g}return y.prototype.getCueAsHTML=function(){var E=window.WebVTT;return E.convertCueToDOMTree(window,this.text)},y}()},"./src/utils/vttparser.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/vttcue.js"),l=function(){return{decode:function(x){if(!x)return"";if(typeof x!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(x))}}};function u(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new l,this.regionList=[]}function f(g){function x(R,S,A,T){return(R|0)*3600+(S|0)*60+(A|0)+(T|0)/1e3}var C=g.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return C?C[3]?x(C[1],C[2],C[3].replace(":",""),C[4]):C[1]>59?x(C[1],C[2],0,C[4]):x(0,C[1],C[2],C[4]):null}function d(){this.values=Object.create(null)}d.prototype={set:function(g,x){!this.get(g)&&x!==""&&(this.values[g]=x)},get:function(g,x,C){return C?this.has(g)?this.values[g]:x[C]:this.has(g)?this.values[g]:x},has:function(g){return g in this.values},alt:function(g,x,C){for(var R=0;R<C.length;++R)if(x===C[R]){this.set(g,x);break}},integer:function(g,x){/^-?\d+$/.test(x)&&this.set(g,parseInt(x,10))},percent:function(g,x){return x.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(x=parseFloat(x),x>=0&&x<=100)?(this.set(g,x),!0):!1}};function h(g,x,C,R){var S=R?g.split(R):[g];for(var A in S)if(typeof S[A]=="string"){var T=S[A].split(C);if(T.length===2){var w=T[0],P=T[1];x(w,P)}}}var y=new a.default(0,0,0),E=y.align==="middle"?"middle":"center";function p(g,x,C){var R=g;function S(){var w=f(g);if(w===null)throw new Error("Malformed timestamp: "+R);return g=g.replace(/^[^\sa-zA-Z-]+/,""),w}function A(w,P){var O=new d;h(w,function(F,G){switch(F){case"region":for(var V=C.length-1;V>=0;V--)if(C[V].id===G){O.set(F,C[V].region);break}break;case"vertical":O.alt(F,G,["rl","lr"]);break;case"line":var W=G.split(","),ee=W[0];O.integer(F,ee),O.percent(F,ee)&&O.set("snapToLines",!1),O.alt(F,ee,["auto"]),W.length===2&&O.alt("lineAlign",W[1],["start",E,"end"]);break;case"position":W=G.split(","),O.percent(F,W[0]),W.length===2&&O.alt("positionAlign",W[1],["start",E,"end","line-left","line-right","auto"]);break;case"size":O.percent(F,G);break;case"align":O.alt(F,G,["start",E,"end","left","right"]);break}},/:/,/\s/),P.region=O.get("region",null),P.vertical=O.get("vertical","");var k=O.get("line","auto");k==="auto"&&y.line===-1&&(k=-1),P.line=k,P.lineAlign=O.get("lineAlign","start"),P.snapToLines=O.get("snapToLines",!0),P.size=O.get("size",100),P.align=O.get("align",E);var D=O.get("position","auto");D==="auto"&&y.position===50&&(D=P.align==="start"||P.align==="left"?0:P.align==="end"||P.align==="right"?100:50),P.position=D}function T(){g=g.replace(/^\s+/,"")}if(T(),x.startTime=S(),T(),g.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+R);g=g.substr(3),T(),x.endTime=S(),T(),A(g,x)}function _(g){return g.replace(/<br(?: \/)?>/gi,`
55
55
  `)}t.fixLineBreaks=_,u.prototype={parse:function(g){var x=this;g&&(x.buffer+=x.decoder.decode(g,{stream:!0}));function C(){var P=x.buffer,O=0;for(P=_(P);O<P.length&&P[O]!=="\r"&&P[O]!==`
@@ -66,7 +66,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
66
66
  `,FORWARD_SLASH="/",ASTERISK="*",EMPTY_STRING$1="",TYPE_COMMENT="comment",TYPE_DECLARATION="declaration",inlineStyleParser=function(o,e){if(typeof o!="string")throw new TypeError("First argument must be a string");if(!o)return[];e=e||{};var r=1,t=1;function n(_){var g=_.match(NEWLINE_REGEX);g&&(r+=g.length);var x=_.lastIndexOf(NEWLINE);t=~x?_.length-x:t+_.length}function a(){var _={line:r,column:t};return function(g){return g.position=new l(_),d(),g}}function l(_){this.start=_,this.end={line:r,column:t},this.source=e.source}l.prototype.content=o;function u(_){var g=new Error(e.source+":"+r+":"+t+": "+_);if(g.reason=_,g.filename=e.source,g.line=r,g.column=t,g.source=o,!e.silent)throw g}function f(_){var g=_.exec(o);if(g){var x=g[0];return n(x),o=o.slice(x.length),g}}function d(){f(WHITESPACE_REGEX)}function h(_){var g;for(_=_||[];g=y();)g!==!1&&_.push(g);return _}function y(){var _=a();if(!(FORWARD_SLASH!=o.charAt(0)||ASTERISK!=o.charAt(1))){for(var g=2;EMPTY_STRING$1!=o.charAt(g)&&(ASTERISK!=o.charAt(g)||FORWARD_SLASH!=o.charAt(g+1));)++g;if(g+=2,EMPTY_STRING$1===o.charAt(g-1))return u("End of comment missing");var x=o.slice(2,g-2);return t+=2,n(x),o=o.slice(g),t+=2,_({type:TYPE_COMMENT,comment:x})}}function E(){var _=a(),g=f(PROPERTY_REGEX);if(g){if(y(),!f(COLON_REGEX))return u("property missing ':'");var x=f(VALUE_REGEX),C=_({type:TYPE_DECLARATION,property:trim(g[0].replace(COMMENT_REGEX,EMPTY_STRING$1)),value:x?trim(x[0].replace(COMMENT_REGEX,EMPTY_STRING$1)):EMPTY_STRING$1});return f(SEMICOLON_REGEX),C}}function p(){var _=[];h(_);for(var g;g=E();)g!==!1&&(_.push(g),h(_));return _}return d(),p()};function trim(o){return o?o.replace(TRIM_REGEX,EMPTY_STRING$1):EMPTY_STRING$1}var parse=inlineStyleParser;function StyleToObject(o,e){var r=null;if(!o||typeof o!="string")return r;for(var t,n=parse(o),a=typeof e=="function",l,u,f=0,d=n.length;f<d;f++)t=n[f],l=t.property,u=t.value,a?e(l,u,t):u&&(r||(r={}),r[l]=u);return r}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(o){return!o||NO_HYPHEN_REGEX.test(o)||CUSTOM_PROPERTY_REGEX.test(o)},capitalize=function(o,e){return e.toUpperCase()},trimHyphen=function(o,e){return"".concat(e,"-")},camelCase=function(o,e){return e===void 0&&(e={}),skipCamelCase(o)?o:(o=o.toLowerCase(),e.reactCompat?o=o.replace(MS_VENDOR_PREFIX_REGEX,trimHyphen):o=o.replace(VENDOR_PREFIX_REGEX,trimHyphen),o.replace(HYPHEN_REGEX,capitalize))};utilities$4.camelCase=camelCase;(function(o){var e=commonjsGlobal&&commonjsGlobal.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};o.__esModule=!0;var r=e(styleToObject),t=utilities$4;function n(a,l){var u={};return!a||typeof a!="string"||(0,r.default)(a,function(f,d){f&&d&&(u[(0,t.camelCase)(f,l)]=d)}),u}o.default=n})(cjs);var React$1=React$2,styleToJS=cjs.default;function invertObject(o,e){if(!o||typeof o!="object")throw new TypeError("First argument must be an object");var r,t,n=typeof e=="function",a={},l={};for(r in o){if(t=o[r],n&&(a=e(r,t),a&&a.length===2)){l[a[0]]=a[1];continue}typeof t=="string"&&(l[t]=r)}return l}function isCustomComponent(o,e){if(o.indexOf("-")===-1)return e&&typeof e.is=="string";switch(o){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(o,e){if(o!=null)try{e.style=styleToJS(o,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(o){return!elementsWithNoTextChildren.has(o.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 o(e){e=e||{};var r={reset:!0,submit:!0},t,n,a,l,u,f={},d=e.type&&r[e.type];for(t in e){if(a=e[t],reactProperty.isCustomAttribute(t)){f[t]=a;continue}if(n=t.toLowerCase(),l=getPropName(n),l){switch(u=reactProperty.getPropertyInfo(l),(l==="checked"||l==="value")&&!d&&(l=getPropName("default"+n)),f[l]=a,u&&u.type){case reactProperty.BOOLEAN:f[l]=!0;break;case reactProperty.OVERLOADED_BOOLEAN:a===""&&(f[l]=!0);break}continue}utilities$2.PRESERVE_CUSTOM_ATTRIBUTES&&(f[t]=a)}return utilities$2.setStyleProp(e.style,f),f};function getPropName(o){return reactProperty.possibleStandardNames[o]}var React=React$2,attributesToProps$1=attributesToProps$2,utilities$1=utilities$3,setStyleProp=utilities$1.setStyleProp,canTextBeChildOfNode=utilities$1.canTextBeChildOfNode;function domToReact$1(o,e){e=e||{};for(var r=e.library||React,t=r.cloneElement,n=r.createElement,a=r.isValidElement,l=[],u,f,d=typeof e.replace=="function",h,y,E,p=e.trim,_=0,g=o.length;_<g;_++){if(u=o[_],d&&(h=e.replace(u),a(h))){g>1&&(h=t(h,{key:h.key||_})),l.push(h);continue}if(u.type==="text"){if(f=!u.data.trim().length,f&&u.parent&&!canTextBeChildOfNode(u.parent)||p&&f)continue;l.push(u.data);continue}switch(y=u.attribs,skipAttributesToProps(u)?setStyleProp(y.style,y):y&&(y=attributesToProps$1(y)),E=null,u.type){case"script":case"style":u.children[0]&&(y.dangerouslySetInnerHTML={__html:u.children[0].data});break;case"tag":u.name==="textarea"&&u.children[0]?y.defaultValue=u.children[0].data:u.children&&u.children.length&&(E=domToReact$1(u.children,e));break;default:continue}g>1&&(y.key=_),l.push(n(u.name,y,E))}return l.length===1?l[0]:l}function skipAttributesToProps(o){return utilities$1.PRESERVE_CUSTOM_ATTRIBUTES&&o.type==="tag"&&utilities$1.isCustomComponent(o.name,o.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(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Doctype=o.CDATA=o.Tag=o.Style=o.Script=o.Comment=o.Directive=o.Text=o.Root=o.isTag=o.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=o.ElementType||(o.ElementType={}));function r(t){return t.type===e.Tag||t.type===e.Script||t.type===e.Style}o.isTag=r,o.Root=e.Root,o.Text=e.Text,o.Directive=e.Directive,o.Comment=e.Comment,o.Script=e.Script,o.Style=e.Style,o.Tag=e.Tag,o.CDATA=e.CDATA,o.Doctype=e.Doctype}(lib$3)),lib$3}var __extends=commonjsGlobal&&commonjsGlobal.__extends||function(){var o=function(e,r){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])},o(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");o(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}}(),__assign=commonjsGlobal&&commonjsGlobal.__assign||function(){return __assign=Object.assign||function(o){for(var e,r=1,t=arguments.length;r<t;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=e[n])}return o},__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 o(e){this.type=e,this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(o.prototype,"nodeType",{get:function(){var e;return(e=nodeTypes.get(this.type))!==null&&e!==void 0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),o.prototype.cloneNode=function(e){return e===void 0&&(e=!1),cloneNode(this,e)},o}();node.Node=Node$2;var DataNode=function(o){__extends(e,o);function e(r,t){var n=o.call(this,r)||this;return n.data=t,n}return Object.defineProperty(e.prototype,"nodeValue",{get:function(){return this.data},set:function(r){this.data=r},enumerable:!1,configurable:!0}),e}(Node$2);node.DataNode=DataNode;var Text$4=function(o){__extends(e,o);function e(r){return o.call(this,domelementtype_1.ElementType.Text,r)||this}return e}(DataNode);node.Text=Text$4;var Comment$1=function(o){__extends(e,o);function e(r){return o.call(this,domelementtype_1.ElementType.Comment,r)||this}return e}(DataNode);node.Comment=Comment$1;var ProcessingInstruction$1=function(o){__extends(e,o);function e(r,t){var n=o.call(this,domelementtype_1.ElementType.Directive,t)||this;return n.name=r,n}return e}(DataNode);node.ProcessingInstruction=ProcessingInstruction$1;var NodeWithChildren=function(o){__extends(e,o);function e(r,t){var n=o.call(this,r)||this;return n.children=t,n}return Object.defineProperty(e.prototype,"firstChild",{get:function(){var r;return(r=this.children[0])!==null&&r!==void 0?r: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(r){this.children=r},enumerable:!1,configurable:!0}),e}(Node$2);node.NodeWithChildren=NodeWithChildren;var Document=function(o){__extends(e,o);function e(r){return o.call(this,domelementtype_1.ElementType.Root,r)||this}return e}(NodeWithChildren);node.Document=Document;var Element$1=function(o){__extends(e,o);function e(r,t,n,a){n===void 0&&(n=[]),a===void 0&&(a=r==="script"?domelementtype_1.ElementType.Script:r==="style"?domelementtype_1.ElementType.Style:domelementtype_1.ElementType.Tag);var l=o.call(this,a,n)||this;return l.name=r,l.attribs=t,l}return Object.defineProperty(e.prototype,"tagName",{get:function(){return this.name},set:function(r){this.name=r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attributes",{get:function(){var r=this;return Object.keys(this.attribs).map(function(t){var n,a;return{name:t,value:r.attribs[t],namespace:(n=r["x-attribsNamespace"])===null||n===void 0?void 0:n[t],prefix:(a=r["x-attribsPrefix"])===null||a===void 0?void 0:a[t]}})},enumerable:!1,configurable:!0}),e}(NodeWithChildren);node.Element=Element$1;function isTag(o){return(0,domelementtype_1.isTag)(o)}node.isTag=isTag;function isCDATA(o){return o.type===domelementtype_1.ElementType.CDATA}node.isCDATA=isCDATA;function isText(o){return o.type===domelementtype_1.ElementType.Text}node.isText=isText;function isComment(o){return o.type===domelementtype_1.ElementType.Comment}node.isComment=isComment;function isDirective(o){return o.type===domelementtype_1.ElementType.Directive}node.isDirective=isDirective;function isDocument(o){return o.type===domelementtype_1.ElementType.Root}node.isDocument=isDocument;function hasChildren(o){return Object.prototype.hasOwnProperty.call(o,"children")}node.hasChildren=hasChildren;function cloneNode(o,e){e===void 0&&(e=!1);var r;if(isText(o))r=new Text$4(o.data);else if(isComment(o))r=new Comment$1(o.data);else if(isTag(o)){var t=e?cloneChildren(o.children):[],n=new Element$1(o.name,__assign({},o.attribs),t);t.forEach(function(f){return f.parent=n}),o.namespace!=null&&(n.namespace=o.namespace),o["x-attribsNamespace"]&&(n["x-attribsNamespace"]=__assign({},o["x-attribsNamespace"])),o["x-attribsPrefix"]&&(n["x-attribsPrefix"]=__assign({},o["x-attribsPrefix"])),r=n}else if(isCDATA(o)){var t=e?cloneChildren(o.children):[],a=new NodeWithChildren(domelementtype_1.ElementType.CDATA,t);t.forEach(function(d){return d.parent=a}),r=a}else if(isDocument(o)){var t=e?cloneChildren(o.children):[],l=new Document(t);t.forEach(function(d){return d.parent=l}),o["x-mode"]&&(l["x-mode"]=o["x-mode"]),r=l}else if(isDirective(o)){var u=new ProcessingInstruction$1(o.name,o.data);o["x-name"]!=null&&(u["x-name"]=o["x-name"],u["x-publicId"]=o["x-publicId"],u["x-systemId"]=o["x-systemId"]),r=u}else throw new Error("Not implemented yet: ".concat(o.type));return r.startIndex=o.startIndex,r.endIndex=o.endIndex,o.sourceCodeLocation!=null&&(r.sourceCodeLocation=o.sourceCodeLocation),r}node.cloneNode=cloneNode;function cloneChildren(o){for(var e=o.map(function(t){return cloneNode(t,!0)}),r=1;r<e.length;r++)e[r].prev=e[r-1],e[r-1].next=e[r];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(o){return caseSensitiveTagNamesMap[o]}function formatAttributes(o){for(var e={},r,t=0,n=o.length;t<n;t++)r=o[t],e[r.name]=r.value;return e}function formatTagName(o){o=o.toLowerCase();var e=getCaseSensitiveTagName(o);return e||o}function formatDOM$1(o,e,r){e=e||null;for(var t=[],n=0,a=o.length;n<a;n++){var l=o[n],u;switch(l.nodeType){case 1:u=new Element(formatTagName(l.nodeName),formatAttributes(l.attributes)),u.children=formatDOM$1(l.childNodes,u);break;case 3:u=new Text$3(l.nodeValue);break;case 8:u=new Comment(l.nodeValue);break;default:continue}var f=t[n-1]||null;f&&(f.next=u),u.parent=e,u.prev=f,u.next=null,t.push(u)}return r&&(u=new ProcessingInstruction(r.substring(0,r.indexOf(" ")).toLowerCase(),r),u.next=t[0]||null,u.parent=e,t.unshift(u),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(o,e){return e&&(o="<"+e+">"+o+"</"+e+">"),domParser.parseFromString(o,mimeType)},parseFromDocument=parseFromString}if(document.implementation){var isIE=utilities.isIE,doc=document.implementation.createHTMLDocument(isIE()?"html-dom-parser":void 0);parseFromDocument=function(o,e){return e?(doc.documentElement.getElementsByTagName(e)[0].innerHTML=o,doc):(doc.documentElement.innerHTML=o,doc)}}var template=document.createElement("template"),parseFromTemplate;template.content&&(parseFromTemplate=function(o){return template.innerHTML=o,template.content.childNodes});function domparser$1(o){var e,r=o.match(FIRST_TAG_REGEX);r&&r[1]&&(e=r[1].toLowerCase());var t,n,a;switch(e){case HTML:return t=parseFromString(o),HEAD_TAG_REGEX.test(o)||(n=t.getElementsByTagName(HEAD)[0],n&&n.parentNode.removeChild(n)),BODY_TAG_REGEX.test(o)||(n=t.getElementsByTagName(BODY)[0],n&&n.parentNode.removeChild(n)),t.getElementsByTagName(HTML);case HEAD:case BODY:return a=parseFromDocument(o).getElementsByTagName(e),BODY_TAG_REGEX.test(o)&&HEAD_TAG_REGEX.test(o)?a[0].parentNode.childNodes:a;default:return parseFromTemplate?parseFromTemplate(o):parseFromDocument(o,BODY).getElementsByTagName(BODY)[0].childNodes}}var domparser_1=domparser$1,domparser=domparser_1,formatDOM=utilities.formatDOM,DIRECTIVE_REGEX=/<(![a-zA-Z\s]+)>/;function HTMLDOMParser(o){if(typeof o!="string")throw new TypeError("First argument must be a string");if(o==="")return[];var e=o.match(DIRECTIVE_REGEX),r;return e&&e[1]&&(r=e[1]),formatDOM(domparser(o),null,r)}var htmlToDom=HTMLDOMParser,lib$2={},hasRequiredLib;function requireLib(){return hasRequiredLib||(hasRequiredLib=1,function(o){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(f,d,h,y){y===void 0&&(y=h);var E=Object.getOwnPropertyDescriptor(d,h);(!E||("get"in E?!d.__esModule:E.writable||E.configurable))&&(E={enumerable:!0,get:function(){return d[h]}}),Object.defineProperty(f,y,E)}:function(f,d,h,y){y===void 0&&(y=h),f[y]=d[h]}),r=commonjsGlobal&&commonjsGlobal.__exportStar||function(f,d){for(var h in f)h!=="default"&&!Object.prototype.hasOwnProperty.call(d,h)&&e(d,f,h)};Object.defineProperty(o,"__esModule",{value:!0}),o.DomHandler=void 0;var t=requireLib$1(),n=node;r(node,o);var a=/\s+/g,l={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1,xmlMode:!1},u=function(){function f(d,h,y){this.dom=[],this.root=new n.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof h=="function"&&(y=h,h=l),typeof d=="object"&&(h=d,d=void 0),this.callback=d??null,this.options=h??l,this.elementCB=y??null}return f.prototype.onparserinit=function(d){this.parser=d},f.prototype.onreset=function(){this.dom=[],this.root=new n.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(d){this.handleCallback(d)},f.prototype.onclosetag=function(){this.lastNode=null;var d=this.tagStack.pop();this.options.withEndIndices&&(d.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(d)},f.prototype.onopentag=function(d,h){var y=this.options.xmlMode?t.ElementType.Tag:void 0,E=new n.Element(d,h,void 0,y);this.addNode(E),this.tagStack.push(E)},f.prototype.ontext=function(d){var h=this.options.normalizeWhitespace,y=this.lastNode;if(y&&y.type===t.ElementType.Text)h?y.data=(y.data+d).replace(a," "):y.data+=d,this.options.withEndIndices&&(y.endIndex=this.parser.endIndex);else{h&&(d=d.replace(a," "));var E=new n.Text(d);this.addNode(E),this.lastNode=E}},f.prototype.oncomment=function(d){if(this.lastNode&&this.lastNode.type===t.ElementType.Comment){this.lastNode.data+=d;return}var h=new n.Comment(d);this.addNode(h),this.lastNode=h},f.prototype.oncommentend=function(){this.lastNode=null},f.prototype.oncdatastart=function(){var d=new n.Text(""),h=new n.NodeWithChildren(t.ElementType.CDATA,[d]);this.addNode(h),d.parent=h,this.lastNode=d},f.prototype.oncdataend=function(){this.lastNode=null},f.prototype.onprocessinginstruction=function(d,h){var y=new n.ProcessingInstruction(d,h);this.addNode(y)},f.prototype.handleCallback=function(d){if(typeof this.callback=="function")this.callback(d,this.dom);else if(d)throw d},f.prototype.addNode=function(d){var h=this.tagStack[this.tagStack.length-1],y=h.children[h.children.length-1];this.options.withStartIndices&&(d.startIndex=this.parser.startIndex),this.options.withEndIndices&&(d.endIndex=this.parser.endIndex),h.children.push(d),y&&(d.prev=y,y.next=d),d.parent=h,this.lastNode=null},f}();o.DomHandler=u,o.default=u}(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(o,e){if(typeof o!="string")throw new TypeError("First argument must be a string");return o===""?[]:(e=e||{},domToReact(htmlToDOM(o,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:o,close:e,minutes:r,seconds:t,btnText:n}){return jsxRuntimeExports.jsx("div",{className:"lectures--buttons",children:o?jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>e(),"aria-label":n,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:[r<10?`0${r}`:r,":",t<10?`0${t}`:t]})})})}LectureButtons.defaultProps={goToLecture:!1,close:()=>{},minutes:0,seconds:0};const noop$1=()=>{},useEkho=({voice:o,text:e,audioType:r,loop:t=!1,started:n=!0,slide:a=0,audio:l,soundActions:u,emitEvent:f,volume:d=.5,onFinish:h=noop$1,onError:y=noop$1,onStart:E=noop$1,pauseTTS:p})=>{const[_,g,x,C]=u,R=!l&&!o,[S,A]=React$2.useState(!1),T=React$2.useRef({url:"",cc:"tts"}),w=React$2.useCallback(F=>f({type:"translate",payload:F}),[f]),P=React$2.useCallback(({id:F,type:G="base"})=>{var ee;const V=w("usedVoices"),W=w("gameCharacters");return G==="base"?V==null?void 0:V[F]:G==="character"?(ee=W==null?void 0:W[F])==null?void 0:ee.voiceId:null},[w]),O=React$2.useCallback((F,G="tts")=>{T.current.url===F&&a===T.current.slide||(T.current={url:F,cc:G,slide:a},_(F,G,t,d,h,E))},[a,_,t,d,h,E]),k=React$2.useCallback(async F=>{if(S&&F.voiceId&&F.text){const G=await f({type:"getSpeech",payload:F});G?O(G):y()}else y()},[f,S,y,O]),D=React$2.useCallback(()=>{T.current.url&&g(T.current.cc)},[g]);return React$2.useEffect(()=>(A(!0),()=>{A(!1),D()}),[D]),React$2.useEffect(()=>{p?x():C()},[x,p,C]),React$2.useEffect(()=>{R&&D()},[R,D]),React$2.useEffect(()=>{if(S&&n)if(r==="voice"&&(o!=null&&o.id)){const F=P(o);k({voiceId:F,text:e})}else(r==="file"||!r)&&l?O(l==null?void 0:l.url):y()},[P,k,S,o,e,r,l==null?void 0:l.url,l,O,y,n]),D},READING_TIME=.2;function LecturesComponent({emitEvent:o,name:e,name_labelId:r,required:t,text:n,text_labelId:a,visible:l,documentType:u,viewed:f,soundActions:d,backgroundImage:h,keyboardControl:y,audio:E,audioType:p,audioVolume:_,voice:g,pause:x,styles:C}){const[R,S]=React$2.useState(),[A,T]=React$2.useState(!1),[w,P]=React$2.useState(0),O=n,k=Math.trunc(O.split(" ").length*READING_TIME),D=!t||t&&w>=k||t&&!l,[F]=d,G=/<\/p>|<\/h1>|<\/h2>|<\/h3>|<\/h4>|<\/h5>|<\/h6>|<\/li>/gi,V=/&quot;|&#39;/gi,q=n.replace(G,". </p>").replace(V,"").replace(/(<([^>]+)>)/gi,""),z=`${e}. ${q}`;useEkho({audioType:p,voice:g,text:z,audio:E,soundActions:d,emitEvent:o,volume:_,pauseTTS:x});const U=Q=>o({type:"translate",payload:Q}),$=React$2.useCallback(()=>{D&&(F("click-ui"),o({type:"finishMedia",payload:{name:r,type:"text",text:a,documentType:u}}))},[u,o,D,r,a,F]);y(null,f?null:$,f?null:$),React$2.useEffect(()=>{if(!l&&!A&&($(),T(!0)),t&&l){const Q=setInterval(()=>{P(J=>J+1)},1e3);return S(Q),()=>{clearInterval(Q)}}},[$,t,A,l]),React$2.useEffect(()=>{w===k&&clearInterval(R)},[R,w,k]);const I=k-w,B=Math.floor(I/60),X=I%60;return l?jsxRuntimeExports.jsx("div",{className:`${f?"notes--results":`lectures--container lectures--container--${C}`} ${!f&&(h!=null&&h.url)?"lectures--container--with-custom-bg":""}`,style:!f&&(h!=null&&h.url)?{backgroundImage:`url('${h.url}')`}:{},children:jsxRuntimeExports.jsx("div",{className:f?"":"lectures__overlay",children:jsxRuntimeExports.jsxs("div",{className:f?"notes--results__text":`lectures lectures--${C}`,children:[jsxRuntimeExports.jsx("div",{className:"lectures--title",children:e}),jsxRuntimeExports.jsxs("div",{className:"lectures--text",dir:"auto",children:[jsxRuntimeExports.jsx("div",{children:O?HTMLReactParser$1(O):null}),f?null:jsxRuntimeExports.jsx(LectureButtons,{goToLecture:D,close:$,minutes:B,seconds:X,btnText:U("screens.continue")})]})]})})}):null}LecturesComponent.defaultProps={emitEvent:()=>{},name:"",text:"",visible:!1,documentType:"",viewed:!1,required:!1,context:{},styles:""};function Slot({character:o,active:e,slot:r,lowQuality:t}){var E;const n=o.type==="image",a=o.type==="character",l=o.type==="object",u=(E=o==null?void 0:o.resource)==null?void 0:E.url,f=()=>n?`url(${u})`:a&&t?`url(${u.replace("character.glb","face.png")})`:l&&t?`url(${u.replace("object.glb","thumbnail.png")})`:"",d=()=>n?"contain":a||l?"auto 95%":"",h=()=>n?"center":a||l?"center bottom":"",y=n||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:h(),backgroundSize:d()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${r}`,style:y,children:e&&o.name?jsxRuntimeExports.jsx("span",{className:"conversation--character__name",children:o.name}):null},o.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};const defaultCamPos=[0,14.63,16],boneWhiteList=["l_eye_jnt","l_eye","eye_l","head_m"],isMobile=DeviceDetection(),loader$1=new GLTFLoader;function Panel({character:o,ttsStarted:e,active:r,emitEvent:t}){var g,x,C,R,S;const n=React$2.useRef(null),a=React$2.useRef(null),l=o.type==="character",u=React$2.useRef(),[f,d]=React$2.useState(!1),h=React$2.useMemo(()=>t({type:"currentLod"}),[t]),y=React$2.useRef(),E=React$2.useMemo(()=>{var A,T,w,P,O,k,D,F;return l?o.animationId&&((A=o.animation)!=null&&A.url)?o.animation:(P=(w=(T=o==null?void 0:o.resource)==null?void 0:T.animations)==null?void 0:w[o.emotion])!=null&&P.url?(k=(O=o==null?void 0:o.resource)==null?void 0:O.animations)==null?void 0:k[o.emotion]:(F=(D=o==null?void 0:o.resource)==null?void 0:D.animations)==null?void 0:F.neutral:{}},[o.emotion,o==null?void 0:o.animationId,o==null?void 0:o.animation,(g=o==null?void 0:o.resource)==null?void 0:g.animations,l]),p=React$2.useCallback(()=>{const{clipAction:A,defaultAnim:T}=y.current.userData.animation;T&&A(T,y.current)},[]);React$2.useEffect(()=>{var A,T,w;if(y.current)if(r)if(e){const P=(w=(T=(A=o==null?void 0:o.resource)==null?void 0:A.animations)==null?void 0:T.talking)==null?void 0:w.url;P&&loader$1.load(P,({animations:O})=>{const{defaultAnim:k,clipAction:D}=y.current.userData.animation;D(mixWithTalkingClip(O[0],k),y.current),d(!0)})}else p();else f&&p()},[(R=(C=(x=o==null?void 0:o.resource)==null?void 0:x.animations)==null?void 0:C.talking)==null?void 0:R.url,e,r,p,f]);const _=React$2.useCallback(A=>{var T;if(n.current){const w=new three.Box3;w.setFromObject(A);const P=w.getSize(new three.Vector3);if(n.current.position.fromArray(defaultCamPos),n.current.rotation.set(0,0,0),n.current.updateProjectionMatrix(),n.current.layers.enableAll(),o.type==="character"){y.current=A;let O;const k=(T=o.emotion)==null?void 0:T.includes("seated");n.current.position.setY(P.y-1.5*1.3),A.traverse(D=>{const F=D.name.toLowerCase();if(D.isBone&&boneWhiteList.includes(F)){const G=k?1:0,V=new three.Vector3().setFromMatrixPosition(D.matrixWorld);if(F==="head_m"){O=V;return}n.current.position.setY(V.y-G),n.current.position.setX(V.x-.5)}}),O&&!k&&n.current.lookAt(O),n.current.zoom=1.5}else o.type==="object"&&(cameraFitAnyObject(A,n.current),n.current.zoom=1);n.current.updateProjectionMatrix()}},[o.type,o.emotion]);return fiber.useFrame(({gl:A})=>{if(n.current&&a.current){const T=document.getElementsByClassName("conversation--character__item")[o.slot];if(T){const w=T.getBoundingClientRect(),P=T.parentNode.getBoundingClientRect(),[O,k]=[w.right-w.left,w.bottom-w.top];n.current.aspect=O/k,n.current.updateProjectionMatrix();const D={top:w.top-P.top,right:w.right-P.right,left:w.left-P.left,bottom:w.bottom-P.bottom};u.current&&_(u.current);const F=isMobile?24:40;D.bottom+=r?-F:F,A.setViewport(D.left,D.bottom,O,k),A.setScissor(D.left,D.bottom,O,k),A.render(a.current,n.current)}}},1),o.type==="image"?null:jsxRuntimeExports.jsxs("scene",{ref:a,children:[(S=o.resource)!=null&&S.url?jsxRuntimeExports.jsx(arcadeThreeCore.QualityManager,{lod:h,children:jsxRuntimeExports.jsx(arcadeThreeCore.SceneResource,{ref:u,name:`char_${o.uid}`,url:o.resource.url,animationUrl:E.url,type:o.type,position:[0,0,0],onLoad:_,interactive:!1})}):null,jsxRuntimeExports.jsx(drei.PerspectiveCamera,{name:`camera_${o.uid}`,fov:35,focus:10,ref:n,position:defaultCamPos,makeDefault:!0,defaultCamera:!0}),jsxRuntimeExports.jsx(LightSet,{})]})}const Panels=({characters:o,slots:e,ttsStarted:r,activeIndex:t,flex:n,lodSettings:a,emitEvent:l})=>e.map((u,f)=>{let d=null;const h=o.findIndex(y=>y&&y.uid===u.uid);if(h>=0){const y=n?h:f;return d={...o[h]},d.slot=y,jsxRuntimeExports.jsx(Panel,{character:d,active:t===y,lodSettings:a,ttsStarted:r,emitEvent:l},`${`${d.uid}_${f}`}_${h}`)}return null});function PanelsWrapper({characters:o,slots:e,ttsStarted:r,slotRefs:t,flex:n,currentMessage:a,emitEvent:l}){return fiber.useFrame(({gl:u})=>{u.setScissorTest(!1),u.clear(!0,!0),u.setScissorTest(!0)}),jsxRuntimeExports.jsx(Panels,{ttsStarted:r,characters:o,slots:e,slotRefs:t,flex:n,activeIndex:a.position,emitEvent:l})}function Scene(o){return o.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)},frameloop:"demand",children:[jsxRuntimeExports.jsx(arcadeThreeCore.SettingsController,{current:{animate:o.pause}}),jsxRuntimeExports.jsx(React$2.Suspense,{fallback:null,children:jsxRuntimeExports.jsx(PanelsWrapper,{...o})})]})}function SlotList({characters:o,actors:e,lodSettings:r,ttsStarted:t,currentMessage:n,flex:a,slots:l,children:u,pause:f,emitEvent:d}){const h=({character:C,active:R,slot:S})=>({character:C,active:R,emotion:R?n.emotion:"neutral",slot:S}),E=React$2.useMemo(()=>d({type:"currentLod"}),[d])==="divideby64",p=l.reduce((C,R)=>{var T,w;const S=e==null?void 0:e.find(P=>P.uid===R.uid),A={...R};if(R.character)A.name=R.alias||R.character.name,A.resource=A.character.resource,A.position=A.position>=0?A.position:-1,delete A.character,A.type="character",C.push(A);else if(S){const{resource:P}=S;A.name=R.alias||R.name,A.position=A.position>=0?A.position:-1,A.resource=P,A.type=S.type,C.push(A)}else R.type?(A.name=R.alias||((T=R.character)==null?void 0:T.name)||R.name,A.resource=((w=A.character)==null?void 0:w.resource)||R.resource,A.position=A.position>=0?A.position:-1,delete A.character,A.type=R.type,C.push(A)):a||C.push(null);return C},[]),_=p.length&&p.some(C=>C),g=o.filter(C=>l.find(R=>C.uid===R.uid));function x(){return _?p.map((C,R)=>C?jsxRuntimeExports.jsx(Slot,{emitEvent:d,lowQuality:E,...h({character:C,active:n.position===C.position,slot:R})},`${C.uid+R}`):jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${R}`},`void_${0+R}`)):a?g.map((C,R)=>{const S=n.position===R;return jsxRuntimeExports.jsx(Slot,{...h({character:C,active:S,slot:R})},`${C.uid+R}`)}):l.length>0?l.map((C,R)=>{const S=o.find(A=>A.uid===C.uid);if(S){const A=n.position===R;return S.name=C.alias||S.name,jsxRuntimeExports.jsx(Slot,{...h({character:S,active:A,slot:R})},`${S.uid+R}`)}return jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${R}`},`${0+R}`)}):null}return jsxRuntimeExports.jsxs("div",{className:"conversation--characters",children:[jsxRuntimeExports.jsx(Scene,{characters:_?p:g,slots:l,flex:a,currentMessage:n,lodSettings:r,ttsStarted:t,pause:f,emitEvent:d,lowQuality:E}),u||jsxRuntimeExports.jsx(x,{})]})}SlotList.defaultProps={characters:[],currentMessage:{},flex:!0,slots:[]};function Options({inherited:o,options:e,selectedChoice:r,selectChoice:t,showingResults:n,simplifiedOptions:a,required:l}){const[u,f]=React$2.useState(null),d=y=>{a?(f(y.id),setTimeout(()=>{t(y)},1e3)):t(y)},h=y=>!!(n&&r.id===y.id||r.right===!0||n&&!l);return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:e&&e.filter(y=>y.text).map(y=>jsxRuntimeExports.jsxs("div",{className:`${o?"conversation--question custom-radio":"custom-radio"}
67
67
  ${u===y.id?"radio-text-clicked":""}`,children:[jsxRuntimeExports.jsx("input",{onChange:()=>{d(y)},className:"radio",type:"radio",id:y.text,name:y.id,defaultChecked:r.id===y.id,disabled:h(y)}),jsxRuntimeExports.jsx("label",{className:`${y.right?"radio-text-success":"radio-text-fail"}`,htmlFor:y.text,children:y.text})]},y.id))})}const noop=()=>{};function BasicDecision({children:o,question:e,showingResults:r,selected:t,required:n,failed:a,onNext:l,translate:u,hasRewards:f,options:d}){return jsxRuntimeExports.jsxs("div",{className:`popup popup__large popup__basicDecision ${r&&t.feedback?"popup__feedback":""}`,children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:r?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[o,!t.feedback&&f.length===0&&jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e!==""&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:e})}),!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:jsxRuntimeExports.jsx(Options,{...d})}),jsxRuntimeExports.jsx("div",{className:"popup--buttons",children:(n?!a:t.id!==void 0)?jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn__navigation ${t.id!==void 0?"":"disabled"}`,onClick:()=>t.id!==void 0&&l(),"aria-label":u("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null})]})}function ComplexDecision({question:o,inScene:e,disabled:r,onNext:t,children:n}){return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`conversation--body ${e?"conversation--body--inScene":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"conversation--message",children:[o!==""&&jsxRuntimeExports.jsx("span",{className:"conversation--main__text",children:o}),n]}),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 ${r?"disabled":""}`,type:"button",onClick:()=>!r&&t(),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})}function DecisionBody({options:o,question:e,inherited:r,branched:t,changeOption:n,onNext:a,failed:l,showingResults:u,currentSelectedChoice:f,children:d,translate:h,hasRewards:y,inScene:E,required:p,simplifiedOptions:_}){const[g,x]=React$2.useState(f),C=A=>{x(A),u&&l&&n(A),a(A)},R=!u&&g.id!==void 0||!l,S={inherited:r,selectedChoice:g,selectChoice:(!p||t)&&g.id!==void 0||p&&!l?noop:C,options:o,showingResults:u,simplifiedOptions:_,required:p};return r?jsxRuntimeExports.jsx(ComplexDecision,{disabled:!R,question:e,inScene:E,onNext:()=>a(g),children:jsxRuntimeExports.jsx(Options,{...S})}):jsxRuntimeExports.jsx(BasicDecision,{question:e,showingResults:u,selected:g,required:p,failed:l,onNext:()=>a(g),translate:h,hasRewards:y,options:S,children:d})}function Wrapper({children:o,inherit:e,feedback:r}){return e?jsxRuntimeExports.jsx("div",{className:`conversation--feedback ${r?"":"only--rewards"}`,children:o}):r?o:jsxRuntimeExports.jsx("div",{className:"popup__basicDecision__only--rewards only--rewards",children:o})}function FeedBack({choice:o,inherited:e,question:r}){return o.feedback?jsxRuntimeExports.jsx(Wrapper,{inherit:e,feedback:o.feedback,children:o.feedback?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"conversation--feedback__title",children:r}),jsxRuntimeExports.jsxs("div",{className:"conversation--feedback__text",dir:"auto",children:[o.right?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("p",{children:o.feedback})]})]}):null}):null}function DecisionComponent({emitEvent:o,soundActions:e,keyboardControl:r,inScene:t,...n}){const{inheritProps:a={},decisionNumber:l,required:u,question:f,onAddPoints:d,onFinish:h,branched:y,simplifiedOptions:E}=n,p=Object.keys(a).length>0,[_,g]=React$2.useState("options"),[x,C]=React$2.useState({}),[R]=e,S=u&&!x.right,A=V=>{var W;(W=V.audio)!=null&&W.url&&R(V.audio.url,"audio_file",!1,V.audioVolume)},T={...a,slots:a.slots?a.slots:a.characters,currentMessage:{position:null,emotion:""},emitEvent:o};a&&a.flex&&T.slots&&(T.characters=T.characters.filter(V=>T.slots.find(W=>W.uid===V.uid)));const w=V=>{o({type:"decisionJournal",payload:{choice:V,decisionNumber:l}})},P=V=>{!S&&_==="results"?(R("click-ui"),p?E?h&&(w(V),h(V,()=>{C({}),g("options")})):(d&&d(V),w(V),o({type:"addPoints",payload:V.rewards,finish:!1,complex:!0,onFinish:()=>{h?h(V,()=>{C({}),g("options")}):o({type:"success"}),C({}),g("options")}})):(w(V),o({type:"addPoints",payload:V.rewards,finish:!0,complex:!0}))):Object.keys(V).length>0&&(R("click-ui"),E?(w({...V,simplified:!0}),h(V,()=>{C({}),g("options")})):(V.right?R("score"):(R("fail"),y||(p||u?(w(V),o({type:"addPoints",payload:V.rewards,finish:!1,complex:!0})):u||(C({}),g("options")))),C(V),A(V),g("results")))},O={...n,selectView:g,selectedView:_,emitEvent:o,inherited:p,branched:y,soundActions:e,showingResults:_==="results",currentSelectedChoice:x,hasRewards:x.rewards||[],failed:S,inScene:t,required:u,simplifiedOptions:E,changeOption:V=>{R("click-ui"),C(V),g("options")},onNext:P,translate:V=>o({type:"translate",payload:V})};r(null,_==="results"&&!S?()=>{P(x)}:null);const k=({children:V})=>p?jsxRuntimeExports.jsx("div",{className:`conversation--layer
68
68
  ${x.feedback?"":"conversation--layer__defaultFeedback"}
69
- ${_==="results"?"conversation--layer__feedback":""}`,children:V}):V,D=({children:V})=>jsxRuntimeExports.jsx("div",{className:"popup--layer",children:V}),F=({children:V})=>{var ee,q;let W={};return W=(ee=a.background)!=null&&ee.img?{backgroundImage:`url("${(q=a.background.img)==null?void 0:q.url}")`}:null,jsxRuntimeExports.jsxs("div",{className:`conversation ${t?"conversation--inScene":""}`,style:W,children:[jsxRuntimeExports.jsx(SlotList,{...T,children:V}),jsxRuntimeExports.jsx(DecisionBody,{...O})]})},G=()=>p?jsxRuntimeExports.jsx(F,{children:_==="results"&&x.feedback?jsxRuntimeExports.jsx(FeedBack,{question:f,soundActions:e,inherited:p,choice:x,rewards:x.rewards||[],emitEvent:o}):null}):jsxRuntimeExports.jsx(D,{children:jsxRuntimeExports.jsx(DecisionBody,{...O,children:jsxRuntimeExports.jsx(FeedBack,{question:f,soundActions:e,inherited:p,choice:x,rewards:x.rewards||[],emitEvent:o})})});return jsxRuntimeExports.jsx(k,{children:jsxRuntimeExports.jsx(G,{})})}function ImageComponent({emitEvent:o,img:e,imgName:r,documentType:t,visible:n,viewed:a,imgId_labelId:l,soundActions:u,keyboardControl:f}){const d=g=>o({type:"translate",payload:g}),[h,y]=React$2.useState(!1),E=e.url,[p]=u,_=React$2.useCallback(()=>{p("click-ui"),o({type:"finishMedia",payload:{imgId:l,name:r,imgName:r,documentType:t,type:"image"}})},[p,l,r,t,o]);return f(null,a?null:_,a?null:_),React$2.useEffect(()=>{!n&&!h&&(y(!0),_())},[_,n,h]),n?jsxRuntimeExports.jsx("div",{className:a?"notes--results":"readings--container readings--container--darkopacity",children:jsxRuntimeExports.jsxs("div",{className:a?"notes--results__text":"readings readings--image",children:[E&&jsxRuntimeExports.jsx("img",{src:E,alt:r}),a?null:jsxRuntimeExports.jsx("div",{className:E?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:_,"aria-label":d("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})})]})}):null}function VoiceOver({name:o}){return jsxRuntimeExports.jsx("div",{className:"conversation--voice__over",children:jsxRuntimeExports.jsx("span",{children:o||"Voice-Over"})})}function ThinkFul({text:o}){return jsxRuntimeExports.jsxs("div",{className:"conversation--voice__over",children:[jsxRuntimeExports.jsx("span",{className:"icon-bubble-thinkful-black"}),jsxRuntimeExports.jsxs("span",{children:["[",o,"]"]})]})}function Message({current:o,translate:e}){var t,n;const r=o.text;return jsxRuntimeExports.jsxs("div",{className:`conversation--message ${o.voiceOver||(t=o==null?void 0:o.emotion)!=null&&t.includes("think")?"voice--over":""}`,children:[o.voiceOver?jsxRuntimeExports.jsx(VoiceOver,{name:o.name}):null,(n=o==null?void 0:o.emotion)!=null&&n.includes("think")?jsxRuntimeExports.jsx(ThinkFul,{text:e("emotion.thinking")}):null,jsxRuntimeExports.jsx("span",{className:"conversation--main__text",children:r})]})}Message.defaultProps={current:{},voiceOver:!1};const characterMs$2=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:o,emitEvent:e,pause:r,lines:t,edges:n,characters:a,actors:l,background:u,soundActions:f,lodSettings:d,autoPlay:h,autoEnd:y,progress:E}){var et,nt,qt;const p=(E==null?void 0:E.line)||0,[_,g]=React$2.useState(!1),[x,C]=React$2.useState(!0),[R,S]=React$2.useState(!!h),[A,T]=React$2.useState(!1),[w,P]=React$2.useState(p),[O,k]=React$2.useState(!1),[D]=f,{start:F,stop:G}=useTimeout(),V=((et=u==null?void 0:u.img)==null?void 0:et.url)||null,W=t[w],{voiceOver:ee,decision:q}=W;let z=[];const U=!!n,$=ee||W.type==="conversationalNarration",I=q||W.type==="conversationalDecision";let{flex:B}=W;const[X,Q]=React$2.useState([]),J=React$2.useMemo(()=>X[X.length-1],[X]),ne=React$2.useCallback(()=>{const We=n.find(pe=>pe.fromId===J)||n.find(pe=>pe.toId===J),at=t.find(pe=>pe.id===(We==null?void 0:We.fromId));return!J&&(E==null?void 0:E.line)>=0?{decision:!0}:at},[n,t,J,E==null?void 0:E.line]),ae=React$2.useCallback(()=>{if(U){const at=ne();return at==null?void 0:at.decision}const We=t[w-1]?t[w-1]:{};return w>0&&(We==null?void 0:We.decision)},[U,ne,t,w]),Z=React$2.useCallback(We=>e({type:"translate",payload:We}),[e]),se=React$2.useMemo(()=>{var at,pe;if(I)return{};if($)return W;const We=(at=W==null?void 0:W.slots)==null?void 0:at.find(me=>me.uid&&me.talking);return We||((pe=W==null?void 0:W.slots)==null?void 0:pe.find(me=>me.uid&&me.text))},[W,$,I]),oe=t.slice(0,w+1).reverse().find(We=>We.slots),fe=!I&&((nt=W.slots)==null?void 0:nt.filter(We=>We.uid).length),de=characterMs$2*(((qt=se==null?void 0:se.text)==null?void 0:qt.length)||0);let ce=[];W.slots?ce=W.slots:oe&&(ce=oe.slots);const Ee=ce.filter(We=>We.uid).map(We=>{const at=(a||l||[]).find(pe=>pe.uid===We.uid);return at&&(We.resource=at.resource,We.type=at.type),We.resource||(We.resource={}),We}),De={characters:Ee,lodSettings:d,actors:l,currentMessage:se||{},slots:$?z:W.slots,flex:B,pause:r,emitEvent:e};if($){const We=t.slice(w).find(pe=>pe.slots),at=oe||We;at&&(z=at.slots,B=at.flex)}else if(!I&&fe&&(W.slots.forEach(We=>{const at=Ee.findIndex(pe=>pe.uid===We.uid);at>=0&&(Ee[at].emotion=We.emotion)}),se&&se.uid)){const We=W.slots.findIndex(pe=>pe.uid===se.uid),at=Ee.findIndex(pe=>pe.uid===se.uid);Ee.forEach(pe=>{pe.uid===se.uid&&(pe.name=se.alias)}),se.position=B?at:We}const we=React$2.useCallback(()=>{e({type:"success"})},[e]),He=React$2.useCallback((We,at)=>{const pe=[3,2,1][We.id],ye=n.filter(ke=>ke.fromId===W.id).find(ke=>parseInt(ke.fromPointIndex)===pe);if(ye){const ke=t.findIndex(Ge=>Ge.id===ye.toId);ye.fromId===ye.toId?at():ke>=0?(P(ke),e({type:"notifyProgress",payload:{line:ke}})):we()}else we()},[W.id,n,e,we,t]),Xe=React$2.useCallback((We=!0)=>{const at=We?["fromId","toId"]:["toId","fromId"],pe=n.filter(ke=>ke[at[0]]===W.id),me=pe.length===1?pe[0]:pe.find(ke=>ke[at[1]]===J);if(!(me!=null&&me[at[0]]))return;We||Q(X.slice(0,-1));const ye=t.findIndex(ke=>ke.id===me[at[1]]);ye>=0?(P(ye),e({type:"notifyProgress",payload:{line:ye}})):we()},[W.id,n,X,e,we,J,t]),Qe=React$2.useCallback(We=>{if(U){if(We){const at=[3,2,1][We.id],me=n.filter(ye=>ye.fromId===W.id).find(ye=>parseInt(ye.fromPointIndex)===at);if(me){const ye=t.findIndex(ke=>ke.id===me.toId);ye>=0&&e({type:"notifyProgress",payload:{line:ye}})}else e({type:"saveNode"})}}else if(w<t.length-1){const pe=w+1;e({type:"notifyProgress",payload:{line:pe}})}else e({type:"saveNode"})},[n,t,e,w,W.id,U]),dt=React$2.useCallback((We,at)=>{let pe=!1;if(k(!1),Q([...X,W.id]),C(!1),T(!1),U)We?He(We,at):Xe();else if(w<t.length-1){const ye=w+1;P(ye),e({type:"notifyProgress",payload:{line:ye}})}else y||W.decision?we():pe=!0;pe||C(!0)},[y,e,w,W.decision,W.id,we,Xe,He,U,t.length,X]),_t=()=>{if(C(!1),k(!1),T(!1),U)Xe(!1);else if(!ae()){const We=w-1;P(We),e({type:"notifyProgress",payload:{line:We}})}C(!0)},ut=React$2.useCallback(()=>U?W&&W.type!=="conversationalDecision"&&!n.find(We=>We.fromId===W.id):w===t.length-1,[w,W,n,U,t.length]),ft=()=>{D("click-ui"),ut()?we():(S(!1),dt())},Xt=()=>{D("click-ui"),S(!1),_t()},kt=R&&!I&&!r,Ue=React$2.useMemo(()=>w===0||ae(),[w,ae]);if(useEkho({audioType:W==null?void 0:W.audioType,volume:W==null?void 0:W.audioVolume,voice:W==null?void 0:W.voice,started:x,slide:w,text:se==null?void 0:se.text,audio:W==null?void 0:W.audio,soundActions:f,emitEvent:e,pauseTTS:r,onStart:()=>{var We;(We=se==null?void 0:se.emotion)!=null&&We.includes("think")||k(!0)},onError:()=>{T(!0)},onFinish:()=>{k(!1),kt&&dt()}}),React$2.useEffect(()=>{var at;let We;return I?()=>{}:(((W==null?void 0:W.audioType)==="none"||A)&&!((at=se==null?void 0:se.emotion)!=null&&at.includes("think"))&&(k(!0),We=setTimeout(()=>{k(!1)},de<minMs$1?minMs$1:de)),()=>{We&&clearTimeout(We)})},[A,W,se==null?void 0:se.emotion,de,I]),React$2.useEffect(()=>(kt&&((W==null?void 0:W.audioType)==="none"||A)&&(!ut()||ut()&&y)&&F(dt,de<minMs$1?minMs$1:de),()=>{G()}),[se,F,G,dt,W==null?void 0:W.audioType,kt,A,y,t,ut,de]),React$2.useEffect(()=>{if(U&&!_){const We=E==null?void 0:E.line;if(We>=0){g(!0),P(We);return}const at=t.filter(pe=>!n.find(me=>me.toId===pe.id));if(at.length){const pe=at[0],me=t.indexOf(pe);me>=0&&(g(!0),P(me))}}},[n,U,t,_,E==null?void 0:E.line]),o(I||Ue?null:Xt,I?null:ft),I){const We={...W.payload,decisionNumber:t.filter(at=>at.decision).findIndex(at=>at.id===t[w].id)+1,required:!U,branched:U,onAddPoints:Qe,onFinish:dt,keyboardControl:o,emitEvent:e,soundActions:f,inheritProps:{characters:Ee,background:u,flex:oe?oe.flex:!0,slots:oe?oe.slots:[]}};return jsxRuntimeExports.jsx(DecisionComponent,{...We})}return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{className:"conversation",style:V?{backgroundImage:`url("${V}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...De,ttsStarted:O}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[se?jsxRuntimeExports.jsx(Message,{current:se,translate:Z}):null,jsxRuntimeExports.jsxs("div",{className:"conversation--controls",children:[jsxRuntimeExports.jsx("button",{className:`gat--btn__round ${Ue?"disabled":""}`,disabled:Ue?!0:"",type:"button",onClick:Xt,"aria-label":LangIsRtl()?Z("storylines.misc.forward"):Z("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{className:`gat--btn__round ${R&&ut()?"glowing-animation":""}`,type:"button",onClick:ft,"aria-label":LangIsRtl()?Z("storylines.misc.rewind"):Z("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:o,soundActions:e,messages:r,characters:t,alias:n,background:a,lodSettings:l}){var g;const[u,f]=React$2.useState(0),[d]=e,h=((g=a==null?void 0:a.img)==null?void 0:g.url)||null,y=r[u],E=t.map((x,C)=>({...x,name:n[C]?n[C]:x.name,uid:C})),p=()=>{const x=r.length-1;d("click-ui"),u+1<=x?f(u+1):o({type:"success"})},_=()=>{u>0&&(f(u-1),d("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{className:"conversation arcade-conversation",style:h?{backgroundImage:`url("${h}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:E,lodSettings:l,currentMessage:y,slots:E,emitEvent:o,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[y?jsxRuntimeExports.jsx(Message,{current:y,voiceOver:y.emotion===null}):jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"conversation--controls arcade-conversation--controls",children:[jsxRuntimeExports.jsx("button",{className:`gat--btn__round ${u>0?"":"visibility--hidden"}`,type:"button",onClick:_,children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("button",{className:"gat--btn__round",type:"button",onClick:p,children:jsxRuntimeExports.jsx("span",{className:"icon-next"})})]})]})]})})}function Vignette({vignette:o,alias:e,translate:r}){var f;const n=(o.img||{url:"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg"}).url,[a,l]=React$2.useState(!0),u=d=>{document.querySelector(`#${d}`).focus(),l(!a)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"comic--image",children:n&&jsxRuntimeExports.jsx("img",{src:n,alt:"comic pic"})}),(f=o==null?void 0:o.textData)!=null&&f.text?jsxRuntimeExports.jsxs("div",{className:`comic-collapsable ${a?"comic-collapsable--opened":""}`,children:[jsxRuntimeExports.jsx("button",{id:"buttonDown",onClick:()=>u("buttonUp"),type:"button",className:"un-btn comic-collapsable__headertoggle","aria-label":r("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,o.textData.text]})]}):null,jsxRuntimeExports.jsx("button",{id:"buttonUp",tabIndex:a?"-1":"0","aria-hidden":a,className:`unset-button comic-buttonup
69
+ ${_==="results"?"conversation--layer__feedback":""}`,children:V}):V,D=({children:V})=>jsxRuntimeExports.jsx("div",{className:"popup--layer popup--layer--transparent",children:V}),F=({children:V})=>{var ee,q;let W={};return W=(ee=a.background)!=null&&ee.img?{backgroundImage:`url("${(q=a.background.img)==null?void 0:q.url}")`}:null,jsxRuntimeExports.jsxs("div",{className:`conversation ${t?"conversation--inScene":""}`,style:W,children:[jsxRuntimeExports.jsx(SlotList,{...T,children:V}),jsxRuntimeExports.jsx(DecisionBody,{...O})]})},G=()=>p?jsxRuntimeExports.jsx(F,{children:_==="results"&&x.feedback?jsxRuntimeExports.jsx(FeedBack,{question:f,soundActions:e,inherited:p,choice:x,rewards:x.rewards||[],emitEvent:o}):null}):jsxRuntimeExports.jsx(D,{children:jsxRuntimeExports.jsx(DecisionBody,{...O,children:jsxRuntimeExports.jsx(FeedBack,{question:f,soundActions:e,inherited:p,choice:x,rewards:x.rewards||[],emitEvent:o})})});return jsxRuntimeExports.jsx(k,{children:jsxRuntimeExports.jsx(G,{})})}function ImageComponent({emitEvent:o,img:e,imgName:r,documentType:t,visible:n,viewed:a,imgId_labelId:l,soundActions:u,keyboardControl:f}){const d=g=>o({type:"translate",payload:g}),[h,y]=React$2.useState(!1),E=e.url,[p]=u,_=React$2.useCallback(()=>{p("click-ui"),o({type:"finishMedia",payload:{imgId:l,name:r,imgName:r,documentType:t,type:"image"}})},[p,l,r,t,o]);return f(null,a?null:_,a?null:_),React$2.useEffect(()=>{!n&&!h&&(y(!0),_())},[_,n,h]),n?jsxRuntimeExports.jsx("div",{className:a?"notes--results":"readings--container readings--container--darkopacity",children:jsxRuntimeExports.jsxs("div",{className:a?"notes--results__text":"readings readings--image",children:[E&&jsxRuntimeExports.jsx("img",{src:E,alt:r}),a?null:jsxRuntimeExports.jsx("div",{className:E?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:_,"aria-label":d("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})})]})}):null}function VoiceOver({name:o}){return jsxRuntimeExports.jsx("div",{className:"conversation--voice__over",children:jsxRuntimeExports.jsx("span",{children:o||"Voice-Over"})})}function ThinkFul({text:o}){return jsxRuntimeExports.jsxs("div",{className:"conversation--voice__over",children:[jsxRuntimeExports.jsx("span",{className:"icon-bubble-thinkful-black"}),jsxRuntimeExports.jsxs("span",{children:["[",o,"]"]})]})}function Message({current:o,translate:e}){var t,n;const r=o.text;return jsxRuntimeExports.jsxs("div",{className:`conversation--message ${o.voiceOver||(t=o==null?void 0:o.emotion)!=null&&t.includes("think")?"voice--over":""}`,children:[o.voiceOver?jsxRuntimeExports.jsx(VoiceOver,{name:o.name}):null,(n=o==null?void 0:o.emotion)!=null&&n.includes("think")?jsxRuntimeExports.jsx(ThinkFul,{text:e("emotion.thinking")}):null,jsxRuntimeExports.jsx("span",{className:"conversation--main__text",children:r})]})}Message.defaultProps={current:{},voiceOver:!1};const characterMs$2=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:o,emitEvent:e,pause:r,lines:t,edges:n,characters:a,actors:l,background:u,soundActions:f,lodSettings:d,autoPlay:h,autoEnd:y,progress:E}){var et,nt,qt;const p=(E==null?void 0:E.line)||0,[_,g]=React$2.useState(!1),[x,C]=React$2.useState(!0),[R,S]=React$2.useState(!!h),[A,T]=React$2.useState(!1),[w,P]=React$2.useState(p),[O,k]=React$2.useState(!1),[D]=f,{start:F,stop:G}=useTimeout(),V=((et=u==null?void 0:u.img)==null?void 0:et.url)||null,W=t[w],{voiceOver:ee,decision:q}=W;let z=[];const U=!!n,$=ee||W.type==="conversationalNarration",I=q||W.type==="conversationalDecision";let{flex:B}=W;const[X,Q]=React$2.useState([]),J=React$2.useMemo(()=>X[X.length-1],[X]),ne=React$2.useCallback(()=>{const We=n.find(pe=>pe.fromId===J)||n.find(pe=>pe.toId===J),at=t.find(pe=>pe.id===(We==null?void 0:We.fromId));return!J&&(E==null?void 0:E.line)>=0?{decision:!0}:at},[n,t,J,E==null?void 0:E.line]),ae=React$2.useCallback(()=>{if(U){const at=ne();return at==null?void 0:at.decision}const We=t[w-1]?t[w-1]:{};return w>0&&(We==null?void 0:We.decision)},[U,ne,t,w]),Z=React$2.useCallback(We=>e({type:"translate",payload:We}),[e]),se=React$2.useMemo(()=>{var at,pe;if(I)return{};if($)return W;const We=(at=W==null?void 0:W.slots)==null?void 0:at.find(me=>me.uid&&me.talking);return We||((pe=W==null?void 0:W.slots)==null?void 0:pe.find(me=>me.uid&&me.text))},[W,$,I]),oe=t.slice(0,w+1).reverse().find(We=>We.slots),fe=!I&&((nt=W.slots)==null?void 0:nt.filter(We=>We.uid).length),de=characterMs$2*(((qt=se==null?void 0:se.text)==null?void 0:qt.length)||0);let ce=[];W.slots?ce=W.slots:oe&&(ce=oe.slots);const Ee=ce.filter(We=>We.uid).map(We=>{const at=(a||l||[]).find(pe=>pe.uid===We.uid);return at&&(We.resource=at.resource,We.type=at.type),We.resource||(We.resource={}),We}),De={characters:Ee,lodSettings:d,actors:l,currentMessage:se||{},slots:$?z:W.slots,flex:B,pause:r,emitEvent:e};if($){const We=t.slice(w).find(pe=>pe.slots),at=oe||We;at&&(z=at.slots,B=at.flex)}else if(!I&&fe&&(W.slots.forEach(We=>{const at=Ee.findIndex(pe=>pe.uid===We.uid);at>=0&&(Ee[at].emotion=We.emotion)}),se&&se.uid)){const We=W.slots.findIndex(pe=>pe.uid===se.uid),at=Ee.findIndex(pe=>pe.uid===se.uid);Ee.forEach(pe=>{pe.uid===se.uid&&(pe.name=se.alias)}),se.position=B?at:We}const we=React$2.useCallback(()=>{e({type:"success"})},[e]),He=React$2.useCallback((We,at)=>{const pe=[3,2,1][We.id],ye=n.filter(ke=>ke.fromId===W.id).find(ke=>parseInt(ke.fromPointIndex)===pe);if(ye){const ke=t.findIndex(Ge=>Ge.id===ye.toId);ye.fromId===ye.toId?at():ke>=0?(P(ke),e({type:"notifyProgress",payload:{line:ke}})):we()}else we()},[W.id,n,e,we,t]),Xe=React$2.useCallback((We=!0)=>{const at=We?["fromId","toId"]:["toId","fromId"],pe=n.filter(ke=>ke[at[0]]===W.id),me=pe.length===1?pe[0]:pe.find(ke=>ke[at[1]]===J);if(!(me!=null&&me[at[0]]))return;We||Q(X.slice(0,-1));const ye=t.findIndex(ke=>ke.id===me[at[1]]);ye>=0?(P(ye),e({type:"notifyProgress",payload:{line:ye}})):we()},[W.id,n,X,e,we,J,t]),Qe=React$2.useCallback(We=>{if(U){if(We){const at=[3,2,1][We.id],me=n.filter(ye=>ye.fromId===W.id).find(ye=>parseInt(ye.fromPointIndex)===at);if(me){const ye=t.findIndex(ke=>ke.id===me.toId);ye>=0&&e({type:"notifyProgress",payload:{line:ye}})}else e({type:"saveNode"})}}else if(w<t.length-1){const pe=w+1;e({type:"notifyProgress",payload:{line:pe}})}else e({type:"saveNode"})},[n,t,e,w,W.id,U]),dt=React$2.useCallback((We,at)=>{let pe=!1;if(k(!1),Q([...X,W.id]),C(!1),T(!1),U)We?He(We,at):Xe();else if(w<t.length-1){const ye=w+1;P(ye),e({type:"notifyProgress",payload:{line:ye}})}else y||W.decision?we():pe=!0;pe||C(!0)},[y,e,w,W.decision,W.id,we,Xe,He,U,t.length,X]),_t=()=>{if(C(!1),k(!1),T(!1),U)Xe(!1);else if(!ae()){const We=w-1;P(We),e({type:"notifyProgress",payload:{line:We}})}C(!0)},ut=React$2.useCallback(()=>U?W&&W.type!=="conversationalDecision"&&!n.find(We=>We.fromId===W.id):w===t.length-1,[w,W,n,U,t.length]),ft=()=>{D("click-ui"),ut()?we():(S(!1),dt())},Xt=()=>{D("click-ui"),S(!1),_t()},kt=R&&!I&&!r,Ue=React$2.useMemo(()=>w===0||ae(),[w,ae]);if(useEkho({audioType:W==null?void 0:W.audioType,volume:W==null?void 0:W.audioVolume,voice:W==null?void 0:W.voice,started:x,slide:w,text:se==null?void 0:se.text,audio:W==null?void 0:W.audio,soundActions:f,emitEvent:e,pauseTTS:r,onStart:()=>{var We;(We=se==null?void 0:se.emotion)!=null&&We.includes("think")||k(!0)},onError:()=>{T(!0)},onFinish:()=>{k(!1),kt&&dt()}}),React$2.useEffect(()=>{var at;let We;return I?()=>{}:(((W==null?void 0:W.audioType)==="none"||A)&&!((at=se==null?void 0:se.emotion)!=null&&at.includes("think"))&&(k(!0),We=setTimeout(()=>{k(!1)},de<minMs$1?minMs$1:de)),()=>{We&&clearTimeout(We)})},[A,W,se==null?void 0:se.emotion,de,I]),React$2.useEffect(()=>(kt&&((W==null?void 0:W.audioType)==="none"||A)&&(!ut()||ut()&&y)&&F(dt,de<minMs$1?minMs$1:de),()=>{G()}),[se,F,G,dt,W==null?void 0:W.audioType,kt,A,y,t,ut,de]),React$2.useEffect(()=>{if(U&&!_){const We=E==null?void 0:E.line;if(We>=0){g(!0),P(We);return}const at=t.filter(pe=>!n.find(me=>me.toId===pe.id));if(at.length){const pe=at[0],me=t.indexOf(pe);me>=0&&(g(!0),P(me))}}},[n,U,t,_,E==null?void 0:E.line]),o(I||Ue?null:Xt,I?null:ft),I){const We={...W.payload,decisionNumber:t.filter(at=>at.decision).findIndex(at=>at.id===t[w].id)+1,required:!U,branched:U,onAddPoints:Qe,onFinish:dt,keyboardControl:o,emitEvent:e,soundActions:f,inheritProps:{characters:Ee,background:u,flex:oe?oe.flex:!0,slots:oe?oe.slots:[]}};return jsxRuntimeExports.jsx(DecisionComponent,{...We})}return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{className:"conversation",style:V?{backgroundImage:`url("${V}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...De,ttsStarted:O}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[se?jsxRuntimeExports.jsx(Message,{current:se,translate:Z}):null,jsxRuntimeExports.jsxs("div",{className:"conversation--controls",children:[jsxRuntimeExports.jsx("button",{className:`gat--btn__round ${Ue?"disabled":""}`,disabled:Ue?!0:"",type:"button",onClick:Xt,"aria-label":LangIsRtl()?Z("storylines.misc.forward"):Z("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{className:`gat--btn__round ${R&&ut()?"glowing-animation":""}`,type:"button",onClick:ft,"aria-label":LangIsRtl()?Z("storylines.misc.rewind"):Z("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:o,soundActions:e,messages:r,characters:t,alias:n,background:a,lodSettings:l}){var g;const[u,f]=React$2.useState(0),[d]=e,h=((g=a==null?void 0:a.img)==null?void 0:g.url)||null,y=r[u],E=t.map((x,C)=>({...x,name:n[C]?n[C]:x.name,uid:C})),p=()=>{const x=r.length-1;d("click-ui"),u+1<=x?f(u+1):o({type:"success"})},_=()=>{u>0&&(f(u-1),d("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{className:"conversation arcade-conversation",style:h?{backgroundImage:`url("${h}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:E,lodSettings:l,currentMessage:y,slots:E,emitEvent:o,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[y?jsxRuntimeExports.jsx(Message,{current:y,voiceOver:y.emotion===null}):jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"conversation--controls arcade-conversation--controls",children:[jsxRuntimeExports.jsx("button",{className:`gat--btn__round ${u>0?"":"visibility--hidden"}`,type:"button",onClick:_,children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("button",{className:"gat--btn__round",type:"button",onClick:p,children:jsxRuntimeExports.jsx("span",{className:"icon-next"})})]})]})]})})}function Vignette({vignette:o,alias:e,translate:r}){var f;const n=(o.img||{url:"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg"}).url,[a,l]=React$2.useState(!0),u=d=>{document.querySelector(`#${d}`).focus(),l(!a)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"comic--image",children:n&&jsxRuntimeExports.jsx("img",{src:n,alt:"comic pic"})}),(f=o==null?void 0:o.textData)!=null&&f.text?jsxRuntimeExports.jsxs("div",{className:`comic-collapsable ${a?"comic-collapsable--opened":""}`,children:[jsxRuntimeExports.jsx("button",{id:"buttonDown",onClick:()=>u("buttonUp"),type:"button",className:"un-btn comic-collapsable__headertoggle","aria-label":r("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,o.textData.text]})]}):null,jsxRuntimeExports.jsx("button",{id:"buttonUp",tabIndex:a?"-1":"0","aria-hidden":a,className:`unset-button comic-buttonup
70
70
  ${a?"":"comic-buttonup--visible"}`,type:"button",onClick:()=>u("buttonDown"),"aria-label":r("comic.toggleText"),children:jsxRuntimeExports.jsx("span",{className:"icon-up-arrow"})})]})}function Slide({slide:o,transition:e,translate:r}){const t=o.transitionEffects||e;return jsxRuntimeExports.jsx("div",{className:`comic--slide__item ${t}`,"aria-label":"comic slide item",children:o.vignettes.map(n=>jsxRuntimeExports.jsx(Vignette,{vignette:n,alias:o.alias,"aria-hidden":"true",translate:r},`Vignete ${n.vignetteOrder}`))})}const characterMs$1=75;function ComicComponent({slides:o,emitEvent:e,soundActions:r=[()=>{},()=>{}],autoPlay:t,autoEnd:n,pause:a,progress:l,keyboardControl:u}){var V,W,ee,q,z,U,$,I;const f=(l==null?void 0:l.slide)||0,d=B=>e({type:"translate",payload:B}),[h,y]=React$2.useState(!0),[E,p]=React$2.useState(!!t),[_,g]=React$2.useState(!1),{start:x,stop:C}=useTimeout(),[R,S]=React$2.useState(f),[A,T]=React$2.useState("slide-animation"),[w]=r,P=o==null?void 0:o[R],O=React$2.useCallback(()=>{y(!1),e({type:"success"})},[e]),k=React$2.useCallback(()=>{if(y(!1),g(!1),R+1<o.length&&!a){const B=R+1;T("slide-animation"),S(B),y(!0),e({type:"notifyProgress",payload:{slide:B}})}else n&&!a&&O()},[R,o.length,a,n,e,O]),D=React$2.useCallback(()=>{if(y(!1),g(!1),R-1>=0){const B=R-1;T("slide-animation"),S(B),y(!0),w("click-ui"),e({type:"notifyProgress",payload:{slide:B}})}},[w,R,e]),F=()=>{w("click-ui"),p(!1),k()},G=()=>{w("click-ui"),p(!1),D()};return u(R>0?G:null,R+1>=o.length&&O||(R+1<o.length?F:null),R+1>=o.length?O:null),useEkho({audioType:(V=o==null?void 0:o[R])==null?void 0:V.audioType,voice:(W=o==null?void 0:o[R])==null?void 0:W.voice,text:(q=(ee=o==null?void 0:o[R])==null?void 0:ee.vignettes[0].textData)==null?void 0:q.text,audio:(z=o==null?void 0:o[R])==null?void 0:z.audio,slide:R,started:h,soundActions:r,emitEvent:e,pauseTTS:a,volume:(U=o==null?void 0:o[R])!=null&&U.audioVolume||(($=o==null?void 0:o[R])==null?void 0:$.audioVolume)===0?(I=o==null?void 0:o[R])==null?void 0:I.audioVolume:.5,onError:()=>{g(!0)},onFinish:()=>{E&&!(P!=null&&P.slideTimer)&&k()}}),React$2.useEffect(()=>{var B,X;if(E){if(P!=null&&P.slideTimer)x(k,P.slideTimer*1e3);else if((P==null?void 0:P.audioType)==="none"&&!a||_&&!a){const Q=characterMs$1*(((X=(B=P==null?void 0:P.vignettes[0])==null?void 0:B.textData)==null?void 0:X.text.length)||0);x(k,Q<1400?1400:Q)}}return()=>{C()}},[_,E,k,a,P==null?void 0:P.audio,P==null?void 0:P.audioType,P==null?void 0:P.slideTimer,P==null?void 0:P.vignettes,x,C]),o!=null&&o.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:[o[R]&&jsxRuntimeExports.jsx(Slide,{slide:o[R],transition:A,soundActions:r,emitEvent:e,role:"complementary","aria-hidden":"true",translate:d},`comic page ${o[R].slideOrder}`),R>0&&jsxRuntimeExports.jsx("button",{type:"button",className:"comic-control comic-control--left gat--btn__round","data-testid":"btn-bck",onClick:G,"aria-label":LangIsRtl()?d("comic.next"):d("comic.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),R<o.length&&jsxRuntimeExports.jsx("button",{type:"button",className:`comic-control comic-control--right gat--btn__round
71
71
  ${E&&R+1>=o.length?"glowing-animation":""}`,"data-testid":"btn-nxt",onClick:()=>{R+1<o.length?F():(w("click-ui"),O())},"aria-label":LangIsRtl()?d("comic.previous"):d("comic.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})}):null}function CartelComponent({img:o,text:e,audio:r,audioType:t,voice:n,emitEvent:a,soundActions:l,audioVolume:u,pause:f,keyboardControl:d}){const h=R=>a({type:"translate",payload:R}),y=(o==null?void 0:o.url)||"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg",E=React$2.useRef(),p=React$2.useRef(),[_]=l;useEkho({audioType:t,voice:n,text:e,audio:r,soundActions:l,emitEvent:a,volume:u,pauseTTS:f});const g=()=>{_("click-ui"),a({type:"success"})};d(null,g,g);const x=(R,S)=>window.matchMedia("(min-width: 1280px)").matches?S:R,C=React$2.useCallback(()=>{if(e&&p.current){const R=p.current.naturalWidth/p.current.naturalHeight;let S=p.current.height*R,A=p.current.height;if(S>p.current.width&&(S=p.current.width,A=p.current.width/R),E.current.style.width=`${S}px`,window.innerHeight<p.current.width)E.current.style.bottom=`${x(24,48)+x(36,100)}px`;else{const T=(window.innerHeight-A)/2+x(36,100);E.current.style.bottom=`${T}px`}}},[e]);return React$2.useEffect(()=>{p.current&&new ResizeObserver(()=>x(24,48)&&C()).observe(p.current)}),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"cartel",children:jsxRuntimeExports.jsxs("div",{className:"cartel__imagewrap",children:[jsxRuntimeExports.jsx("img",{ref:p,onLoad:C,className:"cartel__image",src:y,alt:"cartel pic"}),e?jsxRuntimeExports.jsx("div",{ref:E,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",{type:"button",className:"gat--btn__round",onClick:()=>g(),"aria-label":h("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})})]})}var Typist$1={exports:{}};(function(o){o.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:!1};return e[n].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}return t.m=e,t.c=r,t.p="",t(0)}([function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=Object.assign||function(k){for(var D=1;D<arguments.length;D++){var F=arguments[D];for(var G in F)Object.prototype.hasOwnProperty.call(F,G)&&(k[G]=F[G])}return k},a=function(){function k(D,F){for(var G=0;G<F.length;G++){var V=F[G];V.enumerable=V.enumerable||!1,V.configurable=!0,"value"in V&&(V.writable=!0),Object.defineProperty(D,V.key,V)}}return function(D,F,G){return F&&k(D.prototype,F),G&&k(D,G),D}}(),l=t(1),u=S(l),f=t(2),d=S(f),h=t(10),y=S(h),E=t(12),p=S(E),_=t(13),g=S(_),x=t(14),C=R(x);function R(k){if(k&&k.__esModule)return k;var D={};if(k!=null)for(var F in k)Object.prototype.hasOwnProperty.call(k,F)&&(D[F]=k[F]);return D.default=k,D}function S(k){return k&&k.__esModule?k:{default:k}}function A(k,D){if(!(k instanceof D))throw new TypeError("Cannot call a class as a function")}function T(k,D){if(!k)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D&&(typeof D=="object"||typeof D=="function")?D:k}function w(k,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof D);k.prototype=Object.create(D&&D.prototype,{constructor:{value:k,enumerable:!1,writable:!0,configurable:!0}}),D&&(Object.setPrototypeOf?Object.setPrototypeOf(k,D):k.__proto__=D)}var P=["🔙","⏰"],O=function(k){w(D,k);function D(F){A(this,D);var G=T(this,(D.__proto__||Object.getPrototypeOf(D)).call(this,F));return G.state={textLines:[],isDone:!1},G.onTypingDone=function(){G.mounted&&(G.setState({isDone:!0}),G.props.onTypingDone())},G.delayGenerator=function(V,W,ee,q){var z=G.props.avgTypingDelay,U=G.props.stdTypingDelay;return G.props.delayGenerator(z,U,{line:V,lineIdx:W,character:ee,charIdx:q,defDelayGenerator:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:U;return C.gaussianRnd(I,B)}})},G.typeLine=function(V,W){if(!G.mounted)return Promise.resolve();var ee=V,q=G.props.onLineTyped;return C.isBackspaceElement(V)?(V.props.delay>0&&(G.introducedDelay=V.props.delay),ee="🔙".repeat(V.props.count)):C.isDelayElement(V)&&(G.introducedDelay=V.props.ms,ee="⏰"),new Promise(function(z,U){G.setState({textLines:G.state.textLines.concat([""])},function(){C.eachPromise(ee,G.typeCharacter,ee,W).then(function(){return q(ee,W)}).then(z).catch(U)})})},G.typeCharacter=function(V,W,ee,q){if(!G.mounted)return Promise.resolve();var z=G.props.onCharacterTyped;return new Promise(function(U){var $=G.state.textLines.slice();C.sleep(G.introducedDelay).then(function(){G.introducedDelay=null;var I=V==="🔙",B=V==="⏰";if(B){U();return}if(I&&q>0){for(var X=q-1,Q=$[X],J=X;J>=0&&!(Q.length>0&&!P.includes(Q[0]));J--)X=J,Q=$[X];$[X]=Q.substr(0,Q.length-1)}else $[q]+=V;G.setState({textLines:$},function(){var ne=G.delayGenerator(ee,q,V,W);z(V,W),setTimeout(U,ne)})})})},G.mounted=!1,G.linesToType=[],G.introducedDelay=null,F.children&&(G.linesToType=C.extractTextFromElement(F.children)),G}return a(D,[{key:"componentDidMount",value:function(){this.mounted=!0;var G=this.props,V=G.children,W=G.startDelay;V?W>0&&typeof window<"u"?setTimeout(this.typeAllLines.bind(this),W):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(G,V){if(V.textLines.length!==this.state.textLines.length)return!0;for(var W=0;W<V.textLines.length;W++){var ee=this.state.textLines[W],q=V.textLines[W];if(ee!==q)return!0}return this.state.isDone!==V.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var G=this,V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.linesToType;return C.eachPromise(V,this.typeLine).then(function(){return G.onTypingDone()})}},{key:"render",value:function(){var G=this.props,V=G.className,W=G.cursor,ee=this.state.isDone,q=C.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return u.default.createElement("div",{className:"Typist "+V},q,u.default.createElement(y.default,n({isDone:ee},W)))}}]),D}(l.Component);O.propTypes={children:d.default.node,className:d.default.string,avgTypingDelay:d.default.number,stdTypingDelay:d.default.number,startDelay:d.default.number,cursor:d.default.object,onCharacterTyped:d.default.func,onLineTyped:d.default.func,onTypingDone:d.default.func,delayGenerator:d.default.func},O.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:C.gaussianRnd},r.default=O,O.Backspace=p.default,O.Delay=g.default},function(e,r){e.exports=React$2},function(e,r,t){if(process.env.NODE_ENV!=="production"){var n=typeof Symbol=="function"&&Symbol.for&&Symbol.for("react.element")||60103,a=function(u){return typeof u=="object"&&u!==null&&u.$$typeof===n},l=!0;e.exports=t(3)(a,l)}else e.exports=t(9)()},function(e,r,t){var n=t(4),a=t(5),l=t(6),u=t(7),f=t(8);e.exports=function(d,h){var y=typeof Symbol=="function"&&Symbol.iterator,E="@@iterator";function p($){var I=$&&(y&&$[y]||$[E]);if(typeof I=="function")return I}var _="<<anonymous>>",g={array:S("array"),bool:S("boolean"),func:S("function"),number:S("number"),object:S("object"),string:S("string"),symbol:S("symbol"),any:A(),arrayOf:T,element:w(),instanceOf:P,node:F(),objectOf:k,oneOf:O,oneOfType:D,shape:G};function x($,I){return $===I?$!==0||1/$===1/I:$!==$&&I!==I}function C($){this.message=$,this.stack=""}C.prototype=Error.prototype;function R($){if(process.env.NODE_ENV!=="production")var I={},B=0;function X(J,ne,ae,Z,se,oe,fe){if(Z=Z||_,oe=oe||ae,fe!==u){if(h)a(!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 de=Z+":"+ae;!I[de]&&B<3&&(l(!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.",oe,Z),I[de]=!0,B++)}}return ne[ae]==null?J?ne[ae]===null?new C("The "+se+" `"+oe+"` is marked as required "+("in `"+Z+"`, but its value is `null`.")):new C("The "+se+" `"+oe+"` is marked as required in "+("`"+Z+"`, but its value is `undefined`.")):null:$(ne,ae,Z,se,oe)}var Q=X.bind(null,!1);return Q.isRequired=X.bind(null,!0),Q}function S($){function I(B,X,Q,J,ne,ae){var Z=B[X],se=ee(Z);if(se!==$){var oe=q(Z);return new C("Invalid "+J+" `"+ne+"` of type "+("`"+oe+"` supplied to `"+Q+"`, expected ")+("`"+$+"`."))}return null}return R(I)}function A(){return R(n.thatReturnsNull)}function T($){function I(B,X,Q,J,ne){if(typeof $!="function")return new C("Property `"+ne+"` of component `"+Q+"` has invalid PropType notation inside arrayOf.");var ae=B[X];if(!Array.isArray(ae)){var Z=ee(ae);return new C("Invalid "+J+" `"+ne+"` of type "+("`"+Z+"` supplied to `"+Q+"`, expected an array."))}for(var se=0;se<ae.length;se++){var oe=$(ae,se,Q,J,ne+"["+se+"]",u);if(oe instanceof Error)return oe}return null}return R(I)}function w(){function $(I,B,X,Q,J){var ne=I[B];if(!d(ne)){var ae=ee(ne);return new C("Invalid "+Q+" `"+J+"` of type "+("`"+ae+"` supplied to `"+X+"`, expected a single ReactElement."))}return null}return R($)}function P($){function I(B,X,Q,J,ne){if(!(B[X]instanceof $)){var ae=$.name||_,Z=U(B[X]);return new C("Invalid "+J+" `"+ne+"` of type "+("`"+Z+"` supplied to `"+Q+"`, expected ")+("instance of `"+ae+"`."))}return null}return R(I)}function O($){if(!Array.isArray($))return process.env.NODE_ENV!=="production"&&l(!1,"Invalid argument supplied to oneOf, expected an instance of array."),n.thatReturnsNull;function I(B,X,Q,J,ne){for(var ae=B[X],Z=0;Z<$.length;Z++)if(x(ae,$[Z]))return null;var se=JSON.stringify($);return new C("Invalid "+J+" `"+ne+"` of value `"+ae+"` "+("supplied to `"+Q+"`, expected one of "+se+"."))}return R(I)}function k($){function I(B,X,Q,J,ne){if(typeof $!="function")return new C("Property `"+ne+"` of component `"+Q+"` has invalid PropType notation inside objectOf.");var ae=B[X],Z=ee(ae);if(Z!=="object")return new C("Invalid "+J+" `"+ne+"` of type "+("`"+Z+"` supplied to `"+Q+"`, expected an object."));for(var se in ae)if(ae.hasOwnProperty(se)){var oe=$(ae,se,Q,J,ne+"."+se,u);if(oe instanceof Error)return oe}return null}return R(I)}function D($){if(!Array.isArray($))return process.env.NODE_ENV!=="production"&&l(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),n.thatReturnsNull;for(var I=0;I<$.length;I++){var B=$[I];if(typeof B!="function")return l(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",z(B),I),n.thatReturnsNull}function X(Q,J,ne,ae,Z){for(var se=0;se<$.length;se++){var oe=$[se];if(oe(Q,J,ne,ae,Z,u)==null)return null}return new C("Invalid "+ae+" `"+Z+"` supplied to "+("`"+ne+"`."))}return R(X)}function F(){function $(I,B,X,Q,J){return V(I[B])?null:new C("Invalid "+Q+" `"+J+"` supplied to "+("`"+X+"`, expected a ReactNode."))}return R($)}function G($){function I(B,X,Q,J,ne){var ae=B[X],Z=ee(ae);if(Z!=="object")return new C("Invalid "+J+" `"+ne+"` of type `"+Z+"` "+("supplied to `"+Q+"`, expected `object`."));for(var se in $){var oe=$[se];if(oe){var fe=oe(ae,se,Q,J,ne+"."+se,u);if(fe)return fe}}return null}return R(I)}function V($){switch(typeof $){case"number":case"string":case"undefined":return!0;case"boolean":return!$;case"object":if(Array.isArray($))return $.every(V);if($===null||d($))return!0;var I=p($);if(I){var B=I.call($),X;if(I!==$.entries){for(;!(X=B.next()).done;)if(!V(X.value))return!1}else for(;!(X=B.next()).done;){var Q=X.value;if(Q&&!V(Q[1]))return!1}}else return!1;return!0;default:return!1}}function W($,I){return $==="symbol"||I["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&I instanceof Symbol}function ee($){var I=typeof $;return Array.isArray($)?"array":$ instanceof RegExp?"object":W(I,$)?"symbol":I}function q($){if(typeof $>"u"||$===null)return""+$;var I=ee($);if(I==="object"){if($ instanceof Date)return"date";if($ instanceof RegExp)return"regexp"}return I}function z($){var I=q($);switch(I){case"array":case"object":return"an "+I;case"boolean":case"date":case"regexp":return"a "+I;default:return I}}function U($){return!$.constructor||!$.constructor.name?_:$.constructor.name}return g.checkPropTypes=f,g.PropTypes=g,g}},function(e,r){function t(a){return function(){return a}}var n=function(){};n.thatReturns=t,n.thatReturnsFalse=t(!1),n.thatReturnsTrue=t(!0),n.thatReturnsNull=t(null),n.thatReturnsThis=function(){return this},n.thatReturnsArgument=function(a){return a},e.exports=n},function(e,r){var t=function(l){};process.env.NODE_ENV!=="production"&&(t=function(l){if(l===void 0)throw new Error("invariant requires an error message argument")});function n(a,l,u,f,d,h,y,E){if(t(l),!a){var p;if(l===void 0)p=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var _=[u,f,d,h,y,E],g=0;p=new Error(l.replace(/%s/g,function(){return _[g++]})),p.name="Invariant Violation"}throw p.framesToPop=1,p}}e.exports=n},function(e,r,t){var n=t(4),a=n;process.env.NODE_ENV!=="production"&&function(){var l=function(f){for(var d=arguments.length,h=Array(d>1?d-1:0),y=1;y<d;y++)h[y-1]=arguments[y];var E=0,p="Warning: "+f.replace(/%s/g,function(){return h[E++]});typeof console<"u"&&console.error(p);try{throw new Error(p)}catch{}};a=function(f,d){if(d===void 0)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(d.indexOf("Failed Composite propType: ")!==0&&!f){for(var h=arguments.length,y=Array(h>2?h-2:0),E=2;E<h;E++)y[E-2]=arguments[E];l.apply(void 0,[d].concat(y))}}}(),e.exports=a},function(e,r){var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=t},function(e,r,t){if(process.env.NODE_ENV!=="production")var n=t(5),a=t(6),l=t(7),u={};function f(d,h,y,E,p){if(process.env.NODE_ENV!=="production"){for(var _ in d)if(d.hasOwnProperty(_)){var g;try{n(typeof d[_]=="function","%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",E||"React class",y,_),g=d[_](h,_,E,y,null,l)}catch(C){g=C}if(a(!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).",E||"React class",y,_,typeof g),g instanceof Error&&!(g.message in u)){u[g.message]=!0;var x=p?p():"";a(!1,"Failed %s type: %s%s",y,g.message,x??"")}}}}e.exports=f},function(e,r,t){var n=t(4),a=t(5),l=t(7);e.exports=function(){function u(h,y,E,p,_,g){g!==l&&a(!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")}u.isRequired=u;function f(){return u}var d={array:u,bool:u,func:u,number:u,object:u,string:u,symbol:u,any:u,arrayOf:f,element:u,instanceOf:f,node:u,objectOf:f,oneOf:f,oneOfType:f,shape:f};return d.checkPropTypes=n,d.PropTypes=d,d}},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function _(g,x){for(var C=0;C<x.length;C++){var R=x[C];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(g,R.key,R)}}return function(g,x,C){return x&&_(g.prototype,x),C&&_(g,C),g}}(),a=t(1),l=d(a),u=t(2),f=d(u);t(11);function d(_){return _&&_.__esModule?_:{default:_}}function h(_,g){if(!(_ instanceof g))throw new TypeError("Cannot call a class as a function")}function y(_,g){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:_}function E(_,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);_.prototype=Object.create(g&&g.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(_,g):_.__proto__=g)}var p=function(_){E(g,_);function g(x){h(this,g);var C=y(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,x));return C._isReRenderingCursor=!1,C.state={shouldRender:C.props.show},C}return n(g,[{key:"componentWillReceiveProps",value:function(C){var R=this,S=!this.props.isDone&&C.isDone&&this.props.hideWhenDone;S&&setTimeout(function(){return R.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var C=this.props,R=C.show,S=C.isDone;R&&(S||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var C=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){C.setState({shouldRender:!0},function(){C._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var C=this.props.blink?" Cursor--blinking":"";return l.default.createElement("span",{className:"Cursor"+C},this.props.element)}return null}}]),g}(a.Component);p.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},p.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},r.default=p},function(e,r){},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=t(1),a=f(n),l=t(2),u=f(l);function f(h){return h&&h.__esModule?h:{default:h}}var d=function(){return a.default.createElement("noscript",null)};d.componentName="Backspace",d.propTypes={count:u.default.number,delay:u.default.number},d.defaultProps={count:1,delay:0},r.default=d},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=t(1),a=f(n),l=t(2),u=f(l);function f(h){return h&&h.__esModule?h:{default:h}}var d=function(){return a.default.createElement("noscript",null)};d.componentName="Delay",d.propTypes={ms:u.default.number.isRequired},r.default=d},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0}),r.sleep=void 0;var n=function(){function R(S,A){var T=[],w=!0,P=!1,O=void 0;try{for(var k=S[Symbol.iterator](),D;!(w=(D=k.next()).done)&&(T.push(D.value),!(A&&T.length===A));w=!0);}catch(F){P=!0,O=F}finally{try{!w&&k.return&&k.return()}finally{if(P)throw O}}return T}return function(S,A){if(Array.isArray(S))return S;if(Symbol.iterator in Object(S))return R(S,A);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();r.gaussianRnd=d,r.eachPromise=h,r.exclude=y,r.isBackspaceElement=E,r.isDelayElement=p,r.extractTextFromElement=_,r.cloneElement=g,r.cloneElementWithSpecifiedText=C;var a=t(1),l=u(a);function u(R){return R&&R.__esModule?R:{default:R}}function f(R){if(Array.isArray(R)){for(var S=0,A=Array(R.length);S<R.length;S++)A[S]=R[S];return A}else return Array.from(R)}r.sleep=function(S){return new Promise(function(A){return S!=null?setTimeout(A,S):A()})};function d(R,S){for(var A=12,T=0,w=0;w<A;w++)T+=Math.random();return T-=A/2,Math.round(T*S)+R}function h(R,S){for(var A=arguments.length,T=Array(A>2?A-2:0),w=2;w<A;w++)T[w-2]=arguments[w];var P=function(k,D,F){return k.then(function(){return S.apply(void 0,[D,F].concat(T))})};return Array.from(R).reduce(P,Promise.resolve())}function y(R,S){var A={};for(var T in R)S.indexOf(T)===-1&&(A[T]=R[T]);return A}function E(R){return R&&R.type&&R.type.componentName==="Backspace"}function p(R){return R&&R.type&&R.type.componentName==="Delay"}function _(R){for(var S=R?[R]:[],A=[];S.length>0;){var T=S.pop();if(l.default.isValidElement(T))E(T)||p(T)?A.unshift(T):l.default.Children.forEach(T.props.children,function(G){S.push(G)});else if(Array.isArray(T)){var w=!0,P=!1,O=void 0;try{for(var k=T[Symbol.iterator](),D;!(w=(D=k.next()).done);w=!0){var F=D.value;S.push(F)}}catch(G){P=!0,O=G}finally{try{!w&&k.return&&k.return()}finally{if(P)throw O}}}else A.unshift(T)}return A}function g(R,S){var A=R.type,T=y(R.props,["children"]),w=new Date().getUTCMilliseconds(),P=w+Math.random()+Math.random();return T.key="Typist-element-"+A+"-"+P,l.default.createElement.apply(l.default,[A,T].concat(f(S)))}function x(R,S,A){if(A>=S.length)return[null,A];var T=A,w=function(F){var G=x(F,S,T),V=n(G,2),W=V[0],ee=V[1];return T=ee,W},P=l.default.isValidElement(R)&&!(E(R)||p(R));if(P){var O=l.default.Children.map(R.props.children,w)||[];return[g(R,O),T]}if(Array.isArray(R)){var k=R.map(w);return[k,T]}return[S[T],T+1]}function C(R){var S=R.element,A=R.textLines;if(S)return x(S,A,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:o,type:e}){const r=languages[e];if(r){const t=r.reduce((l,u)=>(l.length?l.length:l)+u.length),n=Math.floor(o*100/t),a=n===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(o*100/t)}%`},children:jsxRuntimeExports.jsxs("span",{className:a,children:[n,"%"]})})})}return null}function Code({codeContainer:o}){const e=o,r=e.split("<br>");return r.length>0?r.map((t,n)=>{const a=t.replace(/ /g," ");return jsxRuntimeExports.jsx("p",{children:a},`line_${0+n}`)}):jsxRuntimeExports.jsx("p",{children:e})}function HackerPuzzleComponent({emitEvent:o,soundActions:e,info:r,themeNumber:t,type:n,writingSpeed:a,disableExit:l,setResolveAction:u}){const f=W=>o({type:"translate",payload:W}),[d]=e,{solution:h}=r,E=themes[`theme${t||1}`],[p,_]=React$2.useState(""),[g,x]=React$2.useState(0),[C,R]=React$2.useState(0),[S,A]=React$2.useState(!1),[T,w]=React$2.useState({start:0,end:0}),P=React$2.useRef(),O=React$2.useRef(),k=f("puzzle.hacker.congratulations"),D=(W,ee)=>W>ee.length?ee.length:W,F=()=>{d("click-ui");const{rewards:W}=h.right;o({type:"addPoints",complex:!0,finish:!0,payload:W}),o({type:"passPuzzle"})};React$2.useEffect(()=>{P.current.focus(),S&&l(!0)},[S]),React$2.useEffect(()=>{u(W=>{d("score"),A(!0),o({type:"hidePuzzleButtons",payload:!1}),W()})},[u]);const G=()=>{if(languages[n]&&!S){O.current&&(O.current.scrollTop=P.current.scrollHeight);const W=languages[n],ee=W[g],q=W.reduce((U,$)=>(U.length?U.length:U)+$.length),z=a>0?a:Math.floor(q/50)+g;if(ee){const U=ee.split(""),$=D(T.end,U),I=U.slice(T.start,$),B=p+I.join("");R(C+I.join("").length),_(B),$===U.length?g+1>=W.length?(d("score"),A(!0)):(x(g+1),_(`${p+I.join("")}<br>`),w({start:0,end:D(z,U)})):w({start:$,end:D($+z,U)})}}},V=W=>{W.preventDefault(),G()};return jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,"data-testid":"hacker",ref:P,onKeyDown:V,onTouchStart:V,className:`puzzle--hacker__container background-hacker-${E.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-${E.color} typography-hacker-${E.typo}`,children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--hacker__code",ref:O,children:[jsxRuntimeExports.jsx(Code,{codeContainer:p}),S?jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,onCharacterTyped:()=>{O.current&&(O.current.scrollTop=P.current.scrollHeight)},cursor:{hideWhenDone:!0},className:"puzzle--hacker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),h.right.desc?`// ${h.right.desc}`:`${k}`]}):null]}),jsxRuntimeExports.jsx(ProgressBar,{type:n,progress:C})]}),S?jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:F,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:o,soundActions:e,info:r,user:t,login:n,password:a,image:l,setResolveAction:u,nodeId:f}){var $;const d=I=>o({type:"translate",payload:I}),h=`login-puzzle_${f}`,y=LangIsRtl(),[E,p]=React$2.useState(""),[_,g]=React$2.useState(""),[x,C]=React$2.useState(!1),[R,S]=React$2.useState(""),[A,T]=React$2.useState(""),[w,P]=React$2.useState(!1),[O,k]=React$2.useState(!1),[D,F]=React$2.useState(!1),[G]=e,[V,W]=React$2.useState([]),ee=(($=l.img)==null?void 0:$.url)||imagenPorDefecto,q=()=>{const{rewards:I}=r.solution.right,B=[...V,...I];o({type:"addPoints",complex:!0,finish:!0,payload:B}),o({type:"passPuzzle"})},z=()=>{G("click-ui");const I={login:!0,password:!1};n&&(I.login=t===E),I.password=a===_,I.login&&I.password?(T("success"),P(!0),k(!1),G("score"),setTimeout(()=>{q()},2e3)):(W([...V,...r.solution.wrong.rewards]),G("fail"),T("failed"),k(!0),o({type:"failPuzzle"}))},U=I=>{let B="";if(I.length>=0){for(let X=0;X<I.length;X+=1)B+="•";S(B)}};return React$2.useEffect(()=>{u(()=>{const I=[...V,...r.resolve.rewards];F(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:h,rewards:I,finish:!0}})},2e3)})},[V,r.resolve.rewards,o,u,h]),jsxRuntimeExports.jsx("div",{className:"puzzle--layer",style:{backgroundImage:`url("${ee}")`},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:d("puzzle.initSession")}),jsxRuntimeExports.jsxs("div",{children:[n&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--login__label",children:d("puzzle.user")}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[D?jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:w,"data-testid":"username",className:"puzzle--login__input success",type:"text",placeholder:t,value:t}):jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:w,"data-testid":"username",className:`puzzle--login__input ${A}`,type:"text",placeholder:d("puzzle.user"),onChange:I=>{p(I.target.value),T(""),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:d("puzzle.password")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[D?jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:!0,"data-testid":"password",className:"puzzle--login__input puzzle--login__input--fakepassword success",type:"text",placeholder:a,value:a,style:{opacity:1}}):jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:w,"data-testid":"password",className:`puzzle--login__input puzzle--login__input--fakepassword ${A}`,type:"text",placeholder:d("puzzle.password"),onFocus:()=>{C(!0)},onBlur:()=>{C(!1)},onChange:I=>{g(I.target.value),U(I.target.value),T(""),k(!1)}}),D?null:jsxRuntimeExports.jsx("div",{dir:y?"rtl":"auto",className:`login-fakepassword${x?" login-fakepassword--focus":""}${R.length?" login-fakepassword--fill":""} ${A||""}`,children:_?R:d("puzzle.password")}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check",children:" "})]})]})]}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${_.length!==0&&!w?"":"disabled"}`,onClick:z,children:d("puzzle.loginIn")}),!D&&O&&r.solution.wrong.desc!==""&&jsxRuntimeExports.jsx("div",{className:"puzzle--login__label--error",children:r.solution.wrong.desc})]})})}function FeedbackComponent$1({text:o,success:e,playSound:r,additionalStyle:t,functionOnClose:n,secondText:a,translate:l,shortText:u,hasTimeout:f,delay:d,timeExpired:h,keyboardControl:y}){const[E,p]=React$2.useState();React$2.useEffect(()=>{let x;return r&&r(e?"score":"fail"),o&&!u&&(x=setTimeout(()=>{p(!0)},1e3)),()=>{x&&clearTimeout(x)}},[r,e,u,o]),React$2.useEffect(()=>{let x;return f&&n&&(x=setTimeout(n,d)),()=>{x&&clearTimeout(x)}},[d,n,f]);const _=()=>e?"success":"failed",g=()=>e?"icon-correct-thumb":h?"icon-times-up":"icon-incorrect-thumb";return y(null,o&&n&&E?n:null,o&&n&&E||n&&u?n:null),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:`feedback-layer ${E?"feedback-layer--withexplain":""}`,children:[jsxRuntimeExports.jsxs("div",{className:`feedback-layer__header ${u?"feedback-layer__header--in-shortText":""} ${t||""} ${_()}`,children:[a&&jsxRuntimeExports.jsxs("span",{className:"puzzle--terminal__visor--file",children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${t||""}`}),jsxRuntimeExports.jsx("span",{children:a})]}),jsxRuntimeExports.jsx("span",{className:"feedback-layer__maintitle",children:!o||!u?jsxRuntimeExports.jsx("div",{title:l(`tooltip.${e?"correct":"incorrect"}`),className:`${g()}`}):o}),u&&jsxRuntimeExports.jsx("button",{type:"button",className:"feedback-layer__closeX",onClick:()=>n(),"aria-label":l("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),!u&&o!==""&&jsxRuntimeExports.jsx("div",{className:"feedback-layer__explainwrap",children:jsxRuntimeExports.jsxs("div",{className:"feedback-layer__explain",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:o}),o&&n&&E&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>n(),"aria-label":l("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};const defaultImage$1="https://min.gamelearn.io/css-resources/gamelearn/resources/keyboard.jpg";function KeyboardPuzzleComponent({emitEvent:o,image:e,password:r,keyboard:t,info:n,disableExit:a,soundActions:l,setResolveAction:u,nodeId:f,keyboardControl:d}){var U;const[h,y]=React$2.useState(!1),[E,p]=React$2.useState(""),[_,g]=React$2.useState(""),[x,C]=React$2.useState(!1),[R,S]=React$2.useState(""),[A,T]=React$2.useState(!1),[w,P]=React$2.useState([]),O=$=>o({type:"translate",payload:$}),k=`keyboard-puzzle_${f}`,[D]=l,F=React$2.useCallback($=>{C(!1),T(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:$})},[o]),G=()=>{if(x){y(!0);const{rewards:$}=n.solution.right,I=[...w,...$];D("score"),F(I)}else o({type:"hidePuzzleButtons",payload:!1}),C(!1),a(!1),T(!1);S("")},V=$=>{$===r?(a(!1),p("success"),D("score"),o({type:"passPuzzle"}),C(!0),T(!0),n.solution.right.desc?S(n.solution.right.desc):setTimeout(()=>{const{rewards:I}=n.solution.right,B=[...w,...I];F(B)},3e3)):(T(!0),p("failed"),D("fail"),o({type:"failPuzzle"}),C(!1),P([...w,...n.solution.wrong.rewards]),o({type:"hidePuzzleButtons",payload:!1}),p(""),g(""),T(!0),n.solution.wrong.desc?S(n.solution.wrong.desc):setTimeout(()=>{G()},3e3))};React$2.useEffect(()=>{u(()=>{a(!1),D("score"),p("success"),C(!0),S(n.solution.right.desc),g(r),y(!0);const $=[...w,...n.resolve.rewards];setTimeout(()=>{C(!1),T(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:k,rewards:$,finish:!0}})},2e3)})},[u,a,n.solution.right.desc,D,n.resolve.rewards,w,r,o,k]);const W=($,I)=>{const B=t[$][I];D("click-ui"),_.length<r.length+1&&(g(_+B),_.length+1===r.length&&V(_+B))},ee=()=>{D("click-ui"),g(_.substring(0,_.length-1))},q=((U=e.img)==null?void 0:U.url)||defaultImage$1,z={backgroundSize:q?"cover":"contain",backgroundImage:`url("${q}")`,backgroudPosition:"center center"};return jsxRuntimeExports.jsxs("div",{className:"puzzle--keyboard",style:z,children:[jsxRuntimeExports.jsx("div",{className:"puzzle--keyboard__header",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--keyboard__result",children:[r.split("").map(($,I)=>jsxRuntimeExports.jsx("div",{className:`puzzle--keyboard__result--item ${E}`,children:_.split("")[I]?_.split("")[I]:""},`${$+I}`)),h?jsxRuntimeExports.jsx("span",{className:"icon-circle-check"}):jsxRuntimeExports.jsx("button",{type:"button",onClick:ee,className:"puzzle--keyboard__delete","aria-label":O("puzzles.keyboard-puzzle.deleteButton"),children:jsxRuntimeExports.jsx("span",{className:"icon-delete-keyboard"})})]})}),jsxRuntimeExports.jsx("div",{className:"puzzle--keyboard__block",children:t.map(($,I)=>jsxRuntimeExports.jsx("div",{className:"puzzle--keyboard__row",children:(Array.isArray($)?$:Object.values($)).map((B,X)=>jsxRuntimeExports.jsx("button",{className:"puzzle--keyboard__character",type:"button",onClick:()=>W(I,X),children:B},B))},`row_${0+I}`))}),A&&jsxRuntimeExports.jsx(FeedbackComponent$1,{translate:O,text:R,success:x,functionOnClose:G,keyboardControl:d})]})}var lib$1={exports:{}},_FullInternals={},_CoreInternals={},Global={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o._registerNode=o.Konva=o.glob=void 0;const e=Math.PI/180;function r(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}o.glob=typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},o.Konva={_global:o.glob,version:"9.3.0",isBrowser:r(),isUnminified:/param/.test((function(n){}).toString()),dblClickWindow:400,getAngle(n){return o.Konva.angleDeg?n*e:n},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 o.Konva.DD.isDragging},isDragReady(){return!!o.Konva.DD.node},releaseCanvasOnDestroy:!0,document:o.glob.document,_injectGlobal(n){o.glob.Konva=n}};const t=n=>{o.Konva[n.prototype.getClassName()]=n};o._registerNode=t,o.Konva._injectGlobal(o.Konva)})(Global);var Util={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Util=o.Transform=void 0;const e=Global;class r{constructor(A=[1,0,0,1,0,0]){this.dirty=!1,this.m=A&&A.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 r(this.m)}copyInto(A){A.m[0]=this.m[0],A.m[1]=this.m[1],A.m[2]=this.m[2],A.m[3]=this.m[3],A.m[4]=this.m[4],A.m[5]=this.m[5]}point(A){var T=this.m;return{x:T[0]*A.x+T[2]*A.y+T[4],y:T[1]*A.x+T[3]*A.y+T[5]}}translate(A,T){return this.m[4]+=this.m[0]*A+this.m[2]*T,this.m[5]+=this.m[1]*A+this.m[3]*T,this}scale(A,T){return this.m[0]*=A,this.m[1]*=A,this.m[2]*=T,this.m[3]*=T,this}rotate(A){var T=Math.cos(A),w=Math.sin(A),P=this.m[0]*T+this.m[2]*w,O=this.m[1]*T+this.m[3]*w,k=this.m[0]*-w+this.m[2]*T,D=this.m[1]*-w+this.m[3]*T;return this.m[0]=P,this.m[1]=O,this.m[2]=k,this.m[3]=D,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(A,T){var w=this.m[0]+this.m[2]*T,P=this.m[1]+this.m[3]*T,O=this.m[2]+this.m[0]*A,k=this.m[3]+this.m[1]*A;return this.m[0]=w,this.m[1]=P,this.m[2]=O,this.m[3]=k,this}multiply(A){var T=this.m[0]*A.m[0]+this.m[2]*A.m[1],w=this.m[1]*A.m[0]+this.m[3]*A.m[1],P=this.m[0]*A.m[2]+this.m[2]*A.m[3],O=this.m[1]*A.m[2]+this.m[3]*A.m[3],k=this.m[0]*A.m[4]+this.m[2]*A.m[5]+this.m[4],D=this.m[1]*A.m[4]+this.m[3]*A.m[5]+this.m[5];return this.m[0]=T,this.m[1]=w,this.m[2]=P,this.m[3]=O,this.m[4]=k,this.m[5]=D,this}invert(){var A=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),T=this.m[3]*A,w=-this.m[1]*A,P=-this.m[2]*A,O=this.m[0]*A,k=A*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),D=A*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=T,this.m[1]=w,this.m[2]=P,this.m[3]=O,this.m[4]=k,this.m[5]=D,this}getMatrix(){return this.m}decompose(){var A=this.m[0],T=this.m[1],w=this.m[2],P=this.m[3],O=this.m[4],k=this.m[5],D=A*P-T*w;let F={x:O,y:k,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(A!=0||T!=0){var G=Math.sqrt(A*A+T*T);F.rotation=T>0?Math.acos(A/G):-Math.acos(A/G),F.scaleX=G,F.scaleY=D/G,F.skewX=(A*w+T*P)/D,F.skewY=0}else if(w!=0||P!=0){var V=Math.sqrt(w*w+P*P);F.rotation=Math.PI/2-(P>0?Math.acos(-w/V):-Math.acos(w/V)),F.scaleX=D/V,F.scaleY=V,F.skewX=0,F.skewY=(A*w+T*P)/D}return F.rotation=o.Util._getRotation(F.rotation),F}}o.Transform=r;var t="[object Array]",n="[object Number]",a="[object String]",l="[object Boolean]",u=Math.PI/180,f=180/Math.PI,d="#",h="",y="0",E="Konva warning: ",p="Konva error: ",_="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]},x=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,C=[];const R=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(S){setTimeout(S,60)};o.Util={_isElement(S){return!!(S&&S.nodeType==1)},_isFunction(S){return!!(S&&S.constructor&&S.call&&S.apply)},_isPlainObject(S){return!!S&&S.constructor===Object},_isArray(S){return Object.prototype.toString.call(S)===t},_isNumber(S){return Object.prototype.toString.call(S)===n&&!isNaN(S)&&isFinite(S)},_isString(S){return Object.prototype.toString.call(S)===a},_isBoolean(S){return Object.prototype.toString.call(S)===l},isObject(S){return S instanceof Object},isValidSelector(S){if(typeof S!="string")return!1;var A=S[0];return A==="#"||A==="."||A===A.toUpperCase()},_sign(S){return S===0||S>0?1:-1},requestAnimFrame(S){C.push(S),C.length===1&&R(function(){const A=C;C=[],A.forEach(function(T){T()})})},createCanvasElement(){var S=document.createElement("canvas");try{S.style=S.style||{}}catch{}return S},createImageElement(){return document.createElement("img")},_isInDocument(S){for(;S=S.parentNode;)if(S==document)return!0;return!1},_urlToImage(S,A){var T=o.Util.createImageElement();T.onload=function(){A(T)},T.src=S},_rgbToHex(S,A,T){return((1<<24)+(S<<16)+(A<<8)+T).toString(16).slice(1)},_hexToRgb(S){S=S.replace(d,h);var A=parseInt(S,16);return{r:A>>16&255,g:A>>8&255,b:A&255}},getRandomColor(){for(var S=(Math.random()*16777215<<0).toString(16);S.length<6;)S=y+S;return d+S},getRGB(S){var A;return S in g?(A=g[S],{r:A[0],g:A[1],b:A[2]}):S[0]===d?this._hexToRgb(S.substring(1)):S.substr(0,4)===_?(A=x.exec(S.replace(/ /g,"")),{r:parseInt(A[1],10),g:parseInt(A[2],10),b:parseInt(A[3],10)}):{r:0,g:0,b:0}},colorToRGBA(S){return S=S||"black",o.Util._namedColorToRBA(S)||o.Util._hex3ColorToRGBA(S)||o.Util._hex4ColorToRGBA(S)||o.Util._hex6ColorToRGBA(S)||o.Util._hex8ColorToRGBA(S)||o.Util._rgbColorToRGBA(S)||o.Util._rgbaColorToRGBA(S)||o.Util._hslColorToRGBA(S)},_namedColorToRBA(S){var A=g[S.toLowerCase()];return A?{r:A[0],g:A[1],b:A[2],a:1}:null},_rgbColorToRGBA(S){if(S.indexOf("rgb(")===0){S=S.match(/rgb\(([^)]+)\)/)[1];var A=S.split(/ *, */).map(Number);return{r:A[0],g:A[1],b:A[2],a:1}}},_rgbaColorToRGBA(S){if(S.indexOf("rgba(")===0){S=S.match(/rgba\(([^)]+)\)/)[1];var A=S.split(/ *, */).map((T,w)=>T.slice(-1)==="%"?w===3?parseInt(T)/100:parseInt(T)/100*255:Number(T));return{r:A[0],g:A[1],b:A[2],a:A[3]}}},_hex8ColorToRGBA(S){if(S[0]==="#"&&S.length===9)return{r:parseInt(S.slice(1,3),16),g:parseInt(S.slice(3,5),16),b:parseInt(S.slice(5,7),16),a:parseInt(S.slice(7,9),16)/255}},_hex6ColorToRGBA(S){if(S[0]==="#"&&S.length===7)return{r:parseInt(S.slice(1,3),16),g:parseInt(S.slice(3,5),16),b:parseInt(S.slice(5,7),16),a:1}},_hex4ColorToRGBA(S){if(S[0]==="#"&&S.length===5)return{r:parseInt(S[1]+S[1],16),g:parseInt(S[2]+S[2],16),b:parseInt(S[3]+S[3],16),a:parseInt(S[4]+S[4],16)/255}},_hex3ColorToRGBA(S){if(S[0]==="#"&&S.length===4)return{r:parseInt(S[1]+S[1],16),g:parseInt(S[2]+S[2],16),b:parseInt(S[3]+S[3],16),a:1}},_hslColorToRGBA(S){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(S)){const[A,...T]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(S),w=Number(T[0])/360,P=Number(T[1])/100,O=Number(T[2])/100;let k,D,F;if(P===0)return F=O*255,{r:Math.round(F),g:Math.round(F),b:Math.round(F),a:1};O<.5?k=O*(1+P):k=O+P-O*P;const G=2*O-k,V=[0,0,0];for(let W=0;W<3;W++)D=w+1/3*-(W-1),D<0&&D++,D>1&&D--,6*D<1?F=G+(k-G)*6*D:2*D<1?F=k:3*D<2?F=G+(k-G)*(2/3-D)*6:F=G,V[W]=F*255;return{r:Math.round(V[0]),g:Math.round(V[1]),b:Math.round(V[2]),a:1}}},haveIntersection(S,A){return!(A.x>S.x+S.width||A.x+A.width<S.x||A.y>S.y+S.height||A.y+A.height<S.y)},cloneObject(S){var A={};for(var T in S)this._isPlainObject(S[T])?A[T]=this.cloneObject(S[T]):this._isArray(S[T])?A[T]=this.cloneArray(S[T]):A[T]=S[T];return A},cloneArray(S){return S.slice(0)},degToRad(S){return S*u},radToDeg(S){return S*f},_degToRad(S){return o.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),o.Util.degToRad(S)},_radToDeg(S){return o.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),o.Util.radToDeg(S)},_getRotation(S){return e.Konva.angleDeg?o.Util.radToDeg(S):S},_capitalize(S){return S.charAt(0).toUpperCase()+S.slice(1)},throw(S){throw new Error(p+S)},error(S){console.error(p+S)},warn(S){e.Konva.showWarnings&&console.warn(E+S)},each(S,A){for(var T in S)A(T,S[T])},_inRange(S,A,T){return A<=S&&S<T},_getProjectionToSegment(S,A,T,w,P,O){var k,D,F,G=(S-T)*(S-T)+(A-w)*(A-w);if(G==0)k=S,D=A,F=(P-T)*(P-T)+(O-w)*(O-w);else{var V=((P-S)*(T-S)+(O-A)*(w-A))/G;V<0?(k=S,D=A,F=(S-P)*(S-P)+(A-O)*(A-O)):V>1?(k=T,D=w,F=(T-P)*(T-P)+(w-O)*(w-O)):(k=S+V*(T-S),D=A+V*(w-A),F=(k-P)*(k-P)+(D-O)*(D-O))}return[k,D,F]},_getProjectionToLine(S,A,T){var w=o.Util.cloneObject(S),P=Number.MAX_VALUE;return A.forEach(function(O,k){if(!(!T&&k===A.length-1)){var D=A[(k+1)%A.length],F=o.Util._getProjectionToSegment(O.x,O.y,D.x,D.y,S.x,S.y),G=F[0],V=F[1],W=F[2];W<P&&(w.x=G,w.y=V,P=W)}}),w},_prepareArrayForTween(S,A,T){var w,P=[],O=[];if(S.length>A.length){var k=A;A=S,S=k}for(w=0;w<S.length;w+=2)P.push({x:S[w],y:S[w+1]});for(w=0;w<A.length;w+=2)O.push({x:A[w],y:A[w+1]});var D=[];return O.forEach(function(F){var G=o.Util._getProjectionToLine(F,P,T);D.push(G.x),D.push(G.y)}),D},_prepareToStringify(S){var A;S.visitedByCircularReferenceRemoval=!0;for(var T in S)if(S.hasOwnProperty(T)&&S[T]&&typeof S[T]=="object"){if(A=Object.getOwnPropertyDescriptor(S,T),S[T].visitedByCircularReferenceRemoval||o.Util._isElement(S[T]))if(A.configurable)delete S[T];else return null;else if(o.Util._prepareToStringify(S[T])===null)if(A.configurable)delete S[T];else return null}return delete S.visitedByCircularReferenceRemoval,S},_assign(S,A){for(var T in A)S[T]=A[T];return S},_getFirstPointerId(S){return S.touches?S.changedTouches[0].identifier:S.pointerId||999},releaseCanvas(...S){e.Konva.releaseCanvasOnDestroy&&S.forEach(A=>{A.width=0,A.height=0})},drawRoundedRectPath(S,A,T,w){let P=0,O=0,k=0,D=0;typeof w=="number"?P=O=k=D=Math.min(w,A/2,T/2):(P=Math.min(w[0]||0,A/2,T/2),O=Math.min(w[1]||0,A/2,T/2),D=Math.min(w[2]||0,A/2,T/2),k=Math.min(w[3]||0,A/2,T/2)),S.moveTo(P,0),S.lineTo(A-O,0),S.arc(A-O,O,O,Math.PI*3/2,0,!1),S.lineTo(A,T-D),S.arc(A-D,T-D,D,0,Math.PI/2,!1),S.lineTo(k,T),S.arc(k,T-k,k,Math.PI/2,Math.PI,!1),S.lineTo(0,P),S.arc(P,P,P,Math.PI,Math.PI*3/2,!1)}}})(Util);var Node$1={},Factory={},Validators={};Object.defineProperty(Validators,"__esModule",{value:!0});Validators.getComponentValidator=Validators.getBooleanValidator=Validators.getNumberArrayValidator=Validators.getFunctionValidator=Validators.getStringOrGradientValidator=Validators.getStringValidator=Validators.getNumberOrAutoValidator=Validators.getNumberOrArrayOfNumbersValidator=Validators.getNumberValidator=Validators.alphaComponent=Validators.RGBComponent=void 0;const Global_1$p=Global,Util_1$f=Util;function _formatValue(o){return Util_1$f.Util._isString(o)?'"'+o+'"':Object.prototype.toString.call(o)==="[object Number]"||Util_1$f.Util._isBoolean(o)?o:Object.prototype.toString.call(o)}function RGBComponent(o){return o>255?255:o<0?0:Math.round(o)}Validators.RGBComponent=RGBComponent;function alphaComponent(o){return o>1?1:o<1e-4?1e-4:o}Validators.alphaComponent=alphaComponent;function getNumberValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){return Util_1$f.Util._isNumber(o)||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),o}}Validators.getNumberValidator=getNumberValidator;function getNumberOrArrayOfNumbersValidator(o){if(Global_1$p.Konva.isUnminified)return function(e,r){let t=Util_1$f.Util._isNumber(e),n=Util_1$f.Util._isArray(e)&&e.length==o;return!t&&!n&&Util_1$f.Util.warn(_formatValue(e)+' is a not valid value for "'+r+'" attribute. The value should be a number or Array<number>('+o+")"),e}}Validators.getNumberOrArrayOfNumbersValidator=getNumberOrArrayOfNumbersValidator;function getNumberOrAutoValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){var r=Util_1$f.Util._isNumber(o),t=o==="auto";return r||t||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),o}}Validators.getNumberOrAutoValidator=getNumberOrAutoValidator;function getStringValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){return Util_1$f.Util._isString(o)||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),o}}Validators.getStringValidator=getStringValidator;function getStringOrGradientValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){const r=Util_1$f.Util._isString(o),t=Object.prototype.toString.call(o)==="[object CanvasGradient]"||o&&o.addColorStop;return r||t||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),o}}Validators.getStringOrGradientValidator=getStringOrGradientValidator;function getFunctionValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){return Util_1$f.Util._isFunction(o)||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),o}}Validators.getFunctionValidator=getFunctionValidator;function getNumberArrayValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){const r=Int8Array?Object.getPrototypeOf(Int8Array):null;return r&&o instanceof r||(Util_1$f.Util._isArray(o)?o.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(o)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),o}}Validators.getNumberArrayValidator=getNumberArrayValidator;function getBooleanValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){var r=o===!0||o===!1;return r||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),o}}Validators.getBooleanValidator=getBooleanValidator;function getComponentValidator(o){if(Global_1$p.Konva.isUnminified)return function(e,r){return e==null||Util_1$f.Util.isObject(e)||Util_1$f.Util.warn(_formatValue(e)+' is a not valid value for "'+r+'" attribute. The value should be an object with properties '+o),e}}Validators.getComponentValidator=getComponentValidator;(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Factory=void 0;const e=Util,r=Validators;var t="get",n="set";o.Factory={addGetterSetter(a,l,u,f,d){o.Factory.addGetter(a,l,u),o.Factory.addSetter(a,l,f,d),o.Factory.addOverloadedGetterSetter(a,l)},addGetter(a,l,u){var f=t+e.Util._capitalize(l);a.prototype[f]=a.prototype[f]||function(){var d=this.attrs[l];return d===void 0?u:d}},addSetter(a,l,u,f){var d=n+e.Util._capitalize(l);a.prototype[d]||o.Factory.overWriteSetter(a,l,u,f)},overWriteSetter(a,l,u,f){var d=n+e.Util._capitalize(l);a.prototype[d]=function(h){return u&&h!==void 0&&h!==null&&(h=u.call(this,h,l)),this._setAttr(l,h),f&&f.call(this),this}},addComponentsGetterSetter(a,l,u,f,d){var h=u.length,y=e.Util._capitalize,E=t+y(l),p=n+y(l),_,g;a.prototype[E]=function(){var C={};for(_=0;_<h;_++)g=u[_],C[g]=this.getAttr(l+y(g));return C};var x=(0,r.getComponentValidator)(u);a.prototype[p]=function(C){var R=this.attrs[l],S;f&&(C=f.call(this,C)),x&&x.call(this,C,l);for(S in C)C.hasOwnProperty(S)&&this._setAttr(l+y(S),C[S]);return C||u.forEach(A=>{this._setAttr(l+y(A),void 0)}),this._fireChangeEvent(l,R,C),d&&d.call(this),this},o.Factory.addOverloadedGetterSetter(a,l)},addOverloadedGetterSetter(a,l){var u=e.Util._capitalize(l),f=n+u,d=t+u;a.prototype[l]=function(){return arguments.length?(this[f](arguments[0]),this):this[d]()}},addDeprecatedGetterSetter(a,l,u,f){e.Util.error("Adding deprecated "+l);var d=t+e.Util._capitalize(l),h=l+" property is deprecated and will be removed soon. Look at Konva change log for more information.";a.prototype[d]=function(){e.Util.error(h);var y=this.attrs[l];return y===void 0?u:y},o.Factory.addSetter(a,l,f,function(){e.Util.error(h)}),o.Factory.addOverloadedGetterSetter(a,l)},backCompat(a,l){e.Util.each(l,function(u,f){var d=a.prototype[f],h=t+e.Util._capitalize(u),y=n+e.Util._capitalize(u);function E(){d.apply(this,arguments),e.Util.error('"'+u+'" method is deprecated and will be removed soon. Use ""'+f+'" instead.')}a.prototype[u]=E,a.prototype[h]=E,a.prototype[y]=E})},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(o){var e=[],r=o.length,t=Util_1$e.Util,n,a;for(n=0;n<r;n++)a=o[n],t._isNumber(a)?a=Math.round(a*1e3)/1e3:t._isString(a)||(a=a+""),e.push(a);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,r){var t=this.traceArr,n=t.length,a="",l,u,f,d;for(l=0;l<n;l++)u=t[l],f=u.method,f?(d=u.args,a+=f,e?a+=DOUBLE_PAREN:Util_1$e.Util._isArray(d[0])?a+=OPEN_PAREN_BRACKET+d.join(COMMA)+CLOSE_BRACKET_PAREN:(r&&(d=d.map(h=>typeof h=="number"?Math.floor(h):h)),a+=OPEN_PAREN+d.join(COMMA)+CLOSE_PAREN)):(a+=u.property,e||(a+=EQUALS+u.val)),a+=SEMICOLON;return a}clearTrace(){this.traceArr=[]}_trace(e){var r=this.traceArr,t;r.push(e),t=r.length,t>=traceArrMax&&r.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var r=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,r.getWidth()/r.pixelRatio,r.getHeight()/r.pixelRatio)}_applyLineCap(e){const r=e.attrs.lineCap;r&&this.setAttr("lineCap",r)}_applyOpacity(e){var r=e.getAbsoluteOpacity();r!==1&&this.setAttr("globalAlpha",r)}_applyLineJoin(e){const r=e.attrs.lineJoin;r&&this.setAttr("lineJoin",r)}setAttr(e,r){this._context[e]=r}arc(e,r,t,n,a,l){this._context.arc(e,r,t,n,a,l)}arcTo(e,r,t,n,a){this._context.arcTo(e,r,t,n,a)}beginPath(){this._context.beginPath()}bezierCurveTo(e,r,t,n,a,l){this._context.bezierCurveTo(e,r,t,n,a,l)}clearRect(e,r,t,n){this._context.clearRect(e,r,t,n)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,r){var t=arguments;if(t.length===2)return this._context.createImageData(e,r);if(t.length===1)return this._context.createImageData(e)}createLinearGradient(e,r,t,n){return this._context.createLinearGradient(e,r,t,n)}createPattern(e,r){return this._context.createPattern(e,r)}createRadialGradient(e,r,t,n,a,l){return this._context.createRadialGradient(e,r,t,n,a,l)}drawImage(e,r,t,n,a,l,u,f,d){var h=arguments,y=this._context;h.length===3?y.drawImage(e,r,t):h.length===5?y.drawImage(e,r,t,n,a):h.length===9&&y.drawImage(e,r,t,n,a,l,u,f,d)}ellipse(e,r,t,n,a,l,u,f){this._context.ellipse(e,r,t,n,a,l,u,f)}isPointInPath(e,r,t,n){return t?this._context.isPointInPath(t,e,r,n):this._context.isPointInPath(e,r,n)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,r,t,n){this._context.fillRect(e,r,t,n)}strokeRect(e,r,t,n){this._context.strokeRect(e,r,t,n)}fillText(e,r,t,n){n?this._context.fillText(e,r,t,n):this._context.fillText(e,r,t)}measureText(e){return this._context.measureText(e)}getImageData(e,r,t,n){return this._context.getImageData(e,r,t,n)}lineTo(e,r){this._context.lineTo(e,r)}moveTo(e,r){this._context.moveTo(e,r)}rect(e,r,t,n){this._context.rect(e,r,t,n)}putImageData(e,r,t){this._context.putImageData(e,r,t)}quadraticCurveTo(e,r,t,n){this._context.quadraticCurveTo(e,r,t,n)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,r){this._context.scale(e,r)}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,r,t,n,a,l){this._context.setTransform(e,r,t,n,a,l)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,r,t,n){this._context.strokeText(e,r,t,n)}transform(e,r,t,n,a,l){this._context.transform(e,r,t,n,a,l)}translate(e,r){this._context.translate(e,r)}_enableTrace(){var e=this,r=CONTEXT_METHODS.length,t=this.setAttr,n,a,l=function(u){var f=e[u],d;e[u]=function(){return a=simplifyArray(Array.prototype.slice.call(arguments,0)),d=f.apply(e,arguments),e._trace({method:u,args:a}),d}};for(n=0;n<r;n++)l(CONTEXT_METHODS[n]);e.setAttr=function(){t.apply(e,arguments);var u=arguments[0],f=arguments[1];(u==="shadowOffsetX"||u==="shadowOffsetY"||u==="shadowBlur")&&(f=f/this.canvas.getPixelRatio()),e._trace({property:u,val:f})}}_applyGlobalCompositeOperation(e){const r=e.attrs.globalCompositeOperation;var t=!r||r==="source-over";t||this.setAttr("globalCompositeOperation",r)}};Context$2.Context=Context$1;CONTEXT_PROPERTIES.forEach(function(o){Object.defineProperty(Context$1.prototype,o,{get(){return this._context[o]},set(e){this._context[o]=e}})});class SceneContext extends Context$1{constructor(e,{willReadFrequently:r=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:r})}_fillColor(e){var r=e.fill();this.setAttr("fillStyle",r),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var r=e._getLinearGradient();r&&(this.setAttr("fillStyle",r),e._fillFunc(this))}_fillRadialGradient(e){const r=e._getRadialGradient();r&&(this.setAttr("fillStyle",r),e._fillFunc(this))}_fill(e){const r=e.fill(),t=e.getFillPriority();if(r&&t==="color"){this._fillColor(e);return}const n=e.getFillPatternImage();if(n&&t==="pattern"){this._fillPattern(e);return}const a=e.getFillLinearGradientColorStops();if(a&&t==="linear-gradient"){this._fillLinearGradient(e);return}const l=e.getFillRadialGradientColorStops();if(l&&t==="radial-gradient"){this._fillRadialGradient(e);return}r?this._fillColor(e):n?this._fillPattern(e):a?this._fillLinearGradient(e):l&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const r=e.getStrokeLinearGradientStartPoint(),t=e.getStrokeLinearGradientEndPoint(),n=e.getStrokeLinearGradientColorStops(),a=this.createLinearGradient(r.x,r.y,t.x,t.y);if(n){for(var l=0;l<n.length;l+=2)a.addColorStop(n[l],n[l+1]);this.setAttr("strokeStyle",a)}}_stroke(e){var r=e.dash(),t=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!t){this.save();var n=this.getCanvas().getPixelRatio();this.setTransform(n,0,0,n,0,0)}this._applyLineCap(e),r&&e.dashEnabled()&&(this.setLineDash(r),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");var a=e.getStrokeLinearGradientColorStops();a?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),t||this.restore()}}_applyShadow(e){var r,t,n,a=(r=e.getShadowRGBA())!==null&&r!==void 0?r:"black",l=(t=e.getShadowBlur())!==null&&t!==void 0?t:5,u=(n=e.getShadowOffset())!==null&&n!==void 0?n:{x:0,y:0},f=e.getAbsoluteScale(),d=this.canvas.getPixelRatio(),h=f.x*d,y=f.y*d;this.setAttr("shadowColor",a),this.setAttr("shadowBlur",l*Math.min(Math.abs(h),Math.abs(y))),this.setAttr("shadowOffsetX",u.x*h),this.setAttr("shadowOffsetY",u.y*y)}}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 a=e.getStrokeScaleEnabled();if(!a){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e);var t=e.hitStrokeWidth(),n=t==="auto"?e.strokeWidth():t;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),a||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 o=Util_1$d.Util.createCanvasElement(),e=o.getContext("2d");return _pixelRatio=function(){var r=Global_1$n.Konva._global.devicePixelRatio||1,t=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return r/t}(),Util_1$d.Util.releaseCanvas(o),_pixelRatio}class Canvas{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var r=e||{},t=r.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 r=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/r,this.getHeight()/r)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var r=this.pixelRatio,t=this.getContext()._context;t.scale(r,r)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var r=this.pixelRatio,t=this.getContext()._context;t.scale(r,r)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,r){this.setWidth(e||0),this.setHeight(r||0)}toDataURL(e,r){try{return this._canvas.toDataURL(e,r)}catch{try{return this._canvas.toDataURL()}catch(n){return Util_1$d.Util.error("Unable to get data URL. "+n.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(o){Object.defineProperty(o,"__esModule",{value:!0}),o.DD=void 0;const e=Global,r=Util;o.DD={get isDragging(){var t=!1;return o.DD._dragElements.forEach(n=>{n.dragStatus==="dragging"&&(t=!0)}),t},justDragged:!1,get node(){var t;return o.DD._dragElements.forEach(n=>{t=n.node}),t},_dragElements:new Map,_drag(t){const n=[];o.DD._dragElements.forEach((a,l)=>{const{node:u}=a,f=u.getStage();f.setPointersPositions(t),a.pointerId===void 0&&(a.pointerId=r.Util._getFirstPointerId(t));const d=f._changedPointerPositions.find(E=>E.id===a.pointerId);if(d){if(a.dragStatus!=="dragging"){var h=u.dragDistance(),y=Math.max(Math.abs(d.x-a.startPointerPos.x),Math.abs(d.y-a.startPointerPos.y));if(y<h||(u.startDrag({evt:t}),!u.isDragging()))return}u._setDragPosition(t,a),n.push(u)}}),n.forEach(a=>{a.fire("dragmove",{type:"dragmove",target:a,evt:t},!0)})},_endDragBefore(t){const n=[];o.DD._dragElements.forEach(a=>{const{node:l}=a,u=l.getStage();if(t&&u.setPointersPositions(t),!u._changedPointerPositions.find(h=>h.id===a.pointerId))return;(a.dragStatus==="dragging"||a.dragStatus==="stopped")&&(o.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,a.dragStatus="stopped");const d=a.node.getLayer()||a.node instanceof e.Konva.Stage&&a.node;d&&n.indexOf(d)===-1&&n.push(d)}),n.forEach(a=>{a.draw()})},_endDragAfter(t){o.DD._dragElements.forEach((n,a)=>{n.dragStatus==="stopped"&&n.node.fire("dragend",{type:"dragend",target:n.node,evt:t},!0),n.dragStatus!=="dragging"&&o.DD._dragElements.delete(a)})}},e.Konva.isBrowser&&(window.addEventListener("mouseup",o.DD._endDragBefore,!0),window.addEventListener("touchend",o.DD._endDragBefore,!0),window.addEventListener("mousemove",o.DD._drag),window.addEventListener("touchmove",o.DD._drag),window.addEventListener("mouseup",o.DD._endDragAfter,!1),window.addEventListener("touchend",o.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,r){var t=this._cache.get(e),n=e===TRANSFORM||e===ABSOLUTE_TRANSFORM,a=t===void 0||n&&t.dirty===!0;return a&&(t=r.call(this),this._cache.set(e,t)),t}_calculate(e,r,t){if(!this._attachedDepsListeners.get(e)){const n=r.map(a=>a+"Change.konva").join(SPACE$1);this.on(n,()=>{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:r,hit:t}=this._cache.get(CANVAS);Util_1$c.Util.releaseCanvas(e,r,t),this._cache.delete(CANVAS)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var r=e||{},t={};(r.x===void 0||r.y===void 0||r.width===void 0||r.height===void 0)&&(t=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));var n=Math.ceil(r.width||t.width),a=Math.ceil(r.height||t.height),l=r.pixelRatio,u=r.x===void 0?Math.floor(t.x):r.x,f=r.y===void 0?Math.floor(t.y):r.y,d=r.offset||0,h=r.drawBorder||!1,y=r.hitCanvasPixelRatio||1;if(!n||!a){Util_1$c.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}n+=d*2+1,a+=d*2+1,u-=d,f-=d;var E=new Canvas_1$1.SceneCanvas({pixelRatio:l,width:n,height:a}),p=new Canvas_1$1.SceneCanvas({pixelRatio:l,width:0,height:0,willReadFrequently:!0}),_=new Canvas_1$1.HitCanvas({pixelRatio:y,width:n,height:a}),g=E.getContext(),x=_.getContext();return _.isCache=!0,E.isCache=!0,this._cache.delete(CANVAS),this._filterUpToDate=!1,r.imageSmoothingEnabled===!1&&(E.getContext()._context.imageSmoothingEnabled=!1,p.getContext()._context.imageSmoothingEnabled=!1),g.save(),x.save(),g.translate(-u,-f),x.translate(-u,-f),this._isUnderCache=!0,this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this.drawScene(E,this),this.drawHit(_,this),this._isUnderCache=!1,g.restore(),x.restore(),h&&(g.save(),g.beginPath(),g.rect(0,0,n,a),g.closePath(),g.setAttr("strokeStyle","red"),g.setAttr("lineWidth",5),g.stroke(),g.restore()),this._cache.set(CANVAS,{scene:E,filter:p,hit:_,x:u,y:f}),this._requestDraw(),this}isCached(){return this._cache.has(CANVAS)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,r){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}],n=1/0,a=1/0,l=-1/0,u=-1/0,f=this.getAbsoluteTransform(r);return t.forEach(function(d){var h=f.point(d);n===void 0&&(n=l=h.x,a=u=h.y),n=Math.min(n,h.x),a=Math.min(a,h.y),l=Math.max(l,h.x),u=Math.max(u,h.y)}),{x:n,y:a,width:l-n,height:u-a}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const r=this._getCanvasCache();e.translate(r.x,r.y);var t=this._getCachedSceneCanvas(),n=t.pixelRatio;e.drawImage(t._canvas,0,0,t.width/n,t.height/n),e.restore()}_drawCachedHitCanvas(e){var r=this._getCanvasCache(),t=r.hit;e.save(),e.translate(r.x,r.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),r=this._getCanvasCache(),t=r.scene,n=r.filter,a=n.getContext(),l,u,f,d;if(e){if(!this._filterUpToDate){var h=t.pixelRatio;n.setSize(t.width/t.pixelRatio,t.height/t.pixelRatio);try{for(l=e.length,a.clear(),a.drawImage(t._canvas,0,0,t.getWidth()/h,t.getHeight()/h),u=a.getImageData(0,0,n.getWidth(),n.getHeight()),f=0;f<l;f++){if(d=e[f],typeof d!="function"){Util_1$c.Util.error("Filter should be type of function, but got "+typeof d+" instead. Please check correct filters");continue}d.call(this,u),a.putImageData(u,0,0)}}catch(y){Util_1$c.Util.error("Unable to apply filter. "+y.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return n}return t}on(e,r){if(this._cache&&this._cache.delete(ALL_LISTENERS),arguments.length===3)return this._delegate.apply(this,arguments);var t=e.split(SPACE$1),n=t.length,a,l,u,f,d;for(a=0;a<n;a++)l=t[a],u=l.split("."),f=u[0],d=u[1]||"",this.eventListeners[f]||(this.eventListeners[f]=[]),this.eventListeners[f].push({name:d,handler:r});return this}off(e,r){var t=(e||"").split(SPACE$1),n=t.length,a,l,u,f,d,h;if(this._cache&&this._cache.delete(ALL_LISTENERS),!e)for(l in this.eventListeners)this._off(l);for(a=0;a<n;a++)if(u=t[a],f=u.split("."),d=f[0],h=f[1],d)this.eventListeners[d]&&this._off(d,h,r);else for(l in this.eventListeners)this._off(l,h,r);return this}dispatchEvent(e){var r={target:this,type:e.type,evt:e};return this.fire(e.type,r),this}addEventListener(e,r){return this.on(e,function(t){r.call(this,t.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,r,t){var n=this;this.on(e,function(a){for(var l=a.target.findAncestors(r,!0,n),u=0;u<l.length;u++)a=Util_1$c.Util.cloneObject(a),a.currentTarget=l[u],t.call(l[u],a)})}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 r="get"+Util_1$c.Util._capitalize(e);return Util_1$c.Util._isFunction(this[r])?this[r]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),r=[];e;)r.push(e),e=e.getParent();return r}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{var r,t;if(!e)return this;for(r in e)r!==CHILDREN&&(t=SET+Util_1$c.Util._capitalize(r),Util_1$c.Util._isFunction(this[t])?this[t](e[r]):this._setAttr(r,e[r]))}),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,r=!1){if(e)return this._isVisible(e)&&this._isListening(e);var t=this.getLayer(),n=!1;DragAndDrop_1.DD._dragElements.forEach(l=>{l.dragStatus==="dragging"&&(l.node.nodeType==="Stage"||l.node.getLayer()===t)&&(n=!0)});var a=!r&&!Global_1$m.Konva.hitOnDragEnabled&&n;return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e=this.getDepth(),r=this,t=0,n,a,l,u;function f(h){for(n=[],a=h.length,l=0;l<a;l++)u=h[l],t++,u.nodeType!==SHAPE&&(n=n.concat(u.getChildren().slice())),u._id===r._id&&(l=a);n.length>0&&n[0].getDepth()<=e&&f(n)}const d=this.getStage();return r.nodeType!==UPPER_STAGE&&d&&f(d.getChildren()),t}getDepth(){for(var e=0,r=this.parent;r;)e++,r=r.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 r=e.getPointerPosition();if(!r)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(r)}getAbsolutePosition(e){let r=!1,t=this.parent;for(;t;){if(t.isCached()){r=!0;break}t=t.parent}r&&!e&&(e=!0);var n=this.getAbsoluteTransform(e).getMatrix(),a=new Util_1$c.Transform,l=this.offset();return a.m=n.slice(),a.translate(l.x,l.y),a.getTranslation()}setAbsolutePosition(e){const{x:r,y:t,...n}=this._clearTransform();this.attrs.x=r,this.attrs.y=t,this._clearCache(TRANSFORM);var a=this._getAbsoluteTransform().copy();return a.invert(),a.translate(e.x,e.y),e={x:this.attrs.x+a.getTranslation().x,y:this.attrs.y+a.getTranslation().y},this._setTransform(n),this.setPosition({x:e.x,y:e.y}),this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this}_setTransform(e){var r;for(r in e)this.attrs[r]=e[r]}_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 r=e.x,t=e.y,n=this.x(),a=this.y();return r!==void 0&&(n+=r),t!==void 0&&(a+=t),this.setPosition({x:n,y:a}),this}_eachAncestorReverse(e,r){var t=[],n=this.getParent(),a,l;if(!(r&&r._id===this._id)){for(t.unshift(this);n&&(!r||n._id!==r._id);)t.unshift(n),n=n.parent;for(a=t.length,l=0;l<a;l++)e(t[l])}}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,r=this.parent.getChildren().length;return e<r-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,r=this.parent.getChildren().length;return e<r-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 r=this.index;return this.parent.children.splice(r,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(),r=this.getParent();return r&&!r._isUnderCache&&(e*=r.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e={},r=this.getAttrs(),t,n,a,l,u;e.attrs={};for(t in r)n=r[t],u=Util_1$c.Util.isObject(n)&&!Util_1$c.Util._isPlainObject(n)&&!Util_1$c.Util._isArray(n),!u&&(a=typeof this[t]=="function"&&this[t],delete r[t],l=a?a.call(this):null,r[t]=n,l!==n&&(e.attrs[t]=n));return e.className=this.getClassName(),Util_1$c.Util._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,r,t){var n=[];r&&this._isMatch(e)&&n.push(this);for(var a=this.parent;a;){if(a===t)return n;a._isMatch(e)&&n.push(a),a=a.parent}return n}isAncestorOf(e){return!1}findAncestor(e,r,t){return this.findAncestors(e,r,t)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var r=e.replace(/ /g,"").split(","),t=r.length,n,a;for(n=0;n<t;n++)if(a=r[n],Util_1$c.Util.isValidSelector(a)||(Util_1$c.Util.warn('Selector "'+a+'" 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?")),a.charAt(0)==="#"){if(this.id()===a.slice(1))return!0}else if(a.charAt(0)==="."){if(this.hasName(a.slice(1)))return!0}else if(this.className===a||this.nodeType===a)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,r={},t){return r.target=r.target||this,t?this._fireAndBubble(e,r):this._fire(e,r),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(ABSOLUTE_TRANSFORM,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var r;if(e)return r=new Util_1$c.Transform,this._eachAncestorReverse(function(n){var a=n.transformsEnabled();a==="all"?r.multiply(n.getTransform()):a==="position"&&r.translate(n.x()-n.offsetX(),n.y()-n.offsetY())},e),r;r=this._cache.get(ABSOLUTE_TRANSFORM)||new Util_1$c.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(r):r.reset();var t=this.transformsEnabled();if(t==="all")r.multiply(this.getTransform());else if(t==="position"){const n=this.attrs.x||0,a=this.attrs.y||0,l=this.attrs.offsetX||0,u=this.attrs.offsetY||0;r.translate(n-l,a-u)}return r.dirty=!1,r}getAbsoluteScale(e){for(var r=this;r;)r._isUnderCache&&(e=r),r=r.getParent();const n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(TRANSFORM,this._getTransform)}_getTransform(){var e,r,t=this._cache.get(TRANSFORM)||new Util_1$c.Transform;t.reset();var n=this.x(),a=this.y(),l=Global_1$m.Konva.getAngle(this.rotation()),u=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,f=(r=this.attrs.scaleY)!==null&&r!==void 0?r:1,d=this.attrs.skewX||0,h=this.attrs.skewY||0,y=this.attrs.offsetX||0,E=this.attrs.offsetY||0;return(n!==0||a!==0)&&t.translate(n,a),l!==0&&t.rotate(l),(d!==0||h!==0)&&t.skew(d,h),(u!==1||f!==1)&&t.scale(u,f),(y!==0||E!==0)&&t.translate(-1*y,-1*E),t.dirty=!1,t}clone(e){var r=Util_1$c.Util.cloneObject(this.attrs),t,n,a,l,u;for(t in e)r[t]=e[t];var f=new this.constructor(r);for(t in this.eventListeners)for(n=this.eventListeners[t],a=n.length,l=0;l<a;l++)u=n[l],u.name.indexOf(KONVA)<0&&(f.eventListeners[t]||(f.eventListeners[t]=[]),f.eventListeners[t].push(u));return f}_toKonvaCanvas(e){e=e||{};var r=this.getClientRect(),t=this.getStage(),n=e.x!==void 0?e.x:Math.floor(r.x),a=e.y!==void 0?e.y:Math.floor(r.y),l=e.pixelRatio||1,u=new Canvas_1$1.SceneCanvas({width:e.width||Math.ceil(r.width)||(t?t.width():0),height:e.height||Math.ceil(r.height)||(t?t.height():0),pixelRatio:l}),f=u.getContext();return e.imageSmoothingEnabled===!1&&(f._context.imageSmoothingEnabled=!1),f.save(),(n||a)&&f.translate(-1*n,-1*a),this.drawScene(u),f.restore(),u}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var r=e.mimeType||null,t=e.quality||null,n=this._toKonvaCanvas(e).toDataURL(r,t);return e.callback&&e.callback(n),n}toImage(e){return new Promise((r,t)=>{try{const n=e==null?void 0:e.callback;n&&delete e.callback,Util_1$c.Util._urlToImage(this.toDataURL(e),function(a){r(a),n==null||n(a)})}catch(n){t(n)}})}toBlob(e){return new Promise((r,t)=>{try{const n=e==null?void 0:e.callback;n&&delete e.callback,this.toCanvas(e).toBlob(a=>{r(a),n==null||n(a)},e==null?void 0:e.mimeType,e==null?void 0:e.quality)}catch(n){t(n)}})}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,r,t){var n=this.eventListeners[e],a,l,u;for(a=0;a<n.length;a++)if(l=n[a].name,u=n[a].handler,(l!=="konva"||r==="konva")&&(!r||l===r)&&(!t||t===u)){if(n.splice(a,1),n.length===0){delete this.eventListeners[e];break}a--}}_fireChangeEvent(e,r,t){this._fire(e+CHANGE,{oldVal:r,newVal:t})}addName(e){if(!this.hasName(e)){var r=this.name(),t=r?r+" "+e:e;this.name(t)}return this}hasName(e){if(!e)return!1;const r=this.name();if(!r)return!1;var t=(r||"").split(/\s/g);return t.indexOf(e)!==-1}removeName(e){var r=(this.name()||"").split(/\s/g),t=r.indexOf(e);return t!==-1&&(r.splice(t,1),this.name(r.join(" "))),this}setAttr(e,r){var t=this[SET+Util_1$c.Util._capitalize(e)];return Util_1$c.Util._isFunction(t)?t.call(this,r):this._setAttr(e,r),this}_requestDraw(){if(Global_1$m.Konva.autoDrawEnabled){const e=this.getLayer()||this.getStage();e==null||e.batchDraw()}}_setAttr(e,r){var t=this.attrs[e];t===r&&!Util_1$c.Util.isObject(r)||(r==null?delete this.attrs[e]:this.attrs[e]=r,this._shouldFireChangeEvents&&this._fireChangeEvent(e,t,r),this._requestDraw())}_setComponentAttr(e,r,t){var n;t!==void 0&&(n=this.attrs[e],n||(this.attrs[e]=this.getAttr(e)),this.attrs[e][r]=t,this._fireChangeEvent(e,n,t))}_fireAndBubble(e,r,t){r&&this.nodeType===SHAPE&&(r.target=this);var n=(e===MOUSEENTER||e===MOUSELEAVE)&&(t&&(this===t||this.isAncestorOf&&this.isAncestorOf(t))||this.nodeType==="Stage"&&!t);if(!n){this._fire(e,r);var a=(e===MOUSEENTER||e===MOUSELEAVE)&&t&&t.isAncestorOf&&t.isAncestorOf(this)&&!t.isAncestorOf(this.parent);(r&&!r.cancelBubble||!r)&&this.parent&&this.parent.isListening()&&!a&&(t&&t.parent?this._fireAndBubble.call(this.parent,e,r,t):this._fireAndBubble.call(this.parent,e,r))}}_getProtoListeners(e){var r,t,n;const a=(r=this._cache.get(ALL_LISTENERS))!==null&&r!==void 0?r:{};let l=a==null?void 0:a[e];if(l===void 0){l=[];let u=Object.getPrototypeOf(this);for(;u;){const f=(n=(t=u.eventListeners)===null||t===void 0?void 0:t[e])!==null&&n!==void 0?n:[];l.push(...f),u=Object.getPrototypeOf(u)}a[e]=l,this._cache.set(ALL_LISTENERS,a)}return l}_fire(e,r){r=r||{},r.currentTarget=this,r.type=e;const t=this._getProtoListeners(e);if(t)for(var n=0;n<t.length;n++)t[n].handler.call(this,r);const a=this.eventListeners[e];if(a)for(var n=0;n<a.length;n++)a[n].handler.call(this,r)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var r=e?e.pointerId:void 0,t=this.getStage(),n=this.getAbsolutePosition();if(t){var a=t._getPointerById(r)||t._changedPointerPositions[0]||n;DragAndDrop_1.DD._dragElements.set(this._id,{node:this,startPointerPos:a,offset:{x:a.x-n.x,y:a.y-n.y},dragStatus:"ready",pointerId:r})}}startDrag(e,r=!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},r)}_setDragPosition(e,r){const t=this.getStage()._getPointerById(r.pointerId);if(t){var n={x:t.x-r.offset.x,y:t.y-r.offset.y},a=this.dragBoundFunc();if(a!==void 0){const l=a.call(this,n,e);l?n=l: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!==n.x||this._lastPos.y!==n.y)&&(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}}stopDrag(e){const r=DragAndDrop_1.DD._dragElements.get(this._id);r&&(r.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 r=e.evt.button!==void 0,t=!r||Global_1$m.Konva.dragButtons.indexOf(e.evt.button)>=0;if(t&&!this.isDragging()){var n=!1;DragAndDrop_1.DD._dragElements.forEach(a=>{this.isAncestorOf(a.node)&&(n=!0)}),n||this._createDragElement(e)}})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var e=this.getStage();if(!e)return;const r=DragAndDrop_1.DD._dragElements.get(this._id),t=r&&r.dragStatus==="dragging",n=r&&r.dragStatus==="ready";t?this.stopDrag():n&&DragAndDrop_1.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const r=this.getStage();if(!r)return!1;const t={x:-e.x,y:-e.y,width:r.width()+2*e.x,height:r.height()+2*e.y};return Util_1$c.Util.haveIntersection(t,this.getClientRect())}static create(e,r){return Util_1$c.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,r)}static _createNode(e,r){var t=Node.prototype.getClassName.call(e),n=e.children,a,l,u;r&&(e.attrs.container=r),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(a=new f(e.attrs),n)for(l=n.length,u=0;u<l;u++)a.add(Node._createNode(n[u]));return a}}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(o){return this._filterUpToDate=!1,o});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 r=this.children||[];var t=[];return r.forEach(function(n){e(n)&&t.push(n)}),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 r=0;r<e.length;r++)this.add(e[r]);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 r=this._generalFind(e,!0);return r.length>0?r[0]:void 0}_generalFind(e,r){var t=[];return this._descendants(n=>{const a=n._isMatch(e);return a&&t.push(n),!!(a&&r)}),t}_descendants(e){let r=!1;const t=this.getChildren();for(const n of t){if(r=e(n),r)return!0;if(n.hasChildren()&&(r=n._descendants(e),r))return!0}return!1}toObject(){var e=Node_1$h.Node.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(r=>{e.children.push(r.toObject())}),e}isAncestorOf(e){for(var r=e.getParent();r;){if(r._id===this._id)return!0;r=r.getParent()}return!1}clone(e){var r=Node_1$h.Node.prototype.clone.call(this,e);return this.getChildren().forEach(function(t){r.add(t.clone())}),r}getAllIntersections(e){var r=[];return this.find("Shape").forEach(t=>{t.isVisible()&&t.intersects(e)&&r.push(t)}),r}_clearSelfAndDescendantCache(e){var r;super._clearSelfAndDescendantCache(e),!this.isCached()&&((r=this.children)===null||r===void 0||r.forEach(function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(r,t){r.index=t}),this._requestDraw()}drawScene(e,r){var t=this.getLayer(),n=e||t&&t.getCanvas(),a=n&&n.getContext(),l=this._getCanvasCache(),u=l&&l.scene,f=n&&n.isCache;if(!this.isVisible()&&!f)return this;if(u){a.save();var d=this.getAbsoluteTransform(r).getMatrix();a.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren("drawScene",n,r);return this}drawHit(e,r){if(!this.shouldDrawHit(r))return this;var t=this.getLayer(),n=e||t&&t.hitCanvas,a=n&&n.getContext(),l=this._getCanvasCache(),u=l&&l.hit;if(u){a.save();var f=this.getAbsoluteTransform(r).getMatrix();a.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedHitCanvas(a),a.restore()}else this._drawChildren("drawHit",n,r);return this}_drawChildren(e,r,t){var n,a=r&&r.getContext(),l=this.clipWidth(),u=this.clipHeight(),f=this.clipFunc(),d=l&&u||f;const h=t===this;if(d){a.save();var y=this.getAbsoluteTransform(t),E=y.getMatrix();a.transform(E[0],E[1],E[2],E[3],E[4],E[5]),a.beginPath();let x;if(f)x=f.call(this,a,this);else{var p=this.clipX(),_=this.clipY();a.rect(p,_,l,u)}a.clip.apply(a,x),E=y.copy().invert().getMatrix(),a.transform(E[0],E[1],E[2],E[3],E[4],E[5])}var g=!h&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";g&&(a.save(),a._applyGlobalCompositeOperation(this)),(n=this.children)===null||n===void 0||n.forEach(function(x){x[e](r,t)}),g&&a.restore(),d&&a.restore()}getClientRect(e={}){var r,t=e.skipTransform,n=e.relativeTo,a,l,u,f,d={x:1/0,y:1/0,width:0,height:0},h=this;(r=this.children)===null||r===void 0||r.forEach(function(g){if(g.visible()){var x=g.getClientRect({relativeTo:h,skipShadow:e.skipShadow,skipStroke:e.skipStroke});x.width===0&&x.height===0||(a===void 0?(a=x.x,l=x.y,u=x.x+x.width,f=x.y+x.height):(a=Math.min(a,x.x),l=Math.min(l,x.y),u=Math.max(u,x.x+x.width),f=Math.max(f,x.y+x.height)))}});for(var y=this.find("Shape"),E=!1,p=0;p<y.length;p++){var _=y[p];if(_._isVisible(this)){E=!0;break}}return E&&a!==void 0?d={x:a,y:l,width:u-a,height:f-l}:d={x:0,y:0,width:0,height:0},t?d:this._transformedRect(d,n)}};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(o){return Captures.get(o)}PointerEvents.getCapturedShape=getCapturedShape;function createEvent(o){return{evt:o,pointerId:o.pointerId}}PointerEvents.createEvent=createEvent;function hasPointerCapture(o,e){return Captures.get(o)===e}PointerEvents.hasPointerCapture=hasPointerCapture;function setPointerCapture(o,e){releaseCapture(o),e.getStage()&&(Captures.set(o,e),SUPPORT_POINTER_EVENTS&&e._fire("gotpointercapture",createEvent(new PointerEvent("gotpointercapture"))))}PointerEvents.setPointerCapture=setPointerCapture;function releaseCapture(o,e){const r=Captures.get(o);if(!r)return;const t=r.getStage();t&&t.content,Captures.delete(o),SUPPORT_POINTER_EVENTS&&r._fire("lostpointercapture",createEvent(new PointerEvent("lostpointercapture")))}PointerEvents.releaseCapture=releaseCapture;(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Stage=o.stages=void 0;const e=Util,r=Factory,t=Container$2,n=Global,a=Canvas$1,l=DragAndDrop,u=Global,f=PointerEvents;var d="Stage",h="string",y="px",E="mouseout",p="mouseleave",_="mouseover",g="mouseenter",x="mousemove",C="mousedown",R="mouseup",S="pointermove",A="pointerdown",T="pointerup",w="pointercancel",P="lostpointercapture",O="pointerout",k="pointerleave",D="pointerover",F="pointerenter",G="contextmenu",V="touchstart",W="touchend",ee="touchmove",q="touchcancel",z="wheel",U=5,$=[[g,"_pointerenter"],[C,"_pointerdown"],[x,"_pointermove"],[R,"_pointerup"],[p,"_pointerleave"],[V,"_pointerdown"],[ee,"_pointermove"],[W,"_pointerup"],[q,"_pointercancel"],[_,"_pointerover"],[z,"_wheel"],[G,"_contextmenu"],[A,"_pointerdown"],[S,"_pointermove"],[T,"_pointerup"],[w,"_pointercancel"],[P,"_lostpointercapture"]];const I={mouse:{[O]:E,[k]:p,[D]:_,[F]:g,[S]:x,[A]:C,[T]:R,[w]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[O]:"touchout",[k]:"touchleave",[D]:"touchover",[F]:"touchenter",[S]:ee,[A]:V,[T]:W,[w]:q,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[O]:O,[k]:k,[D]:D,[F]:F,[S]:S,[A]:A,[T]:T,[w]:w,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},B=ae=>ae.indexOf("pointer")>=0?"pointer":ae.indexOf("touch")>=0?"touch":"mouse",X=ae=>{const Z=B(ae);if(Z==="pointer")return n.Konva.pointerEventsEnabled&&I.pointer;if(Z==="touch")return I.touch;if(Z==="mouse")return I.mouse};function Q(ae={}){return(ae.clipFunc||ae.clipWidth||ae.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),ae}const J="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);";o.stages=[];class ne extends t.Container{constructor(Z){super(Q(Z)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),o.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",()=>{Q(this.attrs)}),this._checkVisibility()}_validateAdd(Z){const se=Z.getType()==="Layer",oe=Z.getType()==="FastLayer";se||oe||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===h){if(Z.charAt(0)==="."){var se=Z.slice(1);Z=document.getElementsByClassName(se)[0]}else{var oe;Z.charAt(0)!=="#"?oe=Z:oe=Z.slice(1),Z=document.getElementById(oe)}if(!Z)throw"Can not find container in document with id "+oe}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,se=Z.length,oe;for(oe=0;oe<se;oe++)Z[oe].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 se=o.stages.indexOf(this);return se>-1&&o.stages.splice(se,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(J),null)}_getPointerById(Z){return this._pointerPositions.find(se=>se.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 se=new a.SceneCanvas({width:Z.width,height:Z.height,pixelRatio:Z.pixelRatio||1}),oe=se.getContext()._context,fe=this.children;return(Z.x||Z.y)&&oe.translate(-1*Z.x,-1*Z.y),fe.forEach(function(de){if(de.isVisible()){var ce=de._toKonvaCanvas(Z);oe.drawImage(ce._canvas,Z.x,Z.y,ce.getWidth()/ce.getPixelRatio(),ce.getHeight()/ce.getPixelRatio())}}),se}getIntersection(Z){if(!Z)return null;var se=this.children,oe=se.length,fe=oe-1,de;for(de=fe;de>=0;de--){const ce=se[de].getIntersection(Z);if(ce)return ce}return null}_resizeDOM(){var Z=this.width(),se=this.height();this.content&&(this.content.style.width=Z+y,this.content.style.height=se+y),this.bufferCanvas.setSize(Z,se),this.bufferHitCanvas.setSize(Z,se),this.children.forEach(oe=>{oe.setSize({width:Z,height:se}),oe.draw()})}add(Z,...se){if(arguments.length>1){for(var oe=0;oe<arguments.length;oe++)this.add(arguments[oe]);return this}super.add(Z);var fe=this.children.length;return fe>U&&e.Util.warn("The stage has "+fe+" 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(),n.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(){n.Konva.isBrowser&&$.forEach(([Z,se])=>{this.content.addEventListener(Z,oe=>{this[se](oe)},{passive:!1})})}_pointerenter(Z){this.setPointersPositions(Z);const se=X(Z.type);se&&this._fire(se.pointerenter,{evt:Z,target:this,currentTarget:this})}_pointerover(Z){this.setPointersPositions(Z);const se=X(Z.type);se&&this._fire(se.pointerover,{evt:Z,target:this,currentTarget:this})}_getTargetShape(Z){let se=this[Z+"targetShape"];return se&&!se.getStage()&&(se=null),se}_pointerleave(Z){const se=X(Z.type),oe=B(Z.type);if(se){this.setPointersPositions(Z);var fe=this._getTargetShape(oe),de=!l.DD.isDragging||n.Konva.hitOnDragEnabled;fe&&de?(fe._fireAndBubble(se.pointerout,{evt:Z}),fe._fireAndBubble(se.pointerleave,{evt:Z}),this._fire(se.pointerleave,{evt:Z,target:this,currentTarget:this}),this[oe+"targetShape"]=null):de&&(this._fire(se.pointerleave,{evt:Z,target:this,currentTarget:this}),this._fire(se.pointerout,{evt:Z,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(Z){const se=X(Z.type),oe=B(Z.type);if(se){this.setPointersPositions(Z);var fe=!1;this._changedPointerPositions.forEach(de=>{var ce=this.getIntersection(de);if(l.DD.justDragged=!1,n.Konva["_"+oe+"ListenClick"]=!0,!ce||!ce.isListening())return;n.Konva.capturePointerEventsEnabled&&ce.setPointerCapture(de.id),this[oe+"ClickStartShape"]=ce,ce._fireAndBubble(se.pointerdown,{evt:Z,pointerId:de.id}),fe=!0;const Ee=Z.type.indexOf("touch")>=0;ce.preventDefault()&&Z.cancelable&&Ee&&Z.preventDefault()}),fe||this._fire(se.pointerdown,{evt:Z,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(Z){const se=X(Z.type),oe=B(Z.type);if(!se)return;l.DD.isDragging&&l.DD.node.preventDefault()&&Z.cancelable&&Z.preventDefault(),this.setPointersPositions(Z);var fe=!l.DD.isDragging||n.Konva.hitOnDragEnabled;if(!fe)return;var de={};let ce=!1;var Ee=this._getTargetShape(oe);this._changedPointerPositions.forEach(De=>{const we=f.getCapturedShape(De.id)||this.getIntersection(De),He=De.id,Xe={evt:Z,pointerId:He};var Qe=Ee!==we;if(Qe&&Ee&&(Ee._fireAndBubble(se.pointerout,{...Xe},we),Ee._fireAndBubble(se.pointerleave,{...Xe},we)),we){if(de[we._id])return;de[we._id]=!0}we&&we.isListening()?(ce=!0,Qe&&(we._fireAndBubble(se.pointerover,{...Xe},Ee),we._fireAndBubble(se.pointerenter,{...Xe},Ee),this[oe+"targetShape"]=we),we._fireAndBubble(se.pointermove,{...Xe})):Ee&&(this._fire(se.pointerover,{evt:Z,target:this,currentTarget:this,pointerId:He}),this[oe+"targetShape"]=null)}),ce||this._fire(se.pointermove,{evt:Z,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(Z){const se=X(Z.type),oe=B(Z.type);if(!se)return;this.setPointersPositions(Z);const fe=this[oe+"ClickStartShape"],de=this[oe+"ClickEndShape"];var ce={};let Ee=!1;this._changedPointerPositions.forEach(De=>{const we=f.getCapturedShape(De.id)||this.getIntersection(De);if(we){if(we.releaseCapture(De.id),ce[we._id])return;ce[we._id]=!0}const He=De.id,Xe={evt:Z,pointerId:He};let Qe=!1;n.Konva["_"+oe+"InDblClickWindow"]?(Qe=!0,clearTimeout(this[oe+"DblTimeout"])):l.DD.justDragged||(n.Konva["_"+oe+"InDblClickWindow"]=!0,clearTimeout(this[oe+"DblTimeout"])),this[oe+"DblTimeout"]=setTimeout(function(){n.Konva["_"+oe+"InDblClickWindow"]=!1},n.Konva.dblClickWindow),we&&we.isListening()?(Ee=!0,this[oe+"ClickEndShape"]=we,we._fireAndBubble(se.pointerup,{...Xe}),n.Konva["_"+oe+"ListenClick"]&&fe&&fe===we&&(we._fireAndBubble(se.pointerclick,{...Xe}),Qe&&de&&de===we&&we._fireAndBubble(se.pointerdblclick,{...Xe}))):(this[oe+"ClickEndShape"]=null,n.Konva["_"+oe+"ListenClick"]&&this._fire(se.pointerclick,{evt:Z,target:this,currentTarget:this,pointerId:He}),Qe&&this._fire(se.pointerdblclick,{evt:Z,target:this,currentTarget:this,pointerId:He}))}),Ee||this._fire(se.pointerup,{evt:Z,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),n.Konva["_"+oe+"ListenClick"]=!1,Z.cancelable&&oe!=="touch"&&Z.preventDefault()}_contextmenu(Z){this.setPointersPositions(Z);var se=this.getIntersection(this.getPointerPosition());se&&se.isListening()?se._fireAndBubble(G,{evt:Z}):this._fire(G,{evt:Z,target:this,currentTarget:this})}_wheel(Z){this.setPointersPositions(Z);var se=this.getIntersection(this.getPointerPosition());se&&se.isListening()?se._fireAndBubble(z,{evt:Z}):this._fire(z,{evt:Z,target:this,currentTarget:this})}_pointercancel(Z){this.setPointersPositions(Z);const se=f.getCapturedShape(Z.pointerId)||this.getIntersection(this.getPointerPosition());se&&se._fireAndBubble(T,f.createEvent(Z)),f.releaseCapture(Z.pointerId)}_lostpointercapture(Z){f.releaseCapture(Z.pointerId)}setPointersPositions(Z){var se=this._getContentPosition(),oe=null,fe=null;Z=Z||window.event,Z.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(Z.touches,de=>{this._pointerPositions.push({id:de.identifier,x:(de.clientX-se.left)/se.scaleX,y:(de.clientY-se.top)/se.scaleY})}),Array.prototype.forEach.call(Z.changedTouches||Z.touches,de=>{this._changedPointerPositions.push({id:de.identifier,x:(de.clientX-se.left)/se.scaleX,y:(de.clientY-se.top)/se.scaleY})})):(oe=(Z.clientX-se.left)/se.scaleX,fe=(Z.clientY-se.top)/se.scaleY,this.pointerPos={x:oe,y:fe},this._pointerPositions=[{x:oe,y:fe,id:e.Util._getFirstPointerId(Z)}],this._changedPointerPositions=[{x:oe,y:fe,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 a.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new a.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!!n.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}}o.Stage=ne,ne.prototype.nodeType=d,(0,u._registerNode)(ne),r.Factory.addGetterSetter(ne,"container")})(Stage$1);var Layer$2={},Shape={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Shape=o.shapes=void 0;const e=Global,r=Util,t=Factory,n=Node$1,a=Validators,l=Global,u=PointerEvents;var f="hasShadow",d="shadowRGBA",h="patternImage",y="linearGradient",E="radialGradient";let p;function _(){return p||(p=r.Util.createCanvasElement().getContext("2d"),p)}o.shapes={};function g(k){const D=this.attrs.fillRule;D?k.fill(D):k.fill()}function x(k){k.stroke()}function C(k){k.fill()}function R(k){k.stroke()}function S(){this._clearCache(f)}function A(){this._clearCache(d)}function T(){this._clearCache(h)}function w(){this._clearCache(y)}function P(){this._clearCache(E)}class O extends n.Node{constructor(D){super(D);let F;for(;F=r.Util.getRandomColor(),!(F&&!(F in o.shapes)););this.colorKey=F,o.shapes[F]=this}getContext(){return r.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return r.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(h,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var D=_();const F=D.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(F&&F.setTransform){const G=new r.Transform;G.translate(this.fillPatternX(),this.fillPatternY()),G.rotate(e.Konva.getAngle(this.fillPatternRotation())),G.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),G.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const V=G.getMatrix(),W=typeof DOMMatrix>"u"?{a:V[0],b:V[1],c:V[2],d:V[3],e:V[4],f:V[5]}:new DOMMatrix(V);F.setTransform(W)}return F}}_getLinearGradient(){return this._getCache(y,this.__getLinearGradient)}__getLinearGradient(){var D=this.fillLinearGradientColorStops();if(D){for(var F=_(),G=this.fillLinearGradientStartPoint(),V=this.fillLinearGradientEndPoint(),W=F.createLinearGradient(G.x,G.y,V.x,V.y),ee=0;ee<D.length;ee+=2)W.addColorStop(D[ee],D[ee+1]);return W}}_getRadialGradient(){return this._getCache(E,this.__getRadialGradient)}__getRadialGradient(){var D=this.fillRadialGradientColorStops();if(D){for(var F=_(),G=this.fillRadialGradientStartPoint(),V=this.fillRadialGradientEndPoint(),W=F.createRadialGradient(G.x,G.y,this.fillRadialGradientStartRadius(),V.x,V.y,this.fillRadialGradientEndRadius()),ee=0;ee<D.length;ee+=2)W.addColorStop(D[ee],D[ee+1]);return W}}getShadowRGBA(){return this._getCache(d,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var D=r.Util.colorToRGBA(this.shadowColor());if(D)return"rgba("+D.r+","+D.g+","+D.b+","+D.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 D=this.hitStrokeWidth();return D==="auto"?this.hasStroke():this.strokeEnabled()&&!!D}intersects(D){var F=this.getStage();if(!F)return!1;const G=F.bufferHitCanvas;return G.getContext().clear(),this.drawHit(G,void 0,!0),G.context.getImageData(Math.round(D.x),Math.round(D.y),1,1).data[3]>0}destroy(){return n.Node.prototype.destroy.call(this),delete o.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(D){var F;if(!this.getStage()||!((F=this.attrs.perfectDrawEnabled)!==null&&F!==void 0?F:!0))return!1;const V=D||this.hasFill(),W=this.hasStroke(),ee=this.getAbsoluteOpacity()!==1;if(V&&W&&ee)return!0;const q=this.hasShadow(),z=this.shadowForStrokeEnabled();return!!(V&&W&&q&&z)}setStrokeHitEnabled(D){r.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),D?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){var D=this.size();return{x:this._centroid?-D.width/2:0,y:this._centroid?-D.height/2:0,width:D.width,height:D.height}}getClientRect(D={}){const F=D.skipTransform,G=D.relativeTo,V=this.getSelfRect(),ee=!D.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,q=V.width+ee,z=V.height+ee,U=!D.skipShadow&&this.hasShadow(),$=U?this.shadowOffsetX():0,I=U?this.shadowOffsetY():0,B=q+Math.abs($),X=z+Math.abs(I),Q=U&&this.shadowBlur()||0,J=B+Q*2,ne=X+Q*2,ae={width:J,height:ne,x:-(ee/2+Q)+Math.min($,0)+V.x,y:-(ee/2+Q)+Math.min(I,0)+V.y};return F?ae:this._transformedRect(ae,G)}drawScene(D,F){var G=this.getLayer(),V=D||G.getCanvas(),W=V.getContext(),ee=this._getCanvasCache(),q=this.getSceneFunc(),z=this.hasShadow(),U,$,I,B=V.isCache,X=F===this;if(!this.isVisible()&&!X)return this;if(ee){W.save();var Q=this.getAbsoluteTransform(F).getMatrix();return W.transform(Q[0],Q[1],Q[2],Q[3],Q[4],Q[5]),this._drawCachedSceneCanvas(W),W.restore(),this}if(!q)return this;if(W.save(),this._useBufferCanvas()&&!B){U=this.getStage(),$=U.bufferCanvas,I=$.getContext(),I.clear(),I.save(),I._applyLineJoin(this);var J=this.getAbsoluteTransform(F).getMatrix();I.transform(J[0],J[1],J[2],J[3],J[4],J[5]),q.call(this,I,this),I.restore();var ne=$.pixelRatio;z&&W._applyShadow(this),W._applyOpacity(this),W._applyGlobalCompositeOperation(this),W.drawImage($._canvas,0,0,$.width/ne,$.height/ne)}else{if(W._applyLineJoin(this),!X){var J=this.getAbsoluteTransform(F).getMatrix();W.transform(J[0],J[1],J[2],J[3],J[4],J[5]),W._applyOpacity(this),W._applyGlobalCompositeOperation(this)}z&&W._applyShadow(this),q.call(this,W,this)}return W.restore(),this}drawHit(D,F,G=!1){if(!this.shouldDrawHit(F,G))return this;var V=this.getLayer(),W=D||V.hitCanvas,ee=W&&W.getContext(),q=this.hitFunc()||this.sceneFunc(),z=this._getCanvasCache(),U=z&&z.hit;if(this.colorKey||r.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()"),U){ee.save();var $=this.getAbsoluteTransform(F).getMatrix();return ee.transform($[0],$[1],$[2],$[3],$[4],$[5]),this._drawCachedHitCanvas(ee),ee.restore(),this}if(!q)return this;if(ee.save(),ee._applyLineJoin(this),!(this===F)){var B=this.getAbsoluteTransform(F).getMatrix();ee.transform(B[0],B[1],B[2],B[3],B[4],B[5])}return q.call(this,ee,this),ee.restore(),this}drawHitFromCache(D=0){var F=this._getCanvasCache(),G=this._getCachedSceneCanvas(),V=F.hit,W=V.getContext(),ee=V.getWidth(),q=V.getHeight(),z,U,$,I,B,X;W.clear(),W.drawImage(G._canvas,0,0,ee,q);try{for(z=W.getImageData(0,0,ee,q),U=z.data,$=U.length,I=r.Util._hexToRgb(this.colorKey),B=0;B<$;B+=4)X=U[B+3],X>D?(U[B]=I.r,U[B+1]=I.g,U[B+2]=I.b,U[B+3]=255):U[B+3]=0;W.putImageData(z,0,0)}catch(Q){r.Util.error("Unable to draw hit graph from cached scene canvas. "+Q.message)}return this}hasPointerCapture(D){return u.hasPointerCapture(D,this)}setPointerCapture(D){u.setPointerCapture(D,this)}releaseCapture(D){u.releaseCapture(D,this)}}o.Shape=O,O.prototype._fillFunc=g,O.prototype._strokeFunc=x,O.prototype._fillFuncHit=C,O.prototype._strokeFuncHit=R,O.prototype._centroid=!1,O.prototype.nodeType="Shape",(0,l._registerNode)(O),O.prototype.eventListeners={},O.prototype.on.call(O.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",S),O.prototype.on.call(O.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",A),O.prototype.on.call(O.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",T),O.prototype.on.call(O.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",w),O.prototype.on.call(O.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",P),t.Factory.addGetterSetter(O,"stroke",void 0,(0,a.getStringOrGradientValidator)()),t.Factory.addGetterSetter(O,"strokeWidth",2,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillAfterStrokeEnabled",!1),t.Factory.addGetterSetter(O,"hitStrokeWidth","auto",(0,a.getNumberOrAutoValidator)()),t.Factory.addGetterSetter(O,"strokeHitEnabled",!0,(0,a.getBooleanValidator)()),t.Factory.addGetterSetter(O,"perfectDrawEnabled",!0,(0,a.getBooleanValidator)()),t.Factory.addGetterSetter(O,"shadowForStrokeEnabled",!0,(0,a.getBooleanValidator)()),t.Factory.addGetterSetter(O,"lineJoin"),t.Factory.addGetterSetter(O,"lineCap"),t.Factory.addGetterSetter(O,"sceneFunc"),t.Factory.addGetterSetter(O,"hitFunc"),t.Factory.addGetterSetter(O,"dash"),t.Factory.addGetterSetter(O,"dashOffset",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"shadowColor",void 0,(0,a.getStringValidator)()),t.Factory.addGetterSetter(O,"shadowBlur",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"shadowOpacity",1,(0,a.getNumberValidator)()),t.Factory.addComponentsGetterSetter(O,"shadowOffset",["x","y"]),t.Factory.addGetterSetter(O,"shadowOffsetX",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"shadowOffsetY",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternImage"),t.Factory.addGetterSetter(O,"fill",void 0,(0,a.getStringOrGradientValidator)()),t.Factory.addGetterSetter(O,"fillPatternX",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternY",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillLinearGradientColorStops"),t.Factory.addGetterSetter(O,"strokeLinearGradientColorStops"),t.Factory.addGetterSetter(O,"fillRadialGradientStartRadius",0),t.Factory.addGetterSetter(O,"fillRadialGradientEndRadius",0),t.Factory.addGetterSetter(O,"fillRadialGradientColorStops"),t.Factory.addGetterSetter(O,"fillPatternRepeat","repeat"),t.Factory.addGetterSetter(O,"fillEnabled",!0),t.Factory.addGetterSetter(O,"strokeEnabled",!0),t.Factory.addGetterSetter(O,"shadowEnabled",!0),t.Factory.addGetterSetter(O,"dashEnabled",!0),t.Factory.addGetterSetter(O,"strokeScaleEnabled",!0),t.Factory.addGetterSetter(O,"fillPriority","color"),t.Factory.addComponentsGetterSetter(O,"fillPatternOffset",["x","y"]),t.Factory.addGetterSetter(O,"fillPatternOffsetX",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternOffsetY",0,(0,a.getNumberValidator)()),t.Factory.addComponentsGetterSetter(O,"fillPatternScale",["x","y"]),t.Factory.addGetterSetter(O,"fillPatternScaleX",1,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternScaleY",1,(0,a.getNumberValidator)()),t.Factory.addComponentsGetterSetter(O,"fillLinearGradientStartPoint",["x","y"]),t.Factory.addComponentsGetterSetter(O,"strokeLinearGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillLinearGradientStartPointX",0),t.Factory.addGetterSetter(O,"strokeLinearGradientStartPointX",0),t.Factory.addGetterSetter(O,"fillLinearGradientStartPointY",0),t.Factory.addGetterSetter(O,"strokeLinearGradientStartPointY",0),t.Factory.addComponentsGetterSetter(O,"fillLinearGradientEndPoint",["x","y"]),t.Factory.addComponentsGetterSetter(O,"strokeLinearGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillLinearGradientEndPointX",0),t.Factory.addGetterSetter(O,"strokeLinearGradientEndPointX",0),t.Factory.addGetterSetter(O,"fillLinearGradientEndPointY",0),t.Factory.addGetterSetter(O,"strokeLinearGradientEndPointY",0),t.Factory.addComponentsGetterSetter(O,"fillRadialGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillRadialGradientStartPointX",0),t.Factory.addGetterSetter(O,"fillRadialGradientStartPointY",0),t.Factory.addComponentsGetterSetter(O,"fillRadialGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillRadialGradientEndPointX",0),t.Factory.addGetterSetter(O,"fillRadialGradientEndPointY",0),t.Factory.addGetterSetter(O,"fillPatternRotation",0),t.Factory.addGetterSetter(O,"fillRule",void 0,(0,a.getStringValidator)()),t.Factory.backCompat(O,{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 r=this.getStage();return r&&r.content&&(r.content.removeChild(this.getNativeCanvasElement()),e<r.children.length-1?r.content.insertBefore(this.getNativeCanvasElement(),r.children[e+1].getCanvas()._canvas):r.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 r=this.getStage();return!r||!r.content?!1:(r.content.removeChild(this.getNativeCanvasElement()),this.index<r.children.length-1?r.content.insertBefore(this.getNativeCanvasElement(),r.children[this.index+1].getCanvas()._canvas):r.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Node_1$g.Node.prototype.moveDown.call(this)){var e=this.getStage();if(e){var r=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),r[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 r=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),r[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:r}){return this.canvas.setSize(e,r),this.hitCanvas.setSize(e,r),this._setSmoothEnabled(),this}_validateAdd(e){var r=e.getType();r!=="Group"&&r!=="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 r=1,t=!1;;){for(let n=0;n<INTERSECTION_OFFSETS_LEN;n++){const a=INTERSECTION_OFFSETS[n],l=this._getIntersection({x:e.x+a.x*r,y:e.y+a.y*r}),u=l.shape;if(u)return u;if(t=!!l.antialiased,!l.antialiased)break}if(t)r+=1;else return null}}_getIntersection(e){const r=this.hitCanvas.pixelRatio,t=this.hitCanvas.context.getImageData(Math.round(e.x*r),Math.round(e.y*r),1,1).data,n=t[3];if(n===255){const a=Util_1$b.Util._rgbToHex(t[0],t[1],t[2]),l=Shape_1$g.shapes[HASH+a];return l?{shape:l}:{antialiased:!0}}else if(n>0)return{antialiased:!0};return{}}drawScene(e,r){var t=this.getLayer(),n=e||t&&t.getCanvas();return this._fire(BEFORE_DRAW,{node:this}),this.clearBeforeDraw()&&n.getContext().clear(),Container_1$1.Container.prototype.drawScene.call(this,n,r),this._fire(DRAW,{node:this}),this}drawHit(e,r){var t=this.getLayer(),n=e||t&&t.hitCanvas;return t&&t.clearBeforeDraw()&&t.getHitCanvas().getContext().clear(),Container_1$1.Container.prototype.drawHit.call(this,n,r),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,r=!!this.hitCanvas._canvas.parentNode;r?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 r=e.getType();r!=="Group"&&r!=="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 Hl{constructor(e,r){this.id=Hl.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:now(),frameRate:0},this.func=e,this.setLayers(r)}setLayers(e){let r=[];return e&&(r=Array.isArray(e)?e:[e]),this.layers=r,this}getLayers(){return this.layers}addLayer(e){const r=this.layers,t=r.length;for(let n=0;n<t;n++)if(r[n]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){const r=Hl.animations,t=r.length;for(let n=0;n<t;n++)if(r[n].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=now(),Hl._addAnimation(this),this}stop(){return Hl._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 r=e.id,t=this.animations,n=t.length;for(let a=0;a<n;a++)if(t[a].id===r){this.animations.splice(a,1);break}}static _runFrames(){const e={},r=this.animations;for(let t=0;t<r.length;t++){const n=r[t],a=n.layers,l=n.func;n._updateFrameObject(now());const u=a.length;let f;if(l?f=l.call(n,n.frame)!==!1:f=!0,!!f)for(let d=0;d<u;d++){const h=a[d];h._id!==void 0&&(e[h._id]=h)}}for(let t in e)e.hasOwnProperty(t)&&e[t].batchDraw()}static _animationLoop(){const e=Hl;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(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Easings=o.Tween=void 0;const e=Util,r=Animation$2,t=Node$1,n=Global;var a={node:1,duration:1,easing:1,onFinish:1,yoyo:1},l=1,u=2,f=3,d=0,h=["fill","stroke","shadowColor"];class y{constructor(_,g,x,C,R,S,A){this.prop=_,this.propFunc=g,this.begin=C,this._pos=C,this.duration=S,this._change=0,this.prevPos=0,this.yoyo=A,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=x,this._change=R-this.begin,this.pause()}fire(_){var g=this[_];g&&g()}setTime(_){_>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():_<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=_,this.update())}getTime(){return this._time}setPosition(_){this.prevPos=this._pos,this.propFunc(_),this._pos=_}getPosition(_){return _===void 0&&(_=this._time),this.func(_,this.begin,this._change,this.duration)}play(){this.state=u,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(_){this.pause(),this._time=_,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 _=this.getTimer()-this._startTime;this.state===u?this.setTime(_):this.state===f&&this.setTime(this.duration-_)}pause(){this.state=l,this.fire("onPause")}getTimer(){return new Date().getTime()}}class E{constructor(_){var g=this,x=_.node,C=x._id,R,S=_.easing||o.Easings.Linear,A=!!_.yoyo,T;typeof _.duration>"u"?R=.3:_.duration===0?R=.001:R=_.duration,this.node=x,this._id=d++;var w=x.getLayer()||(x instanceof n.Konva.Stage?x.getLayers():null);w||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new r.Animation(function(){g.tween.onEnterFrame()},w),this.tween=new y(T,function(P){g._tweenFunc(P)},S,0,1,R*1e3,A),this._addListeners(),E.attrs[C]||(E.attrs[C]={}),E.attrs[C][this._id]||(E.attrs[C][this._id]={}),E.tweens[C]||(E.tweens[C]={});for(T in _)a[T]===void 0&&this._addAttr(T,_[T]);this.reset(),this.onFinish=_.onFinish,this.onReset=_.onReset,this.onUpdate=_.onUpdate}_addAttr(_,g){var x=this.node,C=x._id,R,S,A,T,w,P,O,k;if(A=E.tweens[C][_],A&&delete E.attrs[C][A][_],R=x.getAttr(_),e.Util._isArray(g))if(S=[],w=Math.max(g.length,R.length),_==="points"&&g.length!==R.length&&(g.length>R.length?(O=R,R=e.Util._prepareArrayForTween(R,g,x.closed())):(P=g,g=e.Util._prepareArrayForTween(g,R,x.closed()))),_.indexOf("fill")===0)for(T=0;T<w;T++)if(T%2===0)S.push(g[T]-R[T]);else{var D=e.Util.colorToRGBA(R[T]);k=e.Util.colorToRGBA(g[T]),R[T]=D,S.push({r:k.r-D.r,g:k.g-D.g,b:k.b-D.b,a:k.a-D.a})}else for(T=0;T<w;T++)S.push(g[T]-R[T]);else h.indexOf(_)!==-1?(R=e.Util.colorToRGBA(R),k=e.Util.colorToRGBA(g),S={r:k.r-R.r,g:k.g-R.g,b:k.b-R.b,a:k.a-R.a}):S=g-R;E.attrs[C][this._id][_]={start:R,diff:S,end:g,trueEnd:P,trueStart:O},E.tweens[C][_]=this._id}_tweenFunc(_){var g=this.node,x=E.attrs[g._id][this._id],C,R,S,A,T,w,P,O;for(C in x){if(R=x[C],S=R.start,A=R.diff,O=R.end,e.Util._isArray(S))if(T=[],P=Math.max(S.length,O.length),C.indexOf("fill")===0)for(w=0;w<P;w++)w%2===0?T.push((S[w]||0)+A[w]*_):T.push("rgba("+Math.round(S[w].r+A[w].r*_)+","+Math.round(S[w].g+A[w].g*_)+","+Math.round(S[w].b+A[w].b*_)+","+(S[w].a+A[w].a*_)+")");else for(w=0;w<P;w++)T.push((S[w]||0)+A[w]*_);else h.indexOf(C)!==-1?T="rgba("+Math.round(S.r+A.r*_)+","+Math.round(S.g+A.g*_)+","+Math.round(S.b+A.b*_)+","+(S.a+A.a*_)+")":T=S+A*_;g.setAttr(C,T)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var _=this.node,g=E.attrs[_._id][this._id];g.points&&g.points.trueEnd&&_.setAttr("points",g.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var _=this.node,g=E.attrs[_._id][this._id];g.points&&g.points.trueStart&&_.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(_){return this.tween.seek(_*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var _=this.node._id,g=this._id,x=E.tweens[_],C;this.pause();for(C in x)delete E.tweens[_][C];delete E.attrs[_][g]}}o.Tween=E,E.attrs={},E.tweens={},t.Node.prototype.to=function(p){var _=p.onFinish;p.node=this,p.onFinish=function(){this.destroy(),_&&_()};var g=new E(p);g.play()},o.Easings={BackEaseIn(p,_,g,x){var C=1.70158;return g*(p/=x)*p*((C+1)*p-C)+_},BackEaseOut(p,_,g,x){var C=1.70158;return g*((p=p/x-1)*p*((C+1)*p+C)+1)+_},BackEaseInOut(p,_,g,x){var C=1.70158;return(p/=x/2)<1?g/2*(p*p*(((C*=1.525)+1)*p-C))+_:g/2*((p-=2)*p*(((C*=1.525)+1)*p+C)+2)+_},ElasticEaseIn(p,_,g,x,C,R){var S=0;return p===0?_:(p/=x)===1?_+g:(R||(R=x*.3),!C||C<Math.abs(g)?(C=g,S=R/4):S=R/(2*Math.PI)*Math.asin(g/C),-(C*Math.pow(2,10*(p-=1))*Math.sin((p*x-S)*(2*Math.PI)/R))+_)},ElasticEaseOut(p,_,g,x,C,R){var S=0;return p===0?_:(p/=x)===1?_+g:(R||(R=x*.3),!C||C<Math.abs(g)?(C=g,S=R/4):S=R/(2*Math.PI)*Math.asin(g/C),C*Math.pow(2,-10*p)*Math.sin((p*x-S)*(2*Math.PI)/R)+g+_)},ElasticEaseInOut(p,_,g,x,C,R){var S=0;return p===0?_:(p/=x/2)===2?_+g:(R||(R=x*(.3*1.5)),!C||C<Math.abs(g)?(C=g,S=R/4):S=R/(2*Math.PI)*Math.asin(g/C),p<1?-.5*(C*Math.pow(2,10*(p-=1))*Math.sin((p*x-S)*(2*Math.PI)/R))+_:C*Math.pow(2,-10*(p-=1))*Math.sin((p*x-S)*(2*Math.PI)/R)*.5+g+_)},BounceEaseOut(p,_,g,x){return(p/=x)<1/2.75?g*(7.5625*p*p)+_:p<2/2.75?g*(7.5625*(p-=1.5/2.75)*p+.75)+_:p<2.5/2.75?g*(7.5625*(p-=2.25/2.75)*p+.9375)+_:g*(7.5625*(p-=2.625/2.75)*p+.984375)+_},BounceEaseIn(p,_,g,x){return g-o.Easings.BounceEaseOut(x-p,0,g,x)+_},BounceEaseInOut(p,_,g,x){return p<x/2?o.Easings.BounceEaseIn(p*2,0,g,x)*.5+_:o.Easings.BounceEaseOut(p*2-x,0,g,x)*.5+g*.5+_},EaseIn(p,_,g,x){return g*(p/=x)*p+_},EaseOut(p,_,g,x){return-g*(p/=x)*(p-2)+_},EaseInOut(p,_,g,x){return(p/=x/2)<1?g/2*p*p+_:-g/2*(--p*(p-2)-1)+_},StrongEaseIn(p,_,g,x){return g*(p/=x)*p*p*p*p+_},StrongEaseOut(p,_,g,x){return g*((p=p/x-1)*p*p*p*p+1)+_},StrongEaseInOut(p,_,g,x){return(p/=x/2)<1?g/2*p*p*p*p*p+_:g/2*((p-=2)*p*p*p*p+2)+_},Linear(p,_,g,x){return g*p/x+_}}})(Tween$1);(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Konva=void 0;const e=Global,r=Util,t=Node$1,n=Container$2,a=Stage$1,l=Layer$2,u=FastLayer$1,f=Group$2,d=DragAndDrop,h=Shape,y=Animation$2,E=Tween$1,p=Context$2,_=Canvas$1;o.Konva=r.Util._assign(e.Konva,{Util:r.Util,Transform:r.Transform,Node:t.Node,Container:n.Container,Stage:a.Stage,stages:a.stages,Layer:l.Layer,FastLayer:u.FastLayer,Group:f.Group,DD:d.DD,Shape:h.Shape,shapes:h.shapes,Animation:y.Animation,Tween:E.Tween,Easings:E.Easings,Context:p.Context,Canvas:_.Canvas}),o.default=o.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 r=Global_1$g.Konva.getAngle(this.angle()),t=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,r,t),e.arc(0,0,this.innerRadius(),r,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(),r=this.outerRadius(),t=this.clockwise(),n=Global_1$g.Konva.getAngle(t?360-this.angle():this.angle()),a=Math.cos(Math.min(n,Math.PI)),l=1,u=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),f=Math.sin(Math.min(n,Math.PI/2)),d=a*(a>0?e:r),h=l*r,y=u*(u>0?e:r),E=f*(f>0?r:e);return{x:d,y:t?-1*E:y,width:h-d,height:E-y}}}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(o,e,r,t,n,a,l){var u=Math.sqrt(Math.pow(r-o,2)+Math.pow(t-e,2)),f=Math.sqrt(Math.pow(n-r,2)+Math.pow(a-t,2)),d=l*u/(u+f),h=l*f/(u+f),y=r-d*(n-o),E=t-d*(a-e),p=r+h*(n-o),_=t+h*(a-e);return[y,E,p,_]}function expandPoints(o,e){var r=o.length,t=[],n,a;for(n=2;n<r-2;n+=2)a=getControlPoints(o[n-2],o[n-1],o[n],o[n+1],o[n+2],o[n+3],e),!isNaN(a[0])&&(t.push(a[0]),t.push(a[1]),t.push(o[n]),t.push(o[n+1]),t.push(a[2]),t.push(a[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 r=this.points(),t=r.length,n=this.tension(),a=this.closed(),l=this.bezier(),u,f,d;if(t){if(e.beginPath(),e.moveTo(r[0],r[1]),n!==0&&t>4){for(u=this.getTensionPoints(),f=u.length,d=a?0:4,a||e.quadraticCurveTo(u[0],u[1],u[2],u[3]);d<f-2;)e.bezierCurveTo(u[d++],u[d++],u[d++],u[d++],u[d++],u[d++]);a||e.quadraticCurveTo(u[f-2],u[f-1],r[t-2],r[t-1])}else if(l)for(d=2;d<t;)e.bezierCurveTo(r[d++],r[d++],r[d++],r[d++],r[d++],r[d++]);else for(d=2;d<t;d+=2)e.lineTo(r[d],r[d+1]);a?(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(),r=e.length,t=this.tension(),n=getControlPoints(e[r-2],e[r-1],e[0],e[1],e[2],e[3],t),a=getControlPoints(e[r-4],e[r-3],e[r-2],e[r-1],e[0],e[1],t),l=expandPoints(e,t),u=[n[2],n[3]].concat(l).concat([a[0],a[1],e[r-2],e[r-1],a[2],a[3],n[0],n[1],e[0],e[1]]);return u}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 r=e[0],t=e[0],n=e[1],a=e[1],l,u,f=0;f<e.length/2;f++)l=e[f*2],u=e[f*2+1],r=Math.min(r,l),t=Math.max(t,l),n=Math.min(n,u),a=Math.max(a,u);return{x:r,y:n,width:t-r,height:a-n}}};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(o){Object.defineProperty(o,"__esModule",{value:!0}),o.t2length=o.getQuadraticArcLength=o.getCubicArcLength=o.binomialCoefficients=o.cValues=o.tValues=void 0,o.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]],o.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]],o.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]];const e=(l,u,f)=>{let d,h,y;d=f/2,h=0;for(let p=0;p<20;p++)y=d*o.tValues[20][p]+d,h+=o.cValues[20][p]*t(l,u,y);return d*h};o.getCubicArcLength=e;const r=(l,u,f)=>{f===void 0&&(f=1);const d=l[0]-2*l[1]+l[2],h=u[0]-2*u[1]+u[2],y=2*l[1]-2*l[0],E=2*u[1]-2*u[0],p=4*(d*d+h*h),_=4*(d*y+h*E),g=y*y+E*E;if(p===0)return f*Math.sqrt(Math.pow(l[2]-l[0],2)+Math.pow(u[2]-u[0],2));const x=_/(2*p),C=g/p,R=f+x,S=C-x*x,A=R*R+S>0?Math.sqrt(R*R+S):0,T=x*x+S>0?Math.sqrt(x*x+S):0,w=x+Math.sqrt(x*x+S)!==0?S*Math.log(Math.abs((R+A)/(x+T))):0;return Math.sqrt(p)/2*(R*A-x*T+w)};o.getQuadraticArcLength=r;function t(l,u,f){const d=n(1,f,l),h=n(1,f,u),y=d*d+h*h;return Math.sqrt(y)}const n=(l,u,f)=>{const d=f.length-1;let h,y;if(d===0)return 0;if(l===0){y=0;for(let E=0;E<=d;E++)y+=o.binomialCoefficients[d][E]*Math.pow(1-u,d-E)*Math.pow(u,E)*f[E];return y}else{h=new Array(d);for(let E=0;E<d;E++)h[E]=d*(f[E+1]-f[E]);return n(l-1,u,h)}},a=(l,u,f)=>{let d=1,h=l/u,y=(l-f(h))/u,E=0;for(;d>.001;){const p=f(h+y),_=Math.abs(l-p)/u;if(_<d)d=_,h+=y;else{const g=f(h-y),x=Math.abs(l-g)/u;x<d?(d=x,h-=y):y/=2}if(E++,E>500)break}return h};o.t2length=a})(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 r=this.dataArray;e.beginPath();for(var t=!1,n=0;n<r.length;n++){var a=r[n].command,l=r[n].points;switch(a){case"L":e.lineTo(l[0],l[1]);break;case"M":e.moveTo(l[0],l[1]);break;case"C":e.bezierCurveTo(l[0],l[1],l[2],l[3],l[4],l[5]);break;case"Q":e.quadraticCurveTo(l[0],l[1],l[2],l[3]);break;case"A":var u=l[0],f=l[1],d=l[2],h=l[3],y=l[4],E=l[5],p=l[6],_=l[7],g=d>h?d:h,x=d>h?1:d/h,C=d>h?h/d:1;e.translate(u,f),e.rotate(p),e.scale(x,C),e.arc(0,0,g,y,y+E,1-_),e.scale(1/x,1/C),e.rotate(-p),e.translate(-u,-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(d){if(d.command==="A"){var h=d.points[4],y=d.points[5],E=d.points[4]+y,p=Math.PI/180;if(Math.abs(h-E)<p&&(p=Math.abs(h-E)),y<0)for(let _=h-p;_>E;_-=p){const g=Path.getPointOnEllipticalArc(d.points[0],d.points[1],d.points[2],d.points[3],_,0);e.push(g.x,g.y)}else for(let _=h+p;_<E;_+=p){const g=Path.getPointOnEllipticalArc(d.points[0],d.points[1],d.points[2],d.points[3],_,0);e.push(g.x,g.y)}}else if(d.command==="C")for(let _=0;_<=1;_+=.01){const g=Path.getPointOnCubicBezier(_,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3],d.points[4],d.points[5]);e.push(g.x,g.y)}else e=e.concat(d.points)});for(var r=e[0],t=e[0],n=e[1],a=e[1],l,u,f=0;f<e.length/2;f++)l=e[f*2],u=e[f*2+1],isNaN(l)||(r=Math.min(r,l),t=Math.max(t,l)),isNaN(u)||(n=Math.min(n,u),a=Math.max(a,u));return{x:r,y:n,width:t-r,height:a-n}}getLength(){return this.pathLength}getPointAtLength(e){return Path.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(e,r,t,n){return Math.sqrt((t-e)*(t-e)+(n-r)*(n-r))}static getPathLength(e){let r=0;for(var t=0;t<e.length;++t)r+=e[t].pathLength;return r}static getPointAtLengthOfDataArray(e,r){var t,n=0,a=r.length;if(!a)return null;for(;n<a&&e>r[n].pathLength;)e-=r[n].pathLength,++n;if(n===a)return t=r[n-1].points.slice(-2),{x:t[0],y:t[1]};if(e<.01)return t=r[n].points.slice(0,2),{x:t[0],y:t[1]};var l=r[n],u=l.points;switch(l.command){case"L":return Path.getPointOnLine(e,l.start.x,l.start.y,u[0],u[1]);case"C":return Path.getPointOnCubicBezier((0,BezierFunctions_1.t2length)(e,Path.getPathLength(r),g=>(0,BezierFunctions_1.getCubicArcLength)([l.start.x,u[0],u[2],u[4]],[l.start.y,u[1],u[3],u[5]],g)),l.start.x,l.start.y,u[0],u[1],u[2],u[3],u[4],u[5]);case"Q":return Path.getPointOnQuadraticBezier((0,BezierFunctions_1.t2length)(e,Path.getPathLength(r),g=>(0,BezierFunctions_1.getQuadraticArcLength)([l.start.x,u[0],u[2]],[l.start.y,u[1],u[3]],g)),l.start.x,l.start.y,u[0],u[1],u[2],u[3]);case"A":var f=u[0],d=u[1],h=u[2],y=u[3],E=u[4],p=u[5],_=u[6];return E+=p*e/l.pathLength,Path.getPointOnEllipticalArc(f,d,h,y,E,_)}return null}static getPointOnLine(e,r,t,n,a,l,u){l===void 0&&(l=r),u===void 0&&(u=t);var f=(a-t)/(n-r+1e-8),d=Math.sqrt(e*e/(1+f*f));n<r&&(d*=-1);var h=f*d,y;if(n===r)y={x:l,y:u+h};else if((u-t)/(l-r+1e-8)===f)y={x:l+d,y:u+h};else{var E,p,_=this.getLineLength(r,t,n,a),g=(l-r)*(n-r)+(u-t)*(a-t);g=g/(_*_),E=r+g*(n-r),p=t+g*(a-t);var x=this.getLineLength(l,u,E,p),C=Math.sqrt(e*e-x*x);d=Math.sqrt(C*C/(1+f*f)),n<r&&(d*=-1),h=f*d,y={x:E+d,y:p+h}}return y}static getPointOnCubicBezier(e,r,t,n,a,l,u,f,d){function h(x){return x*x*x}function y(x){return 3*x*x*(1-x)}function E(x){return 3*x*(1-x)*(1-x)}function p(x){return(1-x)*(1-x)*(1-x)}var _=f*h(e)+l*y(e)+n*E(e)+r*p(e),g=d*h(e)+u*y(e)+a*E(e)+t*p(e);return{x:_,y:g}}static getPointOnQuadraticBezier(e,r,t,n,a,l,u){function f(p){return p*p}function d(p){return 2*p*(1-p)}function h(p){return(1-p)*(1-p)}var y=l*f(e)+n*d(e)+r*h(e),E=u*f(e)+a*d(e)+t*h(e);return{x:y,y:E}}static getPointOnEllipticalArc(e,r,t,n,a,l){var u=Math.cos(l),f=Math.sin(l),d={x:t*Math.cos(a),y:n*Math.sin(a)};return{x:e+(d.x*u-d.y*f),y:r+(d.x*f+d.y*u)}}static parsePathData(e){if(!e)return[];var r=e,t=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];r=r.replace(new RegExp(" ","g"),",");for(var n=0;n<t.length;n++)r=r.replace(new RegExp(t[n],"g"),"|"+t[n]);var a=r.split("|"),l=[],u=[],f=0,d=0,h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,y;for(n=1;n<a.length;n++){var E=a[n],p=E.charAt(0);for(E=E.slice(1),u.length=0;y=h.exec(E);)u.push(y[0]);for(var _=[],g=0,x=u.length;g<x;g++){if(u[g]==="00"){_.push(0,0);continue}var C=parseFloat(u[g]);isNaN(C)?_.push(0):_.push(C)}for(;_.length>0&&!isNaN(_[0]);){var R="",S=[],A=f,T=d,w,P,O,k,D,F,G,V,W,ee;switch(p){case"l":f+=_.shift(),d+=_.shift(),R="L",S.push(f,d);break;case"L":f=_.shift(),d=_.shift(),S.push(f,d);break;case"m":var q=_.shift(),z=_.shift();if(f+=q,d+=z,R="M",l.length>2&&l[l.length-1].command==="z"){for(var U=l.length-2;U>=0;U--)if(l[U].command==="M"){f=l[U].points[0]+q,d=l[U].points[1]+z;break}}S.push(f,d),p="l";break;case"M":f=_.shift(),d=_.shift(),R="M",S.push(f,d),p="L";break;case"h":f+=_.shift(),R="L",S.push(f,d);break;case"H":f=_.shift(),R="L",S.push(f,d);break;case"v":d+=_.shift(),R="L",S.push(f,d);break;case"V":d=_.shift(),R="L",S.push(f,d);break;case"C":S.push(_.shift(),_.shift(),_.shift(),_.shift()),f=_.shift(),d=_.shift(),S.push(f,d);break;case"c":S.push(f+_.shift(),d+_.shift(),f+_.shift(),d+_.shift()),f+=_.shift(),d+=_.shift(),R="C",S.push(f,d);break;case"S":P=f,O=d,w=l[l.length-1],w.command==="C"&&(P=f+(f-w.points[2]),O=d+(d-w.points[3])),S.push(P,O,_.shift(),_.shift()),f=_.shift(),d=_.shift(),R="C",S.push(f,d);break;case"s":P=f,O=d,w=l[l.length-1],w.command==="C"&&(P=f+(f-w.points[2]),O=d+(d-w.points[3])),S.push(P,O,f+_.shift(),d+_.shift()),f+=_.shift(),d+=_.shift(),R="C",S.push(f,d);break;case"Q":S.push(_.shift(),_.shift()),f=_.shift(),d=_.shift(),S.push(f,d);break;case"q":S.push(f+_.shift(),d+_.shift()),f+=_.shift(),d+=_.shift(),R="Q",S.push(f,d);break;case"T":P=f,O=d,w=l[l.length-1],w.command==="Q"&&(P=f+(f-w.points[0]),O=d+(d-w.points[1])),f=_.shift(),d=_.shift(),R="Q",S.push(P,O,f,d);break;case"t":P=f,O=d,w=l[l.length-1],w.command==="Q"&&(P=f+(f-w.points[0]),O=d+(d-w.points[1])),f+=_.shift(),d+=_.shift(),R="Q",S.push(P,O,f,d);break;case"A":k=_.shift(),D=_.shift(),F=_.shift(),G=_.shift(),V=_.shift(),W=f,ee=d,f=_.shift(),d=_.shift(),R="A",S=this.convertEndpointToCenterParameterization(W,ee,f,d,G,V,k,D,F);break;case"a":k=_.shift(),D=_.shift(),F=_.shift(),G=_.shift(),V=_.shift(),W=f,ee=d,f+=_.shift(),d+=_.shift(),R="A",S=this.convertEndpointToCenterParameterization(W,ee,f,d,G,V,k,D,F);break}l.push({command:R||p,points:S,start:{x:A,y:T},pathLength:this.calcLength(A,T,R||p,S)})}(p==="z"||p==="Z")&&l.push({command:"z",points:[],start:void 0,pathLength:0})}return l}static calcLength(e,r,t,n){var a,l,u,f,d=Path;switch(t){case"L":return d.getLineLength(e,r,n[0],n[1]);case"C":return(0,BezierFunctions_1.getCubicArcLength)([e,n[0],n[2],n[4]],[r,n[1],n[3],n[5]],1);case"Q":return(0,BezierFunctions_1.getQuadraticArcLength)([e,n[0],n[2]],[r,n[1],n[3]],1);case"A":a=0;var h=n[4],y=n[5],E=n[4]+y,p=Math.PI/180;if(Math.abs(h-E)<p&&(p=Math.abs(h-E)),l=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],h,0),y<0)for(f=h-p;f>E;f-=p)u=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],f,0),a+=d.getLineLength(l.x,l.y,u.x,u.y),l=u;else for(f=h+p;f<E;f+=p)u=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],f,0),a+=d.getLineLength(l.x,l.y,u.x,u.y),l=u;return u=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],E,0),a+=d.getLineLength(l.x,l.y,u.x,u.y),a}return 0}static convertEndpointToCenterParameterization(e,r,t,n,a,l,u,f,d){var h=d*(Math.PI/180),y=Math.cos(h)*(e-t)/2+Math.sin(h)*(r-n)/2,E=-1*Math.sin(h)*(e-t)/2+Math.cos(h)*(r-n)/2,p=y*y/(u*u)+E*E/(f*f);p>1&&(u*=Math.sqrt(p),f*=Math.sqrt(p));var _=Math.sqrt((u*u*(f*f)-u*u*(E*E)-f*f*(y*y))/(u*u*(E*E)+f*f*(y*y)));a===l&&(_*=-1),isNaN(_)&&(_=0);var g=_*u*E/f,x=_*-f*y/u,C=(e+t)/2+Math.cos(h)*g-Math.sin(h)*x,R=(r+n)/2+Math.sin(h)*g+Math.cos(h)*x,S=function(D){return Math.sqrt(D[0]*D[0]+D[1]*D[1])},A=function(D,F){return(D[0]*F[0]+D[1]*F[1])/(S(D)*S(F))},T=function(D,F){return(D[0]*F[1]<D[1]*F[0]?-1:1)*Math.acos(A(D,F))},w=T([1,0],[(y-g)/u,(E-x)/f]),P=[(y-g)/u,(E-x)/f],O=[(-1*y-g)/u,(-1*E-x)/f],k=T(P,O);return A(P,O)<=-1&&(k=Math.PI),A(P,O)>=1&&(k=0),l===0&&k>0&&(k=k-2*Math.PI),l===1&&k<0&&(k=k+2*Math.PI),[C,R,u,f,w,k,h,l]}}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 r=Math.PI*2,t=this.points(),n=t,a=this.tension()!==0&&t.length>4;a&&(n=this.getTensionPoints());var l=this.pointerLength(),u=t.length,f,d;if(a){const E=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],t[u-2],t[u-1]],p=Path_1$2.Path.calcLength(n[n.length-4],n[n.length-3],"C",E),_=Path_1$2.Path.getPointOnQuadraticBezier(Math.min(1,1-l/p),E[0],E[1],E[2],E[3],E[4],E[5]);f=t[u-2]-_.x,d=t[u-1]-_.y}else f=t[u-2]-t[u-4],d=t[u-1]-t[u-3];var h=(Math.atan2(d,f)+r)%r,y=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[u-2],t[u-1]),e.rotate(h),e.moveTo(0,0),e.lineTo(-l,y/2),e.lineTo(-l,-y/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),a?(f=(n[0]+n[2])/2-t[0],d=(n[1]+n[3])/2-t[1]):(f=t[2]-t[0],d=t[3]-t[1]),e.rotate((Math.atan2(-d,-f)+r)%r),e.moveTo(0,0),e.lineTo(-l,y/2),e.lineTo(-l,-y/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var r=this.dashEnabled();r&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),r&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),r=this.pointerWidth()/2;return{x:e.x-r,y:e.y-r,width:e.width+r*2,height:e.height+r*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 r=this.radiusX(),t=this.radiusY();e.beginPath(),e.save(),r!==t&&e.scale(1,t/r),e.arc(0,0,r,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 wv 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 r=this.getWidth(),t=this.getHeight(),n=this.cornerRadius(),a=this.attrs.image;let l;if(a){const u=this.attrs.cropWidth,f=this.attrs.cropHeight;u&&f?l=[a,this.cropX(),this.cropY(),u,f,0,0,r,t]:l=[a,0,0,r,t]}(this.hasFill()||this.hasStroke()||n)&&(e.beginPath(),n?Util_1$7.Util.drawRoundedRectPath(e,r,t,n):e.rect(0,0,r,t),e.closePath(),e.fillStrokeShape(this)),a&&(n&&e.clip(),e.drawImage.apply(e,l))}_hitFunc(e){var r=this.width(),t=this.height(),n=this.cornerRadius();e.beginPath(),n?Util_1$7.Util.drawRoundedRectPath(e,r,t,n):e.rect(0,0,r,t),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,r;return(e=this.attrs.width)!==null&&e!==void 0?e:(r=this.image())===null||r===void 0?void 0:r.width}getHeight(){var e,r;return(e=this.attrs.height)!==null&&e!==void 0?e:(r=this.image())===null||r===void 0?void 0:r.height}static fromURL(e,r,t=null){var n=Util_1$7.Util.createImageElement();n.onload=function(){var a=new wv({image:n});r(a)},n.onerror=t,n.crossOrigin="Anonymous",n.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(r){this._addListeners(r.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var r=this,t,n=function(){r._sync()};for(t=0;t<attrChangeListLen$1;t++)e.on(ATTR_CHANGE_LIST$2[t]+CHANGE_KONVA$1,n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),r=this.getTag(),t,n,a,l,u,f,d;if(e&&r){switch(t=e.width(),n=e.height(),a=r.pointerDirection(),l=r.pointerWidth(),d=r.pointerHeight(),u=0,f=0,a){case UP:u=t/2,f=-1*d;break;case RIGHT$1:u=t+l,f=n/2;break;case DOWN:u=t/2,f=n+d;break;case LEFT$1:u=-1*l,f=n/2;break}r.setAttrs({x:-1*u,y:-1*f,width:t,height:n}),e.setAttrs({x:-1*u,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 r=this.width(),t=this.height(),n=this.pointerDirection(),a=this.pointerWidth(),l=this.pointerHeight(),u=this.cornerRadius();let f=0,d=0,h=0,y=0;typeof u=="number"?f=d=h=y=Math.min(u,r/2,t/2):(f=Math.min(u[0]||0,r/2,t/2),d=Math.min(u[1]||0,r/2,t/2),y=Math.min(u[2]||0,r/2,t/2),h=Math.min(u[3]||0,r/2,t/2)),e.beginPath(),e.moveTo(f,0),n===UP&&(e.lineTo((r-a)/2,0),e.lineTo(r/2,-1*l),e.lineTo((r+a)/2,0)),e.lineTo(r-d,0),e.arc(r-d,d,d,Math.PI*3/2,0,!1),n===RIGHT$1&&(e.lineTo(r,(t-l)/2),e.lineTo(r+a,t/2),e.lineTo(r,(t+l)/2)),e.lineTo(r,t-y),e.arc(r-y,t-y,y,0,Math.PI/2,!1),n===DOWN&&(e.lineTo((r+a)/2,t),e.lineTo(r/2,t+l),e.lineTo((r-a)/2,t)),e.lineTo(h,t),e.arc(h,t-h,h,Math.PI/2,Math.PI,!1),n===LEFT$1&&(e.lineTo(0,(t+l)/2),e.lineTo(-1*a,t/2),e.lineTo(0,(t-l)/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,r=0,t=this.pointerWidth(),n=this.pointerHeight(),a=this.pointerDirection(),l=this.width(),u=this.height();return a===UP?(r-=n,u+=n):a===DOWN?u+=n:a===LEFT$1?(e-=t*1.5,l+=t):a===RIGHT$1&&(l+=t*1.5),{x:e,y:r,width:l,height:u}}}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 r=this.cornerRadius(),t=this.width(),n=this.height();e.beginPath(),r?Util_1$6.Util.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),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 r=this._getPoints();e.beginPath(),e.moveTo(r[0].x,r[0].y);for(var t=1;t<r.length;t++)e.lineTo(r[t].x,r[t].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,r=this.attrs.radius||0,t=[];for(var n=0;n<e;n++)t.push({x:r*Math.sin(n*2*Math.PI/e),y:-1*r*Math.cos(n*2*Math.PI/e)});return t}getSelfRect(){const e=this._getPoints();var r=e[0].x,t=e[0].y,n=e[0].x,a=e[0].y;return e.forEach(l=>{r=Math.min(r,l.x),t=Math.max(t,l.x),n=Math.min(n,l.y),a=Math.max(a,l.y)}),{x:r,y:n,width:t-r,height:a-n}}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 r=this._updated;return this._updated=!1,r}),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 r=this.animation(),t=this.frameIndex(),n=t*4,a=this.animations()[r],l=this.frameOffsets(),u=a[n+0],f=a[n+1],d=a[n+2],h=a[n+3],y=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,d,h),e.closePath(),e.fillStrokeShape(this)),y)if(l){var E=l[r],p=t*2;e.drawImage(y,u,f,d,h,E[p+0],E[p+1],d,h)}else e.drawImage(y,u,f,d,h,0,0,d,h)}_hitFunc(e){var r=this.animation(),t=this.frameIndex(),n=t*4,a=this.animations()[r],l=this.frameOffsets(),u=a[n+2],f=a[n+3];if(e.beginPath(),l){var d=l[r],h=t*2;e.rect(d[h+0],d[h+1],u,f)}else e.rect(0,0,u,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(),r=this.animation(),t=this.animations(),n=t[r],a=n.length/4;e<a-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 r=this.innerRadius(),t=this.outerRadius(),n=this.numPoints();e.beginPath(),e.moveTo(0,0-t);for(var a=1;a<n*2;a++){var l=a%2===0?t:r,u=l*Math.sin(a*Math.PI/n),f=-1*l*Math.cos(a*Math.PI/n);e.lineTo(u,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(o){return Array.from(o)}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(o){return o.split(",").map(e=>{e=e.trim();const r=e.indexOf(" ")>=0,t=e.indexOf('"')>=0||e.indexOf("'")>=0;return r&&!t&&(e=`"${e}"`),e}).join(", ")}var dummyContext;function getDummyContext(){return dummyContext||(dummyContext=Util_1$5.Util.createCanvasElement().getContext(CONTEXT_2D),dummyContext)}function _fillFunc$1(o){o.fillText(this._partialText,this._partialTextX,this._partialTextY)}function _strokeFunc$1(o){o.setAttr("miterLimit",2),o.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function checkDefaultFill(o){return o=o||{},!o.fillLinearGradientColorStops&&!o.fillRadialGradientColorStops&&!o.fillPatternImage&&(o.fill=o.fill||"black"),o}let Text$1=class extends Shape_1$3.Shape{constructor(e){super(checkDefaultFill(e)),this._partialTextX=0,this._partialTextY=0;for(var r=0;r<attrChangeListLen;r++)this.on(ATTR_CHANGE_LIST$1[r]+CHANGE_KONVA,this._setTextData);this._setTextData()}_sceneFunc(e){var r=this.textArr,t=r.length;if(this.text()){var n=this.padding(),a=this.fontSize(),l=this.lineHeight()*a,u=this.verticalAlign(),f=this.direction(),d=0,h=this.align(),y=this.getWidth(),E=this.letterSpacing(),p=this.fill(),_=this.textDecoration(),g=_.indexOf("underline")!==-1,x=_.indexOf("line-through")!==-1,C;f=f===INHERIT?e.direction:f;var R=0,R=l/2,S=0,A=0;for(f===RTL&&e.setAttr("direction",f),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",MIDDLE),e.setAttr("textAlign",LEFT),u===MIDDLE?d=(this.getHeight()-t*l-n*2)/2:u===BOTTOM&&(d=this.getHeight()-t*l-n*2),e.translate(n,d+n),C=0;C<t;C++){var S=0,A=0,T=r[C],w=T.text,P=T.width,O=T.lastInParagraph,k,D,F;if(e.save(),h===RIGHT?S+=y-P-n*2:h===CENTER&&(S+=(y-P-n*2)/2),g){e.save(),e.beginPath(),e.moveTo(S,R+A+Math.round(a/2)),k=w.split(" ").length-1,D=k===0,F=h===JUSTIFY&&!O?y-n*2:P,e.lineTo(S+Math.round(F),R+A+Math.round(a/2)),e.lineWidth=a/15;const z=this._getLinearGradient();e.strokeStyle=z||p,e.stroke(),e.restore()}if(x){e.save(),e.beginPath(),e.moveTo(S,R+A),k=w.split(" ").length-1,D=k===0,F=h===JUSTIFY&&O&&!D?y-n*2:P,e.lineTo(S+Math.round(F),R+A),e.lineWidth=a/15;const z=this._getLinearGradient();e.strokeStyle=z||p,e.stroke(),e.restore()}if(f!==RTL&&(E!==0||h===JUSTIFY)){k=w.split(" ").length-1;for(var G=stringToArray(w),V=0;V<G.length;V++){var W=G[V];W===" "&&!O&&h===JUSTIFY&&(S+=(y-n*2-P)/k),this._partialTextX=S,this._partialTextY=R+A,this._partialText=W,e.fillStrokeShape(this),S+=this.measureSize(W).width+E}}else E!==0&&e.setAttr("letterSpacing",`${E}px`),this._partialTextX=S,this._partialTextY=R+A,this._partialText=w,e.fillStrokeShape(this);e.restore(),t>1&&(R+=l)}}}_hitFunc(e){var r=this.getWidth(),t=this.getHeight();e.beginPath(),e.rect(0,0,r,t),e.closePath(),e.fillStrokeShape(this)}setText(e){var r=Util_1$5.Util._isString(e)?e:e==null?"":e+"";return this._setAttr(TEXT,r),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 r=getDummyContext(),t=this.fontSize(),n;return r.save(),r.font=this._getContextFont(),n=r.measureText(e),r.restore(),{width:n.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 r=this.letterSpacing(),t=e.length;return getDummyContext().measureText(e).width+(t?r*(t-1):0)}_setTextData(){var e=this.text().split(`
72
72
  `),r=+this.fontSize(),t=0,n=this.lineHeight()*r,a=this.attrs.width,l=this.attrs.height,u=a!==AUTO&&a!==void 0,f=l!==AUTO&&l!==void 0,d=this.padding(),h=a-d*2,y=l-d*2,E=0,p=this.wrap(),_=p!==NONE,g=p!==CHAR&&_,x=this.ellipsis();this.textArr=[],getDummyContext().font=this._getContextFont();for(var C=x?this._getTextWidth(ELLIPSIS):0,R=0,S=e.length;R<S;++R){var A=e[R],T=this._getTextWidth(A);if(u&&T>h)for(;A.length>0;){for(var w=0,P=A.length,O="",k=0;w<P;){var D=w+P>>>1,F=A.slice(0,D+1),G=this._getTextWidth(F)+C;G<=h?(w=D+1,O=F,k=G):P=D}if(O){if(g){var V,W=A[O.length],ee=W===SPACE||W===DASH;ee&&k<=h?V=O.length:V=Math.max(O.lastIndexOf(SPACE),O.lastIndexOf(DASH))+1,V>0&&(w=V,O=O.slice(0,w),k=this._getTextWidth(O))}O=O.trimRight(),this._addTextLine(O),t=Math.max(t,k),E+=n;var q=this._shouldHandleEllipsis(E);if(q){this._tryToAddEllipsisToLastLine();break}if(A=A.slice(w),A=A.trimLeft(),A.length>0&&(T=this._getTextWidth(A),T<=h)){this._addTextLine(A),E+=n,t=Math.max(t,T);break}}else break}else this._addTextLine(A),E+=n,t=Math.max(t,T),this._shouldHandleEllipsis(E)&&R<S-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),f&&E+n>y)break}this.textHeight=r,this.textWidth=t}_shouldHandleEllipsis(e){var r=+this.fontSize(),t=this.lineHeight()*r,n=this.attrs.height,a=n!==AUTO&&n!==void 0,l=this.padding(),u=n-l*2,f=this.wrap(),d=f!==NONE;return!d||a&&e+t>u}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,r=e!==AUTO&&e!==void 0,t=this.padding(),n=e-t*2,a=this.ellipsis(),l=this.textArr[this.textArr.length-1];if(!(!l||!a)){if(r){var u=this._getTextWidth(l.text+ELLIPSIS)<n;u||(l.text=l.text.slice(0,l.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(l.text+ELLIPSIS)}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,r=this.hasShadow();return e&&r?!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(o){o.fillText(this.partialText,0,0)}function _strokeFunc(o){o.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 r=this.pathLength;return e-1>r?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 r=this.textDecoration(),t=this.fill(),n=this.fontSize(),a=this.glyphInfo;r==="underline"&&e.beginPath();for(var l=0;l<a.length;l++){e.save();var u=a[l].p0;e.translate(u.x,u.y),e.rotate(a[l].rotation),this.partialText=a[l].text,e.fillStrokeShape(this),r==="underline"&&(l===0&&e.moveTo(0,n/2+1),e.lineTo(n,n/2+1)),e.restore()}r==="underline"&&(e.strokeStyle=t,e.lineWidth=n/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var r=this.glyphInfo;if(r.length>=1){var t=r[0].p0;e.moveTo(t.x,t.y)}for(var n=0;n<r.length;n++){var a=r[n].p1;e.lineTo(a.x,a.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 r=this.dummyCanvas,t=r.getContext("2d");t.save(),t.font=this._getContextFont();var n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:e,height:r}=this._getTextSize(this.attrs.text);if(this.textWidth=e,this.textHeight=r,this.glyphInfo=[],!this.attrs.data)return null;const t=this.letterSpacing(),n=this.align(),a=this.kerningFunc(),l=Math.max(this.textWidth+((this.attrs.text||"").length-1)*t,0);let u=0;n==="center"&&(u=Math.max(0,this.pathLength/2-l/2)),n==="right"&&(u=Math.max(0,this.pathLength-l));const f=(0,Text_1$1.stringToArray)(this.text());let d=u;for(var h=0;h<f.length;h++){const y=this._getPointAtLength(d);if(!y)return;let E=this._getTextSize(f[h]).width+t;if(f[h]===" "&&n==="justify"){const R=this.text().split(" ").length-1;E+=(this.pathLength-l)/R}const p=this._getPointAtLength(d+E);if(!p)return;const _=Path_1$1.Path.getLineLength(y.x,y.y,p.x,p.y);let g=0;if(a)try{g=a(f[h-1],f[h])*this.fontSize()}catch{g=0}y.x+=g,p.x+=g,this.textWidth+=g;const x=Path_1$1.Path.getPointOnLine(g+_/2,y.x,y.y,p.x,p.y),C=Math.atan2(p.y-y.y,p.x-y.x);this.glyphInfo.push({transposeX:x.x,transposeY:x.y,text:f[h],rotation:C,p0:y,p1:p}),d+=E}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach(function(h){e.push(h.p0.x),e.push(h.p0.y),e.push(h.p1.x),e.push(h.p1.y)});for(var r=e[0]||0,t=e[0]||0,n=e[1]||0,a=e[1]||0,l,u,f=0;f<e.length/2;f++)l=e[f*2],u=e[f*2+1],r=Math.min(r,l),t=Math.max(t,l),n=Math.min(n,u),a=Math.max(a,u);var d=this.fontSize();return{x:r-d/2,y:n-d/2,width:t-r+d,height:a-n+d}}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(o=>o+`.${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(o,e,r){if(o==="rotater")return r;e+=Util_1$3.Util.degToRad(ANGLES[o]||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(o){return{x:o.x+o.width/2*Math.cos(o.rotation)+o.height/2*Math.sin(-o.rotation),y:o.y+o.height/2*Math.cos(o.rotation)+o.width/2*Math.sin(o.rotation)}}function rotateAroundPoint(o,e,r){const t=r.x+(o.x-r.x)*Math.cos(e)-(o.y-r.y)*Math.sin(e),n=r.y+(o.x-r.x)*Math.sin(e)+(o.y-r.y)*Math.cos(e);return{...o,rotation:o.rotation+e,x:t,y:n}}function rotateAroundCenter(o,e){const r=getCenter(o);return rotateAroundPoint(o,e,r)}function getSnap(o,e,r){let t=e;for(let n=0;n<o.length;n++){const a=Global_1$1.Konva.getAngle(o[n]),l=Math.abs(a-e)%(Math.PI*2);Math.min(l,Math.PI*2-l)<r&&(t=a)}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 r=e.filter(n=>n.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=r,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(n=>{const a=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()},l=n._attrsAffectingSize.map(u=>u+"Change."+this._getEventNamespace()).join(" ");n.on(l,a),n.on(TRANSFORM_CHANGE_STR.map(u=>u+`.${this._getEventNamespace()}`).join(" "),a),n.on(`absoluteTransformChange.${this._getEventNamespace()}`,a),this._proxyDrag(n)}),this._resetTransformCache();var t=!!this.findOne(".top-left");return t&&this.update(),this}_proxyDrag(e){let r;e.on(`dragstart.${this._getEventNamespace()}`,t=>{r=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(t,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,t=>{if(!r)return;const n=e.getAbsolutePosition(),a=n.x-r.x,l=n.y-r.y;this.nodes().forEach(u=>{if(u===e||u.isDragging())return;const f=u.getAbsolutePosition();u.setAbsolutePosition({x:f.x+a,y:f.y+l}),u.startDrag(t)}),r=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,r=this.rotation(),t){var n=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),a=e.getAbsoluteScale(t),l=e.getAbsolutePosition(t),u=n.x*a.x-e.offsetX()*a.x,f=n.y*a.y-e.offsetY()*a.y;const d=(Global_1$1.Konva.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),h={x:l.x+u*Math.cos(d)+f*Math.sin(-d),y:l.y+f*Math.cos(d)+u*Math.sin(d),width:n.width*a.x,height:n.height*a.y,rotation:d};return rotateAroundPoint(h,-Global_1$1.Konva.getAngle(r),{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 r=[];this.nodes().map(d=>{const h=d.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var y=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}],E=d.getAbsoluteTransform();y.forEach(function(p){var _=E.point(p);r.push(_)})});const t=new Util_1$3.Transform;t.rotate(-Global_1$1.Konva.getAngle(this.rotation()));var n=1/0,a=1/0,l=-1/0,u=-1/0;r.forEach(function(d){var h=t.point(d);n===void 0&&(n=l=h.x,a=u=h.y),n=Math.min(n,h.x),a=Math.min(a,h.y),l=Math.max(l,h.x),u=Math.max(u,h.y)}),t.invert();const f=t.point({x:n,y:a});return{x:f.x,y:f.y,width:l-n,height:u-a,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 r=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;r.on("mousedown touchstart",function(n){t._handleMouseDown(n)}),r.on("dragstart",n=>{r.stopDrag(),n.cancelBubble=!0}),r.on("dragend",n=>{n.cancelBubble=!0}),r.on("mouseenter",()=>{var n=Global_1$1.Konva.getAngle(this.rotation()),a=this.rotateAnchorCursor(),l=getCursor(e,n,a);r.getStage().content&&(r.getStage().content.style.cursor=l),this._cursorChange=!0}),r.on("mouseout",()=>{r.getStage().content&&(r.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(r)}_createBack(){var e=new Shape_1$1.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(r,t){var n=t.getParent(),a=n.padding();r.beginPath(),r.rect(-a,-a,t.width()+a*2,t.height()+a*2),r.moveTo(t.width()/2,-a),n.rotateEnabled()&&n.rotateLineVisible()&&r.lineTo(t.width()/2,-n.rotateAnchorOffset()*Util_1$3.Util._sign(t.height())-a),r.fillStrokeShape(t)},hitFunc:(r,t)=>{if(this.shouldOverdrawWholeArea()){var n=this.padding();r.beginPath(),r.rect(-n,-n,t.width()+n*2,t.height()+n*2),r.fillStrokeShape(t)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",r=>{r.cancelBubble=!0}),e.on("dragmove",r=>{r.cancelBubble=!0}),e.on("dragend",r=>{r.cancelBubble=!0}),this.on("dragmove",r=>{this.update()})}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var r=this._getNodeRect(),t=r.width,n=r.height,a=Math.sqrt(Math.pow(t,2)+Math.pow(n,2));this.sin=Math.abs(n/a),this.cos=Math.abs(t/a),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 l=e.target.getAbsolutePosition(),u=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:u.x-l.x,y:u.y-l.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 r,t,n,a=this.findOne("."+this._movingAnchorName),l=a.getStage();l.setPointersPositions(e);const u=l.getPointerPosition();let f={x:u.x-this._anchorDragOffset.x,y:u.y-this._anchorDragOffset.y};const d=a.getAbsolutePosition();this.anchorDragBoundFunc()&&(f=this.anchorDragBoundFunc()(d,f,e)),a.setAbsolutePosition(f);const h=a.getAbsolutePosition();if(!(d.x===h.x&&d.y===h.y)){if(this._movingAnchorName==="rotater"){var y=this._getNodeRect();r=a.x()-y.width/2,t=-a.y()+y.height/2;let V=Math.atan2(-t,r)+Math.PI/2;y.height<0&&(V-=Math.PI);var E=Global_1$1.Konva.getAngle(this.rotation());const W=E+V,ee=Global_1$1.Konva.getAngle(this.rotationSnapTolerance()),z=getSnap(this.rotationSnaps(),W,ee)-y.rotation,U=rotateAroundCenter(y,z);this._fitNodesInto(U,e);return}var p=this.shiftBehavior(),_;p==="inverted"?_=this.keepRatio()&&!e.shiftKey:p==="none"?_=this.keepRatio():_=this.keepRatio()||e.shiftKey;var S=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(_){var g=S?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(g.x-a.x(),2)+Math.pow(g.y-a.y(),2));var x=this.findOne(".top-left").x()>g.x?-1:1,C=this.findOne(".top-left").y()>g.y?-1:1;r=n*this.cos*x,t=n*this.sin*C,this.findOne(".top-left").x(g.x-r),this.findOne(".top-left").y(g.y-t)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(a.y());else if(this._movingAnchorName==="top-right"){if(_){var g=S?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(a.x()-g.x,2)+Math.pow(g.y-a.y(),2));var x=this.findOne(".top-right").x()<g.x?-1:1,C=this.findOne(".top-right").y()>g.y?-1:1;r=n*this.cos*x,t=n*this.sin*C,this.findOne(".top-right").x(g.x+r),this.findOne(".top-right").y(g.y-t)}var R=a.position();this.findOne(".top-left").y(R.y),this.findOne(".bottom-right").x(R.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(a.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(a.x());else if(this._movingAnchorName==="bottom-left"){if(_){var g=S?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(g.x-a.x(),2)+Math.pow(a.y()-g.y,2));var x=g.x<a.x()?-1:1,C=a.y()<g.y?-1:1;r=n*this.cos*x,t=n*this.sin*C,a.x(g.x-r),a.y(g.y+t)}R=a.position(),this.findOne(".top-left").x(R.x),this.findOne(".bottom-right").y(R.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(a.y());else if(this._movingAnchorName==="bottom-right"){if(_){var g=S?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(a.x()-g.x,2)+Math.pow(a.y()-g.y,2));var x=this.findOne(".bottom-right").x()<g.x?-1:1,C=this.findOne(".bottom-right").y()<g.y?-1:1;r=n*this.cos*x,t=n*this.sin*C,this.findOne(".bottom-right").x(g.x+r),this.findOne(".bottom-right").y(g.y+t)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));var S=this.centeredScaling()||e.altKey;if(S){var A=this.findOne(".top-left"),T=this.findOne(".bottom-right"),w=A.x(),P=A.y(),O=this.getWidth()-T.x(),k=this.getHeight()-T.y();T.move({x:-w,y:-P}),A.move({x:O,y:k})}var D=this.findOne(".top-left").getAbsolutePosition();r=D.x,t=D.y;var F=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),G=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:r,y:t,width:F,height:G,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 r=this.getNode();this._fire("transformend",{evt:e,target:r}),r&&this._nodes.forEach(t=>{t._fire("transformend",{evt:e,target:t})}),this._movingAnchorName=null}}_fitNodesInto(e,r){var t=this._getNodeRect();const n=1;if(Util_1$3.Util._inRange(e.width,-this.padding()*2-n,n)){this.update();return}if(Util_1$3.Util._inRange(e.height,-this.padding()*2-n,n)){this.update();return}var a=new Util_1$3.Transform;if(a.rotate(Global_1$1.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const E=a.point({x:-this.padding()*2,y:0});e.x+=E.x,e.y+=E.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=E.x,this._anchorDragOffset.y-=E.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const E=a.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=E.x,this._anchorDragOffset.y-=E.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const E=a.point({x:0,y:-this.padding()*2});e.x+=E.x,e.y+=E.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=E.x,this._anchorDragOffset.y-=E.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const E=a.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=E.x,this._anchorDragOffset.y-=E.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const E=this.boundBoxFunc()(t,e);E?e=E:Util_1$3.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const l=1e7,u=new Util_1$3.Transform;u.translate(t.x,t.y),u.rotate(t.rotation),u.scale(t.width/l,t.height/l);const f=new Util_1$3.Transform,d=e.width/l,h=e.height/l;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(d),Math.abs(h))):(f.translate(e.x,e.y),f.rotate(e.rotation),f.scale(d,h));const y=f.multiply(u.invert());this._nodes.forEach(E=>{var p;const _=E.getParent().getAbsoluteTransform(),g=E.getTransform().copy();g.translate(E.offsetX(),E.offsetY());const x=new Util_1$3.Transform;x.multiply(_.copy().invert()).multiply(y).multiply(_).multiply(g);const C=x.decompose();E.setAttrs(C),this._fire("transform",{evt:r,target:E}),E._fire("transform",{evt:r,target:E}),(p=E.getLayer())===null||p===void 0||p.batchDraw()}),this.rotation(Util_1$3.Util._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,r){this.findOne(e).setAttrs(r)}update(){var e,r=this._getNodeRect();this.rotation(Util_1$3.Util._getRotation(r.rotation));var t=r.width,n=r.height,a=this.enabledAnchors(),l=this.resizeEnabled(),u=this.padding(),f=this.anchorSize();const d=this.find("._anchor");d.forEach(y=>{y.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+u,offsetY:f/2+u,visible:l&&a.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:t/2,y:0,offsetY:f/2+u,visible:l&&a.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:t,y:0,offsetX:f/2-u,offsetY:f/2+u,visible:l&&a.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:f/2+u,visible:l&&a.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:t,y:n/2,offsetX:f/2-u,visible:l&&a.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:f/2+u,offsetY:f/2-u,visible:l&&a.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:t/2,y:n,offsetY:f/2-u,visible:l&&a.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:t,y:n,offsetX:f/2-u,offsetY:f/2-u,visible:l&&a.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:t/2,y:-this.rotateAnchorOffset()*Util_1$3.Util._sign(n)-u,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:t,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const h=this.anchorStyleFunc();h&&d.forEach(y=>{h(y)}),(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 r=Node_1$f.Node.prototype.clone.call(this,e);return r}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Transformer$1.Transformer=Transformer;function validateAnchors(o){return o instanceof Array||Util_1$3.Util.warn("enabledAnchors value should be an array"),o instanceof Array&&o.forEach(function(e){ANCHORS_NAMES.indexOf(e)===-1&&Util_1$3.Util.warn("Unknown anchor name: "+e+". Available names are: "+ANCHORS_NAMES.join(", "))}),o||[]}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(o,e){var r=o.data,t=o.width,n=o.height,a,l,u,f,d,h,y,E,p,_,g,x,C,R,S,A,T,w,P,O,k,D,F,G,V=e+e+1,W=t-1,ee=n-1,q=e+1,z=q*(q+1)/2,U=new BlurStack,$=null,I=U,B=null,X=null,Q=mul_table[e],J=shg_table[e];for(u=1;u<V;u++)I=I.next=new BlurStack,u===q&&($=I);for(I.next=U,y=h=0,l=0;l<n;l++){for(A=T=w=P=E=p=_=g=0,x=q*(O=r[h]),C=q*(k=r[h+1]),R=q*(D=r[h+2]),S=q*(F=r[h+3]),E+=z*O,p+=z*k,_+=z*D,g+=z*F,I=U,u=0;u<q;u++)I.r=O,I.g=k,I.b=D,I.a=F,I=I.next;for(u=1;u<q;u++)f=h+((W<u?W:u)<<2),E+=(I.r=O=r[f])*(G=q-u),p+=(I.g=k=r[f+1])*G,_+=(I.b=D=r[f+2])*G,g+=(I.a=F=r[f+3])*G,A+=O,T+=k,w+=D,P+=F,I=I.next;for(B=U,X=$,a=0;a<t;a++)r[h+3]=F=g*Q>>J,F!==0?(F=255/F,r[h]=(E*Q>>J)*F,r[h+1]=(p*Q>>J)*F,r[h+2]=(_*Q>>J)*F):r[h]=r[h+1]=r[h+2]=0,E-=x,p-=C,_-=R,g-=S,x-=B.r,C-=B.g,R-=B.b,S-=B.a,f=y+((f=a+e+1)<W?f:W)<<2,A+=B.r=r[f],T+=B.g=r[f+1],w+=B.b=r[f+2],P+=B.a=r[f+3],E+=A,p+=T,_+=w,g+=P,B=B.next,x+=O=X.r,C+=k=X.g,R+=D=X.b,S+=F=X.a,A-=O,T-=k,w-=D,P-=F,X=X.next,h+=4;y+=t}for(a=0;a<t;a++){for(T=w=P=A=p=_=g=E=0,h=a<<2,x=q*(O=r[h]),C=q*(k=r[h+1]),R=q*(D=r[h+2]),S=q*(F=r[h+3]),E+=z*O,p+=z*k,_+=z*D,g+=z*F,I=U,u=0;u<q;u++)I.r=O,I.g=k,I.b=D,I.a=F,I=I.next;for(d=t,u=1;u<=e;u++)h=d+a<<2,E+=(I.r=O=r[h])*(G=q-u),p+=(I.g=k=r[h+1])*G,_+=(I.b=D=r[h+2])*G,g+=(I.a=F=r[h+3])*G,A+=O,T+=k,w+=D,P+=F,I=I.next,u<ee&&(d+=t);for(h=a,B=U,X=$,l=0;l<n;l++)f=h<<2,r[f+3]=F=g*Q>>J,F>0?(F=255/F,r[f]=(E*Q>>J)*F,r[f+1]=(p*Q>>J)*F,r[f+2]=(_*Q>>J)*F):r[f]=r[f+1]=r[f+2]=0,E-=x,p-=C,_-=R,g-=S,x-=B.r,C-=B.g,R-=B.b,S-=B.a,f=a+((f=l+q)<ee?f:ee)*t<<2,E+=A+=B.r=r[f],p+=T+=B.g=r[f+1],_+=w+=B.b=r[f+2],g+=P+=B.a=r[f+3],B=B.next,x+=O=X.r,C+=k=X.g,R+=D=X.b,S+=F=X.a,A-=O,T-=k,w-=D,P-=F,X=X.next,h+=t}}const Blur=function o(e){var r=Math.round(this.blurRadius());r>0&&filterGaussBlurRGBA(e,r)};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(o){var e=this.brightness()*255,r=o.data,t=r.length,n;for(n=0;n<t;n+=4)r[n]+=e,r[n+1]+=e,r[n+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(o){var e=Math.pow((this.contrast()+100)/100,2),r=o.data,t=r.length,n=150,a=150,l=150,u;for(u=0;u<t;u+=4)n=r[u],a=r[u+1],l=r[u+2],n/=255,n-=.5,n*=e,n+=.5,n*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,l/=255,l-=.5,l*=e,l+=.5,l*=255,n=n<0?0:n>255?255:n,a=a<0?0:a>255?255:a,l=l<0?0:l>255?255:l,r[u]=n,r[u+1]=a,r[u+2]=l};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(o){var e=this.embossStrength()*10,r=this.embossWhiteLevel()*255,t=this.embossDirection(),n=this.embossBlend(),a=0,l=0,u=o.data,f=o.width,d=o.height,h=f*4,y=d;switch(t){case"top-left":a=-1,l=-1;break;case"top":a=-1,l=0;break;case"top-right":a=-1,l=1;break;case"right":a=0,l=1;break;case"bottom-right":a=1,l=1;break;case"bottom":a=1,l=0;break;case"bottom-left":a=1,l=-1;break;case"left":a=0,l=-1;break;default:Util_1$2.Util.error("Unknown emboss direction: "+t)}do{var E=(y-1)*h,p=a;y+p<1&&(p=0),y+p>d&&(p=0);var _=(y-1+p)*f*4,g=f;do{var x=E+(g-1)*4,C=l;g+C<1&&(C=0),g+C>f&&(C=0);var R=_+(g-1+C)*4,S=u[x]-u[R],A=u[x+1]-u[R+1],T=u[x+2]-u[R+2],w=S,P=w>0?w:-w,O=A>0?A:-A,k=T>0?T:-T;if(O>P&&(w=A),k>P&&(w=T),w*=e,n){var D=u[x]+w,F=u[x+1]+w,G=u[x+2]+w;u[x]=D>255?255:D<0?0:D,u[x+1]=F>255?255:F<0?0:F,u[x+2]=G>255?255:G<0?0:G}else{var V=r-w;V<0?V=0:V>255&&(V=255),u[x]=u[x+1]=u[x+2]=V}}while(--g)}while(--y)};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(o,e,r,t,n){var a=r-e,l=n-t,u;return a===0?t+l/2:l===0?t:(u=(o-e)/a,u=l*u+t,u)}const Enhance=function(o){var e=o.data,r=e.length,t=e[0],n=t,a,l=e[1],u=l,f,d=e[2],h=d,y,E,p=this.enhance();if(p!==0){for(E=0;E<r;E+=4)a=e[E+0],a<t?t=a:a>n&&(n=a),f=e[E+1],f<l?l=f:f>u&&(u=f),y=e[E+2],y<d?d=y:y>h&&(h=y);n===t&&(n=255,t=0),u===l&&(u=255,l=0),h===d&&(h=255,d=0);var _,g,x,C,R,S,A,T,w;for(p>0?(g=n+p*(255-n),x=t-p*(t-0),R=u+p*(255-u),S=l-p*(l-0),T=h+p*(255-h),w=d-p*(d-0)):(_=(n+t)*.5,g=n+p*(n-_),x=t+p*(t-_),C=(u+l)*.5,R=u+p*(u-C),S=l+p*(l-C),A=(h+d)*.5,T=h+p*(h-A),w=d+p*(d-A)),E=0;E<r;E+=4)e[E+0]=remap(e[E+0],t,n,x,g),e[E+1]=remap(e[E+1],l,u,S,R),e[E+2]=remap(e[E+2],d,h,w,T)}};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(o){var e=o.data,r=e.length,t,n;for(t=0;t<r;t+=4)n=.34*e[t]+.5*e[t+1]+.16*e[t+2],e[t]=n,e[t+1]=n,e[t+2]=n};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(o){var e=o.data,r=e.length,t=1,n=Math.pow(2,this.saturation()),a=Math.abs(this.hue()+360)%360,l=this.luminance()*127,u,f=t*n*Math.cos(a*Math.PI/180),d=t*n*Math.sin(a*Math.PI/180),h=.299*t+.701*f+.167*d,y=.587*t-.587*f+.33*d,E=.114*t-.114*f-.497*d,p=.299*t-.299*f-.328*d,_=.587*t+.413*f+.035*d,g=.114*t-.114*f+.293*d,x=.299*t-.3*f+1.25*d,C=.587*t-.586*f-1.05*d,R=.114*t+.886*f-.2*d,S,A,T,w;for(u=0;u<r;u+=4)S=e[u+0],A=e[u+1],T=e[u+2],w=e[u+3],e[u+0]=h*S+y*A+E*T+l,e[u+1]=p*S+_*A+g*T+l,e[u+2]=x*S+C*A+R*T+l,e[u+3]=w};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(o){var e=o.data,r=e.length,t=Math.pow(2,this.value()),n=Math.pow(2,this.saturation()),a=Math.abs(this.hue()+360)%360,l,u=t*n*Math.cos(a*Math.PI/180),f=t*n*Math.sin(a*Math.PI/180),d=.299*t+.701*u+.167*f,h=.587*t-.587*u+.33*f,y=.114*t-.114*u-.497*f,E=.299*t-.299*u-.328*f,p=.587*t+.413*u+.035*f,_=.114*t-.114*u+.293*f,g=.299*t-.3*u+1.25*f,x=.587*t-.586*u-1.05*f,C=.114*t+.886*u-.2*f,R,S,A,T;for(l=0;l<r;l+=4)R=e[l+0],S=e[l+1],A=e[l+2],T=e[l+3],e[l+0]=d*R+h*S+y*A,e[l+1]=E*R+p*S+_*A,e[l+2]=g*R+x*S+C*A,e[l+3]=T};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(o){var e=o.data,r=e.length,t;for(t=0;t<r;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(o,e,r){var t=o.data,n=e.data,a=o.width,l=o.height,u=r.polarCenterX||a/2,f=r.polarCenterY||l/2,d,h,y,E=0,p=0,_=0,g=0,x,C=Math.sqrt(u*u+f*f);h=a-u,y=l-f,x=Math.sqrt(h*h+y*y),C=x>C?x:C;var R=l,S=a,A,T,w=360/S*Math.PI/180,P,O;for(T=0;T<S;T+=1)for(P=Math.sin(T*w),O=Math.cos(T*w),A=0;A<R;A+=1)h=Math.floor(u+C*A/R*O),y=Math.floor(f+C*A/R*P),d=(y*a+h)*4,E=t[d+0],p=t[d+1],_=t[d+2],g=t[d+3],d=(T+A*a)*4,n[d+0]=E,n[d+1]=p,n[d+2]=_,n[d+3]=g},FromPolar=function(o,e,r){var t=o.data,n=e.data,a=o.width,l=o.height,u=r.polarCenterX||a/2,f=r.polarCenterY||l/2,d,h,y,E,p,_=0,g=0,x=0,C=0,R,S=Math.sqrt(u*u+f*f);h=a-u,y=l-f,R=Math.sqrt(h*h+y*y),S=R>S?R:S;var A=l,T=a,w,P,O=r.polarRotation||0,k,D;for(h=0;h<a;h+=1)for(y=0;y<l;y+=1)E=h-u,p=y-f,w=Math.sqrt(E*E+p*p)*A/S,P=(Math.atan2(p,E)*180/Math.PI+360+O)%360,P=P*T/360,k=Math.floor(P),D=Math.floor(w),d=(D*a+k)*4,_=t[d+0],g=t[d+1],x=t[d+2],C=t[d+3],d=(y*a+h)*4,n[d+0]=_,n[d+1]=g,n[d+2]=x,n[d+3]=C};const Kaleidoscope=function(o){var e=o.width,r=o.height,t,n,a,l,u,f,d,h,y,E,p=Math.round(this.kaleidoscopePower()),_=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(_%360)/360);if(!(p<1)){var x=Util_1$1.Util.createCanvasElement();x.width=e,x.height=r;var C=x.getContext("2d").getImageData(0,0,e,r);Util_1$1.Util.releaseCanvas(x),ToPolar(o,C,{polarCenterX:e/2,polarCenterY:r/2});for(var R=e/Math.pow(2,p);R<=8;)R=R*2,p-=1;R=Math.ceil(R);var S=R,A=0,T=S,w=1;for(g+R>e&&(A=S,T=0,w=-1),n=0;n<r;n+=1)for(t=A;t!==T;t+=w)a=Math.round(t+g)%e,y=(e*n+a)*4,u=C.data[y+0],f=C.data[y+1],d=C.data[y+2],h=C.data[y+3],E=(e*n+t)*4,C.data[E+0]=u,C.data[E+1]=f,C.data[E+2]=d,C.data[E+3]=h;for(n=0;n<r;n+=1)for(S=Math.floor(R),l=0;l<p;l+=1){for(t=0;t<S+1;t+=1)y=(e*n+t)*4,u=C.data[y+0],f=C.data[y+1],d=C.data[y+2],h=C.data[y+3],E=(e*n+S*2-t-1)*4,C.data[E+0]=u,C.data[E+1]=f,C.data[E+2]=d,C.data[E+3]=h;S*=2}FromPolar(C,o,{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(o,e,r){var t=(r*o.width+e)*4,n=[];return n.push(o.data[t++],o.data[t++],o.data[t++],o.data[t++]),n}function rgbDistance(o,e){return Math.sqrt(Math.pow(o[0]-e[0],2)+Math.pow(o[1]-e[1],2)+Math.pow(o[2]-e[2],2))}function rgbMean(o){for(var e=[0,0,0],r=0;r<o.length;r++)e[0]+=o[r][0],e[1]+=o[r][1],e[2]+=o[r][2];return e[0]/=o.length,e[1]/=o.length,e[2]/=o.length,e}function backgroundMask(o,e){var r=pixelAt(o,0,0),t=pixelAt(o,o.width-1,0),n=pixelAt(o,0,o.height-1),a=pixelAt(o,o.width-1,o.height-1),l=e||10;if(rgbDistance(r,t)<l&&rgbDistance(t,a)<l&&rgbDistance(a,n)<l&&rgbDistance(n,r)<l){for(var u=rgbMean([t,r,a,n]),f=[],d=0;d<o.width*o.height;d++){var h=rgbDistance(u,[o.data[d*4],o.data[d*4+1],o.data[d*4+2]]);f[d]=h<l?0:255}return f}}function applyMask(o,e){for(var r=0;r<o.width*o.height;r++)o.data[4*r+3]=e[r]}function erodeMask(o,e,r){for(var t=[1,1,1,1,0,1,1,1,1],n=Math.round(Math.sqrt(t.length)),a=Math.floor(n/2),l=[],u=0;u<r;u++)for(var f=0;f<e;f++){for(var d=u*e+f,h=0,y=0;y<n;y++)for(var E=0;E<n;E++){var p=u+y-a,_=f+E-a;if(p>=0&&p<r&&_>=0&&_<e){var g=p*e+_,x=t[y*n+E];h+=o[g]*x}}l[d]=h===255*8?255:0}return l}function dilateMask(o,e,r){for(var t=[1,1,1,1,1,1,1,1,1],n=Math.round(Math.sqrt(t.length)),a=Math.floor(n/2),l=[],u=0;u<r;u++)for(var f=0;f<e;f++){for(var d=u*e+f,h=0,y=0;y<n;y++)for(var E=0;E<n;E++){var p=u+y-a,_=f+E-a;if(p>=0&&p<r&&_>=0&&_<e){var g=p*e+_,x=t[y*n+E];h+=o[g]*x}}l[d]=h>=255*4?255:0}return l}function smoothEdgeMask(o,e,r){for(var t=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],n=Math.round(Math.sqrt(t.length)),a=Math.floor(n/2),l=[],u=0;u<r;u++)for(var f=0;f<e;f++){for(var d=u*e+f,h=0,y=0;y<n;y++)for(var E=0;E<n;E++){var p=u+y-a,_=f+E-a;if(p>=0&&p<r&&_>=0&&_<e){var g=p*e+_,x=t[y*n+E];h+=o[g]*x}}l[d]=h}return l}const Mask=function(o){var e=this.threshold(),r=backgroundMask(o,e);return r&&(r=erodeMask(r,o.width,o.height),r=dilateMask(r,o.width,o.height),r=smoothEdgeMask(r,o.width,o.height),applyMask(o,r)),o};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(o){var e=this.noise()*255,r=o.data,t=r.length,n=e/2,a;for(a=0;a<t;a+=4)r[a+0]+=n-2*n*Math.random(),r[a+1]+=n-2*n*Math.random(),r[a+2]+=n-2*n*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(o){var e=Math.ceil(this.pixelSize()),r=o.width,t=o.height,n,a,l,u,f,d,h,y=Math.ceil(r/e),E=Math.ceil(t/e),p,_,g,x,C,R,S,A=o.data;if(e<=0){Util_1.Util.error("pixelSize value can not be <= 0");return}for(C=0;C<y;C+=1)for(R=0;R<E;R+=1){for(u=0,f=0,d=0,h=0,p=C*e,_=p+e,g=R*e,x=g+e,S=0,n=p;n<_;n+=1)if(!(n>=r))for(a=g;a<x;a+=1)a>=t||(l=(r*a+n)*4,u+=A[l+0],f+=A[l+1],d+=A[l+2],h+=A[l+3],S+=1);for(u=u/S,f=f/S,d=d/S,h=h/S,n=p;n<_;n+=1)if(!(n>=r))for(a=g;a<x;a+=1)a>=t||(l=(r*a+n)*4,A[l+0]=u,A[l+1]=f,A[l+2]=d,A[l+3]=h)}};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(o){var e=Math.round(this.levels()*254)+1,r=o.data,t=r.length,n=255/e,a;for(a=0;a<t;a+=1)r[a]=Math.floor(r[a]/n)*n};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(o){var e=o.data,r=e.length,t=this.red(),n=this.green(),a=this.blue(),l,u;for(l=0;l<r;l+=4)u=(.34*e[l]+.5*e[l+1]+.16*e[l+2])/255,e[l]=u*t,e[l+1]=u*n,e[l+2]=u*a,e[l+3]=e[l+3]};RGB$1.RGB=RGB;Factory_1$2.Factory.addGetterSetter(Node_1$2.Node,"red",0,function(o){return this._filterUpToDate=!1,o>255?255:o<0?0:Math.round(o)});Factory_1$2.Factory.addGetterSetter(Node_1$2.Node,"green",0,function(o){return this._filterUpToDate=!1,o>255?255:o<0?0:Math.round(o)});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(o){var e=o.data,r=e.length,t=this.red(),n=this.green(),a=this.blue(),l=this.alpha(),u,f;for(u=0;u<r;u+=4)f=1-l,e[u]=t*l+e[u]*f,e[u+1]=n*l+e[u+1]*f,e[u+2]=a*l+e[u+2]*f};RGBA$1.RGBA=RGBA;Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"red",0,function(o){return this._filterUpToDate=!1,o>255?255:o<0?0:Math.round(o)});Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"green",0,function(o){return this._filterUpToDate=!1,o>255?255:o<0?0:Math.round(o)});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(o){return this._filterUpToDate=!1,o>1?1:o<0?0:o});var Sepia$1={};Object.defineProperty(Sepia$1,"__esModule",{value:!0});Sepia$1.Sepia=void 0;const Sepia=function(o){var e=o.data,r=e.length,t,n,a,l;for(t=0;t<r;t+=4)n=e[t+0],a=e[t+1],l=e[t+2],e[t+0]=Math.min(255,n*.393+a*.769+l*.189),e[t+1]=Math.min(255,n*.349+a*.686+l*.168),e[t+2]=Math.min(255,n*.272+a*.534+l*.131)};Sepia$1.Sepia=Sepia;var Solarize$1={};Object.defineProperty(Solarize$1,"__esModule",{value:!0});Solarize$1.Solarize=void 0;const Solarize=function(o){var e=o.data,r=o.width,t=o.height,n=r*4,a=t;do{var l=(a-1)*n,u=r;do{var f=l+(u-1)*4,d=e[f],h=e[f+1],y=e[f+2];d>127&&(d=255-d),h>127&&(h=255-h),y>127&&(y=255-y),e[f]=d,e[f+1]=h,e[f+2]=y}while(--u)}while(--a)};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(o){var e=this.threshold()*255,r=o.data,t=r.length,n;for(n=0;n<t;n+=1)r[n]=r[n]<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(o,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;var r=_CoreInternals;Object.defineProperty(e,"Konva",{enumerable:!0,get:function(){return r.Konva}});const t=_CoreInternals;o.exports=t.Konva})(Core,Core.exports);var CoreExports=Core.exports;const Konva=getDefaultExportFromCjs(CoreExports);var reactReconciler={exports:{}},scheduler={exports:{}},scheduler_production_min={};/**