You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
330 lines
675 KiB
330 lines
675 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[262,5,7],{"55Ip":function(vt,tt,ae){"use strict";ae.d(tt,"a",function(){return i}),ae.d(tt,"b",function(){return c});var he=ae("Ty5D"),N=ae("dI71"),S=ae("q1tI"),U=ae.n(S),L=ae("YS25"),_=ae("17x9"),B=ae.n(_),O=ae("wx14"),k=ae("zLVn"),w=ae("9R94"),v=function(e){Object(N.a)(n,e);function n(){for(var p,g=arguments.length,T=new Array(g),P=0;P<g;P++)T[P]=arguments[P];return p=e.call.apply(e,[this].concat(T))||this,p.history=Object(L.a)(p.props),p}var a=n.prototype;return a.render=function(){return U.a.createElement(he.c,{history:this.history,children:this.props.children})},n}(U.a.Component),x=function(e){Object(N.a)(n,e);function n(){for(var p,g=arguments.length,T=new Array(g),P=0;P<g;P++)T[P]=arguments[P];return p=e.call.apply(e,[this].concat(T))||this,p.history=Object(L.b)(p.props),p}var a=n.prototype;return a.render=function(){return U.a.createElement(he.c,{history:this.history,children:this.props.children})},n}(U.a.Component),C=function(n,a){return typeof n=="function"?n(a):n},E=function(n,a){return typeof n=="string"?Object(L.c)(n,null,null,a):n},b=function(n){return n},y=U.a.forwardRef;typeof y=="undefined"&&(y=b);function d(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var r=y(function(e,n){var a=e.innerRef,p=e.navigate,g=e.onClick,T=Object(k.a)(e,["innerRef","navigate","onClick"]),P=T.target,I=Object(O.a)({},T,{onClick:function(W){try{g&&g(W)}catch(z){throw W.preventDefault(),z}!W.defaultPrevented&&W.button===0&&(!P||P==="_self")&&!d(W)&&(W.preventDefault(),p())}});return b!==y?I.ref=n||a:I.ref=a,U.a.createElement("a",I)}),i=y(function(e,n){var a=e.component,p=a===void 0?r:a,g=e.replace,T=e.to,P=e.innerRef,I=Object(k.a)(e,["component","replace","to","innerRef"]);return U.a.createElement(he.e.Consumer,null,function(F){F||Object(w.a)(!1);var W=F.history,z=E(C(T,F.location),F.location),X=z?W.createHref(z):"",K=Object(O.a)({},I,{href:X,navigate:function(){var ne=C(T,F.location),re=g?W.replace:W.push;re(ne)}});return b!==y?K.ref=n||P:K.innerRef=P,U.a.createElement(p,K)})});if(!1)var o,f;var l=function(n){return n},h=U.a.forwardRef;typeof h=="undefined"&&(h=l);function m(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];return n.filter(function(p){return p}).join(" ")}var c=h(function(e,n){var a=e["aria-current"],p=a===void 0?"page":a,g=e.activeClassName,T=g===void 0?"active":g,P=e.activeStyle,I=e.className,F=e.exact,W=e.isActive,z=e.location,X=e.sensitive,K=e.strict,J=e.style,ne=e.to,re=e.innerRef,be=Object(k.a)(e,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return U.a.createElement(he.e.Consumer,null,function(oe){oe||Object(w.a)(!1);var ue=z||oe.location,de=E(C(ne,ue),ue),ce=de.pathname,te=ce&&ce.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),$=te?Object(he.f)(ue.pathname,{path:te,exact:F,sensitive:X,strict:K}):null,Ae=!!(W?W($,ue):$),Fe=Ae?m(I,T):I,De=Ae?Object(O.a)({},J,{},P):J,Ue=Object(O.a)({"aria-current":Ae&&p||null,className:Fe,style:De,to:de},be);return l!==h?Ue.ref=n||re:Ue.innerRef=re,U.a.createElement(i,Ue)})});if(!1)var u},"7iMQ":function(vt,tt,ae){vt.exports={flex_box_center:"flex_box_center___2gbXl",flex_space_between:"flex_space_between___1wCja",flex_box_vertical_center:"flex_box_vertical_center___1SR9W",flex_box_center_end:"flex_box_center_end___iQrwG",flex_box_column:"flex_box_column___1FzsI",bg:"bg___Fnp9V",containerTitle:"containerTitle___3SWYr",containerDesc:"containerDesc___1vOga",listItem:"listItem___3Ygyv",info:"info___q0zEQ",title:"title___1lfph",titleLeft:"titleLeft___YAW8a",titleRight:"titleRight___24IYl",acitons:"acitons___1eW6L"}},"8hTe":function(vt,tt,ae){vt.exports={button:"button___1wy9m"}},"9Bee":function(vt,tt,ae){"use strict";var he=ae("DYRE"),N=ae("zeV3"),S=ae("+L6B"),U=ae("2/Rp"),L=ae("k1fw"),_=ae("9og8"),B=ae("tJVT"),O=ae("WmNS"),k=ae.n(O),w=ae("q1tI"),v=ae.n(w),x=ae("vg9a"),C=ae("DlQD"),E=ae.n(C),b=ae("rUJ1");function y(R,t){var s=R.match(/^(\s+)(?:```)/);if(s===null)return t;var A=s[1];return t.split(`
|
|
`).map(function(M){var D=M.match(/^\s+/);if(D===null)return M;var Y=Object(B.a)(D,1),ge=Y[0];return ge.length>=A.length?M.slice(A.length):M}).join(`
|
|
`)}var d=[],r=["<ul>"],i=new E.a.Renderer,o=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function f(){d.length=0,r=["<ul>"]}var l={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function h(R,t,s,A){if(t>=R.length||R[t].level<=s)return t;var M=R[t];A.push("<li><a href='#"+M.anchor+"'>"+M.text+"</a>"),t++;var D=[];return t=h(R,t,M.level,D),D.length>0&&(A.push("<ul>"),D.forEach(function(Y){A.push(Y)}),A.push("</ul>")),A.push("</li>"),t=h(R,t,s,A),t}function m(){return h(d,0,0,r),r.push("</ul>"),r.join("")}var c={heading:function(t){var s=o.exec(t);if(s)return{type:"heading",raw:s[0],depth:s[1].length,text:s[2]}},fences:function(t){var s=this.rules.block.fences.exec(t);if(s){var A=s[0],M=y(A,s[3]||""),D=s[2]?s[2].trim():s[2];if(["latex","katex","math"].indexOf(D)>=0){var Y=n(),ge=M;M=Y,a[Y]={type:"block",expression:ge}}return{type:"code",raw:A,lang:D,text:M}}}},u=/(?:\${2})([^\n`]+?)(?:\${2})/gi,e=0,n=function(){return"__special_katext_id_".concat(e++,"__")},a={};function p(){return a}function g(){e=0,a={}}function T(R){return R=R.replace(u,function(t,s){var A=n();return a[A]={type:"inline",expression:s},A}),R}var P=i.listitem;i.listitem=function(R){return P(T(R))};var I=i.paragraph;i.paragraph=function(R){return I(T(R))};var F=i.tablecell;i.tablecell=function(R,t){return F(T(R),t)},i.code=function(R,t,s){var A=(t||"").match(/\S*/)[0];return A?["latex","katex","math"].indexOf(A)>=0?"<p class='editormd-tex'>".concat(R,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(t,'">').concat(s?R:Object(b.escape)(R,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(s?R:Object(b.escape)(R,!0))+"</code></pre>"},i.heading=function(R,t,s){var A=this.options.headerPrefix+s.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return d.push({anchor:A,level:t,text:R}),"<h"+t+' id="'+A+'">'+R+"</h"+t+">"},E.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),E.a.use({tokenizer:c,renderer:i});var W=E.a,z=ae("SJMd"),X=ae("ulZh"),K=ae.n(X),J=ae("m3rI"),ne=ae("Oy/b"),re=ae("p5ED"),be=ae("ErOA");/*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var oe=function(R,t){return(oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,A){s.__proto__=A}||function(s,A){for(var M in A)Object.prototype.hasOwnProperty.call(A,M)&&(s[M]=A[M])})(R,t)};function ue(R,t){function s(){this.constructor=R}oe(R,t),R.prototype=t===null?Object.create(t):(s.prototype=t.prototype,new s)}function de(R,t,s,A){return new(s||(s=Promise))(function(M,D){function Y(ze){try{Ie(A.next(ze))}catch(ye){D(ye)}}function ge(ze){try{Ie(A.throw(ze))}catch(ye){D(ye)}}function Ie(ze){var ye;ze.done?M(ze.value):(ye=ze.value,ye instanceof s?ye:new s(function(Qe){Qe(ye)})).then(Y,ge)}Ie((A=A.apply(R,t||[])).next())})}function ce(R,t){var s,A,M,D,Y={label:0,sent:function(){if(1&M[0])throw M[1];return M[1]},trys:[],ops:[]};return D={next:ge(0),throw:ge(1),return:ge(2)},typeof Symbol=="function"&&(D[Symbol.iterator]=function(){return this}),D;function ge(Ie){return function(ze){return function(ye){if(s)throw new TypeError("Generator is already executing.");for(;Y;)try{if(s=1,A&&(M=2&ye[0]?A.return:ye[0]?A.throw||((M=A.return)&&M.call(A),0):A.next)&&!(M=M.call(A,ye[1])).done)return M;switch(A=0,M&&(ye=[2&ye[0],M.value]),ye[0]){case 0:case 1:M=ye;break;case 4:return Y.label++,{value:ye[1],done:!1};case 5:Y.label++,A=ye[1],ye=[0];continue;case 7:ye=Y.ops.pop(),Y.trys.pop();continue;default:if(!(M=Y.trys,(M=M.length>0&&M[M.length-1])||ye[0]!==6&&ye[0]!==2)){Y=0;continue}if(ye[0]===3&&(!M||ye[1]>M[0]&&ye[1]<M[3])){Y.label=ye[1];break}if(ye[0]===6&&Y.label<M[1]){Y.label=M[1],M=ye;break}if(M&&Y.label<M[2]){Y.label=M[2],Y.ops.push(ye);break}M[2]&&Y.ops.pop(),Y.trys.pop();continue}ye=t.call(R,Y)}catch(Qe){ye=[6,Qe],A=0}finally{s=M=0}if(5&ye[0])throw ye[1];return{value:ye[0]?ye[1]:void 0,done:!0}}([Ie,ze])}}}function te(){for(var R=0,t=0,s=arguments.length;t<s;t++)R+=arguments[t].length;var A=Array(R),M=0;for(t=0;t<s;t++)for(var D=arguments[t],Y=0,ge=D.length;Y<ge;Y++,M++)A[M]=D[Y];return A}var $=function(){function R(){}return R.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},R.setAttributes=function(t,s){for(var A=0,M=s;A<M.length;A++){var D=M[A],Y=D[0],ge=D[1];t.setAttribute(Y,ge)}},R.createRect=function(t,s,A){var M=document.createElementNS("http://www.w3.org/2000/svg","rect");return M.setAttribute("width",t.toString()),M.setAttribute("height",s.toString()),A&&R.setAttributes(M,A),M},R.createLine=function(t,s,A,M,D){var Y=document.createElementNS("http://www.w3.org/2000/svg","line");return Y.setAttribute("x1",t.toString()),Y.setAttribute("y1",s.toString()),Y.setAttribute("x2",A.toString()),Y.setAttribute("y2",M.toString()),D&&R.setAttributes(Y,D),Y},R.createPolygon=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg","polygon");return A.setAttribute("points",t),s&&R.setAttributes(A,s),A},R.createCircle=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg","circle");return A.setAttribute("cx",(t/2).toString()),A.setAttribute("cy",(t/2).toString()),A.setAttribute("r",t.toString()),s&&R.setAttributes(A,s),A},R.createEllipse=function(t,s,A){var M=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return M.setAttribute("cx",(t/2).toString()),M.setAttribute("cy",(s/2).toString()),M.setAttribute("rx",(t/2).toString()),M.setAttribute("ry",(s/2).toString()),A&&R.setAttributes(M,A),M},R.createGroup=function(t){var s=document.createElementNS("http://www.w3.org/2000/svg","g");return t&&R.setAttributes(s,t),s},R.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},R.createMarker=function(t,s,A,M,D,Y,ge){var Ie=document.createElementNS("http://www.w3.org/2000/svg","marker");return R.setAttributes(Ie,[["id",t],["orient",s],["markerWidth",A.toString()],["markerHeight",M.toString()],["refX",D.toString()],["refY",Y.toString()]]),Ie.appendChild(ge),Ie},R.createText=function(t){var s=document.createElementNS("http://www.w3.org/2000/svg","text");return s.setAttribute("x","0"),s.setAttribute("y","0"),t&&R.setAttributes(s,t),s},R.createTSpan=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg","tspan");return A.textContent=t,s&&R.setAttributes(A,s),A},R.createImage=function(t){var s=document.createElementNS("http://www.w3.org/2000/svg","image");return t&&R.setAttributes(s,t),s},R.createPoint=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return A.x=t,A.y=s,A},R.createPath=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg","path");return A.setAttribute("d",t),s&&R.setAttributes(A,s),A},R}(),Ae=function(){function R(){}return R.addKey=function(t){R.key=t},Object.defineProperty(R,"isLicensed",{get:function(){return!!R.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(R.key)},enumerable:!1,configurable:!0}),R}(),Fe=function(){function R(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return R.prototype.rasterize=function(t,s,A){var M=this;return new Promise(function(D){var Y=A!==void 0?A:document.createElement("canvas");t===null&&(M.markersOnly=!0,M.naturalSize=!1);var ge=document.createElementNS("http://www.w3.org/2000/svg","svg");ge.setAttribute("xmlns","http://www.w3.org/2000/svg"),ge.setAttribute("width",s.width.baseVal.valueAsString),ge.setAttribute("height",s.height.baseVal.valueAsString),ge.setAttribute("viewBox","0 0 "+s.viewBox.baseVal.width.toString()+" "+s.viewBox.baseVal.height.toString()),ge.innerHTML=s.innerHTML,M.naturalSize===!0?(ge.width.baseVal.value=t.naturalWidth,ge.height.baseVal.value=t.naturalHeight):M.width!==void 0&&M.height!==void 0&&(ge.width.baseVal.value=M.width,ge.height.baseVal.value=M.height),Y.width=ge.width.baseVal.value,Y.height=ge.height.baseVal.value;var Ie=ge.outerHTML,ze=Y.getContext("2d");M.markersOnly!==!0&&ze.drawImage(t,0,0,Y.width,Y.height);var ye=window.URL,Qe=new Image(Y.width,Y.height);Qe.setAttribute("crossOrigin","anonymous");var pt=new Blob([Ie],{type:"image/svg+xml"}),bt=ye.createObjectURL(pt);Qe.onload=function(){ze.drawImage(Qe,0,0),ye.revokeObjectURL(bt);var Mt=Y.toDataURL(M.imageType,M.imageQuality);D(Mt)},Qe.src=bt})},R}(),De=function(){},Ue=function(){function R(t){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+t+"_"}return Object.defineProperty(R.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#ffffff",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarColor:"#eeeeee",toolbarHeight:40,toolboxColor:"#eeeeee",toolboxAccentColor:"#3080c3",undoButtonVisible:!0,redoButtonVisible:!1,zoomButtonVisible:!1,zoomOutButtonVisible:!1,clearButtonVisible:!1,resultButtonBlockVisible:!0,logoPosition:"left"}},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),R.prototype.addClass=function(t){return this.styleSheet===void 0&&this.addStyleSheet(),t.name=""+this.classNamePrefix+t.localName,this.classes.push(t),this.styleSheet.sheet.insertRule("."+t.name+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length),t},R.prototype.addRule=function(t){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(t),this.styleSheet.sheet.insertRule(t.selector+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length)},R.prototype.addStyleSheet=function(){var t;this.styleSheet=document.createElement("style"),((t=this.styleSheetRoot)!==null&&t!==void 0?t:document.head).appendChild(this.styleSheet),this.addRule(new Re("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Re("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new Re("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new fe("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new fe("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},R.prototype.removeStyleSheet=function(){var t;this.styleSheet&&(((t=this.styleSheetRoot)!==null&&t!==void 0?t:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},R}(),Re=function(R,t){this.selector=R,this.style=t},fe=function(R,t){this.localName=R,this.style=t},Ce=function(){function R(t,s,A,M,D){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=t,this.displayMode=s,this.markerItems=A,this.uiStyleSettings=M,this.styles=D,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return R.prototype.show=function(t){var s=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=t,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var A=document.createElement("div");A.className=this.toolbarBlockStyleClass.name,A.style.whiteSpace="nowrap",this.uiContainer.appendChild(A),this.addActionButton(A,'<svg viewBox="0 0 24 24"><path d="M10.07 14.27a.997.997 0 011.33.48l2.3 4.99 1.8-.85-2.31-4.98c-.24-.5-.02-1.1.48-1.33l.28-.08 2.3-.45L8 5.12V15.9l1.82-1.47.25-.16m3.57 7.7a.99.99 0 01-1.33-.47l-2.18-4.74-2.51 2.02c-.17.14-.38.22-.62.22a1 1 0 01-1-1V3a1 1 0 011-1c.24 0 .47.09.64.23l.01-.01 11.49 9.64a1.001 1.001 0 01-.44 1.75l-3.16.62 2.2 4.73c.26.5.02 1.09-.48 1.32l-3.62 1.69z"/></svg>',"select"),this.addActionButton(A,'<svg viewBox="0 0 24 24"><path d="M9 3v1H4v2h1v13a2 2 0 002 2h10a2 2 0 002-2V6h1V4h-5V3H9M7 6h10v13H7V6m2 2v9h2V8H9m4 0v9h2V8h-2z"/></svg>',"delete"),this.uiStyleSettings.clearButtonVisible&&this.addActionButton(A,'<svg viewBox="0 0 24 24"><path d="M19.36 2.72l1.42 1.42-5.72 5.71c1.07 1.54 1.22 3.39.32 4.59L9.06 8.12c1.2-.9 3.05-.75 4.59.32l5.71-5.72M5.93 17.57c-2.01-2.01-3.24-4.41-3.58-6.65l4.88-2.09 7.44 7.44-2.09 4.88c-2.24-.34-4.64-1.57-6.65-3.58z"/></svg>',"clear"),this.uiStyleSettings.undoButtonVisible&&this.addActionButton(A,'<svg viewBox="0 0 24 24"><path d="M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/></svg>',"undo"),this.uiStyleSettings.redoButtonVisible&&this.addActionButton(A,'<svg viewBox="0 0 24 24"><path d="M18.4 10.6C16.55 9 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 017.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/></svg>',"redo"),this.uiStyleSettings.zoomButtonVisible&&this.addActionButton(A,'<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"zoom"),this.uiStyleSettings.zoomButtonVisible&&this.uiStyleSettings.zoomOutButtonVisible&&this.addActionButton(A,'<svg viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 009.5 3 6.5 6.5 0 003 9.5 6.5 6.5 0 009.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 5 1.5-1.5-5-5m-6 0C7 14 5 12 5 9.5S7 5 9.5 5 14 7 14 9.5 12 14 9.5 14M7 9h5v1H7V9z"/></svg>',"zoom-out"),this.uiStyleSettings.notesButtonVisible&&this.addActionButton(A,'<svg viewBox="0 0 24 24"><path d="M18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 002 2h6v-1.87l.13-.13H5V5h7v7h6.13M14 4.5l5.5 5.5H14V4.5m5.13 9.33l2.04 2.04L15.04 22H13v-2.04l6.13-6.13m3.72.36l-.98.98-2.04-2.04.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72z"/></svg>',"notes"),this.markerButtonBlock=document.createElement("div"),this.markerButtonBlock.className=this.toolbarBlockStyleClass.name,this.markerButtonBlock.style.flexGrow="2",this.markerButtonBlock.style.textAlign="center",this.uiContainer.appendChild(this.markerButtonBlock),this.markerButtonOverflowBlock=document.createElement("div"),this.markerButtonOverflowBlock.className=this.toolbarOverflowBlockStyleClass.name+" "+(this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName?this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName:this.toolbarOverflowBlockStyleColorsClass.name),this.markerButtonOverflowBlock.style.display="none",this.uiContainer.appendChild(this.markerButtonOverflowBlock),this.markerItems&&(this.markerItems.forEach(function(D){var Y=document.createElement("div");Y.className=""+s.toolbarButtonStyleClass.name,Y.setAttribute("data-type-name",D.typeName),Y.innerHTML=D.icon,Y.addEventListener("click",function(){s.markerToolbarButtonClicked(Y,D)}),s.buttons.push(Y),s.markerButtons.push(Y)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var M=document.createElement("div");M.className=this.toolbarBlockStyleClass.name,M.style.whiteSpace="nowrap",M.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(M),this.addActionButton(M,'<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"render"),this.addActionButton(M,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},R.prototype.addButtonClickListener=function(t){this.buttonClickListeners.push(t)},R.prototype.removeButtonClickListener=function(t){this.buttonClickListeners.indexOf(t)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(t),1)},R.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},R.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var t=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var s=0;s<this.markerButtons.length;s++)s<t||s===t&&this.markerButtons.length-1===t?this.markerButtonBlock.appendChild(this.markerButtons[s]):(s===t&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[s]))}},R.prototype.overflowButtonClicked=function(){this.markerButtonOverflowBlock.style.display!=="none"?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},R.prototype.resetButtonStyles=function(){var t=this;this.buttons.forEach(function(s){s.className=s.className.replace(t.uiStyleSettings.toolbarButtonStyleColorsClassName?t.uiStyleSettings.toolbarButtonStyleColorsClassName:t.toolbarButtonStyleColorsClass.name,"").trim(),s.className=s.className.replace(t.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?t.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:t.toolbarActiveButtonStyleColorsClass.name,"").trim(),s.className+=" "+(t.uiStyleSettings.toolbarButtonStyleColorsClassName?t.uiStyleSettings.toolbarButtonStyleColorsClassName:t.toolbarButtonStyleColorsClass.name)})},R.prototype.addActionButton=function(t,s,A){var M=this,D=document.createElement("div");switch(D.className=""+this.toolbarButtonStyleClass.name,D.innerHTML=s,D.setAttribute("data-action",A),D.addEventListener("click",function(){M.actionToolbarButtonClicked(D,A)}),A){case"select":D.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":D.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":D.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":D.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":D.style.fill=this.uiStyleSettings.closeButtonColor}t.appendChild(D),this.buttons.push(D)},R.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new fe("toolbar",`
|
|
width: 100%;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
height: `+this.uiStyleSettings.toolbarHeight+`px;
|
|
box-sizing: content-box;
|
|
`+(this.displayMode==="inline"?"border-top-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
`+(this.displayMode==="inline"?"border-top-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
overflow: hidden;
|
|
`)),this.toolbarStyleColorsClass=this.styles.addClass(new fe("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new fe("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new fe("toolbar-overflow-block",`
|
|
position: absolute;
|
|
top: `+this.uiStyleSettings.toolbarHeight+`px;
|
|
max-width: `+2*this.uiStyleSettings.toolbarHeight+`px;
|
|
z-index: 10;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleColorsClass=this.styles.addClass(new fe("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var t=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new fe("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*t)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*t)+`px;
|
|
padding: `+t+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new fe("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new fe("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Re("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new Re("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},R.prototype.markerToolbarButtonClicked=function(t,s){this.setActiveButton(t),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(A){return A("marker",s)}),this.markerButtonOverflowBlock.style.display="none"},R.prototype.actionToolbarButtonClicked=function(t,s){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(A){return A("action",s)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},R.prototype.setActiveButton=function(t){this.resetButtonStyles(),t.className=t.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),t.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},R.prototype.setActiveMarkerButton=function(t){var s=this.markerButtons.find(function(A){return A.getAttribute("data-type-name")===t});s&&this.setActiveButton(s)},R.prototype.setCurrentMarker=function(t){var s=this;this.currentMarker=t,this.buttons.filter(function(A){return/delete|notes/.test(A.getAttribute("data-action"))}).forEach(function(A){s.currentMarker===void 0?(A.style.fillOpacity="0.4",A.style.pointerEvents="none"):(A.style.fillOpacity="1",A.style.pointerEvents="all")})},R}(),Se=function(){function R(t,s,A,M){this.panels=[],this.panelButtons=[],this.markerjsContainer=t,this.displayMode=s,this.uiStyleSettings=A,this.styles=M,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return R.prototype.addStyles=function(){var t;this.toolboxStyleClass=this.styles.addClass(new fe("toolbox",`
|
|
width: 100%;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
font-family: sans-serif;
|
|
`+(this.displayMode==="popup"?"height:"+2.5*this.uiStyleSettings.toolbarHeight+"px;":"")+`
|
|
box-sizing: content-box;
|
|
`+(this.displayMode==="popup"?"background-color: "+this.uiStyleSettings.canvasBackgroundColor+";":"")+`
|
|
`+(this.displayMode==="inline"?"border-bottom-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
`+(this.displayMode==="inline"?"border-bottom-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
overflow: hidden;
|
|
`)),this.toolboxStyleColorsClass=this.styles.addClass(new fe("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new fe("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new fe("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new fe("toolbox-panel-row",`
|
|
display: flex;
|
|
`+(this.displayMode==="inline"?"position: absolute;":"")+`
|
|
`+(this.displayMode==="inline"?"bottom: "+this.uiStyleSettings.toolbarHeight+"px;":"")+`
|
|
cursor: default;
|
|
height: `+1.5*this.uiStyleSettings.toolbarHeight+`px;
|
|
`+(this.displayMode==="inline"?"width: 100%;":"")+`
|
|
box-sizing: content-box;
|
|
`)),this.toolboxPanelRowStyleColorsClass=this.styles.addClass(new fe("toolbox-panel-row_colors",`
|
|
background-color: `+((t=this.uiStyleSettings.toolboxBackgroundColor)!==null&&t!==void 0?t:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new fe("toolbox_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
|
|
padding: `+s+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new fe("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new fe("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new Re("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Re("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},R.prototype.show=function(t){var s;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=t,this.uiContainer.className=this.toolboxStyleClass.name+" "+((s=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&s!==void 0?s:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},R.prototype.setPanelButtons=function(t){var s,A,M=this;this.panels=t,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((s=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&s!==void 0?s:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((A=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&A!==void 0?A:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(D){var Y;D.uiStyleSettings=M.uiStyleSettings;var ge=document.createElement("div");ge.className=M.toolboxButtonStyleClass.name+" "+((Y=M.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Y!==void 0?Y:M.toolboxButtonStyleColorsClass.name),ge.innerHTML=D.icon,ge.title=D.title,ge.addEventListener("click",function(){M.panelButtonClick(D)}),M.panelButtons.push(ge),M.buttonRow.appendChild(ge)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},R.prototype.panelButtonClick=function(t){var s=this,A=-1;if(t!==this.activePanel){A=this.panels.indexOf(t),this.panelRow.innerHTML="";var M=t.getUi();M.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(M),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=t}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){s.displayMode==="inline"?s.panelRow.style.display="none":s.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(D,Y){var ge,Ie;D.className=s.toolboxButtonStyleClass.name+" "+(Y===A?""+((ge=s.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&ge!==void 0?ge:s.toolboxActiveButtonStyleColorsClass.name):""+((Ie=s.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Ie!==void 0?Ie:s.toolboxButtonStyleColorsClass.name))})},R}(),me=function(R,t){this.title=R,this.icon=t},Te=function(R){function t(s,A,M,D){var Y=R.call(this,s,D||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return Y.colors=[],Y.addTransparent=!1,Y.colorBoxes=[],Y.colors=A,Y.currentColor=M,Y.setCurrentColor=Y.setCurrentColor.bind(Y),Y.getColorBox=Y.getColorBox.bind(Y),Y}return ue(t,R),t.prototype.getUi=function(){var s=this,A=document.createElement("div");return A.style.overflow="hidden",A.style.whiteSpace="nowrap",this.colors.forEach(function(M){var D=s.getColorBox(M);A.appendChild(D),s.colorBoxes.push(D)}),A},t.prototype.getColorBox=function(s){var A=this,M=this.uiStyleSettings.toolbarHeight/4,D=this.uiStyleSettings.toolbarHeight-M,Y=document.createElement("div");Y.style.display="inline-block",Y.style.boxSizing="content-box",Y.style.width=D-2+"px",Y.style.height=D-2+"px",Y.style.padding="1px",Y.style.marginRight="2px",Y.style.marginBottom="2px",Y.style.borderWidth="2px",Y.style.borderStyle="solid",Y.style.borderRadius=(D+2)/2+"px",Y.style.borderColor=s===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",Y.addEventListener("click",function(){A.setCurrentColor(s,Y)});var ge=document.createElement("div");return ge.style.display="inline-block",ge.style.width=D-2+"px",ge.style.height=D-2+"px",ge.style.backgroundColor=s,ge.style.borderRadius=D/2+"px",s==="transparent"&&(ge.style.fill=this.uiStyleSettings.toolboxAccentColor,ge.innerHTML=`<svg viewBox="0 0 24 24">
|
|
<path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />
|
|
</svg>`),Y.appendChild(ge),Y},t.prototype.setCurrentColor=function(s,A){var M=this;this.currentColor=s,this.colorBoxes.forEach(function(D){D.style.borderColor=D===A?M.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(s)},t}(me),pe=function(){function R(t,s,A){this._state="new",this._isSelected=!1,this._container=t,this._overlayContainer=s,this.globalSettings=A,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(R.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),R.prototype.ownsTarget=function(t){return!1},Object.defineProperty(R.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),R.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},R.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},R.prototype.pointerDown=function(t,s){},R.prototype.dblClick=function(t,s){},R.prototype.manipulate=function(t){},R.prototype.pointerUp=function(t){this.stateChanged()},R.prototype.dispose=function(){},R.prototype.addMarkerVisualToContainer=function(t){this.container.childNodes.length>0?this.container.insertBefore(t,this.container.childNodes[0]):this.container.appendChild(t)},R.prototype.getState=function(){return{typeName:R.typeName,state:this.state,notes:this.notes}},R.prototype.restoreState=function(t){this._state=t.state,this.notes=t.notes},R.prototype.scale=function(t,s){},R.prototype.colorChanged=function(t){this.onColorChanged&&this.onColorChanged(t),this.stateChanged()},R.prototype.fillColorChanged=function(t){this.onFillColorChanged&&this.onFillColorChanged(t),this.stateChanged()},R.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var t=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),t.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(t)&&this.onStateChanged(this)}},R.typeName="MarkerBase",R}(),Ee=function(){function R(){this.findGripByVisual=this.findGripByVisual.bind(this)}return R.prototype.findGripByVisual=function(t){return this.topLeft.ownsTarget(t)?this.topLeft:this.topCenter.ownsTarget(t)?this.topCenter:this.topRight.ownsTarget(t)?this.topRight:this.centerLeft.ownsTarget(t)?this.centerLeft:this.centerRight.ownsTarget(t)?this.centerRight:this.bottomLeft.ownsTarget(t)?this.bottomLeft:this.bottomCenter.ownsTarget(t)?this.bottomCenter:this.bottomRight.ownsTarget(t)?this.bottomRight:void 0},R}(),Ge=function(){function R(){this.GRIP_SIZE=10,this.visual=$.createGroup(),this.visual.appendChild($.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild($.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return R.prototype.ownsTarget=function(t){return t===this.visual||t===this.visual.childNodes[0]||t===this.visual.childNodes[1]},R}(),Le=function(){function R(){}return R.toITransformMatrix=function(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}},R.toSVGMatrix=function(t,s){return t.a=s.a,t.b=s.b,t.c=s.c,t.d=s.d,t.e=s.e,t.f=s.f,t},R}(),ke=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.left=0,D.top=0,D.width=0,D.height=0,D.defaultSize={x:50,y:20},D.offsetX=0,D.offsetY=0,D.rotationAngle=0,D.CB_DISTANCE=10,D._suppressMarkerCreateEvent=!1,D.container.transform.baseVal.appendItem($.createTransform()),D.setupControlBox(),D}return ue(t,R),Object.defineProperty(t.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visual",{get:function(){return this._visual},set:function(s){this._visual=s;var A=$.createTransform();this._visual.transform.baseVal.appendItem(A)},enumerable:!1,configurable:!0}),t.prototype.ownsTarget=function(s){return!!R.prototype.ownsTarget.call(this,s)||!!(this.controlGrips.findGripByVisual(s)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(s))},t.prototype.pointerDown=function(s,A){R.prototype.pointerDown.call(this,s,A),this.state==="new"&&(this.left=s.x,this.top=s.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var M=this.unrotatePoint(s);if(this.manipulationStartX=M.x,this.manipulationStartY=M.y,this.offsetX=M.x-this.left,this.offsetY=M.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(A),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(A)){this.activeGrip=this.rotatorGrip;var D=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=D.x-this.width/2,this.top=D.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var Y=this.container.transform.baseVal.getItem(0);Y.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(Y,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},t.prototype.pointerUp=function(s){var A=this.state;R.prototype.pointerUp.call(this,s),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(s),this._state="select",A==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},t.prototype.moveVisual=function(s){this.visual.style.transform="translate("+s.x+"px, "+s.y+"px)"},t.prototype.manipulate=function(s){var A=this.unrotatePoint(s);this.state==="creating"?this.resize(s):this.state==="move"?(this.left=this.manipulationStartLeft+(A.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(A.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(A):this.state==="rotate"&&this.rotate(s)},t.prototype.resize=function(s){var A=this.manipulationStartLeft,M=this.manipulationStartWidth,D=this.manipulationStartTop,Y=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:A=this.manipulationStartLeft+s.x-this.manipulationStartX,M=this.manipulationStartWidth+this.manipulationStartLeft-A;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:M=this.manipulationStartWidth+s.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:D=this.manipulationStartTop+s.y-this.manipulationStartY,Y=this.manipulationStartHeight+this.manipulationStartTop-D;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:Y=this.manipulationStartHeight+s.y-this.manipulationStartY}M>=0?(this.left=A,this.width=M):(this.left=A+M,this.width=-M),Y>=0?(this.top=D,this.height=Y):(this.top=D+Y,this.height=-Y),this.setSize()},t.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},t.prototype.rotate=function(s){if(Math.abs(s.x-this.centerX)>.1){var A=Math.sign(s.x-this.centerX);this.rotationAngle=180*Math.atan((s.y-this.centerY)/(s.x-this.centerX))/Math.PI+90*A,this.applyRotation()}},t.prototype.applyRotation=function(){var s=this.container.transform.baseVal.getItem(0);s.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(s,0)},t.prototype.rotatePoint=function(s){if(this.rotationAngle===0)return s;var A=this.container.getCTM(),M=$.createPoint(s.x,s.y);return{x:(M=M.matrixTransform(A)).x,y:M.y}},t.prototype.unrotatePoint=function(s){if(this.rotationAngle===0)return s;var A=this.container.getCTM();A=A.inverse();var M=$.createPoint(s.x,s.y);return{x:(M=M.matrixTransform(A)).x,y:M.y}},t.prototype.select=function(){R.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},t.prototype.deselect=function(){R.prototype.deselect.call(this),this.controlBox.style.display="none"},t.prototype.setupControlBox=function(){this.controlBox=$.createGroup();var s=$.createTransform();s.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(s),this.container.appendChild(this.controlBox),this.controlRect=$.createRect(this.width+this.CB_DISTANCE,this.height+this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"],["fill","transparent"],["pointer-events","none"]]),this.controlBox.appendChild(this.controlRect),this.globalSettings.disableRotation!==!0&&(this.rotatorGripLine=$.createLine((this.width+2*this.CB_DISTANCE)/2,this.top-this.CB_DISTANCE,(this.width+2*this.CB_DISTANCE)/2,this.top-3*this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.appendChild(this.rotatorGripLine)),this.controlGrips=new Ee,this.addControlGrips(),this.controlBox.style.display="none"},t.prototype.adjustControlBox=function(){var s=this.controlBox.transform.baseVal.getItem(0);s.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(s,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},t.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},t.prototype.createGrip=function(){var s=new Ge;return s.visual.transform.baseVal.appendItem($.createTransform()),this.controlBox.appendChild(s.visual),s},t.prototype.positionGrips=function(){var s=this.controlGrips.topLeft.GRIP_SIZE,A=-s/2,M=A,D=(this.width+this.CB_DISTANCE)/2-s/2,Y=(this.height+this.CB_DISTANCE)/2-s/2,ge=this.height+this.CB_DISTANCE-s/2,Ie=this.width+this.CB_DISTANCE-s/2;this.positionGrip(this.controlGrips.topLeft.visual,A,M),this.positionGrip(this.controlGrips.topCenter.visual,D,M),this.positionGrip(this.controlGrips.topRight.visual,Ie,M),this.positionGrip(this.controlGrips.centerLeft.visual,A,Y),this.positionGrip(this.controlGrips.centerRight.visual,Ie,Y),this.positionGrip(this.controlGrips.bottomLeft.visual,A,ge),this.positionGrip(this.controlGrips.bottomCenter.visual,D,ge),this.positionGrip(this.controlGrips.bottomRight.visual,Ie,ge),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,D,M-3*this.CB_DISTANCE)},t.prototype.positionGrip=function(s,A,M){var D=s.transform.baseVal.getItem(0);D.setTranslate(A,M),s.transform.baseVal.replaceItem(D,0)},t.prototype.hideControlBox=function(){this.controlBox.style.display="none"},t.prototype.showControlBox=function(){this.controlBox.style.display=""},t.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:Le.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:Le.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},R.prototype.getState.call(this))},t.prototype.restoreState=function(s){R.prototype.restoreState.call(this,s);var A=s;this.left=A.left,this.top=A.top,this.width=A.width,this.height=A.height,this.rotationAngle=A.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(Le.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,A.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(Le.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,A.containerTransformMatrix))},t.prototype.scale=function(s,A){R.prototype.scale.call(this,s,A);var M=this.rotatePoint({x:this.left,y:this.top}),D=this.unrotatePoint({x:M.x*s,y:M.y*A});this.left=D.x,this.top=D.y,this.width=this.width*s,this.height=this.height*A,this.adjustControlBox()},t}(pe),Ne=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.fillColor="transparent",D.strokeColor="transparent",D.strokeWidth=0,D.strokeDasharray="",D.opacity=1,D.setStrokeColor=D.setStrokeColor.bind(D),D.setFillColor=D.setFillColor.bind(D),D.setStrokeWidth=D.setStrokeWidth.bind(D),D.setStrokeDasharray=D.setStrokeDasharray.bind(D),D.createVisual=D.createVisual.bind(D),D}return ue(t,R),t.prototype.ownsTarget=function(s){return!(!R.prototype.ownsTarget.call(this,s)&&s!==this.visual)},t.prototype.createVisual=function(){this.visual=$.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},t.prototype.pointerDown=function(s,A){R.prototype.pointerDown.call(this,s,A),this.state==="new"&&(this.createVisual(),this.moveVisual(s),this._state="creating")},t.prototype.manipulate=function(s){R.prototype.manipulate.call(this,s)},t.prototype.resize=function(s){R.prototype.resize.call(this,s),this.setSize()},t.prototype.setSize=function(){R.prototype.setSize.call(this),$.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},t.prototype.pointerUp=function(s){R.prototype.pointerUp.call(this,s),this.setSize()},t.prototype.setStrokeColor=function(s){this.strokeColor=s,this.visual&&$.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(s),this.stateChanged()},t.prototype.setFillColor=function(s){this.fillColor=s,this.visual&&$.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},t.prototype.setStrokeWidth=function(s){this.strokeWidth=s,this.visual&&$.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},t.prototype.setStrokeDasharray=function(s){this.strokeDasharray=s,this.visual&&$.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},t.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},R.prototype.getState.call(this))},t.prototype.restoreState=function(s){var A=s;this.fillColor=A.fillColor,this.strokeColor=A.strokeColor,this.strokeWidth=A.strokeWidth,this.strokeDasharray=A.strokeDasharray,this.opacity=A.opacity,this.createVisual(),R.prototype.restoreState.call(this,s),this.setSize()},t.prototype.scale=function(s,A){R.prototype.scale.call(this,s,A),this.setSize()},t.title="Rectangle marker",t}(ke),ee=function(R){function t(s,A,M,D){var Y=R.call(this,s,D||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return Y.widths=[],Y.widthBoxes=[],Y.widths=A,Y.currentWidth=M,Y.setCurrentWidth=Y.setCurrentWidth.bind(Y),Y}return ue(t,R),t.prototype.getUi=function(){var s=this,A=document.createElement("div");return A.style.display="flex",A.style.overflow="hidden",A.style.flexGrow="2",this.widths.forEach(function(M){var D=document.createElement("div");D.style.display="flex",D.style.flexGrow="2",D.style.alignItems="center",D.style.justifyContent="space-between",D.style.padding="5px",D.style.borderWidth="2px",D.style.borderStyle="solid",D.style.borderColor=M===s.currentWidth?s.uiStyleSettings.toolboxAccentColor:"transparent",D.addEventListener("click",function(){s.setCurrentWidth(M,D)}),A.appendChild(D);var Y=document.createElement("div");Y.innerText=M.toString(),Y.style.marginRight="5px",D.appendChild(Y);var ge=document.createElement("div");ge.style.minHeight="20px",ge.style.flexGrow="2",ge.style.display="flex",ge.style.alignItems="center";var Ie=document.createElement("hr");Ie.style.minWidth="20px",Ie.style.border="0px",Ie.style.borderTop=M+"px solid "+s.uiStyleSettings.toolboxColor,Ie.style.flexGrow="2",ge.appendChild(Ie),D.appendChild(ge),s.widthBoxes.push(D)}),A},t.prototype.setCurrentWidth=function(s,A){var M=this;this.currentWidth=s,this.widthBoxes.forEach(function(D){D.style.borderColor=D===A?M.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},t}(me),Be=function(R){function t(s,A,M,D){var Y=R.call(this,s,D||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return Y.styles=[],Y.styleBoxes=[],Y.styles=A,Y.currentStyle=M,Y.setCurrentStyle=Y.setCurrentStyle.bind(Y),Y}return ue(t,R),t.prototype.getUi=function(){var s=this,A=document.createElement("div");return A.style.display="flex",A.style.overflow="hidden",A.style.flexGrow="2",this.styles.forEach(function(M){var D=document.createElement("div");D.style.display="flex",D.style.alignItems="center",D.style.justifyContent="space-between",D.style.padding="5px",D.style.borderWidth="2px",D.style.borderStyle="solid",D.style.overflow="hidden",D.style.maxWidth=100/s.styles.length-5+"%",D.style.borderColor=M===s.currentStyle?s.uiStyleSettings.toolboxAccentColor:"transparent",D.addEventListener("click",function(){s.setCurrentStyle(M,D)}),A.appendChild(D);var Y=document.createElement("div");Y.style.minHeight="20px",Y.style.flexGrow="2",Y.style.overflow="hidden";var ge=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+s.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(M!==""?'stroke-dasharray="'+M+'"':"")+` />
|
|
</svg>`;Y.innerHTML=ge,D.appendChild(Y),s.styleBoxes.push(D)}),A},t.prototype.setCurrentStyle=function(s,A){var M=this;this.currentStyle=s,this.styleBoxes.forEach(function(D){D.style.borderColor=D===A?M.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},t}(me),_e=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.strokeColor=M.defaultColor,D.strokeWidth=M.defaultStrokeWidth,D.strokeDasharray=M.defaultStrokeDasharray,D.strokePanel=new Te("Line color",M.defaultColorSet,M.defaultColor),D.strokePanel.onColorChanged=D.setStrokeColor,D.strokeWidthPanel=new ee("Line width",M.defaultStrokeWidths,M.defaultStrokeWidth),D.strokeWidthPanel.onWidthChanged=D.setStrokeWidth,D.strokeStylePanel=new Be("Line style",M.defaultStrokeDasharrays,M.defaultStrokeDasharray),D.strokeStylePanel.onStyleChanged=D.setStrokeDasharray,D}return ue(t,R),Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=R.prototype.getState.call(this);return s.typeName=t.typeName,s},t.typeName="FrameMarker",t.title="Frame marker",t.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',t}(Ne),we=function(){this.defaultColorSet=["#EF4444","#10B981","#2563EB","#FFFF00","#7C3AED","#F472B6","#000000","#FFFFFF"],this.defaultColor=this.defaultColorSet[0],this.defaultFillColor=this.defaultColorSet[0],this.defaultStrokeColor=this.defaultColorSet[7],this.defaultHighlightColor=this.defaultColorSet[3],this.defaultStrokeWidth=3,this.defaultStrokeDasharray="",this.defaultHighlightOpacity=.5,this.defaultFontFamily="Helvetica, Arial, sans-serif",this.defaultStrokeWidths=[1,2,3,5,10],this.defaultStrokeDasharrays=["","3","12 3","9 6 3 6"],this.defaultOpacitySteps=[.1,.25,.5,.75,1],this.displayMode="inline",this.defaultFontFamilies=['Times, "Times New Roman", serif',"Helvetica, Arial, sans-serif",'Courier, "Courier New", monospace',"cursive","fantasy"],this.popupMargin=30,this.newFreehandMarkerOnPointerUp=!1,this.defaultColorsFollowCurrentColors=!1,this.freehandPixelRatio=1,this.disableRotation=!1},We=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.x1=0,D.y1=0,D.x2=0,D.y2=0,D.defaultLength=50,D.manipulationStartX=0,D.manipulationStartY=0,D.manipulationStartX1=0,D.manipulationStartY1=0,D.manipulationStartX2=0,D.manipulationStartY2=0,D.setupControlBox(),D}return ue(t,R),t.prototype.ownsTarget=function(s){return!!R.prototype.ownsTarget.call(this,s)||!(!this.grip1.ownsTarget(s)&&!this.grip2.ownsTarget(s))},t.prototype.pointerDown=function(s,A){R.prototype.pointerDown.call(this,s,A),this.manipulationStartX=s.x,this.manipulationStartY=s.y,this.state==="new"&&(this.x1=s.x,this.y1=s.y,this.x2=s.x,this.y2=s.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,this.state!=="new"&&(this.select(),this.grip1.ownsTarget(A)?this.activeGrip=this.grip1:this.grip2.ownsTarget(A)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},t.prototype.pointerUp=function(s){var A=this.state;R.prototype.pointerUp.call(this,s),this.state==="creating"&&Math.abs(this.x1-this.x2)<10&&Math.abs(this.y1-this.y2)<10?(this.x2=this.x1+this.defaultLength,this.adjustVisual(),this.adjustControlBox()):this.manipulate(s),this._state="select",A==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},t.prototype.adjustVisual=function(){},t.prototype.manipulate=function(s){this.state==="creating"?this.resize(s):this.state==="move"?(this.x1=this.manipulationStartX1+s.x-this.manipulationStartX,this.y1=this.manipulationStartY1+s.y-this.manipulationStartY,this.x2=this.manipulationStartX2+s.x-this.manipulationStartX,this.y2=this.manipulationStartY2+s.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(s)},t.prototype.resize=function(s){switch(this.activeGrip){case this.grip1:this.x1=s.x,this.y1=s.y;break;case this.grip2:case void 0:this.x2=s.x,this.y2=s.y}this.adjustVisual(),this.adjustControlBox()},t.prototype.select=function(){R.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},t.prototype.deselect=function(){R.prototype.deselect.call(this),this.controlBox.style.display="none"},t.prototype.setupControlBox=function(){this.controlBox=$.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},t.prototype.adjustControlBox=function(){this.positionGrips()},t.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},t.prototype.createGrip=function(){var s=new Ge;return s.visual.transform.baseVal.appendItem($.createTransform()),this.controlBox.appendChild(s.visual),s},t.prototype.positionGrips=function(){var s=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-s/2,this.y1-s/2),this.positionGrip(this.grip2.visual,this.x2-s/2,this.y2-s/2)},t.prototype.positionGrip=function(s,A,M){var D=s.transform.baseVal.getItem(0);D.setTranslate(A,M),s.transform.baseVal.replaceItem(D,0)},t.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},R.prototype.getState.call(this))},t.prototype.restoreState=function(s){R.prototype.restoreState.call(this,s);var A=s;this.x1=A.x1,this.y1=A.y1,this.x2=A.x2,this.y2=A.y2},t.prototype.scale=function(s,A){R.prototype.scale.call(this,s,A),this.x1=this.x1*s,this.y1=this.y1*A,this.x2=this.x2*s,this.y2=this.y2*A,this.adjustVisual(),this.adjustControlBox()},t}(pe),Pe=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.strokeColor="transparent",D.strokeWidth=0,D.strokeDasharray="",D.setStrokeColor=D.setStrokeColor.bind(D),D.setStrokeWidth=D.setStrokeWidth.bind(D),D.setStrokeDasharray=D.setStrokeDasharray.bind(D),D.strokeColor=M.defaultColor,D.strokeWidth=M.defaultStrokeWidth,D.strokeDasharray=M.defaultStrokeDasharray,D.strokePanel=new Te("Line color",M.defaultColorSet,M.defaultColor),D.strokePanel.onColorChanged=D.setStrokeColor,D.strokeWidthPanel=new ee("Line width",M.defaultStrokeWidths,M.defaultStrokeWidth),D.strokeWidthPanel.onWidthChanged=D.setStrokeWidth,D.strokeStylePanel=new Be("Line style",M.defaultStrokeDasharrays,M.defaultStrokeDasharray),D.strokeStylePanel.onStyleChanged=D.setStrokeDasharray,D}return ue(t,R),t.prototype.ownsTarget=function(s){return!(!R.prototype.ownsTarget.call(this,s)&&s!==this.visual&&s!==this.selectorLine&&s!==this.visibleLine)},t.prototype.createVisual=function(){this.visual=$.createGroup(),this.selectorLine=$.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=$.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},t.prototype.pointerDown=function(s,A){R.prototype.pointerDown.call(this,s,A),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},t.prototype.adjustVisual=function(){this.selectorLine&&this.visibleLine&&(this.selectorLine.setAttribute("x1",this.x1.toString()),this.selectorLine.setAttribute("y1",this.y1.toString()),this.selectorLine.setAttribute("x2",this.x2.toString()),this.selectorLine.setAttribute("y2",this.y2.toString()),this.visibleLine.setAttribute("x1",this.x1.toString()),this.visibleLine.setAttribute("y1",this.y1.toString()),this.visibleLine.setAttribute("x2",this.x2.toString()),this.visibleLine.setAttribute("y2",this.y2.toString()),$.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),$.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),$.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},t.prototype.setStrokeColor=function(s){this.strokeColor=s,this.adjustVisual(),this.colorChanged(s)},t.prototype.setStrokeWidth=function(s){this.strokeWidth=s,this.adjustVisual()},t.prototype.setStrokeDasharray=function(s){this.strokeDasharray=s,this.adjustVisual(),this.stateChanged()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},R.prototype.getState.call(this));return s.typeName=t.typeName,s},t.prototype.restoreState=function(s){R.prototype.restoreState.call(this,s);var A=s;this.strokeColor=A.strokeColor,this.strokeWidth=A.strokeWidth,this.strokeDasharray=A.strokeDasharray,this.createVisual(),this.adjustVisual()},t.typeName="LineMarker",t.title="Line marker",t.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',t}(We),le=function(R){function t(s,A,M,D){var Y=R.call(this,s,D||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return Y.fonts=[],Y.fontBoxes=[],Y.fonts=A,Y.currentFont=M,Y.setCurrentFont=Y.setCurrentFont.bind(Y),Y}return ue(t,R),t.prototype.getUi=function(){var s=this,A=document.createElement("div");return A.style.overflow="hidden",A.style.flexGrow="2",this.fonts.forEach(function(M){var D=document.createElement("div");D.style.display="inline-block",D.style.alignItems="center",D.style.justifyContent="space-between",D.style.padding="5px",D.style.borderWidth="2px",D.style.borderStyle="solid",D.style.overflow="hidden",D.style.maxWidth=100/s.fonts.length-5+"%",D.style.borderColor=M===s.currentFont?s.uiStyleSettings.toolboxAccentColor:"transparent",D.addEventListener("click",function(){s.setCurrentFont(M,D)}),A.appendChild(D);var Y=document.createElement("div");Y.style.display="flex",Y.style.minHeight="20px",Y.style.flexGrow="2",Y.style.fontFamily=M,Y.style.overflow="hidden";var ge=document.createElement("div");ge.style.whiteSpace="nowrap",ge.style.overflow="hidden",ge.style.textOverflow="ellipsis",ge.innerHTML="The quick brown fox jumps over the lazy dog",Y.appendChild(ge),D.appendChild(Y),s.fontBoxes.push(D)}),A},t.prototype.setCurrentFont=function(s,A){var M=this;this.currentFont=s,this.fontBoxes.forEach(function(D){D.style.borderColor=D===A?M.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},t}(me),xe=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.color="transparent",D.padding=5,D.DEFAULT_TEXT="your text here",D.text=D.DEFAULT_TEXT,D.isMoved=!1,D.color=M.defaultColor,D.fontFamily=M.defaultFontFamily,D.defaultSize={x:100,y:30},D.setColor=D.setColor.bind(D),D.setFont=D.setFont.bind(D),D.renderText=D.renderText.bind(D),D.sizeText=D.sizeText.bind(D),D.textEditDivClicked=D.textEditDivClicked.bind(D),D.showTextEditor=D.showTextEditor.bind(D),D.setSize=D.setSize.bind(D),D.positionTextEditor=D.positionTextEditor.bind(D),D.colorPanel=new Te("Color",M.defaultColorSet,M.defaultColor),D.colorPanel.onColorChanged=D.setColor,D.fontFamilyPanel=new le("Font",M.defaultFontFamilies,M.defaultFontFamily),D.fontFamilyPanel.onFontChanged=D.setFont,D}return ue(t,R),t.prototype.ownsTarget=function(s){if(R.prototype.ownsTarget.call(this,s)||s===this.visual||s===this.textElement||s===this.bgRectangle)return!0;var A=!1;return this.textElement.childNodes.forEach(function(M){M===s&&(A=!0)}),A},t.prototype.createVisual=function(){this.visual=$.createGroup(),this.bgRectangle=$.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=$.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem($.createTransform()),this.textElement.transform.baseVal.appendItem($.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},t.prototype.pointerDown=function(s,A){R.prototype.pointerDown.call(this,s,A),this.isMoved=!1,this.pointerDownPoint=s,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(s),this._state="creating")},t.prototype.renderText=function(){var s=this;if(this.textElement){for(;this.textElement.lastChild;)this.textElement.removeChild(this.textElement.lastChild);this.text.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/).forEach(function(A){s.textElement.appendChild($.createTSpan(A.trim()===""?" ":A.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},t.prototype.getTextScale=function(){var s=this.textElement.getBBox(),A=1;if(s.width>0&&s.height>0){var M=(1*this.width-this.width*this.padding*2/100)/s.width,D=(1*this.height-this.height*this.padding*2/100)/s.height;A=Math.min(M,D)}return A},t.prototype.getTextPosition=function(s){var A=this.textElement.getBBox(),M=0,D=0;return A.width>0&&A.height>0&&(M=(this.width-A.width*s)/2,D=this.height/2-A.height*s/2),{x:M,y:D}},t.prototype.sizeText=function(){var s=this.textElement.getBBox(),A=this.getTextScale(),M=this.getTextPosition(A);M.y-=s.y*A,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+M.x+"px, "+M.y+"px) scale("+A+", "+A+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(M.x,M.y),this.textElement.transform.baseVal.getItem(1).setScale(A,A))},t.prototype.manipulate=function(s){R.prototype.manipulate.call(this,s),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(s.x-this.pointerDownPoint.x)>5||Math.abs(s.y-this.pointerDownPoint.y)>5)},t.prototype.resize=function(s){R.prototype.resize.call(this,s),this.isMoved=!0,this.setSize(),this.sizeText()},t.prototype.setSize=function(){R.prototype.setSize.call(this),this.visual&&this.bgRectangle&&($.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),$.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},t.prototype.pointerUp=function(s){var A=this.state;A==="creating"&&(this._suppressMarkerCreateEvent=!0),R.prototype.pointerUp.call(this,s),this.setSize(),(A==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},t.prototype.showTextEditor=function(){var s=this;this._state="edit",this.overlayContainer.innerHTML="",this.textEditDiv=document.createElement("div"),this.textEditDiv.style.flexGrow="2",this.textEditDiv.style.alignItems="center",this.textEditDiv.style.justifyContent="center",this.textEditDiv.style.pointerEvents="auto",this.textEditDiv.style.overflow="hidden",this.textEditor=document.createElement("div"),this.textEditor.style.position="absolute",this.textEditor.style.fontFamily=this.fontFamily,this.textEditor.style.lineHeight="1em",this.textEditor.innerText=this.text,this.textEditor.contentEditable="true",this.textEditor.style.color=this.color,this.textEditor.style.whiteSpace="pre",this.positionTextEditor(),this.textEditor.addEventListener("pointerup",function(A){A.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var A=Number.parseFloat(s.textEditor.style.fontSize);s.textEditor.clientWidth>=Number.parseInt(s.textEditor.style.maxWidth)&&A>.9;)A-=.1,s.textEditor.style.fontSize=Math.max(A,.9)+"em"}),this.textEditor.addEventListener("keyup",function(A){A.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(A){if(A.clipboardData){var M=A.clipboardData.getData("text"),D=window.getSelection();if(!D.rangeCount)return!1;D.deleteFromDocument(),D.getRangeAt(0).insertNode(document.createTextNode(M)),A.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){s.textEditDivClicked(s.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},t.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var s=this.getTextScale(),A=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),M=this.textElement.getBBox(),D={x:M.width*s,y:M.height*s};A.x-=D.x/2,A.y-=D.y/2,this.textEditor.style.top=A.y+"px",this.textEditor.style.left=A.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-A.x+"px",this.textEditor.style.fontSize=Math.max(16*s,12)+"px",this.textElement.style.display="none"}},t.prototype.textEditDivClicked=function(s){this.text=s.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},t.prototype.select=function(){R.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},t.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),R.prototype.deselect.call(this)},t.prototype.dblClick=function(s,A){R.prototype.dblClick.call(this,s,A),this.showTextEditor()},t.prototype.setColor=function(s){this.textElement&&$.setAttributes(this.textElement,[["fill",s]]),this.color=s,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(s)},t.prototype.setFont=function(s){this.textElement&&$.setAttributes(this.textElement,[["font-family",s]]),this.fontFamily=s,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},t.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},t.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},R.prototype.getState.call(this));return s.typeName=t.typeName,s},t.prototype.restoreState=function(s){var A=s;this.color=A.color,this.fontFamily=A.fontFamily,this.padding=A.padding,this.text=A.text,this.createVisual(),R.prototype.restoreState.call(this,s),this.setSize()},t.prototype.scale=function(s,A){R.prototype.scale.call(this,s,A),this.setSize(),this.sizeText(),this.positionTextEditor()},t.typeName="TextMarker",t.title="Text marker",t.icon='<svg viewBox="0 0 24 24"><path d="M9.6 14L12 7.7l2.4 6.3M11 5L5.5 19h2.2l1.1-3H15l1.1 3h2.2L13 5h-2z"/></svg>',t}(ke),q=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.color="transparent",D.lineWidth=3,D.drawing=!1,D.pixelRatio=1,D.color=M.defaultColor,D.lineWidth=M.defaultStrokeWidth,D.pixelRatio=M.freehandPixelRatio,D.setColor=D.setColor.bind(D),D.addCanvas=D.addCanvas.bind(D),D.finishCreation=D.finishCreation.bind(D),D.setLineWidth=D.setLineWidth.bind(D),D.colorPanel=new Te("Color",M.defaultColorSet,M.defaultColor),D.colorPanel.onColorChanged=D.setColor,D.lineWidthPanel=new ee("Line width",M.defaultStrokeWidths,M.defaultStrokeWidth),D.lineWidthPanel.onWidthChanged=D.setLineWidth,D}return ue(t,R),t.prototype.ownsTarget=function(s){return!(!R.prototype.ownsTarget.call(this,s)&&s!==this.visual&&s!==this.drawingImage)},t.prototype.createVisual=function(){this.visual=$.createGroup(),this.drawingImage=$.createImage(),this.visual.appendChild(this.drawingImage);var s=$.createTransform();this.visual.transform.baseVal.appendItem(s),this.addMarkerVisualToContainer(this.visual)},t.prototype.pointerDown=function(s,A){this.state==="new"&&(this.addCanvas(),this.createVisual(),this._state="creating"),this.state==="creating"?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(s.x,s.y),this.drawing=!0):R.prototype.pointerDown.call(this,s,A)},t.prototype.manipulate=function(s){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(s.x,s.y),this.canvasContext.stroke()):R.prototype.manipulate.call(this,s)},t.prototype.resize=function(s){R.prototype.resize.call(this,s),$.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),$.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},t.prototype.pointerUp=function(s){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):R.prototype.pointerUp.call(this,s)},t.prototype.addCanvas=function(){this.overlayContainer.innerHTML="",this.canvasElement=document.createElement("canvas"),this.canvasElement.width=this.overlayContainer.clientWidth*this.pixelRatio,this.canvasElement.height=this.overlayContainer.clientHeight*this.pixelRatio,this.canvasContext=this.canvasElement.getContext("2d"),this.canvasContext.scale(this.pixelRatio,this.pixelRatio),this.overlayContainer.appendChild(this.canvasElement)},t.prototype.select=function(){this.state==="creating"&&this.finishCreation(),R.prototype.select.call(this)},t.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),R.prototype.deselect.call(this)},t.prototype.finishCreation=function(){for(var s=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),A=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],M=A[0],D=A[1],Y=A[2],ge=A[3],Ie=!1,ze=0;ze<this.canvasElement.height;ze++)for(var ye=0;ye<this.canvasElement.width;ye++)s.data[ze*this.canvasElement.width*4+4*ye+3]>0&&(Ie=!0,ze<D&&(D=ze),ye<M&&(M=ye),ze>ge&&(ge=ze),ye>Y&&(Y=ye));if(Ie){this.left=M/this.pixelRatio,this.top=D/this.pixelRatio,this.width=(Y-M)/this.pixelRatio,this.height=(ge-D)/this.pixelRatio;var Qe=document.createElement("canvas");Qe.width=Y-M,Qe.height=ge-D,Qe.getContext("2d").putImageData(this.canvasContext.getImageData(M,D,Y-M,ge-D),0,0),this.drawingImgUrl=Qe.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},t.prototype.setDrawingImage=function(){$.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),$.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},t.prototype.setColor=function(s){this.color=s,this.colorChanged(s)},t.prototype.setLineWidth=function(s){this.lineWidth=s},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=Object.assign({drawingImgUrl:this.drawingImgUrl},R.prototype.getState.call(this));return s.typeName=t.typeName,s},t.prototype.restoreState=function(s){this.createVisual(),R.prototype.restoreState.call(this,s),this.drawingImgUrl=s.drawingImgUrl,this.setDrawingImage()},t.prototype.scale=function(s,A){R.prototype.scale.call(this,s,A),this.setDrawingImage()},t.typeName="FreehandMarker",t.title="Freehand marker",t.icon='<svg viewBox="0 0 24 24"><path d="M9.75 20.85c1.78-.7 1.39-2.63.49-3.85-.89-1.25-2.12-2.11-3.36-2.94A9.817 9.817 0 014.54 12c-.28-.33-.85-.94-.27-1.06.59-.12 1.61.46 2.13.68.91.38 1.81.82 2.65 1.34l1.01-1.7C8.5 10.23 6.5 9.32 4.64 9.05c-1.06-.16-2.18.06-2.54 1.21-.32.99.19 1.99.77 2.77 1.37 1.83 3.5 2.71 5.09 4.29.34.33.75.72.95 1.18.21.44.16.47-.31.47-1.24 0-2.79-.97-3.8-1.61l-1.01 1.7c1.53.94 4.09 2.41 5.96 1.79m11.09-15.6c.22-.22.22-.58 0-.79l-1.3-1.3a.562.562 0 00-.78 0l-1.02 1.02 2.08 2.08M11 10.92V13h2.08l6.15-6.15-2.08-2.08L11 10.92z"/></svg>',t}(ke),Q=function(R){function t(s,A,M){var D=R.call(this,s,M||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return D.typeBoxes=[],D.currentType=A,D.setCurrentType=D.setCurrentType.bind(D),D}return ue(t,R),t.prototype.getUi=function(){var s=this,A=document.createElement("div");A.style.display="flex",A.style.overflow="hidden",A.style.flexGrow="2";for(var M=function(ge){var Ie="both";switch(ge){case 0:Ie="both";break;case 1:Ie="start";break;case 2:Ie="end";break;case 3:Ie="none"}var ze=document.createElement("div");if(ze.style.display="flex",ze.style.flexGrow="2",ze.style.alignItems="center",ze.style.justifyContent="space-between",ze.style.padding="5px",ze.style.borderWidth="2px",ze.style.borderStyle="solid",ze.style.borderColor=Ie===D.currentType?D.uiStyleSettings.toolboxAccentColor:"transparent",ze.addEventListener("click",function(){s.setCurrentType(Ie,ze)}),A.appendChild(ze),Ie==="both"||Ie==="start"){var ye=document.createElement("div");ye.style.display="flex",ye.style.alignItems="center",ye.style.minHeight="20px",ye.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,5 10,0 10,10" fill="`+(D.uiStyleSettings!==void 0?D.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,ye.style.marginLeft="5px",ze.appendChild(ye)}var Qe=document.createElement("div");Qe.style.display="flex",Qe.style.alignItems="center",Qe.style.minHeight="20px",Qe.style.flexGrow="2";var pt=document.createElement("hr");if(pt.style.minWidth="20px",pt.style.border="0px",pt.style.borderTop="3px solid "+(D.uiStyleSettings!==void 0?D.uiStyleSettings.toolboxColor:"#eeeeee"),pt.style.flexGrow="2",Qe.appendChild(pt),ze.appendChild(Qe),Ie==="both"||Ie==="end"){var bt=document.createElement("div");bt.style.display="flex",bt.style.alignItems="center",bt.style.minHeight="20px",bt.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,0 10,5 0,10" fill="`+(D.uiStyleSettings!==void 0?D.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,bt.style.marginRight="5px",ze.appendChild(bt)}D.typeBoxes.push(ze)},D=this,Y=0;Y<4;Y++)M(Y);return A},t.prototype.setCurrentType=function(s,A){var M=this;this.currentType=s,this.typeBoxes.forEach(function(D){D.style.borderColor=D===A?M.uiStyleSettings!==void 0?M.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},t}(me),Z=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.arrowType="end",D.arrowBaseHeight=10,D.arrowBaseWidth=10,D.getArrowPoints=D.getArrowPoints.bind(D),D.setArrowType=D.setArrowType.bind(D),D.arrowTypePanel=new Q("Arrow type","end"),D.arrowTypePanel.onArrowTypeChanged=D.setArrowType,D}return ue(t,R),t.prototype.ownsTarget=function(s){return!(!R.prototype.ownsTarget.call(this,s)&&s!==this.arrow1&&s!==this.arrow2)},t.prototype.getArrowPoints=function(s,A){var M=this.arrowBaseWidth+2*this.strokeWidth,D=this.arrowBaseHeight+2*this.strokeWidth;return s-M/2+","+(A+D/2)+" "+s+","+(A-D/2)+" "+(s+M/2)+","+(A+D/2)},t.prototype.createTips=function(){this.arrow1=$.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem($.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=$.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem($.createTransform()),this.visual.appendChild(this.arrow2)},t.prototype.pointerDown=function(s,A){R.prototype.pointerDown.call(this,s,A),this.state==="creating"&&this.createTips()},t.prototype.adjustVisual=function(){if(R.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",$.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),$.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var s=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),A=this.arrow1.transform.baseVal.getItem(0);A.setRotate(s,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(A,0);var M=this.arrow2.transform.baseVal.getItem(0);M.setRotate(s+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(M,0)}},t.prototype.setArrowType=function(s){this.arrowType=s,this.adjustVisual(),this.stateChanged()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=Object.assign({arrowType:this.arrowType},R.prototype.getState.call(this));return s.typeName=t.typeName,s},t.prototype.restoreState=function(s){R.prototype.restoreState.call(this,s);var A=s;this.arrowType=A.arrowType,this.createTips(),this.adjustVisual()},t.typeName="ArrowMarker",t.title="Arrow marker",t.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',t}(Pe),j=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.fillColor=M.defaultFillColor,D.strokeWidth=0,D.fillPanel=new Te("Color",M.defaultColorSet,M.defaultFillColor),D.fillPanel.onColorChanged=D.setFillColor,D}return ue(t,R),Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=R.prototype.getState.call(this);return s.typeName=t.typeName,s},t.typeName="CoverMarker",t.title="Cover marker",t.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',t}(Ne),H=function(R){function t(s,A,M,D){var Y=R.call(this,s,D||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return Y.opacities=[],Y.opacityBoxes=[],Y.opacities=A,Y.currentOpacity=M,Y.setCurrentOpacity=Y.setCurrentOpacity.bind(Y),Y}return ue(t,R),t.prototype.getUi=function(){var s=this,A=document.createElement("div");return A.style.display="flex",A.style.overflow="hidden",A.style.flexGrow="2",A.style.justifyContent="space-between",this.opacities.forEach(function(M){var D=document.createElement("div");D.style.display="flex",D.style.alignItems="center",D.style.justifyContent="center",D.style.padding="5px",D.style.borderWidth="2px",D.style.borderStyle="solid",D.style.borderColor=M===s.currentOpacity?s.uiStyleSettings.toolboxAccentColor:"transparent",D.addEventListener("click",function(){s.setCurrentOpacity(M,D)}),A.appendChild(D);var Y=document.createElement("div");Y.innerText=100*M+"%",D.appendChild(Y),s.opacityBoxes.push(D)}),A},t.prototype.setCurrentOpacity=function(s,A){var M=this;this.currentOpacity=s,this.opacityBoxes.forEach(function(D){D.style.borderColor=D===A?M.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},t}(me),G=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.setOpacity=D.setOpacity.bind(D),D.fillColor=M.defaultHighlightColor,D.strokeWidth=0,D.opacity=M.defaultHighlightOpacity,D.fillPanel=new Te("Color",M.defaultColorSet,D.fillColor),D.fillPanel.onColorChanged=D.setFillColor,D.opacityPanel=new H("Opacity",M.defaultOpacitySteps,D.opacity),D.opacityPanel.onOpacityChanged=D.setOpacity,D}return ue(t,R),t.prototype.setOpacity=function(s){this.opacity=s,this.visual&&$.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=R.prototype.getState.call(this);return s.typeName=t.typeName,s},t.typeName="HighlightMarker",t.title="Highlight marker",t.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',t}(j),V='<svg viewBox="0 0 24 24"><path d="M19 11.5s-2 2.17-2 3.5a2 2 0 002 2 2 2 0 002-2c0-1.33-2-3.5-2-3.5M5.21 10L10 5.21 14.79 10m1.77-1.06L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.56-.59 1.53 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.59.59-1.56 0-2.12z"/></svg>',ie=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.bgColor="transparent",D.tipPosition={x:0,y:0},D.tipBase1Position={x:0,y:0},D.tipBase2Position={x:0,y:0},D.tipMoving=!1,D.color=M.defaultStrokeColor,D.bgColor=M.defaultFillColor,D.fontFamily=M.defaultFontFamily,D.defaultSize={x:100,y:30},D.setBgColor=D.setBgColor.bind(D),D.getTipPoints=D.getTipPoints.bind(D),D.positionTip=D.positionTip.bind(D),D.setTipPoints=D.setTipPoints.bind(D),D.colorPanel=new Te("Text color",M.defaultColorSet,D.color,'<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>'),D.colorPanel.onColorChanged=D.setColor,D.bgColorPanel=new Te("Fill color",M.defaultColorSet,D.bgColor,V),D.bgColorPanel.onColorChanged=D.setBgColor,D.fontFamilyPanel=new le("Font",M.defaultFontFamilies,M.defaultFontFamily),D.fontFamilyPanel.onFontChanged=D.setFont,D.tipGrip=new Ge,D.tipGrip.visual.transform.baseVal.appendItem($.createTransform()),D.controlBox.appendChild(D.tipGrip.visual),D}return ue(t,R),t.prototype.ownsTarget=function(s){return R.prototype.ownsTarget.call(this,s)||this.tipGrip.ownsTarget(s)||this.tip===s},t.prototype.createTip=function(){$.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=$.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},t.prototype.pointerDown=function(s,A){this.state==="new"&&R.prototype.pointerDown.call(this,s,A),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(A)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):R.prototype.pointerDown.call(this,s,A)},t.prototype.pointerUp=function(s){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,R.prototype.pointerUp.call(this,s);else{var A=this.state==="creating";R.prototype.pointerUp.call(this,s),this.setTipPoints(A),this.positionTip()}},t.prototype.manipulate=function(s){if(this.tipMoving){var A=this.unrotatePoint(s);this.tipPosition={x:A.x-this.manipulationStartLeft,y:A.y-this.manipulationStartTop},this.positionTip()}else R.prototype.manipulate.call(this,s)},t.prototype.setBgColor=function(s){this.bgRectangle&&this.tip&&($.setAttributes(this.bgRectangle,[["fill",s]]),$.setAttributes(this.tip,[["fill",s]])),this.bgColor=s,this.fillColorChanged(s)},t.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},t.prototype.setTipPoints=function(s){s===void 0&&(s=!1);var A=Math.min(this.height/2,15),M=this.height/5;s&&(this.tipPosition={x:A+M/2,y:this.height+20});var D=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?D<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(M=this.width/5,A=Math.min(this.width/2,15),this.tipBase1Position={x:A,y:0},this.tipBase2Position={x:A+M,y:0}):(this.tipBase1Position={x:0,y:A},this.tipBase2Position={x:0,y:A+M}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?D<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(M=this.width/5,A=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-A-M,y:0},this.tipBase2Position={x:this.width-A,y:0}):(this.tipBase1Position={x:this.width,y:A},this.tipBase2Position={x:this.width,y:A+M}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?D<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(M=this.width/5,A=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-A-M,y:this.height},this.tipBase2Position={x:this.width-A,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-A-M},this.tipBase2Position={x:this.width,y:this.height-A}):D<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(M=this.width/5,A=Math.min(this.width/2,15),this.tipBase1Position={x:A,y:this.height},this.tipBase2Position={x:A+M,y:this.height}):(this.tipBase1Position={x:0,y:this.height-A},this.tipBase2Position={x:0,y:this.height-A-M})},t.prototype.resize=function(s){R.prototype.resize.call(this,s),this.positionTip()},t.prototype.positionTip=function(){$.setAttributes(this.tip,[["points",this.getTipPoints()]]);var s=this.tipGrip.visual.transform.baseVal.getItem(0);s.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(s,0)},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),t.prototype.select=function(){this.positionTip(),R.prototype.select.call(this)},t.prototype.getState=function(){var s=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},R.prototype.getState.call(this));return s.typeName=t.typeName,s},t.prototype.restoreState=function(s){var A=s;this.bgColor=A.bgColor,this.tipPosition=A.tipPosition,R.prototype.restoreState.call(this,s),this.createTip(),this.setTipPoints()},t.prototype.scale=function(s,A){R.prototype.scale.call(this,s,A),this.tipPosition={x:this.tipPosition.x*s,y:this.tipPosition.y*A},this.positionTip()},t.typeName="CalloutMarker",t.title="Callout marker",t.icon='<svg viewBox="0 0 24 24"><path d="M4 2h16a2 2 0 012 2v12a2 2 0 01-2 2h-4l-4 4-4-4H4a2 2 0 01-2-2V4a2 2 0 012-2m0 2v12h4.83L12 19.17 15.17 16H20V4H4m2 3h12v2H6V7m0 4h10v2H6v-2z"/></svg>',t}(xe),se=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.fillColor="transparent",D.strokeColor="transparent",D.strokeWidth=0,D.strokeDasharray="",D.opacity=1,D.strokeColor=M.defaultColor,D.strokeWidth=M.defaultStrokeWidth,D.strokeDasharray=M.defaultStrokeDasharray,D.fillColor=M.defaultFillColor,D.setStrokeColor=D.setStrokeColor.bind(D),D.setFillColor=D.setFillColor.bind(D),D.setStrokeWidth=D.setStrokeWidth.bind(D),D.setStrokeDasharray=D.setStrokeDasharray.bind(D),D.setOpacity=D.setOpacity.bind(D),D.createVisual=D.createVisual.bind(D),D.strokePanel=new Te("Line color",te(M.defaultColorSet,["transparent"]),M.defaultColor),D.strokePanel.onColorChanged=D.setStrokeColor,D.fillPanel=new Te("Fill color",te(M.defaultColorSet,["transparent"]),D.fillColor,V),D.fillPanel.onColorChanged=D.setFillColor,D.strokeWidthPanel=new ee("Line width",M.defaultStrokeWidths,M.defaultStrokeWidth),D.strokeWidthPanel.onWidthChanged=D.setStrokeWidth,D.strokeStylePanel=new Be("Line style",M.defaultStrokeDasharrays,M.defaultStrokeDasharray),D.strokeStylePanel.onStyleChanged=D.setStrokeDasharray,D.opacityPanel=new H("Opacity",M.defaultOpacitySteps,D.opacity),D.opacityPanel.onOpacityChanged=D.setOpacity,D}return ue(t,R),t.prototype.ownsTarget=function(s){return!(!R.prototype.ownsTarget.call(this,s)&&s!==this.visual)},t.prototype.createVisual=function(){this.visual=$.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},t.prototype.pointerDown=function(s,A){R.prototype.pointerDown.call(this,s,A),this.state==="new"&&(this.createVisual(),this.moveVisual(s),this._state="creating")},t.prototype.manipulate=function(s){R.prototype.manipulate.call(this,s)},t.prototype.resize=function(s){R.prototype.resize.call(this,s),this.setSize()},t.prototype.setSize=function(){R.prototype.setSize.call(this),$.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},t.prototype.pointerUp=function(s){R.prototype.pointerUp.call(this,s),this.setSize()},t.prototype.setStrokeColor=function(s){this.strokeColor=s,this.visual&&$.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(s),this.stateChanged()},t.prototype.setFillColor=function(s){this.fillColor=s,this.visual&&$.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(s),this.stateChanged()},t.prototype.setStrokeWidth=function(s){this.strokeWidth=s,this.visual&&$.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},t.prototype.setStrokeDasharray=function(s){this.strokeDasharray=s,this.visual&&$.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},t.prototype.setOpacity=function(s){this.opacity=s,this.visual&&$.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},R.prototype.getState.call(this));return s.typeName=t.typeName,s},t.prototype.restoreState=function(s){var A=s;this.fillColor=A.fillColor,this.strokeColor=A.strokeColor,this.strokeWidth=A.strokeWidth,this.strokeDasharray=A.strokeDasharray,this.opacity=A.opacity,this.createVisual(),R.prototype.restoreState.call(this,s),this.setSize()},t.prototype.scale=function(s,A){R.prototype.scale.call(this,s,A),this.setSize()},t.typeName="EllipseMarker",t.title="Ellipse marker",t.icon='<svg viewBox="0 0 24 24"><path d="M12 4C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',t}(ke),ve=function(R){function t(s,A,M){return R.call(this,s,A,M)||this}return ue(t,R),Object.defineProperty(t.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),t.prototype.ownsTarget=function(s){return!(!R.prototype.ownsTarget.call(this,s)&&s!==this.tip1&&s!==this.tip2)},t.prototype.createTips=function(){this.tip1=$.createLine(this.x1-this.tipLength/2,this.y1,this.x1+this.tipLength/2,this.y1,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip1.transform.baseVal.appendItem($.createTransform()),this.visual.appendChild(this.tip1),this.tip2=$.createLine(this.x2-this.tipLength/2,this.y2,this.x2+this.tipLength/2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip2.transform.baseVal.appendItem($.createTransform()),this.visual.appendChild(this.tip2)},t.prototype.pointerDown=function(s,A){R.prototype.pointerDown.call(this,s,A),this.state==="creating"&&this.createTips()},t.prototype.adjustVisual=function(){if(R.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&($.setAttributes(this.tip1,[["x1",(this.x1-this.tipLength/2).toString()],["y1",this.y1.toString()],["x2",(this.x1+this.tipLength/2).toString()],["y2",this.y1.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),$.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var s=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),A=this.tip1.transform.baseVal.getItem(0);A.setRotate(s,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(A,0);var M=this.tip2.transform.baseVal.getItem(0);M.setRotate(s+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(M,0)}},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=R.prototype.getState.call(this);return s.typeName=t.typeName,s},t.prototype.restoreState=function(s){R.prototype.restoreState.call(this,s),this.createTips(),this.adjustVisual()},t.typeName="MeasurementMarker",t.title="Measurement marker",t.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',t}(Pe),Oe=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.strokePanel.colors=M.defaultColorSet,D.fillColor="transparent",D}return ue(t,R),Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=R.prototype.getState.call(this);return s.typeName=t.typeName,s},t.typeName="EllipseFrameMarker",t.title="Ellipse frame marker",t.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',t}(se),je=function(){function R(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(R.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),R.prototype.addUndoStep=function(t){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(t)||(this.undoStack.push(t),JSON.stringify(this.lastRedoStep)!==JSON.stringify(t)&&this.redoStack.splice(0,this.redoStack.length))},R.prototype.replaceLastUndoStep=function(t){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=t)},R.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},R.prototype.undo=function(){if(this.undoStack.length>1){var t=this.undoStack.pop();return t!==void 0&&this.redoStack.push(t),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},R.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},R}(),Me=function(R){function t(s,A,M){var D=R.call(this,s,A,M)||this;return D.strokeColor="transparent",D.strokeWidth=0,D.strokeDasharray="",D.curveX=0,D.curveY=0,D.manipulationStartCurveX=0,D.manipulationStartCurveY=0,D.setStrokeColor=D.setStrokeColor.bind(D),D.setStrokeWidth=D.setStrokeWidth.bind(D),D.setStrokeDasharray=D.setStrokeDasharray.bind(D),D.positionGrips=D.positionGrips.bind(D),D.addControlGrips=D.addControlGrips.bind(D),D.adjustVisual=D.adjustVisual.bind(D),D.setupControlBox=D.setupControlBox.bind(D),D.resize=D.resize.bind(D),D.strokeColor=M.defaultColor,D.strokeWidth=M.defaultStrokeWidth,D.strokeDasharray=M.defaultStrokeDasharray,D.strokePanel=new Te("Line color",M.defaultColorSet,M.defaultColor),D.strokePanel.onColorChanged=D.setStrokeColor,D.strokeWidthPanel=new ee("Line width",M.defaultStrokeWidths,M.defaultStrokeWidth),D.strokeWidthPanel.onWidthChanged=D.setStrokeWidth,D.strokeStylePanel=new Be("Line style",M.defaultStrokeDasharrays,M.defaultStrokeDasharray),D.strokeStylePanel.onStyleChanged=D.setStrokeDasharray,D}return ue(t,R),t.prototype.ownsTarget=function(s){return!(!R.prototype.ownsTarget.call(this,s)&&s!==this.visual&&s!==this.selectorCurve&&s!==this.visibleCurve&&!this.curveGrip.ownsTarget(s))},t.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},t.prototype.createVisual=function(){this.visual=$.createGroup(),this.selectorCurve=$.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=$.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},t.prototype.pointerDown=function(s,A){R.prototype.pointerDown.call(this,s,A),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=s.x,this.curveY=s.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(A)&&(this.activeGrip=this.curveGrip,this._state="resize")},t.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),$.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),$.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),$.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},t.prototype.setupControlBox=function(){R.prototype.setupControlBox.call(this),this.curveControlLine1=$.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=$.createLine(this.x2,this.y2,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.insertBefore(this.curveControlLine1,this.controlBox.firstChild),this.controlBox.insertBefore(this.curveControlLine2,this.controlBox.firstChild)},t.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,R.prototype.addControlGrips.call(this)},t.prototype.positionGrips=function(){R.prototype.positionGrips.call(this);var s=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-s/2,this.curveY-s/2),this.curveControlLine1&&this.curveControlLine2&&(this.curveControlLine1.setAttribute("x1",this.x1.toString()),this.curveControlLine1.setAttribute("y1",this.y1.toString()),this.curveControlLine1.setAttribute("x2",this.curveX.toString()),this.curveControlLine1.setAttribute("y2",this.curveY.toString()),this.curveControlLine2.setAttribute("x1",this.x2.toString()),this.curveControlLine2.setAttribute("y1",this.y2.toString()),this.curveControlLine2.setAttribute("x2",this.curveX.toString()),this.curveControlLine2.setAttribute("y2",this.curveY.toString()))},t.prototype.manipulate=function(s){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+s.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+s.y-this.manipulationStartY),R.prototype.manipulate.call(this,s)},t.prototype.resize=function(s){this.activeGrip===this.curveGrip&&(this.curveX=s.x,this.curveY=s.y),R.prototype.resize.call(this,s),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},t.prototype.setStrokeColor=function(s){this.strokeColor=s,this.adjustVisual(),this.colorChanged(s)},t.prototype.setStrokeWidth=function(s){this.strokeWidth=s,this.adjustVisual()},t.prototype.setStrokeDasharray=function(s){this.strokeDasharray=s,this.adjustVisual()},t.prototype.scale=function(s,A){this.curveX=this.curveX*s,this.curveY=this.curveY*A,R.prototype.scale.call(this,s,A)},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var s=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},R.prototype.getState.call(this));return s.typeName=t.typeName,s},t.prototype.restoreState=function(s){R.prototype.restoreState.call(this,s);var A=s;this.strokeColor=A.strokeColor,this.strokeWidth=A.strokeWidth,this.strokeDasharray=A.strokeDasharray,this.curveX=A.curveX,this.curveY=A.curveY,this.createVisual(),this.adjustVisual()},t.typeName="CurveMarker",t.title="Curve marker",t.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',t}(We),Xe=function(){function R(t,s){s===void 0&&(s=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=t,this.cancelable=s}return Object.defineProperty(R.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),R.prototype.preventDefault=function(){this._defaultPrevented=!0},R}(),$e=function(R){function t(s,A,M){var D=R.call(this,s,!1)||this;return D.dataUrl=A,D.state=M,D}return ue(t,R),t}(Xe),He=function(R){function t(s,A,M){M===void 0&&(M=!1);var D=R.call(this,s,M)||this;return D.marker=A,D}return ue(t,R),t}(Xe),Ze=function(){function R(){this.render=[],this.beforeclose=[],this.close=[],this.show=[],this.restorestate=[],this.statechange=[],this.markerselect=[],this.markerdeselect=[],this.markercreating=[],this.markercreate=[],this.markerbeforedelete=[],this.markerdelete=[],this.markerchange=[],this.focus=[],this.blur=[]}return R.prototype.addEventListener=function(t,s){this[t].push(s)},R.prototype.removeEventListener=function(t,s){var A=this[t].indexOf(s);A>-1&&this[t].splice(A,1)},R}(),rt=function(){function R(t){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new we,this._isOpen=!1,this.undoRedoManager=new je,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.renderMarkersOnly=!1,this.zoomSteps=[1,1.5,2,4],this._zoomLevel=1,this._isResizing=!1,this.prevPanPoint={x:0,y:0},this.eventListeners=new Ze,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=R.instanceCounter++,this.styles=new Ue(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=t,this.targetRoot=document.body,this.width=t.clientWidth,this.height=t.clientHeight,this.styles.removeStyleSheet(),this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.toolbarButtonClicked=this.toolbarButtonClicked.bind(this),this.createNewMarker=this.createNewMarker.bind(this),this.addNewMarker=this.addNewMarker.bind(this),this.markerCreated=this.markerCreated.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onDblClick=this.onDblClick.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.deleteSelectedMarker=this.deleteSelectedMarker.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.removeMarker=this.removeMarker.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this),this.onPopupTargetResize=this.onPopupTargetResize.bind(this),this.showNotesEditor=this.showNotesEditor.bind(this),this.hideNotesEditor=this.hideNotesEditor.bind(this),this.stepZoom=this.stepZoom.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.markerStateChanged=this.markerStateChanged.bind(this),this.switchToSelectMode=this.switchToSelectMode.bind(this),this.addDefs=this.addDefs.bind(this),this.addDefsToImage=this.addDefsToImage.bind(this)}return Object.defineProperty(R.prototype,"ALL_MARKER_TYPES",{get:function(){return[_e,q,Z,xe,Oe,se,G,ie,ve,j,Pe,Me]},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[_e,q,Z,xe,se,G,ie]},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"BASIC_MARKER_TYPES",{get:function(){return[_e,q,Z,xe,G]},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(t){var s=this;this._availableMarkerTypes.splice(0),t.forEach(function(A){if(typeof A=="string"){var M=s.ALL_MARKER_TYPES.find(function(D){return D.typeName===A});M!==void 0&&s._availableMarkerTypes.push(M)}else s._availableMarkerTypes.push(A)})},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(t){this._zoomLevel=t,this.editorCanvas&&this.contentDiv&&(this.editorCanvas.style.transform="scale("+this._zoomLevel+")",this.contentDiv.scrollTo({left:(this.editorCanvas.clientWidth*this._zoomLevel-this.contentDiv.clientWidth)/2,top:(this.editorCanvas.clientHeight*this._zoomLevel-this.contentDiv.clientHeight)/2}))},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),R.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),Ae.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},R.prototype.show=function(){var t=this;this.styles.styleSheetRoot===void 0&&De.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=De.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(s){return s(new Xe(t))})},R.prototype.render=function(){return de(this,void 0,void 0,function(){var t;return ce(this,function(s){switch(s.label){case 0:return this.setCurrentMarker(),(t=new Fe).naturalSize=this.renderAtNaturalSize,t.imageType=this.renderImageType,t.imageQuality=this.renderImageQuality,t.markersOnly=this.renderMarkersOnly,t.width=this.renderWidth,t.height=this.renderHeight,[4,t.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return s.sent(),[4,t.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,s.sent()]}})})},R.prototype.close=function(t){var s=this;if(t===void 0&&(t=!1),this.isOpen){var A=!1;t||this.eventListeners.beforeclose.forEach(function(M){var D=new Xe(s,!0);M(D),D.defaultPrevented&&(A=!0)}),A||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.settings.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach(function(M){return M(new Xe(s))}),this.detachEvents(),this._isOpen=!1)}},R.prototype.addMarkersToToolbar=function(){for(var t,s=[],A=0;A<arguments.length;A++)s[A]=arguments[A];(t=this._availableMarkerTypes).push.apply(t,s)},R.prototype.addRenderEventListener=function(t){this.addEventListener("render",function(s){t(s.dataUrl,s.state)})},R.prototype.removeRenderEventListener=function(t){},R.prototype.addCloseEventListener=function(t){this.addEventListener("close",function(){t()})},R.prototype.removeCloseEventListener=function(t){},R.prototype.setupResizeObserver=function(){var t=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){t.resize(t.target.clientWidth,t.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return t.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},R.prototype.onPopupTargetResize=function(){var t=1*this.target.clientWidth/this.target.clientHeight,s=this.editorCanvas.clientWidth/t>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*t:this.editorCanvas.clientWidth,A=s<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/t;this.resize(s,A)},R.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},R.prototype.resize=function(t,s){this._isResizing=!0;var A=t/this.imageWidth,M=s/this.imageHeight;this.imageWidth=Math.round(t),this.imageHeight=Math.round(s),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px",this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.settings.displayMode!=="popup"?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),this.toolbar!==void 0&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(A,M),this._isResizing=!1},R.prototype.scaleMarkers=function(t,s){var A,M=this;this._currentMarker&&this._currentMarker instanceof xe?this._currentMarker.scale(t,s):(A=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(D){D!==M._currentMarker&&D.scale(t,s)}),A!==void 0&&this.setCurrentMarker(A)},R.prototype.setEditingTarget=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px"},R.prototype.setTopLeft=function(){var t=this.editingTarget.getBoundingClientRect(),s=this.editorCanvas.getBoundingClientRect();this.left=t.left-s.left,this.top=t.top-s.top},R.prototype.initMarkerCanvas=function(){this.markerImageHolder=document.createElement("div"),this.markerImageHolder.style.setProperty("touch-action","pinch-zoom"),this.markerImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.markerImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImage.style.pointerEvents="auto",this.markerImageHolder.style.position="absolute",this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.markerImageHolder.style.transformOrigin="top left",this.positionMarkerImage(),this.markerImageHolder.appendChild(this.markerImage),this.editorCanvas.appendChild(this.markerImageHolder)},R.prototype.addDefs=function(){for(var t,s=[],A=0;A<arguments.length;A++)s[A]=arguments[A];this.defs=$.createDefs(),this.addDefsToImage(),(t=this.defs).append.apply(t,s)},R.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},R.prototype.initOverlay=function(){this.overlayContainer=document.createElement("div"),this.overlayContainer.style.position="absolute",this.overlayContainer.style.left="0px",this.overlayContainer.style.top="0px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.overlayContainer.style.display="flex",this.markerImageHolder.appendChild(this.overlayContainer)},R.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},R.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},R.prototype.attachWindowEvents=function(){window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("pointerout",this.onPointerOut),window.addEventListener("pointerleave",this.onPointerUp),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keyup",this.onKeyUp)},R.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},R.prototype.detachWindowEvents=function(){window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("pointerout",this.onPointerOut),window.removeEventListener("pointerleave",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keyup",this.onKeyUp)},R.prototype.addLogo=function(){this.logoUI=document.createElement("div"),this.logoUI.style.display="inline-block",this.logoUI.style.margin="0px",this.logoUI.style.padding="0px",this.logoUI.style.fill="#333333";var t=document.createElement("a");t.href="https://markerjs.com/",t.target="_blank",t.innerHTML='<svg viewBox="0 0 112 96" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path fill="#e5f20d" fill-opacity=".647" d="M0 40.386h111.96V95.62H0z"/><path d="M93.61 61.452c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.591 1.048-1.481 0-2.222-.74-2.222-2.22 0-16.617-.533-29.347-1.604-38.192-1.068-8.842-2.92-13.265-5.552-13.265-4.443 0-10.94 15.509-19.497 46.52v.124c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.592 1.048-1.48 0-2.22-.74-2.22-2.22 0-3.29.165-8.392.493-15.302.33-7.732.494-13.82.494-18.262 0-6.17-.186-10.55-.556-13.142-.37-2.591-1.172-3.887-2.406-3.887-2.796 0-6.333 5.12-10.612 15.363C38.494 34.367 34.01 46.44 29.32 60.34l-1.11 3.209a5.714 5.714 0 01-1.42 2.097c-.617.578-1.295.864-2.036.864-.987 0-1.644-.081-1.974-.247-.328-.162-.533-.656-.617-1.48-.41-4.03-.74-9.418-.987-16.165-.163-1.728-.329-4.566-.494-8.515-.822-13.901-1.562-23.3-2.221-28.196-.657-4.893-.987-7.628-.987-8.205 0-.657.33-1.44.987-2.345.659-.903 1.276-1.357 1.85-1.357 1.319 0 2.387.947 3.21 2.838.411.906.863 4.526 1.357 10.859.493 6.335.905 14.19 1.233 23.568l.617 18.88c4.527-13.983 9.216-26.673 14.068-38.068C45.65 6.686 50.093.988 54.123.988c2.715 0 4.566 1.974 5.553 5.923.987 3.949 1.481 9.667 1.481 17.152 0 3.949-.081 9.625-.247 17.029l-.123 5.676c3.373-11.762 6.725-21.634 10.057-29.615 3.331-7.979 6.685-11.97 10.056-11.97 8.475 0 12.71 18.757 12.71 56.269z" fill-rule="nonzero"/></svg>',t.title="Powered by marker.js",t.style.display="grid",t.style.alignItems="center",t.style.justifyItems="center",t.style.padding="3px",t.style.width="20px",t.style.height="20px",this.logoUI.appendChild(t),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},R.prototype.positionLogo=function(){this.logoUI&&(this.uiStyleSettings.logoPosition!=="right"?this.logoUI.style.left=this.markerImageHolder.offsetLeft+10+"px":this.logoUI.style.left=this.markerImageHolder.offsetLeft+this.markerImageHolder.offsetWidth-this.logoUI.clientWidth-10+"px",this.logoUI.style.top=this.markerImageHolder.offsetTop+this.markerImageHolder.offsetHeight-this.logoUI.clientHeight-10+"px")},R.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},R.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},R.prototype.showUI=function(){switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var t=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=t+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new Ce(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new Se(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},R.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},R.prototype.removeMarker=function(t){this.markerImage.removeChild(t.container),this.markers.indexOf(t)>-1&&this.markers.splice(this.markers.indexOf(t),1),t.dispose()},R.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),this._currentMarker!==void 0&&(this._currentMarker.state!=="new"?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},R.prototype.toolbarButtonClicked=function(t,s){if(t==="marker"&&s!==void 0)this.createNewMarker(s);else if(t==="action")switch(s){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},R.prototype.deleteSelectedMarker=function(){var t=this;if(this._currentMarker!==void 0){var s=!1;if(this.eventListeners.markerbeforedelete.forEach(function(M){var D=new He(t,t._currentMarker,!0);M(D),D.defaultPrevented&&(s=!0)}),!s){var A=this._currentMarker;this._currentMarker.dispose(),this.markerImage.removeChild(this._currentMarker.container),this.markers.splice(this.markers.indexOf(this._currentMarker),1),this.setCurrentMarker(),this.addUndoStep(),this.eventListeners.markerdelete.forEach(function(M){return M(new He(t,A))})}}},R.prototype.clear=function(){var t=this,s=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(Y){var ge=new He(t,void 0,!0);Y(ge),ge.defaultPrevented&&(s=!0)}),!s)){this.setCurrentMarker();for(var A=function(Y){var ge=M.markers[Y];M.setCurrentMarker(M.markers[Y]),M._currentMarker.dispose(),M.markerImage.removeChild(M._currentMarker.container),M.markers.splice(M.markers.indexOf(M._currentMarker),1),M.eventListeners.markerdelete.forEach(function(Ie){return Ie(new He(t,ge))})},M=this,D=this.markers.length-1;D>=0;D--)A(D);this.addUndoStep()}},Object.defineProperty(R.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),R.prototype.showNotesEditor=function(){var t;this._currentMarker!==void 0&&(this.overlayContainer.innerHTML="",this.notesArea=document.createElement("textarea"),this.notesArea.className=this.uiStyleSettings.notesAreaStyleClassName,this.notesArea.style.pointerEvents="auto",this.notesArea.style.alignSelf="stretch",this.notesArea.style.width="100%",this.notesArea.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.notesArea.value=(t=this._currentMarker.notes)!==null&&t!==void 0?t:"",this.overlayContainer.appendChild(this.notesArea))},R.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(this._currentMarker!==void 0&&(this._currentMarker.notes=this.notesArea.value.trim()!==""?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},R.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},R.prototype.addUndoStep=function(){var t=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var s=this.getState(),A=this.undoRedoManager.getLastUndoStep();if(!A||A.width===s.width&&A.height===s.height){var M=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(s),M<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(D){return D(new Xe(t))})}else this.undoRedoManager.replaceLastUndoStep(s),this.eventListeners.statechange.forEach(function(D){return D(new Xe(t))})}},R.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},R.prototype.undoStep=function(){var t=this,s=this.undoRedoManager.undo();s!==void 0&&(this.restoreState(s),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(A){return A(new Xe(t))}))},R.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},R.prototype.redoStep=function(){var t=this,s=this.undoRedoManager.redo();s!==void 0&&(this.restoreState(s),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(A){return A(new Xe(t))}))},R.prototype.stepZoom=function(){var t=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=t<this.zoomSteps.length-1?this.zoomSteps[t+1]:this.zoomSteps[0]},R.prototype.panTo=function(t){this.contentDiv.scrollBy({left:this.prevPanPoint.x-t.x,top:this.prevPanPoint.y-t.y}),this.prevPanPoint=t},R.prototype.startRenderAndClose=function(){return de(this,void 0,void 0,function(){var t,s,A=this;return ce(this,function(M){switch(M.label){case 0:return[4,this.render()];case 1:return t=M.sent(),s=this.getState(),this.eventListeners.render.forEach(function(D){return D(new $e(A,t,s))}),this.close(!0),[2]}})})},R.prototype.getState=function(t){t===!0&&this.setCurrentMarker();var s={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(A){return s.markers.push(A.getState())}),s},R.prototype.restoreState=function(t){var s=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);t.markers.forEach(function(A){var M=s._availableMarkerTypes.find(function(Y){return Y.typeName===A.typeName});if(M!==void 0){var D=s.addNewMarker(M);D.restoreState(A),s.markers.push(D)}}),t.width&&t.height&&(t.width!==this.imageWidth||t.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/t.width,this.imageHeight/t.height),this.eventListeners.restorestate.forEach(function(A){return A(new Xe(s))})},R.prototype.addNewMarker=function(t){var s=$.createGroup();return this.markerImage.appendChild(s),new t(s,this.overlayContainer,this.settings)},R.prototype.createNewMarker=function(t){var s,A=this;(s=typeof t=="string"?this._availableMarkerTypes.find(function(M){return M.typeName===t}):t)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(s),this._currentMarker.onMarkerCreated=this.markerCreated,this._currentMarker.onColorChanged=this.colorChanged,this._currentMarker.onFillColorChanged=this.fillColorChanged,this._currentMarker.onStateChanged=this.markerStateChanged,this.markerImage.style.cursor="crosshair",this.toolbar.setActiveMarkerButton(s.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(M){return M(new He(A,A._currentMarker))}))},R.prototype.markerCreated=function(t){var s=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(t),this.setCurrentMarker(t),t instanceof q&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(q):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(A){return A(new He(s,s._currentMarker))})},R.prototype.colorChanged=function(t){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=t,this.settings.defaultStrokeColor=t)},R.prototype.fillColorChanged=function(t){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=t)},R.prototype.markerStateChanged=function(t){var s=this;this.eventListeners.markerchange.forEach(function(A){return A(new He(s,t))})},R.prototype.setCurrentMarker=function(t){var s=this;this._currentMarker!==t&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(A){return A(new He(s,s._currentMarker))})),this._currentMarker=t,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(A){return A(new He(s,s._currentMarker))}))},R.prototype.onPointerDown=function(t){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||t.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var s=this.markers.find(function(A){return A.ownsTarget(t.target)});s!==void 0?(this.setCurrentMarker(s),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(t.clientX,t.clientY),t.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:t.clientX,y:t.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(t.clientX,t.clientY))},R.prototype.onDblClick=function(t){if(this._isFocused||this.focus(),this.mode==="select"){var s=this.markers.find(function(A){return A.ownsTarget(t.target)});s!==void 0&&s!==this._currentMarker&&this.setCurrentMarker(s),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(t.clientX,t.clientY),t.target):this.setCurrentMarker()}},R.prototype.onPointerMove=function(t){this.touchPoints!==1&&t.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||t.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(t.clientX,t.clientY)):this.zoomLevel>1&&this.panTo({x:t.clientX,y:t.clientY}))},R.prototype.onPointerUp=function(t){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(t.clientX,t.clientY)),this.isDragging=!1,this.addUndoStep()},R.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},R.prototype.onKeyUp=function(t){this._currentMarker===void 0||this.notesArea!==void 0||t.key!=="Delete"&&t.key!=="Backspace"||this.deleteSelectedMarker()},R.prototype.clientToLocalCoordinates=function(t,s){var A=this.markerImage.getBoundingClientRect();return{x:(t-A.left)/this.zoomLevel,y:(s-A.top)/this.zoomLevel}},R.prototype.onWindowResize=function(){this.positionUI()},R.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var t=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=t+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.styles.settings.toolbarHeight+"px"}this.positionMarkerImage(),this.positionLogo()},R.prototype.addLicenseKey=function(t){Ae.addKey(t)},R.prototype.addEventListener=function(t,s){this.eventListeners.addEventListener(t,s)},R.prototype.removeEventListener=function(t,s){this.eventListeners.removeEventListener(t,s)},R.prototype.renderState=function(t){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(t),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(R.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),R.prototype.focus=function(){var t=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(s){return s(new Xe(t))}))},R.prototype.blur=function(){var t=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(s){return s(new Xe(t))}))},R.instanceCounter=0,R}();/* **********************************
|
|
cropro version 1.2.0
|
|
@license SEE LICENSE IN LICENSE
|
|
|
|
copyright Alan Mendelevich
|
|
see README and LICENSE for details
|
|
********************************** *//*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var lt=function(R,t){return(lt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,A){s.__proto__=A}||function(s,A){for(var M in A)Object.prototype.hasOwnProperty.call(A,M)&&(s[M]=A[M])})(R,t)};function Ye(R,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function s(){this.constructor=R}lt(R,t),R.prototype=t===null?Object.create(t):(s.prototype=t.prototype,new s)}function it(R,t,s,A){return new(s||(s=Promise))(function(M,D){function Y(ze){try{Ie(A.next(ze))}catch(ye){D(ye)}}function ge(ze){try{Ie(A.throw(ze))}catch(ye){D(ye)}}function Ie(ze){var ye;ze.done?M(ze.value):(ye=ze.value,ye instanceof s?ye:new s(function(Qe){Qe(ye)})).then(Y,ge)}Ie((A=A.apply(R,t||[])).next())})}function mt(R,t){var s,A,M,D,Y={label:0,sent:function(){if(1&M[0])throw M[1];return M[1]},trys:[],ops:[]};return D={next:ge(0),throw:ge(1),return:ge(2)},typeof Symbol=="function"&&(D[Symbol.iterator]=function(){return this}),D;function ge(Ie){return function(ze){return function(ye){if(s)throw new TypeError("Generator is already executing.");for(;Y;)try{if(s=1,A&&(M=2&ye[0]?A.return:ye[0]?A.throw||((M=A.return)&&M.call(A),0):A.next)&&!(M=M.call(A,ye[1])).done)return M;switch(A=0,M&&(ye=[2&ye[0],M.value]),ye[0]){case 0:case 1:M=ye;break;case 4:return Y.label++,{value:ye[1],done:!1};case 5:Y.label++,A=ye[1],ye=[0];continue;case 7:ye=Y.ops.pop(),Y.trys.pop();continue;default:if(!(M=Y.trys,(M=M.length>0&&M[M.length-1])||ye[0]!==6&&ye[0]!==2)){Y=0;continue}if(ye[0]===3&&(!M||ye[1]>M[0]&&ye[1]<M[3])){Y.label=ye[1];break}if(ye[0]===6&&Y.label<M[1]){Y.label=M[1],M=ye;break}if(M&&Y.label<M[2]){Y.label=M[2],Y.ops.push(ye);break}M[2]&&Y.ops.pop(),Y.trys.pop();continue}ye=t.call(R,Y)}catch(Qe){ye=[6,Qe],A=0}finally{s=M=0}if(5&ye[0])throw ye[1];return{value:ye[0]?ye[1]:void 0,done:!0}}([Ie,ze])}}}var kt=function(){function R(){}return R.addKey=function(t){R.key=t},Object.defineProperty(R,"isLicensed",{get:function(){return!!R.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(R.key)},enumerable:!1,configurable:!0}),R}(),Ve=function(){function R(){}return R.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},R.setAttributes=function(t,s){for(var A=0,M=s;A<M.length;A++){var D=M[A],Y=D[0],ge=D[1];t.setAttribute(Y,ge)}},R.createRect=function(t,s,A){var M=document.createElementNS("http://www.w3.org/2000/svg","rect");return M.setAttribute("width",t.toString()),M.setAttribute("height",s.toString()),A&&R.setAttributes(M,A),M},R.createLine=function(t,s,A,M,D){var Y=document.createElementNS("http://www.w3.org/2000/svg","line");return Y.setAttribute("x1",t.toString()),Y.setAttribute("y1",s.toString()),Y.setAttribute("x2",A.toString()),Y.setAttribute("y2",M.toString()),D&&R.setAttributes(Y,D),Y},R.createPolygon=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg","polygon");return A.setAttribute("points",t),s&&R.setAttributes(A,s),A},R.createCircle=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg","circle");return A.setAttribute("cx",(t/2).toString()),A.setAttribute("cy",(t/2).toString()),A.setAttribute("r",t.toString()),s&&R.setAttributes(A,s),A},R.createEllipse=function(t,s,A){var M=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return M.setAttribute("cx",(t/2).toString()),M.setAttribute("cy",(s/2).toString()),M.setAttribute("rx",(t/2).toString()),M.setAttribute("ry",(s/2).toString()),A&&R.setAttributes(M,A),M},R.createGroup=function(t){var s=document.createElementNS("http://www.w3.org/2000/svg","g");return t&&R.setAttributes(s,t),s},R.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},R.createMarker=function(t,s,A,M,D,Y,ge){var Ie=document.createElementNS("http://www.w3.org/2000/svg","marker");return R.setAttributes(Ie,[["id",t],["orient",s],["markerWidth",A.toString()],["markerHeight",M.toString()],["refX",D.toString()],["refY",Y.toString()]]),Ie.appendChild(ge),Ie},R.createText=function(t){var s=document.createElementNS("http://www.w3.org/2000/svg","text");return s.setAttribute("x","0"),s.setAttribute("y","0"),t&&R.setAttributes(s,t),s},R.createTSpan=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg","tspan");return A.textContent=t,s&&R.setAttributes(A,s),A},R.createImage=function(t){var s=document.createElementNS("http://www.w3.org/2000/svg","image");return t&&R.setAttributes(s,t),s},R.createPoint=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return A.x=t,A.y=s,A},R.createPath=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg","path");return A.setAttribute("d",t),s&&R.setAttributes(A,s),A},R.createElement=function(t,s){var A=document.createElementNS("http://www.w3.org/2000/svg",t);return s&&R.setAttributes(A,s),A},R.getHollowRectanglePath=function(t,s,A,M,D,Y,ge,Ie){return"M"+t+","+s+"V"+(s+M)+"H"+(t+A)+"V"+s+"H"+D+"V"+Y+"H"+(D+ge)+"V"+(Y+Ie)+"H"+D+"V"+s+"Z"},R}(),Ct=function(){function R(t){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+t+"_"}return Object.defineProperty(R.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#333333",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarBackgroundActiveColor:"#282828",toolbarColor:"#eeeeee",cropShadeColor:"#ffffff",cropFrameColor:"#ffffff",gripColor:"#333333",gripFillColor:"#cccccc",toolbarHeight:40}},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),R.prototype.addClass=function(t){return this.styleSheet===void 0&&this.addStyleSheet(),t.name=""+this.classNamePrefix+t.localName,this.classes.push(t),this.styleSheet.sheet.insertRule("."+t.name+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length),t},R.prototype.addRule=function(t){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(t),this.styleSheet.sheet.insertRule(t.selector+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length)},R.prototype.addStyleSheet=function(){var t;this.styleSheet=document.createElement("style"),((t=this.styleSheetRoot)!==null&&t!==void 0?t:document.head).appendChild(this.styleSheet),this.addRule(new At("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new At("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new At("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new st("_fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new st("_fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},R.prototype.removeStyleSheet=function(){var t;this.styleSheet&&(((t=this.styleSheetRoot)!==null&&t!==void 0?t:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},R}(),At=function(R,t){this.selector=R,this.style=t},st=function(R,t){this.localName=R,this.style=t},nt=function(){function R(){this.blocks=[],this.display=""}return R.prototype.addButtonBlock=function(t){t.className=this.blockClassName,t.buttonClassName=this.buttonClassName,t.buttonColorsClassName=this.buttonColorsClassName,t.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(t)},R.prototype.addElementBlock=function(t){t.className===void 0&&(t.className=this.blockClassName),this.blocks.push(t)},R.prototype.getUI=function(){var t=document.createElement("div");return t.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,t.style.display=this.display,this.blocks.forEach(function(s){return t.appendChild(s.getUI())}),t},R}(),ot=function(){function R(){}return R.prototype.getUI=function(){var t=document.createElement("div");if(t.className=this.className,this.minWidth!==void 0&&(t.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":t.style.justifyContent="flex-start";break;case"center":t.style.justifyContent="center";break;case"end":t.style.justifyContent="flex-end"}return t.style.whiteSpace="nowrap",t},R}(),Et=function(R){function t(){var s=R!==null&&R.apply(this,arguments)||this;return s.buttons=[],s}return Ye(t,R),t.prototype.addButton=function(s){s.className=this.buttonClassName,s.colorsClassName=this.buttonColorsClassName,s.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(s)},t.prototype.getUI=function(){var s=R.prototype.getUI.call(this);return this.buttons.forEach(function(A){return s.appendChild(A.getUI())}),s},t}(ot),qe=function(){function R(t,s){this._isActive=!1,this._isHidden=!1,this._icon=t,this.title=s,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(R.prototype,"icon",{get:function(){return this._icon},set:function(t){this._icon=t,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isActive",{get:function(){return this._isActive},set:function(t){this._isActive=t,this.adjustClassName()},enumerable:!1,configurable:!0}),R.prototype.getUI=function(){var t=this;return this.buttonContainer=document.createElement("div"),this.buttonContainer.title=this.title,this.buttonContainer.className=this.className+" "+this.colorsClassName,this.adjustClassName(),this.buttonContainer.innerHTML=this._icon,this.onClick&&this.buttonContainer.addEventListener("click",function(){return t.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},R.prototype.adjustClassName=function(){this.activeColorsClassName&&(this._isActive&&this.buttonContainer.className.indexOf(this.activeColorsClassName)<0?this.buttonContainer.className+=" "+this.activeColorsClassName:this._isActive||(this.buttonContainer.className=this.buttonContainer.className.replace(this.activeColorsClassName,"")))},R.prototype.hide=function(){this._isHidden=!0},R}(),Je=function(R){function t(){var s=R!==null&&R.apply(this,arguments)||this;return s.elements=[],s}return Ye(t,R),t.prototype.addElement=function(s){this.elements.push(s)},t.prototype.getUI=function(){var s=R.prototype.getUI.call(this);return this.elements.forEach(function(A){return s.appendChild(A)}),s},t}(ot),et=function(){function R(t,s){this.horizontal=t,this.vertical=s}return Object.defineProperty(R.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),R.prototype.getVerticalLength=function(t){return t/this.ratio},R.prototype.getHorizontalLength=function(t){return t*this.ratio},R}(),ct=function(){function R(){}return R.getIcon=function(t,s){if(t>0&&s>0){var A=new et(t,s),M=A.ratio>=1?20:A.getHorizontalLength(20),D=A.ratio<1?20:A.getVerticalLength(20),Y=document.createElementNS("http://www.w3.org/2000/svg","svg");Y.setAttribute("xmlns","http://www.w3.org/2000/svg"),Y.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(Y);var ge=Ve.createDefs();Y.appendChild(ge);var Ie=Ve.createElement("clipPath",[["id","text-bg-clip"]]);ge.appendChild(Ie);var ze=Ve.createPath(Ve.getHollowRectanglePath((24-M)/2,(24-D)/2,M,D,(24-M)/2+2,(24-D)/2+2,M-4,D-4));Y.appendChild(ze);var ye=Ve.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);ye.appendChild(Ve.createTSpan(t+":"+s)),Y.appendChild(ye);var Qe=ye.getBBox();Ve.setAttributes(ye,[["x",((24-Qe.width)/2).toString()],["y",((24-Qe.height)/2-Qe.y).toString()]]);var pt=Ve.createPath(Ve.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Qe.width))/2,(24-Math.ceil(Qe.height))/2,Math.ceil(Qe.width),Math.ceil(Qe.height)));return Ie.appendChild(pt),Ve.setAttributes(ze,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(Y),Y.outerHTML}return'<svg viewBox="0 0 24 24"><path d="M19 12h-2v3h-3v2h5v-5M7 9h3V7H5v5h2V9m14-6H3a2 2 0 00-2 2v14a2 2 0 002 2h18a2 2 0 002-2V5a2 2 0 00-2-2m0 16H3V5h18v14z"/></svg>'},R}(),yt=function(R){function t(s,A,M){var D=R.call(this,s,A)||this;return D.isDropdownOpen=!1,D.onClick=D.dropdownButtonClicked,D.dropdownButtons=M,D}return Ye(t,R),t.prototype.setupDropdown=function(){var s=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(A){A.className=s.className,A.colorsClassName=s.colorsClassName,s.dropdownBlock.appendChild(A.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},t.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},t.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},t.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},t.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},t.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},t}(qe),wt=function(){function R(t,s){this.GRIP_SIZE=10,this.color=t,this.fillColor=s,this.visual=Ve.createGroup(),this.visual.appendChild(Ve.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Ve.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return R.prototype.ownsTarget=function(t){return t===this.visual||t===this.visual.childNodes[0]||t===this.visual.childNodes[1]},R.prototype.setCenter=function(t,s){this.visual.childNodes.forEach(function(A){return Ve.setAttributes(A,[["cx",t.toString()],["cy",s.toString()]])})},R}(),ut=function(){function R(t,s,A,M){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=t,this.canvasHeight=s,this.margin=A,this.container=M,this.attachEvents=this.attachEvents.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.resize=this.resize.bind(this),this.adjustCropRect=this.adjustCropRect.bind(this),this.scaleCanvas=this.scaleCanvas.bind(this),this.getRescaledRect=this.getRescaledRect.bind(this)}return Object.defineProperty(R.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(t){this._aspectRatio=t,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(t){this._isGridVisible=t,this.gridContainer&&Ve.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(t){this._zoomFactor=t,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),R.prototype.open=function(){var t=this;this.cropShadeElement=Ve.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=Ve.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var s=0;s<this.numberOfGridLines;s++)this.horizontalGridLines.push(Ve.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(Ve.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(A){return t.gridContainer.appendChild(A)}),this.verticalGridLines.forEach(function(A){return t.gridContainer.appendChild(A)}),this.cropRectElement=Ve.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new wt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new wt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new wt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new wt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},R.prototype.setCropRectangle=function(t){this.cropRect=t;var s=Object.assign({},this.cropRect);this.zoomFactor!==1&&(s.width=this.cropRect.width*this.zoomFactor,s.height=this.cropRect.height*this.zoomFactor,s.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-s.width/2,s.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-s.height/2),Ve.setAttributes(this.cropRectElement,[["x",s.x.toString()],["y",s.y.toString()],["width",s.width.toString()],["height",s.height.toString()]]);var A=s.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(D,Y){var ge=s.y+A*(Y+1);Ve.setAttributes(D,[["x1",""+s.x],["y1",""+ge],["x2",""+(s.x+s.width)],["y2",""+ge]])});var M=s.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(D,Y){var ge=s.x+M*(Y+1);Ve.setAttributes(D,[["x1",""+ge],["y1",""+s.y],["x2",""+ge],["y2",""+(s.y+s.height)]])}),Ve.setAttributes(this.cropShadeElement,[["d",Ve.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,s.x,s.y,s.width,s.height)]]),this.topLeftGrip.setCenter(s.x,s.y),this.topRightGrip.setCenter(s.x+s.width,s.y),this.bottomLeftGrip.setCenter(s.x,s.y+s.height),this.bottomRightGrip.setCenter(s.x+s.width,s.y+s.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},R.prototype.attachEvents=function(){this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp)},R.prototype.clientToLocalCoordinates=function(t,s){var A=this.container.getBoundingClientRect();return{x:t-A.left+this.margin,y:s-A.top+this.margin}},R.prototype.onPointerDown=function(t){this.container.setPointerCapture(t.pointerId),this.previousPoint=this.clientToLocalCoordinates(t.clientX,t.clientY),this.cropRectElement===t.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(t.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(t.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(t.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(t.target)&&(this.activeGrip=this.bottomRightGrip)},R.prototype.onPointerMove=function(t){if(this.isMoving)this.move(this.clientToLocalCoordinates(t.clientX,t.clientY));else if(this.activeGrip){var s=this.clientToLocalCoordinates(t.clientX,t.clientY);this.resize(s)}t.preventDefault()},R.prototype.onPointerUp=function(t){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(t.pointerId)},R.prototype.move=function(t){var s=t.x-this.previousPoint.x,A=t.y-this.previousPoint.y;this.zoomFactor!==1&&(s=-s/this.zoomFactor,A=-A/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+s),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+A),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=t},R.prototype.resize=function(t){var s=Object.assign({},this.cropRect),A=t.x-this.previousPoint.x,M=t.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:s.x+A<this.margin&&(A=this.margin-s.x),s.x+=A,s.width=this.cropRect.x+this.cropRect.width-s.x;break;case this.bottomRightGrip:case this.topRightGrip:s.width+A>this.canvasWidth*this.zoomFactor&&(A=this.canvasWidth*this.zoomFactor-s.width),s.width+=A}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(s.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(A),s.height=this.aspectRatio.getVerticalLength(s.width)):(s.y+=M,s.height=this.cropRect.y+this.cropRect.height-s.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?s.height=this.aspectRatio.getVerticalLength(s.width):s.height+=M}s.width<10&&(s.x=this.cropRect.x,s.width=10),s.height<10&&(s.y=this.cropRect.y,s.height=10),this.previousPoint=t,s.x>=this.margin&&s.y>=this.margin&&s.x-this.margin+s.width<=this.canvasWidth&&s.y-this.margin+s.height<=this.canvasHeight&&(this.cropRect=s,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},R.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var t=this.cropRect.x+this.cropRect.width/2,s=this.cropRect.y+this.cropRect.height/2,A=this.aspectRatio.getHorizontalLength(this.cropRect.height),M=this.aspectRatio.getVerticalLength(this.cropRect.width);A/this.canvasWidth<M/this.canvasHeight?this.cropRect.width=A:this.cropRect.height=M,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=t-this.cropRect.width/2,this.cropRect.y=s-this.cropRect.height/2,this.cropRect.x+this.cropRect.width>this.margin+this.canvasWidth&&(this.cropRect.x=this.margin+this.canvasWidth-this.cropRect.width),this.cropRect.y+this.cropRect.height>this.margin+this.canvasHeight&&(this.cropRect.y=this.margin+this.canvasHeight-this.cropRect.height),this.cropRect.x=Math.max(this.cropRect.x,this.margin),this.cropRect.y=Math.max(this.cropRect.y,this.margin)}},R.prototype.getRescaledRect=function(t,s,A,M,D,Y){var ge=A/t,Ie=M/s;return{x:(D.x-Y)*ge+Y,y:(D.y-Y)*Ie+Y,width:D.width*ge,height:D.height*Ie}},R.prototype.scaleCanvas=function(t,s){var A=this.getRescaledRect(this.canvasWidth,this.canvasHeight,t,s,this.cropRect,this.margin);this.canvasWidth=t,this.canvasHeight=s,this.onCropChange&&this.onCropChange(A),this.setCropRectangle(A)},R}(),Ot=function(){function R(t){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=t,this.uiContainer=document.createElement("div"),this.getUI=this.getUI.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.setAngleLabel=this.setAngleLabel.bind(this),this.positionScaleShape=this.positionScaleShape.bind(this)}return Object.defineProperty(R.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),R.prototype.getUI=function(){return this.controlContainer=document.createElement("div"),this.controlContainer.title=this.title,this.controlContainer.className=this.className+" "+this.colorsClassName,this.controlContainer.appendChild(this.getVisual()),this.controlContainer.addEventListener("pointerdown",this.onPointerDown),this.controlContainer.addEventListener("pointermove",this.onPointerMove),this.controlContainer.addEventListener("pointerup",this.onPointerUp),this.uiContainer.appendChild(this.controlContainer),this.uiContainer.style.display="inline-block",this.uiContainer.style.touchAction="none",this.setAngleLabel(),this.positionScaleShape(),this.uiContainer},R.prototype.onPointerDown=function(t){this.controlContainer.setPointerCapture(t.pointerId),this.isDragging=!0,this.previousPoint={x:t.clientX,y:t.clientY}},R.prototype.onPointerMove=function(t){this.isDragging&&(this.onAngleChange&&this.onAngleChange((t.clientX-this.previousPoint.x)/5),this.previousPoint.x=t.clientX)},R.prototype.onPointerUp=function(t){this.isDragging&&this.onAngleChange&&this.onAngleChange((t.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(t.pointerId)},R.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var t=this.angleLabelText.getBBox();Ve.setAttributes(this.angleLabelElement,[["x",((this.width-t.width)/2).toString()],["y",(this.height/2).toString()]])}},R.prototype.positionScaleShape=function(){if(this.scaleShape){var t=this.scaleShape.transform.baseVal.getItem(0);t.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(t,0)}},R.prototype.getVisual=function(){var t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("width",this.width+"px"),t.setAttribute("height",this.height+"px"),t.setAttribute("viewBox","0 0 "+this.width+" "+this.height),t.style.flexShrink="0",document.body.appendChild(t);for(var s="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,A=1;A<=this.width/5+10;A++){var M=A%5==0?this.height/3:this.height/6;s+="h4v"+-M+"h1v"+M}s+="v1H0Z",this.scaleShape=Ve.createPath(s);var D=Ve.createTransform();this.scaleShape.transform.baseVal.appendItem(D),t.appendChild(this.scaleShape),this.angleLabelElement=Ve.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=Ve.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var Y=Ve.createTSpan("");return Y.innerHTML="°",this.angleLabelElement.appendChild(Y),t.appendChild(this.angleLabelElement),document.body.removeChild(t),t},R}(),_t=function(){function R(){this.naturalSize=!1,this.imageType="image/png"}return R.prototype.rasterize=function(t,s,A,M,D,Y,ge){var Ie=this;return new Promise(function(ze){var ye=document.createElement("canvas");ye.width=t.width.baseVal.value-2*M,ye.height=t.height.baseVal.value-2*M;var Qe=1,pt=1;Ie.naturalSize===!0?(Qe=s.naturalWidth/(t.width.baseVal.value-2*M)/Y,pt=s.naturalHeight/(t.height.baseVal.value-2*M)/ge,ye.width=s.naturalWidth/Y,ye.height=s.naturalHeight/ge):Ie.width!==void 0&&Ie.height!==void 0&&(Qe=Ie.width/A.width,pt=Ie.height/A.height,ye.width*=Qe,ye.height*=pt);var bt=ye.getContext("2d");bt.translate(ye.width/2,ye.height/2),bt.rotate(D*Math.PI/180),bt.scale(Y,ge),bt.translate(-ye.width/2,-ye.height/2),bt.drawImage(s,0,0,ye.width,ye.height);var Mt=document.createElement("canvas");Mt.width=A.width*Qe,Mt.height=A.height*pt,Mt.getContext("2d").putImageData(bt.getImageData((A.x-M)*Qe,(A.y-M)*pt,A.width*Qe,A.height*pt),0,0),ze(Mt.toDataURL(Ie.imageType,Ie.imageQuality))})},R}(),at=function(){function R(t){this._zoomToCropEnabled=!0,this.zoomFactor=1,this.flippedHorizontally=!1,this.flippedVertically=!1,this._isGridVisible=!0,this._gridLines=2,this._rotationAngle=0,this.scaleFactor=1,this.renderEventListeners=[],this.closeEventListeners=[],this._isOpen=!1,this.CANVAS_MARGIN=20,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.displayMode="inline",this.popupMargin=30,this.toolbarHeight=40,this.aspectRatios=[{horizontal:0,vertical:0},{horizontal:4,vertical:3},{horizontal:3,vertical:2},{horizontal:16,vertical:9},{horizontal:1,vertical:1},{horizontal:3,vertical:4},{horizontal:2,vertical:3},{horizontal:9,vertical:16}],this._instanceNo=R.instanceCounter++,this.styles=new Ct(this.instanceNo),this.target=t,this.targetRoot=document.body,this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.rotateBy=this.rotateBy.bind(this),this.applyRotation=this.applyRotation.bind(this),this.cropRectChanged=this.cropRectChanged.bind(this),this.zoomToCrop=this.zoomToCrop.bind(this),this.unzoomFromCrop=this.unzoomFromCrop.bind(this),this.rotateLeftButtonClicked=this.rotateLeftButtonClicked.bind(this),this.rotateRightButtonClicked=this.rotateRightButtonClicked.bind(this),this.flipHorizontallyButtonClicked=this.flipHorizontallyButtonClicked.bind(this),this.flipVerticallyButtonClicked=this.flipVerticallyButtonClicked.bind(this),this.applyFlip=this.applyFlip.bind(this),this.startRenderAndClose=this.startRenderAndClose.bind(this),this.render=this.render.bind(this),this.onPopupResize=this.onPopupResize.bind(this),this.applyAspectRatio=this.applyAspectRatio.bind(this)}return Object.defineProperty(R.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(t){this._zoomToCropEnabled=t,t?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(t){this._isGridVisible=t,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"gridLines",{get:function(){return this._gridLines},set:function(t){this._gridLines=t,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(t){this._rotationAngle=t,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"aspectRatio",{get:function(){var t;return(t=this._aspectRatio)!==null&&t!==void 0?t:this.aspectRatios[0]},set:function(t){this._aspectRatio=t},enumerable:!1,configurable:!0}),R.prototype.open=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.setupResizeObserver(),this.initCropCanvas(),this.setEditingTarget(),this.setTopLeft(),this.initCropLayer(),this.attachEvents(),this.applyAspectRatio(),this.displayMode==="popup"&&this.onPopupResize(),this._isOpen=!0},R.prototype.show=function(){this.showUI(),this.open()},R.prototype.close=function(t){t===void 0&&(t=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),t||this.closeEventListeners.forEach(function(s){return s()}),this._isOpen=!1)},R.prototype.addRenderEventListener=function(t){this.renderEventListeners.push(t)},R.prototype.removeRenderEventListener=function(t){this.renderEventListeners.indexOf(t)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(t),1)},R.prototype.addCloseEventListener=function(t){this.closeEventListeners.push(t)},R.prototype.removeCloseEventListener=function(t){this.closeEventListeners.indexOf(t)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(t),1)},R.prototype.setupResizeObserver=function(){var t=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){t.resize(t.target.clientWidth,t.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},R.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var t=1*this.target.clientWidth/this.target.clientHeight,s=this.contentDiv.clientWidth/t>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*t:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,A=s+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/t;this.resize(s,A)}},R.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},R.prototype.setEditingTargetSize=function(){this.editorCanvas.style.width=this.imageWidth+2*this.CANVAS_MARGIN+"px",this.editorCanvas.style.height=this.imageHeight+2*this.CANVAS_MARGIN+"px",Ve.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},R.prototype.resize=function(t,s){this.imageWidth=Math.round(t),this.imageHeight=Math.round(s),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.displayMode!=="popup"?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},R.prototype.setEditingTarget=function(){var t=document.createElement("canvas");t.width=this.target.naturalWidth,t.height=this.target.naturalHeight,t.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var s=t.toDataURL();Ve.setAttributes(this.editingTarget,[["href",s]]),this.setEditingTargetSize()},R.prototype.setTopLeft=function(){var t=this.target.getBoundingClientRect(),s=this.editorCanvas.getBoundingClientRect();this.left=t.left-s.left-this.CANVAS_MARGIN,this.top=t.top-s.top-this.CANVAS_MARGIN},R.prototype.initCropCanvas=function(){this.cropImageHolder=document.createElement("div"),this.cropImageHolder.style.setProperty("touch-action","none"),this.cropImageHolder.style.setProperty("-ms-touch-action","none"),this.cropImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.cropImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImage.style.pointerEvents="auto",this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.cropImageHolder.style.transformOrigin="top left",this.positionCropImage(),this.defs=Ve.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=Ve.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=Ve.createGroup(),this.editingTargetRotationScaleContainer=Ve.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var t=Ve.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(t);var s=Ve.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(s),this.editingTargetContainer=Ve.createGroup(),this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px)",this.editingTargetContainer.appendChild(this.editingTargetRotationContainer),this.cropImage.appendChild(this.editingTargetContainer),this.cropImageHolder.appendChild(this.cropImage),this.editorCanvas.appendChild(this.cropImageHolder)},R.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},R.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=Ve.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new ut(this.imageWidth,this.imageHeight,this.CANVAS_MARGIN,this.cropLayerContainer),this.cropLayer.onCropChange=this.cropRectChanged,this.cropLayer.numberOfGridLines=this.gridLines,this.cropLayer.isGridVisible=this.isGridVisible,this.cropLayer.cropShadeColor=this.styles.settings.cropShadeColor,this.cropLayer.cropFrameColor=this.styles.settings.cropFrameColor,this.cropLayer.gripColor=this.styles.settings.gripColor,this.cropLayer.gripFillColor=this.styles.settings.gripFillColor,this.cropLayer.open(),this.cropLayer.setCropRectangle(this.cropRect),this.zoomToCropEnabled&&this.zoomToCrop()},R.prototype.zoomToCrop=function(){if(this.cropRect){var t=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,s=this.cropRect.y-this.CANVAS_MARGIN+this.cropRect.height/2;this.zoomFactor=Math.min(this.imageWidth/this.cropRect.width,this.imageHeight/this.cropRect.height),this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin=t+"px "+s+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-t+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-s+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},R.prototype.unzoomFromCrop=function(){this.zoomFactor=1,this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin="center",this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px) scale(1)",this.cropLayer.zoomFactor=this.zoomFactor)},R.prototype.cropRectChanged=function(t){this.cropRect=t,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},R.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},R.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},R.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},R.prototype.showUI=function(){switch(this.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var t=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,s=this.target.offsetTop>t+this.CANVAS_MARGIN?this.target.offsetTop-(t+this.CANVAS_MARGIN):0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=(this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0)+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},R.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},R.prototype.addTopToolbar=function(){var t=this;this.topToolbar=new nt,this.topToolbar.display=this.styles.settings.hideTopToolbar?"none":"",this.topToolbar.className=this.toolbarStyleClass.name,this.topToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.topToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.topToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.topToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.topToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.topToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var s=new Et;s.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(s);var A=[];this.aspectRatios.forEach(function(pt){var bt=new qe(ct.getIcon(pt.horizontal,pt.vertical),pt.horizontal===0&&pt.vertical===0?"FREE":pt.horizontal+":"+pt.vertical);bt.onClick=function(){return t.ratioButtonClicked(pt)},A.push(bt)}),this.aspectRatioButton=new yt(ct.getIcon(0,0),"Aspect ratio",A),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,s.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var M=new qe('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");M.isActive=this.isGridVisible,M.onClick=function(){t.isGridVisible=!t.isGridVisible,M.isActive=t.isGridVisible},s.addButton(M);var D=new qe('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(D.isActive=this.zoomToCropEnabled,D.onClick=function(){t.zoomToCropEnabled=!t.zoomToCropEnabled,D.isActive=t.zoomToCropEnabled},s.addButton(D),!kt.isLicensed){var Y=new Je;this.topToolbar.addElementBlock(Y);var ge=document.createElement("div");ge.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Ie=document.createElement("a");Ie.style.color="currentColor",Ie.href="https://markerjs.com/products/cropro",Ie.target="_blank",Ie.innerHTML='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"><path d="M16.326 14.895c0 1.126-.558 1.688-1.673 1.688H9.931c-1.116 0-1.674-.562-1.674-1.688V3.733c0-1.126.558-1.688 1.674-1.688h4.722c1.115 0 1.673.562 1.673 1.688v2.899h-1.957V3.793h-4.124v11.042h4.124v-3.242h1.957v3.302z" fill="currentColor"/><path d="M15.94 7.364a.783.783 0 00-1.065-.304l-11.01 6.126a.783.783 0 00-.303 1.065l4.498 8.085a.783.783 0 001.065.304l11.01-6.126a.783.783 0 00.303-1.065L15.94 7.364zM5.311 14.173l3.737 6.718 9.641-5.364-3.737-6.718-9.641 5.364z" fill="#eef762"/></svg>',ge.appendChild(Ie),Y.addElement(ge)}var ze=new Et;ze.minWidth=3*this.toolbarHeight+"px",ze.contentAlign="end",this.topToolbar.addButtonBlock(ze);var ye=new qe('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");ye.onClick=this.startRenderAndClose,ze.addButton(ye),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(ye.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Qe=new qe('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");Qe.onClick=this.close,ze.addButton(Qe),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Qe.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},R.prototype.addBottomToolbar=function(){var t=this;this.bottomToolbar=new nt,this.bottomToolbar.display=this.styles.settings.hideBottomToolbar?"none":"",this.bottomToolbar.className=this.toolbarStyleClass.name,this.bottomToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.bottomToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.bottomToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.bottomToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.bottomToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.bottomToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var s=new Et;s.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(s);var A=new qe('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");A.onClick=this.rotateLeftButtonClicked,s.addButton(A);var M=new qe('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");M.onClick=this.rotateRightButtonClicked,s.addButton(M);var D=new Je;D.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(D),this.straightener=new Ot("Straighten"),this.straightener.className=this.toolbarStraightenerStyleClass.name,this.straightener.colorsClassName=this.styles.settings.toolbarStraightenerColorsClassName?this.styles.settings.toolbarStraightenerColorsClassName:this.toolbarStraightenerStyleColorsClass.name,this.straightener.onAngleChange=function(ze){t.rotateBy(ze),t.straightener.angle=t.rotationAngle},D.addElement(this.straightener.getUI());var Y=new Et;Y.minWidth=2*this.toolbarHeight+"px",Y.contentAlign="end",this.bottomToolbar.addButtonBlock(Y);var ge=new qe('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");ge.onClick=this.flipHorizontallyButtonClicked,Y.addButton(ge);var Ie=new qe('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");Ie.onClick=this.flipVerticallyButtonClicked,Y.addButton(Ie)},R.prototype.ratioButtonClicked=function(t){this.aspectRatio=t,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},R.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ct.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},R.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new et(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},R.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},R.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},R.prototype.restoreState=function(t){if(t){var s=this.cropLayer.getRescaledRect(t.width,t.height,this.imageWidth,this.imageHeight,t.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(s),this.cropRectChanged(s),this.flippedHorizontally=t.flippedHorizontally,this.flippedVertically=t.flippedVertically,this.applyFlip(),this.rotationAngle=t.rotationAngle,this.applyRotation()}},R.prototype.clientToLocalCoordinates=function(t,s){var A=this.cropImage.getBoundingClientRect();return{x:t-A.left,y:s-A.top}},R.prototype.onWindowResize=function(){this.positionUI()},R.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var t=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=t+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)"}this.positionCropImage()},R.prototype.rotateLeftButtonClicked=function(){var t=this.rotationAngle-90;this.rotationAngle%90!=0&&(t+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(t)},R.prototype.rotateRightButtonClicked=function(){var t=this.rotationAngle+90;this.rotationAngle%90!=0&&(t-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(t)},R.prototype.rotateTo=function(t){t=(t=t>180?t-360:t)<=-180?t+360:t,this.rotationAngle=t,this.applyRotation()},R.prototype.rotateBy=function(t){this.rotateTo((this.rotationAngle+t)%360)},R.prototype.applyRotation=function(){var t=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var s=this.editingTargetRotationContainer.transform.baseVal.getItem(0);s.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(s,0);var A=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/A.width,this.imageHeight/A.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=t},R.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},R.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},R.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},R.prototype.startRenderAndClose=function(){return it(this,void 0,void 0,function(){var t,s;return mt(this,function(A){switch(A.label){case 0:return[4,this.render()];case 1:return t=A.sent(),s=this.getState(),this.renderEventListeners.forEach(function(M){return M(t,s)}),this.close(!0),[2]}})})},R.prototype.render=function(){return it(this,void 0,void 0,function(){var t;return mt(this,function(s){switch(s.label){case 0:return(t=new _t).naturalSize=this.renderAtNaturalSize,t.imageType=this.renderImageType,t.imageQuality=this.renderImageQuality,t.width=this.renderWidth,t.height=this.renderHeight,this.unzoomFromCrop(),Ve.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,t.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 1:return s.sent(),[4,t.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return[2,s.sent()]}})})},R.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new st("toolbar",`
|
|
width: `+(this.displayMode==="inline"?"100%":"calc(100vw - "+2*this.popupMargin+"px)")+`;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
height: `+this.toolbarHeight+`px;
|
|
box-sizing: content-box;
|
|
overflow: hidden;
|
|
line-height: 0px;
|
|
`)),this.toolbarStyleColorsClass=this.styles.addClass(new st("toolbar_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new st("toolbar-block",`
|
|
display: flex;
|
|
align-items: center;
|
|
box-sizing: content-box;
|
|
`));var t=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new st("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.toolbarHeight-2*t)+`px;
|
|
height: `+(this.toolbarHeight-2*t)+`px;
|
|
padding: `+t+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new st("toolbar_button_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new st("toolbar_active_button",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
|
|
`)),this.styles.addRule(new At("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new At("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
|
|
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new st("toolbar_dropdown",`
|
|
position: absolute;
|
|
max-width: `+4*this.toolbarHeight+`px;
|
|
z-index: 20;
|
|
white-space: normal;
|
|
box-sizing: content-box;
|
|
box-shadow: 3px 3px rgba(33, 33, 33, 0.1);
|
|
margin: `+(this.displayMode==="inline"?"0":this.popupMargin)+`px;
|
|
line-height: 0px;
|
|
`)),this.toolbarDropdownStyleColorsClass=this.styles.addClass(new st("toolbar_dropdown_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new st("toolbar_straightener_block",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
-webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 30%, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);
|
|
`)),this.toolbarStraightenerStyleClass=this.styles.addClass(new st("toolbar_straightener",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
height: `+(this.toolbarHeight-2*t)+`px;
|
|
padding: `+t+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new st("toolbar_straightener_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`))},R.instanceCounter=0,R}(),Ke=ae("8hTe"),dt=ae.n(Ke),xt=/<pre[^>]*>/g;function Tt(R){var t=document.createElement("div");return t.innerHTML=R,t.childNodes.length===0?"":t.childNodes[0].nodeValue}var ht=tt.a=function(R){var t=R.value,s=t===void 0?"":t,A=R.edit,M=A===void 0?!1:A,D=R.className,Y=R.showTextOnly,ge=R.showLines,Ie=R.replaces,ze=R.zoomImg,ye=R.hasMask,Qe=R.style,pt=Qe===void 0?{}:Qe,bt=R.stylesPrev,Mt=bt===void 0?{}:bt,Bt=String(s),It=Object(w.useRef)(),Ut=Object(w.useRef)(),$t=Object(w.useState)(""),zt=Object(B.a)($t,2),jt=zt[0],Ft=zt[1],Yt=Object(w.useState)("office"),Vt=Object(B.a)(Yt,2),Qt=Vt[0],Wt=Vt[1],Zt=function(){var gt=new at(Ut.current);gt.displayMode="popup",gt.addRenderEventListener(function(){var Dt=Object(_.a)(k.a.mark(function ft(Pt){var St;return k.a.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:return It.current.style.display="none",Lt.next=3,Object(be.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:Pt}});case 3:St=Lt.sent,St!=null&&St.id&&Ie(Ut.current.getAttribute("src").replace(J.a.API_SERVER,""),"/api/attachments/".concat(St==null?void 0:St.id,"?type=").concat(St.content_type));case 5:case"end":return Lt.stop()}},ft)}));return function(ft){return Dt.apply(this,arguments)}}()),gt.show()},Jt=function(){var gt=new rt(Ut.current);gt.settings.displayMode="popup",gt.addEventListener("render",function(){var Dt=Object(_.a)(k.a.mark(function ft(Pt){var St;return k.a.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:if(It.current.style.display="none",!Ut.current){Lt.next=6;break}return Lt.next=4,Object(be.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:Pt.dataUrl}});case 4:St=Lt.sent,St!=null&&St.id&&Ie(Ut.current.getAttribute("src").replace(J.a.API_SERVER,""),"/api/attachments/".concat(St==null?void 0:St.id,"?type=").concat(St.content_type));case 6:case"end":return Lt.stop()}},ft)}));return function(ft){return Dt.apply(this,arguments)}}()),gt.show(),window.markerArea=gt},Ht=Object(w.useMemo)(function(){try{var Rt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,gt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,Dt=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;Bt=Bt.replace(Rt,"("+J.a.API_SERVER+"/api/attachments/").replace(gt,'"'+J.a.API_SERVER+"/api/attachments/").replace(Dt,'"'+J.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,`
|
|
`),Bt=Bt.replace(new RegExp("(?<!\\n)\\n(?!\\n)","g"),`
|
|
`)}catch(Kt){}var ft=W(Bt),Pt=p();if(Bt.match(/\[TOC\]/)&&(ft=ft.replace("<p>[TOC]</p>",m()),f()),ft=ft.replace(/(__special_katext_id_\d+__)/g,function(Kt,Lt){var Xt=Pt[Lt],tr=Xt.type,rr=Xt.expression;return Object(ne.renderToString)(Tt(rr)||"",{displayMode:tr==="block",throwOnError:!1,output:"html"})}),ft=ft.replace(/▁/g,"\u2581\u2581\u2581"),g(),Y){var St=document.createElement("div");return St.innerHTML=ft,St.innerText}return setTimeout(function(){return qt()},500),ft},[Bt]),Nt=Object(w.useRef)();l.WebkitLineClamp=ge,ge&&(pt=Object(L.a)(Object(L.a)({},pt),l));function Gt(Rt){var gt=Rt.target;if(gt.tagName.toUpperCase()==="IMG"){if(ze){var Dt=gt.getAttribute("src");Ft(Dt),Wt("image")}}else if(gt.tagName.toUpperCase()==="A"){var ft=gt.getAttribute("href");if(ft.indexOf("office")>-1)Rt.preventDefault(),Ft(ft),Wt("office");else if(ft.indexOf("application/pdf")>-1)Rt.preventDefault(),Ft(ft),Wt("pdf");else if(ft.indexOf("type=text")>-1)Rt.preventDefault(),Ft(ft),Wt("html");else if(ft.startsWith("#")){Rt.preventDefault();var Pt=document.getElementById(ft.replace("#",""));Pt&&Pt.scrollIntoView(!0)}}}var qt=function(){var gt,Dt=(gt=Nt.current)===null||gt===void 0?void 0:gt.querySelectorAll("video");Dt==null||Dt.forEach(function(ft){if(ft.oncontextmenu=function(){return!1},ft.src.indexOf(".m3u8")>-1&&!ft.canPlayType("application/vnd.apple.mpegurl")){if(K.a.isSupported()){var Pt=new K.a;Pt.loadSource(ft.src),Pt.attachMedia(ft)}}})};Object(w.useEffect)(function(){if(Nt.current&&Ht&&(Ht.match(xt)&&window.PR.prettyPrint()),Nt.current)return Nt.current.addEventListener("click",Gt),function(){Nt.current.removeEventListener("click",Gt),g(),f()}},[Ht,Nt.current,Gt]);var er=function(gt){if(!M)return;gt.target.nodeName==="IMG"?(It.current.style.display="flex",It.current.style.width=gt.target.clientWidth+"px",It.current.style.height=gt.target.clientHeight+"px",It.current.style.top=gt.target.offsetTop+"px",It.current.style.left=gt.target.offsetLeft+"px",Ut.current.src=gt.target.getAttribute("src")):It.current.style.display="none"};return v.a.createElement("div",{style:{position:"relative"}},v.a.createElement("div",{ref:Nt,style:Object(L.a)({},pt),className:"".concat(D||""," markdown-body ").concat(dt.a.mdBody),onMouseOver:er,dangerouslySetInnerHTML:{__html:Ht}}),v.a.createElement("div",{ref:It,className:dt.a.button},v.a.createElement(N.a,null,v.a.createElement(U.a,{onClick:function(){return Zt()}},"\u88C1\u526A"),v.a.createElement(U.a,{onClick:function(){return Jt()}},"\u7F16\u8F91"))),v.a.createElement("img",{ref:Ut,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1,top:"-10000px"}}),v.a.createElement(re.a,{close:!0,data:jt,hasMask:ye,type:jt!=null&&jt.length?Qt:"",style:Object(L.a)({},Mt),onClose:function(){return Ft("")}}))}},BU3w:function(vt,tt,ae){"use strict";ae.d(tt,"a",function(){return _});var he=ae("MNnm"),N="rc-util-key";function S(B){if(B.attachTo)return B.attachTo;var O=document.querySelector("head");return O||document.body}function U(B){var O,k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(he.a)())return null;var w=document.createElement("style");if((O=k.csp)===null||O===void 0?void 0:O.nonce){var v;w.nonce=(v=k.csp)===null||v===void 0?void 0:v.nonce}w.innerHTML=B;var x=S(k),C=x.firstChild;return k.prepend&&x.prepend?x.prepend(w):k.prepend&&C?x.insertBefore(w,C):x.appendChild(w),w}var L=new Map;function _(B,O){var k=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},w=S(k);if(!L.has(w)){var v=U("",k),x=v.parentNode;L.set(w,x),x.removeChild(v)}var C=Array.from(L.get(w).children).find(function(r){return r.tagName==="STYLE"&&r[N]===O});if(C){var E,b;if(((E=k.csp)===null||E===void 0?void 0:E.nonce)&&C.nonce!==((b=k.csp)===null||b===void 0?void 0:b.nonce)){var y;C.nonce=(y=k.csp)===null||y===void 0?void 0:y.nonce}return C.innerHTML!==B&&(C.innerHTML=B),C}var d=U(B,k);return d[N]=O,d}},DlQD:function(vt,tt,ae){(function(he,N){vt.exports=N()})(this,function(){"use strict";function he(q,Q){for(var Z=0;Z<Q.length;Z++){var j=Q[Z];j.enumerable=j.enumerable||!1,j.configurable=!0,"value"in j&&(j.writable=!0),Object.defineProperty(q,j.key,j)}}function N(q,Q,Z){return Q&&he(q.prototype,Q),Z&&he(q,Z),q}function S(q,Q){if(!q)return;if(typeof q=="string")return U(q,Q);var Z=Object.prototype.toString.call(q).slice(8,-1);if(Z==="Object"&&q.constructor&&(Z=q.constructor.name),Z==="Map"||Z==="Set")return Array.from(q);if(Z==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Z))return U(q,Q)}function U(q,Q){(Q==null||Q>q.length)&&(Q=q.length);for(var Z=0,j=new Array(Q);Z<Q;Z++)j[Z]=q[Z];return j}function L(q,Q){var Z;if(typeof Symbol=="undefined"||q[Symbol.iterator]==null){if(Array.isArray(q)||(Z=S(q))||Q&&q&&typeof q.length=="number"){Z&&(q=Z);var j=0;return function(){return j>=q.length?{done:!0}:{done:!1,value:q[j++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}return Z=q[Symbol.iterator](),Z.next.bind(Z)}function _(q,Q){return Q={exports:{}},q(Q,Q.exports),Q.exports}var B=_(function(q){function Q(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function Z(j){q.exports.defaults=j}q.exports={defaults:Q(),getDefaults:Q,changeDefaults:Z}}),O=B.defaults,k=B.getDefaults,w=B.changeDefaults,v=/[&<>"']/,x=/[&<>"']/g,C=/[<>"']|&(?!#?\w+;)/,E=/[<>"']|&(?!#?\w+;)/g,b={"&":"&","<":"<",">":">",'"':""","'":"'"},y=function(Q){return b[Q]};function d(q,Q){if(Q){if(v.test(q))return q.replace(x,y)}else if(C.test(q))return q.replace(E,y);return q}var r=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function i(q){return q.replace(r,function(Q,Z){return Z=Z.toLowerCase(),Z==="colon"?":":Z.charAt(0)==="#"?Z.charAt(1)==="x"?String.fromCharCode(parseInt(Z.substring(2),16)):String.fromCharCode(+Z.substring(1)):""})}var o=/(^|[^\[])\^/g;function f(q,Q){q=q.source||q,Q=Q||"";var Z={replace:function(H,G){return G=G.source||G,G=G.replace(o,"$1"),q=q.replace(H,G),Z},getRegex:function(){return new RegExp(q,Q)}};return Z}var l=/[^\w:]/g,h=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function m(q,Q,Z){if(q){var j;try{j=decodeURIComponent(i(Z)).replace(l,"").toLowerCase()}catch(H){return null}if(j.indexOf("javascript:")===0||j.indexOf("vbscript:")===0||j.indexOf("data:")===0)return null}Q&&!h.test(Z)&&(Z=a(Q,Z));try{Z=encodeURI(Z).replace(/%25/g,"%")}catch(H){return null}return Z}var c={},u=/^[^:]+:\/*[^/]*$/,e=/^([^:]+:)[\s\S]*$/,n=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(q,Q){c[" "+q]||(u.test(q)?c[" "+q]=q+"/":c[" "+q]=P(q,"/",!0)),q=c[" "+q];var Z=q.indexOf(":")===-1;return Q.substring(0,2)==="//"?Z?Q:q.replace(e,"$1")+Q:Q.charAt(0)==="/"?Z?Q:q.replace(n,"$1")+Q:q+Q}var p={exec:function(){}};function g(q){for(var Q=1,Z,j;Q<arguments.length;Q++){Z=arguments[Q];for(j in Z)Object.prototype.hasOwnProperty.call(Z,j)&&(q[j]=Z[j])}return q}function T(q,Q){var Z=q.replace(/\|/g,function(G,V,ie){for(var se=!1,ve=V;--ve>=0&&ie[ve]==="\\";)se=!se;return se?"|":" |"}),j=Z.split(/ \|/),H=0;if(j.length>Q)j.splice(Q);else for(;j.length<Q;)j.push("");for(;H<j.length;H++)j[H]=j[H].trim().replace(/\\\|/g,"|");return j}function P(q,Q,Z){var j=q.length;if(j===0)return"";for(var H=0;H<j;){var G=q.charAt(j-H-1);if(G===Q&&!Z)H++;else if(G!==Q&&Z)H++;else break}return q.substr(0,j-H)}function I(q,Q){if(q.indexOf(Q[1])===-1)return-1;for(var Z=q.length,j=0,H=0;H<Z;H++)if(q[H]==="\\")H++;else if(q[H]===Q[0])j++;else if(q[H]===Q[1]&&(j--,j<0))return H;return-1}function F(q){q&&q.sanitize&&!q.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}var W={escape:d,unescape:i,edit:f,cleanUrl:m,resolveUrl:a,noopTest:p,merge:g,splitCells:T,rtrim:P,findClosingBracket:I,checkSanitizeDeprecation:F},z=B.defaults,X=W.rtrim,K=W.splitCells,J=W.escape,ne=W.findClosingBracket;function re(q,Q,Z){var j=Q.href,H=Q.title?J(Q.title):null,G=q[1].replace(/\\([\[\]])/g,"$1");return q[0].charAt(0)!=="!"?{type:"link",raw:Z,href:j,title:H,text:G}:{type:"image",raw:Z,href:j,title:H,text:J(G)}}function be(q,Q){var Z=q.match(/^(\s+)(?:```)/);if(Z===null)return Q;var j=Z[1];return Q.split(`
|
|
`).map(function(H){var G=H.match(/^\s+/);if(G===null)return H;var V=G[0];return V.length>=j.length?H.slice(j.length):H}).join(`
|
|
`)}var oe=function(){function q(Z){this.options=Z||z}var Q=q.prototype;return Q.space=function(j){var H=this.rules.block.newline.exec(j);if(H)return H[0].length>1?{type:"space",raw:H[0]}:{raw:`
|
|
`}},Q.code=function(j,H){var G=this.rules.block.code.exec(j);if(G){var V=H[H.length-1];if(V&&V.type==="paragraph")return{raw:G[0],text:G[0].trimRight()};var ie=G[0].replace(/^ {4}/gm,"");return{type:"code",raw:G[0],codeBlockStyle:"indented",text:this.options.pedantic?ie:X(ie,`
|
|
`)}}},Q.fences=function(j){var H=this.rules.block.fences.exec(j);if(H){var G=H[0],V=be(G,H[3]||"");return{type:"code",raw:G,lang:H[2]?H[2].trim():H[2],text:V}}},Q.heading=function(j){var H=this.rules.block.heading.exec(j);if(H)return{type:"heading",raw:H[0],depth:H[1].length,text:H[2]}},Q.nptable=function(j){var H=this.rules.block.nptable.exec(j);if(H){var G={type:"table",header:K(H[1].replace(/^ *| *\| *$/g,"")),align:H[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:H[3]?H[3].replace(/\n$/,"").split(`
|
|
`):[],raw:H[0]};if(G.header.length===G.align.length){var V=G.align.length,ie;for(ie=0;ie<V;ie++)/^ *-+: *$/.test(G.align[ie])?G.align[ie]="right":/^ *:-+: *$/.test(G.align[ie])?G.align[ie]="center":/^ *:-+ *$/.test(G.align[ie])?G.align[ie]="left":G.align[ie]=null;for(V=G.cells.length,ie=0;ie<V;ie++)G.cells[ie]=K(G.cells[ie],G.header.length);return G}}},Q.hr=function(j){var H=this.rules.block.hr.exec(j);if(H)return{type:"hr",raw:H[0]}},Q.blockquote=function(j){var H=this.rules.block.blockquote.exec(j);if(H){var G=H[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:H[0],text:G}}},Q.list=function(j){var H=this.rules.block.list.exec(j);if(H){for(var G=H[0],V=H[2],ie=V.length>1,se=V[V.length-1]===")",ve={type:"list",raw:G,ordered:ie,start:ie?+V.slice(0,-1):"",loose:!1,items:[]},Oe=H[0].match(this.rules.block.item),je=!1,Me,Xe,$e,He,Ze,rt,lt,Ye=Oe.length,it=0;it<Ye;it++)Me=Oe[it],G=Me,Xe=Me.length,Me=Me.replace(/^ *([*+-]|\d+[.)]) */,""),~Me.indexOf(`
|
|
`)&&(Xe-=Me.length,Me=this.options.pedantic?Me.replace(/^ {1,4}/gm,""):Me.replace(new RegExp("^ {1,"+Xe+"}","gm"),"")),it!==Ye-1&&($e=this.rules.block.bullet.exec(Oe[it+1])[0],(ie?$e.length===1||!se&&$e[$e.length-1]===")":$e.length>1||this.options.smartLists&&$e!==V)&&(He=Oe.slice(it+1).join(`
|
|
`),ve.raw=ve.raw.substring(0,ve.raw.length-He.length),it=Ye-1)),Ze=je||/\n\n(?!\s*$)/.test(Me),it!==Ye-1&&(je=Me.charAt(Me.length-1)===`
|
|
`,Ze||(Ze=je)),Ze&&(ve.loose=!0),rt=/^\[[ xX]\] /.test(Me),lt=void 0,rt&&(lt=Me[1]!==" ",Me=Me.replace(/^\[[ xX]\] +/,"")),ve.items.push({type:"list_item",raw:G,task:rt,checked:lt,loose:Ze,text:Me});return ve}},Q.html=function(j){var H=this.rules.block.html.exec(j);if(H)return{type:this.options.sanitize?"paragraph":"html",raw:H[0],pre:!this.options.sanitizer&&(H[1]==="pre"||H[1]==="script"||H[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(H[0]):J(H[0]):H[0]}},Q.def=function(j){var H=this.rules.block.def.exec(j);if(H){H[3]&&(H[3]=H[3].substring(1,H[3].length-1));var G=H[1].toLowerCase().replace(/\s+/g," ");return{tag:G,raw:H[0],href:H[2],title:H[3]}}},Q.table=function(j){var H=this.rules.block.table.exec(j);if(H){var G={type:"table",header:K(H[1].replace(/^ *| *\| *$/g,"")),align:H[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:H[3]?H[3].replace(/\n$/,"").split(`
|
|
`):[]};if(G.header.length===G.align.length){G.raw=H[0];var V=G.align.length,ie;for(ie=0;ie<V;ie++)/^ *-+: *$/.test(G.align[ie])?G.align[ie]="right":/^ *:-+: *$/.test(G.align[ie])?G.align[ie]="center":/^ *:-+ *$/.test(G.align[ie])?G.align[ie]="left":G.align[ie]=null;for(V=G.cells.length,ie=0;ie<V;ie++)G.cells[ie]=K(G.cells[ie].replace(/^ *\| *| *\| *$/g,""),G.header.length);return G}}},Q.lheading=function(j){var H=this.rules.block.lheading.exec(j);if(H)return{type:"heading",raw:H[0],depth:H[2].charAt(0)==="="?1:2,text:H[1]}},Q.paragraph=function(j){var H=this.rules.block.paragraph.exec(j);if(H)return{type:"paragraph",raw:H[0],text:H[1].charAt(H[1].length-1)===`
|
|
`?H[1].slice(0,-1):H[1]}},Q.text=function(j,H){var G=this.rules.block.text.exec(j);if(G){var V=H[H.length-1];return V&&V.type==="text"?{raw:G[0],text:G[0]}:{type:"text",raw:G[0],text:G[0]}}},Q.escape=function(j){var H=this.rules.inline.escape.exec(j);if(H)return{type:"escape",raw:H[0],text:J(H[1])}},Q.tag=function(j,H,G){var V=this.rules.inline.tag.exec(j);if(V)return!H&&/^<a /i.test(V[0])?H=!0:H&&/^<\/a>/i.test(V[0])&&(H=!1),!G&&/^<(pre|code|kbd|script)(\s|>)/i.test(V[0])?G=!0:G&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(V[0])&&(G=!1),{type:this.options.sanitize?"text":"html",raw:V[0],inLink:H,inRawBlock:G,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(V[0]):J(V[0]):V[0]}},Q.link=function(j){var H=this.rules.inline.link.exec(j);if(H){var G=ne(H[2],"()");if(G>-1){var V=H[0].indexOf("!")===0?5:4,ie=V+H[1].length+G;H[2]=H[2].substring(0,G),H[0]=H[0].substring(0,ie).trim(),H[3]=""}var se=H[2],ve="";if(this.options.pedantic){var Oe=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(se);Oe?(se=Oe[1],ve=Oe[3]):ve=""}else ve=H[3]?H[3].slice(1,-1):"";se=se.trim().replace(/^<([\s\S]*)>$/,"$1");var je=re(H,{href:se&&se.replace(this.rules.inline._escapes,"$1"),title:ve&&ve.replace(this.rules.inline._escapes,"$1")},H[0]);return je}},Q.reflink=function(j,H){var G;if((G=this.rules.inline.reflink.exec(j))||(G=this.rules.inline.nolink.exec(j))){var V=(G[2]||G[1]).replace(/\s+/g," ");if(V=H[V.toLowerCase()],!V||!V.href){var ie=G[0].charAt(0);return{type:"text",raw:ie,text:ie}}var se=re(G,V,G[0]);return se}},Q.strong=function(j,H,G){G===void 0&&(G="");var V=this.rules.inline.strong.start.exec(j);if(V&&(!V[1]||V[1]&&(G===""||this.rules.inline.punctuation.exec(G)))){H=H.slice(-1*j.length);var ie=V[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ie.lastIndex=0;for(var se;(V=ie.exec(H))!=null;)if(se=this.rules.inline.strong.middle.exec(H.slice(0,V.index+3)),se)return{type:"strong",raw:j.slice(0,se[0].length),text:j.slice(2,se[0].length-2)}}},Q.em=function(j,H,G){G===void 0&&(G="");var V=this.rules.inline.em.start.exec(j);if(V&&(!V[1]||V[1]&&(G===""||this.rules.inline.punctuation.exec(G)))){H=H.slice(-1*j.length);var ie=V[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ie.lastIndex=0;for(var se;(V=ie.exec(H))!=null;)if(se=this.rules.inline.em.middle.exec(H.slice(0,V.index+2)),se)return{type:"em",raw:j.slice(0,se[0].length),text:j.slice(1,se[0].length-1)}}},Q.codespan=function(j){var H=this.rules.inline.code.exec(j);if(H){var G=H[2].replace(/\n/g," "),V=/[^ ]/.test(G),ie=G.startsWith(" ")&&G.endsWith(" ");return V&&ie&&(G=G.substring(1,G.length-1)),G=J(G,!0),{type:"codespan",raw:H[0],text:G}}},Q.br=function(j){var H=this.rules.inline.br.exec(j);if(H)return{type:"br",raw:H[0]}},Q.del=function(j){var H=this.rules.inline.del.exec(j);if(H)return{type:"del",raw:H[0],text:H[1]}},Q.autolink=function(j,H){var G=this.rules.inline.autolink.exec(j);if(G){var V,ie;return G[2]==="@"?(V=J(this.options.mangle?H(G[1]):G[1]),ie="mailto:"+V):(V=J(G[1]),ie=V),{type:"link",raw:G[0],text:V,href:ie,tokens:[{type:"text",raw:V,text:V}]}}},Q.url=function(j,H){var G;if(G=this.rules.inline.url.exec(j)){var V,ie;if(G[2]==="@")V=J(this.options.mangle?H(G[0]):G[0]),ie="mailto:"+V;else{var se;do se=G[0],G[0]=this.rules.inline._backpedal.exec(G[0])[0];while(se!==G[0]);V=J(G[0]),G[1]==="www."?ie="http://"+V:ie=V}return{type:"link",raw:G[0],text:V,href:ie,tokens:[{type:"text",raw:V,text:V}]}}},Q.inlineText=function(j,H,G){var V=this.rules.inline.text.exec(j);if(V){var ie;return H?ie=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(V[0]):J(V[0]):V[0]:ie=J(this.options.smartypants?G(V[0]):V[0]),{type:"text",raw:V[0],text:ie}}},q}(),ue=W.noopTest,de=W.edit,ce=W.merge,te={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:ue,table:ue,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};te._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,te._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,te.def=de(te.def).replace("label",te._label).replace("title",te._title).getRegex(),te.bullet=/(?:[*+-]|\d{1,9}[.)])/,te.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,te.item=de(te.item,"gm").replace(/bull/g,te.bullet).getRegex(),te.list=de(te.list).replace(/bull/g,te.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+te.def.source+")").getRegex(),te._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",te._comment=/<!--(?!-?>)[\s\S]*?-->/,te.html=de(te.html,"i").replace("comment",te._comment).replace("tag",te._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),te.paragraph=de(te._paragraph).replace("hr",te.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",te._tag).getRegex(),te.blockquote=de(te.blockquote).replace("paragraph",te.paragraph).getRegex(),te.normal=ce({},te),te.gfm=ce({},te.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),te.gfm.nptable=de(te.gfm.nptable).replace("hr",te.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",te._tag).getRegex(),te.gfm.table=de(te.gfm.table).replace("hr",te.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",te._tag).getRegex(),te.pedantic=ce({},te.normal,{html:de(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",te._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:ue,paragraph:de(te.normal._paragraph).replace("hr",te.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",te.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var $={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ue,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",strong:{start:/^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,middle:/^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,endAst:/[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]__(?!_)(?:(?=[punctuation\s])|$)/},em:{start:/^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,middle:/^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,endAst:/[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]_(?!_)(?:(?=[punctuation\s])|$)/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:ue,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};$._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",$.punctuation=de($.punctuation).replace(/punctuation/g,$._punctuation).getRegex(),$._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",$._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",$.em.start=de($.em.start).replace(/punctuation/g,$._punctuation).getRegex(),$.em.middle=de($.em.middle).replace(/punctuation/g,$._punctuation).replace(/overlapSkip/g,$._overlapSkip).getRegex(),$.em.endAst=de($.em.endAst,"g").replace(/punctuation/g,$._punctuation).getRegex(),$.em.endUnd=de($.em.endUnd,"g").replace(/punctuation/g,$._punctuation).getRegex(),$.strong.start=de($.strong.start).replace(/punctuation/g,$._punctuation).getRegex(),$.strong.middle=de($.strong.middle).replace(/punctuation/g,$._punctuation).replace(/blockSkip/g,$._blockSkip).getRegex(),$.strong.endAst=de($.strong.endAst,"g").replace(/punctuation/g,$._punctuation).getRegex(),$.strong.endUnd=de($.strong.endUnd,"g").replace(/punctuation/g,$._punctuation).getRegex(),$.blockSkip=de($._blockSkip,"g").getRegex(),$.overlapSkip=de($._overlapSkip,"g").getRegex(),$._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,$._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,$._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,$.autolink=de($.autolink).replace("scheme",$._scheme).replace("email",$._email).getRegex(),$._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,$.tag=de($.tag).replace("comment",te._comment).replace("attribute",$._attribute).getRegex(),$._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,$._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,$._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,$.link=de($.link).replace("label",$._label).replace("href",$._href).replace("title",$._title).getRegex(),$.reflink=de($.reflink).replace("label",$._label).getRegex(),$.reflinkSearch=de($.reflinkSearch,"g").replace("reflink",$.reflink).replace("nolink",$.nolink).getRegex(),$.normal=ce({},$),$.pedantic=ce({},$.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:de(/^!?\[(label)\]\((.*?)\)/).replace("label",$._label).getRegex(),reflink:de(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",$._label).getRegex()}),$.gfm=ce({},$.normal,{escape:de($.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),$.gfm.url=de($.gfm.url,"i").replace("email",$.gfm._extended_email).getRegex(),$.breaks=ce({},$.gfm,{br:de($.br).replace("{2,}","*").getRegex(),text:de($.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var Ae={block:te,inline:$},Fe=B.defaults,De=Ae.block,Ue=Ae.inline;function Re(q){return q.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function fe(q){var Q="",Z,j,H=q.length;for(Z=0;Z<H;Z++)j=q.charCodeAt(Z),Math.random()>.5&&(j="x"+j.toString(16)),Q+="&#"+j+";";return Q}var Ce=function(){function q(Z){this.tokens=[],this.tokens.links=Object.create(null),this.options=Z||Fe,this.options.tokenizer=this.options.tokenizer||new oe,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var j={block:De.normal,inline:Ue.normal};this.options.pedantic?(j.block=De.pedantic,j.inline=Ue.pedantic):this.options.gfm&&(j.block=De.gfm,this.options.breaks?j.inline=Ue.breaks:j.inline=Ue.gfm),this.tokenizer.rules=j}q.lex=function(j,H){var G=new q(H);return G.lex(j)};var Q=q.prototype;return Q.lex=function(j){return j=j.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," "),this.blockTokens(j,this.tokens,!0),this.inline(this.tokens),this.tokens},Q.blockTokens=function(j,H,G){H===void 0&&(H=[]),G===void 0&&(G=!0),j=j.replace(/^ +$/gm,"");for(var V,ie,se,ve;j;){if(V=this.tokenizer.space(j)){j=j.substring(V.raw.length),V.type&&H.push(V);continue}if(V=this.tokenizer.code(j,H)){j=j.substring(V.raw.length),V.type?H.push(V):(ve=H[H.length-1],ve.raw+=`
|
|
`+V.raw,ve.text+=`
|
|
`+V.text);continue}if(V=this.tokenizer.fences(j)){j=j.substring(V.raw.length),H.push(V);continue}if(V=this.tokenizer.heading(j)){j=j.substring(V.raw.length),H.push(V);continue}if(V=this.tokenizer.nptable(j)){j=j.substring(V.raw.length),H.push(V);continue}if(V=this.tokenizer.hr(j)){j=j.substring(V.raw.length),H.push(V);continue}if(V=this.tokenizer.blockquote(j)){j=j.substring(V.raw.length),V.tokens=this.blockTokens(V.text,[],G),H.push(V);continue}if(V=this.tokenizer.list(j)){for(j=j.substring(V.raw.length),se=V.items.length,ie=0;ie<se;ie++)V.items[ie].tokens=this.blockTokens(V.items[ie].text,[],!1);H.push(V);continue}if(V=this.tokenizer.html(j)){j=j.substring(V.raw.length),H.push(V);continue}if(G&&(V=this.tokenizer.def(j))){j=j.substring(V.raw.length),this.tokens.links[V.tag]||(this.tokens.links[V.tag]={href:V.href,title:V.title});continue}if(V=this.tokenizer.table(j)){j=j.substring(V.raw.length),H.push(V);continue}if(V=this.tokenizer.lheading(j)){j=j.substring(V.raw.length),H.push(V);continue}if(G&&(V=this.tokenizer.paragraph(j))){j=j.substring(V.raw.length),H.push(V);continue}if(V=this.tokenizer.text(j,H)){j=j.substring(V.raw.length),V.type?H.push(V):(ve=H[H.length-1],ve.raw+=`
|
|
`+V.raw,ve.text+=`
|
|
`+V.text);continue}if(j){var Oe="Infinite loop on byte: "+j.charCodeAt(0);if(this.options.silent){console.error(Oe);break}else throw new Error(Oe)}}return H},Q.inline=function(j){var H,G,V,ie,se,ve,Oe=j.length;for(H=0;H<Oe;H++){ve=j[H];switch(ve.type){case"paragraph":case"text":case"heading":{ve.tokens=[],this.inlineTokens(ve.text,ve.tokens);break}case"table":{for(ve.tokens={header:[],cells:[]},ie=ve.header.length,G=0;G<ie;G++)ve.tokens.header[G]=[],this.inlineTokens(ve.header[G],ve.tokens.header[G]);for(ie=ve.cells.length,G=0;G<ie;G++)for(se=ve.cells[G],ve.tokens.cells[G]=[],V=0;V<se.length;V++)ve.tokens.cells[G][V]=[],this.inlineTokens(se[V],ve.tokens.cells[G][V]);break}case"blockquote":{this.inline(ve.tokens);break}case"list":{for(ie=ve.items.length,G=0;G<ie;G++)this.inline(ve.items[G].tokens);break}}}return j},Q.inlineTokens=function(j,H,G,V,ie){H===void 0&&(H=[]),G===void 0&&(G=!1),V===void 0&&(V=!1),ie===void 0&&(ie="");var se,ve=j,Oe;if(this.tokens.links){var je=Object.keys(this.tokens.links);if(je.length>0)for(;(Oe=this.tokenizer.rules.inline.reflinkSearch.exec(ve))!=null;)je.includes(Oe[0].slice(Oe[0].lastIndexOf("[")+1,-1))&&(ve=ve.slice(0,Oe.index)+"["+"a".repeat(Oe[0].length-2)+"]"+ve.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(Oe=this.tokenizer.rules.inline.blockSkip.exec(ve))!=null;)ve=ve.slice(0,Oe.index)+"["+"a".repeat(Oe[0].length-2)+"]"+ve.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;j;){if(se=this.tokenizer.escape(j)){j=j.substring(se.raw.length),H.push(se);continue}if(se=this.tokenizer.tag(j,G,V)){j=j.substring(se.raw.length),G=se.inLink,V=se.inRawBlock,H.push(se);continue}if(se=this.tokenizer.link(j)){j=j.substring(se.raw.length),se.type==="link"&&(se.tokens=this.inlineTokens(se.text,[],!0,V)),H.push(se);continue}if(se=this.tokenizer.reflink(j,this.tokens.links)){j=j.substring(se.raw.length),se.type==="link"&&(se.tokens=this.inlineTokens(se.text,[],!0,V)),H.push(se);continue}if(se=this.tokenizer.strong(j,ve,ie)){j=j.substring(se.raw.length),se.tokens=this.inlineTokens(se.text,[],G,V),H.push(se);continue}if(se=this.tokenizer.em(j,ve,ie)){j=j.substring(se.raw.length),se.tokens=this.inlineTokens(se.text,[],G,V),H.push(se);continue}if(se=this.tokenizer.codespan(j)){j=j.substring(se.raw.length),H.push(se);continue}if(se=this.tokenizer.br(j)){j=j.substring(se.raw.length),H.push(se);continue}if(se=this.tokenizer.del(j)){j=j.substring(se.raw.length),se.tokens=this.inlineTokens(se.text,[],G,V),H.push(se);continue}if(se=this.tokenizer.autolink(j,fe)){j=j.substring(se.raw.length),H.push(se);continue}if(!G&&(se=this.tokenizer.url(j,fe))){j=j.substring(se.raw.length),H.push(se);continue}if(se=this.tokenizer.inlineText(j,V,Re)){j=j.substring(se.raw.length),ie=se.raw.slice(-1),H.push(se);continue}if(j){var Me="Infinite loop on byte: "+j.charCodeAt(0);if(this.options.silent){console.error(Me);break}else throw new Error(Me)}}return H},N(q,null,[{key:"rules",get:function(){return{block:De,inline:Ue}}}]),q}(),Se=B.defaults,me=W.cleanUrl,Te=W.escape,pe=function(){function q(Z){this.options=Z||Se}var Q=q.prototype;return Q.code=function(j,H,G){var V=(H||"").match(/\S*/)[0];if(this.options.highlight){var ie=this.options.highlight(j,V);ie!=null&&ie!==j&&(G=!0,j=ie)}return V?'<pre><code class="'+this.options.langPrefix+Te(V,!0)+'">'+(G?j:Te(j,!0))+`</code></pre>
|
|
`:"<pre><code>"+(G?j:Te(j,!0))+`</code></pre>
|
|
`},Q.blockquote=function(j){return`<blockquote>
|
|
`+j+`</blockquote>
|
|
`},Q.html=function(j){return j},Q.heading=function(j,H,G,V){return this.options.headerIds?"<h"+H+' id="'+this.options.headerPrefix+V.slug(G)+'">'+j+"</h"+H+`>
|
|
`:"<h"+H+">"+j+"</h"+H+`>
|
|
`},Q.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},Q.list=function(j,H,G){var V=H?"ol":"ul",ie=H&&G!==1?' start="'+G+'"':"";return"<"+V+ie+`>
|
|
`+j+"</"+V+`>
|
|
`},Q.listitem=function(j){return"<li>"+j+`</li>
|
|
`},Q.checkbox=function(j){return"<input "+(j?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},Q.paragraph=function(j){return"<p>"+j+`</p>
|
|
`},Q.table=function(j,H){return H&&(H="<tbody>"+H+"</tbody>"),`<table>
|
|
<thead>
|
|
`+j+`</thead>
|
|
`+H+`</table>
|
|
`},Q.tablerow=function(j){return`<tr>
|
|
`+j+`</tr>
|
|
`},Q.tablecell=function(j,H){var G=H.header?"th":"td",V=H.align?"<"+G+' align="'+H.align+'">':"<"+G+">";return V+j+"</"+G+`>
|
|
`},Q.strong=function(j){return"<strong>"+j+"</strong>"},Q.em=function(j){return"<em>"+j+"</em>"},Q.codespan=function(j){return"<code>"+j+"</code>"},Q.br=function(){return this.options.xhtml?"<br/>":"<br>"},Q.del=function(j){return"<del>"+j+"</del>"},Q.link=function(j,H,G){if(j=me(this.options.sanitize,this.options.baseUrl,j),j===null)return G;var V='<a href="'+Te(j)+'"';return H&&(V+=' title="'+H+'"'),V+=">"+G+"</a>",V},Q.image=function(j,H,G){if(j=me(this.options.sanitize,this.options.baseUrl,j),j===null)return G;var V='<img src="'+j+'" alt="'+G+'"';return H&&(V+=' title="'+H+'"'),V+=this.options.xhtml?"/>":">",V},Q.text=function(j){return j},q}(),Ee=function(){function q(){}var Q=q.prototype;return Q.strong=function(j){return j},Q.em=function(j){return j},Q.codespan=function(j){return j},Q.del=function(j){return j},Q.html=function(j){return j},Q.text=function(j){return j},Q.link=function(j,H,G){return""+G},Q.image=function(j,H,G){return""+G},Q.br=function(){return""},q}(),Ge=function(){function q(){this.seen={}}var Q=q.prototype;return Q.slug=function(j){var H=j.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(H)){var G=H;do this.seen[G]++,H=G+"-"+this.seen[G];while(this.seen.hasOwnProperty(H))}return this.seen[H]=0,H},q}(),Le=B.defaults,ke=W.unescape,Ne=function(){function q(Z){this.options=Z||Le,this.options.renderer=this.options.renderer||new pe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Ee,this.slugger=new Ge}q.parse=function(j,H){var G=new q(H);return G.parse(j)};var Q=q.prototype;return Q.parse=function(j,H){H===void 0&&(H=!0);var G="",V,ie,se,ve,Oe,je,Me,Xe,$e,He,Ze,rt,lt,Ye,it,mt,kt,Ve,Ct=j.length;for(V=0;V<Ct;V++){He=j[V];switch(He.type){case"space":continue;case"hr":{G+=this.renderer.hr();continue}case"heading":{G+=this.renderer.heading(this.parseInline(He.tokens),He.depth,ke(this.parseInline(He.tokens,this.textRenderer)),this.slugger);continue}case"code":{G+=this.renderer.code(He.text,He.lang,He.escaped);continue}case"table":{for(Xe="",Me="",ve=He.header.length,ie=0;ie<ve;ie++)Me+=this.renderer.tablecell(this.parseInline(He.tokens.header[ie]),{header:!0,align:He.align[ie]});for(Xe+=this.renderer.tablerow(Me),$e="",ve=He.cells.length,ie=0;ie<ve;ie++){for(je=He.tokens.cells[ie],Me="",Oe=je.length,se=0;se<Oe;se++)Me+=this.renderer.tablecell(this.parseInline(je[se]),{header:!1,align:He.align[se]});$e+=this.renderer.tablerow(Me)}G+=this.renderer.table(Xe,$e);continue}case"blockquote":{$e=this.parse(He.tokens),G+=this.renderer.blockquote($e);continue}case"list":{for(Ze=He.ordered,rt=He.start,lt=He.loose,ve=He.items.length,$e="",ie=0;ie<ve;ie++)it=He.items[ie],mt=it.checked,kt=it.task,Ye="",it.task&&(Ve=this.renderer.checkbox(mt),lt?it.tokens.length>0&&it.tokens[0].type==="text"?(it.tokens[0].text=Ve+" "+it.tokens[0].text,it.tokens[0].tokens&&it.tokens[0].tokens.length>0&&it.tokens[0].tokens[0].type==="text"&&(it.tokens[0].tokens[0].text=Ve+" "+it.tokens[0].tokens[0].text)):it.tokens.unshift({type:"text",text:Ve}):Ye+=Ve),Ye+=this.parse(it.tokens,lt),$e+=this.renderer.listitem(Ye,kt,mt);G+=this.renderer.list($e,Ze,rt);continue}case"html":{G+=this.renderer.html(He.text);continue}case"paragraph":{G+=this.renderer.paragraph(this.parseInline(He.tokens));continue}case"text":{for($e=He.tokens?this.parseInline(He.tokens):He.text;V+1<Ct&&j[V+1].type==="text";)He=j[++V],$e+=`
|
|
`+(He.tokens?this.parseInline(He.tokens):He.text);G+=H?this.renderer.paragraph($e):$e;continue}default:{var At='Token with "'+He.type+'" type was not found.';if(this.options.silent){console.error(At);return}else throw new Error(At)}}}return G},Q.parseInline=function(j,H){H=H||this.renderer;var G="",V,ie,se=j.length;for(V=0;V<se;V++){ie=j[V];switch(ie.type){case"escape":{G+=H.text(ie.text);break}case"html":{G+=H.html(ie.text);break}case"link":{G+=H.link(ie.href,ie.title,this.parseInline(ie.tokens,H));break}case"image":{G+=H.image(ie.href,ie.title,ie.text);break}case"strong":{G+=H.strong(this.parseInline(ie.tokens,H));break}case"em":{G+=H.em(this.parseInline(ie.tokens,H));break}case"codespan":{G+=H.codespan(ie.text);break}case"br":{G+=H.br();break}case"del":{G+=H.del(this.parseInline(ie.tokens,H));break}case"text":{G+=H.text(ie.text);break}default:{var ve='Token with "'+ie.type+'" type was not found.';if(this.options.silent){console.error(ve);return}else throw new Error(ve)}}}return G},q}(),ee=W.merge,Be=W.checkSanitizeDeprecation,_e=W.escape,we=B.getDefaults,We=B.changeDefaults,Pe=B.defaults;function le(q,Q,Z){if(typeof q=="undefined"||q===null)throw new Error("marked(): input parameter is undefined or null");if(typeof q!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(q)+", string expected");if(typeof Q=="function"&&(Z=Q,Q=null),Q=ee({},le.defaults,Q||{}),Be(Q),Z){var j=Q.highlight,H;try{H=Ce.lex(q,Q)}catch(se){return Z(se)}var G=function(ve){var Oe;if(!ve)try{Oe=Ne.parse(H,Q)}catch(je){ve=je}return Q.highlight=j,ve?Z(ve):Z(null,Oe)};if(!j||j.length<3)return G();if(delete Q.highlight,!H.length)return G();var V=0;le.walkTokens(H,function(se){se.type==="code"&&(V++,setTimeout(function(){j(se.text,se.lang,function(ve,Oe){if(ve)return G(ve);Oe!=null&&Oe!==se.text&&(se.text=Oe,se.escaped=!0),V--,V===0&&G()})},0))}),V===0&&G();return}try{var ie=Ce.lex(q,Q);return Q.walkTokens&&le.walkTokens(ie,Q.walkTokens),Ne.parse(ie,Q)}catch(se){if(se.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,Q.silent)return"<p>An error occurred:</p><pre>"+_e(se.message+"",!0)+"</pre>";throw se}}le.options=le.setOptions=function(q){return ee(le.defaults,q),We(le.defaults),le},le.getDefaults=we,le.defaults=Pe,le.use=function(q){var Q=ee({},q);if(q.renderer&&function(){var j=le.defaults.renderer||new pe,H=function(ie){var se=j[ie];j[ie]=function(){for(var ve=arguments.length,Oe=new Array(ve),je=0;je<ve;je++)Oe[je]=arguments[je];var Me=q.renderer[ie].apply(j,Oe);return Me===!1&&(Me=se.apply(j,Oe)),Me}};for(var G in q.renderer)H(G);Q.renderer=j}(),q.tokenizer&&function(){var j=le.defaults.tokenizer||new oe,H=function(ie){var se=j[ie];j[ie]=function(){for(var ve=arguments.length,Oe=new Array(ve),je=0;je<ve;je++)Oe[je]=arguments[je];var Me=q.tokenizer[ie].apply(j,Oe);return Me===!1&&(Me=se.apply(j,Oe)),Me}};for(var G in q.tokenizer)H(G);Q.tokenizer=j}(),q.walkTokens){var Z=le.defaults.walkTokens;Q.walkTokens=function(j){q.walkTokens(j),Z&&Z(j)}}le.setOptions(Q)},le.walkTokens=function(q,Q){for(var Z=L(q),j;!(j=Z()).done;){var H=j.value;Q(H);switch(H.type){case"table":{for(var G=L(H.tokens.header),V;!(V=G()).done;){var ie=V.value;le.walkTokens(ie,Q)}for(var se=L(H.tokens.cells),ve;!(ve=se()).done;)for(var Oe=ve.value,je=L(Oe),Me;!(Me=je()).done;){var Xe=Me.value;le.walkTokens(Xe,Q)}break}case"list":{le.walkTokens(H.items,Q);break}default:H.tokens&&le.walkTokens(H.tokens,Q)}}},le.Parser=Ne,le.parser=Ne.parse,le.Renderer=pe,le.TextRenderer=Ee,le.Lexer=Ce,le.lexer=Ce.lex,le.Tokenizer=oe,le.Slugger=Ge,le.parse=le;var xe=le;return xe})},LdHM:function(vt,tt,ae){"use strict";ae.d(tt,"b",function(){return o}),ae.d(tt,"a",function(){return l});var he=ae("1OyB"),N=ae("vuIU"),S=ae("Ji7U"),U=ae("LK+K"),L=ae("q1tI"),_=ae("rePB"),B=ae("Ff2n"),O=ae("ODXe"),k=ae("4IlW"),w=ae("bX4T"),v=ae("YrtM"),x=ae("TSYQ"),C=ae.n(x),E=ae("+nKL"),b=ae("8OUc"),y=function(K,J){var ne=K.prefixCls,re=K.id,be=K.flattenOptions,oe=K.childrenAsData,ue=K.values,de=K.searchValue,ce=K.multiple,te=K.defaultActiveFirstOption,$=K.height,Ae=K.itemHeight,Fe=K.notFoundContent,De=K.open,Ue=K.menuItemSelectedIcon,Re=K.virtual,fe=K.onSelect,Ce=K.onToggleOpen,Se=K.onActiveValue,me=K.onScroll,Te=K.onMouseEnter,pe="".concat(ne,"-item"),Ee=Object(v.a)(function(){return be},[De,be],function(xe,q){return q[0]&&xe[1]!==q[1]}),Ge=L.useRef(null),Le=function(q){q.preventDefault()},ke=function(q){Ge.current&&Ge.current.scrollTo({index:q})},Ne=function(q){for(var Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Z=Ee.length,j=0;j<Z;j+=1){var H=(q+j*Q+Z)%Z,G=Ee[H],V=G.group,ie=G.data;if(!V&&!ie.disabled)return H}return-1},ee=L.useState(function(){return Ne(0)}),Be=Object(O.a)(ee,2),_e=Be[0],we=Be[1],We=function(q){we(q);var Q=Ee[q];if(!Q){Se(null,-1);return}Se(Q.data.value,q)};L.useEffect(function(){We(te!==!1?Ne(0):-1)},[Ee.length,de]),L.useEffect(function(){var xe=setTimeout(function(){if(!ce&&De&&ue.size===1){var q=Array.from(ue)[0],Q=Ee.findIndex(function(Z){var j=Z.data;return j.value===q});We(Q),ke(Q)}});return function(){return clearTimeout(xe)}},[De]);var Pe=function(q){q!==void 0&&fe(q,{selected:!ue.has(q)}),ce||Ce(!1)};if(L.useImperativeHandle(J,function(){return{onKeyDown:function(q){var Q=q.which;switch(Q){case k.a.UP:case k.a.DOWN:{var Z=0;if(Q===k.a.UP?Z=-1:Q===k.a.DOWN&&(Z=1),Z!==0){var j=Ne(_e+Z,Z);ke(j),We(j)}break}case k.a.ENTER:{var H=Ee[_e];H&&!H.data.disabled?Pe(H.data.value):Pe(void 0),De&&q.preventDefault();break}case k.a.ESC:Ce(!1)}},onKeyUp:function(){},scrollTo:function(q){ke(q)}}}),Ee.length===0)return L.createElement("div",{role:"listbox",id:"".concat(re,"_list"),className:"".concat(pe,"-empty"),onMouseDown:Le},Fe);function le(xe){var q=Ee[xe];if(!q)return null;var Q=q.data||{},Z=Q.value,j=Q.label,H=Q.children,G=Object(w.a)(Q,!0),V=oe?H:j;return q?L.createElement("div",Object.assign({"aria-label":typeof V=="string"?V:null},G,{key:xe,role:"option",id:"".concat(re,"_list_").concat(xe),"aria-selected":ue.has(Z)}),Z):null}return L.createElement(L.Fragment,null,L.createElement("div",{role:"listbox",id:"".concat(re,"_list"),style:{height:0,width:0,overflow:"hidden"}},le(_e-1),le(_e),le(_e+1)),L.createElement(E.a,{itemKey:"key",ref:Ge,data:Ee,height:$,itemHeight:Ae,fullHeight:!1,onMouseDown:Le,onScroll:me,virtual:Re,onMouseEnter:Te},function(xe,q){var Q,Z=xe.group,j=xe.groupOption,H=xe.data,G=H.label,V=H.key;if(Z)return L.createElement("div",{className:C()(pe,"".concat(pe,"-group"))},G!==void 0?G:V);var ie=H.disabled,se=H.value,ve=H.title,Oe=H.children,je=H.style,Me=H.className,Xe=Object(B.a)(H,["disabled","value","title","children","style","className"]),$e=ue.has(se),He="".concat(pe,"-option"),Ze=C()(pe,He,Me,(Q={},Object(_.a)(Q,"".concat(He,"-grouped"),j),Object(_.a)(Q,"".concat(He,"-active"),_e===q&&!ie),Object(_.a)(Q,"".concat(He,"-disabled"),ie),Object(_.a)(Q,"".concat(He,"-selected"),$e),Q)),rt=oe?Oe:G,lt=!Ue||typeof Ue=="function"||$e;return L.createElement("div",Object.assign({},Xe,{"aria-selected":$e,className:Ze,title:ve,onMouseMove:function(){if(_e===q||ie)return;We(q)},onClick:function(){ie||Pe(se)},style:je}),L.createElement("div",{className:"".concat(He,"-content")},rt||se),L.isValidElement(Ue)||$e,lt&&L.createElement(b.a,{className:"".concat(pe,"-option-state"),customizeIcon:Ue,customizeIconProps:{isSelected:$e}},$e?"\u2713":null))}))},d=L.forwardRef(y);d.displayName="OptionList";var r=d,i=function(){return null};i.isSelectOption=!0;var o=i,f=function(){return null};f.isSelectOptGroup=!0;var l=f,h=ae("VTBJ"),m=ae("Zm9Q");function c(X){var K=X.key,J=X.props,ne=J.children,re=J.value,be=Object(B.a)(J,["children","value"]);return Object(h.a)({key:K,value:re!==void 0?re:K,children:ne},be)}function u(X){var K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(m.a)(X).map(function(J,ne){if(!L.isValidElement(J)||!J.type)return null;var re=J.type.isSelectOptGroup,be=J.key,oe=J.props,ue=oe.children,de=Object(B.a)(oe,["children"]);return K||!re?c(J):Object(h.a)(Object(h.a)({key:"__RC_SELECT_GRP__".concat(be===null?ne:be,"__"),label:be},de),{},{options:u(ue)})}).filter(function(J){return J})}var e=ae("2Qr1"),n=ae("qNPg"),a=ae("U8pU"),p=ae("Kwbf"),g=ae("WKfj");function T(X){var K=X.mode,J=X.options,ne=X.children,re=X.backfill,be=X.allowClear,oe=X.placeholder,ue=X.getInputElement,de=X.showSearch,ce=X.onSearch,te=X.defaultOpen,$=X.autoFocus,Ae=X.labelInValue,Fe=X.value,De=X.inputValue,Ue=X.optionLabelProp,Re=K==="multiple"||K==="tags",fe=de!==void 0?de:Re||K==="combobox",Ce=J||u(ne);if(Object(p.a)(K!=="tags"||Ce.every(function(pe){return!pe.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),K==="tags"||K==="combobox"){var Se=Ce.some(function(pe){return pe.options?pe.options.some(function(Ee){return typeof("value"in Ee?Ee.value:Ee.key)=="number"}):typeof("value"in pe?pe.value:pe.key)=="number"});Object(p.a)(!Se,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(p.a)(K!=="combobox"||!Ue,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(p.a)(K==="combobox"||!re,"`backfill` only works with `combobox` mode."),Object(p.a)(K==="combobox"||!ue,"`getInputElement` only work with `combobox` mode."),Object(p.b)(K!=="combobox"||!ue||!be||!oe,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),ce&&!fe&&K!=="combobox"&&K!=="tags"&&Object(p.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(p.b)(!te||$,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Fe!=null){var me=Object(g.d)(Fe);Object(p.a)(!Ae||me.every(function(pe){return Object(a.a)(pe)==="object"&&("key"in pe||"value"in pe)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(p.a)(!Re||Array.isArray(Fe),"`value` should be array when `mode` is `multiple` or `tags`")}if(ne){var Te=null;Object(m.a)(ne).some(function(pe){if(!L.isValidElement(pe)||!pe.type)return!1;var Ee=pe.type;if(Ee.isSelectOption)return!1;if(Ee.isSelectOptGroup){var Ge=Object(m.a)(pe.props.children).every(function(Le){return!L.isValidElement(Le)||!pe.type||Le.type.isSelectOption?!0:(Te=Le.type,!1)});return!Ge}return Te=Ee,!0}),Te&&Object(p.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Te.displayName||Te.name||Te,"`.")),Object(p.a)(De===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var P=T,I=Object(n.a)({prefixCls:"rc-select",components:{optionList:r},convertChildrenToData:u,flattenOptions:e.d,getLabeledValue:e.e,filterOptions:e.b,isValueDisabled:e.g,findValueOption:e.c,warningProps:P,fillOptionsWithMissingValue:e.a}),F=function(X){Object(S.a)(J,X);var K=Object(U.a)(J);function J(){var ne;return Object(he.a)(this,J),ne=K.apply(this,arguments),ne.selectRef=L.createRef(),ne.focus=function(){ne.selectRef.current.focus()},ne.blur=function(){ne.selectRef.current.blur()},ne}return Object(N.a)(J,[{key:"render",value:function(){return L.createElement(I,Object.assign({ref:this.selectRef},this.props))}}]),J}(L.Component);F.Option=o,F.OptGroup=l;var W=F,z=tt.c=W},SJMd:function(vt,tt){/**
|
|
* @license
|
|
* Copyright (C) 2006 Google Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/var ae,he,N,S=!1,U,L;window.PR_SHOULD_USE_CONTINUATION=!0;var _,B;(function(){var O=window,k=["break,continue,do,else,for,if,return,while"],w=[k,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],v=[w,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],x=[v,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],C=[v,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],E=[v,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],b="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",y=[v,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],d="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",r=[k,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],i=[k,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],o=[k,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],f=[x,E,C,y,d,r,i,o],l=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,h="str",m="kwd",c="com",u="typ",e="lit",n="pun",a="pln",p="tag",g="dec",T="src",P="atn",I="atv",F="nocode",W="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(fe){for(var Ce=0,Se=!1,me=!1,Te=0,pe=fe.length;Te<pe;++Te){var Ee=fe[Te];if(Ee.ignoreCase)me=!0;else if(/[a-z]/i.test(Ee.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Se=!0,me=!1;break}}var Ge={b:8,t:9,n:10,v:11,f:12,r:13};function Le(_e){var we=_e.charCodeAt(0);if(we!==92)return we;var We=_e.charAt(1);return we=Ge[We],we||("0"<=We&&We<="7"?parseInt(_e.substring(1),8):We==="u"||We==="x"?parseInt(_e.substring(2),16):_e.charCodeAt(1))}function ke(_e){if(_e<32)return(_e<16?"\\x0":"\\x")+_e.toString(16);var we=String.fromCharCode(_e);return we==="\\"||we==="-"||we==="]"||we==="^"?"\\"+we:we}function Ne(_e){var we=_e.substring(1,_e.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g")),We=[],Pe=we[0]==="^",le=["["];Pe&&le.push("^");for(var xe=Pe?1:0,q=we.length;xe<q;++xe){var Q=we[xe];if(/\\[bdsw]/i.test(Q))le.push(Q);else{var Z=Le(Q),j;xe+2<q&&we[xe+1]==="-"?(j=Le(we[xe+2]),xe+=2):j=Z,We.push([Z,j]),j<65||Z>122||(j<65||Z>90||We.push([Math.max(65,Z)|32,Math.min(j,90)|32]),j<97||Z>122||We.push([Math.max(97,Z)&~32,Math.min(j,122)&~32]))}}We.sort(function(ie,se){return ie[0]-se[0]||se[1]-ie[1]});for(var H=[],G=[],xe=0;xe<We.length;++xe){var V=We[xe];V[0]<=G[1]+1?G[1]=Math.max(G[1],V[1]):H.push(G=V)}for(var xe=0;xe<H.length;++xe){var V=H[xe];le.push(ke(V[0])),V[1]>V[0]&&(V[1]+1>V[0]&&le.push("-"),le.push(ke(V[1])))}return le.push("]"),le.join("")}function ee(_e){for(var we=_e.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),We=we.length,Pe=[],le=0,xe=0;le<We;++le){var q=we[le];if(q==="(")++xe;else if(q.charAt(0)==="\\"){var Q=+q.substring(1);Q&&(Q<=xe?Pe[Q]=-1:we[le]=ke(Q))}}for(var le=1;le<Pe.length;++le)Pe[le]===-1&&(Pe[le]=++Ce);for(var le=0,xe=0;le<We;++le){var q=we[le];if(q==="(")++xe,Pe[xe]||(we[le]="(?:");else if(q.charAt(0)==="\\"){var Q=+q.substring(1);Q&&Q<=xe&&(we[le]="\\"+Pe[Q])}}for(var le=0;le<We;++le)we[le]==="^"&&we[le+1]!=="^"&&(we[le]="");if(_e.ignoreCase&&Se)for(var le=0;le<We;++le){var q=we[le],Z=q.charAt(0);q.length>=2&&Z==="["?we[le]=Ne(q):Z!=="\\"&&(we[le]=q.replace(/[a-zA-Z]/g,function(G){var V=G.charCodeAt(0);return"["+String.fromCharCode(V&~32,V|32)+"]"}))}return we.join("")}for(var Be=[],Te=0,pe=fe.length;Te<pe;++Te){var Ee=fe[Te];if(Ee.global||Ee.multiline)throw new Error(""+Ee);Be.push("(?:"+ee(Ee)+")")}return new RegExp(Be.join("|"),me?"gi":"g")}function X(fe,Ce){var Se=/(?:^|\s)nocode(?:\s|$)/,me=[],Te=0,pe=[],Ee=0;function Ge(Le){var ke=Le.nodeType;if(ke==1){if(Se.test(Le.className))return;for(var Ne=Le.firstChild;Ne;Ne=Ne.nextSibling)Ge(Ne);var ee=Le.nodeName.toLowerCase();(ee==="br"||ee==="li")&&(me[Ee]=`
|
|
`,pe[Ee<<1]=Te++,pe[Ee++<<1|1]=Le)}else if(ke==3||ke==4){var Be=Le.nodeValue;Be.length&&(Ce?Be=Be.replace(/\r\n?/g,`
|
|
`):Be=Be.replace(/[ \t\r\n]+/g," "),me[Ee]=Be,pe[Ee<<1]=Te,Te+=Be.length,pe[Ee++<<1|1]=Le)}}return Ge(fe),{sourceCode:me.join("").replace(/\n$/,""),spans:pe}}function K(fe,Ce,Se,me,Te){if(!Se)return;var pe={sourceNode:fe,pre:1,langExtension:null,numberLines:null,sourceCode:Se,spans:null,basePos:Ce,decorations:null};me(pe),Te.push.apply(Te,pe.decorations)}var J=/\S/;function ne(fe){for(var Ce=void 0,Se=fe.firstChild;Se;Se=Se.nextSibling){var me=Se.nodeType;Ce=me===1?Ce?fe:Se:me===3&&J.test(Se.nodeValue)?fe:Ce}return Ce===fe?void 0:Ce}function re(fe,Ce){var Se={},me;(function(){for(var Ee=fe.concat(Ce),Ge=[],Le={},ke=0,Ne=Ee.length;ke<Ne;++ke){var ee=Ee[ke],Be=ee[3];if(Be)for(var _e=Be.length;--_e>=0;)Se[Be.charAt(_e)]=ee;var we=ee[1],We=""+we;Le.hasOwnProperty(We)||(Ge.push(we),Le[We]=null)}Ge.push(/[\0-\uffff]/),me=z(Ge)})();var Te=Ce.length,pe=function(Ee){for(var Ge=Ee.sourceCode,Le=Ee.basePos,ke=Ee.sourceNode,Ne=[Le,a],ee=0,Be=Ge.match(me)||[],_e={},we=0,We=Be.length;we<We;++we){var Pe=Be[we],le=_e[Pe],xe=void 0,q;if(typeof le=="string")q=!1;else{var Q=Se[Pe.charAt(0)];if(Q)xe=Pe.match(Q[1]),le=Q[0];else{for(var Z=0;Z<Te;++Z)if(Q=Ce[Z],xe=Pe.match(Q[1]),xe){le=Q[0];break}xe||(le=a)}q=le.length>=5&&le.substring(0,5)==="lang-",q&&!(xe&&typeof xe[1]=="string")&&(q=!1,le=T),q||(_e[Pe]=le)}var j=ee;if(ee+=Pe.length,!q)Ne.push(Le+j,le);else{var H=xe[1],G=Pe.indexOf(H),V=G+H.length;xe[2]&&(V=Pe.length-xe[2].length,G=V-H.length);var ie=le.substring(5);K(ke,Le+j,Pe.substring(0,G),pe,Ne),K(ke,Le+j+G,H,$(ie,H),Ne),K(ke,Le+j+V,Pe.substring(V),pe,Ne)}}Ee.decorations=Ne};return pe}function be(fe){var Ce=[],Se=[];fe.tripleQuotedStrings?Ce.push([h,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):fe.multiLineStrings?Ce.push([h,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Ce.push([h,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),fe.verbatimStrings&&Se.push([h,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var me=fe.hashComments;me&&(fe.cStyleComments?(me>1?Ce.push([c,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Ce.push([c,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Se.push([h,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Ce.push([c,/^#[^\r\n]*/,null,"#"])),fe.cStyleComments&&(Se.push([c,/^\/\/[^\r\n]*/,null]),Se.push([c,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Te=fe.regexLiterals;if(Te){var pe=Te>1?"":`
|
|
\r`,Ee=pe?".":"[\\S\\s]",Ge="/(?=[^/*"+pe+"])(?:[^/\\x5B\\x5C"+pe+"]|\\x5C"+Ee+"|\\x5B(?:[^\\x5C\\x5D"+pe+"]|\\x5C"+Ee+")*(?:\\x5D|$))+/";Se.push(["lang-regex",RegExp("^"+W+"("+Ge+")")])}var Le=fe.types;Le&&Se.push([u,Le]);var ke=(""+fe.keywords).replace(/^ | $/g,"");ke.length&&Se.push([m,new RegExp("^(?:"+ke.replace(/[\s,]+/g,"|")+")\\b"),null]),Ce.push([a,/^\s+/,null,` \r
|
|
\xA0`]);var Ne="^.[^\\s\\w.$@'\"`/\\\\]*";return fe.regexLiterals&&(Ne+="(?!s*/)"),Se.push([e,/^@[a-z_$][a-z_$@0-9]*/i,null],[u,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[e,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[n,new RegExp(Ne),null]),re(Ce,Se)}var oe=be({keywords:f,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function ue(fe,Ce,Se){for(var me=/(?:^|\s)nocode(?:\s|$)/,Te=/\r\n?|\n/,pe=fe.ownerDocument,Ee=pe.createElement("li");fe.firstChild;)Ee.appendChild(fe.firstChild);var Ge=[Ee];function Le(we){var We=we.nodeType;if(We==1&&!me.test(we.className))if(we.nodeName==="br")ke(we),we.parentNode&&we.parentNode.removeChild(we);else for(var Pe=we.firstChild;Pe;Pe=Pe.nextSibling)Le(Pe);else if((We==3||We==4)&&Se){var le=we.nodeValue,xe=le.match(Te);if(xe){var q=le.substring(0,xe.index);we.nodeValue=q;var Q=le.substring(xe.index+xe[0].length);if(Q){var Z=we.parentNode;Z.insertBefore(pe.createTextNode(Q),we.nextSibling)}ke(we),q||we.parentNode.removeChild(we)}}}function ke(we){for(;!we.nextSibling;)if(we=we.parentNode,!we)return;function We(xe,q){var Q=q?xe.cloneNode(!1):xe,Z=xe.parentNode;if(Z){var j=We(Z,1),H=xe.nextSibling;j.appendChild(Q);for(var G=H;G;G=H)H=G.nextSibling,j.appendChild(G)}return Q}for(var Pe=We(we.nextSibling,0),le;(le=Pe.parentNode)&&le.nodeType===1;)Pe=le;Ge.push(Pe)}for(var Ne=0;Ne<Ge.length;++Ne)Le(Ge[Ne]);Ce===(Ce|0)&&Ge[0].setAttribute("value",Ce);var ee=pe.createElement("ol");ee.className="linenums";for(var Be=Math.max(0,Ce-1|0)||0,Ne=0,_e=Ge.length;Ne<_e;++Ne)Ee=Ge[Ne],Ee.className="L"+(Ne+Be)%10,Ee.firstChild||Ee.appendChild(pe.createTextNode("\xA0")),ee.appendChild(Ee);fe.appendChild(ee)}function de(fe){var Ce=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Ce=Ce&&+Ce[1]<=8;var Se=/\n/g,me=fe.sourceCode,Te=me.length,pe=0,Ee=fe.spans,Ge=Ee.length,Le=0,ke=fe.decorations,Ne=ke.length,ee=0;ke[Ne]=Te;var Be,_e;for(_e=Be=0;_e<Ne;)ke[_e]!==ke[_e+2]?(ke[Be++]=ke[_e++],ke[Be++]=ke[_e++]):_e+=2;for(Ne=Be,_e=Be=0;_e<Ne;){for(var we=ke[_e],We=ke[_e+1],Pe=_e+2;Pe+2<=Ne&&ke[Pe+1]===We;)Pe+=2;ke[Be++]=we,ke[Be++]=We,_e=Pe}Ne=ke.length=Be;var le=fe.sourceNode,xe="";le&&(xe=le.style.display,le.style.display="none");try{for(var q=null;Le<Ge;){var Q=Ee[Le],Z=Ee[Le+2]||Te,j=ke[ee+2]||Te,Pe=Math.min(Z,j),H=Ee[Le+1],G;if(H.nodeType!==1&&(G=me.substring(pe,Pe))){Ce&&(G=G.replace(Se,"\r")),H.nodeValue=G;var V=H.ownerDocument,ie=V.createElement("span");ie.className=ke[ee+1];var se=H.parentNode;se.replaceChild(ie,H),ie.appendChild(H),pe<Z&&(Ee[Le+1]=H=V.createTextNode(me.substring(Pe,Z)),se.insertBefore(H,ie.nextSibling))}pe=Pe,pe>=Z&&(Le+=2),pe>=j&&(ee+=2)}}finally{le&&(le.style.display=xe)}}var ce={};function te(fe,Ce){for(var Se=Ce.length;--Se>=0;){var me=Ce[Se];ce.hasOwnProperty(me)?O.console&&console.warn("cannot override language handler %s",me):ce[me]=fe}}function $(fe,Ce){return fe&&ce.hasOwnProperty(fe)||(fe=/^\s*</.test(Ce)?"default-markup":"default-code"),ce[fe]}te(oe,["default-code"]),te(re([],[[a,/^[^<?]+/],[g,/^<!\w[^>]*(?:>|$)/],[c,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[n,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),te(re([[a,/^[\s]+/,null,` \r
|
|
`],[I,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[p,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[n,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),te(re([],[[I,/^[\s\S]+/]]),["uq.val"]),te(be({keywords:x,hashComments:!0,cStyleComments:!0,types:l}),["c","cc","cpp","cxx","cyc","m"]),te(be({keywords:"null,true,false"}),["json"]),te(be({keywords:E,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:l}),["cs"]),te(be({keywords:C,cStyleComments:!0}),["java"]),te(be({keywords:o,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),te(be({keywords:r,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),te(be({keywords:d,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),te(be({keywords:i,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),te(be({keywords:y,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),te(be({keywords:b,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),te(re([],[[h,/^[\s\S]+/]]),["regex"]);function Ae(fe){var Ce=fe.langExtension;try{var Se=X(fe.sourceNode,fe.pre),me=Se.sourceCode;fe.sourceCode=me,fe.spans=Se.spans,fe.basePos=0,$(Ce,me)(fe),de(fe)}catch(Te){O.console&&console.log(Te&&Te.stack||Te)}}function Fe(fe,Ce,Se){var me=Se||!1,Te=Ce||null,pe=document.createElement("div");pe.innerHTML="<pre>"+fe+"</pre>",pe=pe.firstChild,me&&ue(pe,me,!0);var Ee={langExtension:Te,numberLines:me,sourceNode:pe,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return Ae(Ee),pe.innerHTML}function De(fe,Ce){var Se=Ce||document.body,me=Se.ownerDocument||document;function Te(Q){return Se.getElementsByTagName(Q)}for(var pe=[Te("pre"),Te("code"),Te("xmp")],Ee=[],Ge=0;Ge<pe.length;++Ge)for(var Le=0,ke=pe[Ge].length;Le<ke;++Le)Ee.push(pe[Ge][Le]);pe=null;var Ne=Date;Ne.now||(Ne={now:function(){return+new Date}});var ee=0,Be=/\blang(?:uage)?-([\w.]+)(?!\S)/,_e=/\bprettyprint\b/,we=/\bprettyprinted\b/,We=/pre|xmp/i,Pe=/^code$/i,le=/^(?:pre|code|xmp)$/i,xe={};function q(){for(var Q=O.PR_SHOULD_USE_CONTINUATION?Ne.now()+250:Infinity;ee<Ee.length&&Ne.now()<Q;ee++){for(var Z=Ee[ee],j=xe,H=Z;H=H.previousSibling;){var G=H.nodeType,V=(G===7||G===8)&&H.nodeValue;if(V?!/^\??prettify\b/.test(V):G!==3||/\S/.test(H.nodeValue))break;if(V){j={},V.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Ye,it,mt){j[it]=mt});break}}var ie=Z.className;if((j!==xe||_e.test(ie))&&!we.test(ie)){for(var se=!1,ve=Z.parentNode;ve;ve=ve.parentNode){var Oe=ve.tagName;if(le.test(Oe)&&ve.className&&_e.test(ve.className)){se=!0;break}}if(!se){Z.className+=" prettyprinted";var je=j.lang;if(!je){je=ie.match(Be);var Me;!je&&(Me=ne(Z))&&Pe.test(Me.tagName)&&(je=Me.className.match(Be)),je&&(je=je[1])}var Xe;if(We.test(Z.tagName))Xe=1;else{var $e=Z.currentStyle,He=me.defaultView,Ze=$e?$e.whiteSpace:He&&He.getComputedStyle?He.getComputedStyle(Z,null).getPropertyValue("white-space"):0;Xe=Ze&&Ze.substring(0,3)==="pre"}var rt=j.linenums;(rt=rt==="true"||+rt)||(rt=ie.match(/\blinenums\b(?::(\d+))?/),rt=rt?rt[1]&&rt[1].length?+rt[1]:!0:!1),rt&&ue(Z,rt,Xe);var lt={langExtension:je,sourceNode:Z,numberLines:rt,pre:Xe,sourceCode:null,basePos:null,spans:null,decorations:null};Ae(lt)}}}ee<Ee.length?O.setTimeout(q,250):typeof fe=="function"&&fe()}q()}var Ue=O.PR={createSimpleLexer:re,registerLangHandler:te,sourceDecorator:be,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:I,PR_COMMENT:c,PR_DECLARATION:g,PR_KEYWORD:m,PR_LITERAL:e,PR_NOCODE:F,PR_PLAIN:a,PR_PUNCTUATION:n,PR_SOURCE:T,PR_STRING:h,PR_TAG:p,PR_TYPE:u,prettyPrintOne:S?O.prettyPrintOne=Fe:_=Fe,prettyPrint:B=S?O.prettyPrint=De:B=De},Re=O.define;typeof Re=="function"&&Re.amd&&Re("google-code-prettify",[],function(){return Ue})})()},VSi8:function(vt,tt,ae){"use strict";ae.r(tt);var he=ae("+L6B"),N=ae("2/Rp"),S=ae("5NDa"),U=ae("5rEg"),L=ae("5Dmo"),_=ae("3S7+"),B=ae("14J3"),O=ae("BMrR"),k=ae("jCWc"),w=ae("kPKH"),v=ae("sPJy"),x=ae("bE4q"),C=ae("/zsF"),E=ae("PArb"),b=ae("miYZ"),y=ae("tsqr"),d=ae("9og8"),r=ae("k1fw"),i=ae("oBTY"),o=ae("y8nQ"),f=ae("Vl3Y"),l=ae("tJVT"),h=ae("PpiC"),m=ae("WmNS"),c=ae.n(m),u=ae("q1tI"),e=ae.n(u),n=ae("Ty5D"),a=ae("55Ip"),p=ae("9kvl"),g=ae("w5pM"),T=ae("tgas"),P=ae("OaEy"),I=ae("2fM7"),F=ae("sRBo"),W=ae("kaz8"),z=ae("2qtc"),X=ae("kLXV"),K=ae("9Bee"),J=ae("otbz"),ne=ae.n(J),re=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],be=function(me,Te){var pe=me.problemset,Ee=me.globalSetting,Ge=me.loading,Le=me.dispatch,ke=me.onRef,Ne=ke===void 0?function(){}:ke,ee=me.editData,Be=me.editKey,_e=me.callback,we=Object(h.a)(me,["problemset","globalSetting","loading","dispatch","onRef","editData","editKey","callback"]),We=Object(u.useState)([]),Pe=Object(l.a)(We,2),le=Pe[0],xe=Pe[1],q=Object(u.useState)(),Q=Object(l.a)(q,2),Z=Q[0],j=Q[1],H=Object(u.useState)([]),G=Object(l.a)(H,2),V=G[0],ie=G[1],se=Object(u.useState)(""),ve=Object(l.a)(se,2),Oe=ve[0],je=ve[1],Me=Object(u.useState)(0),Xe=Object(l.a)(Me,2),$e=Xe[0],He=Xe[1],Ze=Object(u.useState)(!0),rt=Object(l.a)(Ze,2),lt=rt[0],Ye=rt[1],it=Object(u.useState)(!1),mt=Object(l.a)(it,2),kt=mt[0],Ve=mt[1],Ct=Object(n.i)(),At=Object(u.useState)(""),st=Object(l.a)(At,2),nt=st[0],ot=st[1],Et=Object(u.useState)(""),qe=Object(l.a)(Et,2),Je=qe[0],et=qe[1];Object(u.useEffect)(function(){var _t,at,Ke,dt,xt,Tt,ht,R;if(!(ee!=null&&(_t=ee.question)!==null&&_t!==void 0&&_t.question_title)){xe([{disabled:!1,value:""},{disabled:!1,value:""},{disabled:!1,value:""},{disabled:!1,value:""}]),Ye(!0),je(""),Ve(!1);return}ot(ee==null||((at=ee.question)===null||at===void 0)?void 0:at.max_choices),et(ee==null||((Ke=ee.question)===null||Ke===void 0)?void 0:Ke.min_choices),je(ee==null||((dt=ee.question)===null||dt===void 0)?void 0:dt.question_title),Ye(!!(ee!=null&&(xt=ee.question)!==null&&xt!==void 0&&xt.is_necessary)),xe(ee==null||((Tt=ee.question)===null||Tt===void 0)?void 0:Tt.answers.map(function(t){return{value:t.answer_text,disabled:t.answer_text==="\u5176\u5B83"}})),Ve(!!(ee!=null&&(ht=ee.question)!==null&&ht!==void 0&&(R=ht.answers)!==null&&R!==void 0&&R.find(function(t){return t.answer_text==="\u5176\u5B83"})))},[ee]),Object(u.useImperativeHandle)(Te,function(){return{onSave:ct}});var ct=function(){var _t=Object(d.a)(c.a.mark(function at(Ke){var dt,xt,Tt,ht,R,t;return c.a.wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(!(nt&&!Je||!nt&&Je)){A.next=3;break}return y.b.info('\u53EF\u9009\uFF1A\u6700\u5C0F\u548C\u6700\u5927\u9650\u5236\u987B\u540C\u65F6\u4E3A\u6570\u503C\u6216\u8005\u201C--"'),A.abrupt("return");case 3:if(!(Je>nt)){A.next=6;break}return y.b.info("\u53EF\u9009\u7684\u6700\u5927\u9650\u5236\u4E0D\u80FD\u5C0F\u4E8E\u6700\u5C0F\u9650\u5236"),A.abrupt("return");case 6:if(Oe){A.next=9;break}return y.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u76EE"),A.abrupt("return",!1);case 9:if(xt=le.findIndex(function(M){return!M.value}),!(xt>-1)){A.next=13;break}return y.b.info("\u8BF7\u5148\u8F93\u5165 ".concat(re[xt]," \u9009\u9879\u7684\u5185\u5BB9")),A.abrupt("return",!1);case 13:if(ht={question_title:Oe,question_type:2,insert_id:ee.insert_id,is_necessary:Math.ceil(lt),max_choices:nt,min_choices:Je,question_answers:le.map(function(M){return M.value})},!((dt=ee.question)!==null&&dt!==void 0&&dt.id)){A.next=20;break}return A.next=17,Object(T.w)(Object(r.a)({pollsId:ee.question.id},ht));case 17:Tt=A.sent,A.next=23;break;case 20:return A.next=22,Object(T.c)(Object(r.a)({exercise_bank_id:Ct.topicId},ht));case 22:Tt=A.sent;case 23:if(!(Tt.status===0)){A.next=30;break}return y.b.success("\u4FDD\u5B58\u6210\u529F"),_e("edit",-1),A.next=28,Le({type:"polls/getExerciseBanks",payload:Object(r.a)({},Ct)});case 28:R=A.sent,Ke&&(ht.answers=ht.question_answers.map(function(M){return{answer_text:M}}),t=[].concat(Object(i.a)(R==null?void 0:R.questions),[{question:Object(r.a)({type:2,insert_id:ee.question.id,key:ee.key,question_type:2},ht)}]),_e("addContinue",{editData:t}));case 30:case"end":return A.stop()}},at)}));return function(Ke){return _t.apply(this,arguments)}}(),yt=[{name:"\u5220\u9664",icon:"iconfont c-light-black ml30 icon-shanchu current",id:"del"},{name:"\u4E0A\u79FB",icon:"iconfont c-green ml30 icon-xiangshangyi current",id:"up"},{name:"\u4E0B\u79FB",icon:"iconfont c-green ml30 icon-xiangxiayi current",id:"down"},{name:"\u6DFB\u52A0",icon:"iconfont c-green ml30 icon-tianjia current",id:"add"},{name:"\u7F16\u8F91",icon:"iconfont c-green ml30 icon-bianjidaibeijing current",id:"edit"}],wt=function(){var _t=Object(d.a)(c.a.mark(function at(Ke){var dt,xt;return c.a.wrap(function(ht){for(;;)switch(ht.prev=ht.next){case 0:ht.t0=Ke.id,ht.next=ht.t0==="del"?3:ht.t0==="up"||ht.t0==="down"?5:ht.t0==="edit"?9:ht.t0==="add"?11:13;break;case 3:return X.a.confirm({centered:!0,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u786E\u8BA4\u8981\u5220\u9664\u8FD9\u4E2A\u95EE\u9898\u5417\uFF1F",onOk:function(){return Object(d.a)(c.a.mark(function t(){var s;return c.a.wrap(function(M){for(;;)switch(M.prev=M.next){case 0:return M.next=2,Object(T.e)({pollsId:ee==null||((s=ee.question)===null||s===void 0)?void 0:s.id});case 2:Le({type:"polls/getExerciseBanks",payload:Object(r.a)({},Ct)});case 3:case"end":return M.stop()}},t)}))()}}),ht.abrupt("break",13);case 5:return ht.next=7,Object(T.i)({pollsId:ee==null||((dt=ee.question)===null||dt===void 0)?void 0:dt.id,opr:Ke.id});case 7:return Le({type:"polls/getExerciseBanks",payload:Object(r.a)({},Ct)}),ht.abrupt("break",13);case 9:return _e("edit",ee.key),ht.abrupt("break",13);case 11:return _e("add",{type:2,key:ee.key,insert_id:ee==null||((xt=ee.question)===null||xt===void 0)?void 0:xt.id,question_type:2}),ht.abrupt("break",13);case 13:case"end":return ht.stop()}},at)}));return function(Ke){return _t.apply(this,arguments)}}(),ut=function(){var at,Ke,dt,xt;return e.a.createElement("aside",null,e.a.createElement("div",{className:ne.a.questionType},e.a.createElement("div",null,e.a.createElement("span",{className:"font16"},"\u7B2C",ee.key,"\u9898"),e.a.createElement("span",{className:"font16 c-light-black ml10"},"\u591A\u9009\u9898"),e.a.createElement("span",{className:"tag-grey-eae ml10 mr10"},(ee==null||((at=ee.question)===null||at===void 0)?void 0:at.is_necessary)===0?"\u9009\u7B54":"\u5FC5\u7B54"),"\u53EF\u9009",ee==null||((Ke=ee.question)===null||Ke===void 0)?void 0:Ke.min_choices,"-",ee==null||((dt=ee.question)===null||dt===void 0)?void 0:dt.max_choices,"\u9879"),yt.map(function(Tt,ht){return Tt.id==="up"&&ee.key===1||Tt.id==="down"&&ee.key===ee.len?null:e.a.createElement(_.a,{key:ht,placement:"bottom",title:Tt.name},e.a.createElement("span",{onClick:function(){return wt(Tt)},className:Tt.icon}))})),e.a.createElement("div",{className:"mt5"},e.a.createElement(K.a,{value:ee.question.question_title})),e.a.createElement("div",{className:ne.a.questionChoices},ee==null||((xt=ee.question.answers)===null||xt===void 0)?void 0:xt.map(function(Tt,ht){return e.a.createElement(O.a,null,e.a.createElement(w.a,null,e.a.createElement(W.a,{key:ht,disabled:!0},e.a.createElement("span",{className:"c-black font14"},Tt.answer_text))))})))},Ot=function(){return e.a.createElement("aside",null,e.a.createElement("div",{className:ne.a.questionType},e.a.createElement("div",null,e.a.createElement("span",{className:"font16 c-blue"},"\u591A\u9009\u9898")," ",e.a.createElement(W.a,{checked:!!lt,className:"ml10",onChange:function(Ke){return Ye(Ke.target.checked)}},"\u5FC5\u7B54"))),e.a.createElement("p",{className:ne.a.titleWrap},e.a.createElement(U.a.TextArea,{autoSize:{maxRows:5},rows:1,value:Oe,placeholder:"\u8BF7\u8F93\u5165\u9898\u76EE",onChange:function(Ke){return je(Ke.target.value)}})),le.map(function(at,Ke){return e.a.createElement(O.a,{className:ne.a.choiceWrap,key:Ke,gutter:[12,12]},e.a.createElement(w.a,null,e.a.createElement("span",{className:"font16"},"\u9009\u9879")),e.a.createElement(w.a,{className:ne.a.editorWrap,flex:"1"},e.a.createElement(U.a.TextArea,{autoSize:{maxRows:5},value:le[Ke].value,rows:1,disabled:!!at.disabled,onChange:function(xt){le[Ke].value=xt.target.value,xe(Object(i.a)(le))}})),e.a.createElement(w.a,null,Ke>1&&e.a.createElement(_.a,{title:"\u5220\u9664"},e.a.createElement("i",{className:"".concat(ne.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){xe(le.filter(function(xt,Tt){return Tt!==Ke})),at.disabled&&Ve(!1)}}))))}),e.a.createElement(O.a,{gutter:[12,12]},e.a.createElement(w.a,null,"\u53EF\u9009"),e.a.createElement(w.a,null,e.a.createElement(I.a,{value:Je||"",style:{width:120},onChange:function(Ke){return et(Ke)}},e.a.createElement(I.a.Option,{value:""},"--"),le.map(function(at,Ke){return e.a.createElement(I.a.Option,{value:String(Ke+2)},Ke+2)})),e.a.createElement("span",{className:"ml10 mr10"},"~"),e.a.createElement(I.a,{style:{width:120},value:nt||"",onChange:function(Ke){return ot(Ke)}},e.a.createElement(I.a.Option,{value:""},"--"),le.map(function(at,Ke){return e.a.createElement(I.a.Option,{value:String(Ke+2)},Ke+2)})),e.a.createElement("span",{className:"font14 c-grey-999"},"\uFF08\u5B66\u751F\u7B54\u9898\u65F6\uFF0C\u7CFB\u7EDF\u5BF9\u5176\u9009\u62E9\u7684\u9009\u9879\u4E2A\u6570\u8FDB\u884C\u9650\u5236\uFF0C--\u8868\u793A\u4E0D\u9650\u5236\uFF09"))),e.a.createElement(O.a,{gutter:[12,12]},e.a.createElement(w.a,{flex:"1"},e.a.createElement(N.a,{type:"default",onClick:function(){le.find(function(Ke){return Ke.value==="\u5176\u5B83"})?xe([].concat(Object(i.a)(le.filter(function(Ke){return Ke.value!=="\u5176\u5B83"})),[{value:""},{value:"\u5176\u5B83",disabled:!0}])):xe([].concat(Object(i.a)(le),[{value:""}]))}},"\u65B0\u589E\u9009\u9879"),!kt&&e.a.createElement(N.a,{type:"default",className:"ml20",onClick:function(){xe([].concat(Object(i.a)(le),[{disabled:!0,value:"\u5176\u5B83"}])),Ve(!0)}},"\u65B0\u589E\u5176\u5B83\u9009\u9879")),e.a.createElement(w.a,{className:"tl"},e.a.createElement(N.a,{type:"default",onClick:function(){var Ke;(Ke=ee.question)!==null&&Ke!==void 0&&Ke.id?_e("edit",-1):_e("del",ee.key)}},"\u53D6\u6D88"),e.a.createElement(N.a,{className:"ml20",type:"primary",onClick:function(){return ct()}},"\u4FDD\u5B58"),e.a.createElement(N.a,{className:"ml20",type:"primary",onClick:function(){return ct(!0)}},"\u4FDD\u5B58\u5E76\u7EE7\u7EED"))))};return e.a.createElement("section",{className:ne.a.wrap},Be!==ee.key&&ut(),Be===ee.key&&Ot())},oe=Object(p.a)(function(Se){var me=Se.problemset,Te=Se.loading,pe=Se.globalSetting;return{problemset:me,globalSetting:pe,loading:Te.effects}},null,null,{forwardRef:!0})(Object(u.forwardRef)(be)),ue=ae("7Kak"),de=ae("9yH6"),ce=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],te=function(me,Te){var pe=me.problemset,Ee=me.globalSetting,Ge=me.loading,Le=me.dispatch,ke=me.onRef,Ne=ke===void 0?function(){}:ke,ee=me.editData,Be=me.editKey,_e=me.callback,we=Object(h.a)(me,["problemset","globalSetting","loading","dispatch","onRef","editData","editKey","callback"]),We=Object(u.useState)([]),Pe=Object(l.a)(We,2),le=Pe[0],xe=Pe[1],q=Object(u.useState)(),Q=Object(l.a)(q,2),Z=Q[0],j=Q[1],H=Object(u.useState)([]),G=Object(l.a)(H,2),V=G[0],ie=G[1],se=Object(u.useState)(""),ve=Object(l.a)(se,2),Oe=ve[0],je=ve[1],Me=Object(u.useState)(0),Xe=Object(l.a)(Me,2),$e=Xe[0],He=Xe[1],Ze=Object(u.useState)(!1),rt=Object(l.a)(Ze,2),lt=rt[0],Ye=rt[1],it=Object(u.useState)(!1),mt=Object(l.a)(it,2),kt=mt[0],Ve=mt[1],Ct=Object(n.i)();Object(u.useEffect)(function(){var qe,Je,et,ct,yt,wt;if(!(ee!=null&&(qe=ee.question)!==null&&qe!==void 0&&qe.question_title)){xe([{disabled:!1,value:""},{disabled:!1,value:""},{disabled:!1,value:""},{disabled:!1,value:""}]),Ye(!1),je(""),Ve(!1);return}je(ee==null||((Je=ee.question)===null||Je===void 0)?void 0:Je.question_title),Ye(!!(ee!=null&&(et=ee.question)!==null&&et!==void 0&&et.is_necessary)),xe(ee==null||((ct=ee.question)===null||ct===void 0)?void 0:ct.answers.map(function(ut){return{value:ut.answer_text,disabled:ut.answer_text==="\u5176\u5B83"}})),Ve(!!(ee!=null&&(yt=ee.question)!==null&&yt!==void 0&&(wt=yt.answers)!==null&&wt!==void 0&&wt.find(function(ut){return ut.answer_text==="\u5176\u5B83"})))},[ee]),Object(u.useImperativeHandle)(Te,function(){return{onSave:At}});var At=function(){var qe=Object(d.a)(c.a.mark(function Je(et){var ct,yt,wt,ut,Ot,_t;return c.a.wrap(function(Ke){for(;;)switch(Ke.prev=Ke.next){case 0:if(Oe){Ke.next=3;break}return y.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u76EE"),Ke.abrupt("return",!1);case 3:if(yt=le.findIndex(function(dt){return!dt.value}),!(yt>-1)){Ke.next=7;break}return y.b.info("\u8BF7\u5148\u8F93\u5165 ".concat(ce[yt]," \u9009\u9879\u7684\u5185\u5BB9")),Ke.abrupt("return",!1);case 7:if(ut={question_title:Oe,question_type:1,insert_id:ee.insert_id,is_necessary:Math.ceil(lt),question_answers:le.map(function(dt){return dt.value})},!((ct=ee.question)!==null&&ct!==void 0&&ct.id)){Ke.next=14;break}return Ke.next=11,Object(T.w)(Object(r.a)({pollsId:ee.question.id},ut));case 11:wt=Ke.sent,Ke.next=17;break;case 14:return Ke.next=16,Object(T.c)(Object(r.a)({exercise_bank_id:Ct.topicId},ut));case 16:wt=Ke.sent;case 17:if(!(wt.status===0)){Ke.next=24;break}return y.b.success("\u4FDD\u5B58\u6210\u529F"),_e("edit",-1),Ke.next=22,Le({type:"polls/getExerciseBanks",payload:Object(r.a)({},Ct)});case 22:Ot=Ke.sent,et&&(ut.answers=ut.question_answers.map(function(dt){return{answer_text:dt}}),_t=[].concat(Object(i.a)(Ot==null?void 0:Ot.questions),[{question:Object(r.a)({type:1,insert_id:ee.question.id,key:ee.key,question_type:1},ut)}]),_e("addContinue",{editData:_t}));case 24:case"end":return Ke.stop()}},Je)}));return function(et){return qe.apply(this,arguments)}}(),st=[{name:"\u5220\u9664",icon:"iconfont c-light-black ml30 icon-shanchu current",id:"del"},{name:"\u4E0A\u79FB",icon:"iconfont c-green ml30 icon-xiangshangyi current",id:"up"},{name:"\u4E0B\u79FB",icon:"iconfont c-green ml30 icon-xiangxiayi current",id:"down"},{name:"\u6DFB\u52A0",icon:"iconfont c-green ml30 icon-tianjia current",id:"add"},{name:"\u7F16\u8F91",icon:"iconfont c-green ml30 icon-bianjidaibeijing current",id:"edit"}],nt=function(){var qe=Object(d.a)(c.a.mark(function Je(et){var ct,yt;return c.a.wrap(function(ut){for(;;)switch(ut.prev=ut.next){case 0:ut.t0=et.id,ut.next=ut.t0==="del"?3:ut.t0==="up"||ut.t0==="down"?5:ut.t0==="edit"?9:ut.t0==="add"?11:13;break;case 3:return X.a.confirm({centered:!0,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u786E\u8BA4\u8981\u5220\u9664\u8FD9\u4E2A\u95EE\u9898\u5417\uFF1F",onOk:function(){return Object(d.a)(c.a.mark(function _t(){var at;return c.a.wrap(function(dt){for(;;)switch(dt.prev=dt.next){case 0:return dt.next=2,Object(T.e)({pollsId:ee==null||((at=ee.question)===null||at===void 0)?void 0:at.id});case 2:Le({type:"polls/getExerciseBanks",payload:Object(r.a)({},Ct)});case 3:case"end":return dt.stop()}},_t)}))()}}),ut.abrupt("break",13);case 5:return ut.next=7,Object(T.i)({pollsId:ee==null||((ct=ee.question)===null||ct===void 0)?void 0:ct.id,opr:et.id});case 7:return Le({type:"polls/getExerciseBanks",payload:Object(r.a)({},Ct)}),ut.abrupt("break",13);case 9:return _e("edit",ee.key),ut.abrupt("break",13);case 11:return _e("add",{type:1,key:ee.key,insert_id:ee==null||((yt=ee.question)===null||yt===void 0)?void 0:yt.id,question_type:1}),ut.abrupt("break",13);case 13:case"end":return ut.stop()}},Je)}));return function(et){return qe.apply(this,arguments)}}(),ot=function(){var Je,et;return e.a.createElement("aside",null,e.a.createElement("div",{className:ne.a.questionType},e.a.createElement("div",null,e.a.createElement("span",{className:"font16"},"\u7B2C",ee.key,"\u9898"),e.a.createElement("span",{className:"font16 c-light-black ml10"},"\u5355\u9009\u9898"),e.a.createElement("span",{className:"tag-grey-eae ml10"},(ee==null||((Je=ee.question)===null||Je===void 0)?void 0:Je.is_necessary)===0?"\u9009\u7B54":"\u5FC5\u7B54")),st.map(function(ct,yt){return ct.id==="up"&&ee.key===1||ct.id==="down"&&ee.key===ee.len?null:e.a.createElement(_.a,{key:yt,placement:"bottom",title:ct.name},e.a.createElement("span",{onClick:function(){return nt(ct)},className:ct.icon}))})),e.a.createElement("div",{className:"mt5"},e.a.createElement(K.a,{value:ee.question.question_title})),e.a.createElement("div",{className:ne.a.questionChoices},ee==null||((et=ee.question.answers)===null||et===void 0)?void 0:et.map(function(ct,yt){return e.a.createElement(O.a,null,e.a.createElement(w.a,null,e.a.createElement(de.a,{key:yt,disabled:!0})),e.a.createElement(w.a,{flex:"1"},e.a.createElement("span",{className:"c-black font14"},ct.answer_text)))})))},Et=function(){return e.a.createElement("aside",null,e.a.createElement("div",{className:ne.a.questionType},e.a.createElement("div",null,e.a.createElement("span",{className:"font16 c-blue"},"\u5355\u9009\u9898")," ",e.a.createElement(W.a,{checked:!!lt,className:"ml10",onChange:function(et){return Ye(et.target.checked)}},"\u5FC5\u7B54"))),e.a.createElement("p",{className:ne.a.titleWrap},e.a.createElement(U.a.TextArea,{autoSize:{maxRows:5},rows:1,value:Oe,placeholder:"\u8BF7\u8F93\u5165\u9898\u76EE",onChange:function(et){return je(et.target.value)}})),le.map(function(Je,et){return e.a.createElement(O.a,{className:ne.a.choiceWrap,key:et,gutter:[12,12]},e.a.createElement(w.a,null,e.a.createElement("span",{className:"font16"},"\u9009\u9879")),e.a.createElement(w.a,{className:ne.a.editorWrap,flex:"1"},e.a.createElement(U.a.TextArea,{autoSize:{maxRows:5},value:le[et].value,rows:1,disabled:!!Je.disabled,onChange:function(yt){le[et].value=yt.target.value,xe(Object(i.a)(le))}})),e.a.createElement(w.a,null,et>1&&e.a.createElement(_.a,{title:"\u5220\u9664"},e.a.createElement("i",{className:"".concat(ne.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){xe(le.filter(function(yt,wt){return wt!==et})),Je.disabled&&Ve(!1)}}))))}),e.a.createElement(O.a,{gutter:[12,12]},e.a.createElement(w.a,{flex:"1"},e.a.createElement(N.a,{type:"default",onClick:function(){le.find(function(et){return et.value==="\u5176\u5B83"})?xe([].concat(Object(i.a)(le.filter(function(et){return et.value!=="\u5176\u5B83"})),[{value:""},{value:"\u5176\u5B83",disabled:!0}])):xe([].concat(Object(i.a)(le),[{value:""}]))}},"\u65B0\u589E\u9009\u9879"),!kt&&e.a.createElement(N.a,{type:"default",className:"ml20",onClick:function(){xe([].concat(Object(i.a)(le),[{disabled:!0,value:"\u5176\u5B83"}])),Ve(!0)}},"\u65B0\u589E\u5176\u5B83\u9009\u9879")),e.a.createElement(w.a,{className:"tl"},e.a.createElement(N.a,{type:"default",onClick:function(){var et;(et=ee.question)!==null&&et!==void 0&&et.id?_e("edit",-1):_e("del",ee.key)}},"\u53D6\u6D88"),e.a.createElement(N.a,{className:"ml20",type:"primary",onClick:function(){return At()}},"\u4FDD\u5B58"),e.a.createElement(N.a,{className:"ml20",type:"primary",onClick:function(){return At(!0)}},"\u4FDD\u5B58\u5E76\u7EE7\u7EED"))))};return e.a.createElement("section",{className:ne.a.wrap},Be!==ee.key&&ot(),Be===ee.key&&Et())},$=Object(p.a)(function(Se){var me=Se.problemset,Te=Se.loading,pe=Se.globalSetting;return{problemset:me,globalSetting:pe,loading:Te.effects}},null,null,{forwardRef:!0})(Object(u.forwardRef)(te)),Ae=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Fe=function(me,Te){var pe=me.problemset,Ee=me.globalSetting,Ge=me.loading,Le=me.dispatch,ke=me.onRef,Ne=ke===void 0?function(){}:ke,ee=me.editData,Be=me.editKey,_e=me.callback,we=Object(h.a)(me,["problemset","globalSetting","loading","dispatch","onRef","editData","editKey","callback"]),We=Object(u.useState)(""),Pe=Object(l.a)(We,2),le=Pe[0],xe=Pe[1],q=Object(u.useState)(!0),Q=Object(l.a)(q,2),Z=Q[0],j=Q[1],H=Object(n.i)();Object(u.useEffect)(function(){var Oe,je,Me;if(!(ee!=null&&(Oe=ee.question)!==null&&Oe!==void 0&&Oe.question_title)){j(!0),xe("");return}xe(ee==null||((je=ee.question)===null||je===void 0)?void 0:je.question_title),j(!!(ee!=null&&(Me=ee.question)!==null&&Me!==void 0&&Me.is_necessary))},[ee]),Object(u.useImperativeHandle)(Te,function(){return{onSave:G}});var G=function(){var Oe=Object(d.a)(c.a.mark(function je(Me){var Xe,$e,He,Ze,rt;return c.a.wrap(function(Ye){for(;;)switch(Ye.prev=Ye.next){case 0:if(le){Ye.next=3;break}return y.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u76EE"),Ye.abrupt("return",!1);case 3:if(He={question_title:le,question_type:3,insert_id:ee.insert_id,is_necessary:Math.ceil(Z)},!((Xe=ee.question)!==null&&Xe!==void 0&&Xe.id)){Ye.next=10;break}return Ye.next=7,Object(T.w)(Object(r.a)({pollsId:ee.question.id},He));case 7:$e=Ye.sent,Ye.next=13;break;case 10:return Ye.next=12,Object(T.c)(Object(r.a)({exercise_bank_id:H.topicId},He));case 12:$e=Ye.sent;case 13:if(!($e.status===0)){Ye.next=20;break}return y.b.success("\u4FDD\u5B58\u6210\u529F"),_e("edit",-1),Ye.next=18,Le({type:"polls/getExerciseBanks",payload:Object(r.a)({},H)});case 18:Ze=Ye.sent,Me&&(rt=[].concat(Object(i.a)(Ze==null?void 0:Ze.questions),[{question:Object(r.a)({type:3,insert_id:ee.question.id,key:ee.key,question_type:3},He)}]),_e("addContinue",{editData:rt}));case 20:case"end":return Ye.stop()}},je)}));return function(Me){return Oe.apply(this,arguments)}}(),V=[{name:"\u5220\u9664",icon:"iconfont c-light-black ml30 icon-shanchu current",id:"del"},{name:"\u4E0A\u79FB",icon:"iconfont c-green ml30 icon-xiangshangyi current",id:"up"},{name:"\u4E0B\u79FB",icon:"iconfont c-green ml30 icon-xiangxiayi current",id:"down"},{name:"\u6DFB\u52A0",icon:"iconfont c-green ml30 icon-tianjia current",id:"add"},{name:"\u7F16\u8F91",icon:"iconfont c-green ml30 icon-bianjidaibeijing current",id:"edit"}],ie=function(){var Oe=Object(d.a)(c.a.mark(function je(Me){var Xe,$e;return c.a.wrap(function(Ze){for(;;)switch(Ze.prev=Ze.next){case 0:Ze.t0=Me.id,Ze.next=Ze.t0==="del"?3:Ze.t0==="up"||Ze.t0==="down"?5:Ze.t0==="edit"?9:Ze.t0==="add"?11:13;break;case 3:return X.a.confirm({centered:!0,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u786E\u8BA4\u8981\u5220\u9664\u8FD9\u4E2A\u95EE\u9898\u5417\uFF1F",onOk:function(){return Object(d.a)(c.a.mark(function lt(){var Ye;return c.a.wrap(function(mt){for(;;)switch(mt.prev=mt.next){case 0:return mt.next=2,Object(T.e)({pollsId:ee==null||((Ye=ee.question)===null||Ye===void 0)?void 0:Ye.id});case 2:Le({type:"polls/getExerciseBanks",payload:Object(r.a)({},H)});case 3:case"end":return mt.stop()}},lt)}))()}}),Ze.abrupt("break",13);case 5:return Ze.next=7,Object(T.i)({pollsId:ee==null||((Xe=ee.question)===null||Xe===void 0)?void 0:Xe.id,opr:Me.id});case 7:return Le({type:"polls/getExerciseBanks",payload:Object(r.a)({},H)}),Ze.abrupt("break",13);case 9:return _e("edit",ee.key),Ze.abrupt("break",13);case 11:return _e("add",{type:3,key:ee.key,insert_id:ee==null||(($e=ee.question)===null||$e===void 0)?void 0:$e.id,question_type:3}),Ze.abrupt("break",13);case 13:case"end":return Ze.stop()}},je)}));return function(Me){return Oe.apply(this,arguments)}}(),se=function(){var je,Me;return e.a.createElement("aside",null,e.a.createElement("div",{className:ne.a.questionType},e.a.createElement("div",null,e.a.createElement("span",{className:"font16"},"\u7B2C",ee.key,"\u9898"),e.a.createElement("span",{className:"font16 c-light-black ml10"},"\u95EE\u7B54\u9898"),e.a.createElement("span",{className:"tag-grey-eae ml10 mr10"},(ee==null||((je=ee.question)===null||je===void 0)?void 0:je.is_necessary)===0?"\u9009\u7B54":"\u5FC5\u7B54")),V.map(function(Xe,$e){return Xe.id==="up"&&ee.key===1||Xe.id==="down"&&ee.key===ee.len?null:e.a.createElement(_.a,{key:$e,placement:"bottom",title:Xe.name},e.a.createElement("span",{onClick:function(){return ie(Xe)},className:Xe.icon}))})),e.a.createElement("div",{className:"mt5"},e.a.createElement(K.a,{value:ee.question.question_title}),e.a.createElement("div",{className:"mt15"},e.a.createElement(U.a.TextArea,{placeholder:"\u5728\u6B64\u586B\u5165\u7B54\u6848",rows:5,disabled:!0}))),e.a.createElement("div",{className:ne.a.questionChoices},ee==null||((Me=ee.question.answers)===null||Me===void 0)?void 0:Me.map(function(Xe,$e){return e.a.createElement(O.a,null,e.a.createElement(w.a,null,e.a.createElement(W.a,{key:$e,disabled:!0},e.a.createElement("span",{className:"c-black font14"},Xe.answer_text))))})))},ve=function(){return e.a.createElement("aside",null,e.a.createElement("div",{className:ne.a.questionType},e.a.createElement("div",null,e.a.createElement("span",{className:"font16 c-blue"},"\u95EE\u7B54\u9898")," ",e.a.createElement(W.a,{checked:!!Z,className:"ml10",onChange:function(Me){return j(Me.target.checked)}},"\u5FC5\u7B54"))),e.a.createElement("p",{className:ne.a.titleWrap},e.a.createElement(U.a.TextArea,{autoSize:{maxRows:5},rows:1,value:le,placeholder:"\u8BF7\u8F93\u5165\u9898\u76EE",onChange:function(Me){return xe(Me.target.value)}})),e.a.createElement(O.a,{gutter:[12,12]},e.a.createElement(w.a,{flex:"1"}),e.a.createElement(w.a,{className:"tl"},e.a.createElement(N.a,{type:"default",onClick:function(){var Me;(Me=ee.question)!==null&&Me!==void 0&&Me.id?_e("edit",-1):_e("del",ee.key)}},"\u53D6\u6D88"),e.a.createElement(N.a,{className:"ml20",type:"primary",onClick:function(){return G()}},"\u4FDD\u5B58"),e.a.createElement(N.a,{className:"ml20",type:"primary",onClick:function(){return G(!0)}},"\u4FDD\u5B58\u5E76\u7EE7\u7EED"))))};return e.a.createElement("section",{className:ne.a.wrap},Be!==ee.key&&se(),Be===ee.key&&ve())},De=Object(p.a)(function(Se){var me=Se.problemset,Te=Se.loading,pe=Se.globalSetting;return{problemset:me,globalSetting:pe,loading:Te.effects}},null,null,{forwardRef:!0})(Object(u.forwardRef)(Fe)),Ue=ae("7iMQ"),Re=ae.n(Ue),fe=function(me){var Te,pe,Ee,Ge,Le,ke,Ne,ee,Be,_e,we,We,Pe=me.polls,le=me.globalSetting,xe=me.loading,q=me.user,Q=me.dispatch,Z=Object(h.a)(me,["polls","globalSetting","loading","user","dispatch"]),j=Object(n.i)(),H=q.userInfo,G=f.a.useForm(),V=Object(l.a)(G,1),ie=V[0],se=Object(u.useState)([]),ve=Object(l.a)(se,2),Oe=ve[0],je=ve[1],Me=Object(u.useState)(!1),Xe=Object(l.a)(Me,2),$e=Xe[0],He=Xe[1],Ze=Object(u.useState)(-1),rt=Object(l.a)(Ze,2),lt=rt[0],Ye=rt[1],it=[{name:"\u5355\u9009\u9898",id:1},{name:"\u591A\u9009\u9898",id:2},{name:"\u95EE\u7B54\u9898",id:3}],mt=Object(u.useRef)();Object(u.useEffect)(function(){var st;if((st=Pe.exerciseBanks)!==null&&st!==void 0&&st.questions){var nt,ot,Et,qe,Je;je(Object(i.a)((nt=Pe.exerciseBanks)===null||nt===void 0?void 0:nt.questions)),ie.setFieldsValue({exercise_name:(ot=Pe.exerciseBanks)===null||ot===void 0||((Et=ot.poll)===null||Et===void 0)?void 0:Et.name,exercise_description:(qe=Pe.exerciseBanks)===null||qe===void 0||((Je=qe.poll)===null||Je===void 0)?void 0:Je.description})}},[Pe.exerciseBanks]),Object(u.useEffect)(function(){Q({type:"polls/getExerciseBanks",payload:Object(r.a)({},j)})},[j.categoryId]);var kt=function(){var st=Object(d.a)(c.a.mark(function nt(){var ot;return c.a.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:return qe.next=2,ie.validateFields();case 2:return ot=ie.getFieldValue(),ot.is_md=!0,ot.topicId=j.topicId,He(!1),qe.next=8,Object(T.v)(Object(r.a)({},ot));case 8:Q({type:"polls/getExerciseBanks",payload:Object(r.a)({},j)});case 9:case"end":return qe.stop()}},nt)}));return function(){return st.apply(this,arguments)}}(),Ve=function(){var st=Object(d.a)(c.a.mark(function nt(ot){var Et;return c.a.wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:if(Et=mt==null?void 0:mt.current,!(lt!==-1)){Je.next=4;break}return y.b.error("\u4E0D\u80FD\u540C\u65F6\u7F16\u8F91\u4E24\u9898"),Je.abrupt("return");case 4:Ye(Oe.length+1),je([].concat(Object(i.a)(Oe),[{question:{question_type:ot}}]));case 6:case"end":return Je.stop()}},nt)}));return function(ot){return st.apply(this,arguments)}}(),Ct=function(nt,ot,Et){var qe;switch(nt){case"edit":if(ot!==-1&<!==-1&&ot!==lt){y.b.error("\u4E0D\u80FD\u540C\u65F6\u7F16\u8F91\u4E24\u9898");return}Ye(ot);return;case"add":if(lt!=-1){y.b.error("\u4E0D\u80FD\u540C\u65F6\u7F16\u8F91\u4E24\u9898");return}Ye(-1);break;case"addContinue":je(Object(i.a)(ot==null?void 0:ot.editData)),Ye(ot==null||((qe=ot.editData)===null||qe===void 0)?void 0:qe.length);break;case"del":Oe.splice(ot-1,1),je(Object(i.a)(Oe)),Ye(-1);break}},At=function(){return Oe==null?void 0:Oe.map(function(nt,ot){var Et;if(nt.key=ot+1,nt.len=Oe.length,nt.question.question_type===1)return e.a.createElement("aside",{key:nt.id},e.a.createElement($,{ref:mt,editKey:lt,callback:Ct,editData:nt}),e.a.createElement(E.a,null));if(nt.question.question_type===2)return e.a.createElement("aside",{key:nt.id},e.a.createElement(oe,{ref:mt,editKey:lt,callback:Ct,editData:nt}),e.a.createElement(E.a,null));if(((Et=nt.question)===null||Et===void 0?void 0:Et.question_type)===3)return e.a.createElement("aside",{key:nt.id},e.a.createElement(De,{ref:mt,editKey:lt,callback:Ct,editData:nt}),e.a.createElement(E.a,null))})};return e.a.createElement("section",{className:"edu-container"},e.a.createElement("section",{className:"animated fadeIn"},e.a.createElement("aside",{className:"mt10"},H&&e.a.createElement(x.a,{separator:">"},e.a.createElement(x.a.Item,null,e.a.createElement(a.a,{to:"/users/".concat(j.username,"/").concat(j.topictype==="personal"?"topics":"topicbank","/").concat(j.topictype)},j.topictype==="personal"?"\u6211\u7684\u8BFE\u5802\u8D44\u6E90":"\u516C\u5171\u9898\u5E93")),e.a.createElement(x.a.Item,null,e.a.createElement(a.a,{to:"/users/".concat(H==null?void 0:H.login,"/topics/").concat(j.topicId,"/").concat(j.topictype,"/poll/detail")},"\u8BE6\u60C5")),e.a.createElement(x.a.Item,null,"\u7F16\u8F91"))),e.a.createElement("aside",{className:[Re.a.title,"mt20"].join(" ")},e.a.createElement(O.a,{style:{width:"100%"}},e.a.createElement(w.a,{flex:"1"},e.a.createElement("strong",{className:"font20 ml5"},"\u7F16\u8F91")),e.a.createElement(w.a,null,e.a.createElement(a.a,{className:"font16 c-light-black",to:"/users/".concat(H.login,"/topics/").concat(j.topictype)},"\u8FD4\u56DE"))))),e.a.createElement("section",{className:[Re.a.bg,"pt30","pl30","pr30","pb30","mt20"].join(" ")},!$e&&e.a.createElement("aside",null,e.a.createElement("div",{className:Re.a.containerDesc},e.a.createElement("div",null,(Te=Pe.exerciseBanks)===null||Te===void 0||((pe=Te.poll)===null||pe===void 0)?void 0:pe.name),e.a.createElement("div",null,e.a.createElement(_.a,{title:"\u7F16\u8F91"},e.a.createElement("span",{onClick:function(){return He(!0)},className:"iconfont c-green ml30 icon-bianjidaibeijing"})))),e.a.createElement("div",{className:"c-light-black"},(Ee=Pe.exerciseBanks)===null||Ee===void 0||((Ge=Ee.poll)===null||Ge===void 0)?void 0:Ge.description)),$e&&e.a.createElement(f.a,{layout:"vertical",form:ie},e.a.createElement(f.a.Item,{name:"exercise_name",label:"\u95EE\u5377\u6807\u9898\uFF1A",rules:[{required:!0,message:"\u8BF7\u586B\u5199\u95EE\u5377\u6807\u9898"}]},e.a.createElement(U.a,{maxLength:60,placeholder:"\u95EE\u5377\u6807\u9898\uFF0C\u6700\u5927\u9650\u523660\u4E2A\u5B57\u7B26"})),e.a.createElement(f.a.Item,{label:"\u95EE\u5377\u987B\u77E5\uFF1A",name:"exercise_description"},e.a.createElement(U.a.TextArea,{rows:6,placeholder:"\u8BF7\u5728\u6B64\u8F93\u5165\u672C\u6B21\u95EE\u5377\u7B54\u9898\u7684\u76F8\u5173\u8BF4\u660E\uFF0C\u6700\u5927\u9650\u5236100\u4E2A\u5B57\u7B26"})),e.a.createElement(f.a.Item,{className:"tr"},e.a.createElement(N.a,{type:"primary",onClick:function(){kt()}},"\u4FDD\u5B58")))),e.a.createElement("section",{className:"mt20"},e.a.createElement(O.a,null,e.a.createElement(w.a,{flex:1},e.a.createElement("span",{className:"c-light-black mr20"},"\u5355\u9009\u9898 ",(Le=Pe.exerciseBanks)===null||Le===void 0||((ke=Le.question_types)===null||ke===void 0)?void 0:ke.q_singles," \u9898"),e.a.createElement("span",{className:"c-light-black mr20"},"\u591A\u9009\u9898 ",(Ne=Pe.exerciseBanks)===null||Ne===void 0||((ee=Ne.question_types)===null||ee===void 0)?void 0:ee.q_doubles," \u9898"),e.a.createElement("span",{className:"c-light-black"},"\u95EE\u7B54\u9898 ",(Be=Pe.exerciseBanks)===null||Be===void 0||((_e=Be.question_types)===null||_e===void 0)?void 0:_e.q_mains," \u9898")),e.a.createElement(w.a,{className:"c-light-black"},"\u5408\u8BA1 ",e.a.createElement("span",{className:"c-orange"},(we=Pe.exerciseBanks)===null||we===void 0||((We=we.question_types)===null||We===void 0)?void 0:We.q_counts)," \u9898"))),Oe!=""&&e.a.createElement("section",{className:[Re.a.bg,"pt30","pl20","pr20","pb20","mt20"].join(" ")},At()),e.a.createElement("section",{className:[Re.a.bg,"pt30","pl30","pr30","pb30","mt20"].join(" ")},it.map(function(st,nt){return e.a.createElement(N.a,{className:"mr20",type:"primary",onClick:function(){return Ve(st.id)}},e.a.createElement(g.a,{className:"mr5"}),st.name)})))},Ce=tt.default=Object(p.a)(function(Se){var me=Se.polls,Te=Se.loading,pe=Se.user,Ee=Se.globalSetting;return{polls:me,globalSetting:Ee,user:pe,loading:Te.effects}})(fe)},Y1PL:function(vt,tt,ae){"use strict";ae.r(tt),ae.d(tt,"ResizableTextArea",function(){return ne});var he=ae("wx14"),N=ae("1OyB"),S=ae("vuIU"),U=ae("Ji7U"),L=ae("LK+K"),_=ae("q1tI"),B=ae("VTBJ"),O=ae("rePB"),k=ae("Zm9Q"),w=ae("Kwbf"),v=ae("c+Xe"),x=ae("m+aA"),C=ae("bdgK"),E=new Map;function b(oe){oe.forEach(function(ue){var de,ce=ue.target;(de=E.get(ce))===null||de===void 0||de.forEach(function(te){return te(ce)})})}var y=new C.default(b),d=null,r=null;function i(oe,ue){E.has(oe)||(E.set(oe,new Set),y.observe(oe)),E.get(oe).add(ue)}function o(oe,ue){E.has(oe)&&(E.get(oe).delete(ue),E.get(oe).size||(y.unobserve(oe),E.delete(oe)))}var f=function(oe){Object(U.a)(de,oe);var ue=Object(L.a)(de);function de(){return Object(N.a)(this,de),ue.apply(this,arguments)}return Object(S.a)(de,[{key:"render",value:function(){return this.props.children}}]),de}(_.Component),l=_.createContext(null);function h(oe){var ue=oe.children,de=oe.onBatchResize,ce=_.useRef(0),te=_.useRef([]),$=_.useContext(l),Ae=_.useCallback(function(Fe,De,Ue){ce.current+=1;var Re=ce.current;te.current.push({size:Fe,element:De,data:Ue}),Promise.resolve().then(function(){Re===ce.current&&(de==null||de(te.current),te.current=[])}),$==null||$(Fe,De,Ue)},[de,$]);return _.createElement(l.Provider,{value:Ae},ue)}function m(oe){var ue=oe.children,de=oe.disabled,ce=_.useRef(null),te=_.useRef(null),$=_.useContext(l),Ae=_.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Fe=_.isValidElement(ue)&&Object(v.c)(ue),De=Fe?ue.ref:null,Ue=_.useMemo(function(){return Object(v.a)(De,ce)},[De,ce]),Re=_.useRef(oe);Re.current=oe;var fe=_.useCallback(function(Ce){var Se=Re.current,me=Se.onResize,Te=Se.data,pe=Ce.getBoundingClientRect(),Ee=pe.width,Ge=pe.height,Le=Ce.offsetWidth,ke=Ce.offsetHeight,Ne=Math.floor(Ee),ee=Math.floor(Ge);if(Ae.current.width!==Ne||Ae.current.height!==ee||Ae.current.offsetWidth!==Le||Ae.current.offsetHeight!==ke){var Be={width:Ne,height:ee,offsetWidth:Le,offsetHeight:ke};Ae.current=Be;var _e=Le===Math.round(Ee)?Ee:Le,we=ke===Math.round(Ge)?Ge:ke,We=Object(B.a)(Object(B.a)({},Be),{},{offsetWidth:_e,offsetHeight:we});$==null||$(We,Ce,Te),me&&Promise.resolve().then(function(){me(We,Ce)})}},[]);return _.useEffect(function(){var Ce=Object(x.a)(ce.current)||Object(x.a)(te.current);return Ce&&!de&&i(Ce,fe),function(){return o(Ce,fe)}},[ce.current,de]),_.createElement(f,{ref:te},Fe?_.cloneElement(ue,{ref:Ue}):ue)}var c="rc-observer-key";function u(oe){var ue=oe.children,de=Object(k.a)(ue);return de.map(function(ce,te){var $=(ce==null?void 0:ce.key)||"".concat(c,"-").concat(te);return _.createElement(m,Object(he.a)({},oe,{key:$}),ce)})}u.Collection=h;var e=u,n=ae("bT9E"),a=ae("TSYQ"),p=ae.n(a),g=`
|
|
min-height:0 !important;
|
|
max-height:none !important;
|
|
height:0 !important;
|
|
visibility:hidden !important;
|
|
overflow:hidden !important;
|
|
position:absolute !important;
|
|
z-index:-1000 !important;
|
|
top:0 !important;
|
|
right:0 !important
|
|
`,T=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],P={},I;function F(oe){var ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,de=oe.getAttribute("id")||oe.getAttribute("data-reactid")||oe.getAttribute("name");if(ue&&P[de])return P[de];var ce=window.getComputedStyle(oe),te=ce.getPropertyValue("box-sizing")||ce.getPropertyValue("-moz-box-sizing")||ce.getPropertyValue("-webkit-box-sizing"),$=parseFloat(ce.getPropertyValue("padding-bottom"))+parseFloat(ce.getPropertyValue("padding-top")),Ae=parseFloat(ce.getPropertyValue("border-bottom-width"))+parseFloat(ce.getPropertyValue("border-top-width")),Fe=T.map(function(Ue){return"".concat(Ue,":").concat(ce.getPropertyValue(Ue))}).join(";"),De={sizingStyle:Fe,paddingSize:$,borderSize:Ae,boxSizing:te};return ue&&de&&(P[de]=De),De}function W(oe){var ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,de=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,ce=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;I||(I=document.createElement("textarea"),I.setAttribute("tab-index","-1"),I.setAttribute("aria-hidden","true"),document.body.appendChild(I)),oe.getAttribute("wrap")?I.setAttribute("wrap",oe.getAttribute("wrap")):I.removeAttribute("wrap");var te=F(oe,ue),$=te.paddingSize,Ae=te.borderSize,Fe=te.boxSizing,De=te.sizingStyle;I.setAttribute("style","".concat(De,";").concat(g)),I.value=oe.value||oe.placeholder||"";var Ue=Number.MIN_SAFE_INTEGER,Re=Number.MAX_SAFE_INTEGER,fe=I.scrollHeight,Ce;if(Fe==="border-box"?fe+=Ae:Fe==="content-box"&&(fe-=$),de!==null||ce!==null){I.value=" ";var Se=I.scrollHeight-$;de!==null&&(Ue=Se*de,Fe==="border-box"&&(Ue=Ue+$+Ae),fe=Math.max(Ue,fe)),ce!==null&&(Re=Se*ce,Fe==="border-box"&&(Re=Re+$+Ae),Ce=fe>Re?"":"hidden",fe=Math.min(Re,fe))}return{height:fe,minHeight:Ue,maxHeight:Re,overflowY:Ce,resize:"none"}}var z=ae("Gytx"),X=ae.n(z),K;(function(oe){oe[oe.NONE=0]="NONE",oe[oe.RESIZING=1]="RESIZING",oe[oe.RESIZED=2]="RESIZED"})(K||(K={}));var J=function(oe){Object(U.a)(de,oe);var ue=Object(L.a)(de);function de(ce){var te;return Object(N.a)(this,de),te=ue.call(this,ce),te.nextFrameActionId=void 0,te.resizeFrameId=void 0,te.textArea=void 0,te.saveTextArea=function($){te.textArea=$},te.handleResize=function($){var Ae=te.state.resizeStatus,Fe=te.props,De=Fe.autoSize,Ue=Fe.onResize;if(Ae!==K.NONE)return;typeof Ue=="function"&&Ue($),De&&te.resizeOnNextFrame()},te.resizeOnNextFrame=function(){cancelAnimationFrame(te.nextFrameActionId),te.nextFrameActionId=requestAnimationFrame(te.resizeTextarea)},te.resizeTextarea=function(){var $=te.props.autoSize;if(!$||!te.textArea)return;var Ae=$.minRows,Fe=$.maxRows,De=W(te.textArea,!1,Ae,Fe);te.setState({textareaStyles:De,resizeStatus:K.RESIZING},function(){cancelAnimationFrame(te.resizeFrameId),te.resizeFrameId=requestAnimationFrame(function(){te.setState({resizeStatus:K.RESIZED},function(){te.resizeFrameId=requestAnimationFrame(function(){te.setState({resizeStatus:K.NONE}),te.fixFirefoxAutoScroll()})})})})},te.renderTextArea=function(){var $=te.props,Ae=$.prefixCls,Fe=Ae===void 0?"rc-textarea":Ae,De=$.autoSize,Ue=$.onResize,Re=$.className,fe=$.disabled,Ce=te.state,Se=Ce.textareaStyles,me=Ce.resizeStatus,Te=Object(n.a)(te.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),pe=p()(Fe,Re,Object(O.a)({},"".concat(Fe,"-disabled"),fe));"value"in Te&&(Te.value=Te.value||"");var Ee=Object(B.a)(Object(B.a)(Object(B.a)({},te.props.style),Se),me===K.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return _.createElement(e,{onResize:te.handleResize,disabled:!(De||Ue)},_.createElement("textarea",Object(he.a)({},Te,{className:pe,style:Ee,ref:te.saveTextArea})))},te.state={textareaStyles:{},resizeStatus:K.NONE},te}return Object(S.a)(de,[{key:"componentDidUpdate",value:function(te){(te.value!==this.props.value||!X()(te.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var te=this.textArea.selectionStart,$=this.textArea.selectionEnd;this.textArea.setSelectionRange(te,$)}}catch(Ae){}}},{key:"render",value:function(){return this.renderTextArea()}}]),de}(_.Component),ne=J,re=function(oe){Object(U.a)(de,oe);var ue=Object(L.a)(de);function de(ce){var te;Object(N.a)(this,de),te=ue.call(this,ce),te.resizableTextArea=void 0,te.focus=function(){te.resizableTextArea.textArea.focus()},te.saveTextArea=function(Ae){te.resizableTextArea=Ae},te.handleChange=function(Ae){var Fe=te.props.onChange;te.setValue(Ae.target.value,function(){te.resizableTextArea.resizeTextarea()}),Fe&&Fe(Ae)},te.handleKeyDown=function(Ae){var Fe=te.props,De=Fe.onPressEnter,Ue=Fe.onKeyDown;Ae.keyCode===13&&De&&De(Ae),Ue&&Ue(Ae)};var $=typeof ce.value=="undefined"||ce.value===null?ce.defaultValue:ce.value;return te.state={value:$},te}return Object(S.a)(de,[{key:"setValue",value:function(te,$){"value"in this.props||this.setState({value:te},$)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return _.createElement(ne,Object(he.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(te){return"value"in te?{value:te.value}:null}}]),de}(_.Component),be=tt.default=re},ZW9T:function(vt,tt,ae){"use strict";ae.d(tt,"a",function(){return f});var he=ae("k1fw"),N=ae("miYZ"),S=ae("tsqr"),U=ae("rAM+"),L=ae("tJVT"),_=ae("PpiC"),B=ae("q1tI"),O=ae.n(B),k=ae("bdgK");function w(l,h,m,c,u){var e=h.getWordUntilPosition(m),n={startLineNumber:m.lineNumber,endLineNumber:m.lineNumber,startColumn:e.startColumn,endColumn:e.endColumn},a=c.map(function(p){return{label:p,kind:l.languages.CompletionItemKind.Keyword,insertText:p,insertTextRules:l.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:n}});return u.map(function(p){a.push(Object(he.a)(Object(he.a)({},p),{},{range:n}))}),a}var v=function(l){var h={label:"ifelse",kind:l.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {"," $0","} else {"," ","}"].join(`
|
|
`),insertTextRules:l.languages.CompletionItemInsertTextRule.InsertAsSnippet},m=["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","inline","restrict","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Static_assert","_Noreturn","_Thread_local","_Generic"];l.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(n,a){var p=w(l,n,a,m,[h]);return{suggestions:p}}});var c=["False","None","True","and","as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"];l.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(n,a){var p=[{label:"print",kind:l.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join(`
|
|
`),insertTextRules:l.languages.CompletionItemInsertTextRule.InsertAsSnippet}],g=w(l,n,a,c,p);return{suggestions:g}}});var u=["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instance of","int","interface","long","native","new","package","private","protected","public","return","strictfp","short","static","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"];l.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(n,a){var p=[h,{label:"main",kind:l.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {"," $0","}"].join(`
|
|
`),insertTextRules:l.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:l.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join(`
|
|
`),insertTextRules:l.languages.CompletionItemInsertTextRule.InsertAsSnippet}],g=w(l,n,a,u,p);return{suggestions:g}}})},x="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",C=ae("LvDl");function E(l){return/^\d+$/.test(l)?"".concat(l,"px"):l}function b(){}var y=!1,d={"Python3.6":"python","Python2.7":"python",Dynamips:"cpp",Java:"java",Web:"php",Html:"html",Hive:"sql",Hadoop:"java",SDL:"cpp",PHP:"php",Matlab:"python",Git:"python",Python:"python","C/C++":"cpp","C++":"cpp",C:"cpp",Ruby:"ruby",Shell:"shell",JavaScript:"javascript",Perl6:"perl",Kotlin:"kotlin",Elixir:"elixir",Android:"java",JavaWeb:"java",Go:"go",Spark:"sql",MachineLearning:"python",Verilog:"xml","Verilog/VNC":"xml",Docker:"dockerfile","C#":"csharp",SQLite3:"sql",Oracle:"sql",Vhdl:"vhdl",R:"r",Swift:"swift",SQLServer:"mysql",MySQL:"mysql",Mongo:"sql",PostgreSql:"pgsql",Hbase:"powershell",Sqoop:"sql",Nasm:"cpp",Kafka:"java",Flink:"java",Sml:"javascript",OpenGL:"cpp",Perl5:"perl",Orange:"python"};function r(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],h=l;if(Array.isArray(l)){for(var m=0;m<l.length;m++){var c=d[l[m]];if(c)return c}return h[0]}return d[h]||h}var i=null,o=tt.b=function(l){var h=l.width,m=h===void 0?"100%":h,c=l.height,u=c===void 0?"100%":c,e=l.value,n=l.language,a=n===void 0?"javascript":n,p=l.style,g=p===void 0?{}:p,T=l.options,P=T===void 0?{}:T,I=l.overrideServices,F=I===void 0?{}:I,W=l.theme,z=W===void 0?"vs-dark":W,X=l.onEditBlur,K=l.onSave,J=l.autoHeight,ne=J===void 0?!1:J,re=l.forbidCopy,be=re===void 0?!1:re,oe=l.onChange,ue=oe===void 0?b:oe,de=l.editorDidMount,ce=de===void 0?b:de,te=l.onFocus,$=te===void 0?b:te,Ae=l.filename,Fe=Ae===void 0?"educoder.txt":Ae,De=Object(_.a)(l,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),Ue=Object(B.useRef)(),Re=Object(B.useRef)({}),fe=Object(B.useRef)(),Ce=Object(B.useRef)(!1),Se=Object(B.useRef)(),me=Object(B.useState)(!1),Te=Object(L.a)(me,2),pe=Te[0],Ee=Te[1];function Ge(){var G;return Ue.current&&(G=new k.default(function(V){var ie=Object(U.a)(V),se;try{for(ie.s();!(se=ie.n()).done;){var ve=se.value;(ve.target.offsetHeight>0||ve.target.offsetWidth>0)&&Re.current.instance.layout()}}catch(Oe){ie.e(Oe)}finally{ie.f()}}),G.observe(Ue.current)),G}function Le(){S.b.warn(decodeURIComponent(x))}var ke=function(){var V=Re.current.instance;if(e!=null&&V&&pe){var ie=V.getModel();ie&&e!==ie.getValue()&&(y=!0,ie.setValue(e),V.layout(),y=!1)}};Object(B.useEffect)(function(){fe.current&&clearTimeout(fe.current),fe.current=setTimeout(function(){ke()},500)},[e,pe,Re.current]);function Ne(){var G=Re.current.instance;if(G){var V=G.getSelection(),ie=Re.current.pastePos||{},se=new i.Range(ie.startLineNumber||V.endLineNumber,ie.startColumn||V.endColumn,ie.endLineNumber||V.endLineNumber,ie.endColumn||V.endColumn);setTimeout(function(){G.executeEdits("",[{range:se,text:""}])},300)}}function ee(G){(window.navigator.platform.match("Mac")?G.metaKey:G.ctrlKey)&&G.keyCode==83&&(G.preventDefault(),K())}var Be=function(){if(ne&&Re.current.instance){var V=Re.current.instance.getContentHeight();j(V<u?u:V)}else j(u)};function _e(G){var V=document.createEvent("MouseEvents");V.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),G.dispatchEvent(V)}function we(G,V){var ie=window.URL||window.webkitURL||window,se=new Blob([V]),ve=document.createElementNS("http://www.w3.org/1999/xhtml","a");ve.href=ie.createObjectURL(se),ve.download=G,_e(ve)}Object(B.useEffect)(function(){Be()},[Be]),Object(B.useEffect)(function(){Ue.current&&!pe&&ae.e(27).then(ae.t.bind(null,"M/lh",7)).then(function(G){try{i=G,Re.current.instance=i.editor.create(Ue.current,{value:e,language:r(a),theme:z,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},F);var V=Re.current.instance;if(ce(V,i),setTimeout(function(){Be(),Re.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){we(Fe||"educoder.txt",V.getValue())}})},500),Re.current.subscription=V.onDidChangeModelContent(function(se){Ce.current?clearTimeout(Se.current):(Be(),ue(V.getValue(),se)),Se.current=setTimeout(function(){Ce.current=!1},500)}),window.Monaco||v(i),be&&(V.addCommand(i.KeyMod.CtrlCmd|i.KeyMod.Shift|i.KeyCode.KEY_V,function(){return Le(),null}),V.addCommand(i.KeyMod.CtrlCmd|i.KeyCode.KEY_C,function(){return Le(),null})),window.Monaco=i,X&&V.onDidBlurEditorWidget(function(){X(V.getValue())}),$&&V.onDidFocusEditorText(function(){$(V.getValue())}),be){V.addCommand(i.KeyMod.CtrlCmd|i.KeyCode.KEY_V,function(){return Le(),null}),V.onDidPaste(function(se){Re.current.pastePos=se});try{window.addEventListener("paste",Ne)}catch(se){}}var ie=Ge();return Ee(!0),function(){var se=Re.current.instance;se.dispose();var ve=se.getModel();ve&&ve.dispose(),Re.current.subscription&&Re.current.subscription.dispose(),be&&window.removeEventListener("paste",Ne),ie.unobserve(Ue.current)}}catch(se){}})},[]),Object(B.useEffect)(function(){var G=Re.current.instance;if(G&&pe)return document.addEventListener("keydown",ee,!1),function(){document.removeEventListener("keydown",ee)}},[K,pe]),Object(B.useEffect)(function(){var G=Re.current.instance;if(G&&pe){var V=r(a);i.editor.setModelLanguage(G.getModel(),V),console.log("language:",a,G.getModel(),V)}},[a,pe]),Object(B.useEffect)(function(){var G=Re.current.instance;G&&pe&&i.editor.setTheme(z)},[z,pe]),Object(B.useEffect)(function(){var G=Re.current.instance;G&&pe&&(G.updateOptions(Object(he.a)({},P)),setTimeout(function(){G.getModel().updateOptions(Object(he.a)({},P))},200))},[JSON.stringify(P),pe]),Object(B.useEffect)(function(){var G=Re.current.instance;G&&pe&&G.layout()},[m,u,pe]);var We=Object(B.useState)(E(m)),Pe=Object(L.a)(We,2),le=Pe[0],xe=Pe[1],q=Object(B.useState)(E(u)),Q=Object(L.a)(q,2),Z=Q[0],j=Q[1],H=Object(he.a)(Object(he.a)({},g),{},{width:le,height:Z});return O.a.createElement("div",{className:"my-monaco-editor",ref:Ue,style:H})};function f(l){var h=l.width,m=h===void 0?"100%":h,c=l.height,u=c===void 0?"100%":c,e=l.original,n=l.modified,a=l.language,p=l.options,g=p===void 0?{}:p,T=Object(B.useRef)(),P=Object(B.useState)(null),I=Object(L.a)(P,2),F=I[0],W=I[1];function z(ne){var re;return T.current&&(re=new k.default(function(be){var oe=Object(U.a)(be),ue;try{for(oe.s();!(ue=oe.n()).done;){var de=ue.value;(de.target.offsetHeight>0||de.target.offsetWidth>0)&&ne.layout()}}catch(ce){oe.e(ce)}finally{oe.f()}}),re.observe(T.current)),re}Object(B.useEffect)(function(){T.current&&ae.e(27).then(ae.t.bind(null,"M/lh",7)).then(function(ne){i=ne;var re=i.editor.createDiffEditor(T.current,Object(he.a)(Object(he.a)({enableSplitViewResizing:!1,scrollBeyondLastLine:!1,roundedSelection:!1,renderIndicators:!1,useShadows:!1,horizontal:"hidden",lineNumbers:"off",ignoreTrimWhitespace:!1,followsCaret:!0,ignoreCharChanges:!0,minimap:{enabled:!1},readOnly:!0},g),{},{wordWrap:!0}));W(re);var be=z(re);return function(){re.dispose();var oe=re.getModel();oe&&oe.dispose(),be.unobserve(T.current)}})},[]),Object(B.useEffect)(function(){F&&F.setModel({original:i.editor.createModel(e,a),modified:i.editor.createModel(n,a)})},[e,n,a,F]);var X=E(m),K=E(u),J={width:X,height:K};return O.a.createElement("div",{className:"my-diff-editor",ref:T,style:J})}},ZpRC:function(vt,tt,ae){"use strict";function he(v){return typeof v=="object"&&v!=null&&v.nodeType===1}function N(v,x){return(!x||v!=="hidden")&&v!=="visible"&&v!=="clip"}function S(v,x){if(v.clientHeight<v.scrollHeight||v.clientWidth<v.scrollWidth){var C=getComputedStyle(v,null);return N(C.overflowY,x)||N(C.overflowX,x)||function(E){var b=function(y){if(!y.ownerDocument||!y.ownerDocument.defaultView)return null;try{return y.ownerDocument.defaultView.frameElement}catch(d){return null}}(E);return!!b&&(b.clientHeight<E.scrollHeight||b.clientWidth<E.scrollWidth)}(v)}return!1}function U(v,x,C,E,b,y,d,r){return y<v&&d>x||y>v&&d<x?0:y<=v&&r<=C||d>=x&&r>=C?y-v-E:d>x&&r<C||y<v&&r>C?d-x+b:0}var L=function(v,x){var C=window,E=x.scrollMode,b=x.block,y=x.inline,d=x.boundary,r=x.skipOverflowHiddenElements,i=typeof d=="function"?d:function(Se){return Se!==d};if(!he(v))throw new TypeError("Invalid target");for(var o=document.scrollingElement||document.documentElement,f=[],l=v;he(l)&&i(l);){if((l=l.parentElement)===o){f.push(l);break}l!=null&&l===document.body&&S(l)&&!S(document.documentElement)||l!=null&&S(l,r)&&f.push(l)}for(var h=C.visualViewport?C.visualViewport.width:innerWidth,m=C.visualViewport?C.visualViewport.height:innerHeight,c=window.scrollX||pageXOffset,u=window.scrollY||pageYOffset,e=v.getBoundingClientRect(),n=e.height,a=e.width,p=e.top,g=e.right,T=e.bottom,P=e.left,I=b==="start"||b==="nearest"?p:b==="end"?T:p+n/2,F=y==="center"?P+a/2:y==="end"?g:P,W=[],z=0;z<f.length;z++){var X=f[z],K=X.getBoundingClientRect(),J=K.height,ne=K.width,re=K.top,be=K.right,oe=K.bottom,ue=K.left;if(E==="if-needed"&&p>=0&&P>=0&&T<=m&&g<=h&&p>=re&&T<=oe&&P>=ue&&g<=be)return W;var de=getComputedStyle(X),ce=parseInt(de.borderLeftWidth,10),te=parseInt(de.borderTopWidth,10),$=parseInt(de.borderRightWidth,10),Ae=parseInt(de.borderBottomWidth,10),Fe=0,De=0,Ue="offsetWidth"in X?X.offsetWidth-X.clientWidth-ce-$:0,Re="offsetHeight"in X?X.offsetHeight-X.clientHeight-te-Ae:0;if(o===X)Fe=b==="start"?I:b==="end"?I-m:b==="nearest"?U(u,u+m,m,te,Ae,u+I,u+I+n,n):I-m/2,De=y==="start"?F:y==="center"?F-h/2:y==="end"?F-h:U(c,c+h,h,ce,$,c+F,c+F+a,a),Fe=Math.max(0,Fe+u),De=Math.max(0,De+c);else{Fe=b==="start"?I-re-te:b==="end"?I-oe+Ae+Re:b==="nearest"?U(re,oe,J,te,Ae+Re,I,I+n,n):I-(re+J/2)+Re/2,De=y==="start"?F-ue-ce:y==="center"?F-(ue+ne/2)+Ue/2:y==="end"?F-be+$+Ue:U(ue,be,ne,ce,$+Ue,F,F+a,a);var fe=X.scrollLeft,Ce=X.scrollTop;I+=Ce-(Fe=Math.max(0,Math.min(Ce+Fe,X.scrollHeight-J+Re))),F+=fe-(De=Math.max(0,Math.min(fe+De,X.scrollWidth-ne+Ue)))}W.push({el:X,top:Fe,left:De})}return W};function _(v){return v===Object(v)&&Object.keys(v).length!==0}function B(v,x){x===void 0&&(x="auto");var C="scrollBehavior"in document.body.style;v.forEach(function(E){var b=E.el,y=E.top,d=E.left;b.scroll&&C?b.scroll({top:y,left:d,behavior:x}):(b.scrollTop=y,b.scrollLeft=d)})}function O(v){return v===!1?{block:"end",inline:"nearest"}:_(v)?v:{block:"start",inline:"nearest"}}function k(v,x){var C=!v.ownerDocument.documentElement.contains(v);if(_(x)&&typeof x.behavior=="function")return x.behavior(C?[]:L(v,x));if(C)return;var E=O(x);return B(L(v,E),E.behavior)}var w=tt.a=k},bT9E:function(vt,tt,ae){"use strict";ae.d(tt,"a",function(){return N});var he=ae("VTBJ");function N(S,U){var L=Object(he.a)({},S);return Array.isArray(U)&&U.forEach(function(_){delete L[_]}),L}},otbz:function(vt,tt,ae){vt.exports={flex_box_center:"flex_box_center___3WVQg",flex_space_between:"flex_space_between___qOmUA",flex_box_vertical_center:"flex_box_vertical_center___3Tvh1",flex_box_center_end:"flex_box_center_end___vdEZx",flex_box_column:"flex_box_column___1y_IJ",wrap:"wrap___ciPTn",modal:"modal___2lr4h",titleWrap:"titleWrap___2Szy4",required:"required___2OpIu",title:"title___hZmu6",colorGray:"colorGray___32oND",choiceWrap:"choiceWrap___24IrF",answer:"answer___3w_7N",activeAnswer:"activeAnswer___f89lY",deleteIcon:"deleteIcon___qd0T4",addIcon:"addIcon___GQKIw",editorWrap:"editorWrap___iuxhH",htmlWrap:"htmlWrap___17kgS",radio:"radio___3IfyE",color333:"color333___1rjEP",color999:"color999___25PqS",questionType:"questionType___3G5uc",questionChoices:"questionChoices___GBK2t"}},p5ED:function(vt,tt,ae){"use strict";var he=ae("+L6B"),N=ae("2/Rp"),S=ae("5Dmo"),U=ae("3S7+"),L=ae("k1fw"),_=ae("tJVT"),B=ae("q1tI"),O=ae.n(B),k=ae("vHTk"),w=ae.n(k),v=ae("yEEn"),x=ae("ZW9T"),C=ae("1vsH"),E=ae("m3rI");tt.a=function(b){var y=b.name,d=b.data,r=b.theme,i=b.type,o=b.filename,f=b.monacoEditor,l=b.className,h=b.style,m=b.close,c=b.onClose,u=b.hasMask,e=b.otherData,n=Object(B.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),a=Object(_.a)(n,2),p=a[0],g=a[1],T=Object(B.useState)(""),P=Object(_.a)(T,2),I=P[0],F=P[1],W,z=1024*1024,X=10*z,K=Object(B.useRef)();i==="office"&&(W=Object(C.R)(d).filesize,W>X&&(i="other")),o&&(f.filename=o),Object(B.useEffect)(function(){var re,be,oe=(re=document.cookie)===null||re===void 0||((be=re.replace(/\s/g,""))===null||be===void 0)?void 0:be.split(";");oe==null||oe.map(function(ue){var de=ue.split("=");de[0]==="_educoder_session"&&F(de[1])})},[]);var J=function(){if(d.startsWith("http")||d.startsWith("blob:")){ne();return}Object(C.x)(o||"educoder",d,o)},ne=function(){Object(C.v)(o||"educoder",decodeURIComponent(d))};return O.a.createElement("div",{style:Object(L.a)({},h||{}),className:"".concat(u&&w.a.bgBlack," ").concat(i?w.a.wrp:"hide")},m&&O.a.createElement("div",{className:w.a.close,ref:K},O.a.createElement(U.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return K.current}},O.a.createElement("span",{onClick:ne},O.a.createElement("i",{className:"icon-quxiaozhiding"}))),O.a.createElement(U.a,{title:"\u5173\u95ED",getPopupContainer:function(){return K.current}},O.a.createElement("span",{className:"",onClick:c},O.a.createElement("i",{className:"icon-guanbi1"})))),O.a.createElement("div",{className:"".concat(w.a[l]," ").concat(l," ").concat(w.a.monaco," ").concat(i==="txt"?"show":"hide")},i==="txt"&&O.a.createElement(x.b,f)),i==="audio"&&O.a.createElement("audio",{src:"".concat((d==null?void 0:d.indexOf("http://"))>-1||(d==null?void 0:d.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(d),autoPlay:!0}),i==="video"&&O.a.createElement(O.a.Fragment,null,(d==null?void 0:d.indexOf("http"))>-1?O.a.createElement("video",{controls:!0,src:"".concat(d),autoPlay:!0}):O.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(d),autoPlay:!0})),i==="office"&&O.a.createElement("iframe",{src:"https://view.officeapps.live.com/op/embed.aspx?src=".concat(d,"?").concat(encodeURIComponent("disposition=office&token=".concat(I)))}),(i==="xlsx"||i==="doc"||i==="pptx"||i==="docx")&&O.a.createElement("iframe",{src:"/react/build/office.html?key=".concat(e.key,"&url=").concat(E.a.API_SERVER+e.url,"&callbackUrl=").concat(E.a.API_SERVER+e.callbackUrl,"&fileType=").concat(e.fileType,"&title=").concat(e.title,"&model=").concat(e.model)}),i==="html"&&O.a.createElement("iframe",{src:d+"&disposition=inline"}),i==="pdf"&&O.a.createElement("embed",{className:w.a.embed,src:d,type:"application/pdf"}),i==="image"&&O.a.createElement("img",{src:"".concat((d==null?void 0:d.indexOf("http://"))>-1||(d==null?void 0:d.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(d)}),i==="other"&&O.a.createElement("div",null,O.a.createElement(N.a,{type:"primary",size:"large",onClick:J},O.a.createElement(v.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),i==="download"&&O.a.createElement(N.a,{type:"primary",size:"large",onClick:J},O.a.createElement(v.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"rAM+":function(vt,tt,ae){"use strict";ae.d(tt,"a",function(){return N});var he=ae("Qw5x");function N(S,U){var L;if(typeof Symbol=="undefined"||S[Symbol.iterator]==null){if(Array.isArray(S)||(L=Object(he.a)(S))||U&&S&&typeof S.length=="number"){L&&(S=L);var _=0,B=function(){};return{s:B,n:function(){return _>=S.length?{done:!0}:{done:!1,value:S[_++]}},e:function(x){throw x},f:B}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var O=!0,k=!1,w;return{s:function(){L=S[Symbol.iterator]()},n:function(){var x=L.next();return O=x.done,x},e:function(x){k=!0,w=x},f:function(){try{!O&&L.return!=null&&L.return()}finally{if(k)throw w}}}}},rUJ1:function(vt,tt){const ae=/[&<>"']/,he=/[&<>"']/g,N=/[<>"']|&(?!#?\w+;)/,S=/[<>"']|&(?!#?\w+;)/g,U={"&":"&","<":"<",">":">",'"':""","'":"'"},L=c=>U[c];function _(c,u){if(u){if(ae.test(c))return c.replace(he,L)}else if(N.test(c))return c.replace(S,L);return c}const B=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function O(c){return c.replace(B,(u,e)=>(e=e.toLowerCase(),e==="colon"?":":e.charAt(0)==="#"?e.charAt(1)==="x"?String.fromCharCode(parseInt(e.substring(2),16)):String.fromCharCode(+e.substring(1)):""))}const k=/(^|[^\[])\^/g;function w(c,u){c=c.source||c,u=u||"";const e={replace:(n,a)=>(a=a.source||a,a=a.replace(k,"$1"),c=c.replace(n,a),e),getRegex:()=>new RegExp(c,u)};return e}const v=/[^\w:]/g,x=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function C(c,u,e){if(c){let n;try{n=decodeURIComponent(O(e)).replace(v,"").toLowerCase()}catch(a){return null}if(n.indexOf("javascript:")===0||n.indexOf("vbscript:")===0||n.indexOf("data:")===0)return null}u&&!x.test(e)&&(e=r(u,e));try{e=encodeURI(e).replace(/%25/g,"%")}catch(n){return null}return e}const E={},b=/^[^:]+:\/*[^/]*$/,y=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function r(c,u){E[" "+c]||(b.test(c)?E[" "+c]=c+"/":E[" "+c]=l(c,"/",!0)),c=E[" "+c];const e=c.indexOf(":")===-1;return u.substring(0,2)==="//"?e?u:c.replace(y,"$1")+u:u.charAt(0)==="/"?e?u:c.replace(d,"$1")+u:c+u}const i={exec:function(){}};function o(c){let u=1,e,n;for(;u<arguments.length;u++){e=arguments[u];for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(c[n]=e[n])}return c}function f(c,u){const e=c.replace(/\|/g,(p,g,T)=>{let P=!1,I=g;for(;--I>=0&&T[I]==="\\";)P=!P;return P?"|":" |"}),n=e.split(/ \|/);let a=0;if(n.length>u)n.splice(u);else for(;n.length<u;)n.push("");for(;a<n.length;a++)n[a]=n[a].trim().replace(/\\\|/g,"|");return n}function l(c,u,e){const n=c.length;if(n===0)return"";let a=0;for(;a<n;){const p=c.charAt(n-a-1);if(p===u&&!e)a++;else if(p!==u&&e)a++;else break}return c.substr(0,n-a)}function h(c,u){if(c.indexOf(u[1])===-1)return-1;const e=c.length;let n=0,a=0;for(;a<e;a++)if(c[a]==="\\")a++;else if(c[a]===u[0])n++;else if(c[a]===u[1]&&(n--,n<0))return a;return-1}function m(c){c&&c.sanitize&&!c.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}vt.exports={escape:_,unescape:O,edit:w,cleanUrl:C,resolveUrl:r,noopTest:i,merge:o,splitCells:f,rtrim:l,findClosingBracket:h,checkSanitizeDeprecation:m}},ulZh:function(vt,tt,ae){typeof window!="undefined"&&function(N,S){vt.exports=S()}(this,function(){return function(he){var N={};function S(U){if(N[U])return N[U].exports;var L=N[U]={i:U,l:!1,exports:{}};return he[U].call(L.exports,L,L.exports,S),L.l=!0,L.exports}return S.m=he,S.c=N,S.d=function(U,L,_){S.o(U,L)||Object.defineProperty(U,L,{enumerable:!0,get:_})},S.r=function(U){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(U,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(U,"__esModule",{value:!0})},S.t=function(U,L){if(L&1&&(U=S(U)),L&8)return U;if(L&4&&typeof U=="object"&&U&&U.__esModule)return U;var _=Object.create(null);if(S.r(_),Object.defineProperty(_,"default",{enumerable:!0,value:U}),L&2&&typeof U!="string")for(var B in U)S.d(_,B,function(O){return U[O]}.bind(null,B));return _},S.n=function(U){var L=U&&U.__esModule?function(){return U.default}:function(){return U};return S.d(L,"a",L),L},S.o=function(U,L){return Object.prototype.hasOwnProperty.call(U,L)},S.p="/dist/",S(S.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(he,N,S){"use strict";var U=Object.prototype.hasOwnProperty,L="~";function _(){}Object.create&&(_.prototype=Object.create(null),new _().__proto__||(L=!1));function B(v,x,C){this.fn=v,this.context=x,this.once=C||!1}function O(v,x,C,E,b){if(typeof C!="function")throw new TypeError("The listener must be a function");var y=new B(C,E||v,b),d=L?L+x:x;return v._events[d]?v._events[d].fn?v._events[d]=[v._events[d],y]:v._events[d].push(y):(v._events[d]=y,v._eventsCount++),v}function k(v,x){--v._eventsCount===0?v._events=new _:delete v._events[x]}function w(){this._events=new _,this._eventsCount=0}w.prototype.eventNames=function(){var x=[],C,E;if(this._eventsCount===0)return x;for(E in C=this._events)U.call(C,E)&&x.push(L?E.slice(1):E);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(C)):x},w.prototype.listeners=function(x){var C=L?L+x:x,E=this._events[C];if(!E)return[];if(E.fn)return[E.fn];for(var b=0,y=E.length,d=new Array(y);b<y;b++)d[b]=E[b].fn;return d},w.prototype.listenerCount=function(x){var C=L?L+x:x,E=this._events[C];return E?E.fn?1:E.length:0},w.prototype.emit=function(x,C,E,b,y,d){var r=L?L+x:x;if(!this._events[r])return!1;var i=this._events[r],o=arguments.length,f,l;if(i.fn){i.once&&this.removeListener(x,i.fn,void 0,!0);switch(o){case 1:return i.fn.call(i.context),!0;case 2:return i.fn.call(i.context,C),!0;case 3:return i.fn.call(i.context,C,E),!0;case 4:return i.fn.call(i.context,C,E,b),!0;case 5:return i.fn.call(i.context,C,E,b,y),!0;case 6:return i.fn.call(i.context,C,E,b,y,d),!0}for(l=1,f=new Array(o-1);l<o;l++)f[l-1]=arguments[l];i.fn.apply(i.context,f)}else{var h=i.length,m;for(l=0;l<h;l++){i[l].once&&this.removeListener(x,i[l].fn,void 0,!0);switch(o){case 1:i[l].fn.call(i[l].context);break;case 2:i[l].fn.call(i[l].context,C);break;case 3:i[l].fn.call(i[l].context,C,E);break;case 4:i[l].fn.call(i[l].context,C,E,b);break;default:if(!f)for(m=1,f=new Array(o-1);m<o;m++)f[m-1]=arguments[m];i[l].fn.apply(i[l].context,f)}}}return!0},w.prototype.on=function(x,C,E){return O(this,x,C,E,!1)},w.prototype.once=function(x,C,E){return O(this,x,C,E,!0)},w.prototype.removeListener=function(x,C,E,b){var y=L?L+x:x;if(!this._events[y])return this;if(!C)return k(this,y),this;var d=this._events[y];if(d.fn)d.fn===C&&(!b||d.once)&&(!E||d.context===E)&&k(this,y);else{for(var r=0,i=[],o=d.length;r<o;r++)(d[r].fn!==C||b&&!d[r].once||E&&d[r].context!==E)&&i.push(d[r]);i.length?this._events[y]=i.length===1?i[0]:i:k(this,y)}return this},w.prototype.removeAllListeners=function(x){var C;return x?(C=L?L+x:x,this._events[C]&&k(this,C)):(this._events=new _,this._eventsCount=0),this},w.prototype.off=w.prototype.removeListener,w.prototype.addListener=w.prototype.on,w.prefixed=L,w.EventEmitter=w,he.exports=w},"./node_modules/url-toolkit/src/url-toolkit.js":function(he,N,S){(function(U){var L=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,_=/^([^\/?#]*)([^]*)$/,B=/(?:\/|^)\.(?=\/)/g,O=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,k={buildAbsoluteURL:function(w,v,x){if(x=x||{},w=w.trim(),v=v.trim(),!v){if(!x.alwaysNormalize)return w;var C=k.parseURL(w);if(!C)throw new Error("Error trying to parse base URL.");return C.path=k.normalizePath(C.path),k.buildURLFromParts(C)}var E=k.parseURL(v);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return x.alwaysNormalize?(E.path=k.normalizePath(E.path),k.buildURLFromParts(E)):v;var b=k.parseURL(w);if(!b)throw new Error("Error trying to parse base URL.");if(!b.netLoc&&b.path&&b.path[0]!=="/"){var y=_.exec(b.path);b.netLoc=y[1],b.path=y[2]}b.netLoc&&!b.path&&(b.path="/");var d={scheme:b.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(d.netLoc=b.netLoc,E.path[0]!=="/"))if(!E.path)d.path=b.path,E.params||(d.params=b.params,E.query||(d.query=b.query));else{var r=b.path,i=r.substring(0,r.lastIndexOf("/")+1)+E.path;d.path=k.normalizePath(i)}return d.path===null&&(d.path=x.alwaysNormalize?k.normalizePath(E.path):E.path),k.buildURLFromParts(d)},parseURL:function(w){var v=L.exec(w);return v?{scheme:v[1]||"",netLoc:v[2]||"",path:v[3]||"",params:v[4]||"",query:v[5]||"",fragment:v[6]||""}:null},normalizePath:function(w){for(w=w.split("").reverse().join("").replace(B,"");w.length!==(w=w.replace(O,"")).length;);return w.split("").reverse().join("")},buildURLFromParts:function(w){return w.scheme+w.netLoc+w.path+w.params+w.query+w.fragment}};he.exports=k})(this)},"./node_modules/webworkify-webpack/index.js":function(he,N,S){function U(x){var C={};function E(y){if(C[y])return C[y].exports;var d=C[y]={i:y,l:!1,exports:{}};return x[y].call(d.exports,d,d.exports,E),d.l=!0,d.exports}E.m=x,E.c=C,E.i=function(y){return y},E.d=function(y,d,r){E.o(y,d)||Object.defineProperty(y,d,{configurable:!1,enumerable:!0,get:r})},E.r=function(y){Object.defineProperty(y,"__esModule",{value:!0})},E.n=function(y){var d=y&&y.__esModule?function(){return y.default}:function(){return y};return E.d(d,"a",d),d},E.o=function(y,d){return Object.prototype.hasOwnProperty.call(y,d)},E.p="/",E.oe=function(y){throw console.error(y),y};var b=E(E.s=ENTRY_MODULE);return b.default||b}var L="[\\.|\\-|\\+|\\w|/|@]+",_="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+L+").*?\\)";function B(x){return(x+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function O(x){return!isNaN(1*x)}function k(x,C,E){var b={};b[E]=[];var y=C.toString(),d=y.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return b;for(var r=d[1],i=new RegExp("(\\\\n|\\W)"+B(r)+_,"g"),o;o=i.exec(y);){if(o[3]==="dll-reference")continue;b[E].push(o[3])}for(i=new RegExp("\\("+B(r)+'\\("(dll-reference\\s('+L+'))"\\)\\)'+_,"g");o=i.exec(y);)x[o[2]]||(b[E].push(o[1]),x[o[2]]=S(o[1]).m),b[o[2]]=b[o[2]]||[],b[o[2]].push(o[4]);for(var f=Object.keys(b),l=0;l<f.length;l++)for(var h=0;h<b[f[l]].length;h++)O(b[f[l]][h])&&(b[f[l]][h]=1*b[f[l]][h]);return b}function w(x){var C=Object.keys(x);return C.reduce(function(E,b){return E||x[b].length>0},!1)}function v(x,C){for(var E={main:[C]},b={main:[]},y={main:{}};w(E);)for(var d=Object.keys(E),r=0;r<d.length;r++){var i=d[r],o=E[i],f=o.pop();if(y[i]=y[i]||{},y[i][f]||!x[i][f])continue;y[i][f]=!0,b[i]=b[i]||[],b[i].push(f);for(var l=k(x,x[i][f],i),h=Object.keys(l),m=0;m<h.length;m++)E[h[m]]=E[h[m]]||[],E[h[m]]=E[h[m]].concat(l[h[m]])}return b}he.exports=function(x,C){C=C||{};var E={main:S.m},b=C.all?{main:Object.keys(E.main)}:v(E,x),y="";Object.keys(b).filter(function(f){return f!=="main"}).forEach(function(f){for(var l=0;b[f][l];)l++;b[f].push(l),E[f][l]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",y=y+"var "+f+" = ("+U.toString().replace("ENTRY_MODULE",JSON.stringify(l))+")({"+b[f].map(function(h){return""+JSON.stringify(h)+": "+E[f][h].toString()}).join(",")+`});
|
|
`}),y=y+"new (("+U.toString().replace("ENTRY_MODULE",JSON.stringify(x))+")({"+b.main.map(function(f){return""+JSON.stringify(f)+": "+E.main[f].toString()}).join(",")+"}))(self);";var d=new window.Blob([y],{type:"text/javascript"});if(C.bare)return d;var r=window.URL||window.webkitURL||window.mozURL||window.msURL,i=r.createObjectURL(d),o=new window.Worker(i);return o.objectURL=i,o}},"./src/config.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"hlsDefaultConfig",function(){return m}),S.d(N,"mergeConfig",function(){return u}),S.d(N,"enableStreamingMode",function(){return e});var U=S("./src/controller/abr-controller.ts"),L=S("./src/controller/audio-stream-controller.ts"),_=S("./src/controller/audio-track-controller.ts"),B=S("./src/controller/subtitle-stream-controller.ts"),O=S("./src/controller/subtitle-track-controller.ts"),k=S("./src/controller/buffer-controller.ts"),w=S("./src/controller/timeline-controller.ts"),v=S("./src/controller/cap-level-controller.ts"),x=S("./src/controller/fps-controller.ts"),C=S("./src/controller/eme-controller.ts"),E=S("./src/controller/cmcd-controller.ts"),b=S("./src/utils/xhr-loader.ts"),y=S("./src/utils/fetch-loader.ts"),d=S("./src/utils/cues.ts"),r=S("./src/utils/mediakeys-helper.ts"),i=S("./src/utils/logger.ts");function o(){return o=Object.assign||function(n){for(var a=1;a<arguments.length;a++){var p=arguments[a];for(var g in p)Object.prototype.hasOwnProperty.call(p,g)&&(n[g]=p[g])}return n},o.apply(this,arguments)}function f(n,a){var p=Object.keys(n);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(n);a&&(g=g.filter(function(T){return Object.getOwnPropertyDescriptor(n,T).enumerable})),p.push.apply(p,g)}return p}function l(n){for(var a=1;a<arguments.length;a++){var p=arguments[a]!=null?arguments[a]:{};a%2?f(Object(p),!0).forEach(function(g){h(n,g,p[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(p)):f(Object(p)).forEach(function(g){Object.defineProperty(n,g,Object.getOwnPropertyDescriptor(p,g))})}return n}function h(n,a,p){return a in n?Object.defineProperty(n,a,{value:p,enumerable:!0,configurable:!0,writable:!0}):n[a]=p,n}var m=l(l({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,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:b.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:U.default,bufferController:k.default,capLevelController:v.default,fpsController:x.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,drmSystemOptions:{},requestMediaKeySystemAccessFunc:r.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},c()),{},{subtitleStreamController:B.SubtitleStreamController,subtitleTrackController:O.default,timelineController:w.TimelineController,audioStreamController:L.default,audioTrackController:_.default,emeController:C.default,cmcdController:E.default});function c(){return{cueHandler:d.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function u(n,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return o({},n,a)}function e(n){var a=n.loader;if(a!==y.default&&a!==b.default)i.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1;else{var p=Object(y.fetchSupported)();p&&(n.loader=y.default,n.progressive=!0,n.enableSoftwareAES=!0,i.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/polyfills/number.ts"),L=S("./src/utils/ewma-bandwidth-estimator.ts"),_=S("./src/events.ts"),B=S("./src/utils/buffer-helper.ts"),O=S("./src/errors.ts"),k=S("./src/types/loader.ts"),w=S("./src/utils/logger.ts");function v(E,b){for(var y=0;y<b.length;y++){var d=b[y];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(E,d.key,d)}}function x(E,b,y){return b&&v(E.prototype,b),y&&v(E,y),E}var C=function(){function E(y){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=y;var d=y.config;this.bwEstimator=new L.default(d.abrEwmaSlowVoD,d.abrEwmaFastVoD,d.abrEwmaDefaultEstimate),this.registerListeners()}var b=E.prototype;return b.registerListeners=function(){var d=this.hls;d.on(_.Events.FRAG_LOADING,this.onFragLoading,this),d.on(_.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(_.Events.FRAG_BUFFERED,this.onFragBuffered,this),d.on(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(_.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var d=this.hls;d.off(_.Events.FRAG_LOADING,this.onFragLoading,this),d.off(_.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(_.Events.FRAG_BUFFERED,this.onFragBuffered,this),d.off(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(_.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},b.onFragLoading=function(d,r){var i=r.frag;if(i.type===k.PlaylistLevelType.MAIN&&!this.timer){var o;this.fragCurrent=i,this.partCurrent=(o=r.part)!=null?o:null,this.timer=self.setInterval(this.onCheck,100)}},b.onLevelLoaded=function(d,r){var i=this.hls.config;r.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)},b._abandonRulesCheck=function(){var d=this.fragCurrent,r=this.partCurrent,i=this.hls,o=i.autoLevelEnabled,f=i.config,l=i.media;if(!d||!l)return;var h=r?r.stats:d.stats,m=r?r.duration:d.duration;if(h.aborted){w.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!o||l.paused||!l.playbackRate||!l.readyState)return;var c=performance.now()-h.loading.start,u=Math.abs(l.playbackRate);if(c<=500*m/u)return;var e=i.levels,n=i.minAutoLevel,a=e[d.level],p=h.total||Math.max(h.loaded,Math.round(m*a.maxBitrate/8)),g=Math.max(1,h.bwEstimate?h.bwEstimate/8:h.loaded*1e3/c),T=(p-h.loaded)/g,P=l.currentTime,I=(B.BufferHelper.bufferInfo(l,P,f.maxBufferHole).end-P)/u;if(I>=2*m/u||T<=I)return;var F=Number.POSITIVE_INFINITY,W;for(W=d.level-1;W>n;W--){var z=e[W].maxBitrate;if(F=m*z/(8*.8*g),F<I)break}if(F>=T)return;var X=this.bwEstimator.getEstimate();w.logger.warn("Fragment "+d.sn+(r?" part "+r.index:"")+" of level "+d.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+W+`
|
|
Current BW estimate: `+(Object(U.isFiniteNumber)(X)?(X/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+T.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+F.toFixed(3)+` s
|
|
Time to underbuffer: `+I.toFixed(3)+" s"),i.nextLoadLevel=W,this.bwEstimator.sample(c,h.loaded),this.clearTimer(),d.loader&&(this.fragCurrent=this.partCurrent=null,d.loader.abort()),i.trigger(_.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:d,part:r,stats:h})},b.onFragLoaded=function(d,r){var i=r.frag,o=r.part;if(i.type===k.PlaylistLevelType.MAIN&&Object(U.isFiniteNumber)(i.sn)){var f=o?o.stats:i.stats,l=o?o.duration:i.duration;if(this.clearTimer(),this.lastLoadedFragLevel=i.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var h=this.hls.levels[i.level],m=(h.loaded?h.loaded.bytes:0)+f.loaded,c=(h.loaded?h.loaded.duration:0)+l;h.loaded={bytes:m,duration:c},h.realBitrate=Math.round(8*m/c)}if(i.bitrateTest){var u={stats:f,frag:i,part:o,id:i.type};this.onFragBuffered(_.Events.FRAG_BUFFERED,u),i.bitrateTest=!1}}},b.onFragBuffered=function(d,r){var i=r.frag,o=r.part,f=o?o.stats:i.stats;if(f.aborted)return;if(i.type!==k.PlaylistLevelType.MAIN||i.sn==="initSegment")return;var l=f.parsing.end-f.loading.start;this.bwEstimator.sample(l,f.loaded),f.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0},b.onError=function(d,r){switch(r.details){case O.ErrorDetails.FRAG_LOAD_ERROR:case O.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},b.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},b.getNextABRAutoLevel=function(){var d=this.fragCurrent,r=this.partCurrent,i=this.hls,o=i.maxAutoLevel,f=i.config,l=i.minAutoLevel,h=i.media,m=r?r.duration:d?d.duration:0,c=h?h.currentTime:0,u=h&&h.playbackRate!==0?Math.abs(h.playbackRate):1,e=this.bwEstimator?this.bwEstimator.getEstimate():f.abrEwmaDefaultEstimate,n=(B.BufferHelper.bufferInfo(h,c,f.maxBufferHole).end-c)/u,a=this.findBestLevel(e,l,o,n,f.abrBandWidthFactor,f.abrBandWidthUpFactor);if(a>=0)return a;w.logger.trace((n?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var p=m?Math.min(m,f.maxStarvationDelay):f.maxStarvationDelay,g=f.abrBandWidthFactor,T=f.abrBandWidthUpFactor;if(!n){var P=this.bitrateTestDelay;if(P){var I=m?Math.min(m,f.maxLoadingDelay):f.maxLoadingDelay;p=I-P,w.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*p)+" ms"),g=T=1}}return a=this.findBestLevel(e,l,o,n+p,g,T),Math.max(a,0)},b.findBestLevel=function(d,r,i,o,f,l){for(var h,m=this.fragCurrent,c=this.partCurrent,u=this.lastLoadedFragLevel,e=this.hls.levels,n=e[u],a=!!(n!=null&&(h=n.details)!==null&&h!==void 0&&h.live),p=n==null?void 0:n.codecSet,g=c?c.duration:m?m.duration:0,T=i;T>=r;T--){var P=e[T];if(!P||p&&P.codecSet!==p)continue;var I=P.details,F=(c?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||g,W=void 0;T<=u?W=f*d:W=l*d;var z=e[T].maxBitrate,X=z*F/W;if(w.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+T+"/"+Math.round(W)+"/"+z+"/"+F+"/"+o+"/"+X),W>z&&(!X||a&&!this.bitrateTestDelay||X<o))return T}return-1},x(E,[{key:"nextAutoLevel",get:function(){var d=this._nextAutoLevel,r=this.bwEstimator;if(d!==-1&&(!r||!r.canEstimate()))return d;var i=this.getNextABRAutoLevel();return d!==-1&&(i=Math.min(d,i)),i},set:function(d){this._nextAutoLevel=d}}]),E}();N.default=C},"./src/controller/audio-stream-controller.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/polyfills/number.ts"),L=S("./src/controller/base-stream-controller.ts"),_=S("./src/events.ts"),B=S("./src/utils/buffer-helper.ts"),O=S("./src/controller/fragment-tracker.ts"),k=S("./src/types/level.ts"),w=S("./src/types/loader.ts"),v=S("./src/loader/fragment.ts"),x=S("./src/demux/chunk-cache.ts"),C=S("./src/demux/transmuxer-interface.ts"),E=S("./src/types/transmuxer.ts"),b=S("./src/controller/fragment-finders.ts"),y=S("./src/utils/discontinuities.ts"),d=S("./src/errors.ts"),r=S("./src/utils/logger.ts");function i(){return i=Object.assign||function(m){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var e in u)Object.prototype.hasOwnProperty.call(u,e)&&(m[e]=u[e])}return m},i.apply(this,arguments)}function o(m,c){m.prototype=Object.create(c.prototype),m.prototype.constructor=m,f(m,c)}function f(m,c){return f=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},f(m,c)}var l=100,h=function(m){o(c,m);function c(e,n){var a;return a=m.call(this,e,n,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var u=c.prototype;return u.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},u._registerListeners=function(){var n=this.hls;n.on(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(_.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(_.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(_.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(_.Events.ERROR,this.onError,this),n.on(_.Events.BUFFER_RESET,this.onBufferReset,this),n.on(_.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(_.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(_.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(_.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u._unregisterListeners=function(){var n=this.hls;n.off(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(_.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(_.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(_.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(_.Events.ERROR,this.onError,this),n.off(_.Events.BUFFER_RESET,this.onBufferReset,this),n.off(_.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(_.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(_.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(_.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u.onInitPtsFound=function(n,a){var p=a.frag,g=a.id,T=a.initPTS;if(g==="main"){var P=p.cc;this.initPTS[p.cc]=T,this.log("InitPTS for cc: "+P+" found from main: "+T),this.videoTrackCC=P,this.state===L.State.WAITING_INIT_PTS&&this.tick()}},u.startLoad=function(n){if(!this.levels){this.startPosition=n,this.state=L.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(l),this.fragLoadError=0,a>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=L.State.IDLE):(this.loadedmetadata=!1,this.state=L.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},u.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_TRACK:{var n,a=this.levels,p=this.trackId,g=a==null||((n=a[p])===null||n===void 0)?void 0:n.details;if(g){if(this.waitForCdnTuneIn(g))break;this.state=L.State.WAITING_INIT_PTS}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var T,P=performance.now(),I=this.retryDate;(!I||P>=I||(T=this.media)!==null&&T!==void 0&&T.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=L.State.IDLE);break}case L.State.WAITING_INIT_PTS:{var F=this.waitingData;if(F){var W=F.frag,z=F.part,X=F.cache,K=F.complete;if(this.initPTS[W.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.FRAG_LOADING;var J=X.flush(),ne={frag:W,part:z,payload:J,networkDetails:null};this._handleFragmentLoadProgress(ne),K&&m.prototype._handleFragmentLoadComplete.call(this,ne)}else if(this.videoTrackCC!==this.waitingVideoCC)r.logger.log("Waiting fragment cc ("+W.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var re=this.getLoadPosition(),be=B.BufferHelper.bufferInfo(this.mediaBuffer,re,this.config.maxBufferHole),oe=Object(b.fragmentWithinToleranceTest)(be.end,this.config.maxFragLookUpTolerance,W);oe<0&&(r.logger.log("Waiting fragment cc ("+W.cc+") @ "+W.start+" cancelled because another fragment at "+be.end+" is needed"),this.clearWaitingFragment())}}else this.state=L.State.IDLE}}this.onTickEnd()},u.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.IDLE)},u.onTickEnd=function(){var n=this.media;if(!n||!n.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:n,p=a.buffered;!this.loadedmetadata&&p.length&&(this.loadedmetadata=!0),this.lastCurrentTime=n.currentTime},u.doTickIdle=function(){var n,a,p=this.hls,g=this.levels,T=this.media,P=this.trackId,I=p.config;if(!g||!g[P])return;if(!T&&(this.startFragRequested||!I.startFragPrefetch))return;var F=g[P],W=F.details;if(!W||W.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(W)){this.state=L.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,v.ElementaryStreamTypes.AUDIO,w.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,w.PlaylistLevelType.AUDIO);if(z===null)return;var X=z.len,K=this.getMaxBufferLength(),J=this.audioSwitch;if(X>=K&&!J)return;if(!J&&this._streamEnded(z,W)){p.trigger(_.Events.BUFFER_EOS,{type:"audio"}),this.state=L.State.ENDED;return}var ne=W.fragments,re=ne[0].start,be=z.end;if(J){var oe=this.getLoadPosition();be=oe,W.PTSKnown&&oe<re&&((z.end>re||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),T.currentTime=re+.05))}var ue=this.getNextFragment(be,W);if(!ue){this.bufferFlushed=!0;return}((n=ue.decryptdata)===null||n===void 0?void 0:n.keyFormat)==="identity"&&!((a=ue.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(ue,W):this.loadFragment(ue,W,be)},u.getMaxBufferLength=function(){var n=m.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,w.PlaylistLevelType.MAIN);return a===null?n:Math.max(n,a.len)},u.onMediaDetaching=function(){this.videoBuffer=null,m.prototype.onMediaDetaching.call(this)},u.onAudioTracksUpdated=function(n,a){var p=a.audioTracks;this.resetTransmuxer(),this.levels=p.map(function(g){return new k.Level(g)})},u.onAudioTrackSwitching=function(n,a){var p=!!a.url;this.trackId=a.id;var g=this.fragCurrent;g!=null&&g.loader&&g.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),p?this.setInterval(l):this.resetTransmuxer(),p?(this.audioSwitch=!0,this.state=L.State.IDLE):this.state=L.State.STOPPED,this.tick()},u.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},u.onLevelLoaded=function(n,a){this.mainDetails=a.details},u.onAudioTrackLoaded=function(n,a){var p,g=this.levels,T=a.details,P=a.id;if(!g){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+T.startSN+","+T.endSN+"],duration:"+T.totalduration);var I=g[P],F=0;if(T.live||(p=I.details)!==null&&p!==void 0&&p.live){var W=this.mainDetails;if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed||!W)return;!I.details&&T.hasProgramDateTime&&W.hasProgramDateTime?(Object(y.alignMediaPlaylistByPDT)(T,W),F=T.fragments[0].start):F=this.alignPlaylists(T,I.details)}I.details=T,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!T.live)&&this.setStartPosition(I.details,F),this.state===L.State.WAITING_TRACK&&!this.waitForCdnTuneIn(T)&&(this.state=L.State.IDLE),this.tick()},u._handleFragmentLoadProgress=function(n){var a,p=n.frag,g=n.part,T=n.payload,P=this.config,I=this.trackId,F=this.levels;if(!F){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+p.sn+" of level "+p.level+" will not be buffered");return}var W=F[I];console.assert(W,"Audio track is defined on fragment load progress");var z=W.details;console.assert(z,"Audio track details are defined on fragment load progress");var X=P.defaultAudioCodec||W.audioCodec||"mp4a.40.2",K=this.transmuxer;K||(K=this.transmuxer=new C.default(this.hls,w.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var J=this.initPTS[p.cc],ne=(a=p.initSegment)===null||a===void 0?void 0:a.data;if(J!==void 0){var re=!1,be=g?g.index:-1,oe=be!==-1,ue=new E.ChunkMetadata(p.level,p.sn,p.stats.chunkCount,T.byteLength,be,oe);K.push(T,ne,X,"",p,g,z.totalduration,re,ue,J)}else{r.logger.log("Unknown video PTS for cc "+p.cc+", waiting for video PTS before demuxing audio frag "+p.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+I);var de=this.waitingData=this.waitingData||{frag:p,part:g,cache:new x.default,complete:!1},ce=de.cache;ce.push(new Uint8Array(T)),this.waitingVideoCC=this.videoTrackCC,this.state=L.State.WAITING_INIT_PTS}},u._handleFragmentLoadComplete=function(n){if(this.waitingData){this.waitingData.complete=!0;return}m.prototype._handleFragmentLoadComplete.call(this,n)},u.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},u.onBufferCreated=function(n,a){var p=a.tracks.audio;p&&(this.mediaBuffer=p.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},u.onFragBuffered=function(n,a){var p=a.frag,g=a.part;if(p.type!==w.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(p)){this.warn("Fragment "+p.sn+(g?" p: "+g.index:"")+" of level "+p.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}p.sn!=="initSegment"&&(this.fragPrevious=p,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(_.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(p,g)},u.onError=function(n,a){switch(a.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:this.onFragmentOrKeyLoadError(w.PlaylistLevelType.AUDIO,a);break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==L.State.ERROR&&this.state!==L.State.STOPPED&&(this.state=a.fatal?L.State.ERROR:L.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var p=!0,g=this.getFwdBufferInfo(this.mediaBuffer,w.PlaylistLevelType.AUDIO);g&&g.len>.5&&(p=!this.reduceMaxBufferLength(g.len)),p&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,m.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},u.onBufferFlushed=function(n,a){var p=a.type;p===v.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},u._handleTransmuxComplete=function(n){var a,p="audio",g=this.hls,T=n.remuxResult,P=n.chunkMeta,I=this.getCurrentContext(P);if(!I){this.warn("The loading context changed while buffering fragment "+P.sn+" of level "+P.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(P.level);return}var F=I.frag,W=I.part,z=T.audio,X=T.text,K=T.id3,J=T.initSegment;if(this.fragContextChanged(F))return;if(this.state=L.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),J!=null&&J.tracks&&(this._bufferInitSegment(J.tracks,F,P),g.trigger(_.Events.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:p,tracks:J.tracks})),z){var ne=z.startPTS,re=z.endPTS,be=z.startDTS,oe=z.endDTS;W&&(W.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:ne,endPTS:re,startDTS:be,endDTS:oe}),F.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,ne,re,be,oe),this.bufferFragmentData(z,F,W,P)}if(K!=null&&(a=K.samples)!==null&&a!==void 0&&a.length){var ue=i({frag:F,id:p},K);g.trigger(_.Events.FRAG_PARSING_METADATA,ue)}if(X){var de=i({frag:F,id:p},X);g.trigger(_.Events.FRAG_PARSING_USERDATA,de)}},u._bufferInitSegment=function(n,a,p){if(this.state!==L.State.PARSING)return;n.video&&delete n.video;var g=n.audio;if(!g)return;g.levelCodec=g.codec,g.id="audio",this.log("Init audio buffer, container:"+g.container+", codecs[parsed]=["+g.codec+"]"),this.hls.trigger(_.Events.BUFFER_CODECS,n);var T=g.initSegment;if(T!=null&&T.byteLength){var P={type:"audio",frag:a,part:null,chunkMeta:p,parent:a.type,data:T};this.hls.trigger(_.Events.BUFFER_APPENDING,P)}this.tick()},u.loadFragment=function(n,a,p){var g=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||g===O.FragmentState.NOT_LOADED||g===O.FragmentState.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n):a.live&&!Object(U.isFiniteNumber)(this.initPTS[n.cc])?(this.log("Waiting for video PTS in continuity counter "+n.cc+" of live stream before loading audio fragment "+n.sn+" of level "+this.trackId),this.state=L.State.WAITING_INIT_PTS):(this.startFragRequested=!0,m.prototype.loadFragment.call(this,n,a,p)))},u.completeAudioSwitch=function(){var n=this.hls,a=this.media,p=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),m.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(_.Events.AUDIO_TRACK_SWITCHED,{id:p})},c}(L.default);N.default=h},"./src/controller/audio-track-controller.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/events.ts"),L=S("./src/errors.ts"),_=S("./src/controller/base-playlist-controller.ts"),B=S("./src/types/loader.ts");function O(C,E){for(var b=0;b<E.length;b++){var y=E[b];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(C,y.key,y)}}function k(C,E,b){return E&&O(C.prototype,E),b&&O(C,b),C}function w(C,E){C.prototype=Object.create(E.prototype),C.prototype.constructor=C,v(C,E)}function v(C,E){return v=Object.setPrototypeOf||function(y,d){return y.__proto__=d,y},v(C,E)}var x=function(C){w(E,C);function E(y){var d;return d=C.call(this,y,"[audio-track-controller]")||this,d.tracks=[],d.groupId=null,d.tracksInGroup=[],d.trackId=-1,d.trackName="",d.selectDefaultTrack=!0,d.registerListeners(),d}var b=E.prototype;return b.registerListeners=function(){var d=this.hls;d.on(U.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(U.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.on(U.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(U.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.on(U.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(U.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var d=this.hls;d.off(U.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(U.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.off(U.Events.LEVEL_LOADING,this.onLevelLoading,this),d.off(U.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.off(U.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(U.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,C.prototype.destroy.call(this)},b.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},b.onManifestParsed=function(d,r){this.tracks=r.audioTracks||[]},b.onAudioTrackLoaded=function(d,r){var i=r.id,o=r.details,f=this.tracksInGroup[i];if(!f){this.warn("Invalid audio track id "+i);return}var l=f.details;f.details=r.details,this.log("audioTrack "+i+" loaded ["+o.startSN+"-"+o.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,r,l))},b.onLevelLoading=function(d,r){this.switchLevel(r.level)},b.onLevelSwitching=function(d,r){this.switchLevel(r.level)},b.switchLevel=function(d){var r=this.hls.levels[d];if(!(r!=null&&r.audioGroupIds))return;var i=r.audioGroupIds[r.urlId];if(this.groupId!==i){this.groupId=i;var o=this.tracks.filter(function(l){return!i||l.groupId===i});this.selectDefaultTrack&&!o.some(function(l){return l.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=o;var f={audioTracks:o};this.log("Updating audio tracks, "+o.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(U.Events.AUDIO_TRACKS_UPDATED,f),this.selectInitialTrack()}},b.onError=function(d,r){if(C.prototype.onError.call(this,d,r),r.fatal||!r.context)return;r.context.type===B.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},b.setAudioTrack=function(d){var r=this.tracksInGroup;if(d<0||d>=r.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var i=r[this.trackId];this.log("Now switching to audio-track index "+d);var o=r[d],f=o.id,l=o.groupId,h=l===void 0?"":l,m=o.name,c=o.type,u=o.url;if(this.trackId=d,this.trackName=m,this.selectDefaultTrack=!1,this.hls.trigger(U.Events.AUDIO_TRACK_SWITCHING,{id:f,groupId:h,name:m,type:c,url:u}),o.details&&!o.details.live)return;var e=this.switchParams(o.url,i==null?void 0:i.details);this.loadPlaylist(e)},b.selectInitialTrack=function(){var d=this.tracksInGroup;console.assert(d.length,"Initial audio track should be selected when tracks are known");var r=this.trackName,i=this.findTrackId(r)||this.findTrackId();i!==-1?this.setAudioTrack(i):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},b.findTrackId=function(d){for(var r=this.tracksInGroup,i=0;i<r.length;i++){var o=r[i];if((!this.selectDefaultTrack||o.default)&&(!d||d===o.name))return o.id}return-1},b.loadPlaylist=function(d){var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var i=r.id,o=r.groupId,f=r.url;if(d)try{f=d.addDirectives(f)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("loading audio-track playlist for id: "+i),this.clearTimer(),this.hls.trigger(U.Events.AUDIO_TRACK_LOADING,{url:f,id:i,groupId:o,deliveryDirectives:d||null})}},k(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(d){this.selectDefaultTrack=!1,this.setAudioTrack(d)}}]),E}(_.default);N.default=x},"./src/controller/base-playlist-controller.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return k});var U=S("./src/polyfills/number.ts"),L=S("./src/types/level.ts"),_=S("./src/controller/level-helper.ts"),B=S("./src/utils/logger.ts"),O=S("./src/errors.ts"),k=function(){function w(x,C){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=B.logger.log.bind(B.logger,C+":"),this.warn=B.logger.warn.bind(B.logger,C+":"),this.hls=x}var v=w.prototype;return v.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},v.onError=function(C,E){E.fatal&&E.type===O.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},v.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},v.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},v.stopLoad=function(){this.canLoad=!1,this.clearTimer()},v.switchParams=function(C,E){var b=E==null?void 0:E.renditionReports;if(b)for(var y=0;y<b.length;y++){var d=b[y],r=""+d.URI;if(r===C.substr(-r.length)){var i=parseInt(d["LAST-MSN"]),o=parseInt(d["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var f=Math.min(E.age-E.partTarget,E.targetduration);o!==void 0&&f>E.partTarget&&(o+=1)}if(Object(U.isFiniteNumber)(i))return new L.HlsUrlParameters(i,Object(U.isFiniteNumber)(o)?o:void 0,L.HlsSkip.No)}}},v.loadPlaylist=function(C){},v.shouldLoadTrack=function(C){return this.canLoad&&C&&!!C.url&&(!C.details||C.details.live)},v.playlistLoaded=function(C,E,b){var y=this,d=E.details,r=E.stats,i=r.loading.end?Math.max(0,self.performance.now()-r.loading.end):0;if(d.advancedDateTime=Date.now()-i,d.live||b!=null&&b.live){if(d.reloaded(b),b&&this.log("live playlist "+C+" "+(d.advanced?"REFRESHED "+d.lastPartSn+"-"+d.lastPartIndex:"MISSED")),b&&d.fragments.length>0&&Object(_.mergeDetails)(b,d),!this.canLoad||!d.live)return;var o,f=void 0,l=void 0;if(d.canBlockReload&&d.endSN&&d.advanced){var h=this.hls.config.lowLatencyMode,m=d.lastPartSn,c=d.endSN,u=d.lastPartIndex,e=u!==-1,n=m===c,a=h?0:u;e?(f=n?c+1:m,l=n?a:u+1):f=c+1;var p=d.age,g=p+d.ageHeader,T=Math.min(g-d.partTarget,d.targetduration*1.5);if(T>0){if(b&&T>b.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+b.tuneInGoal+" to: "+T+" with playlist age: "+d.age),T=0;else{var P=Math.floor(T/d.targetduration);if(f+=P,l!==void 0){var I=Math.round(T%d.targetduration/d.partTarget);l+=I}this.log("CDN Tune-in age: "+d.ageHeader+"s last advanced "+p.toFixed(2)+"s goal: "+T+" skip sn "+P+" to part "+l)}d.tuneInGoal=T}if(o=this.getDeliveryDirectives(d,E.deliveryDirectives,f,l),h||!n){this.loadPlaylist(o);return}}else o=this.getDeliveryDirectives(d,E.deliveryDirectives,f,l);var F=Object(_.computeReloadInterval)(d,r);f!==void 0&&d.canBlockReload&&(F-=d.partTarget||1),this.log("reload live playlist "+C+" in "+Math.round(F)+" ms"),this.timer=self.setTimeout(function(){return y.loadPlaylist(o)},F)}else this.clearTimer()},v.getDeliveryDirectives=function(C,E,b,y){var d=Object(L.getSkipValue)(C,b);return E!=null&&E.skip&&C.deltaUpdateFailed&&(b=E.msn,y=E.part,d=L.HlsSkip.No),new L.HlsUrlParameters(b,y,d)},v.retryLoadingOrFail=function(C){var E=this,b=this.hls.config,y=this.retryCount<b.levelLoadingMaxRetry;if(y){var d;if(this.retryCount++,C.details.indexOf("LoadTimeOut")>-1&&(d=C.context)!==null&&d!==void 0&&d.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+C.details+'"'),this.loadPlaylist();else{var r=Math.min(Math.pow(2,this.retryCount)*b.levelLoadingRetryDelay,b.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return E.loadPlaylist()},r),this.warn("retry playlist loading #"+this.retryCount+" in "+r+' ms after "'+C.details+'"')}}else this.warn('cannot recover from error "'+C.details+'"'),this.clearTimer(),C.fatal=!0;return y},w}()},"./src/controller/base-stream-controller.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"State",function(){return c}),S.d(N,"default",function(){return u});var U=S("./src/polyfills/number.ts"),L=S("./src/task-loop.ts"),_=S("./src/controller/fragment-tracker.ts"),B=S("./src/utils/buffer-helper.ts"),O=S("./src/utils/logger.ts"),k=S("./src/events.ts"),w=S("./src/errors.ts"),v=S("./src/types/transmuxer.ts"),x=S("./src/utils/mp4-tools.ts"),C=S("./src/utils/discontinuities.ts"),E=S("./src/controller/fragment-finders.ts"),b=S("./src/controller/level-helper.ts"),y=S("./src/loader/fragment-loader.ts"),d=S("./src/crypt/decrypter.ts"),r=S("./src/utils/time-ranges.ts"),i=S("./src/types/loader.ts");function o(e,n){for(var a=0;a<n.length;a++){var p=n[a];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(e,p.key,p)}}function f(e,n,a){return n&&o(e.prototype,n),a&&o(e,a),e}function l(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,m(e,n)}function m(e,n){return m=Object.setPrototypeOf||function(p,g){return p.__proto__=g,p},m(e,n)}var c={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},u=function(e){h(n,e);function n(p,g,T){var P;return P=e.call(this)||this,P.hls=void 0,P.fragPrevious=null,P.fragCurrent=null,P.fragmentTracker=void 0,P.transmuxer=null,P._state=c.STOPPED,P.media=void 0,P.mediaBuffer=void 0,P.config=void 0,P.bitrateTest=!1,P.lastCurrentTime=0,P.nextLoadPosition=0,P.startPosition=0,P.loadedmetadata=!1,P.fragLoadError=0,P.retryDate=0,P.levels=null,P.fragmentLoader=void 0,P.levelLastLoaded=null,P.startFragRequested=!1,P.decrypter=void 0,P.initPTS=[],P.onvseeking=null,P.onvended=null,P.logPrefix="",P.log=void 0,P.warn=void 0,P.logPrefix=T,P.log=O.logger.log.bind(O.logger,T+":"),P.warn=O.logger.warn.bind(O.logger,T+":"),P.hls=p,P.fragmentLoader=new y.default(p.config),P.fragmentTracker=g,P.config=p.config,P.decrypter=new d.default(p,p.config),p.on(k.Events.KEY_LOADED,P.onKeyLoaded,l(P)),P}var a=n.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(g){},a.stopLoad=function(){this.fragmentLoader.abort();var g=this.fragCurrent;g&&this.fragmentTracker.removeFragment(g),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},a._streamEnded=function(g,T){var P=this.fragCurrent,I=this.fragmentTracker;if(!T.live&&P&&P.sn===T.endSN&&!g.nextStart){var F=I.getState(P);return F===_.FragmentState.PARTIAL||F===_.FragmentState.OK}return!1},a.onMediaAttached=function(g,T){var P=this.media=this.mediaBuffer=T.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),P.addEventListener("seeking",this.onvseeking),P.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===c.STOPPED&&this.startLoad(I.startPosition)},a.onMediaDetaching=function(){var g=this.media;g!=null&&g.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),g&&(g.removeEventListener("seeking",this.onvseeking),g.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var g=this.config,T=this.fragCurrent,P=this.media,I=this.mediaBuffer,F=this.state,W=P?P.currentTime:0,z=B.BufferHelper.bufferInfo(I||P,W,g.maxBufferHole);if(this.log("media seeking to "+(Object(U.isFiniteNumber)(W)?W.toFixed(3):W)+", state: "+F),F===c.ENDED)this.resetLoadingState();else if(T&&!z.len){var X=g.maxFragLookUpTolerance,K=T.start-X,J=T.start+T.duration+X,ne=W>J;(W<K||ne)&&(ne&&T.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),T.loader.abort()),this.resetLoadingState())}P&&(this.lastCurrentTime=W),!this.loadedmetadata&&!z.len&&(this.nextLoadPosition=this.startPosition=W),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(g,T){if(this.state!==c.KEY_LOADING||T.frag!==this.fragCurrent||!this.levels)return;this.state=c.IDLE;var P=this.levels[T.frag.level].details;P&&this.loadFragment(T.frag,P,T.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(k.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,e.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(g,T){this.log("Loading key for "+g.sn+" of ["+T.startSN+"-"+T.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level),this.state=c.KEY_LOADING,this.fragCurrent=g,this.hls.trigger(k.Events.KEY_LOADING,{frag:g})},a.loadFragment=function(g,T,P){this._loadFragForPlayback(g,T,P)},a._loadFragForPlayback=function(g,T,P){var I=this,F=function(z){if(I.fragContextChanged(g)){I.warn("Fragment "+g.sn+(z.part?" p: "+z.part.index:"")+" of level "+g.level+" was dropped during download."),I.fragmentTracker.removeFragment(g);return}g.stats.chunkCount++,I._handleFragmentLoadProgress(z)};this._doFragLoad(g,T,P,F).then(function(W){if(!W)return;I.fragLoadError=0;var z=I.state;if(I.fragContextChanged(g)){(z===c.FRAG_LOADING||z===c.BACKTRACKING||!I.fragCurrent&&z===c.PARSING)&&(I.fragmentTracker.removeFragment(g),I.state=c.IDLE);return}if("payload"in W&&(I.log("Loaded fragment "+g.sn+" of level "+g.level),I.hls.trigger(k.Events.FRAG_LOADED,W),I.state===c.BACKTRACKING)){I.fragmentTracker.backtrack(g,W),I.resetFragmentLoading(g);return}I._handleFragmentLoadComplete(W)}).catch(function(W){I.warn(W),I.resetFragmentLoading(g)})},a.flushMainBuffer=function(g,T,P){if(P===void 0&&(P=null),!(g-T))return;var I={startOffset:g,endOffset:T,type:P};this.fragLoadError=0,this.hls.trigger(k.Events.BUFFER_FLUSHING,I)},a._loadInitSegment=function(g){var T=this;this._doFragLoad(g).then(function(P){if(!P||T.fragContextChanged(g)||!T.levels)throw new Error("init load aborted");return P}).then(function(P){var I=T.hls,F=P.payload,W=g.decryptdata;if(F&&F.byteLength>0&&W&&W.key&&W.iv&&W.method==="AES-128"){var z=self.performance.now();return T.decrypter.webCryptoDecrypt(new Uint8Array(F),W.key.buffer,W.iv.buffer).then(function(X){var K=self.performance.now();return I.trigger(k.Events.FRAG_DECRYPTED,{frag:g,payload:X,stats:{tstart:z,tdecrypt:K}}),P.payload=X,P})}return P}).then(function(P){var I=T.fragCurrent,F=T.hls,W=T.levels;if(!W)throw new Error("init load aborted, missing levels");var z=W[g.level].details;console.assert(z,"Level details are defined when init segment is loaded");var X=g.stats;T.state=c.IDLE,T.fragLoadError=0,g.data=new Uint8Array(P.payload),X.parsing.start=X.buffering.start=self.performance.now(),X.parsing.end=X.buffering.end=self.performance.now(),P.frag===I&&F.trigger(k.Events.FRAG_BUFFERED,{stats:X,frag:I,part:null,id:g.type}),T.tick()}).catch(function(P){T.warn(P),T.resetFragmentLoading(g)})},a.fragContextChanged=function(g){var T=this.fragCurrent;return!g||!T||g.level!==T.level||g.sn!==T.sn||g.urlId!==T.urlId},a.fragBufferedComplete=function(g,T){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+g.type+" sn: "+g.sn+(T?" part: "+T.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level+" "+r.default.toString(B.BufferHelper.getBuffered(P))),this.state=c.IDLE,this.tick()},a._handleFragmentLoadComplete=function(g){var T=this.transmuxer;if(!T)return;var P=g.frag,I=g.part,F=g.partsLoaded,W=!F||F.length===0||F.some(function(X){return!X}),z=new v.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,I?I.index:-1,!W);T.flush(z)},a._handleFragmentLoadProgress=function(g){},a._doFragLoad=function(g,T,P,I){var F=this;if(P===void 0&&(P=null),!this.levels)throw new Error("frag load aborted, missing levels");if(P=Math.max(g.start,P||0),this.config.lowLatencyMode&&T){var W=T.partList;if(W&&I){P>g.end&&T.fragmentHint&&(g=T.fragmentHint);var z=this.getNextPart(W,g,P);if(z>-1){var X=W[z];return this.log("Loading part sn: "+g.sn+" p: "+X.index+" cc: "+g.cc+" of playlist ["+T.startSN+"-"+T.endSN+"] parts [0-"+z+"-"+(W.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=X.start+X.duration,this.state=c.FRAG_LOADING,this.hls.trigger(k.Events.FRAG_LOADING,{frag:g,part:W[z],targetBufferTime:P}),this.doFragPartsLoad(g,W,z,I).catch(function(K){return F.handleFragLoadError(K)})}else if(!g.url||this.loadedEndOfParts(W,P))return Promise.resolve(null)}}return this.log("Loading fragment "+g.sn+" cc: "+g.cc+" "+(T?"of ["+T.startSN+"-"+T.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(P.toFixed(3))),Object(U.isFiniteNumber)(g.sn)&&!this.bitrateTest&&(this.nextLoadPosition=g.start+g.duration),this.state=c.FRAG_LOADING,this.hls.trigger(k.Events.FRAG_LOADING,{frag:g,targetBufferTime:P}),this.fragmentLoader.load(g,I).catch(function(K){return F.handleFragLoadError(K)})},a.doFragPartsLoad=function(g,T,P,I){var F=this;return new Promise(function(W,z){var X=[],K=function J(ne){var re=T[ne];F.fragmentLoader.loadPart(g,re,I).then(function(be){X[re.index]=be;var oe=be.part;F.hls.trigger(k.Events.FRAG_LOADED,be);var ue=T[ne+1];if(ue&&ue.fragment===g)J(ne+1);else return W({frag:g,part:oe,partsLoaded:X})}).catch(z)};K(P)})},a.handleFragLoadError=function(g){var T=g.data;return T&&T.details===w.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(T.frag,T.part):this.hls.trigger(k.Events.ERROR,T),null},a._handleTransmuxerFlush=function(g){var T=this.getCurrentContext(g);if(!T||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var P=T.frag,I=T.part,F=T.level,W=self.performance.now();P.stats.parsing.end=W,I&&(I.stats.parsing.end=W),this.updateLevelTiming(P,I,F,g.partial)},a.getCurrentContext=function(g){var T=this.levels,P=g.level,I=g.sn,F=g.part;if(!T||!T[P])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+P+". The current chunk will not be buffered."),null;var W=T[P],z=F>-1?Object(b.getPartWith)(W,I,F):null,X=z?z.fragment:Object(b.getFragmentWithSN)(W,I,this.fragCurrent);return X?{frag:X,part:z,level:W}:null},a.bufferFragmentData=function(g,T,P,I){if(!g||this.state!==c.PARSING)return;var F=g.data1,W=g.data2,z=F;if(F&&W&&(z=Object(x.appendUint8Array)(F,W)),!z||!z.length)return;var X={type:g.type,frag:T,part:P,chunkMeta:I,parent:T.type,data:z};this.hls.trigger(k.Events.BUFFER_APPENDING,X),g.dropped&&g.independent&&!P&&this.flushBufferGap(T)},a.flushBufferGap=function(g){var T=this.media;if(!T)return;if(!B.BufferHelper.isBuffered(T,T.currentTime)){this.flushMainBuffer(0,g.start);return}var P=T.currentTime,I=B.BufferHelper.bufferInfo(T,P,0),F=g.duration,W=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),z=Math.max(Math.min(g.start-W,I.end-W),P+W);g.start-z>W&&this.flushMainBuffer(z,g.start)},a.getFwdBufferInfo=function(g,T){var P=this.config,I=this.getLoadPosition();if(!Object(U.isFiniteNumber)(I))return null;var F=B.BufferHelper.bufferInfo(g,I,P.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var W=this.fragmentTracker.getBufferedFrag(I,T);if(W&&F.nextStart<W.end)return B.BufferHelper.bufferInfo(g,I,Math.max(F.nextStart,P.maxBufferHole))}return F},a.getMaxBufferLength=function(g){var T=this.config,P;return g?P=Math.max(8*T.maxBufferSize/g,T.maxBufferLength):P=T.maxBufferLength,Math.min(P,T.maxMaxBufferLength)},a.reduceMaxBufferLength=function(g){var T=this.config,P=g||T.maxBufferLength;return T.maxMaxBufferLength>=P?(T.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+T.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(g,T){var P,I,F=T.fragments,W=F.length;if(!W)return null;var z=this.config,X=F[0].start,K;if(T.live){var J=z.initialLiveManifestSize;if(W<J)return this.warn("Not enough fragments to start playback (have: "+W+", need: "+J+")"),null;!T.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(K=this.getInitialLiveFragment(T,F),this.startPosition=K?this.hls.liveSyncPosition||K.start:g)}else g<=X&&(K=F[0]);if(!K){var ne=z.lowLatencyMode?T.partEnd:T.fragmentEnd;K=this.getFragmentAtPosition(g,ne,T)}return(P=K)!==null&&P!==void 0&&P.initSegment&&!((I=K)!==null&&I!==void 0&&I.initSegment.data)&&!this.bitrateTest&&(K=K.initSegment),K},a.getNextPart=function(g,T,P){for(var I=-1,F=!1,W=!0,z=0,X=g.length;z<X;z++){var K=g[z];if(W=W&&!K.independent,I>-1&&P<K.start)break;var J=K.loaded;!J&&(F||K.independent||W)&&K.fragment===T&&(I=z),F=J}return I},a.loadedEndOfParts=function(g,T){var P=g[g.length-1];return P&&T>P.start&&P.loaded},a.getInitialLiveFragment=function(g,T){var P=this.fragPrevious,I=null;if(P){if(g.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),I=Object(E.findFragmentByPDT)(T,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var F=P.sn+1;if(F>=g.startSN&&F<=g.endSN){var W=T[F-g.startSN];P.cc===W.cc&&(I=W,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=Object(E.findFragWithCC)(T,P.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var z=this.hls.liveSyncPosition;z!==null&&(I=this.getFragmentAtPosition(z,this.bitrateTest?g.fragmentEnd:g.edge,g))}return I},a.getFragmentAtPosition=function(g,T,P){var I=this.config,F=this.fragPrevious,W=P.fragments,z=P.endSN,X=P.fragmentHint,K=I.maxFragLookUpTolerance,J=!!(I.lowLatencyMode&&P.partList&&X);J&&X&&!this.bitrateTest&&(W=W.concat(X),z=X.sn);var ne;if(g<T){var re=g>T-K?0:K;ne=Object(E.findFragmentByPTS)(F,W,g,re)}else ne=W[W.length-1];if(ne){var be=ne.sn-P.startSN,oe=F&&ne.level===F.level,ue=W[be+1],de=this.fragmentTracker.getState(ne);if(de===_.FragmentState.BACKTRACKED){ne=null;for(var ce=be;W[ce]&&this.fragmentTracker.getState(W[ce])===_.FragmentState.BACKTRACKED;)F?ne=W[ce--]:ne=W[--ce];ne||(ne=ue)}else F&&ne.sn===F.sn&&!J&&(oe&&(ne.sn<z&&this.fragmentTracker.getState(ue)!==_.FragmentState.OK?(this.log("SN "+ne.sn+" just loaded, load next one: "+ue.sn),ne=ue):ne=null))}return ne},a.synchronizeToLiveEdge=function(g){var T=this.config,P=this.media;if(!P)return;var I=this.hls.liveSyncPosition,F=P.currentTime,W=g.fragments[0].start,z=g.edge,X=F>=W-T.maxFragLookUpTolerance&&F<=z;if(I!==null&&P.duration>I&&(F<I||!X)){var K=T.liveMaxLatencyDuration!==void 0?T.liveMaxLatencyDuration:T.liveMaxLatencyDurationCount*g.targetduration;(!X&&P.readyState<4||F<z-K)&&(this.loadedmetadata||(this.nextLoadPosition=I),P.readyState&&(this.warn("Playback: "+F.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+I.toFixed(3)),P.currentTime=I))}},a.alignPlaylists=function(g,T){var P=this.levels,I=this.levelLastLoaded,F=this.fragPrevious,W=I!==null?P[I]:null,z=g.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var X=g.fragments[0].start,K=!T,J=g.alignedSliding&&Object(U.isFiniteNumber)(X);if(K||!J&&!X){Object(C.alignStream)(F,W,g);var ne=g.fragments[0].start;return this.log("Live playlist sliding: "+ne.toFixed(2)+" start-sn: "+(T?T.startSN:"na")+"->"+g.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+z),ne}return X},a.waitForCdnTuneIn=function(g){var T=3;return g.live&&g.canBlockReload&&g.tuneInGoal>Math.max(g.partHoldBack,g.partTarget*T)},a.setStartPosition=function(g,T){var P=this.startPosition;if(P<T&&(P=-1),P===-1||this.lastCurrentTime===-1){var I=g.startTimeOffset;Object(U.isFiniteNumber)(I)?(P=T+I,I<0&&(P+=g.totalduration),P=Math.min(Math.max(T,P),T+g.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+P),this.startPosition=P):g.live?P=this.hls.liveSyncPosition||T:this.startPosition=P=0,this.lastCurrentTime=P}this.nextLoadPosition=P},a.getLoadPosition=function(){var g=this.media,T=0;return this.loadedmetadata&&g?T=g.currentTime:this.nextLoadPosition&&(T=this.nextLoadPosition),T},a.handleFragLoadAborted=function(g,T){this.transmuxer&&g.sn!=="initSegment"&&g.stats.aborted&&(this.warn("Fragment "+g.sn+(T?" part"+T.index:"")+" of level "+g.level+" was aborted"),this.resetFragmentLoading(g))},a.resetFragmentLoading=function(g){(!this.fragCurrent||!this.fragContextChanged(g))&&(this.state=c.IDLE)},a.onFragmentOrKeyLoadError=function(g,T){if(T.fatal)return;var P=T.frag;if(!P||P.type!==g)return;var I=this.fragCurrent;console.assert(I&&P.sn===I.sn&&P.level===I.level&&P.urlId===I.urlId,"Frag load error must match current frag to retry");var F=this.config;if(this.fragLoadError+1<=F.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(P.level))return;var W=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+P.sn+" of "+g+" "+P.level+" failed to load, retrying in "+W+"ms"),this.retryDate=self.performance.now()+W,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else T.levelRetry?(g===i.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(O.logger.error(T.details+" reaches max retry, redispatch as fatal ..."),T.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)},a.afterBufferFlushed=function(g,T,P){if(!g)return;var I=B.BufferHelper.getBuffered(g);this.fragmentTracker.detectEvictedFragments(T,I,P),this.state===c.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},a.resetLiveStartWhenNotLoaded=function(g){if(!this.loadedmetadata){this.startFragRequested=!1;var T=this.levels?this.levels[g].details:null;if(T!=null&&T.live)return this.startPosition=-1,this.setStartPosition(T,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(g,T,P,I){var F=this,W=P.details;console.assert(!!W,"level.details must be defined");var z=Object.keys(g.elementaryStreams).reduce(function(X,K){var J=g.elementaryStreams[K];if(J){var ne=J.endPTS-J.startPTS;if(ne<=0)return F.warn("Could not parse fragment "+g.sn+" "+K+" duration reliably ("+ne+") resetting transmuxer to fallback to playlist timing"),F.resetTransmuxer(),X||!1;var re=I?0:Object(b.updateFragPTSDTS)(W,g,J.startPTS,J.endPTS,J.startDTS,J.endDTS);return F.hls.trigger(k.Events.LEVEL_PTS_UPDATED,{details:W,level:P,drift:re,type:K,frag:g,start:J.startPTS,end:J.endPTS}),!0}return X},!1);z?(this.state=c.PARSED,this.hls.trigger(k.Events.FRAG_PARSED,{frag:g,part:T})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},f(n,[{key:"state",get:function(){return this._state},set:function(g){var T=this._state;T!==g&&(this._state=g,this.log(T+"->"+g))}}]),n}(L.default)},"./src/controller/buffer-controller.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return E});var U=S("./src/polyfills/number.ts"),L=S("./src/events.ts"),_=S("./src/utils/logger.ts"),B=S("./src/errors.ts"),O=S("./src/utils/buffer-helper.ts"),k=S("./src/utils/mediasource-helper.ts"),w=S("./src/loader/fragment.ts"),v=S("./src/controller/buffer-operation-queue.ts"),x=Object(k.getMediaSource)(),C=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function b(d){var r=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var i=r.hls,o=r.media,f=r.mediaSource;_.logger.log("[buffer-controller]: Media source opened"),o&&(r.updateMediaElementDuration(),i.trigger(L.Events.MEDIA_ATTACHED,{media:o})),f&&f.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},this._onMediaSourceClose=function(){_.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){_.logger.log("[buffer-controller]: Media source ended")},this.hls=d,this._initSourceBuffer(),this.registerListeners()}var y=b.prototype;return y.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},y.destroy=function(){this.unregisterListeners(),this.details=null},y.registerListeners=function(){var r=this.hls;r.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),r.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(L.Events.BUFFER_RESET,this.onBufferReset,this),r.on(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),r.on(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),r.on(L.Events.BUFFER_EOS,this.onBufferEos,this),r.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),r.on(L.Events.FRAG_PARSED,this.onFragParsed,this),r.on(L.Events.FRAG_CHANGED,this.onFragChanged,this)},y.unregisterListeners=function(){var r=this.hls;r.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),r.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(L.Events.BUFFER_RESET,this.onBufferReset,this),r.off(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),r.off(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),r.off(L.Events.BUFFER_EOS,this.onBufferEos,this),r.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),r.off(L.Events.FRAG_PARSED,this.onFragParsed,this),r.off(L.Events.FRAG_CHANGED,this.onFragChanged,this)},y._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new v.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},y.onManifestParsed=function(r,i){var o=2;(i.audio&&!i.video||!i.altAudio)&&(o=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=o,this.details=null,_.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},y.onMediaAttaching=function(r,i){var o=this.media=i.media;if(o&&x){var f=this.mediaSource=new x;f.addEventListener("sourceopen",this._onMediaSourceOpen),f.addEventListener("sourceended",this._onMediaSourceEnded),f.addEventListener("sourceclose",this._onMediaSourceClose),o.src=self.URL.createObjectURL(f),this._objectUrl=o.src}},y.onMediaDetaching=function(){var r=this.media,i=this.mediaSource,o=this._objectUrl;if(i){if(_.logger.log("[buffer-controller]: media source detaching"),i.readyState==="open")try{i.endOfStream()}catch(f){_.logger.warn("[buffer-controller]: onMediaDetaching: "+f.message+" while calling endOfStream")}this.onBufferReset(),i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),r&&(o&&self.URL.revokeObjectURL(o),r.src===o?(r.removeAttribute("src"),r.load()):_.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(L.Events.MEDIA_DETACHED,void 0)},y.onBufferReset=function(){var r=this;this.getSourceBufferTypes().forEach(function(i){var o=r.sourceBuffer[i];try{o&&(r.removeBufferListeners(i),r.mediaSource&&r.mediaSource.removeSourceBuffer(o),r.sourceBuffer[i]=void 0)}catch(f){_.logger.warn("[buffer-controller]: Failed to reset the "+i+" buffer",f)}}),this._initSourceBuffer()},y.onBufferCodecs=function(r,i){var o=this,f=this.getSourceBufferTypes().length;if(Object.keys(i).forEach(function(l){if(f){var h=o.tracks[l];if(h&&typeof h.buffer.changeType=="function"){var m=i[l],c=m.codec,u=m.levelCodec,e=m.container,n=(h.levelCodec||h.codec).replace(C,"$1"),a=(u||c).replace(C,"$1");if(n!==a){var p=e+";codecs="+(u||c);o.appendChangeType(l,p)}}}else o.pendingTracks[l]=i[l]}),f)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},y.appendChangeType=function(r,i){var o=this,f=this.operationQueue,l={execute:function(){var m=o.sourceBuffer[r];m&&(_.logger.log("[buffer-controller]: changing "+r+" sourceBuffer type to "+i),m.changeType(i)),f.shiftAndExecuteNext(r)},onStart:function(){},onComplete:function(){},onError:function(m){_.logger.warn("[buffer-controller]: Failed to change "+r+" SourceBuffer type",m)}};f.append(l,r)},y.onBufferAppending=function(r,i){var o=this,f=this.hls,l=this.operationQueue,h=this.tracks,m=i.data,c=i.type,u=i.frag,e=i.part,n=i.chunkMeta,a=n.buffering[c],p=self.performance.now();a.start=p;var g=u.stats.buffering,T=e?e.stats.buffering:null;g.start===0&&(g.start=p),T&&T.start===0&&(T.start=p);var P=h.audio,I=c==="audio"&&n.id===1&&(P==null?void 0:P.container)==="audio/mpeg",F={execute:function(){if(a.executeStart=self.performance.now(),I){var z=o.sourceBuffer[c];if(z){var X=u.start-z.timestampOffset;Math.abs(X)>=.1&&(_.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+u.start+" (delta: "+X+") sn: "+u.sn+")"),z.timestampOffset=u.start)}}o.appendExecutor(m,c)},onStart:function(){},onComplete:function(){var z=self.performance.now();a.executeEnd=a.end=z,g.first===0&&(g.first=z),T&&T.first===0&&(T.first=z);var X=o.sourceBuffer,K={};for(var J in X)K[J]=O.BufferHelper.getBuffered(X[J]);o.appendError=0,o.hls.trigger(L.Events.BUFFER_APPENDED,{type:c,frag:u,part:e,chunkMeta:n,parent:u.type,timeRanges:K})},onError:function(z){_.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",z);var X={type:B.ErrorTypes.MEDIA_ERROR,parent:u.type,details:B.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?X.details=B.ErrorDetails.BUFFER_FULL_ERROR:(o.appendError++,X.details=B.ErrorDetails.BUFFER_APPEND_ERROR,o.appendError>f.config.appendErrorMaxRetry&&(_.logger.error("[buffer-controller]: Failed "+f.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),X.fatal=!0)),f.trigger(L.Events.ERROR,X)}};l.append(F,c)},y.onBufferFlushing=function(r,i){var o=this,f=this.operationQueue,l=function(m){return{execute:o.removeExecutor.bind(o,m,i.startOffset,i.endOffset),onStart:function(){},onComplete:function(){o.hls.trigger(L.Events.BUFFER_FLUSHED,{type:m})},onError:function(u){_.logger.warn("[buffer-controller]: Failed to remove from "+m+" SourceBuffer",u)}}};i.type?f.append(l(i.type),i.type):this.getSourceBufferTypes().forEach(function(h){f.append(l(h),h)})},y.onFragParsed=function(r,i){var o=this,f=i.frag,l=i.part,h=[],m=l?l.elementaryStreams:f.elementaryStreams;m[w.ElementaryStreamTypes.AUDIOVIDEO]?h.push("audiovideo"):(m[w.ElementaryStreamTypes.AUDIO]&&h.push("audio"),m[w.ElementaryStreamTypes.VIDEO]&&h.push("video"));var c=function(){var e=self.performance.now();f.stats.buffering.end=e,l&&(l.stats.buffering.end=e);var n=l?l.stats:f.stats;o.hls.trigger(L.Events.FRAG_BUFFERED,{frag:f,part:l,stats:n,id:f.type})};h.length===0&&_.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+f.type+" level: "+f.level+" sn: "+f.sn),this.blockBuffers(c,h)},y.onFragChanged=function(r,i){this.flushBackBuffer()},y.onBufferEos=function(r,i){var o=this,f=this.getSourceBufferTypes().reduce(function(l,h){var m=o.sourceBuffer[h];return(!i.type||i.type===h)&&(m&&!m.ended&&(m.ended=!0,_.logger.log("[buffer-controller]: "+h+" sourceBuffer now EOS"))),l&&!!(!m||m.ended)},!0);f&&this.blockBuffers(function(){var l=o.mediaSource;if(!l||l.readyState!=="open")return;l.endOfStream()})},y.onLevelUpdated=function(r,i){var o=i.details;if(!o.fragments.length)return;this.details=o,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},y.flushBackBuffer=function(){var r=this.hls,i=this.details,o=this.media,f=this.sourceBuffer;if(!o||i===null)return;var l=this.getSourceBufferTypes();if(!l.length)return;var h=i.live&&r.config.liveBackBufferLength!==null?r.config.liveBackBufferLength:r.config.backBufferLength;if(!Object(U.isFiniteNumber)(h)||h<0)return;var m=o.currentTime,c=i.levelTargetDuration,u=Math.max(h,c),e=Math.floor(m/c)*c-u;l.forEach(function(n){var a=f[n];if(a){var p=O.BufferHelper.getBuffered(a);p.length>0&&e>p.start(0)&&(r.trigger(L.Events.BACK_BUFFER_REACHED,{bufferEnd:e}),i.live&&r.trigger(L.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:e}),r.trigger(L.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:e,type:n}))}})},y.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var r=this.details,i=this.hls,o=this.media,f=this.mediaSource,l=r.fragments[0].start+r.totalduration,h=o.duration,m=Object(U.isFiniteNumber)(f.duration)?f.duration:0;r.live&&i.config.liveDurationInfinity?(_.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),f.duration=Infinity,this.updateSeekableRange(r)):(l>m&&l>h||!Object(U.isFiniteNumber)(h))&&(_.logger.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),f.duration=l)},y.updateSeekableRange=function(r){var i=this.mediaSource,o=r.fragments,f=o.length;if(f&&r.live&&i!==null&&i!==void 0&&i.setLiveSeekableRange){var l=Math.max(0,o[0].start),h=Math.max(l,l+r.totalduration);i.setLiveSeekableRange(l,h)}},y.checkPendingTracks=function(){var r=this.bufferCodecEventsExpected,i=this.operationQueue,o=this.pendingTracks,f=Object.keys(o).length;if(f&&!r||f===2){this.createSourceBuffers(o),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length===0){this.hls.trigger(L.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}l.forEach(function(h){i.executeNext(h)})}},y.createSourceBuffers=function(r){var i=this.sourceBuffer,o=this.mediaSource;if(!o)throw Error("createSourceBuffers called when mediaSource was null");var f=0;for(var l in r)if(!i[l]){var h=r[l];if(!h)throw Error("source buffer exists for track "+l+", however track does not");var m=h.levelCodec||h.codec,c=h.container+";codecs="+m;_.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var u=i[l]=o.addSourceBuffer(c),e=l;this.addBufferListener(e,"updatestart",this._onSBUpdateStart),this.addBufferListener(e,"updateend",this._onSBUpdateEnd),this.addBufferListener(e,"error",this._onSBUpdateError),this.tracks[l]={buffer:u,codec:m,container:h.container,levelCodec:h.levelCodec,id:h.id},f++}catch(n){_.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+n.message),this.hls.trigger(L.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:n,mimeType:c})}}f&&this.hls.trigger(L.Events.BUFFER_CREATED,{tracks:this.tracks})},y._onSBUpdateStart=function(r){var i=this.operationQueue,o=i.current(r);o.onStart()},y._onSBUpdateEnd=function(r){var i=this.operationQueue,o=i.current(r);o.onComplete(),i.shiftAndExecuteNext(r)},y._onSBUpdateError=function(r,i){_.logger.error("[buffer-controller]: "+r+" SourceBuffer error",i),this.hls.trigger(L.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var o=this.operationQueue.current(r);o&&o.onError(i)},y.removeExecutor=function(r,i,o){var f=this.media,l=this.mediaSource,h=this.operationQueue,m=this.sourceBuffer,c=m[r];if(!f||!l||!c){_.logger.warn("[buffer-controller]: Attempting to remove from the "+r+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(r);return}var u=Object(U.isFiniteNumber)(f.duration)?f.duration:Infinity,e=Object(U.isFiniteNumber)(l.duration)?l.duration:Infinity,n=Math.max(0,i),a=Math.min(o,u,e);a>n?(_.logger.log("[buffer-controller]: Removing ["+n+","+a+"] from the "+r+" SourceBuffer"),console.assert(!c.updating,r+" sourceBuffer must not be updating"),c.remove(n,a)):h.shiftAndExecuteNext(r)},y.appendExecutor=function(r,i){var o=this.operationQueue,f=this.sourceBuffer,l=f[i];if(!l){_.logger.warn("[buffer-controller]: Attempting to append to the "+i+" SourceBuffer, but it does not exist"),o.shiftAndExecuteNext(i);return}l.ended=!1,console.assert(!l.updating,i+" sourceBuffer must not be updating"),l.appendBuffer(r)},y.blockBuffers=function(r,i){var o=this;if(i===void 0&&(i=this.getSourceBufferTypes()),!i.length){_.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(r);return}var f=this.operationQueue,l=i.map(function(h){return f.appendBlocker(h)});Promise.all(l).then(function(){r(),i.forEach(function(h){var m=o.sourceBuffer[h];(!m||!m.updating)&&f.shiftAndExecuteNext(h)})})},y.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},y.addBufferListener=function(r,i,o){var f=this.sourceBuffer[r];if(!f)return;var l=o.bind(this,r);this.listeners[r].push({event:i,listener:l}),f.addEventListener(i,l)},y.removeBufferListeners=function(r){var i=this.sourceBuffer[r];if(!i)return;this.listeners[r].forEach(function(o){i.removeEventListener(o.event,o.listener)})},b}()},"./src/controller/buffer-operation-queue.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return L});var U=S("./src/utils/logger.ts"),L=function(){function _(O){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=O}var B=_.prototype;return B.append=function(k,w){var v=this.queues[w];v.push(k),v.length===1&&this.buffers[w]&&this.executeNext(w)},B.insertAbort=function(k,w){var v=this.queues[w];v.unshift(k),this.executeNext(w)},B.appendBlocker=function(k){var w,v=new Promise(function(C){w=C}),x={execute:w,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(x,k),v},B.executeNext=function(k){var w=this.buffers,v=this.queues,x=w[k],C=v[k];if(C.length){var E=C[0];try{E.execute()}catch(b){U.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(b),(!x||!x.updating)&&(C.shift(),this.executeNext(k))}}},B.shiftAndExecuteNext=function(k){this.queues[k].shift(),this.executeNext(k)},B.current=function(k){return this.queues[k][0]},_}()},"./src/controller/cap-level-controller.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/events.ts");function L(O,k){for(var w=0;w<k.length;w++){var v=k[w];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(O,v.key,v)}}function _(O,k,w){return k&&L(O.prototype,k),w&&L(O,w),O}var B=function(){function O(w){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=w,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var k=O.prototype;return k.setStreamController=function(v){this.streamController=v},k.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},k.registerListeners=function(){var v=this.hls;v.on(U.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.on(U.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.on(U.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.on(U.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.on(U.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},k.unregisterListener=function(){var v=this.hls;v.off(U.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.off(U.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(U.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.off(U.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.off(U.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},k.onFpsDropLevelCapping=function(v,x){O.isLevelAllowed(x.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(x.droppedLevel)},k.onMediaAttaching=function(v,x){this.media=x.media instanceof HTMLVideoElement?x.media:null},k.onManifestParsed=function(v,x){var C=this.hls;this.restrictedLevels=[],this.firstLevel=x.firstLevel,C.config.capLevelToPlayerSize&&x.video&&this.startCapping()},k.onBufferCodecs=function(v,x){var C=this.hls;C.config.capLevelToPlayerSize&&x.video&&this.startCapping()},k.onMediaDetaching=function(){this.stopCapping()},k.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var v=this.hls.levels;if(v.length){var x=this.hls;x.autoLevelCapping=this.getMaxLevel(v.length-1),x.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=x.autoLevelCapping}}},k.getMaxLevel=function(v){var x=this,C=this.hls.levels;if(!C.length)return-1;var E=C.filter(function(b,y){return O.isLevelAllowed(y,x.restrictedLevels)&&y<=v});return this.clientRect=null,O.getMaxLevelByMediaSize(E,this.mediaWidth,this.mediaHeight)},k.startCapping=function(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize()},k.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},k.getDimensions=function(){if(this.clientRect)return this.clientRect;var v=this.media,x={width:0,height:0};if(v){var C=v.getBoundingClientRect();x.width=C.width,x.height=C.height,!x.width&&!x.height&&(x.width=C.right-C.left||v.width||0,x.height=C.bottom-C.top||v.height||0)}return this.clientRect=x,x},O.isLevelAllowed=function(v,x){return x===void 0&&(x=[]),x.indexOf(v)===-1},O.getMaxLevelByMediaSize=function(v,x,C){if(!v||!v.length)return-1;for(var E=function(i,o){return o?i.width!==o.width||i.height!==o.height:!0},b=v.length-1,y=0;y<v.length;y+=1){var d=v[y];if((d.width>=x||d.height>=C)&&E(d,v[y+1])){b=y;break}}return b},_(O,[{key:"mediaWidth",get:function(){return this.getDimensions().width*O.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*O.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var v=1;try{v=self.devicePixelRatio}catch(x){}return v}}]),O}();N.default=B},"./src/controller/cmcd-controller.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return E});var U=S("./src/events.ts"),L=S("./src/types/cmcd.ts"),_=S("./src/utils/buffer-helper.ts"),B=S("./src/utils/logger.ts");function O(b,y){for(var d=0;d<y.length;d++){var r=y[d];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(b,r.key,r)}}function k(b,y,d){return y&&O(b.prototype,y),d&&O(b,d),b}function w(b,y){var d=typeof Symbol!="undefined"&&b[Symbol.iterator]||b["@@iterator"];if(d)return(d=d.call(b)).next.bind(d);if(Array.isArray(b)||(d=v(b))||y&&b&&typeof b.length=="number"){d&&(b=d);var r=0;return function(){return r>=b.length?{done:!0}:{done:!1,value:b[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function v(b,y){if(!b)return;if(typeof b=="string")return x(b,y);var d=Object.prototype.toString.call(b).slice(8,-1);if(d==="Object"&&b.constructor&&(d=b.constructor.name),d==="Map"||d==="Set")return Array.from(b);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return x(b,y)}function x(b,y){(y==null||y>b.length)&&(y=b.length);for(var d=0,r=new Array(y);d<y;d++)r[d]=b[d];return r}function C(){return C=Object.assign||function(b){for(var y=1;y<arguments.length;y++){var d=arguments[y];for(var r in d)Object.prototype.hasOwnProperty.call(d,r)&&(b[r]=d[r])}return b},C.apply(this,arguments)}var E=function(){function b(d){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(f){try{r.apply(f,{ot:L.CMCDObjectType.MANIFEST,su:!r.initialized})}catch(l){B.logger.warn("Could not generate manifest CMCD data.",l)}},this.applyFragmentData=function(f){try{var l=f.frag,h=r.hls.levels[l.level],m=r.getObjectType(l),c={d:l.duration*1e3,ot:m};(m===L.CMCDObjectType.VIDEO||m===L.CMCDObjectType.AUDIO||m==L.CMCDObjectType.MUXED)&&(c.br=h.bitrate/1e3,c.tb=r.getTopBandwidth(m),c.bl=r.getBufferLength(m)),r.apply(f,c)}catch(u){B.logger.warn("Could not generate segment CMCD data.",u)}},this.hls=d;var i=this.config=d.config,o=i.cmcd;o!=null&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=o.sessionId||b.uuid(),this.cid=o.contentId,this.useHeaders=o.useHeaders===!0,this.registerListeners())}var y=b.prototype;return y.registerListeners=function(){var r=this.hls;r.on(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(U.Events.MEDIA_DETACHED,this.onMediaDetached,this),r.on(U.Events.BUFFER_CREATED,this.onBufferCreated,this)},y.unregisterListeners=function(){var r=this.hls;r.off(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(U.Events.MEDIA_DETACHED,this.onMediaDetached,this),r.off(U.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},y.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},y.onMediaAttached=function(r,i){this.media=i.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},y.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},y.onBufferCreated=function(r,i){var o,f;this.audioBuffer=(o=i.tracks.audio)===null||o===void 0?void 0:o.buffer,this.videoBuffer=(f=i.tracks.video)===null||f===void 0?void 0:f.buffer},y.createData=function(){var r;return{v:L.CMCDVersion,sf:L.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(r=this.media)===null||r===void 0?void 0:r.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},y.apply=function(r,i){i===void 0&&(i={}),C(i,this.createData());var o=i.ot===L.CMCDObjectType.INIT||i.ot===L.CMCDObjectType.VIDEO||i.ot===L.CMCDObjectType.MUXED;if(this.starved&&o&&(i.bs=!0,i.su=!0,this.starved=!1),i.su==null&&(i.su=this.buffering),this.useHeaders){var f=b.toHeaders(i);if(!Object.keys(f).length)return;r.headers||(r.headers={}),C(r.headers,f)}else{var l=b.toQuery(i);if(!l)return;r.url=b.appendQueryToUri(r.url,l)}},y.getObjectType=function(r){var i=r.type;return i==="subtitle"?L.CMCDObjectType.TIMED_TEXT:r.sn==="initSegment"?L.CMCDObjectType.INIT:i==="audio"?L.CMCDObjectType.AUDIO:i==="main"?this.hls.audioTracks.length?L.CMCDObjectType.VIDEO:L.CMCDObjectType.MUXED:void 0},y.getTopBandwidth=function(r){for(var i=0,o=r===L.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,f=w(o),l;!(l=f()).done;){var h=l.value;h.bitrate>i&&(i=h.bitrate)}return i>0?i:NaN},y.getBufferLength=function(r){var i=this.hls.media,o=r===L.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!o||!i)return NaN;var f=_.BufferHelper.bufferInfo(o,i.currentTime,this.config.maxBufferHole);return f.len*1e3},y.createPlaylistLoader=function(){var r=this.config.pLoader,i=this.applyPlaylistData,o=r||this.config.loader;return function(){function f(h){this.loader=void 0,this.loader=new o(h)}var l=f.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(m,c,u){i(m),this.loader.load(m,c,u)},k(f,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),f}()},y.createFragmentLoader=function(){var r=this.config.fLoader,i=this.applyFragmentData,o=r||this.config.loader;return function(){function f(h){this.loader=void 0,this.loader=new o(h)}var l=f.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(m,c,u){i(m),this.loader.load(m,c,u)},k(f,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),f}()},b.uuid=function(){var r=URL.createObjectURL(new Blob),i=r.toString();return URL.revokeObjectURL(r),i.substr(i.lastIndexOf("/")+1)},b.serialize=function(r){for(var i=[],o=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},f=function(I){return Math.round(I)},l=function(I){return f(I/100)*100},h=function(I){return encodeURIComponent(I)},m={br:f,d:f,bl:l,dl:l,mtp:l,nor:h,rtp:l,tb:f},c=Object.keys(r||{}).sort(),u=w(c),e;!(e=u()).done;){var n=e.value,a=r[n];if(!o(a))continue;if(n==="v"&&a===1)continue;if(n=="pr"&&a===1)continue;var p=m[n];p&&(a=p(a));var g=typeof a,T=void 0;n==="ot"||n==="sf"||n==="st"?T=n+"="+a:g==="boolean"?T=n:g==="number"?T=n+"="+a:T=n+"="+JSON.stringify(a),i.push(T)}return i.join(",")},b.toHeaders=function(r){for(var i=Object.keys(r),o={},f=["Object","Request","Session","Status"],l=[{},{},{},{}],h={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},m=0,c=i;m<c.length;m++){var u=c[m],e=h[u]!=null?h[u]:1;l[e][u]=r[u]}for(var n=0;n<l.length;n++){var a=b.serialize(l[n]);a&&(o["CMCD-"+f[n]]=a)}return o},b.toQuery=function(r){return"CMCD="+encodeURIComponent(b.serialize(r))},b.appendQueryToUri=function(r,i){if(!i)return r;var o=r.includes("?")?"&":"?";return""+r+o+i},b}()},"./src/controller/eme-controller.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/events.ts"),L=S("./src/errors.ts"),_=S("./src/utils/logger.ts"),B=S("./src/utils/mediakeys-helper.ts");function O(E,b){for(var y=0;y<b.length;y++){var d=b[y];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(E,d.key,d)}}function k(E,b,y){return b&&O(E.prototype,b),y&&O(E,y),E}var w=3,v=function(b,y,d){var r={audioCapabilities:[],videoCapabilities:[]};return b.forEach(function(i){r.audioCapabilities.push({contentType:'audio/mp4; codecs="'+i+'"',robustness:d.audioRobustness||""})}),y.forEach(function(i){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+i+'"',robustness:d.videoRobustness||""})}),[r]},x=function(b,y,d,r){switch(b){case B.KeySystems.WIDEVINE:return v(y,d,r);default:throw new Error("Unknown key-system: "+b)}},C=function(){function E(y){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=y,this._config=y.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var b=E.prototype;return b.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},b._registerListeners=function(){this.hls.on(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(U.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(U.Events.MANIFEST_PARSED,this.onManifestParsed,this)},b._unregisterListeners=function(){this.hls.off(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(U.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(U.Events.MANIFEST_PARSED,this.onManifestParsed,this)},b.getLicenseServerUrl=function(d){switch(d){case B.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+d+'"')},b._attemptKeySystemAccess=function(d,r,i){var o=this,f=x(d,r,i,this._drmSystemOptions);_.logger.log("Requesting encrypted media key-system access");var l=this.requestMediaKeySystemAccess(d,f);this.mediaKeysPromise=l.then(function(h){return o._onMediaKeySystemAccessObtained(d,h)}),l.catch(function(h){_.logger.error('Failed to obtain key-system "'+d+'" access:',h)})},b._onMediaKeySystemAccessObtained=function(d,r){var i=this;_.logger.log('Access for key-system "'+d+'" obtained');var o={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:r,mediaKeySystemDomain:d};this._mediaKeysList.push(o);var f=Promise.resolve().then(function(){return r.createMediaKeys()}).then(function(l){return o.mediaKeys=l,_.logger.log('Media-keys created for key-system "'+d+'"'),i._onMediaKeysCreated(),l});return f.catch(function(l){_.logger.error("Failed to create media-keys:",l)}),f},b._onMediaKeysCreated=function(){var d=this;this._mediaKeysList.forEach(function(r){r.mediaKeysSession||(r.mediaKeysSession=r.mediaKeys.createSession(),d._onNewMediaKeySession(r.mediaKeysSession))})},b._onNewMediaKeySession=function(d){var r=this;_.logger.log("New key-system session "+d.sessionId),d.addEventListener("message",function(i){r._onKeySessionMessage(d,i.message)},!1)},b._onKeySessionMessage=function(d,r){_.logger.log("Got EME message event, creating license request"),this._requestLicense(r,function(i){_.logger.log("Received license data (length: "+(i&&i.byteLength)+"), updating key-session"),d.update(i)})},b.onMediaEncrypted=function(d){var r=this;if(_.logger.log('Media is encrypted using "'+d.initDataType+'" init data type'),!this.mediaKeysPromise){_.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var i=function(f){if(!r._media)return;r._attemptSetMediaKeys(f),r._generateRequestWithPreferredKeySession(d.initDataType,d.initData)};this.mediaKeysPromise.then(i).catch(i)},b._attemptSetMediaKeys=function(d){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var r=this._mediaKeysList[0];if(!r||!r.mediaKeys){_.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}_.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(r.mediaKeys),this._hasSetMediaKeys=!0}},b._generateRequestWithPreferredKeySession=function(d,r){var i=this,o=this._mediaKeysList[0];if(!o){_.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(o.mediaKeysSessionInitialized){_.logger.warn("Key-Session already initialized but requested again");return}var f=o.mediaKeysSession;if(!f){_.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!r){_.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}_.logger.log('Generating key-session request for "'+d+'" init data type'),o.mediaKeysSessionInitialized=!0,f.generateRequest(d,r).then(function(){_.logger.debug("Key-session generation succeeded")}).catch(function(l){_.logger.error("Error generating key-session request:",l),i.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},b._createLicenseXhr=function(d,r,i){var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,o,d,r,i);var f=this._licenseXhrSetup;if(f)try{f.call(this.hls,o,d),f=void 0}catch(l){_.logger.error(l)}try{o.readyState||o.open("POST",d,!0),f&&f.call(this.hls,o,d)}catch(l){throw new Error("issue setting up KeySystem license XHR "+l)}return o},b._onLicenseRequestReadyStageChange=function(d,r,i,o){switch(d.readyState){case 4:if(d.status===200){this._requestLicenseFailureCount=0,_.logger.log("License request succeeded");var f=d.response,l=this._licenseResponseCallback;if(l)try{f=l.call(this.hls,d,r)}catch(m){_.logger.error(m)}o(f)}else{if(_.logger.error("License Request XHR failed ("+r+"). Status: "+d.status+" ("+d.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>w){this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var h=w-this._requestLicenseFailureCount+1;_.logger.warn("Retrying license request, "+h+" attempts left"),this._requestLicense(i,o)}break}},b._generateLicenseRequestChallenge=function(d,r){switch(d.mediaKeySystemDomain){case B.KeySystems.WIDEVINE:return r}throw new Error("unsupported key-system: "+d.mediaKeySystemDomain)},b._requestLicense=function(d,r){_.logger.log("Requesting content license for key-system");var i=this._mediaKeysList[0];if(!i){_.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var o=this.getLicenseServerUrl(i.mediaKeySystemDomain),f=this._createLicenseXhr(o,d,r);_.logger.log("Sending license request to URL: "+o);var l=this._generateLicenseRequestChallenge(i,d);f.send(l)}catch(h){_.logger.error("Failure requesting DRM license: "+h),this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},b.onMediaAttached=function(d,r){if(!this._emeEnabled)return;var i=r.media;this._media=i,i.addEventListener("encrypted",this._onMediaEncrypted)},b.onMediaDetached=function(){var d=this._media,r=this._mediaKeysList;if(!d)return;d.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(r.map(function(i){if(i.mediaKeysSession)return i.mediaKeysSession.close().catch(function(){})})).then(function(){return d.setMediaKeys(null)}).catch(function(){})},b.onManifestParsed=function(d,r){if(!this._emeEnabled)return;var i=r.levels.map(function(f){return f.audioCodec}).filter(function(f){return!!f}),o=r.levels.map(function(f){return f.videoCodec}).filter(function(f){return!!f});this._attemptKeySystemAccess(B.KeySystems.WIDEVINE,i,o)},k(E,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),E}();N.default=C},"./src/controller/fps-controller.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/events.ts"),L=S("./src/utils/logger.ts"),_=function(){function B(k){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=k,this.registerListeners()}var O=B.prototype;return O.setStreamController=function(w){this.streamController=w},O.registerListeners=function(){this.hls.on(U.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},O.unregisterListeners=function(){this.hls.off(U.Events.MEDIA_ATTACHING,this.onMediaAttaching)},O.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},O.onMediaAttaching=function(w,v){var x=this.hls.config;if(x.capLevelOnFPSDrop){var C=v.media instanceof self.HTMLVideoElement?v.media:null;this.media=C,C&&typeof C.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),x.fpsDroppedMonitoringPeriod)}},O.checkFPS=function(w,v,x){var C=performance.now();if(v){if(this.lastTime){var E=C-this.lastTime,b=x-this.lastDroppedFrames,y=v-this.lastDecodedFrames,d=1e3*b/E,r=this.hls;if(r.trigger(U.Events.FPS_DROP,{currentDropped:b,currentDecoded:y,totalDroppedFrames:x}),d>0&&b>r.config.fpsDroppedMonitoringThreshold*y){var i=r.currentLevel;L.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+i),i>0&&(r.autoLevelCapping===-1||r.autoLevelCapping>=i)&&(i=i-1,r.trigger(U.Events.FPS_DROP_LEVEL_CAPPING,{level:i,droppedLevel:r.currentLevel}),r.autoLevelCapping=i,this.streamController.nextLevelSwitch())}}this.lastTime=C,this.lastDroppedFrames=x,this.lastDecodedFrames=v}},O.checkFPSInterval=function(){var w=this.media;if(w)if(this.isVideoPlaybackQualityAvailable){var v=w.getVideoPlaybackQuality();this.checkFPS(w,v.totalVideoFrames,v.droppedVideoFrames)}else this.checkFPS(w,w.webkitDecodedFrameCount,w.webkitDroppedFrameCount)},B}();N.default=_},"./src/controller/fragment-finders.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"findFragmentByPDT",function(){return _}),S.d(N,"findFragmentByPTS",function(){return B}),S.d(N,"fragmentWithinToleranceTest",function(){return O}),S.d(N,"pdtWithinToleranceTest",function(){return k}),S.d(N,"findFragWithCC",function(){return w});var U=S("./src/polyfills/number.ts"),L=S("./src/utils/binary-search.ts");function _(v,x,C){if(x===null||!Array.isArray(v)||!v.length||!Object(U.isFiniteNumber)(x))return null;var E=v[0].programDateTime;if(x<(E||0))return null;var b=v[v.length-1].endProgramDateTime;if(x>=(b||0))return null;C=C||0;for(var y=0;y<v.length;++y){var d=v[y];if(k(x,C,d))return d}return null}function B(v,x,C,E){C===void 0&&(C=0),E===void 0&&(E=0);var b=null;if(v?b=x[v.sn-x[0].sn+1]||null:C===0&&x[0].start===0&&(b=x[0]),b&&O(C,E,b)===0)return b;var y=L.default.search(x,O.bind(null,C,E));return y||b}function O(v,x,C){v===void 0&&(v=0),x===void 0&&(x=0);var E=Math.min(x,C.duration+(C.deltaPTS?C.deltaPTS:0));return C.start+C.duration-E<=v?1:C.start-E>v&&C.start?-1:0}function k(v,x,C){var E=Math.min(x,C.duration+(C.deltaPTS?C.deltaPTS:0))*1e3,b=C.endProgramDateTime||0;return b-E>v}function w(v,x){return L.default.search(v,function(C){return C.cc<x?1:C.cc>x?-1:0})}},"./src/controller/fragment-tracker.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"FragmentState",function(){return _}),S.d(N,"FragmentTracker",function(){return B});var U=S("./src/events.ts"),L=S("./src/types/loader.ts"),_;(function(w){w.NOT_LOADED="NOT_LOADED",w.BACKTRACKED="BACKTRACKED",w.APPENDING="APPENDING",w.PARTIAL="PARTIAL",w.OK="OK"})(_||(_={}));var B=function(){function w(x){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=x,this._registerListeners()}var v=w.prototype;return v._registerListeners=function(){var C=this.hls;C.on(U.Events.BUFFER_APPENDED,this.onBufferAppended,this),C.on(U.Events.FRAG_BUFFERED,this.onFragBuffered,this),C.on(U.Events.FRAG_LOADED,this.onFragLoaded,this)},v._unregisterListeners=function(){var C=this.hls;C.off(U.Events.BUFFER_APPENDED,this.onBufferAppended,this),C.off(U.Events.FRAG_BUFFERED,this.onFragBuffered,this),C.off(U.Events.FRAG_LOADED,this.onFragLoaded,this)},v.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},v.getAppendedFrag=function(C,E){if(E===L.PlaylistLevelType.MAIN){var b=this.activeFragment,y=this.activeParts;if(!b)return null;if(y)for(var d=y.length;d--;){var r=y[d],i=r?r.end:b.appendedPTS;if(r.start<=C&&i!==void 0&&C<=i)return d>9&&(this.activeParts=y.slice(d-9)),r}else if(b.start<=C&&b.appendedPTS!==void 0&&C<=b.appendedPTS)return b}return this.getBufferedFrag(C,E)},v.getBufferedFrag=function(C,E){for(var b=this.fragments,y=Object.keys(b),d=y.length;d--;){var r=b[y[d]];if((r==null?void 0:r.body.type)===E&&r.buffered){var i=r.body;if(i.start<=C&&C<=i.end)return i}}return null},v.detectEvictedFragments=function(C,E,b){var y=this;Object.keys(this.fragments).forEach(function(d){var r=y.fragments[d];if(!r)return;if(!r.buffered){r.body.type===b&&y.removeFragment(r.body);return}var i=r.range[C];if(!i)return;i.time.some(function(o){var f=!y.isTimeBuffered(o.startPTS,o.endPTS,E);return f&&y.removeFragment(r.body),f})})},v.detectPartialFragments=function(C){var E=this,b=this.timeRanges,y=C.frag,d=C.part;if(!b||y.sn==="initSegment")return;var r=k(y),i=this.fragments[r];if(!i)return;Object.keys(b).forEach(function(o){var f=y.elementaryStreams[o];if(!f)return;var l=b[o],h=d!==null||f.partial===!0;i.range[o]=E.getBufferedTimes(y,d,h,l)}),i.backtrack=i.loaded=null,Object.keys(i.range).length?i.buffered=!0:this.removeFragment(i.body)},v.fragBuffered=function(C){var E=k(C),b=this.fragments[E];b&&(b.backtrack=b.loaded=null,b.buffered=!0)},v.getBufferedTimes=function(C,E,b,y){for(var d={time:[],partial:b},r=E?E.start:C.start,i=E?E.end:C.end,o=C.minEndPTS||i,f=C.maxStartPTS||r,l=0;l<y.length;l++){var h=y.start(l)-this.bufferPadding,m=y.end(l)+this.bufferPadding;if(f>=h&&o<=m){d.time.push({startPTS:Math.max(r,y.start(l)),endPTS:Math.min(i,y.end(l))});break}else if(r<m&&i>h)d.partial=!0,d.time.push({startPTS:Math.max(r,y.start(l)),endPTS:Math.min(i,y.end(l))});else if(i<=h)break}return d},v.getPartialFragment=function(C){var E=null,b,y,d,r=0,i=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach(function(f){var l=o[f];if(!l)return;O(l)&&(y=l.body.start-i,d=l.body.end+i,C>=y&&C<=d&&(b=Math.min(C-y,d-C),r<=b&&(E=l.body,r=b)))}),E},v.getState=function(C){var E=k(C),b=this.fragments[E];return b?b.buffered?O(b)?_.PARTIAL:_.OK:b.backtrack?_.BACKTRACKED:_.APPENDING:_.NOT_LOADED},v.backtrack=function(C,E){var b=k(C),y=this.fragments[b];if(!y||y.backtrack)return null;var d=y.backtrack=E||y.loaded;return y.loaded=null,d},v.getBacktrackData=function(C){var E=k(C),b=this.fragments[E];if(b){var y,d=b.backtrack;if(d!=null&&(y=d.payload)!==null&&y!==void 0&&y.byteLength)return d;this.removeFragment(C)}return null},v.isTimeBuffered=function(C,E,b){for(var y,d,r=0;r<b.length;r++){if(y=b.start(r)-this.bufferPadding,d=b.end(r)+this.bufferPadding,C>=y&&E<=d)return!0;if(E<=y)return!1}return!1},v.onFragLoaded=function(C,E){var b=E.frag,y=E.part;if(b.sn==="initSegment"||b.bitrateTest||y)return;var d=k(b);this.fragments[d]={body:b,loaded:E,backtrack:null,buffered:!1,range:Object.create(null)}},v.onBufferAppended=function(C,E){var b=this,y=E.frag,d=E.part,r=E.timeRanges;if(y.type===L.PlaylistLevelType.MAIN)if(this.activeFragment=y,d){var i=this.activeParts;i||(this.activeParts=i=[]),i.push(d)}else this.activeParts=null;this.timeRanges=r,Object.keys(r).forEach(function(o){var f=r[o];if(b.detectEvictedFragments(o,f),!d)for(var l=0;l<f.length;l++)y.appendedPTS=Math.max(f.end(l),y.appendedPTS||0)})},v.onFragBuffered=function(C,E){this.detectPartialFragments(E)},v.hasFragment=function(C){var E=k(C);return!!this.fragments[E]},v.removeFragmentsInRange=function(C,E,b){var y=this;Object.keys(this.fragments).forEach(function(d){var r=y.fragments[d];if(!r)return;if(r.buffered){var i=r.body;i.type===b&&i.start<E&&i.end>C&&y.removeFragment(i)}})},v.removeFragment=function(C){var E=k(C);C.stats.loaded=0,C.clearElementaryStreamInfo(),delete this.fragments[E]},v.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},w}();function O(w){var v,x;return w.buffered&&(((v=w.range.video)===null||v===void 0?void 0:v.partial)||((x=w.range.audio)===null||x===void 0?void 0:x.partial))}function k(w){return w.type+"_"+w.level+"_"+w.urlId+"_"+w.sn}},"./src/controller/gap-controller.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"STALL_MINIMUM_DURATION_MS",function(){return O}),S.d(N,"MAX_START_GAP_JUMP",function(){return k}),S.d(N,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return w}),S.d(N,"SKIP_BUFFER_RANGE_START",function(){return v}),S.d(N,"default",function(){return x});var U=S("./src/utils/buffer-helper.ts"),L=S("./src/errors.ts"),_=S("./src/events.ts"),B=S("./src/utils/logger.ts"),O=250,k=2,w=.1,v=.05,x=function(){function C(b,y,d,r){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=b,this.media=y,this.fragmentTracker=d,this.hls=r}var E=C.prototype;return E.destroy=function(){this.hls=this.fragmentTracker=this.media=null},E.poll=function(y){var d=this.config,r=this.media,i=this.stalled,o=r.currentTime,f=r.seeking,l=this.seeking&&!f,h=!this.seeking&&f;if(this.seeking=f,o!==y){if(this.moved=!0,i!==null){if(this.stallReported){var m=self.performance.now()-i;B.logger.warn("playback not stuck anymore @"+o+", after "+Math.round(m)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((h||l)&&(this.stalled=null),r.paused||r.ended||r.playbackRate===0||!U.BufferHelper.getBuffered(r).length)return;var c=U.BufferHelper.bufferInfo(r,o,0),u=c.len>0,e=c.nextStart||0;if(!u&&!e)return;if(f){var n=c.len>k,a=!e||e-o>k&&!this.fragmentTracker.getPartialFragment(o);if(n||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var p,g=Math.max(e,c.start||0)-o,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=T==null||((p=T.details)===null||p===void 0)?void 0:p.live,I=P?T.details.targetduration*2:k;if(g>0&&g<=I){this._trySkipBufferHole(null);return}}var F=self.performance.now();if(i===null){this.stalled=F;return}var W=F-i;!f&&W>=O&&this._reportStall(c.len);var z=U.BufferHelper.bufferInfo(r,o,d.maxBufferHole);this._tryFixBufferStall(z,W)},E._tryFixBufferStall=function(y,d){var r=this.config,i=this.fragmentTracker,o=this.media,f=o.currentTime,l=i.getPartialFragment(f);if(l){var h=this._trySkipBufferHole(l);if(h)return}y.len>r.maxBufferHole&&d>r.highBufferWatchdogPeriod*1e3&&(B.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},E._reportStall=function(y){var d=this.hls,r=this.media,i=this.stallReported;i||(this.stallReported=!0,B.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+y+")"),d.trigger(_.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y}))},E._trySkipBufferHole=function(y){for(var d=this.config,r=this.hls,i=this.media,o=i.currentTime,f=0,l=U.BufferHelper.getBuffered(i),h=0;h<l.length;h++){var m=l.start(h);if(o+d.maxBufferHole>=f&&o<m){var c=Math.max(m+v,i.currentTime+w);return B.logger.warn("skipping hole, adjusting currentTime from "+o+" to "+c),this.moved=!0,this.stalled=null,i.currentTime=c,y&&r.trigger(_.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+o+" to "+c,frag:y}),c}f=l.end(h)}return 0},E._tryNudgeBuffer=function(){var y=this.config,d=this.hls,r=this.media,i=r.currentTime,o=(this.nudgeRetry||0)+1;if(this.nudgeRetry=o,o<y.nudgeMaxRetry){var f=i+o*y.nudgeOffset;B.logger.warn("Nudging 'currentTime' from "+i+" to "+f),r.currentTime=f,d.trigger(_.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else B.logger.error("Playhead still not moving while enough data buffered @"+i+" after "+y.nudgeMaxRetry+" nudges"),d.trigger(_.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},C}()},"./src/controller/id3-track-controller.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/events.ts"),L=S("./src/utils/texttrack-utils.ts"),_=S("./src/demux/id3.ts"),B=.25,O=function(){function k(v){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=v,this._registerListeners()}var w=k.prototype;return w.destroy=function(){this._unregisterListeners()},w._registerListeners=function(){var x=this.hls;x.on(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),x.on(U.Events.MEDIA_DETACHING,this.onMediaDetaching,this),x.on(U.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),x.on(U.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},w._unregisterListeners=function(){var x=this.hls;x.off(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),x.off(U.Events.MEDIA_DETACHING,this.onMediaDetaching,this),x.off(U.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),x.off(U.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},w.onMediaAttached=function(x,C){this.media=C.media},w.onMediaDetaching=function(){if(!this.id3Track)return;Object(L.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},w.getID3Track=function(x){if(!this.media)return;for(var C=0;C<x.length;C++){var E=x[C];if(E.kind==="metadata"&&E.label==="id3")return Object(L.sendAddTrackEvent)(E,this.media),E}return this.media.addTextTrack("metadata","id3")},w.onFragParsingMetadata=function(x,C){if(!this.media)return;var E=C.frag,b=C.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var y=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,d=0;d<b.length;d++){var r=_.getID3Frames(b[d].data);if(r){var i=b[d].pts,o=d<b.length-1?b[d+1].pts:E.end,f=o-i;f<=0&&(o=i+B);for(var l=0;l<r.length;l++){var h=r[l];if(!_.isTimeStampFrame(h)){var m=new y(i,o,"");m.value=h,this.id3Track.addCue(m)}}}}},w.onBufferFlushing=function(x,C){var E=C.startOffset,b=C.endOffset,y=C.type;if(!y||y==="audio"){var d=this.id3Track;d&&Object(L.removeCuesInRange)(d,E,b)}},k}();N.default=O},"./src/controller/latency-controller.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return k});var U=S("./src/errors.ts"),L=S("./src/events.ts"),_=S("./src/utils/logger.ts");function B(w,v){for(var x=0;x<v.length;x++){var C=v[x];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(w,C.key,C)}}function O(w,v,x){return v&&B(w.prototype,v),x&&B(w,x),w}var k=function(){function w(x){var C=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return C.timeupdate()},this.hls=x,this.config=x.config,this.registerListeners()}var v=w.prototype;return v.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},v.registerListeners=function(){this.hls.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(L.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){this.hls.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(L.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(L.Events.ERROR,this.onError)},v.onMediaAttached=function(C,E){this.media=E.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},v.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},v.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},v.onLevelUpdated=function(C,E){var b=E.details;this.levelDetails=b,b.advanced&&this.timeupdate(),!b.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},v.onError=function(C,E){if(E.details!==U.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,_.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},v.timeupdate=function(){var C=this.media,E=this.levelDetails;if(!C||!E)return;this.currentTime=C.currentTime;var b=this.computeLatency();if(b===null)return;this._latency=b;var y=this.config,d=y.lowLatencyMode,r=y.maxLiveSyncPlaybackRate;if(!d||r===1)return;var i=this.targetLatency;if(i===null)return;var o=b-i,f=Math.min(this.maxLatency,i+E.targetduration),l=o<f;if(E.live&&l&&o>.05&&this.forwardBufferLength>1){var h=Math.min(2,Math.max(1,r)),m=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;C.playbackRate=Math.min(h,Math.max(1,m))}else C.playbackRate!==1&&C.playbackRate!==0&&(C.playbackRate=1)},v.estimateLiveEdge=function(){var C=this.levelDetails;return C===null?null:C.edge+C.age},v.computeLatency=function(){var C=this.estimateLiveEdge();return C===null?null:C-this.currentTime},O(w,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var C=this.config,E=this.levelDetails;return C.liveMaxLatencyDuration!==void 0?C.liveMaxLatencyDuration:E?C.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var C=this.levelDetails;if(C===null)return null;var E=C.holdBack,b=C.partHoldBack,y=C.targetduration,d=this.config,r=d.liveSyncDuration,i=d.liveSyncDurationCount,o=d.lowLatencyMode,f=this.hls.userConfig,l=o&&b||E;(f.liveSyncDuration||f.liveSyncDurationCount||l===0)&&(l=r!==void 0?r:i*y);var h=y,m=1;return l+Math.min(this.stallCount*m,h)}},{key:"liveSyncPosition",get:function(){var C=this.estimateLiveEdge(),E=this.targetLatency,b=this.levelDetails;if(C===null||E===null||b===null)return null;var y=b.edge,d=C-E-this.edgeStalled,r=y-b.totalduration,i=y-(this.config.lowLatencyMode&&b.partTarget||b.targetduration);return Math.min(Math.max(r,d),i)}},{key:"drift",get:function(){var C=this.levelDetails;return C===null?1:C.drift}},{key:"edgeStalled",get:function(){var C=this.levelDetails;if(C===null)return 0;var E=(this.config.lowLatencyMode&&C.partTarget||C.targetduration)*3;return Math.max(C.age-E,0)}},{key:"forwardBufferLength",get:function(){var C=this.media,E=this.levelDetails;if(!C||!E)return 0;var b=C.buffered.length;return b?C.buffered.end(b-1):E.edge-this.currentTime}}]),w}()},"./src/controller/level-controller.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return d});var U=S("./src/types/level.ts"),L=S("./src/events.ts"),_=S("./src/errors.ts"),B=S("./src/utils/codecs.ts"),O=S("./src/controller/level-helper.ts"),k=S("./src/controller/base-playlist-controller.ts"),w=S("./src/types/loader.ts");function v(){return v=Object.assign||function(r){for(var i=1;i<arguments.length;i++){var o=arguments[i];for(var f in o)Object.prototype.hasOwnProperty.call(o,f)&&(r[f]=o[f])}return r},v.apply(this,arguments)}function x(r,i){for(var o=0;o<i.length;o++){var f=i[o];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(r,f.key,f)}}function C(r,i,o){return i&&x(r.prototype,i),o&&x(r,o),r}function E(r,i){r.prototype=Object.create(i.prototype),r.prototype.constructor=r,b(r,i)}function b(r,i){return b=Object.setPrototypeOf||function(f,l){return f.__proto__=l,f},b(r,i)}var y=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(r){E(i,r);function i(f){var l;return l=r.call(this,f,"[level-controller]")||this,l._levels=[],l._firstLevel=-1,l._startLevel=void 0,l.currentLevelIndex=-1,l.manualLevelIndex=-1,l.onParsedComplete=void 0,l._registerListeners(),l}var o=i.prototype;return o._registerListeners=function(){var l=this.hls;l.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),l.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(L.Events.ERROR,this.onError,this)},o._unregisterListeners=function(){var l=this.hls;l.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),l.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),l.off(L.Events.ERROR,this.onError,this)},o.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,r.prototype.destroy.call(this)},o.startLoad=function(){var l=this._levels;l.forEach(function(h){h.loadError=0}),r.prototype.startLoad.call(this)},o.onManifestLoaded=function(l,h){var m=[],c=[],u=[],e,n={},a,p=!1,g=!1,T=!1;if(h.levels.forEach(function(W){var z=W.attrs;p=p||!!(W.width&&W.height),g=g||!!W.videoCodec,T=T||!!W.audioCodec,y&&W.audioCodec&&W.audioCodec.indexOf("mp4a.40.34")!==-1&&(W.audioCodec=void 0);var X=W.bitrate+"-"+W.attrs.RESOLUTION+"-"+W.attrs.CODECS;a=n[X],a?a.url.push(W.url):(a=new U.Level(W),n[X]=a,m.push(a)),z&&(z.AUDIO&&Object(O.addGroupId)(a,"audio",z.AUDIO),z.SUBTITLES&&Object(O.addGroupId)(a,"text",z.SUBTITLES))}),(p||g)&&T&&(m=m.filter(function(W){var z=W.videoCodec,X=W.width,K=W.height;return!!z||!!(X&&K)})),m=m.filter(function(W){var z=W.audioCodec,X=W.videoCodec;return(!z||Object(B.isCodecSupportedInMp4)(z,"audio"))&&(!X||Object(B.isCodecSupportedInMp4)(X,"video"))}),h.audioTracks&&(c=h.audioTracks.filter(function(W){return!W.audioCodec||Object(B.isCodecSupportedInMp4)(W.audioCodec,"audio")}),Object(O.assignTrackIdsByGroup)(c)),h.subtitles&&(u=h.subtitles,Object(O.assignTrackIdsByGroup)(u)),m.length>0){e=m[0].bitrate,m.sort(function(W,z){return W.bitrate-z.bitrate}),this._levels=m;for(var P=0;P<m.length;P++)if(m[P].bitrate===e){this._firstLevel=P,this.log("manifest loaded, "+m.length+" level(s) found, first bitrate: "+e);break}var I=T&&!g,F={levels:m,audioTracks:c,subtitleTracks:u,firstLevel:this._firstLevel,stats:h.stats,audio:T,video:g,altAudio:!I&&c.some(function(W){return!!W.url})};this.hls.trigger(L.Events.MANIFEST_PARSED,F),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:h.url,reason:"no level with compatible codecs found in manifest"})},o.onError=function(l,h){if(r.prototype.onError.call(this,l,h),h.fatal)return;var m=h.context,c=this._levels[this.currentLevelIndex];if(m&&(m.type===w.PlaylistContextType.AUDIO_TRACK&&c.audioGroupIds&&m.groupId===c.audioGroupIds[c.urlId]||m.type===w.PlaylistContextType.SUBTITLE_TRACK&&c.textGroupIds&&m.groupId===c.textGroupIds[c.urlId])){this.redundantFailover(this.currentLevelIndex);return}var u=!1,e=!0,n;switch(h.details){case _.ErrorDetails.FRAG_LOAD_ERROR:case _.ErrorDetails.FRAG_LOAD_TIMEOUT:case _.ErrorDetails.KEY_LOAD_ERROR:case _.ErrorDetails.KEY_LOAD_TIMEOUT:if(h.frag){var a=this._levels[h.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(n=h.frag.level)):n=h.frag.level}break;case _.ErrorDetails.LEVEL_LOAD_ERROR:case _.ErrorDetails.LEVEL_LOAD_TIMEOUT:m&&(m.deliveryDirectives&&(e=!1),n=m.level),u=!0;break;case _.ErrorDetails.REMUX_ALLOC_ERROR:n=h.level,u=!0;break}n!==void 0&&this.recoverLevel(h,n,u,e)},o.recoverLevel=function(l,h,m,c){var u=l.details,e=this._levels[h];if(e.loadError++,m){var n=this.retryLoadingOrFail(l);if(n)l.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var a=e.url.length;if(a>1&&e.loadError<a)l.levelRetry=!0,this.redundantFailover(h);else if(this.manualLevelIndex===-1){var p=h===0?this._levels.length-1:h-1;this.currentLevelIndex!==p&&this._levels[p].loadError===0&&(this.warn(u+": switch to "+p),l.levelRetry=!0,this.hls.nextAutoLevel=p)}}},o.redundantFailover=function(l){var h=this._levels[l],m=h.url.length;if(m>1){var c=(h.urlId+1)%m;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(u){u.urlId=c}),this.level=l}},o.onFragLoaded=function(l,h){var m=h.frag;if(m!==void 0&&m.type===w.PlaylistLevelType.MAIN){var c=this._levels[m.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},o.onLevelLoaded=function(l,h){var m,c=h.level,u=h.details,e=this._levels[c];if(!e){var n;this.warn("Invalid level index "+c),(n=h.deliveryDirectives)!==null&&n!==void 0&&n.skip&&(u.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(e.fragmentError===0&&(e.loadError=0,this.retryCount=0),this.playlistLoaded(c,h,e.details)):(m=h.deliveryDirectives)!==null&&m!==void 0&&m.skip&&(u.deltaUpdateFailed=!0)},o.onAudioTrackSwitched=function(l,h){var m=this.hls.levels[this.currentLevelIndex];if(!m)return;if(m.audioGroupIds){for(var c=-1,u=this.hls.audioTracks[h.id].groupId,e=0;e<m.audioGroupIds.length;e++)if(m.audioGroupIds[e]===u){c=e;break}c!==m.urlId&&(m.urlId=c,this.startLoad())}},o.loadPlaylist=function(l){var h=this.currentLevelIndex,m=this._levels[h];if(this.canLoad&&m&&m.url.length>0){var c=m.urlId,u=m.url[c];if(l)try{u=l.addDirectives(u)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Attempt loading level index "+h+(l?" at sn "+l.msn+" part "+l.part:"")+" with URL-id "+c+" "+u),this.clearTimer(),this.hls.trigger(L.Events.LEVEL_LOADING,{url:u,level:h,id:c,deliveryDirectives:l||null})}},o.removeLevel=function(l,h){var m=function(e,n){return n!==h},c=this._levels.filter(function(u,e){return e!==l?!0:u.url.length>1&&h!==void 0?(u.url=u.url.filter(m),u.audioGroupIds&&(u.audioGroupIds=u.audioGroupIds.filter(m)),u.textGroupIds&&(u.textGroupIds=u.textGroupIds.filter(m)),u.urlId=0,!0):!1}).map(function(u,e){var n=u.details;return n!=null&&n.fragments&&n.fragments.forEach(function(a){a.level=e}),u});this._levels=c,this.hls.trigger(L.Events.LEVELS_UPDATED,{levels:c})},C(i,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(l){var h,m=this._levels;if(m.length===0)return;if(this.currentLevelIndex===l&&(h=m[l])!==null&&h!==void 0&&h.details)return;if(l<0||l>=m.length){var c=l<0;if(this.hls.trigger(L.Events.ERROR,{type:_.ErrorTypes.OTHER_ERROR,details:_.ErrorDetails.LEVEL_SWITCH_ERROR,level:l,fatal:c,reason:"invalid level idx"}),c)return;l=Math.min(l,m.length-1)}this.clearTimer();var u=this.currentLevelIndex,e=m[u],n=m[l];this.log("switching to level "+l+" from "+u),this.currentLevelIndex=l;var a=v({},n,{level:l,maxBitrate:n.maxBitrate,uri:n.uri,urlId:n.urlId});delete a._urlId,this.hls.trigger(L.Events.LEVEL_SWITCHING,a);var p=n.details;if(!p||p.live){var g=this.switchParams(n.uri,e==null?void 0:e.details);this.loadPlaylist(g)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(l){this.manualLevelIndex=l,this._startLevel===void 0&&(this._startLevel=l),l!==-1&&(this.level=l)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(l){this._firstLevel=l}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var l=this.hls.config.startLevel;return l!==void 0?l:this._firstLevel}else return this._startLevel},set:function(l){this._startLevel=l}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(l){this.level=l,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=l)}}]),i}(k.default)},"./src/controller/level-helper.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"addGroupId",function(){return _}),S.d(N,"assignTrackIdsByGroup",function(){return B}),S.d(N,"updatePTS",function(){return O}),S.d(N,"updateFragPTSDTS",function(){return w}),S.d(N,"mergeDetails",function(){return v}),S.d(N,"mapPartIntersection",function(){return x}),S.d(N,"mapFragmentIntersection",function(){return C}),S.d(N,"adjustSliding",function(){return E}),S.d(N,"addSliding",function(){return b}),S.d(N,"computeReloadInterval",function(){return y}),S.d(N,"getFragmentWithSN",function(){return d}),S.d(N,"getPartWith",function(){return r});var U=S("./src/polyfills/number.ts"),L=S("./src/utils/logger.ts");function _(i,o,f){switch(o){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(f);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(f);break}}function B(i){var o={};i.forEach(function(f){var l=f.groupId||"";f.id=o[l]=o[l]||0,o[l]++})}function O(i,o,f){var l=i[o],h=i[f];k(l,h)}function k(i,o){var f=o.startPTS;if(Object(U.isFiniteNumber)(f)){var l=0,h;o.sn>i.sn?(l=f-i.start,h=i):(l=i.start-f,h=o),h.duration!==l&&(h.duration=l)}else if(o.sn>i.sn){var m=i.cc===o.cc;m&&i.minEndPTS?o.start=i.start+(i.minEndPTS-i.start):o.start=i.start+i.duration}else o.start=Math.max(i.start-o.duration,0)}function w(i,o,f,l,h,m){var c=l-f;c<=0&&(L.logger.warn("Fragment should have a positive duration",o),l=f+o.duration,m=h+o.duration);var u=f,e=l,n=o.startPTS,a=o.endPTS;if(Object(U.isFiniteNumber)(n)){var p=Math.abs(n-f);Object(U.isFiniteNumber)(o.deltaPTS)?o.deltaPTS=Math.max(p,o.deltaPTS):o.deltaPTS=p,u=Math.max(f,n),f=Math.min(f,n),h=Math.min(h,o.startDTS),e=Math.min(l,a),l=Math.max(l,a),m=Math.max(m,o.endDTS)}o.duration=l-f;var g=f-o.start;o.appendedPTS=l,o.start=o.startPTS=f,o.maxStartPTS=u,o.startDTS=h,o.endPTS=l,o.minEndPTS=e,o.endDTS=m;var T=o.sn;if(!i||T<i.startSN||T>i.endSN)return 0;var P,I=T-i.startSN,F=i.fragments;for(F[I]=o,P=I;P>0;P--)k(F[P],F[P-1]);for(P=I;P<F.length-1;P++)k(F[P],F[P+1]);return i.fragmentHint&&k(F[F.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,g}function v(i,o){for(var f=null,l=i.fragments,h=l.length-1;h>=0;h--){var m=l[h].initSegment;if(m){f=m;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var c=0,u;if(C(i,o,function(P,I){P.relurl&&(c=P.cc-I.cc),Object(U.isFiniteNumber)(P.startPTS)&&Object(U.isFiniteNumber)(P.endPTS)&&(I.start=I.startPTS=P.startPTS,I.startDTS=P.startDTS,I.appendedPTS=P.appendedPTS,I.maxStartPTS=P.maxStartPTS,I.endPTS=P.endPTS,I.endDTS=P.endDTS,I.minEndPTS=P.minEndPTS,I.duration=P.endPTS-P.startPTS,I.duration&&(u=I),o.PTSKnown=o.alignedSliding=!0),I.elementaryStreams=P.elementaryStreams,I.loader=P.loader,I.stats=P.stats,I.urlId=P.urlId,P.initSegment&&(I.initSegment=P.initSegment,f=P.initSegment)}),f){var e=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments;e.forEach(function(P){var I;(!P.initSegment||P.initSegment.relurl===((I=f)===null||I===void 0?void 0:I.relurl))&&(P.initSegment=f)})}if(o.skippedSegments&&(o.deltaUpdateFailed=o.fragments.some(function(P){return!P}),o.deltaUpdateFailed)){L.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var n=o.skippedSegments;n--;)o.fragments.shift();o.startSN=o.fragments[0].sn,o.startCC=o.fragments[0].cc}var a=o.fragments;if(c){L.logger.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<a.length;p++)a[p].cc+=c}o.skippedSegments&&(o.startCC=o.fragments[0].cc),x(i.partList,o.partList,function(P,I){I.elementaryStreams=P.elementaryStreams,I.stats=P.stats}),u?w(o,u,u.startPTS,u.endPTS,u.startDTS,u.endDTS):E(i,o),a.length&&(o.totalduration=o.edge-a[0].start),o.driftStartTime=i.driftStartTime,o.driftStart=i.driftStart;var g=o.advancedDateTime;if(o.advanced&&g){var T=o.edge;o.driftStart||(o.driftStartTime=g,o.driftStart=T),o.driftEndTime=g,o.driftEnd=T}else o.driftEndTime=i.driftEndTime,o.driftEnd=i.driftEnd,o.advancedDateTime=i.advancedDateTime}function x(i,o,f){if(i&&o)for(var l=0,h=0,m=i.length;h<=m;h++){var c=i[h],u=o[h+l];c&&u&&c.index===u.index&&c.fragment.sn===u.fragment.sn?f(c,u):l--}}function C(i,o,f){for(var l=o.skippedSegments,h=Math.max(i.startSN,o.startSN)-o.startSN,m=(i.fragmentHint?1:0)+(l?o.endSN:Math.min(i.endSN,o.endSN))-o.startSN,c=o.startSN-i.startSN,u=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments,e=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,n=h;n<=m;n++){var a=e[c+n],p=u[n];l&&!p&&n<l&&(p=o.fragments[n]=a),a&&p&&f(a,p)}}function E(i,o){var f=o.startSN+o.skippedSegments-i.startSN,l=i.fragments;if(f<0||f>=l.length)return;b(o,l[f].start)}function b(i,o){if(o){for(var f=i.fragments,l=i.skippedSegments;l<f.length;l++)f[l].start+=o;i.fragmentHint&&(i.fragmentHint.start+=o)}}function y(i,o){var f=1e3*i.levelTargetDuration,l=f/2,h=i.age,m=h>0&&h<f*3,c=o.loading.end-o.loading.start,u,e=i.availabilityDelay;if(i.updated===!1)if(m){var n=333*i.misses;u=Math.max(Math.min(l,c*2),n),i.availabilityDelay=(i.availabilityDelay||0)+u}else u=l;else m?(e=Math.min(e||f/2,h),i.availabilityDelay=e,u=e+f-h):u=f-c;return Math.round(u)}function d(i,o,f){if(!i||!i.details)return null;var l=i.details,h=l.fragments[o-l.startSN];return h||(h=l.fragmentHint,h&&h.sn===o?h:o<l.startSN&&f&&f.sn===o?f:null)}function r(i,o,f){if(!i||!i.details)return null;var l=i.details.partList;if(l)for(var h=l.length;h--;){var m=l[h];if(m.index===f&&m.fragment.sn===o)return m}return null}},"./src/controller/stream-controller.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return l});var U=S("./src/polyfills/number.ts"),L=S("./src/controller/base-stream-controller.ts"),_=S("./src/is-supported.ts"),B=S("./src/events.ts"),O=S("./src/utils/buffer-helper.ts"),k=S("./src/controller/fragment-tracker.ts"),w=S("./src/types/loader.ts"),v=S("./src/loader/fragment.ts"),x=S("./src/demux/transmuxer-interface.ts"),C=S("./src/types/transmuxer.ts"),E=S("./src/controller/gap-controller.ts"),b=S("./src/errors.ts"),y=S("./src/utils/logger.ts");function d(h,m){for(var c=0;c<m.length;c++){var u=m[c];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(h,u.key,u)}}function r(h,m,c){return m&&d(h.prototype,m),c&&d(h,c),h}function i(h,m){h.prototype=Object.create(m.prototype),h.prototype.constructor=h,o(h,m)}function o(h,m){return o=Object.setPrototypeOf||function(u,e){return u.__proto__=e,u},o(h,m)}var f=100,l=function(h){i(m,h);function m(u,e){var n;return n=h.call(this,u,e,"[stream-controller]")||this,n.audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.stalled=!1,n.couldBacktrack=!1,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}var c=m.prototype;return c._registerListeners=function(){var e=this.hls;e.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(B.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(B.Events.ERROR,this.onError,this),e.on(B.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(B.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(B.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(B.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(B.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var e=this.hls;e.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(B.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(B.Events.ERROR,this.onError,this),e.off(B.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(B.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(B.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(B.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(B.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},c.startLoad=function(e){if(this.levels){var n=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(f),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var p=a.startLevel;p===-1&&(a.config.testBandwidth?(p=0,this.bitrateTest=!0):p=a.nextAutoLevel),this.level=a.nextLoadLevel=p,this.loadedmetadata=!1}n>0&&e===-1&&(this.log("Override startPosition with lastCurrentTime @"+n.toFixed(3)),e=n),this.state=L.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=L.State.STOPPED},c.stopLoad=function(){this._forceStartLoad=!1,h.prototype.stopLoad.call(this)},c.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_LEVEL:{var e,n=this.levels,a=this.level,p=n==null||((e=n[a])===null||e===void 0)?void 0:e.details;if(p&&(!p.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(p))break;this.state=L.State.IDLE;break}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var g,T=self.performance.now(),P=this.retryDate;(!P||T>=P||(g=this.media)!==null&&g!==void 0&&g.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=L.State.IDLE)}break;default:break}this.onTickEnd()},c.onTickEnd=function(){h.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},c.doTickIdle=function(){var e,n,a=this.hls,p=this.levelLastLoaded,g=this.levels,T=this.media,P=a.config,I=a.nextLoadLevel;if(p===null||!T&&(this.startFragRequested||!P.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!g||!g[I])return;var F=g[I];this.level=a.nextLoadLevel=I;var W=F.details;if(!W||this.state===L.State.WAITING_LEVEL||W.live&&this.levelLastLoaded!==I){this.state=L.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:T,w.PlaylistLevelType.MAIN);if(z===null)return;var X=z.len,K=this.getMaxBufferLength(F.maxBitrate);if(X>=K)return;if(this._streamEnded(z,W)){var J={};this.altAudio&&(J.type="video"),this.hls.trigger(B.Events.BUFFER_EOS,J),this.state=L.State.ENDED;return}var ne=z.end,re=this.getNextFragment(ne,W);if(this.couldBacktrack&&!this.fragPrevious&&re&&re.sn!=="initSegment"){var be=re.sn-W.startSN;be>1&&(re=W.fragments[be-1],this.fragmentTracker.removeFragment(re))}if(re&&this.fragmentTracker.getState(re)===k.FragmentState.OK&&this.nextLoadPosition>ne){var oe=this.audioOnly&&!this.altAudio?v.ElementaryStreamTypes.AUDIO:v.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(T,oe,w.PlaylistLevelType.MAIN),re=this.getNextFragment(this.nextLoadPosition,W)}if(!re)return;re.initSegment&&!re.initSegment.data&&!this.bitrateTest&&(re=re.initSegment),((e=re.decryptdata)===null||e===void 0?void 0:e.keyFormat)==="identity"&&!((n=re.decryptdata)!==null&&n!==void 0&&n.key)?this.loadKey(re,W):this.loadFragment(re,W,ne)},c.loadFragment=function(e,n,a){var p,g=this.fragmentTracker.getState(e);if(this.fragCurrent=e,g===k.FragmentState.BACKTRACKED){var T=this.fragmentTracker.getBacktrackData(e);if(T){this._handleFragmentLoadProgress(T),this._handleFragmentLoadComplete(T);return}else g=k.FragmentState.NOT_LOADED}g===k.FragmentState.NOT_LOADED||g===k.FragmentState.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e):this.bitrateTest?(e.bitrateTest=!0,this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e)):(this.startFragRequested=!0,h.prototype.loadFragment.call(this,e,n,a)):g===k.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):((p=this.media)===null||p===void 0?void 0:p.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},c.getAppendedFrag=function(e){var n=this.fragmentTracker.getAppendedFrag(e,w.PlaylistLevelType.MAIN);return n&&"fragment"in n?n.fragment:n},c.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,w.PlaylistLevelType.MAIN)},c.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},c.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},c.nextLevelSwitch=function(){var e=this.levels,n=this.media;if(n!=null&&n.readyState){var a,p=this.getAppendedFrag(n.currentTime);if(p&&p.start>1&&this.flushMainBuffer(0,p.start-1),!n.paused&&e){var g=this.hls.nextLoadLevel,T=e[g],P=this.fragLastKbps;P&&this.fragCurrent?a=this.fragCurrent.duration*T.maxBitrate/(1e3*P)+1:a=0}else a=0;var I=this.getBufferedFrag(n.currentTime+a);if(I){var F=this.followingBufferedFrag(I);if(F){this.abortCurrentFrag();var W=F.maxStartPTS?F.maxStartPTS:F.start,z=F.duration,X=Math.max(I.end,W+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(X,Number.POSITIVE_INFINITY)}}}},c.abortCurrentFrag=function(){var e=this.fragCurrent;this.fragCurrent=null,e!=null&&e.loader&&e.loader.abort(),this.state===L.State.KEY_LOADING&&(this.state=L.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},c.flushMainBuffer=function(e,n){h.prototype.flushMainBuffer.call(this,e,n,this.altAudio?"video":null)},c.onMediaAttached=function(e,n){h.prototype.onMediaAttached.call(this,e,n);var a=n.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,a,this.fragmentTracker,this.hls)},c.onMediaDetaching=function(){var e=this.media;e&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),h.prototype.onMediaDetaching.call(this)},c.onMediaPlaying=function(){this.tick()},c.onMediaSeeked=function(){var e=this.media,n=e?e.currentTime:null;Object(U.isFiniteNumber)(n)&&this.log("Media seeked to "+n.toFixed(3)),this.tick()},c.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(B.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},c.onManifestParsed=function(e,n){var a=!1,p=!1,g;n.levels.forEach(function(T){g=T.audioCodec,g&&(g.indexOf("mp4a.40.2")!==-1&&(a=!0),g.indexOf("mp4a.40.5")!==-1&&(p=!0))}),this.audioCodecSwitch=a&&p&&!Object(_.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=n.levels,this.startFragRequested=!1},c.onLevelLoading=function(e,n){var a=this.levels;if(!a||this.state!==L.State.IDLE)return;var p=a[n.level];(!p.details||p.details.live&&this.levelLastLoaded!==n.level||this.waitForCdnTuneIn(p.details))&&(this.state=L.State.WAITING_LEVEL)},c.onLevelLoaded=function(e,n){var a,p=this.levels,g=n.level,T=n.details,P=T.totalduration;if(!p){this.warn("Levels were reset while loading level "+g);return}this.log("Level "+g+" loaded ["+T.startSN+","+T.endSN+"], cc ["+T.startCC+", "+T.endCC+"] duration:"+P);var I=this.fragCurrent;I&&(this.state===L.State.FRAG_LOADING||this.state===L.State.FRAG_LOADING_WAITING_RETRY)&&(I.level!==n.level&&I.loader&&(this.state=L.State.IDLE,I.loader.abort()));var F=p[g],W=0;if(T.live||(a=F.details)!==null&&a!==void 0&&a.live){if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed)return;W=this.alignPlaylists(T,F.details)}if(F.details=T,this.levelLastLoaded=g,this.hls.trigger(B.Events.LEVEL_UPDATED,{details:T,level:g}),this.state===L.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(T))return;this.state=L.State.IDLE}this.startFragRequested?T.live&&this.synchronizeToLiveEdge(T):this.setStartPosition(T,W),this.tick()},c._handleFragmentLoadProgress=function(e){var n,a=e.frag,p=e.part,g=e.payload,T=this.levels;if(!T){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var P=T[a.level],I=P.details;if(!I){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var F=P.videoCodec,W=I.PTSKnown||!I.live,z=(n=a.initSegment)===null||n===void 0?void 0:n.data,X=this._getAudioCodec(P),K=this.transmuxer=this.transmuxer||new x.default(this.hls,w.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),J=p?p.index:-1,ne=J!==-1,re=new C.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,g.byteLength,J,ne),be=this.initPTS[a.cc];K.push(g,z,X,F,a,p,I.totalduration,W,re,be)},c.onAudioTrackSwitching=function(e,n){var a=this.altAudio,p=!!n.url,g=n.id;if(!p){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var T=this.fragCurrent;T!=null&&T.loader&&(this.log("Switching to main audio track, cancel main fragment load"),T.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var P=this.hls;a&&P.trigger(B.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(B.Events.AUDIO_TRACK_SWITCHED,{id:g})}},c.onAudioTrackSwitched=function(e,n){var a=n.id,p=!!this.hls.audioTracks[a].url;if(p){var g=this.videoBuffer;g&&this.mediaBuffer!==g&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=g)}this.altAudio=p,this.tick()},c.onBufferCreated=function(e,n){var a=n.tracks,p,g,T=!1;for(var P in a){var I=a[P];if(I.id==="main"){if(g=P,p=I,P==="video"){var F=a[P];F&&(this.videoBuffer=F.buffer)}}else T=!0}T&&p?(this.log("Alternate track found, use "+g+".buffered to schedule main fragment loading"),this.mediaBuffer=p.buffer):this.mediaBuffer=this.media},c.onFragBuffered=function(e,n){var a=n.frag,p=n.part;if(a&&a.type!==w.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(p?" p: "+p.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===L.State.PARSED&&(this.state=L.State.IDLE);return}var g=p?p.stats:a.stats;this.fragLastKbps=Math.round(8*g.total/(g.buffering.end-g.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,p)},c.onError=function(e,n){switch(n.details){case b.ErrorDetails.FRAG_LOAD_ERROR:case b.ErrorDetails.FRAG_LOAD_TIMEOUT:case b.ErrorDetails.KEY_LOAD_ERROR:case b.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(w.PlaylistLevelType.MAIN,n);break;case b.ErrorDetails.LEVEL_LOAD_ERROR:case b.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==L.State.ERROR&&(n.fatal?(this.warn(""+n.details),this.state=L.State.ERROR):!n.levelRetry&&this.state===L.State.WAITING_LEVEL&&(this.state=L.State.IDLE));break;case b.ErrorDetails.BUFFER_FULL_ERROR:if(n.parent==="main"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var a=!0,p=this.getFwdBufferInfo(this.media,w.PlaylistLevelType.MAIN);p&&p.len>.5&&(a=!this.reduceMaxBufferLength(p.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},c.checkBuffer=function(){var e=this.media,n=this.gapController;if(!e||!n||!e.readyState)return;var a=O.BufferHelper.getBuffered(e);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):n.poll(this.lastCurrentTime),this.lastCurrentTime=e.currentTime},c.onFragLoadEmergencyAborted=function(){this.state=L.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},c.onBufferFlushed=function(e,n){var a=n.type;if(a!==v.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var p=(a===v.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(p,a,w.PlaylistLevelType.MAIN)}},c.onLevelsUpdated=function(e,n){this.levels=n.levels},c.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},c.seekToStartPos=function(){var e=this.media,n=e.currentTime,a=this.startPosition;if(a>=0&&n<a){if(e.seeking){y.logger.log("could not seek to "+a+", already seeking at "+n);return}var p=O.BufferHelper.getBuffered(e),g=p.length?p.start(0):0,T=g-a;T>0&&(T<this.config.maxBufferHole||T<this.config.maxFragLookUpTolerance)&&(y.logger.log("adjusting start position by "+T+" to match buffer start"),a+=T,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+n),e.currentTime=a}},c._getAudioCodec=function(e){var n=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&n&&(this.log("Swapping audio codec"),n.indexOf("mp4a.40.5")!==-1?n="mp4a.40.2":n="mp4a.40.5"),n},c._loadBitrateTestFrag=function(e){var n=this;this._doFragLoad(e).then(function(a){var p=n.hls;if(!a||p.nextLoadLevel||n.fragContextChanged(e))return;n.fragLoadError=0,n.state=L.State.IDLE,n.startFragRequested=!1,n.bitrateTest=!1;var g=e.stats;g.parsing.start=g.parsing.end=g.buffering.start=g.buffering.end=self.performance.now(),p.trigger(B.Events.FRAG_LOADED,a)})},c._handleTransmuxComplete=function(e){var n,a="main",p=this.hls,g=e.remuxResult,T=e.chunkMeta,P=this.getCurrentContext(T);if(!P){this.warn("The loading context changed while buffering fragment "+T.sn+" of level "+T.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(T.level);return}var I=P.frag,F=P.part,W=P.level,z=g.video,X=g.text,K=g.id3,J=g.initSegment,ne=this.altAudio?void 0:g.audio;if(this.fragContextChanged(I))return;if(this.state=L.State.PARSING,J){J.tracks&&(this._bufferInitSegment(W,J.tracks,I,T),p.trigger(B.Events.FRAG_PARSING_INIT_SEGMENT,{frag:I,id:a,tracks:J.tracks}));var re=J.initPTS,be=J.timescale;Object(U.isFiniteNumber)(re)&&(this.initPTS[I.cc]=re,p.trigger(B.Events.INIT_PTS_FOUND,{frag:I,id:a,initPTS:re,timescale:be}))}if(z&&g.independent!==!1){if(W.details){var oe=z.startPTS,ue=z.endPTS,de=z.startDTS,ce=z.endDTS;if(F)F.elementaryStreams[z.type]={startPTS:oe,endPTS:ue,startDTS:de,endDTS:ce};else if(z.firstKeyFrame&&z.independent&&(this.couldBacktrack=!0),z.dropped&&z.independent){var te=this.getLoadPosition()+this.config.maxBufferHole;if(te<oe){this.backtrack(I);return}I.setElementaryStreamInfo(z.type,I.start,ue,I.start,ce,!0)}I.setElementaryStreamInfo(z.type,oe,ue,de,ce),this.bufferFragmentData(z,I,F,T)}}else if(g.independent===!1){this.backtrack(I);return}if(ne){var $=ne.startPTS,Ae=ne.endPTS,Fe=ne.startDTS,De=ne.endDTS;F&&(F.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:$,endPTS:Ae,startDTS:Fe,endDTS:De}),I.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,$,Ae,Fe,De),this.bufferFragmentData(ne,I,F,T)}if(K!=null&&(n=K.samples)!==null&&n!==void 0&&n.length){var Ue={frag:I,id:a,samples:K.samples};p.trigger(B.Events.FRAG_PARSING_METADATA,Ue)}if(X){var Re={frag:I,id:a,samples:X.samples};p.trigger(B.Events.FRAG_PARSING_USERDATA,Re)}},c._bufferInitSegment=function(e,n,a,p){var g=this;if(this.state!==L.State.PARSING)return;this.audioOnly=!!n.audio&&!n.video,this.altAudio&&!this.audioOnly&&delete n.audio;var T=n.audio,P=n.video,I=n.audiovideo;if(T){var F=e.audioCodec,W=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(F&&(F.indexOf("mp4a.40.5")!==-1?F="mp4a.40.2":F="mp4a.40.5"),T.metadata.channelCount!==1&&W.indexOf("firefox")===-1&&(F="mp4a.40.5")),W.indexOf("android")!==-1&&T.container!=="audio/mpeg"&&(F="mp4a.40.2",this.log("Android: force audio codec to "+F)),e.audioCodec&&e.audioCodec!==F&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+F+'"'),T.levelCodec=F,T.id="main",this.log("Init audio buffer, container:"+T.container+", codecs[selected/level/parsed]=["+(F||"")+"/"+(e.audioCodec||"")+"/"+T.codec+"]")}P&&(P.levelCodec=e.videoCodec,P.id="main",this.log("Init video buffer, container:"+P.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+P.codec+"]")),I&&this.log("Init audiovideo buffer, container:"+I.container+", codecs[level/parsed]=["+(e.attrs.CODECS||"")+"/"+I.codec+"]"),this.hls.trigger(B.Events.BUFFER_CODECS,n),Object.keys(n).forEach(function(z){var X=n[z],K=X.initSegment;K!=null&&K.byteLength&&g.hls.trigger(B.Events.BUFFER_APPENDING,{type:z,data:K,frag:a,part:null,chunkMeta:p,parent:a.type})}),this.tick()},c.backtrack=function(e){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(e);var n=this.fragmentTracker.backtrack(e);this.fragPrevious=null,this.nextLoadPosition=e.start,n?this.resetFragmentLoading(e):this.state=L.State.BACKTRACKING},c.checkFragmentChanged=function(){var e=this.media,n=null;if(e&&e.readyState>1&&e.seeking===!1){var a=e.currentTime;if(O.BufferHelper.isBuffered(e,a)?n=this.getAppendedFrag(a):O.BufferHelper.isBuffered(e,a+.1)&&(n=this.getAppendedFrag(a+.1)),n){var p=this.fragPlaying,g=n.level;(!p||n.sn!==p.sn||p.level!==g||n.urlId!==p.urlId)&&(this.hls.trigger(B.Events.FRAG_CHANGED,{frag:n}),(!p||p.level!==g)&&this.hls.trigger(B.Events.LEVEL_SWITCHED,{level:g}),this.fragPlaying=n)}}},r(m,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentLevel",get:function(){var e=this.media;if(e){var n=this.getAppendedFrag(e.currentTime);if(n)return n.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;if(e){var n=this.getAppendedFrag(e.currentTime);return this.followingBufferedFrag(n)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),m}(L.default)},"./src/controller/subtitle-stream-controller.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"SubtitleStreamController",function(){return i});var U=S("./src/events.ts"),L=S("./src/utils/logger.ts"),_=S("./src/utils/buffer-helper.ts"),B=S("./src/controller/fragment-finders.ts"),O=S("./src/utils/discontinuities.ts"),k=S("./src/controller/level-helper.ts"),w=S("./src/controller/fragment-tracker.ts"),v=S("./src/controller/base-stream-controller.ts"),x=S("./src/types/loader.ts"),C=S("./src/types/level.ts");function E(o,f){for(var l=0;l<f.length;l++){var h=f[l];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(o,h.key,h)}}function b(o,f,l){return f&&E(o.prototype,f),l&&E(o,l),o}function y(o,f){o.prototype=Object.create(f.prototype),o.prototype.constructor=o,d(o,f)}function d(o,f){return d=Object.setPrototypeOf||function(h,m){return h.__proto__=m,h},d(o,f)}var r=500,i=function(o){y(f,o);function f(h,m){var c;return c=o.call(this,h,m,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var l=f.prototype;return l.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},l._registerListeners=function(){var m=this.hls;m.on(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),m.on(U.Events.MEDIA_DETACHING,this.onMediaDetaching,this),m.on(U.Events.MANIFEST_LOADING,this.onManifestLoading,this),m.on(U.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.on(U.Events.ERROR,this.onError,this),m.on(U.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),m.on(U.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),m.on(U.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),m.on(U.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),m.on(U.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},l._unregisterListeners=function(){var m=this.hls;m.off(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),m.off(U.Events.MEDIA_DETACHING,this.onMediaDetaching,this),m.off(U.Events.MANIFEST_LOADING,this.onManifestLoading,this),m.off(U.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.off(U.Events.ERROR,this.onError,this),m.off(U.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),m.off(U.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),m.off(U.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),m.off(U.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),m.off(U.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},l.startLoad=function(){this.stopLoad(),this.state=v.State.IDLE,this.setInterval(r),this.tick()},l.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},l.onLevelLoaded=function(m,c){this.mainDetails=c.details},l.onSubtitleFragProcessed=function(m,c){var u=c.frag,e=c.success;if(this.fragPrevious=u,this.state=v.State.IDLE,!e)return;var n=this.tracksBuffered[this.currentTrackId];if(!n)return;for(var a,p=u.start,g=0;g<n.length;g++)if(p>=n[g].start&&p<=n[g].end){a=n[g];break}var T=u.start+u.duration;a?a.end=T:(a={start:p,end:T},n.push(a)),this.fragmentTracker.fragBuffered(u)},l.onBufferFlushing=function(m,c){var u=c.startOffset,e=c.endOffset;if(u===0&&e!==Number.POSITIVE_INFINITY){var n=this.currentTrackId,a=this.levels;if(!a.length||!a[n]||!a[n].details)return;var p=a[n].details,g=p.targetduration,T=e-g;if(T<=0)return;c.endOffsetSubtitles=Math.max(0,T),this.tracksBuffered.forEach(function(P){for(var I=0;I<P.length;){if(P[I].end<=T){P.shift();continue}else if(P[I].start<T)P[I].start=T;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(u,T,x.PlaylistLevelType.SUBTITLE)}},l.onError=function(m,c){var u,e=c.frag;if(!e||e.type!==x.PlaylistLevelType.SUBTITLE)return;(u=this.fragCurrent)!==null&&u!==void 0&&u.loader&&this.fragCurrent.loader.abort(),this.state=v.State.IDLE},l.onSubtitleTracksUpdated=function(m,c){var u=this,e=c.subtitleTracks;this.tracksBuffered=[],this.levels=e.map(function(n){return new C.Level(n)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(n){u.tracksBuffered[n.id]=[]}),this.mediaBuffer=null},l.onSubtitleTrackSwitch=function(m,c){if(this.currentTrackId=c.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var u=this.levels[this.currentTrackId];u!=null&&u.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,u&&this.setInterval(r)},l.onSubtitleTrackLoaded=function(m,c){var u,e=c.details,n=c.id,a=this.currentTrackId,p=this.levels;if(!p.length)return;var g=p[a];if(n>=p.length||n!==a||!g)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,e.live||(u=g.details)!==null&&u!==void 0&&u.live){var T=this.mainDetails;if(e.deltaUpdateFailed||!T)return;var P=T.fragments[0];if(!g.details)e.hasProgramDateTime&&T.hasProgramDateTime?Object(O.alignMediaPlaylistByPDT)(e,T):P&&Object(k.addSliding)(e,P.start);else{var I=this.alignPlaylists(e,g.details);I===0&&P&&Object(k.addSliding)(e,P.start)}}if(g.details=e,this.levelLastLoaded=n,this.tick(),e.live&&!this.fragCurrent&&this.media&&this.state===v.State.IDLE){var F=Object(B.findFragmentByPTS)(null,e.fragments,this.media.currentTime,0);F||(this.warn("Subtitle playlist not aligned with playback"),g.details=void 0)}},l._handleFragmentLoadComplete=function(m){var c=m.frag,u=m.payload,e=c.decryptdata,n=this.hls;if(this.fragContextChanged(c))return;if(u&&u.byteLength>0&&e&&e.key&&e.iv&&e.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(u),e.key.buffer,e.iv.buffer).then(function(p){var g=performance.now();n.trigger(U.Events.FRAG_DECRYPTED,{frag:c,payload:p,stats:{tstart:a,tdecrypt:g}})})}},l.doTick=function(){if(!this.media){this.state=v.State.IDLE;return}if(this.state===v.State.IDLE){var m,c=this.currentTrackId,u=this.levels;if(!u.length||!u[c]||!u[c].details)return;var e=u[c].details,n=e.targetduration,a=this.config,p=this.media,g=_.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,p.currentTime-n,a.maxBufferHole),T=g.end,P=g.len,I=this.getMaxBufferLength()+n;if(P>I)return;console.assert(e,"Subtitle track details are defined on idle subtitle stream controller tick");var F=e.fragments,W=F.length,z=e.edge,X,K=this.fragPrevious;if(T<z){var J=a.maxFragLookUpTolerance;K&&e.hasProgramDateTime&&(X=Object(B.findFragmentByPDT)(F,K.endProgramDateTime,J)),X||(X=Object(B.findFragmentByPTS)(K,F,T,J),!X&&K&&K.start<F[0].start&&(X=F[0]))}else X=F[W-1];(m=X)!==null&&m!==void 0&&m.encrypted?(L.logger.log("Loading key for "+X.sn),this.state=v.State.KEY_LOADING,this.hls.trigger(U.Events.KEY_LOADING,{frag:X})):X&&this.fragmentTracker.getState(X)===w.FragmentState.NOT_LOADED&&this.loadFragment(X,e,T)}},l.loadFragment=function(m,c,u){this.fragCurrent=m,o.prototype.loadFragment.call(this,m,c,u)},b(f,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),f}(v.default)},"./src/controller/subtitle-track-controller.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/events.ts"),L=S("./src/utils/texttrack-utils.ts"),_=S("./src/controller/base-playlist-controller.ts"),B=S("./src/types/loader.ts");function O(E,b){for(var y=0;y<b.length;y++){var d=b[y];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(E,d.key,d)}}function k(E,b,y){return b&&O(E.prototype,b),y&&O(E,y),E}function w(E,b){E.prototype=Object.create(b.prototype),E.prototype.constructor=E,v(E,b)}function v(E,b){return v=Object.setPrototypeOf||function(d,r){return d.__proto__=r,d},v(E,b)}var x=function(E){w(b,E);function b(d){var r;return r=E.call(this,d,"[subtitle-track-controller]")||this,r.media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r.subtitleDisplay=!0,r.registerListeners(),r}var y=b.prototype;return y.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,E.prototype.destroy.call(this)},y.registerListeners=function(){var r=this.hls;r.on(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(U.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(U.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(U.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(U.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(U.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(U.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(U.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){var r=this.hls;r.off(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(U.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(U.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(U.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(U.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(U.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(U.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(U.Events.ERROR,this.onError,this)},y.onMediaAttached=function(r,i){if(this.media=i.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},y.pollTrackChange=function(r){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,r)},y.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var r=C(this.media.textTracks);r.forEach(function(i){Object(L.clearCurrentCues)(i)}),this.subtitleTrack=-1,this.media=null},y.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},y.onManifestParsed=function(r,i){this.tracks=i.subtitleTracks},y.onSubtitleTrackLoaded=function(r,i){var o=i.id,f=i.details,l=this.trackId,h=this.tracksInGroup[l];if(!h){this.warn("Invalid subtitle track id "+o);return}var m=h.details;h.details=i.details,this.log("subtitle track "+o+" loaded ["+f.startSN+"-"+f.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,i,m))},y.onLevelLoading=function(r,i){this.switchLevel(i.level)},y.onLevelSwitching=function(r,i){this.switchLevel(i.level)},y.switchLevel=function(r){var i=this.hls.levels[r];if(!(i!=null&&i.textGroupIds))return;var o=i.textGroupIds[i.urlId];if(this.groupId!==o){var f=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,l=this.tracks.filter(function(c){return!o||c.groupId===o});this.tracksInGroup=l;var h=this.findTrackId(f==null?void 0:f.name)||this.findTrackId();this.groupId=o;var m={subtitleTracks:l};this.log("Updating subtitle tracks, "+l.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(U.Events.SUBTITLE_TRACKS_UPDATED,m),h!==-1&&this.setSubtitleTrack(h,f)}},y.findTrackId=function(r){for(var i=this.tracksInGroup,o=0;o<i.length;o++){var f=i[o];if((!this.selectDefaultTrack||f.default)&&(!r||r===f.name))return f.id}return-1},y.onError=function(r,i){if(E.prototype.onError.call(this,r,i),i.fatal||!i.context)return;i.context.type===B.PlaylistContextType.SUBTITLE_TRACK&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&this.retryLoadingOrFail(i)},y.loadPlaylist=function(r){var i=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(i)){var o=i.id,f=i.groupId,l=i.url;if(r)try{l=r.addDirectives(l)}catch(h){this.warn("Could not construct new URL with HLS Delivery Directives: "+h)}this.log("Loading subtitle playlist for id "+o),this.hls.trigger(U.Events.SUBTITLE_TRACK_LOADING,{url:l,id:o,groupId:f,deliveryDirectives:r||null})}},y.toggleTrackModes=function(r){var i=this,o=this.media,f=this.subtitleDisplay,l=this.trackId;if(!o)return;var h=C(o.textTracks),m=h.filter(function(e){return e.groupId===i.groupId});if(r===-1)[].slice.call(h).forEach(function(e){e.mode="disabled"});else{var c=m[l];c&&(c.mode="disabled")}var u=m[r];u&&(u.mode=f?"showing":"hidden")},y.setSubtitleTrack=function(r,i){var o,f=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=r;return}if(this.trackId!==r&&this.toggleTrackModes(r),this.trackId===r&&(r===-1||(o=f[r])!==null&&o!==void 0&&o.details)||r<-1||r>=f.length)return;this.clearTimer();var l=f[r];if(this.log("Switching to subtitle track "+r),this.trackId=r,l){var h=l.id,m=l.groupId,c=m===void 0?"":m,u=l.name,e=l.type,n=l.url;this.hls.trigger(U.Events.SUBTITLE_TRACK_SWITCH,{id:h,groupId:c,name:u,type:e,url:n});var a=this.switchParams(l.url,i==null?void 0:i.details);this.loadPlaylist(a)}else this.hls.trigger(U.Events.SUBTITLE_TRACK_SWITCH,{id:r})},y.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var r=-1,i=C(this.media.textTracks),o=0;o<i.length;o++)if(i[o].mode==="hidden")r=o;else if(i[o].mode==="showing"){r=o;break}this.subtitleTrack!==r&&(this.subtitleTrack=r)},k(b,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1;var i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(r,i)}}]),b}(_.default);function C(E){for(var b=[],y=0;y<E.length;y++){var d=E[y];d.kind==="subtitles"&&d.label&&b.push(E[y])}return b}N.default=x},"./src/controller/timeline-controller.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"TimelineController",function(){return C});var U=S("./src/polyfills/number.ts"),L=S("./src/events.ts"),_=S("./src/utils/cea-608-parser.ts"),B=S("./src/utils/output-filter.ts"),O=S("./src/utils/webvtt-parser.ts"),k=S("./src/utils/texttrack-utils.ts"),w=S("./src/utils/imsc1-ttml-parser.ts"),v=S("./src/types/loader.ts"),x=S("./src/utils/logger.ts"),C=function(){function d(i){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=y(),this.captionsProperties=void 0,this.hls=i,this.config=i.config,this.Cues=i.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var o=new B.default(this,"textTrack1"),f=new B.default(this,"textTrack2"),l=new B.default(this,"textTrack3"),h=new B.default(this,"textTrack4");this.cea608Parser1=new _.default(1,o,f),this.cea608Parser2=new _.default(3,l,h)}i.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),i.on(L.Events.FRAG_LOADING,this.onFragLoading,this),i.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),i.on(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),i.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),i.on(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),i.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var r=d.prototype;return r.destroy=function(){var o=this.hls;o.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),o.off(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(L.Events.FRAG_LOADING,this.onFragLoading,this),o.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),o.off(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),o.off(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),o.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),o.off(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),o.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},r.addCues=function(o,f,l,h,m){for(var c=!1,u=m.length;u--;){var e=m[u],n=b(e[0],e[1],f,l);if(n>=0&&(e[0]=Math.min(e[0],f),e[1]=Math.max(e[1],l),c=!0,n/(l-f)>.5))return}if(c||m.push([f,l]),this.config.renderTextTracksNatively){var a=this.captionsTracks[o];this.Cues.newCue(a,f,l,h)}else{var p=this.Cues.newCue(null,f,l,h);this.hls.trigger(L.Events.CUES_PARSED,{type:"captions",cues:p,track:o})}},r.onInitPtsFound=function(o,f){var l=this,h=f.frag,m=f.id,c=f.initPTS,u=f.timescale,e=this.unparsedVttFrags;m==="main"&&(this.initPTS[h.cc]=c,this.timescale[h.cc]=u),e.length&&(this.unparsedVttFrags=[],e.forEach(function(n){l.onFragLoaded(L.Events.FRAG_LOADED,n)}))},r.getExistingTrack=function(o){var f=this.media;if(f)for(var l=0;l<f.textTracks.length;l++){var h=f.textTracks[l];if(h[o])return h}return null},r.createCaptionsTrack=function(o){this.config.renderTextTracksNatively?this.createNativeTrack(o):this.createNonNativeTrack(o)},r.createNativeTrack=function(o){if(this.captionsTracks[o])return;var f=this.captionsProperties,l=this.captionsTracks,h=this.media,m=f[o],c=m.label,u=m.languageCode,e=this.getExistingTrack(o);if(e)l[o]=e,Object(k.clearCurrentCues)(l[o]),Object(k.sendAddTrackEvent)(l[o],h);else{var n=this.createTextTrack("captions",c,u);n&&(n[o]=!0,l[o]=n)}},r.createNonNativeTrack=function(o){if(this.nonNativeCaptionsTracks[o])return;var f=this.captionsProperties[o];if(!f)return;var l=f.label,h={_id:o,label:l,kind:"captions",default:f.media?!!f.media.default:!1,closedCaptions:f.media};this.nonNativeCaptionsTracks[o]=h,this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[h]})},r.createTextTrack=function(o,f,l){var h=this.media;return h?h.addTextTrack(o,f,l):void 0},r.onMediaAttaching=function(o,f){this.media=f.media,this._cleanTracks()},r.onMediaDetaching=function(){var o=this.captionsTracks;Object.keys(o).forEach(function(f){Object(k.clearCurrentCues)(o[f]),delete o[f]}),this.nonNativeCaptionsTracks={}},r.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=y(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},r._cleanTracks=function(){var o=this.media;if(!o)return;var f=o.textTracks;if(f)for(var l=0;l<f.length;l++)Object(k.clearCurrentCues)(f[l])},r.onSubtitleTracksUpdated=function(o,f){var l=this;this.textTracks=[];var h=f.subtitleTracks||[],m=h.some(function(n){return n.textCodec===w.IMSC1_CODEC});if(this.config.enableWebVTT||m&&this.config.enableIMSC1){var c=this.tracks&&h&&this.tracks.length===h.length;if(this.tracks=h||[],this.config.renderTextTracksNatively){var u=this.media?this.media.textTracks:[];this.tracks.forEach(function(n,a){var p;if(a<u.length){for(var g=null,T=0;T<u.length;T++)if(E(u[T],n)){g=u[T];break}g&&(p=g)}p?Object(k.clearCurrentCues)(p):(p=l.createTextTrack("subtitles",n.name,n.lang),p&&(p.mode="disabled")),p&&(p.groupId=n.groupId,l.textTracks.push(p))})}else if(!c&&this.tracks&&this.tracks.length){var e=this.tracks.map(function(n){return{label:n.name,kind:n.type.toLowerCase(),default:n.default,subtitleTrack:n}});this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}},r.onManifestLoaded=function(o,f){var l=this;this.config.enableCEA708Captions&&f.captions&&f.captions.forEach(function(h){var m=/(?:CC|SERVICE)([1-4])/.exec(h.instreamId);if(!m)return;var c="textTrack"+m[1],u=l.captionsProperties[c];if(!u)return;u.label=h.name,h.lang&&(u.languageCode=h.lang),u.media=h})},r.onFragLoading=function(o,f){var l=this.cea608Parser1,h=this.cea608Parser2,m=this.lastSn,c=this.lastPartIndex;if(!this.enabled||!(l&&h))return;if(f.frag.type===v.PlaylistLevelType.MAIN){var u,e,n=f.frag.sn,a=(u=f==null||((e=f.part)===null||e===void 0)?void 0:e.index)!=null?u:-1;n===m+1||n===m&&a===c+1||(l.reset(),h.reset()),this.lastSn=n,this.lastPartIndex=a}},r.onFragLoaded=function(o,f){var l=f.frag,h=f.payload,m=this.initPTS,c=this.unparsedVttFrags;if(l.type===v.PlaylistLevelType.SUBTITLE)if(h.byteLength){if(!Object(U.isFiniteNumber)(m[l.cc])){c.push(f),m.length&&this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:l,error:new Error("Missing initial subtitle PTS")});return}var u=l.decryptdata;if(u==null||u.key==null||u.method!=="AES-128"){var e=this.tracks[l.level],n=this.vttCCs;n[l.cc]||(n[l.cc]={start:l.start,prevCC:this.prevCC,new:!0},this.prevCC=l.cc),e&&e.textCodec===w.IMSC1_CODEC?this._parseIMSC1(l,h):this._parseVTTs(l,h,n)}}else this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:l,error:new Error("Empty subtitle payload")})},r._parseIMSC1=function(o,f){var l=this,h=this.hls;Object(w.parseIMSC1)(f,this.initPTS[o.cc],this.timescale[o.cc],function(m){l._appendCues(m,o.level),h.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})},function(m){x.logger.log("Failed to parse IMSC1: "+m),h.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:m})})},r._parseVTTs=function(o,f,l){var h=this,m=this.hls;Object(O.parseWebVTT)(f,this.initPTS[o.cc],this.timescale[o.cc],l,o.cc,o.start,function(c){h._appendCues(c,o.level),m.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})},function(c){h._fallbackToIMSC1(o,f),x.logger.log("Failed to parse VTT cue: "+c),m.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:c})})},r._fallbackToIMSC1=function(o,f){var l=this,h=this.tracks[o.level];h.textCodec||Object(w.parseIMSC1)(f,this.initPTS[o.cc],this.timescale[o.cc],function(){h.textCodec=w.IMSC1_CODEC,l._parseIMSC1(o,f)},function(){h.textCodec="wvtt"})},r._appendCues=function(o,f){var l=this.hls;if(this.config.renderTextTracksNatively){var h=this.textTracks[f];if(h.mode==="disabled")return;o.forEach(function(u){return Object(k.addCueToTrack)(h,u)})}else{var m=this.tracks[f],c=m.default?"default":"subtitles"+f;l.trigger(L.Events.CUES_PARSED,{type:"subtitles",cues:o,track:c})}},r.onFragDecrypted=function(o,f){var l=f.frag;if(l.type===v.PlaylistLevelType.SUBTITLE){if(!Object(U.isFiniteNumber)(this.initPTS[l.cc])){this.unparsedVttFrags.push(f);return}this.onFragLoaded(L.Events.FRAG_LOADED,f)}},r.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},r.onFragParsingUserdata=function(o,f){var l=this.cea608Parser1,h=this.cea608Parser2;if(!this.enabled||!(l&&h))return;for(var m=0;m<f.samples.length;m++){var c=f.samples[m].bytes;if(c){var u=this.extractCea608Data(c);l.addData(f.samples[m].pts,u[0]),h.addData(f.samples[m].pts,u[1])}}},r.onBufferFlushing=function(o,f){var l=f.startOffset,h=f.endOffset,m=f.endOffsetSubtitles,c=f.type,u=this.media;if(!u||u.currentTime<h)return;if(!c||c==="video"){var e=this.captionsTracks;Object.keys(e).forEach(function(a){return Object(k.removeCuesInRange)(e[a],l,h)})}if(this.config.renderTextTracksNatively&&(l===0&&m!==void 0)){var n=this.textTracks;Object.keys(n).forEach(function(a){return Object(k.removeCuesInRange)(n[a],l,m)})}},r.extractCea608Data=function(o){for(var f=o[0]&31,l=2,h=[[],[]],m=0;m<f;m++){var c=o[l++],u=127&o[l++],e=127&o[l++],n=(4&c)!==0,a=3&c;if(u===0&&e===0)continue;n&&((a===0||a===1)&&(h[a].push(u),h[a].push(e)))}return h},d}();function E(d,r){return d&&d.label===r.name&&!(d.textTrack1||d.textTrack2)}function b(d,r,i,o){return Math.min(r,o)-Math.max(d,i)}function y(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return U});var U=function(){function L(B,O){this.subtle=void 0,this.aesIV=void 0,this.subtle=B,this.aesIV=O}var _=L.prototype;return _.decrypt=function(O,k){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},k,O)},L}()},"./src/crypt/aes-decryptor.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"removePadding",function(){return L}),S.d(N,"default",function(){return _});var U=S("./src/utils/typed-array.ts");function L(B){var O=B.byteLength,k=O&&new DataView(B.buffer).getUint8(O-1);return k?Object(U.sliceUint8)(B,0,O-k):B}var _=function(){function B(){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.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var O=B.prototype;return O.uint8ArrayToUint32Array_=function(w){for(var v=new DataView(w),x=new Uint32Array(4),C=0;C<4;C++)x[C]=v.getUint32(C*4);return x},O.initTable=function(){var w=this.sBox,v=this.invSBox,x=this.subMix,C=x[0],E=x[1],b=x[2],y=x[3],d=this.invSubMix,r=d[0],i=d[1],o=d[2],f=d[3],l=new Uint32Array(256),h=0,m=0,c=0;for(c=0;c<256;c++)c<128?l[c]=c<<1:l[c]=c<<1^283;for(c=0;c<256;c++){var u=m^m<<1^m<<2^m<<3^m<<4;u=u>>>8^u&255^99,w[h]=u,v[u]=h;var e=l[h],n=l[e],a=l[n],p=l[u]*257^u*16843008;C[h]=p<<24|p>>>8,E[h]=p<<16|p>>>16,b[h]=p<<8|p>>>24,y[h]=p,p=a*16843009^n*65537^e*257^h*16843008,r[u]=p<<24|p>>>8,i[u]=p<<16|p>>>16,o[u]=p<<8|p>>>24,f[u]=p,h?(h=e^l[l[l[a^e]]],m^=l[l[m]]):h=m=1}},O.expandKey=function(w){for(var v=this.uint8ArrayToUint32Array_(w),x=!0,C=0;C<v.length&&x;)x=v[C]===this.key[C],C++;if(x)return;this.key=v;var E=this.keySize=v.length;if(E!==4&&E!==6&&E!==8)throw new Error("Invalid aes key size="+E);var b=this.ksRows=(E+6+1)*4,y,d,r=this.keySchedule=new Uint32Array(b),i=this.invKeySchedule=new Uint32Array(b),o=this.sBox,f=this.rcon,l=this.invSubMix,h=l[0],m=l[1],c=l[2],u=l[3],e,n;for(y=0;y<b;y++){if(y<E){e=r[y]=v[y];continue}n=e,y%E===0?(n=n<<8|n>>>24,n=o[n>>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[n&255],n^=f[y/E|0]<<24):E>6&&y%E===4&&(n=o[n>>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[n&255]),r[y]=e=(r[y-E]^n)>>>0}for(d=0;d<b;d++)y=b-d,d&3?n=r[y]:n=r[y-4],d<4||y<=4?i[d]=n:i[d]=h[o[n>>>24]]^m[o[n>>>16&255]]^c[o[n>>>8&255]]^u[o[n&255]],i[d]=i[d]>>>0},O.networkToHostOrderSwap=function(w){return w<<24|(w&65280)<<8|(w&16711680)>>8|w>>>24},O.decrypt=function(w,v,x){for(var C=this.keySize+6,E=this.invKeySchedule,b=this.invSBox,y=this.invSubMix,d=y[0],r=y[1],i=y[2],o=y[3],f=this.uint8ArrayToUint32Array_(x),l=f[0],h=f[1],m=f[2],c=f[3],u=new Int32Array(w),e=new Int32Array(u.length),n,a,p,g,T,P,I,F,W,z,X,K,J,ne,re=this.networkToHostOrderSwap;v<u.length;){for(W=re(u[v]),z=re(u[v+1]),X=re(u[v+2]),K=re(u[v+3]),T=W^E[0],P=K^E[1],I=X^E[2],F=z^E[3],J=4,ne=1;ne<C;ne++)n=d[T>>>24]^r[P>>16&255]^i[I>>8&255]^o[F&255]^E[J],a=d[P>>>24]^r[I>>16&255]^i[F>>8&255]^o[T&255]^E[J+1],p=d[I>>>24]^r[F>>16&255]^i[T>>8&255]^o[P&255]^E[J+2],g=d[F>>>24]^r[T>>16&255]^i[P>>8&255]^o[I&255]^E[J+3],T=n,P=a,I=p,F=g,J=J+4;n=b[T>>>24]<<24^b[P>>16&255]<<16^b[I>>8&255]<<8^b[F&255]^E[J],a=b[P>>>24]<<24^b[I>>16&255]<<16^b[F>>8&255]<<8^b[T&255]^E[J+1],p=b[I>>>24]<<24^b[F>>16&255]<<16^b[T>>8&255]<<8^b[P&255]^E[J+2],g=b[F>>>24]<<24^b[T>>16&255]<<16^b[P>>8&255]<<8^b[I&255]^E[J+3],e[v]=re(n^l),e[v+1]=re(g^h),e[v+2]=re(p^m),e[v+3]=re(a^c),l=W,h=z,m=X,c=K,v=v+4}return e.buffer},B}()},"./src/crypt/decrypter.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return v});var U=S("./src/crypt/aes-crypto.ts"),L=S("./src/crypt/fast-aes-key.ts"),_=S("./src/crypt/aes-decryptor.ts"),B=S("./src/utils/logger.ts"),O=S("./src/utils/mp4-tools.ts"),k=S("./src/utils/typed-array.ts"),w=16,v=function(){function x(E,b,y){var d=y===void 0?{}:y,r=d.removePKCS7Padding,i=r===void 0?!0:r;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=E,this.config=b,this.removePKCS7Padding=i,i)try{var o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch(f){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var C=x.prototype;return C.destroy=function(){this.observer=null},C.isSync=function(){return this.config.enableSoftwareAES},C.flush=function(){var b=this.currentResult;if(!b){this.reset();return}var y=new Uint8Array(b);return this.reset(),this.removePKCS7Padding?Object(_.removePadding)(y):y},C.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},C.decrypt=function(b,y,d,r){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(b),y,d);var i=this.flush();i&&r(i.buffer)}else this.webCryptoDecrypt(new Uint8Array(b),y,d).then(r)},C.softwareDecrypt=function(b,y,d){var r=this.currentIV,i=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(b=Object(O.appendUint8Array)(o,b),this.remainderData=null);var f=this.getValidChunk(b);if(!f.length)return null;r&&(d=r);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new _.default),l.expandKey(y);var h=i;return this.currentResult=l.decrypt(f.buffer,0,d),this.currentIV=Object(k.sliceUint8)(f,-16).buffer,h||null},C.webCryptoDecrypt=function(b,y,d){var r=this,i=this.subtle;return(this.key!==y||!this.fastAesKey)&&(this.key=y,this.fastAesKey=new L.default(i,y)),this.fastAesKey.expandKey().then(function(o){if(!i)return Promise.reject(new Error("web crypto not initialized"));var f=new U.default(i,d);return f.decrypt(b.buffer,o)}).catch(function(o){return r.onWebCryptoError(o,b,y,d)})},C.onWebCryptoError=function(b,y,d,r){return B.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",b),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(y,d,r)},C.getValidChunk=function(b){var y=b,d=b.length-b.length%w;return d!==b.length&&(y=Object(k.sliceUint8)(b,0,d),this.remainderData=Object(k.sliceUint8)(b,d)),y},C.logOnce=function(b){if(!this.logEnabled)return;B.logger.log("[decrypter.ts]: "+b),this.logEnabled=!1},x}()},"./src/crypt/fast-aes-key.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return U});var U=function(){function L(B,O){this.subtle=void 0,this.key=void 0,this.subtle=B,this.key=O}var _=L.prototype;return _.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},L}()},"./src/demux/aacdemuxer.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/demux/base-audio-demuxer.ts"),L=S("./src/demux/adts.ts"),_=S("./src/utils/logger.ts"),B=S("./src/demux/id3.ts");function O(v,x){v.prototype=Object.create(x.prototype),v.prototype.constructor=v,k(v,x)}function k(v,x){return k=Object.setPrototypeOf||function(E,b){return E.__proto__=b,E},k(v,x)}var w=function(v){O(x,v);function x(E,b){var y;return y=v.call(this)||this,y.observer=void 0,y.config=void 0,y.observer=E,y.config=b,y}var C=x.prototype;return C.resetInitSegment=function(b,y,d){v.prototype.resetInitSegment.call(this,b,y,d),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:b,duration:d,inputTimeScale:9e4,dropped:0}},x.probe=function(b){if(!b)return!1;for(var y=B.getID3Data(b,0)||[],d=y.length,r=b.length;d<r;d++)if(L.probe(b,d))return _.logger.log("ADTS sync word found !"),!0;return!1},C.canParse=function(b,y){return L.canParse(b,y)},C.appendFrame=function(b,y,d){L.initTrackConfig(b,this.observer,y,d,b.manifestCodec);var r=L.appendFrame(b,y,d,this.initPTS,this.frameIndex);if(r&&r.missing===0)return r},x}(U.default);w.minProbeByteLength=9,N.default=w},"./src/demux/adts.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"getAudioConfig",function(){return B}),S.d(N,"isHeaderPattern",function(){return O}),S.d(N,"getHeaderLength",function(){return k}),S.d(N,"getFullFrameLength",function(){return w}),S.d(N,"canGetFrameLength",function(){return v}),S.d(N,"isHeader",function(){return x}),S.d(N,"canParse",function(){return C}),S.d(N,"probe",function(){return E}),S.d(N,"initTrackConfig",function(){return b}),S.d(N,"getFrameDuration",function(){return y}),S.d(N,"parseFrameHeader",function(){return d}),S.d(N,"appendFrame",function(){return r});var U=S("./src/utils/logger.ts"),L=S("./src/errors.ts"),_=S("./src/events.ts");function B(i,o,f,l){var h,m,c,u,e=navigator.userAgent.toLowerCase(),n=l,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];h=((o[f+2]&192)>>>6)+1;var p=(o[f+2]&60)>>>2;if(p>a.length-1){i.trigger(_.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+p});return}return c=(o[f+2]&1)<<2,c|=(o[f+3]&192)>>>6,U.logger.log("manifest codec:"+l+", ADTS type:"+h+", samplingIndex:"+p),/firefox/i.test(e)?p>=6?(h=5,u=new Array(4),m=p-3):(h=2,u=new Array(2),m=p):e.indexOf("android")!==-1?(h=2,u=new Array(2),m=p):(h=5,u=new Array(4),l&&(l.indexOf("mp4a.40.29")!==-1||l.indexOf("mp4a.40.5")!==-1)||!l&&p>=6?m=p-3:((l&&l.indexOf("mp4a.40.2")!==-1&&(p>=6&&c===1||/vivaldi/i.test(e))||!l&&c===1)&&(h=2,u=new Array(2)),m=p)),u[0]=h<<3,u[0]|=(p&14)>>1,u[1]|=(p&1)<<7,u[1]|=c<<3,h===5&&(u[1]|=(m&14)>>1,u[2]=(m&1)<<7,u[2]|=2<<2,u[3]=0),{config:u,samplerate:a[p],channelCount:c,codec:"mp4a.40."+h,manifestCodec:n}}function O(i,o){return i[o]===255&&(i[o+1]&246)===240}function k(i,o){return i[o+1]&1?7:9}function w(i,o){return(i[o+3]&3)<<11|i[o+4]<<3|(i[o+5]&224)>>>5}function v(i,o){return o+5<i.length}function x(i,o){return o+1<i.length&&O(i,o)}function C(i,o){return v(i,o)&&O(i,o)&&w(i,o)<=i.length-o}function E(i,o){if(x(i,o)){var f=k(i,o);if(o+f>=i.length)return!1;var l=w(i,o);if(l<=f)return!1;var h=o+l;return h===i.length||x(i,h)}return!1}function b(i,o,f,l,h){if(!i.samplerate){var m=B(o,f,l,h);if(!m)return;i.config=m.config,i.samplerate=m.samplerate,i.channelCount=m.channelCount,i.codec=m.codec,i.manifestCodec=m.manifestCodec,U.logger.log("parsed codec:"+i.codec+", rate:"+m.samplerate+", channels:"+m.channelCount)}}function y(i){return 1024*9e4/i}function d(i,o,f,l,h){var m=k(i,o),c=w(i,o);if(c-=m,c>0){var u=f+l*h;return{headerLength:m,frameLength:c,stamp:u}}}function r(i,o,f,l,h){var m=y(i.samplerate),c=d(o,f,l,h,m);if(c){var u=c.frameLength,e=c.headerLength,n=c.stamp,a=e+u,p=Math.max(0,f+a-o.length),g;p?(g=new Uint8Array(a-e),g.set(o.subarray(f+e,o.length),0)):g=o.subarray(f+e,f+a);var T={unit:g,pts:n};return p||i.samples.push(T),{sample:T,length:a,missing:p}}}},"./src/demux/base-audio-demuxer.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"initPTSFn",function(){return w});var U=S("./src/polyfills/number.ts"),L=S("./src/demux/id3.ts"),_=S("./src/demux/dummy-demuxed-track.ts"),B=S("./src/utils/mp4-tools.ts"),O=S("./src/utils/typed-array.ts"),k=function(){function v(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var x=v.prototype;return x.resetInitSegment=function(E,b,y){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},x.resetTimeStamp=function(){},x.resetContiguity=function(){},x.canParse=function(E,b){return!1},x.appendFrame=function(E,b,y){},x.demux=function(E,b){this.cachedData&&(E=Object(B.appendUint8Array)(this.cachedData,E),this.cachedData=null);var y=L.getID3Data(E,0),d=y?y.length:0,r,i,o=this._audioTrack,f=this._id3Track,l=y?L.getTimeStamp(y):void 0,h=E.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=w(l,b)),y&&y.length>0&&f.samples.push({pts:this.initPTS,dts:this.initPTS,data:y}),i=this.initPTS;d<h;){if(this.canParse(E,d)){var m=this.appendFrame(o,E,d);m?(this.frameIndex++,i=m.sample.pts,d+=m.length,r=d):d=h}else L.canParse(E,d)?(y=L.getID3Data(E,d),f.samples.push({pts:i,dts:i,data:y}),d+=y.length,r=d):d++;if(d===h&&r!==h){var c=Object(O.sliceUint8)(E,r);this.cachedData?this.cachedData=Object(B.appendUint8Array)(this.cachedData,c):this.cachedData=c}}return{audioTrack:o,avcTrack:Object(_.dummyTrack)(),id3Track:f,textTrack:Object(_.dummyTrack)()}},x.demuxSampleAes=function(E,b,y){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},x.flush=function(E){var b=this.cachedData;return b&&(this.cachedData=null,this.demux(b,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(_.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(_.dummyTrack)()}},x.destroy=function(){},v}(),w=function(x,C){return Object(U.isFiniteNumber)(x)?x*90:C*9e4};N.default=k},"./src/demux/chunk-cache.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return U});var U=function(){function _(){this.chunks=[],this.dataLength=0}var B=_.prototype;return B.push=function(k){this.chunks.push(k),this.dataLength+=k.length},B.flush=function(){var k=this.chunks,w=this.dataLength,v;if(k.length)k.length===1?v=k[0]:v=L(k,w);else return new Uint8Array(0);return this.reset(),v},B.reset=function(){this.chunks.length=0,this.dataLength=0},_}();function L(_,B){for(var O=new Uint8Array(B),k=0,w=0;w<_.length;w++){var v=_[w];O.set(v,k),k+=v.length}return O}},"./src/demux/dummy-demuxed-track.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"dummyTrack",function(){return U});function U(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/utils/logger.ts"),L=function(){function _(O){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=O,this.bytesAvailable=O.byteLength,this.word=0,this.bitsAvailable=0}var B=_.prototype;return B.loadWord=function(){var k=this.data,w=this.bytesAvailable,v=k.byteLength-w,x=new Uint8Array(4),C=Math.min(4,w);if(C===0)throw new Error("no bytes available");x.set(k.subarray(v,v+C)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=C*8,this.bytesAvailable-=C},B.skipBits=function(k){var w;this.bitsAvailable>k?(this.word<<=k,this.bitsAvailable-=k):(k-=this.bitsAvailable,w=k>>3,k-=w>>3,this.bytesAvailable-=w,this.loadWord(),this.word<<=k,this.bitsAvailable-=k)},B.readBits=function(k){var w=Math.min(this.bitsAvailable,k),v=this.word>>>32-w;return k>32&&U.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=w,this.bitsAvailable>0?this.word<<=w:this.bytesAvailable>0&&this.loadWord(),w=k-w,w>0&&this.bitsAvailable?v<<w|this.readBits(w):v},B.skipLZ=function(){var k;for(k=0;k<this.bitsAvailable;++k)if((this.word&2147483648>>>k)!==0)return this.word<<=k,this.bitsAvailable-=k,k;return this.loadWord(),k+this.skipLZ()},B.skipUEG=function(){this.skipBits(1+this.skipLZ())},B.skipEG=function(){this.skipBits(1+this.skipLZ())},B.readUEG=function(){var k=this.skipLZ();return this.readBits(k+1)-1},B.readEG=function(){var k=this.readUEG();return 1&k?1+k>>>1:-1*(k>>>1)},B.readBoolean=function(){return this.readBits(1)===1},B.readUByte=function(){return this.readBits(8)},B.readUShort=function(){return this.readBits(16)},B.readUInt=function(){return this.readBits(32)},B.skipScalingList=function(k){for(var w=8,v=8,x,C=0;C<k;C++)v!==0&&(x=this.readEG(),v=(w+x+256)%256),w=v===0?w:v},B.readSPS=function(){var k=0,w=0,v=0,x=0,C,E,b,y=this.readUByte.bind(this),d=this.readBits.bind(this),r=this.readUEG.bind(this),i=this.readBoolean.bind(this),o=this.skipBits.bind(this),f=this.skipEG.bind(this),l=this.skipUEG.bind(this),h=this.skipScalingList.bind(this);y();var m=y();if(d(5),o(3),y(),l(),m===100||m===110||m===122||m===244||m===44||m===83||m===86||m===118||m===128){var c=r();if(c===3&&o(1),l(),l(),o(1),i())for(E=c!==3?8:12,b=0;b<E;b++)i()&&(b<6?h(16):h(64))}l();var u=r();if(u===0)r();else if(u===1)for(o(1),f(),f(),C=r(),b=0;b<C;b++)f();l(),o(1);var e=r(),n=r(),a=d(1);a===0&&o(1),o(1),i()&&(k=r(),w=r(),v=r(),x=r());var p=[1,1];if(i()&&i()){var g=y();switch(g){case 1:p=[1,1];break;case 2:p=[12,11];break;case 3:p=[10,11];break;case 4:p=[16,11];break;case 5:p=[40,33];break;case 6:p=[24,11];break;case 7:p=[20,11];break;case 8:p=[32,11];break;case 9:p=[80,33];break;case 10:p=[18,11];break;case 11:p=[15,11];break;case 12:p=[64,33];break;case 13:p=[160,99];break;case 14:p=[4,3];break;case 15:p=[3,2];break;case 16:p=[2,1];break;case 255:{p=[y()<<8|y(),y()<<8|y()];break}}}return{width:Math.ceil((e+1)*16-k*2-w*2),height:(2-a)*(n+1)*16-(a?2:4)*(v+x),pixelRatio:p}},B.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},_}();N.default=L},"./src/demux/id3.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"isHeader",function(){return U}),S.d(N,"isFooter",function(){return L}),S.d(N,"getID3Data",function(){return _}),S.d(N,"canParse",function(){return O}),S.d(N,"getTimeStamp",function(){return k}),S.d(N,"isTimeStampFrame",function(){return w}),S.d(N,"getID3Frames",function(){return x}),S.d(N,"decodeFrame",function(){return C}),S.d(N,"utf8ArrayToStr",function(){return r}),S.d(N,"testables",function(){return i});var U=function(h,m){return m+10<=h.length&&(h[m]===73&&h[m+1]===68&&h[m+2]===51&&(h[m+3]<255&&h[m+4]<255&&(h[m+6]<128&&h[m+7]<128&&h[m+8]<128&&h[m+9]<128)))},L=function(h,m){return m+10<=h.length&&(h[m]===51&&h[m+1]===68&&h[m+2]===73&&(h[m+3]<255&&h[m+4]<255&&(h[m+6]<128&&h[m+7]<128&&h[m+8]<128&&h[m+9]<128)))},_=function(h,m){for(var c=m,u=0;U(h,m);){u+=10;var e=B(h,m+6);u+=e,L(h,m+10)&&(u+=10),m+=u}return u>0?h.subarray(c,c+u):void 0},B=function(h,m){var c=0;return c=(h[m]&127)<<21,c|=(h[m+1]&127)<<14,c|=(h[m+2]&127)<<7,c|=h[m+3]&127,c},O=function(h,m){return U(h,m)&&B(h,m+6)+10<=h.length-m},k=function(h){for(var m=x(h),c=0;c<m.length;c++){var u=m[c];if(w(u))return d(u)}return},w=function(h){return h&&h.key==="PRIV"&&h.info==="com.apple.streaming.transportStreamTimestamp"},v=function(h){var m=String.fromCharCode(h[0],h[1],h[2],h[3]),c=B(h,4),u=10;return{type:m,size:c,data:h.subarray(u,u+c)}},x=function(h){for(var m=0,c=[];U(h,m);){var u=B(h,m+6);m+=10;for(var e=m+u;m+8<e;){var n=v(h.subarray(m)),a=C(n);a&&c.push(a),m+=n.size+10}L(h,m)&&(m+=10)}return c},C=function(h){return h.type==="PRIV"?E(h):h.type[0]==="W"?y(h):b(h)},E=function(h){if(h.size<2)return;var m=r(h.data,!0),c=new Uint8Array(h.data.subarray(m.length+1));return{key:h.type,info:m,data:c.buffer}},b=function(h){if(h.size<2)return;if(h.type==="TXXX"){var m=1,c=r(h.data.subarray(m),!0);m+=c.length+1;var u=r(h.data.subarray(m));return{key:h.type,info:c,data:u}}var e=r(h.data.subarray(1));return{key:h.type,data:e}},y=function(h){if(h.type==="WXXX"){if(h.size<2)return;var m=1,c=r(h.data.subarray(m),!0);m+=c.length+1;var u=r(h.data.subarray(m));return{key:h.type,info:c,data:u}}var e=r(h.data);return{key:h.type,data:e}},d=function(h){if(h.data.byteLength===8){var m=new Uint8Array(h.data),c=m[3]&1,u=(m[4]<<23)+(m[5]<<15)+(m[6]<<7)+m[7];return u/=45,c&&(u+=4772185884e-2),Math.round(u)}return},r=function(h,m){m===void 0&&(m=!1);var c=f();if(c){var u=c.decode(h);if(m){var e=u.indexOf("\0");return e!==-1?u.substring(0,e):u}return u.replace(/\0/g,"")}for(var n=h.length,a,p,g,T="",P=0;P<n;){if(a=h[P++],a===0&&m)return T;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:T+=String.fromCharCode(a);break;case 12:case 13:p=h[P++],T+=String.fromCharCode((a&31)<<6|p&63);break;case 14:p=h[P++],g=h[P++],T+=String.fromCharCode((a&15)<<12|(p&63)<<6|(g&63)<<0);break;default:}}return T},i={decodeTextFrame:b},o;function f(){return!o&&typeof self.TextDecoder!="undefined"&&(o=new self.TextDecoder("utf-8")),o}},"./src/demux/mp3demuxer.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/demux/base-audio-demuxer.ts"),L=S("./src/demux/id3.ts"),_=S("./src/utils/logger.ts"),B=S("./src/demux/mpegaudio.ts");function O(v,x){v.prototype=Object.create(x.prototype),v.prototype.constructor=v,k(v,x)}function k(v,x){return k=Object.setPrototypeOf||function(E,b){return E.__proto__=b,E},k(v,x)}var w=function(v){O(x,v);function x(){return v.apply(this,arguments)||this}var C=x.prototype;return C.resetInitSegment=function(b,y,d){v.prototype.resetInitSegment.call(this,b,y,d),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:b,duration:d,inputTimeScale:9e4,dropped:0}},x.probe=function(b){if(!b)return!1;for(var y=L.getID3Data(b,0)||[],d=y.length,r=b.length;d<r;d++)if(B.probe(b,d))return _.logger.log("MPEG Audio sync word found !"),!0;return!1},C.canParse=function(b,y){return B.canParse(b,y)},C.appendFrame=function(b,y,d){return this.initPTS===null?void 0:B.appendFrame(b,y,d,this.initPTS,this.frameIndex)},x}(U.default);w.minProbeByteLength=4,N.default=w},"./src/demux/mp4demuxer.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/utils/mp4-tools.ts"),L=S("./src/demux/dummy-demuxed-track.ts"),_=function(){function B(k,w){this.remainderData=null,this.config=void 0,this.config=w}var O=B.prototype;return O.resetTimeStamp=function(){},O.resetInitSegment=function(){},O.resetContiguity=function(){},B.probe=function(w){return Object(U.findBox)({data:w,start:0,end:Math.min(w.length,16384)},["moof"]).length>0},O.demux=function(w){var v=w,x=Object(L.dummyTrack)();if(this.config.progressive){this.remainderData&&(v=Object(U.appendUint8Array)(this.remainderData,w));var C=Object(U.segmentValidRange)(v);this.remainderData=C.remainder,x.samples=C.valid||new Uint8Array}else x.samples=v;return{audioTrack:Object(L.dummyTrack)(),avcTrack:x,id3Track:Object(L.dummyTrack)(),textTrack:Object(L.dummyTrack)()}},O.flush=function(){var w=Object(L.dummyTrack)();return w.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(L.dummyTrack)(),avcTrack:w,id3Track:Object(L.dummyTrack)(),textTrack:Object(L.dummyTrack)()}},O.demuxSampleAes=function(w,v,x){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},O.destroy=function(){},B}();_.minProbeByteLength=1024,N.default=_},"./src/demux/mpegaudio.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"appendFrame",function(){return k}),S.d(N,"parseHeader",function(){return w}),S.d(N,"isHeaderPattern",function(){return v}),S.d(N,"isHeader",function(){return x}),S.d(N,"canParse",function(){return C}),S.d(N,"probe",function(){return E});var U=null,L=[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],_=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],B=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],O=[0,1,1,4];function k(b,y,d,r,i){if(d+24>y.length)return;var o=w(y,d);if(o&&d+o.frameLength<=y.length){var f=o.samplesPerFrame*9e4/o.sampleRate,l=r+i*f,h={unit:y.subarray(d,d+o.frameLength),pts:l,dts:l};return b.config=[],b.channelCount=o.channelCount,b.samplerate=o.sampleRate,b.samples.push(h),{sample:h,length:o.frameLength,missing:0}}}function w(b,y){var d=b[y+1]>>3&3,r=b[y+1]>>1&3,i=b[y+2]>>4&15,o=b[y+2]>>2&3;if(d!==1&&i!==0&&i!==15&&o!==3){var f=b[y+2]>>1&1,l=b[y+3]>>6,h=d===3?3-r:r===3?3:4,m=L[h*14+i-1]*1e3,c=d===3?0:d===2?1:2,u=_[c*3+o],e=l===3?1:2,n=B[d][r],a=O[r],p=n*8*a,g=Math.floor(n*m/u+f)*a;if(U===null){var T=navigator.userAgent||"",P=T.match(/Chrome\/(\d+)/i);U=P?parseInt(P[1]):0}var I=!!U&&U<=87;return I&&r===2&&m>=224e3&&l===0&&(b[y+3]=b[y+3]|128),{sampleRate:u,channelCount:e,frameLength:g,samplesPerFrame:p}}}function v(b,y){return b[y]===255&&(b[y+1]&224)===224&&(b[y+1]&6)!==0}function x(b,y){return y+1<b.length&&v(b,y)}function C(b,y){var d=4;return v(b,y)&&d<=b.length-y}function E(b,y){if(y+1<b.length&&v(b,y)){var d=4,r=w(b,y),i=d;r!=null&&r.frameLength&&(i=r.frameLength);var o=y+i;return o===b.length||x(b,o)}return!1}},"./src/demux/sample-aes.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/crypt/decrypter.ts"),L=S("./src/demux/tsdemuxer.ts"),_=function(){function B(k,w,v){this.keyData=void 0,this.decrypter=void 0,this.keyData=v,this.decrypter=new U.default(k,w,{removePKCS7Padding:!1})}var O=B.prototype;return O.decryptBuffer=function(w,v){this.decrypter.decrypt(w,this.keyData.key.buffer,this.keyData.iv.buffer,v)},O.decryptAacSample=function(w,v,x,C){var E=w[v].unit,b=E.subarray(16,E.length-E.length%16),y=b.buffer.slice(b.byteOffset,b.byteOffset+b.length),d=this;this.decryptBuffer(y,function(r){var i=new Uint8Array(r);E.set(i,16),C||d.decryptAacSamples(w,v+1,x)})},O.decryptAacSamples=function(w,v,x){for(;;v++){if(v>=w.length){x();return}if(w[v].unit.length<32)continue;var C=this.decrypter.isSync();if(this.decryptAacSample(w,v,x,C),!C)return}},O.getAvcEncryptedData=function(w){for(var v=Math.floor((w.length-48)/160)*16+16,x=new Int8Array(v),C=0,E=32;E<=w.length-16;E+=160,C+=16)x.set(w.subarray(E,E+16),C);return x},O.getAvcDecryptedUnit=function(w,v){for(var x=new Uint8Array(v),C=0,E=32;E<=w.length-16;E+=160,C+=16)w.set(x.subarray(C,C+16),E);return w},O.decryptAvcSample=function(w,v,x,C,E,b){var y=Object(L.discardEPB)(E.data),d=this.getAvcEncryptedData(y),r=this;this.decryptBuffer(d.buffer,function(i){E.data=r.getAvcDecryptedUnit(y,i),b||r.decryptAvcSamples(w,v,x+1,C)})},O.decryptAvcSamples=function(w,v,x,C){if(w instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;v++,x=0){if(v>=w.length){C();return}for(var E=w[v].units;!(x>=E.length);x++){var b=E[x];if(b.data.length<=48||b.type!==1&&b.type!==5)continue;var y=this.decrypter.isSync();if(this.decryptAvcSample(w,v,x,C,b,y),!y)return}}},B}();N.default=_},"./src/demux/transmuxer-interface.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return E});var U=S("./node_modules/webworkify-webpack/index.js"),L=S.n(U),_=S("./src/events.ts"),B=S("./src/demux/transmuxer.ts"),O=S("./src/utils/logger.ts"),k=S("./src/errors.ts"),w=S("./src/utils/mediasource-helper.ts"),v=S("./node_modules/eventemitter3/index.js"),x=S.n(v),C=Object(w.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function b(d,r,i,o){var f=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=d,this.id=r,this.onTransmuxComplete=i,this.onFlush=o;var l=d.config,h=function(n,a){a=a||{},a.frag=f.frag,a.id=f.id,d.trigger(n,a)};this.observer=new v.EventEmitter,this.observer.on(_.Events.FRAG_DECRYPTED,h),this.observer.on(_.Events.ERROR,h);var m={mp4:C.isTypeSupported("video/mp4"),mpeg:C.isTypeSupported("audio/mpeg"),mp3:C.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(l.enableWorker&&typeof Worker!="undefined"){O.logger.log("demuxing in webworker");var u;try{u=this.worker=U("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),u.addEventListener("message",this.onwmsg),u.onerror=function(e){d.trigger(_.Events.ERROR,{type:k.ErrorTypes.OTHER_ERROR,details:k.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},u.postMessage({cmd:"init",typeSupported:m,vendor:c,id:r,config:JSON.stringify(l)})}catch(e){O.logger.warn("Error in worker:",e),O.logger.error("Error while initializing DemuxerWorker, fallback to inline"),u&&self.URL.revokeObjectURL(u.objectURL),this.transmuxer=new B.default(this.observer,m,l,c,r),this.worker=null}}else this.transmuxer=new B.default(this.observer,m,l,c,r)}var y=b.prototype;return y.destroy=function(){var r=this.worker;if(r)r.removeEventListener("message",this.onwmsg),r.terminate(),this.worker=null;else{var i=this.transmuxer;i&&(i.destroy(),this.transmuxer=null)}var o=this.observer;o&&o.removeAllListeners(),this.observer=null},y.push=function(r,i,o,f,l,h,m,c,u,e){var n=this;u.transmuxing.start=self.performance.now();var a=this.transmuxer,p=this.worker,g=h?h.start:l.start,T=l.decryptdata,P=this.frag,I=!(P&&l.cc===P.cc),F=!(P&&u.level===P.level),W=P?u.sn-P.sn:-1,z=this.part?u.part-this.part.index:1,X=!F&&(W===1||W===0&&z===1),K=self.performance.now();(F||W||l.stats.parsing.start===0)&&(l.stats.parsing.start=K),h&&(z||!X)&&(h.stats.parsing.start=K);var J=new B.TransmuxState(I,X,c,F,g);if(!X||I){O.logger.log("[transmuxer-interface, "+l.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
discontinuity: `+I+`
|
|
trackSwitch: `+F+`
|
|
contiguous: `+X+`
|
|
accurateTimeOffset: `+c+`
|
|
timeOffset: `+g);var ne=new B.TransmuxConfig(o,f,i,m,e);this.configureTransmuxer(ne)}if(this.frag=l,this.part=h,p)p.postMessage({cmd:"demux",data:r,decryptdata:T,chunkMeta:u,state:J},r instanceof ArrayBuffer?[r]:[]);else if(a){var re=a.push(r,T,u,J);Object(B.isPromise)(re)?re.then(function(be){n.handleTransmuxComplete(be)}):this.handleTransmuxComplete(re)}},y.flush=function(r){var i=this;r.transmuxing.start=self.performance.now();var o=this.transmuxer,f=this.worker;if(f)f.postMessage({cmd:"flush",chunkMeta:r});else if(o){var l=o.flush(r);Object(B.isPromise)(l)?l.then(function(h){i.handleFlushResult(h,r)}):this.handleFlushResult(l,r)}},y.handleFlushResult=function(r,i){var o=this;r.forEach(function(f){o.handleTransmuxComplete(f)}),this.onFlush(i)},y.onWorkerMessage=function(r){var i=r.data,o=this.hls;switch(i.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(i.data);break}case"flush":{this.onFlush(i.data);break}default:{i.data=i.data||{},i.data.frag=this.frag,i.data.id=this.id,o.trigger(i.event,i.data);break}}},y.configureTransmuxer=function(r){var i=this.worker,o=this.transmuxer;i?i.postMessage({cmd:"configure",config:r}):o&&o.configure(r)},y.handleTransmuxComplete=function(r){r.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(r)},b}()},"./src/demux/transmuxer-worker.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return k});var U=S("./src/demux/transmuxer.ts"),L=S("./src/events.ts"),_=S("./src/utils/logger.ts"),B=S("./node_modules/eventemitter3/index.js"),O=S.n(B);function k(E){var b=new B.EventEmitter,y=function(r,i){E.postMessage({event:r,data:i})};b.on(L.Events.FRAG_DECRYPTED,y),b.on(L.Events.ERROR,y),E.addEventListener("message",function(d){var r=d.data;switch(r.cmd){case"init":{var i=JSON.parse(r.config);E.transmuxer=new U.default(b,r.typeSupported,i,r.vendor,r.id),Object(_.enableLogs)(i.debug),y("init",null);break}case"configure":{E.transmuxer.configure(r.config);break}case"demux":{var o=E.transmuxer.push(r.data,r.decryptdata,r.chunkMeta,r.state);Object(U.isPromise)(o)?o.then(function(h){w(E,h)}):w(E,o);break}case"flush":{var f=r.chunkMeta,l=E.transmuxer.flush(f);Object(U.isPromise)(l)?l.then(function(h){x(E,h,f)}):x(E,l,f);break}default:break}})}function w(E,b){if(C(b.remuxResult))return;var y=[],d=b.remuxResult,r=d.audio,i=d.video;r&&v(y,r),i&&v(y,i),E.postMessage({event:"transmuxComplete",data:b},y)}function v(E,b){b.data1&&E.push(b.data1.buffer),b.data2&&E.push(b.data2.buffer)}function x(E,b,y){b.forEach(function(d){w(E,d)}),E.postMessage({event:"flush",data:y})}function C(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return i}),S.d(N,"isPromise",function(){return l}),S.d(N,"TransmuxConfig",function(){return h}),S.d(N,"TransmuxState",function(){return m});var U=S("./src/events.ts"),L=S("./src/errors.ts"),_=S("./src/crypt/decrypter.ts"),B=S("./src/demux/aacdemuxer.ts"),O=S("./src/demux/mp4demuxer.ts"),k=S("./src/demux/tsdemuxer.ts"),w=S("./src/demux/mp3demuxer.ts"),v=S("./src/remux/mp4-remuxer.ts"),x=S("./src/remux/passthrough-remuxer.ts"),C=S("./src/demux/chunk-cache.ts"),E=S("./src/utils/mp4-tools.ts"),b=S("./src/utils/logger.ts"),y;try{y=self.performance.now.bind(self.performance)}catch(c){b.logger.debug("Unable to use Performance API on this environment"),y=self.Date.now}var d=[{demux:k.default,remux:v.default},{demux:O.default,remux:x.default},{demux:B.default,remux:v.default},{demux:w.default,remux:v.default}],r=1024;d.forEach(function(c){var u=c.demux;r=Math.max(r,u.minProbeByteLength)});var i=function(){function c(e,n,a,p,g){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new C.default,this.observer=e,this.typeSupported=n,this.config=a,this.vendor=p,this.id=g}var u=c.prototype;return u.configure=function(n){this.transmuxConfig=n,this.decrypter&&this.decrypter.reset()},u.push=function(n,a,p,g){var T=this,P=p.transmuxing;P.executeStart=y();var I=new Uint8Array(n),F=this.cache,W=this.config,z=this.currentTransmuxState,X=this.transmuxConfig;g&&(this.currentTransmuxState=g);var K=o(I,a);if(K&&K.method==="AES-128"){var J=this.getDecrypter();if(W.enableSoftwareAES){var ne=J.softwareDecrypt(I,K.key.buffer,K.iv.buffer);if(!ne)return P.executeEnd=y(),f(p);I=new Uint8Array(ne)}else return this.decryptionPromise=J.webCryptoDecrypt(I,K.key.buffer,K.iv.buffer).then(function(Ce){var Se=T.push(Ce,null,p);return T.decryptionPromise=null,Se}),this.decryptionPromise}var re=g||z,be=re.contiguous,oe=re.discontinuity,ue=re.trackSwitch,de=re.accurateTimeOffset,ce=re.timeOffset,te=X.audioCodec,$=X.videoCodec,Ae=X.defaultInitPts,Fe=X.duration,De=X.initSegmentData;if((oe||ue)&&this.resetInitSegment(De,te,$,Fe),oe&&this.resetInitialTimestamp(Ae),be||this.resetContiguity(),this.needsProbing(I,oe,ue)){if(F.dataLength){var Ue=F.flush();I=Object(E.appendUint8Array)(Ue,I)}this.configureTransmuxer(I,X)}var Re=this.transmux(I,K,ce,de,p),fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,P.executeEnd=y(),Re},u.flush=function(n){var a=this,p=n.transmuxing;p.executeStart=y();var g=this.decrypter,T=this.cache,P=this.currentTransmuxState,I=this.decryptionPromise;if(I)return I.then(function(){return a.flush(n)});var F=[],W=P.timeOffset;if(g){var z=g.flush();z&&F.push(this.push(z,null,n))}var X=T.dataLength;T.reset();var K=this.demuxer,J=this.remuxer;if(!K||!J)return X>=r&&this.observer.emit(U.Events.ERROR,U.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),p.executeEnd=y(),[f(n)];var ne=K.flush(W);return l(ne)?ne.then(function(re){return a.flushRemux(F,re,n),F}):(this.flushRemux(F,ne,n),F)},u.flushRemux=function(n,a,p){var g=a.audioTrack,T=a.avcTrack,P=a.id3Track,I=a.textTrack,F=this.currentTransmuxState,W=F.accurateTimeOffset,z=F.timeOffset;b.logger.log("[transmuxer.ts]: Flushed fragment "+p.sn+(p.part>-1?" p: "+p.part:"")+" of level "+p.level);var X=this.remuxer.remux(g,T,P,I,z,W,!0,this.id);n.push({remuxResult:X,chunkMeta:p}),p.transmuxing.executeEnd=y()},u.resetInitialTimestamp=function(n){var a=this.demuxer,p=this.remuxer;if(!a||!p)return;a.resetTimeStamp(n),p.resetTimeStamp(n)},u.resetContiguity=function(){var n=this.demuxer,a=this.remuxer;if(!n||!a)return;n.resetContiguity(),a.resetNextTimestamp()},u.resetInitSegment=function(n,a,p,g){var T=this.demuxer,P=this.remuxer;if(!T||!P)return;T.resetInitSegment(a,p,g),P.resetInitSegment(n,a,p)},u.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},u.transmux=function(n,a,p,g,T){var P;return a&&a.method==="SAMPLE-AES"?P=this.transmuxSampleAes(n,a,p,g,T):P=this.transmuxUnencrypted(n,p,g,T),P},u.transmuxUnencrypted=function(n,a,p,g){var T=this.demuxer.demux(n,a,!1,!this.config.progressive),P=T.audioTrack,I=T.avcTrack,F=T.id3Track,W=T.textTrack,z=this.remuxer.remux(P,I,F,W,a,p,!1,this.id);return{remuxResult:z,chunkMeta:g}},u.transmuxSampleAes=function(n,a,p,g,T){var P=this;return this.demuxer.demuxSampleAes(n,a,p).then(function(I){var F=P.remuxer.remux(I.audioTrack,I.avcTrack,I.id3Track,I.textTrack,p,g,!1,P.id);return{remuxResult:F,chunkMeta:T}})},u.configureTransmuxer=function(n,a){for(var p=this.config,g=this.observer,T=this.typeSupported,P=this.vendor,I=a.audioCodec,F=a.defaultInitPts,W=a.duration,z=a.initSegmentData,X=a.videoCodec,K,J=0,ne=d.length;J<ne;J++)if(d[J].demux.probe(n)){K=d[J];break}K||(b.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),K={demux:O.default,remux:x.default});var re=this.demuxer,be=this.remuxer,oe=K.remux,ue=K.demux;(!be||!(be instanceof oe))&&(this.remuxer=new oe(g,p,T,P)),(!re||!(re instanceof ue))&&(this.demuxer=new ue(g,p,T),this.probe=ue.probe),this.resetInitSegment(z,I,X,W),this.resetInitialTimestamp(F)},u.needsProbing=function(n,a,p){return!this.demuxer||!this.remuxer||a||p},u.getDecrypter=function(){var n=this.decrypter;return n||(n=this.decrypter=new _.default(this.observer,this.config)),n},c}();function o(c,u){var e=null;return c.byteLength>0&&u!=null&&u.key!=null&&u.iv!==null&&u.method!=null&&(e=u),e}var f=function(u){return{remuxResult:{},chunkMeta:u}};function l(c){return"then"in c&&c.then instanceof Function}var h=function(u,e,n,a,p){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=u,this.videoCodec=e,this.initSegmentData=n,this.duration=a,this.defaultInitPts=p},m=function(u,e,n,a,p){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=u,this.contiguous=e,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=p}},"./src/demux/tsdemuxer.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"discardEPB",function(){return f});var U=S("./src/demux/adts.ts"),L=S("./src/demux/mpegaudio.ts"),_=S("./src/demux/exp-golomb.ts"),B=S("./src/demux/id3.ts"),O=S("./src/demux/sample-aes.ts"),k=S("./src/events.ts"),w=S("./src/utils/mp4-tools.ts"),v=S("./src/utils/logger.ts"),x=S("./src/errors.ts"),C={video:1,audio:2,id3:3,text:4},E=function(){function l(m,c,u){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=m,this.config=c,this.typeSupported=u}l.probe=function(c){var u=l.syncOffset(c);return u<0?!1:(u&&v.logger.warn("MPEG2-TS detected but first sync word found @ offset "+u+", junk ahead ?"),!0)},l.syncOffset=function(c){for(var u=Math.min(1e3,c.length-3*188),e=0;e<u;){if(c[e]===71&&c[e+188]===71&&c[e+2*188]===71)return e;e++}return-1},l.createTrack=function(c,u){return{container:c==="video"||c==="audio"?"video/mp2t":void 0,type:c,id:C[c],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:c==="audio"?u:void 0}};var h=l.prototype;return h.resetInitSegment=function(c,u,e){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=l.createTrack("video",e),this._audioTrack=l.createTrack("audio",e),this._id3Track=l.createTrack("id3",e),this._txtTrack=l.createTrack("text",e),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=c,this.videoCodec=u,this._duration=e},h.resetTimeStamp=function(){},h.resetContiguity=function(){var c=this._audioTrack,u=this._avcTrack,e=this._id3Track;c&&(c.pesData=null),u&&(u.pesData=null),e&&(e.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},h.demux=function(c,u,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1),e||(this.sampleAes=null);var a,p=this._avcTrack,g=this._audioTrack,T=this._id3Track,P=p.pid,I=p.pesData,F=g.pid,W=T.pid,z=g.pesData,X=T.pesData,K=!1,J=this.pmtParsed,ne=this._pmtId,re=c.length;if(this.remainderData&&(c=Object(w.appendUint8Array)(this.remainderData,c),re=c.length,this.remainderData=null),re<188&&!n)return this.remainderData=c,{audioTrack:g,avcTrack:p,id3Track:T,textTrack:this._txtTrack};var be=Math.max(0,l.syncOffset(c));re-=(re+be)%188,re<c.byteLength&&!n&&(this.remainderData=new Uint8Array(c.buffer,re,c.buffer.byteLength-re));for(var oe=be;oe<re;oe+=188)if(c[oe]===71){var ue=!!(c[oe+1]&64),de=((c[oe+1]&31)<<8)+c[oe+2],ce=(c[oe+3]&48)>>4,te=void 0;if(ce>1){if(te=oe+5+c[oe+4],te===oe+188)continue}else te=oe+4;switch(de){case P:ue&&(I&&(a=r(I))&&this.parseAVCPES(a,!1),I={data:[],size:0}),I&&(I.data.push(c.subarray(te,oe+188)),I.size+=oe+188-te);break;case F:ue&&(z&&(a=r(z))&&(g.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),z={data:[],size:0}),z&&(z.data.push(c.subarray(te,oe+188)),z.size+=oe+188-te);break;case W:ue&&(X&&(a=r(X))&&this.parseID3PES(a),X={data:[],size:0}),X&&(X.data.push(c.subarray(te,oe+188)),X.size+=oe+188-te);break;case 0:ue&&(te+=c[te]+1),ne=this._pmtId=y(c,te);break;case ne:{ue&&(te+=c[te]+1);var $=d(c,te,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,e);P=$.avc,P>0&&(p.pid=P),F=$.audio,F>0&&(g.pid=F,g.isAAC=$.isAAC),W=$.id3,W>0&&(T.pid=W),K&&!J&&(v.logger.log("reparse from beginning"),K=!1,oe=be-188),J=this.pmtParsed=!0;break}case 17:case 8191:break;default:K=!0;break}}else this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});p.pesData=I,g.pesData=z,T.pesData=X;var Ae={audioTrack:g,avcTrack:p,id3Track:T,textTrack:this._txtTrack};return n&&this.extractRemainingSamples(Ae),Ae},h.flush=function(){var c=this.remainderData;this.remainderData=null;var u;return c?u=this.demux(c,-1,!1,!0):u={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(u),this.sampleAes?this.decrypt(u,this.sampleAes):u},h.extractRemainingSamples=function(c){var u=c.audioTrack,e=c.avcTrack,n=c.id3Track,a=e.pesData,p=u.pesData,g=n.pesData,T;a&&(T=r(a))?(this.parseAVCPES(T,!0),e.pesData=null):e.pesData=a,p&&(T=r(p))?(u.isAAC?this.parseAACPES(T):this.parseMPEGPES(T),u.pesData=null):(p!=null&&p.size&&v.logger.log("last AAC PES packet truncated,might overlap between fragments"),u.pesData=p),g&&(T=r(g))?(this.parseID3PES(T),n.pesData=null):n.pesData=g},h.demuxSampleAes=function(c,u,e){var n=this.demux(c,e,!0,!this.config.progressive),a=this.sampleAes=new O.default(this.observer,this.config,u);return this.decrypt(n,a)},h.decrypt=function(c,u){return new Promise(function(e){var n=c.audioTrack,a=c.avcTrack;n.samples&&n.isAAC?u.decryptAacSamples(n.samples,0,function(){a.samples?u.decryptAvcSamples(a.samples,0,0,function(){e(c)}):e(c)}):a.samples&&u.decryptAvcSamples(a.samples,0,0,function(){e(c)})})},h.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},h.parseAVCPES=function(c,u){var e=this,n=this._avcTrack,a=this.parseAVCNALu(c.data),p=!1,g=this.avcSample,T,P=!1;c.data=null,g&&a.length&&!n.audFound&&(i(g,n),g=this.avcSample=b(!1,c.pts,c.dts,"")),a.forEach(function(I){switch(I.type){case 1:{T=!0,g||(g=e.avcSample=b(!0,c.pts,c.dts,"")),p&&(g.debug+="NDR "),g.frame=!0;var F=I.data;if(P&&F.length>4){var W=new _.default(F).readSliceType();(W===2||W===4||W===7||W===9)&&(g.key=!0)}break}case 5:T=!0,g||(g=e.avcSample=b(!0,c.pts,c.dts,"")),p&&(g.debug+="IDR "),g.key=!0,g.frame=!0;break;case 6:{T=!0,p&&g&&(g.debug+="SEI ");var z=new _.default(f(I.data));z.readUByte();for(var X=0,K=0,J=!1,ne=0;!J&&z.bytesAvailable>1;){X=0;do ne=z.readUByte(),X+=ne;while(ne===255);K=0;do ne=z.readUByte(),K+=ne;while(ne===255);if(X===4&&z.bytesAvailable!==0){J=!0;var re=z.readUByte();if(re===181){var be=z.readUShort();if(be===49){var oe=z.readUInt();if(oe===1195456820){var ue=z.readUByte();if(ue===3){for(var de=z.readUByte(),ce=z.readUByte(),te=31&de,$=[de,ce],Ae=0;Ae<te;Ae++)$.push(z.readUByte()),$.push(z.readUByte()),$.push(z.readUByte());o(e._txtTrack.samples,{type:3,pts:c.pts,bytes:$})}}}}}else if(X===5&&z.bytesAvailable!==0){if(J=!0,K>16){for(var Fe=[],De=0;De<16;De++)Fe.push(z.readUByte().toString(16)),(De===3||De===5||De===7||De===9)&&Fe.push("-");for(var Ue=K-16,Re=new Uint8Array(Ue),fe=0;fe<Ue;fe++)Re[fe]=z.readUByte();o(e._txtTrack.samples,{pts:c.pts,payloadType:X,uuid:Fe.join(""),userData:Object(B.utf8ArrayToStr)(Re),userDataBytes:Re})}}else if(K<z.bytesAvailable)for(var Ce=0;Ce<K;Ce++)z.readUByte()}break}case 7:if(T=!0,P=!0,p&&g&&(g.debug+="SPS "),!n.sps){var Se=new _.default(I.data),me=Se.readSPS();n.width=me.width,n.height=me.height,n.pixelRatio=me.pixelRatio,n.sps=[I.data],n.duration=e._duration;for(var Te=I.data.subarray(1,4),pe="avc1.",Ee=0;Ee<3;Ee++){var Ge=Te[Ee].toString(16);Ge.length<2&&(Ge="0"+Ge),pe+=Ge}n.codec=pe}break;case 8:T=!0,p&&g&&(g.debug+="PPS "),n.pps||(n.pps=[I.data]);break;case 9:T=!1,n.audFound=!0,g&&i(g,n),g=e.avcSample=b(!1,c.pts,c.dts,p?"AUD ":"");break;case 12:T=!1;break;default:T=!1,g&&(g.debug+="unknown NAL "+I.type+" ");break}if(g&&T){var Le=g.units;Le.push(I)}}),u&&g&&(i(g,n),this.avcSample=null)},h.getLastNalUnit=function(){var c,u=this.avcSample,e;if(!u||u.units.length===0){var n=this._avcTrack.samples;u=n[n.length-1]}if((c=u)!==null&&c!==void 0&&c.units){var a=u.units;e=a[a.length-1]}return e},h.parseAVCNALu=function(c){var u=c.byteLength,e=this._avcTrack,n=e.naluState||0,a=n,p=[],g=0,T,P,I,F=-1,W=0;for(n===-1&&(F=0,W=c[0]&31,n=0,g=1);g<u;){if(T=c[g++],!n){n=T?0:1;continue}if(n===1){n=T?0:2;continue}if(!T)n=3;else if(T===1){if(F>=0){var z={data:c.subarray(F,g-n-1),type:W};p.push(z)}else{var X=this.getLastNalUnit();if(X&&(a&&g<=4-a&&(X.state&&(X.data=X.data.subarray(0,X.data.byteLength-a))),P=g-n-1,P>0)){var K=new Uint8Array(X.data.byteLength+P);K.set(X.data,0),K.set(c.subarray(0,P),X.data.byteLength),X.data=K,X.state=0}}g<u?(I=c[g]&31,F=g,W=I,n=0):n=-1}else n=0}if(F>=0&&n>=0){var J={data:c.subarray(F,u),type:W,state:n};p.push(J)}if(p.length===0){var ne=this.getLastNalUnit();if(ne){var re=new Uint8Array(ne.data.byteLength+c.byteLength);re.set(ne.data,0),re.set(c,ne.data.byteLength),ne.data=re}}return e.naluState=n,p},h.parseAACPES=function(c){var u=0,e=this._audioTrack,n=this.aacOverFlow,a=c.data;if(n){this.aacOverFlow=null;var p=n.sample.unit.byteLength,g=Math.min(n.missing,p),T=p-g;n.sample.unit.set(a.subarray(0,g),T),e.samples.push(n.sample),u=n.missing}var P,I;for(P=u,I=a.length;P<I-1&&!U.isHeader(a,P);P++);if(P!==u){var F,W;if(P<I-1?(F="AAC PES did not start with ADTS header,offset:"+P,W=!1):(F="no ADTS header found in AAC PES",W=!0),v.logger.warn("parsing error:"+F),this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.FRAG_PARSING_ERROR,fatal:W,reason:F}),W)return}U.initTrackConfig(e,this.observer,a,P,this.audioCodec);var z;if(c.pts!==void 0)z=c.pts;else if(n){var X=U.getFrameDuration(e.samplerate);z=n.sample.pts+X}else{v.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var K=0;P<I;)if(U.isHeader(a,P)){if(P+5<I){var J=U.appendFrame(e,a,P,z,K);if(J)if(J.missing)this.aacOverFlow=J;else{P+=J.length,K++;continue}}break}else P++},h.parseMPEGPES=function(c){var u=c.data,e=u.length,n=0,a=0,p=c.pts;if(p===void 0){v.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<e;)if(L.isHeader(u,a)){var g=L.appendFrame(this._audioTrack,u,a,p,n);if(g)a+=g.length,n++;else break}else a++},h.parseID3PES=function(c){if(c.pts===void 0){v.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(c)},l}();E.minProbeByteLength=188;function b(l,h,m,c){return{key:l,frame:!1,pts:h,dts:m,units:[],debug:c,length:0}}function y(l,h){return(l[h+10]&31)<<8|l[h+11]}function d(l,h,m,c){var u={audio:-1,avc:-1,id3:-1,isAAC:!0},e=(l[h+1]&15)<<8|l[h+2],n=h+3+e-4,a=(l[h+10]&15)<<8|l[h+11];for(h+=12+a;h<n;){var p=(l[h+1]&31)<<8|l[h+2];switch(l[h]){case 207:if(!c){v.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:u.audio===-1&&(u.audio=p);break;case 21:u.id3===-1&&(u.id3=p);break;case 219:if(!c){v.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:u.avc===-1&&(u.avc=p);break;case 3:case 4:m?u.audio===-1&&(u.audio=p,u.isAAC=!1):v.logger.log("MPEG audio found, not supported in this browser");break;case 36:v.logger.warn("Unsupported HEVC stream type found");break;default:break}h+=((l[h+3]&15)<<8|l[h+4])+5}return u}function r(l){var h=0,m,c,u,e,n,a=l.data;if(!l||l.size===0)return null;for(;a[0].length<19&&a.length>1;){var p=new Uint8Array(a[0].length+a[1].length);p.set(a[0]),p.set(a[1],a[0].length),a[0]=p,a.splice(1,1)}m=a[0];var g=(m[0]<<16)+(m[1]<<8)+m[2];if(g===1){if(c=(m[4]<<8)+m[5],c&&c>l.size-6)return null;var T=m[7];T&192&&(e=(m[9]&14)*536870912+(m[10]&255)*4194304+(m[11]&254)*16384+(m[12]&255)*128+(m[13]&254)/2,T&64?(n=(m[14]&14)*536870912+(m[15]&255)*4194304+(m[16]&254)*16384+(m[17]&255)*128+(m[18]&254)/2,e-n>60*9e4&&(v.logger.warn(Math.round((e-n)/9e4)+"s delta between PTS and DTS, align them"),e=n)):n=e),u=m[8];var P=u+9;if(l.size<=P)return null;l.size-=P;for(var I=new Uint8Array(l.size),F=0,W=a.length;F<W;F++){m=a[F];var z=m.byteLength;if(P)if(P>z){P-=z;continue}else m=m.subarray(P),z-=P,P=0;I.set(m,h),h+=z}return c&&(c-=u+3),{data:I,pts:e,dts:n,len:c}}return null}function i(l,h){if(l.units.length&&l.frame){if(l.pts===void 0){var m=h.samples,c=m.length;if(c){var u=m[c-1];l.pts=u.pts,l.dts=u.dts}else{h.dropped++;return}}h.samples.push(l)}l.debug.length&&v.logger.log(l.pts+"/"+l.dts+":"+l.debug)}function o(l,h){var m=l.length;if(m>0){if(h.pts>=l[m-1].pts)l.push(h);else for(var c=m-1;c>=0;c--)if(h.pts<l[c].pts){l.splice(c,0,h);break}}else l.push(h)}function f(l){for(var h=l.byteLength,m=[],c=1;c<h-2;)l[c]===0&&l[c+1]===0&&l[c+2]===3?(m.push(c+2),c+=2):c++;if(m.length===0)return l;var u=h-m.length,e=new Uint8Array(u),n=0;for(c=0;c<u;n++,c++)n===m[0]&&(n++,m.shift()),e[c]=l[n];return e}N.default=E},"./src/errors.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"ErrorTypes",function(){return U}),S.d(N,"ErrorDetails",function(){return L});var U;(function(_){_.NETWORK_ERROR="networkError",_.MEDIA_ERROR="mediaError",_.KEY_SYSTEM_ERROR="keySystemError",_.MUX_ERROR="muxError",_.OTHER_ERROR="otherError"})(U||(U={}));var L;(function(_){_.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",_.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",_.KEY_SYSTEM_NO_SESSION="keySystemNoSession",_.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",_.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",_.MANIFEST_LOAD_ERROR="manifestLoadError",_.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",_.MANIFEST_PARSING_ERROR="manifestParsingError",_.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",_.LEVEL_EMPTY_ERROR="levelEmptyError",_.LEVEL_LOAD_ERROR="levelLoadError",_.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",_.LEVEL_SWITCH_ERROR="levelSwitchError",_.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",_.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",_.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",_.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",_.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_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",_.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",_.INTERNAL_ABORTED="aborted",_.UNKNOWN="unknown"})(L||(L={}))},"./src/events.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"Events",function(){return U});var U;(function(L){L.MEDIA_ATTACHING="hlsMediaAttaching",L.MEDIA_ATTACHED="hlsMediaAttached",L.MEDIA_DETACHING="hlsMediaDetaching",L.MEDIA_DETACHED="hlsMediaDetached",L.BUFFER_RESET="hlsBufferReset",L.BUFFER_CODECS="hlsBufferCodecs",L.BUFFER_CREATED="hlsBufferCreated",L.BUFFER_APPENDING="hlsBufferAppending",L.BUFFER_APPENDED="hlsBufferAppended",L.BUFFER_EOS="hlsBufferEos",L.BUFFER_FLUSHING="hlsBufferFlushing",L.BUFFER_FLUSHED="hlsBufferFlushed",L.MANIFEST_LOADING="hlsManifestLoading",L.MANIFEST_LOADED="hlsManifestLoaded",L.MANIFEST_PARSED="hlsManifestParsed",L.LEVEL_SWITCHING="hlsLevelSwitching",L.LEVEL_SWITCHED="hlsLevelSwitched",L.LEVEL_LOADING="hlsLevelLoading",L.LEVEL_LOADED="hlsLevelLoaded",L.LEVEL_UPDATED="hlsLevelUpdated",L.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",L.LEVELS_UPDATED="hlsLevelsUpdated",L.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",L.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",L.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",L.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",L.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",L.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",L.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",L.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",L.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",L.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",L.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",L.CUES_PARSED="hlsCuesParsed",L.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",L.INIT_PTS_FOUND="hlsInitPtsFound",L.FRAG_LOADING="hlsFragLoading",L.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",L.FRAG_LOADED="hlsFragLoaded",L.FRAG_DECRYPTED="hlsFragDecrypted",L.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",L.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",L.FRAG_PARSING_METADATA="hlsFragParsingMetadata",L.FRAG_PARSED="hlsFragParsed",L.FRAG_BUFFERED="hlsFragBuffered",L.FRAG_CHANGED="hlsFragChanged",L.FPS_DROP="hlsFpsDrop",L.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",L.ERROR="hlsError",L.DESTROYING="hlsDestroying",L.KEY_LOADING="hlsKeyLoading",L.KEY_LOADED="hlsKeyLoaded",L.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",L.BACK_BUFFER_REACHED="hlsBackBufferReached"})(U||(U={}))},"./src/hls.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return l});var U=S("./node_modules/url-toolkit/src/url-toolkit.js"),L=S.n(U),_=S("./src/loader/playlist-loader.ts"),B=S("./src/loader/key-loader.ts"),O=S("./src/controller/id3-track-controller.ts"),k=S("./src/controller/latency-controller.ts"),w=S("./src/controller/level-controller.ts"),v=S("./src/controller/fragment-tracker.ts"),x=S("./src/controller/stream-controller.ts"),C=S("./src/is-supported.ts"),E=S("./src/utils/logger.ts"),b=S("./src/config.ts"),y=S("./node_modules/eventemitter3/index.js"),d=S.n(y),r=S("./src/events.ts"),i=S("./src/errors.ts");function o(h,m){for(var c=0;c<m.length;c++){var u=m[c];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(h,u.key,u)}}function f(h,m,c){return m&&o(h.prototype,m),c&&o(h,c),h}var l=function(){h.isSupported=function(){return Object(C.isSupported)()};function h(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new y.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var u=this.config=Object(b.mergeConfig)(h.DefaultConfig,c);this.userConfig=c,Object(E.enableLogs)(u.debug),this._autoLevelCapping=-1,u.progressive&&Object(b.enableStreamingMode)(u);var e=u.abrController,n=u.bufferController,a=u.capLevelController,p=u.fpsController,g=this.abrController=new e(this),T=this.bufferController=new n(this),P=this.capLevelController=new a(this),I=new p(this),F=new _.default(this),W=new B.default(this),z=new O.default(this),X=this.levelController=new w.default(this),K=new v.FragmentTracker(this),J=this.streamController=new x.default(this,K);P.setStreamController(J),I.setStreamController(J);var ne=[X,J];this.networkControllers=ne;var re=[F,W,g,T,P,I,z,K];this.audioTrackController=this.createController(u.audioTrackController,null,ne),this.createController(u.audioStreamController,K,ne),this.subtitleTrackController=this.createController(u.subtitleTrackController,null,ne),this.createController(u.subtitleStreamController,K,ne),this.createController(u.timelineController,null,re),this.emeController=this.createController(u.emeController,null,re),this.cmcdController=this.createController(u.cmcdController,null,re),this.latencyController=this.createController(k.default,null,re),this.coreComponents=re}var m=h.prototype;return m.createController=function(u,e,n){if(u){var a=e?new u(this,e):new u(this);return n&&n.push(a),a}return null},m.on=function(u,e,n){n===void 0&&(n=this),this._emitter.on(u,e,n)},m.once=function(u,e,n){n===void 0&&(n=this),this._emitter.once(u,e,n)},m.removeAllListeners=function(u){this._emitter.removeAllListeners(u)},m.off=function(u,e,n,a){n===void 0&&(n=this),this._emitter.off(u,e,n,a)},m.listeners=function(u){return this._emitter.listeners(u)},m.emit=function(u,e,n){return this._emitter.emit(u,e,n)},m.trigger=function(u,e){if(this.config.debug)return this.emit(u,u,e);try{return this.emit(u,u,e)}catch(n){E.logger.error("An internal error happened while handling event "+u+'. Error message: "'+n.message+'". Here is a stacktrace:',n),this.trigger(r.Events.ERROR,{type:i.ErrorTypes.OTHER_ERROR,details:i.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:u,error:n})}return!1},m.listenerCount=function(u){return this._emitter.listenerCount(u)},m.destroy=function(){E.logger.log("destroy"),this.trigger(r.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(u){return u.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(u){return u.destroy()}),this.coreComponents.length=0},m.attachMedia=function(u){E.logger.log("attachMedia"),this._media=u,this.trigger(r.Events.MEDIA_ATTACHING,{media:u})},m.detachMedia=function(){E.logger.log("detachMedia"),this.trigger(r.Events.MEDIA_DETACHING,void 0),this._media=null},m.loadSource=function(u){this.stopLoad();var e=this.media,n=this.url,a=this.url=U.buildAbsoluteURL(self.location.href,u,{alwaysNormalize:!0});E.logger.log("loadSource:"+a),e&&n&&n!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(e)),this.trigger(r.Events.MANIFEST_LOADING,{url:u})},m.startLoad=function(u){u===void 0&&(u=-1),E.logger.log("startLoad("+u+")"),this.networkControllers.forEach(function(e){e.startLoad(u)})},m.stopLoad=function(){E.logger.log("stopLoad"),this.networkControllers.forEach(function(u){u.stopLoad()})},m.swapAudioCodec=function(){E.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},m.recoverMediaError=function(){E.logger.log("recoverMediaError");var u=this._media;this.detachMedia(),u&&this.attachMedia(u)},m.removeLevel=function(u,e){e===void 0&&(e=0),this.levelController.removeLevel(u,e)},f(h,[{key:"levels",get:function(){var u=this.levelController.levels;return u||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(u){E.logger.log("set currentLevel:"+u),this.loadLevel=u,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(u){E.logger.log("set nextLevel:"+u),this.levelController.manualLevel=u,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(u){E.logger.log("set loadLevel:"+u),this.levelController.manualLevel=u}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(u){this.levelController.nextLoadLevel=u}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(u){E.logger.log("set firstLevel:"+u),this.levelController.firstLevel=u}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(u){E.logger.log("set startLevel:"+u),u!==-1&&(u=Math.max(u,this.minAutoLevel)),this.levelController.startLevel=u}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(u){var e=!!u;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(u){this._autoLevelCapping!==u&&(E.logger.log("set autoLevelCapping:"+u),this._autoLevelCapping=u)}},{key:"bandwidthEstimate",get:function(){var u=this.abrController.bwEstimator;return u?u.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var u=this.levels,e=this.config.minAutoBitrate;if(!u)return 0;for(var n=u.length,a=0;a<n;a++)if(u[a].maxBitrate>e)return a;return 0}},{key:"maxAutoLevel",get:function(){var u=this.levels,e=this.autoLevelCapping,n;return e===-1&&u&&u.length?n=u.length-1:n=e,n}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(u){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,u)}},{key:"audioTracks",get:function(){var u=this.audioTrackController;return u?u.audioTracks:[]}},{key:"audioTrack",get:function(){var u=this.audioTrackController;return u?u.audioTrack:-1},set:function(u){var e=this.audioTrackController;e&&(e.audioTrack=u)}},{key:"subtitleTracks",get:function(){var u=this.subtitleTrackController;return u?u.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var u=this.subtitleTrackController;return u?u.subtitleTrack:-1},set:function(u){var e=this.subtitleTrackController;e&&(e.subtitleTrack=u)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var u=this.subtitleTrackController;return u?u.subtitleDisplay:!1},set:function(u){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=u)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(u){this.config.lowLatencyMode=u}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return r.Events}},{key:"ErrorTypes",get:function(){return i.ErrorTypes}},{key:"ErrorDetails",get:function(){return i.ErrorDetails}},{key:"DefaultConfig",get:function(){return h.defaultConfig?h.defaultConfig:b.hlsDefaultConfig},set:function(u){h.defaultConfig=u}}]),h}();l.defaultConfig=void 0},"./src/is-supported.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"isSupported",function(){return _}),S.d(N,"changeTypeSupported",function(){return B});var U=S("./src/utils/mediasource-helper.ts");function L(){return self.SourceBuffer||self.WebKitSourceBuffer}function _(){var O=Object(U.getMediaSource)();if(!O)return!1;var k=L(),w=O&&typeof O.isTypeSupported=="function"&&O.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),v=!k||k.prototype&&typeof k.prototype.appendBuffer=="function"&&typeof k.prototype.remove=="function";return!!w&&!!v}function B(){var O,k=L();return typeof(k==null||((O=k.prototype)===null||O===void 0)?void 0:O.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return E}),S.d(N,"LoadError",function(){return y});var U=S("./src/polyfills/number.ts"),L=S("./src/errors.ts");function _(d,r){d.prototype=Object.create(r.prototype),d.prototype.constructor=d,v(d,r)}function B(d){var r=typeof Map=="function"?new Map:void 0;return B=function(o){if(o===null||!w(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof r!="undefined"){if(r.has(o))return r.get(o);r.set(o,f)}function f(){return O(o,arguments,x(this).constructor)}return f.prototype=Object.create(o.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),v(f,o)},B(d)}function O(d,r,i){return k()?O=Reflect.construct:O=function(f,l,h){var m=[null];m.push.apply(m,l);var c=Function.bind.apply(f,m),u=new c;return h&&v(u,h.prototype),u},O.apply(null,arguments)}function k(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(d){return!1}}function w(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function v(d,r){return v=Object.setPrototypeOf||function(o,f){return o.__proto__=f,o},v(d,r)}function x(d){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},x(d)}var C=Math.pow(2,17),E=function(){function d(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var r=d.prototype;return r.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},r.abort=function(){this.loader&&this.loader.abort()},r.load=function(o,f){var l=this,h=o.url;if(!h)return Promise.reject(new y({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,networkDetails:null},"Fragment does not have a "+(h?"part list":"url")));this.abort();var m=this.config,c=m.fLoader,u=m.loader;return new Promise(function(e,n){l.loader&&l.loader.destroy();var a=l.loader=o.loader=c?new c(m):new u(m),p=b(o),g={timeout:m.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:m.fragLoadingMaxRetryTimeout,highWaterMark:C};o.stats=a.stats,a.load(p,g,{onSuccess:function(P,I,F,W){l.resetLoader(o,a),e({frag:o,part:null,payload:P.data,networkDetails:W})},onError:function(P,I,F){l.resetLoader(o,a),n(new y({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:P,networkDetails:F}))},onAbort:function(P,I,F){l.resetLoader(o,a),n(new y({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:o,networkDetails:F}))},onTimeout:function(P,I,F){l.resetLoader(o,a),n(new y({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,networkDetails:F}))},onProgress:function(P,I,F,W){f&&f({frag:o,part:null,payload:F,networkDetails:W})}})})},r.loadPart=function(o,f,l){var h=this;this.abort();var m=this.config,c=m.fLoader,u=m.loader;return new Promise(function(e,n){h.loader&&h.loader.destroy();var a=h.loader=o.loader=c?new c(m):new u(m),p=b(o,f),g={timeout:m.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:m.fragLoadingMaxRetryTimeout,highWaterMark:C};f.stats=a.stats,a.load(p,g,{onSuccess:function(P,I,F,W){h.resetLoader(o,a),h.updateStatsFromPart(o,f);var z={frag:o,part:f,payload:P.data,networkDetails:W};l(z),e(z)},onError:function(P,I,F){h.resetLoader(o,a),n(new y({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,part:f,response:P,networkDetails:F}))},onAbort:function(P,I,F){o.stats.aborted=f.stats.aborted,h.resetLoader(o,a),n(new y({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:o,part:f,networkDetails:F}))},onTimeout:function(P,I,F){h.resetLoader(o,a),n(new y({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,part:f,networkDetails:F}))}})})},r.updateStatsFromPart=function(o,f){var l=o.stats,h=f.stats,m=h.total;if(l.loaded+=h.loaded,m){var c=Math.round(o.duration/f.duration),u=Math.min(Math.round(l.loaded/m),c),e=c-u,n=e*Math.round(l.loaded/u);l.total=l.loaded+n}else l.total=Math.max(l.loaded,l.total);var a=l.loading,p=h.loading;a.start?a.first+=p.first-p.start:(a.start=p.start,a.first=p.first),a.end=p.end},r.resetLoader=function(o,f){o.loader=null,this.loader===f&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),f.destroy()},d}();function b(d,r){r===void 0&&(r=null);var i=r||d,o={frag:d,part:r,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},f=i.byteRangeStartOffset,l=i.byteRangeEndOffset;return Object(U.isFiniteNumber)(f)&&Object(U.isFiniteNumber)(l)&&(o.rangeStart=f,o.rangeEnd=l),o}var y=function(d){_(r,d);function r(i){for(var o,f=arguments.length,l=new Array(f>1?f-1:0),h=1;h<f;h++)l[h-1]=arguments[h];return o=d.call.apply(d,[this].concat(l))||this,o.data=void 0,o.data=i,o}return r}(B(Error))},"./src/loader/fragment.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"ElementaryStreamTypes",function(){return E}),S.d(N,"BaseSegment",function(){return b}),S.d(N,"Fragment",function(){return y}),S.d(N,"Part",function(){return d});var U=S("./src/polyfills/number.ts"),L=S("./node_modules/url-toolkit/src/url-toolkit.js"),_=S.n(L),B=S("./src/utils/logger.ts"),O=S("./src/loader/level-key.ts"),k=S("./src/loader/load-stats.ts");function w(r,i){r.prototype=Object.create(i.prototype),r.prototype.constructor=r,v(r,i)}function v(r,i){return v=Object.setPrototypeOf||function(f,l){return f.__proto__=l,f},v(r,i)}function x(r,i){for(var o=0;o<i.length;o++){var f=i[o];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(r,f.key,f)}}function C(r,i,o){return i&&x(r.prototype,i),o&&x(r,o),r}var E;(function(r){r.AUDIO="audio",r.VIDEO="video",r.AUDIOVIDEO="audiovideo"})(E||(E={}));var b=function(){function r(o){var f;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(f={},f[E.AUDIO]=null,f[E.VIDEO]=null,f[E.AUDIOVIDEO]=null,f),this.baseurl=o}var i=r.prototype;return i.setByteRange=function(f,l){var h=f.split("@",2),m=[];h.length===1?m[0]=l?l.byteRangeEndOffset:0:m[0]=parseInt(h[1]),m[1]=parseInt(h[0])+m[0],this._byteRange=m},C(r,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(L.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(f){this._url=f}}]),r}(),y=function(r){w(i,r);function i(f,l){var h;return h=r.call(this,l)||this,h._decryptdata=null,h.rawProgramDateTime=null,h.programDateTime=null,h.tagList=[],h.duration=0,h.sn=0,h.levelkey=void 0,h.type=void 0,h.loader=null,h.level=-1,h.cc=0,h.startPTS=void 0,h.endPTS=void 0,h.appendedPTS=void 0,h.startDTS=void 0,h.endDTS=void 0,h.start=0,h.deltaPTS=void 0,h.maxStartPTS=void 0,h.minEndPTS=void 0,h.stats=new k.LoadStats,h.urlId=0,h.data=void 0,h.bitrateTest=!1,h.title=null,h.initSegment=null,h.type=f,h}var o=i.prototype;return o.createInitializationVector=function(l){for(var h=new Uint8Array(16),m=12;m<16;m++)h[m]=l>>8*(15-m)&255;return h},o.setDecryptDataFromLevelKey=function(l,h){var m=l;return(l==null?void 0:l.method)==="AES-128"&&l.uri&&!l.iv&&(m=O.LevelKey.fromURI(l.uri),m.method=l.method,m.iv=this.createInitializationVector(h),m.keyFormat="identity"),m},o.setElementaryStreamInfo=function(l,h,m,c,u,e){e===void 0&&(e=!1);var n=this.elementaryStreams,a=n[l];if(!a){n[l]={startPTS:h,endPTS:m,startDTS:c,endDTS:u,partial:e};return}a.startPTS=Math.min(a.startPTS,h),a.endPTS=Math.max(a.endPTS,m),a.startDTS=Math.min(a.startDTS,c),a.endDTS=Math.max(a.endDTS,u)},o.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[E.AUDIO]=null,l[E.VIDEO]=null,l[E.AUDIOVIDEO]=null},C(i,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var l=this.sn;typeof l!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&B.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),l=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,l)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(U.isFiniteNumber)(this.programDateTime))return null;var l=Object(U.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+l*1e3}},{key:"encrypted",get:function(){var l;return!!((l=this.decryptdata)!==null&&l!==void 0&&l.keyFormat&&this.decryptdata.uri)}}]),i}(b),d=function(r){w(i,r);function i(o,f,l,h,m){var c;c=r.call(this,l)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new k.LoadStats,c.duration=o.decimalFloatingPoint("DURATION"),c.gap=o.bool("GAP"),c.independent=o.bool("INDEPENDENT"),c.relurl=o.enumeratedString("URI"),c.fragment=f,c.index=h;var u=o.enumeratedString("BYTERANGE");return u&&c.setByteRange(u,m),m&&(c.fragOffset=m.fragOffset+m.duration),c}return C(i,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var f=this.elementaryStreams;return!!(f.audio||f.video||f.audiovideo)}}]),i}(b)},"./src/loader/key-loader.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return B});var U=S("./src/events.ts"),L=S("./src/errors.ts"),_=S("./src/utils/logger.ts"),B=function(){function O(w){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=w,this._registerListeners()}var k=O.prototype;return k._registerListeners=function(){this.hls.on(U.Events.KEY_LOADING,this.onKeyLoading,this)},k._unregisterListeners=function(){this.hls.off(U.Events.KEY_LOADING,this.onKeyLoading)},k.destroy=function(){this._unregisterListeners();for(var v in this.loaders){var x=this.loaders[v];x&&x.destroy()}this.loaders={}},k.onKeyLoading=function(v,x){var C=x.frag,E=C.type,b=this.loaders[E];if(!C.decryptdata){_.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var y=C.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var d=this.hls.config;if(b&&(_.logger.warn("abort previous key loader for type:"+E),b.abort()),!y){_.logger.warn("key uri is falsy");return}var r=d.loader,i=C.loader=this.loaders[E]=new r(d);this.decrypturl=y,this.decryptkey=null;var o={url:y,frag:C,responseType:"arraybuffer"},f={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:d.fragLoadingRetryDelay,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:0},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};i.load(o,f,l)}else this.decryptkey&&(C.decryptdata.key=this.decryptkey,this.hls.trigger(U.Events.KEY_LOADED,{frag:C}))},k.loadsuccess=function(v,x,C){var E=C.frag;if(!E.decryptdata){_.logger.error("after key load, decryptdata unset");return}this.decryptkey=E.decryptdata.key=new Uint8Array(v.data),E.loader=null,delete this.loaders[E.type],this.hls.trigger(U.Events.KEY_LOADED,{frag:E})},k.loaderror=function(v,x){var C=x.frag,E=C.loader;E&&E.abort(),delete this.loaders[C.type],this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:C,response:v})},k.loadtimeout=function(v,x){var C=x.frag,E=C.loader;E&&E.abort(),delete this.loaders[C.type],this.hls.trigger(U.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:C})},O}()},"./src/loader/level-details.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"LevelDetails",function(){return O});var U=S("./src/polyfills/number.ts");function L(k,w){for(var v=0;v<w.length;v++){var x=w[v];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(k,x.key,x)}}function _(k,w,v){return w&&L(k.prototype,w),v&&L(k,v),k}var B=10,O=function(){function k(v){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=v}var w=k.prototype;return w.reloaded=function(x){if(!x){this.advanced=!0,this.updated=!0;return}var C=this.lastPartSn-x.lastPartSn,E=this.lastPartIndex-x.lastPartIndex;this.updated=this.endSN!==x.endSN||!!E||!!C,this.advanced=this.endSN>x.endSN||C>0||C===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(x.misses*.6):this.misses=x.misses+1,this.availabilityDelay=x.availabilityDelay},_(k,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(U.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||B}},{key:"drift",get:function(){var x=this.driftEndTime-this.driftStartTime;if(x>0){var C=this.driftEnd-this.driftStart;return C*1e3/x}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var x;return(x=this.fragments)!==null&&x!==void 0&&x.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),k}()},"./src/loader/level-key.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"LevelKey",function(){return O});var U=S("./node_modules/url-toolkit/src/url-toolkit.js"),L=S.n(U);function _(k,w){for(var v=0;v<w.length;v++){var x=w[v];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(k,x.key,x)}}function B(k,w,v){return w&&_(k.prototype,w),v&&_(k,v),k}var O=function(){k.fromURL=function(v,x){return new k(v,x)},k.fromURI=function(v){return new k(v)};function k(w,v){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,v?this._uri=Object(U.buildAbsoluteURL)(w,v,{alwaysNormalize:!0}):this._uri=w}return B(k,[{key:"uri",get:function(){return this._uri}}]),k}()},"./src/loader/load-stats.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"LoadStats",function(){return U});var U=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return i});var U=S("./src/polyfills/number.ts"),L=S("./node_modules/url-toolkit/src/url-toolkit.js"),_=S.n(L),B=S("./src/loader/fragment.ts"),O=S("./src/loader/level-details.ts"),k=S("./src/loader/level-key.ts"),w=S("./src/utils/attr-list.ts"),v=S("./src/utils/logger.ts"),x=S("./src/utils/codecs.ts"),C=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,E=/#EXT-X-MEDIA:(.*)/g,b=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),y=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),d=/\.(mp4|m4s|m4v|m4a)$/i;function r(m){var c,u;return d.test((c=(u=L.parseURL(m))===null||u===void 0?void 0:u.path)!=null?c:"")}var i=function(){function m(){}return m.findGroup=function(u,e){for(var n=0;n<u.length;n++){var a=u[n];if(a.id===e)return a}},m.convertAVC1ToAVCOTI=function(u){var e=u.split(".");if(e.length>2){var n=e.shift()+".";return n+=parseInt(e.shift()).toString(16),n+=("000"+parseInt(e.shift()).toString(16)).substr(-4),n}return u},m.resolve=function(u,e){return L.buildAbsoluteURL(e,u,{alwaysNormalize:!0})},m.parseMasterPlaylist=function(u,e){var n=[],a={},p=!1;C.lastIndex=0;for(var g;(g=C.exec(u))!=null;)if(g[1]){var T=new w.AttrList(g[1]),P={attrs:T,bitrate:T.decimalInteger("AVERAGE-BANDWIDTH")||T.decimalInteger("BANDWIDTH"),name:T.NAME,url:m.resolve(g[2],e)},I=T.decimalResolution("RESOLUTION");I&&(P.width=I.width,P.height=I.height),o((T.CODECS||"").split(/[ ,]+/).filter(function(W){return W}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=m.convertAVC1ToAVCOTI(P.videoCodec)),n.push(P)}else if(g[3]){var F=new w.AttrList(g[3]);F["DATA-ID"]&&(p=!0,a[F["DATA-ID"]]=F)}return{levels:n,sessionData:p?a:null}},m.parseMasterPlaylistMedia=function(u,e,n,a){a===void 0&&(a=[]);var p,g=[],T=0;for(E.lastIndex=0;(p=E.exec(u))!==null;){var P=new w.AttrList(p[1]);if(P.TYPE===n){var I={attrs:P,bitrate:0,id:T++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:n,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?m.resolve(P.URI,e):""};if(a.length){var F=m.findGroup(a,I.groupId)||a[0];f(I,F,"audioCodec"),f(I,F,"textCodec")}g.push(I)}}return g},m.parseLevelPlaylist=function(u,e,n,a,p){var g=new O.LevelDetails(e),T=g.fragments,P=null,I=0,F=0,W=0,z=0,X=null,K=new B.Fragment(a,e),J,ne,re,be=-1,oe=!1;for(b.lastIndex=0,g.m3u8=u;(J=b.exec(u))!==null;){oe&&(oe=!1,K=new B.Fragment(a,e),K.start=W,K.sn=I,K.cc=z,K.level=n,P&&(K.initSegment=P,K.rawProgramDateTime=P.rawProgramDateTime));var ue=J[1];if(ue){K.duration=parseFloat(ue);var de=(" "+J[2]).slice(1);K.title=de||null,K.tagList.push(de?["INF",ue,de]:["INF",ue])}else if(J[3])Object(U.isFiniteNumber)(K.duration)&&(K.start=W,re&&(K.levelkey=re),K.sn=I,K.level=n,K.cc=z,K.urlId=p,T.push(K),K.relurl=(" "+J[3]).slice(1),h(K,X),X=K,W+=K.duration,I++,F=0,oe=!0);else if(J[4]){var ce=(" "+J[4]).slice(1);X?K.setByteRange(ce,X):K.setByteRange(ce)}else if(J[5])K.rawProgramDateTime=(" "+J[5]).slice(1),K.tagList.push(["PROGRAM-DATE-TIME",K.rawProgramDateTime]),be===-1&&(be=T.length);else{if(J=J[0].match(y),!J){v.logger.warn("No matches on slow regex match for level playlist!");continue}for(ne=1;ne<J.length&&!(typeof J[ne]!="undefined");ne++);var te=(" "+J[ne]).slice(1),$=(" "+J[ne+1]).slice(1),Ae=J[ne+2]?(" "+J[ne+2]).slice(1):"";switch(te){case"PLAYLIST-TYPE":g.type=$.toUpperCase();break;case"MEDIA-SEQUENCE":I=g.startSN=parseInt($);break;case"SKIP":{var Fe=new w.AttrList($),De=Fe.decimalInteger("SKIPPED-SEGMENTS");if(Object(U.isFiniteNumber)(De)){g.skippedSegments=De;for(var Ue=De;Ue--;)T.unshift(null);I+=De}var Re=Fe.enumeratedString("RECENTLY-REMOVED-DATERANGES");Re&&(g.recentlyRemovedDateranges=Re.split(" "));break}case"TARGETDURATION":g.targetduration=parseFloat($);break;case"VERSION":g.version=parseInt($);break;case"EXTM3U":break;case"ENDLIST":g.live=!1;break;case"#":($||Ae)&&K.tagList.push(Ae?[$,Ae]:[$]);break;case"DIS":z++;case"GAP":K.tagList.push([te]);break;case"BITRATE":K.tagList.push([te,$]);break;case"DISCONTINUITY-SEQ":z=parseInt($);break;case"KEY":{var fe,Ce=new w.AttrList($),Se=Ce.enumeratedString("METHOD"),me=Ce.URI,Te=Ce.hexadecimalInteger("IV"),pe=Ce.enumeratedString("KEYFORMATVERSIONS"),Ee=Ce.enumeratedString("KEYID"),Ge=(fe=Ce.enumeratedString("KEYFORMAT"))!=null?fe:"identity",Le=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Le.indexOf(Ge)>-1){v.logger.warn("Keyformat "+Ge+" is not supported from the manifest");continue}else if(Ge!=="identity")continue;Se&&(re=k.LevelKey.fromURL(e,me),me&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Se)>=0&&(re.method=Se,re.keyFormat=Ge,Ee&&(re.keyID=Ee),pe&&(re.keyFormatVersions=pe),re.iv=Te));break}case"START":{var ke=new w.AttrList($),Ne=ke.decimalFloatingPoint("TIME-OFFSET");Object(U.isFiniteNumber)(Ne)&&(g.startTimeOffset=Ne);break}case"MAP":{var ee=new w.AttrList($);K.relurl=ee.URI,ee.BYTERANGE&&K.setByteRange(ee.BYTERANGE),K.level=n,K.sn="initSegment",re&&(K.levelkey=re),K.initSegment=null,P=K,oe=!0;break}case"SERVER-CONTROL":{var Be=new w.AttrList($);g.canBlockReload=Be.bool("CAN-BLOCK-RELOAD"),g.canSkipUntil=Be.optionalFloat("CAN-SKIP-UNTIL",0),g.canSkipDateRanges=g.canSkipUntil>0&&Be.bool("CAN-SKIP-DATERANGES"),g.partHoldBack=Be.optionalFloat("PART-HOLD-BACK",0),g.holdBack=Be.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var _e=new w.AttrList($);g.partTarget=_e.decimalFloatingPoint("PART-TARGET");break}case"PART":{var we=g.partList;we||(we=g.partList=[]);var We=F>0?we[we.length-1]:void 0,Pe=F++,le=new B.Part(new w.AttrList($),K,e,Pe,We);we.push(le),K.duration+=le.duration;break}case"PRELOAD-HINT":{var xe=new w.AttrList($);g.preloadHint=xe;break}case"RENDITION-REPORT":{var q=new w.AttrList($);g.renditionReports=g.renditionReports||[],g.renditionReports.push(q);break}default:v.logger.warn("line parsed but not handled: "+J);break}}}X&&!X.relurl?(T.pop(),W-=X.duration,g.partList&&(g.fragmentHint=X)):g.partList&&(h(K,X),K.cc=z,g.fragmentHint=K);var Q=T.length,Z=T[0],j=T[Q-1];if(W+=g.skippedSegments*g.targetduration,W>0&&Q&&j){g.averagetargetduration=W/Q;var H=j.sn;g.endSN=H!=="initSegment"?H:0,Z&&(g.startCC=Z.cc,Z.initSegment||g.fragments.every(function(G){return G.relurl&&r(G.relurl)})&&(v.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),K=new B.Fragment(a,e),K.relurl=j.relurl,K.level=n,K.sn="initSegment",Z.initSegment=K,g.needSidxRanges=!0))}else g.endSN=0,g.startCC=0;return g.fragmentHint&&(W+=g.fragmentHint.duration),g.totalduration=W,g.endCC=z,be>0&&l(T,be),g},m}();function o(m,c){["video","audio","text"].forEach(function(u){var e=m.filter(function(a){return Object(x.isCodecType)(a,u)});if(e.length){var n=e.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});c[u+"Codec"]=n.length>0?n[0]:e[0],m=m.filter(function(a){return e.indexOf(a)===-1})}}),c.unknownCodecs=m}function f(m,c,u){var e=c[u];e&&(m[u]=e)}function l(m,c){for(var u=m[c],e=c;e--;){var n=m[e];if(!n)return;n.programDateTime=u.programDateTime-n.duration*1e3,u=n}}function h(m,c){m.rawProgramDateTime?m.programDateTime=Date.parse(m.rawProgramDateTime):c!=null&&c.programDateTime&&(m.programDateTime=c.endProgramDateTime),Object(U.isFiniteNumber)(m.programDateTime)||(m.programDateTime=null,m.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/polyfills/number.ts"),L=S("./src/events.ts"),_=S("./src/errors.ts"),B=S("./src/utils/logger.ts"),O=S("./src/utils/mp4-tools.ts"),k=S("./src/loader/m3u8-parser.ts"),w=S("./src/types/loader.ts"),v=S("./src/utils/attr-list.ts");function x(b){var y=b.type;switch(y){case w.PlaylistContextType.AUDIO_TRACK:return w.PlaylistLevelType.AUDIO;case w.PlaylistContextType.SUBTITLE_TRACK:return w.PlaylistLevelType.SUBTITLE;default:return w.PlaylistLevelType.MAIN}}function C(b,y){var d=b.url;return(d===void 0||d.indexOf("data:")===0)&&(d=y.url),d}var E=function(){function b(d){this.hls=void 0,this.loaders=Object.create(null),this.hls=d,this.registerListeners()}var y=b.prototype;return y.registerListeners=function(){var r=this.hls;r.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(L.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),r.on(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.unregisterListeners=function(){var r=this.hls;r.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(L.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),r.off(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.createInternalLoader=function(r){var i=this.hls.config,o=i.pLoader,f=i.loader,l=o||f,h=new l(i);return r.loader=h,this.loaders[r.type]=h,h},y.getInternalLoader=function(r){return this.loaders[r.type]},y.resetInternalLoader=function(r){this.loaders[r]&&delete this.loaders[r]},y.destroyInternalLoaders=function(){for(var r in this.loaders){var i=this.loaders[r];i&&i.destroy(),this.resetInternalLoader(r)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(r,i){var o=i.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:w.PlaylistContextType.MANIFEST,url:o,deliveryDirectives:null})},y.onLevelLoading=function(r,i){var o=i.id,f=i.level,l=i.url,h=i.deliveryDirectives;this.load({id:o,groupId:null,level:f,responseType:"text",type:w.PlaylistContextType.LEVEL,url:l,deliveryDirectives:h})},y.onAudioTrackLoading=function(r,i){var o=i.id,f=i.groupId,l=i.url,h=i.deliveryDirectives;this.load({id:o,groupId:f,level:null,responseType:"text",type:w.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:h})},y.onSubtitleTrackLoading=function(r,i){var o=i.id,f=i.groupId,l=i.url,h=i.deliveryDirectives;this.load({id:o,groupId:f,level:null,responseType:"text",type:w.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:h})},y.load=function(r){var i,o=this.hls.config,f=this.getInternalLoader(r);if(f){var l=f.context;if(l&&l.url===r.url){B.logger.trace("[playlist-loader]: playlist request ongoing");return}B.logger.log("[playlist-loader]: aborting previous loader for type: "+r.type),f.abort()}var h,m,c,u;switch(r.type){case w.PlaylistContextType.MANIFEST:h=o.manifestLoadingMaxRetry,m=o.manifestLoadingTimeOut,c=o.manifestLoadingRetryDelay,u=o.manifestLoadingMaxRetryTimeout;break;case w.PlaylistContextType.LEVEL:case w.PlaylistContextType.AUDIO_TRACK:case w.PlaylistContextType.SUBTITLE_TRACK:h=0,m=o.levelLoadingTimeOut;break;default:h=o.levelLoadingMaxRetry,m=o.levelLoadingTimeOut,c=o.levelLoadingRetryDelay,u=o.levelLoadingMaxRetryTimeout;break}if(f=this.createInternalLoader(r),(i=r.deliveryDirectives)!==null&&i!==void 0&&i.part){var e;if(r.type===w.PlaylistContextType.LEVEL&&r.level!==null?e=this.hls.levels[r.level].details:r.type===w.PlaylistContextType.AUDIO_TRACK&&r.id!==null?e=this.hls.audioTracks[r.id].details:r.type===w.PlaylistContextType.SUBTITLE_TRACK&&r.id!==null&&(e=this.hls.subtitleTracks[r.id].details),e){var n=e.partTarget,a=e.targetduration;n&&a&&(m=Math.min(Math.max(n*3,a*.8)*1e3,m))}}var p={timeout:m,maxRetry:h,retryDelay:c,maxRetryDelay:u,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};f.load(r,p,g)},y.loadsuccess=function(r,i,o,f){if(f===void 0&&(f=null),o.isSidxRequest){this.handleSidxRequest(r,o),this.handlePlaylistLoaded(r,i,o,f);return}this.resetInternalLoader(o.type);var l=r.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(r,o,"no EXTM3U delimiter",f);return}i.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(r,i,o,f):this.handleMasterPlaylist(r,i,o,f)},y.loaderror=function(r,i,o){o===void 0&&(o=null),this.handleNetworkError(i,o,!1,r)},y.loadtimeout=function(r,i,o){o===void 0&&(o=null),this.handleNetworkError(i,o,!0)},y.handleMasterPlaylist=function(r,i,o,f){var l=this.hls,h=r.data,m=C(r,o),c=k.default.parseMasterPlaylist(h,m),u=c.levels,e=c.sessionData;if(!u.length){this.handleManifestParsingError(r,o,"no level found in manifest",f);return}var n=u.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),a=u.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),p=k.default.parseMasterPlaylistMedia(h,m,"AUDIO",n),g=k.default.parseMasterPlaylistMedia(h,m,"SUBTITLES",a),T=k.default.parseMasterPlaylistMedia(h,m,"CLOSED-CAPTIONS");if(p.length){var P=p.some(function(I){return!I.url});!P&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(B.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new v.AttrList({}),bitrate:0,url:""}))}l.trigger(L.Events.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:g,captions:T,url:m,stats:i,networkDetails:f,sessionData:e})},y.handleTrackOrLevelPlaylist=function(r,i,o,f){var l=this.hls,h=o.id,m=o.level,c=o.type,u=C(r,o),e=Object(U.isFiniteNumber)(h)?h:0,n=Object(U.isFiniteNumber)(m)?m:e,a=x(o),p=k.default.parseLevelPlaylist(r.data,u,n,a,e);if(!p.fragments.length){l.trigger(L.Events.ERROR,{type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:u,reason:"no fragments found in level",level:typeof o.level=="number"?o.level:void 0});return}if(c===w.PlaylistContextType.MANIFEST){var g={attrs:new v.AttrList({}),bitrate:0,details:p,name:"",url:u};l.trigger(L.Events.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:u,stats:i,networkDetails:f,sessionData:null})}if(i.parsing.end=performance.now(),p.needSidxRanges){var T,P=(T=p.fragments[0].initSegment)===null||T===void 0?void 0:T.url;this.load({url:P,isSidxRequest:!0,type:c,level:m,levelDetails:p,id:h,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}o.levelDetails=p,this.handlePlaylistLoaded(r,i,o,f)},y.handleSidxRequest=function(r,i){var o=Object(O.parseSegmentIndex)(new Uint8Array(r.data));if(!o)return;var f=o.references,l=i.levelDetails;f.forEach(function(h,m){var c=h.info,u=l.fragments[m];u.byteRange.length===0&&u.setByteRange(String(1+c.end-c.start)+"@"+String(c.start)),u.initSegment&&u.initSegment.setByteRange(String(o.moovEndOffset)+"@0")})},y.handleManifestParsingError=function(r,i,o,f){this.hls.trigger(L.Events.ERROR,{type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:i.type===w.PlaylistContextType.MANIFEST,url:r.url,reason:o,response:r,context:i,networkDetails:f})},y.handleNetworkError=function(r,i,o,f){o===void 0&&(o=!1),B.logger.warn("[playlist-loader]: A network "+(o?"timeout":"error")+" occurred while loading "+r.type+" level: "+r.level+" id: "+r.id+' group-id: "'+r.groupId+'"');var l=_.ErrorDetails.UNKNOWN,h=!1,m=this.getInternalLoader(r);switch(r.type){case w.PlaylistContextType.MANIFEST:l=o?_.ErrorDetails.MANIFEST_LOAD_TIMEOUT:_.ErrorDetails.MANIFEST_LOAD_ERROR,h=!0;break;case w.PlaylistContextType.LEVEL:l=o?_.ErrorDetails.LEVEL_LOAD_TIMEOUT:_.ErrorDetails.LEVEL_LOAD_ERROR,h=!1;break;case w.PlaylistContextType.AUDIO_TRACK:l=o?_.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:_.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case w.PlaylistContextType.SUBTITLE_TRACK:l=o?_.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:_.ErrorDetails.SUBTITLE_LOAD_ERROR,h=!1;break}m&&this.resetInternalLoader(r.type);var c={type:_.ErrorTypes.NETWORK_ERROR,details:l,fatal:h,url:r.url,loader:m,context:r,networkDetails:i};f&&(c.response=f),this.hls.trigger(L.Events.ERROR,c)},y.handlePlaylistLoaded=function(r,i,o,f){var l=o.type,h=o.level,m=o.id,c=o.groupId,u=o.loader,e=o.levelDetails,n=o.deliveryDirectives;if(!(e!=null&&e.targetduration)){this.handleManifestParsingError(r,o,"invalid target duration",f);return}if(!u)return;e.live&&(u.getCacheAge&&(e.ageHeader=u.getCacheAge()||0),(!u.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0));switch(l){case w.PlaylistContextType.MANIFEST:case w.PlaylistContextType.LEVEL:this.hls.trigger(L.Events.LEVEL_LOADED,{details:e,level:h||0,id:m||0,stats:i,networkDetails:f,deliveryDirectives:n});break;case w.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,{details:e,id:m||0,groupId:c||"",stats:i,networkDetails:f,deliveryDirectives:n});break;case w.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(L.Events.SUBTITLE_TRACK_LOADED,{details:e,id:m||0,groupId:c||"",stats:i,networkDetails:f,deliveryDirectives:n});break}},b}();N.default=E},"./src/polyfills/number.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"isFiniteNumber",function(){return U}),S.d(N,"MAX_SAFE_INTEGER",function(){return L});var U=Number.isFinite||function(_){return typeof _=="number"&&isFinite(_)},L=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(he,N,S){"use strict";S.r(N);var U=function(){function L(){}return L.getSilentFrame=function(B,O){switch(B){case"mp4a.40.2":if(O===1)return new Uint8Array([0,200,0,128,35,128]);if(O===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(O===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(O===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(O===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(O===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(O===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(O===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(O===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},L}();N.default=U},"./src/remux/mp4-generator.ts":function(he,N,S){"use strict";S.r(N);var U=Math.pow(2,32)-1,L=function(){function _(){}return _.init=function(){_.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 O;for(O in _.types)_.types.hasOwnProperty(O)&&(_.types[O]=[O.charCodeAt(0),O.charCodeAt(1),O.charCodeAt(2),O.charCodeAt(3)]);var k=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]),w=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]);_.HDLR_TYPES={video:k,audio:w};var v=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),x=new Uint8Array([0,0,0,0,0,0,0,0]);_.STTS=_.STSC=_.STCO=x,_.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),_.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),_.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),_.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var C=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),b=new Uint8Array([0,0,0,1]);_.FTYP=_.box(_.types.ftyp,C,b,C,E),_.DINF=_.box(_.types.dinf,_.box(_.types.dref,v))},_.box=function(O){for(var k=8,w=arguments.length,v=new Array(w>1?w-1:0),x=1;x<w;x++)v[x-1]=arguments[x];for(var C=v.length,E=C;C--;)k+=v[C].byteLength;var b=new Uint8Array(k);for(b[0]=k>>24&255,b[1]=k>>16&255,b[2]=k>>8&255,b[3]=k&255,b.set(O,4),C=0,k=8;C<E;C++)b.set(v[C],k),k+=v[C].byteLength;return b},_.hdlr=function(O){return _.box(_.types.hdlr,_.HDLR_TYPES[O])},_.mdat=function(O){return _.box(_.types.mdat,O)},_.mdhd=function(O,k){k*=O;var w=Math.floor(k/(U+1)),v=Math.floor(k%(U+1));return _.box(_.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,w>>24,w>>16&255,w>>8&255,w&255,v>>24,v>>16&255,v>>8&255,v&255,85,196,0,0]))},_.mdia=function(O){return _.box(_.types.mdia,_.mdhd(O.timescale,O.duration),_.hdlr(O.type),_.minf(O))},_.mfhd=function(O){return _.box(_.types.mfhd,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255]))},_.minf=function(O){return O.type==="audio"?_.box(_.types.minf,_.box(_.types.smhd,_.SMHD),_.DINF,_.stbl(O)):_.box(_.types.minf,_.box(_.types.vmhd,_.VMHD),_.DINF,_.stbl(O))},_.moof=function(O,k,w){return _.box(_.types.moof,_.mfhd(O),_.traf(w,k))},_.moov=function(O){for(var k=O.length,w=[];k--;)w[k]=_.trak(O[k]);return _.box.apply(null,[_.types.moov,_.mvhd(O[0].timescale,O[0].duration)].concat(w).concat(_.mvex(O)))},_.mvex=function(O){for(var k=O.length,w=[];k--;)w[k]=_.trex(O[k]);return _.box.apply(null,[_.types.mvex].concat(w))},_.mvhd=function(O,k){k*=O;var w=Math.floor(k/(U+1)),v=Math.floor(k%(U+1)),x=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,w>>24,w>>16&255,w>>8&255,w&255,v>>24,v>>16&255,v>>8&255,v&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 _.box(_.types.mvhd,x)},_.sdtp=function(O){var k=O.samples||[],w=new Uint8Array(4+k.length),v,x;for(v=0;v<k.length;v++)x=k[v].flags,w[v+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return _.box(_.types.sdtp,w)},_.stbl=function(O){return _.box(_.types.stbl,_.stsd(O),_.box(_.types.stts,_.STTS),_.box(_.types.stsc,_.STSC),_.box(_.types.stsz,_.STSZ),_.box(_.types.stco,_.STCO))},_.avc1=function(O){var k=[],w=[],v,x,C;for(v=0;v<O.sps.length;v++)x=O.sps[v],C=x.byteLength,k.push(C>>>8&255),k.push(C&255),k=k.concat(Array.prototype.slice.call(x));for(v=0;v<O.pps.length;v++)x=O.pps[v],C=x.byteLength,w.push(C>>>8&255),w.push(C&255),w=w.concat(Array.prototype.slice.call(x));var E=_.box(_.types.avcC,new Uint8Array([1,k[3],k[4],k[5],252|3,224|O.sps.length].concat(k).concat([O.pps.length]).concat(w))),b=O.width,y=O.height,d=O.pixelRatio[0],r=O.pixelRatio[1];return _.box(_.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,b>>8&255,b&255,y>>8&255,y&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]),E,_.box(_.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),_.box(_.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,r>>24,r>>16&255,r>>8&255,r&255])))},_.esds=function(O){var k=O.config.length;return new Uint8Array([0,0,0,0,3,23+k,0,1,0,4,15+k,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([k]).concat(O.config).concat([6,1,2]))},_.mp4a=function(O){var k=O.samplerate;return _.box(_.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,O.channelCount,0,16,0,0,0,0,k>>8&255,k&255,0,0]),_.box(_.types.esds,_.esds(O)))},_.mp3=function(O){var k=O.samplerate;return _.box(_.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,O.channelCount,0,16,0,0,0,0,k>>8&255,k&255,0,0]))},_.stsd=function(O){return O.type==="audio"?!O.isAAC&&O.codec==="mp3"?_.box(_.types.stsd,_.STSD,_.mp3(O)):_.box(_.types.stsd,_.STSD,_.mp4a(O)):_.box(_.types.stsd,_.STSD,_.avc1(O))},_.tkhd=function(O){var k=O.id,w=O.duration*O.timescale,v=O.width,x=O.height,C=Math.floor(w/(U+1)),E=Math.floor(w%(U+1));return _.box(_.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,k>>24&255,k>>16&255,k>>8&255,k&255,0,0,0,0,C>>24,C>>16&255,C>>8&255,C&255,E>>24,E>>16&255,E>>8&255,E&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,v>>8&255,v&255,0,0,x>>8&255,x&255,0,0]))},_.traf=function(O,k){var w=_.sdtp(O),v=O.id,x=Math.floor(k/(U+1)),C=Math.floor(k%(U+1));return _.box(_.types.traf,_.box(_.types.tfhd,new Uint8Array([0,0,0,0,v>>24,v>>16&255,v>>8&255,v&255])),_.box(_.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,C>>24,C>>16&255,C>>8&255,C&255])),_.trun(O,w.length+16+20+8+16+8+8),w)},_.trak=function(O){return O.duration=O.duration||4294967295,_.box(_.types.trak,_.tkhd(O),_.mdia(O))},_.trex=function(O){var k=O.id;return _.box(_.types.trex,new Uint8Array([0,0,0,0,k>>24,k>>16&255,k>>8&255,k&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},_.trun=function(O,k){var w=O.samples||[],v=w.length,x=12+16*v,C=new Uint8Array(x),E,b,y,d,r,i;for(k+=8+x,C.set([0,0,15,1,v>>>24&255,v>>>16&255,v>>>8&255,v&255,k>>>24&255,k>>>16&255,k>>>8&255,k&255],0),E=0;E<v;E++)b=w[E],y=b.duration,d=b.size,r=b.flags,i=b.cts,C.set([y>>>24&255,y>>>16&255,y>>>8&255,y&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,r.isLeading<<2|r.dependsOn,r.isDependedOn<<6|r.hasRedundancy<<4|r.paddingValue<<1|r.isNonSync,r.degradPrio&240<<8,r.degradPrio&15,i>>>24&255,i>>>16&255,i>>>8&255,i&255],12+16*E);return _.box(_.types.trun,C)},_.initSegment=function(O){_.types||_.init();var k=_.moov(O),w=new Uint8Array(_.FTYP.byteLength+k.byteLength);return w.set(_.FTYP),w.set(k,_.FTYP.byteLength),w},_}();L.types=void 0,L.HDLR_TYPES=void 0,L.STTS=void 0,L.STSC=void 0,L.STCO=void 0,L.STSZ=void 0,L.VMHD=void 0,L.SMHD=void 0,L.STSD=void 0,L.FTYP=void 0,L.DINF=void 0,N.default=L},"./src/remux/mp4-remuxer.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return i}),S.d(N,"normalizePts",function(){return o});var U=S("./src/polyfills/number.ts"),L=S("./src/remux/aac-helper.ts"),_=S("./src/remux/mp4-generator.ts"),B=S("./src/events.ts"),O=S("./src/errors.ts"),k=S("./src/utils/logger.ts"),w=S("./src/types/loader.ts"),v=S("./src/utils/timescale-conversion.ts");function x(){return x=Object.assign||function(m){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var e in u)Object.prototype.hasOwnProperty.call(u,e)&&(m[e]=u[e])}return m},x.apply(this,arguments)}var C=10*1e3,E=1024,b=1152,y=null,d=null,r=!1,i=function(){function m(u,e,n,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=u,this.config=e,this.typeSupported=n,this.ISGenerated=!1,y===null){var p=navigator.userAgent||"",g=p.match(/Chrome\/(\d+)/i);y=g?parseInt(g[1]):0}if(d===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);d=T?parseInt(T[1]):0}r=!!y&&y<75||!!d&&d<600}var c=m.prototype;return c.destroy=function(){},c.resetTimeStamp=function(e){k.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},c.resetNextTimestamp=function(){k.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},c.resetInitSegment=function(){k.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},c.getVideoStartPts=function(e){var n=!1,a=e.reduce(function(p,g){var T=g.pts-p;return T<-4294967296?(n=!0,o(p,g.pts)):T>0?p:g.pts},e[0].pts);return n&&k.logger.debug("PTS rollover detected"),a},c.remux=function(e,n,a,p,g,T,P,I){var F,W,z,X,K,J,ne=g,re=g,be=e.pid>-1,oe=n.pid>-1,ue=n.samples.length,de=e.samples.length>0,ce=ue>1,te=(!be||de)&&(!oe||ce)||this.ISGenerated||P;if(te){this.ISGenerated||(z=this.generateIS(e,n,g));var $=this.isVideoContiguous,Ae=-1;if(ce&&(Ae=f(n.samples),!$&&this.config.forceKeyFrameOnDiscontinuity))if(J=!0,Ae>0){k.logger.warn("[mp4-remuxer]: Dropped "+Ae+" out of "+ue+" video samples due to a missing keyframe");var Fe=this.getVideoStartPts(n.samples);n.samples=n.samples.slice(Ae),n.dropped+=Ae,re+=(n.samples[0].pts-Fe)/(n.timescale||9e4)}else Ae===-1&&(k.logger.warn("[mp4-remuxer]: No keyframe found out of "+ue+" video samples"),J=!1);if(this.ISGenerated){if(de&&ce){var De=this.getVideoStartPts(n.samples),Ue=o(e.samples[0].pts,De)-De,Re=Ue/n.inputTimeScale;ne+=Math.max(0,Re),re+=Math.max(0,-Re)}if(de){if(e.samplerate||(k.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(e,n,g)),W=this.remuxAudio(e,ne,this.isAudioContiguous,T,oe||ce||I===w.PlaylistLevelType.AUDIO?re:void 0),ce){var fe=W?W.endPTS-W.startPTS:0;n.inputTimeScale||(k.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(e,n,g)),F=this.remuxVideo(n,re,$,fe)}}else ce&&(F=this.remuxVideo(n,re,$,0));F&&(F.firstKeyFrame=Ae,F.independent=Ae!==-1)}}return this.ISGenerated&&(a.samples.length&&(K=this.remuxID3(a,g)),p.samples.length&&(X=this.remuxText(p,g))),{audio:W,video:F,initSegment:z,independent:J,text:X,id3:K}},c.generateIS=function(e,n,a){var p=e.samples,g=n.samples,T=this.typeSupported,P={},I=!Object(U.isFiniteNumber)(this._initPTS),F="audio/mp4",W,z,X;if(I&&(W=z=Infinity),e.config&&p.length&&(e.timescale=e.samplerate,e.isAAC||(T.mpeg?(F="audio/mpeg",e.codec=""):T.mp3&&(e.codec="mp3")),P.audio={id:"audio",container:F,codec:e.codec,initSegment:!e.isAAC&&T.mpeg?new Uint8Array(0):_.default.initSegment([e]),metadata:{channelCount:e.channelCount}},I&&(X=e.inputTimeScale,W=z=p[0].pts-Math.round(X*a))),n.sps&&n.pps&&g.length&&(n.timescale=n.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:n.codec,initSegment:_.default.initSegment([n]),metadata:{width:n.width,height:n.height}},I)){X=n.inputTimeScale;var K=this.getVideoStartPts(g),J=Math.round(X*a);z=Math.min(z,o(g[0].dts,K)-J),W=Math.min(W,K-J)}if(Object.keys(P).length)return this.ISGenerated=!0,I&&(this._initPTS=W,this._initDTS=z),{tracks:P,initPTS:W,timescale:X}},c.remuxVideo=function(e,n,a,p){var g=e.inputTimeScale,T=e.samples,P=[],I=T.length,F=this._initPTS,W=this.nextAvcDts,z=8,X,K,J,ne=Number.POSITIVE_INFINITY,re=Number.NEGATIVE_INFINITY,be=0,oe=!1;if(!a||W===null){var ue=n*g,de=T[0].pts-o(T[0].dts,T[0].pts);W=ue-de}for(var ce=0;ce<I;ce++){var te=T[ce];if(te.pts=o(te.pts-F,W),te.dts=o(te.dts-F,W),te.dts>te.pts){var $=9e4*.2;be=Math.max(Math.min(be,te.pts-te.dts),-1*$)}te.dts<T[ce>0?ce-1:ce].dts&&(oe=!0)}oe&&T.sort(function(Xe,$e){var He=Xe.dts-$e.dts,Ze=Xe.pts-$e.pts;return He||Ze}),K=T[0].dts,J=T[T.length-1].dts;var Ae=Math.round((J-K)/(I-1));if(be<0){if(be<Ae*-2){k.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(v.toMsFromMpegTsClock)(-Ae,!0)+" ms");for(var Fe=be,De=0;De<I;De++)T[De].dts=Fe=Math.max(Fe,T[De].pts-Ae),T[De].pts=Math.max(Fe,T[De].pts)}else{k.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(v.toMsFromMpegTsClock)(be,!0)+" ms to overcome this issue");for(var Ue=0;Ue<I;Ue++)T[Ue].dts=T[Ue].dts+be}K=T[0].dts}if(a){var Re=K-W,fe=Re>Ae,Ce=Re<-1;if(fe||Ce){fe?k.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(Re,!0)+" ms ("+Re+"dts) hole between fragments detected, filling it"):k.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(-Re,!0)+" ms ("+Re+"dts) overlapping between fragments detected"),K=W;var Se=T[0].pts-Re;T[0].dts=K,T[0].pts=Se,k.logger.log("Video: First PTS/DTS adjusted: "+Object(v.toMsFromMpegTsClock)(Se,!0)+"/"+Object(v.toMsFromMpegTsClock)(K,!0)+", delta: "+Object(v.toMsFromMpegTsClock)(Re,!0)+" ms")}}r&&(K=Math.max(0,K));for(var me=0,Te=0,pe=0;pe<I;pe++){for(var Ee=T[pe],Ge=Ee.units,Le=Ge.length,ke=0,Ne=0;Ne<Le;Ne++)ke+=Ge[Ne].data.length;Te+=ke,me+=Le,Ee.length=ke,Ee.dts=Math.max(Ee.dts,K),Ee.pts=Math.max(Ee.pts,Ee.dts,0),ne=Math.min(Ee.pts,ne),re=Math.max(Ee.pts,re)}J=T[I-1].dts;var ee=Te+4*me+8,Be;try{Be=new Uint8Array(ee)}catch(Xe){this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:O.ErrorTypes.MUX_ERROR,details:O.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ee,reason:"fail allocating video mdat "+ee});return}var _e=new DataView(Be.buffer);_e.setUint32(0,ee),Be.set(_.default.types.mdat,4);for(var we=0;we<I;we++){for(var We=T[we],Pe=We.units,le=0,xe=0,q=Pe.length;xe<q;xe++){var Q=Pe[xe],Z=Q.data,j=Q.data.byteLength;_e.setUint32(z,j),z+=4,Be.set(Z,z),z+=j,le+=4+j}if(we<I-1)X=T[we+1].dts-We.dts;else{var H=this.config,G=We.dts-T[we>0?we-1:we].dts;if(H.stretchShortVideoTrack&&this.nextAudioPts!==null){var V=Math.floor(H.maxBufferHole*g),ie=(p?ne+p*g:this.nextAudioPts)-We.pts;ie>V?(X=ie-G,X<0&&(X=G),k.logger.log("[mp4-remuxer]: It is approximately "+ie/90+" ms to the next segment; using duration "+X/90+" ms for the last video frame.")):X=G}else X=G}var se=Math.round(We.pts-We.dts);P.push(new l(We.key,X,le,se))}if(P.length&&y&&y<70){var ve=P[0].flags;ve.dependsOn=2,ve.isNonSync=0}console.assert(X!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=W=J+X,this.isVideoContiguous=!0;var Oe=_.default.moof(e.sequenceNumber++,K,x({},e,{samples:P})),je="video",Me={data1:Oe,data2:Be,startPTS:ne/g,endPTS:(re+X)/g,startDTS:K/g,endDTS:W/g,type:je,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(Be.length,"MDAT length must not be zero"),Me},c.remuxAudio=function(e,n,a,p,g){var T=e.inputTimeScale,P=e.samplerate?e.samplerate:T,I=T/P,F=e.isAAC?E:b,W=F*I,z=this._initPTS,X=!e.isAAC&&this.typeSupported.mpeg,K=[],J=e.samples,ne=X?0:8,re=this.nextAudioPts||-1,be=n*T;if(this.isAudioContiguous=a=a||J.length&&re>0&&(p&&Math.abs(be-re)<9e3||Math.abs(o(J[0].pts-z,be)-re)<20*W),J.forEach(function(Z){Z.pts=o(Z.pts-z,be)}),!a||re<0){if(J=J.filter(function(Z){return Z.pts>=0}),!J.length)return;g===0?re=0:p?re=Math.max(0,be):re=J[0].pts}if(e.isAAC)for(var oe=g!==void 0,ue=this.config.maxAudioFramesDrift,de=0,ce=re;de<J.length;de++){var te=J[de],$=te.pts,Ae=$-ce,Fe=Math.abs(1e3*Ae/T);if(Ae<=-ue*W&&oe)de===0&&(k.logger.warn("Audio frame @ "+($/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Ae/T)+" ms."),this.nextAudioPts=re=ce=$);else if(Ae>=ue*W&&Fe<C&&oe){var De=Math.round(Ae/W);ce=$-De*W,ce<0&&(De--,ce+=W),de===0&&(this.nextAudioPts=re=ce),k.logger.warn("[mp4-remuxer]: Injecting "+De+" audio frame @ "+(ce/T).toFixed(3)+"s due to "+Math.round(1e3*Ae/T)+" ms gap.");for(var Ue=0;Ue<De;Ue++){var Re=Math.max(ce,0),fe=L.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);fe||(k.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),fe=te.unit.subarray()),J.splice(de,0,{unit:fe,pts:Re}),ce+=W,de++}}te.pts=ce,ce+=W}for(var Ce=null,Se=null,me,Te=0,pe=J.length;pe--;)Te+=J[pe].unit.byteLength;for(var Ee=0,Ge=J.length;Ee<Ge;Ee++){var Le=J[Ee],ke=Le.unit,Ne=Le.pts;if(Se!==null){var ee=K[Ee-1];ee.duration=Math.round((Ne-Se)/I)}else if(a&&e.isAAC&&(Ne=re),Ce=Ne,Te>0){Te+=ne;try{me=new Uint8Array(Te)}catch(Z){this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:O.ErrorTypes.MUX_ERROR,details:O.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Te,reason:"fail allocating audio mdat "+Te});return}if(!X){var Be=new DataView(me.buffer);Be.setUint32(0,Te),me.set(_.default.types.mdat,4)}}else return;me.set(ke,ne);var _e=ke.byteLength;ne+=_e,K.push(new l(!0,F,_e,0)),Se=Ne}var we=K.length;if(!we)return;var We=K[K.length-1];this.nextAudioPts=re=Se+I*We.duration;var Pe=X?new Uint8Array(0):_.default.moof(e.sequenceNumber++,Ce/I,x({},e,{samples:K}));e.samples=[];var le=Ce/T,xe=re/T,q="audio",Q={data1:Pe,data2:me,startPTS:le,endPTS:xe,startDTS:le,endDTS:xe,type:q,hasAudio:!0,hasVideo:!1,nb:we};return this.isAudioContiguous=!0,console.assert(me.length,"MDAT length must not be zero"),Q},c.remuxEmptyAudio=function(e,n,a,p){var g=e.inputTimeScale,T=e.samplerate?e.samplerate:g,P=g/T,I=this.nextAudioPts,F=(I!==null?I:p.startDTS*g)+this._initDTS,W=p.endDTS*g+this._initDTS,z=P*E,X=Math.ceil((W-F)/z),K=L.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(k.logger.warn("[mp4-remuxer]: remux empty Audio"),!K){k.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var J=[],ne=0;ne<X;ne++){var re=F+ne*z;J.push({unit:K,pts:re,dts:re})}return e.samples=J,this.remuxAudio(e,n,a,!1)},c.remuxID3=function(e,n){var a=e.samples.length;if(!a)return;for(var p=e.inputTimeScale,g=this._initPTS,T=this._initDTS,P=0;P<a;P++){var I=e.samples[P];I.pts=o(I.pts-g,n*p)/p,I.dts=o(I.dts-T,n*p)/p}var F=e.samples;return e.samples=[],{samples:F}},c.remuxText=function(e,n){var a=e.samples.length;if(!a)return;for(var p=e.inputTimeScale,g=this._initPTS,T=0;T<a;T++){var P=e.samples[T];P.pts=o(P.pts-g,n*p)/p}e.samples.sort(function(F,W){return F.pts-W.pts});var I=e.samples;return e.samples=[],{samples:I}},m}();function o(m,c){var u;if(c===null)return m;for(c<m?u=-8589934592:u=8589934592;Math.abs(m-c)>4294967296;)m+=u;return m}function f(m){for(var c=0;c<m.length;c++)if(m[c].key)return c;return-1}var l=function(c,u,e,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=u,this.size=e,this.cts=n,this.flags=new h(c)},h=function(c){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=c?2:1,this.isNonSync=c?0:1}},"./src/remux/passthrough-remuxer.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/polyfills/number.ts"),L=S("./src/utils/mp4-tools.ts"),_=S("./src/loader/fragment.ts"),B=S("./src/utils/logger.ts"),O=function(){function v(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var x=v.prototype;return x.destroy=function(){},x.resetTimeStamp=function(E){this.initPTS=E,this.lastEndDTS=null},x.resetNextTimestamp=function(){this.lastEndDTS=null},x.resetInitSegment=function(E,b,y){this.audioCodec=b,this.videoCodec=y,this.generateInitSegment(E),this.emitInitSegment=!0},x.generateInitSegment=function(E){var b=this.audioCodec,y=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var d=this.initData=Object(L.parseInitSegment)(E);b||(b=w(d.audio,_.ElementaryStreamTypes.AUDIO)),y||(y=w(d.video,_.ElementaryStreamTypes.VIDEO));var r={};d.audio&&d.video?r.audiovideo={container:"video/mp4",codec:b+","+y,initSegment:E,id:"main"}:d.audio?r.audio={container:"audio/mp4",codec:b,initSegment:E,id:"audio"}:d.video?r.video={container:"video/mp4",codec:y,initSegment:E,id:"main"}:B.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r},x.remux=function(E,b,y,d,r){var i=this.initPTS,o=this.lastEndDTS,f={audio:void 0,video:void 0,text:d,id3:y,initSegment:void 0};Object(U.isFiniteNumber)(o)||(o=this.lastEndDTS=r||0);var l=b.samples;if(!l||!l.length)return f;var h={initPTS:void 0,timescale:1},m=this.initData;if((!m||!m.length)&&(this.generateInitSegment(l),m=this.initData),!m||!m.length)return B.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1),Object(U.isFiniteNumber)(i)||(this.initPTS=h.initPTS=i=k(m,l,o));var c=Object(L.getDuration)(l,m),u=o,e=c+u;Object(L.offsetStartDTS)(m,l,i),c>0?this.lastEndDTS=e:(B.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var n=!!m.audio,a=!!m.video,p="";n&&(p+="audio"),a&&(p+="video");var g={data1:l,startPTS:u,startDTS:u,endPTS:e,endDTS:e,type:p,hasAudio:n,hasVideo:a,nb:1,dropped:0};return f.audio=g.type==="audio"?g:void 0,f.video=g.type!=="audio"?g:void 0,f.text=d,f.id3=y,f.initSegment=h,f},v}(),k=function(x,C,E){return Object(L.getStartDTS)(x,C)-E};function w(v,x){var C=v==null?void 0:v.codec;return C&&C.length>4?C:C==="hvc1"?"hvc1.1.c.L120.90":C==="av01"?"av01.0.04M.08":C==="avc1"||x===_.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}N.default=O},"./src/task-loop.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return U});var U=function(){function L(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var _=L.prototype;return _.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},_.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},_.onHandlerDestroyed=function(){},_.hasInterval=function(){return!!this._tickInterval},_.hasNextTick=function(){return!!this._tickTimer},_.setInterval=function(O){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,O),!0)},_.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},_.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},_.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},_.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},_.doTick=function(){},L}()},"./src/types/cmcd.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"CMCDVersion",function(){return U}),S.d(N,"CMCDObjectType",function(){return L}),S.d(N,"CMCDStreamingFormat",function(){return _}),S.d(N,"CMCDStreamType",function(){return B});var U=1,L;(function(O){O.MANIFEST="m",O.AUDIO="a",O.VIDEO="v",O.MUXED="av",O.INIT="i",O.CAPTION="c",O.TIMED_TEXT="tt",O.KEY="k",O.OTHER="o"})(L||(L={}));var _;(function(O){O.DASH="d",O.HLS="h",O.SMOOTH="s",O.OTHER="o"})(_||(_={}));var B;(function(O){O.VOD="v",O.LIVE="l"})(B||(B={}))},"./src/types/level.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"HlsSkip",function(){return _}),S.d(N,"getSkipValue",function(){return B}),S.d(N,"HlsUrlParameters",function(){return O}),S.d(N,"Level",function(){return k});function U(w,v){for(var x=0;x<v.length;x++){var C=v[x];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(w,C.key,C)}}function L(w,v,x){return v&&U(w.prototype,v),x&&U(w,x),w}var _;(function(w){w.No="",w.Yes="YES",w.v2="v2"})(_||(_={}));function B(w,v){var x=w.canSkipUntil,C=w.canSkipDateRanges,E=w.endSN,b=v!==void 0?v-E:0;return x&&b<x?C?_.v2:_.Yes:_.No}var O=function(){function w(x,C,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=x,this.part=C,this.skip=E}var v=w.prototype;return v.addDirectives=function(C){var E=new self.URL(C);return this.msn!==void 0&&E.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&E.searchParams.set("_HLS_part",this.part.toString()),this.skip&&E.searchParams.set("_HLS_skip",this.skip),E.toString()},w}(),k=function(){function w(v){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[v.url],this.attrs=v.attrs,this.bitrate=v.bitrate,v.details&&(this.details=v.details),this.id=v.id||0,this.name=v.name,this.width=v.width||0,this.height=v.height||0,this.audioCodec=v.audioCodec,this.videoCodec=v.videoCodec,this.unknownCodecs=v.unknownCodecs,this.codecSet=[v.videoCodec,v.audioCodec].filter(function(x){return x}).join(",").replace(/\.[^.,]+/g,"")}return L(w,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(x){var C=x%this.url.length;this._urlId!==C&&(this.details=void 0,this._urlId=C)}}]),w}()},"./src/types/loader.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"PlaylistContextType",function(){return U}),S.d(N,"PlaylistLevelType",function(){return L});var U;(function(_){_.MANIFEST="manifest",_.LEVEL="level",_.AUDIO_TRACK="audioTrack",_.SUBTITLE_TRACK="subtitleTrack"})(U||(U={}));var L;(function(_){_.MAIN="main",_.AUDIO="audio",_.SUBTITLE="subtitle"})(L||(L={}))},"./src/types/transmuxer.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"ChunkMetadata",function(){return U});var U=function(B,O,k,w,v,x){w===void 0&&(w=0),v===void 0&&(v=-1),x===void 0&&(x=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=L(),this.buffering={audio:L(),video:L(),audiovideo:L()},this.level=B,this.sn=O,this.id=k,this.size=w,this.part=v,this.partial=x};function L(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"AttrList",function(){return _});var U=/^(\d+)x(\d+)$/,L=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,_=function(){function B(k){typeof k=="string"&&(k=B.parseAttrList(k));for(var w in k)k.hasOwnProperty(w)&&(this[w]=k[w])}var O=B.prototype;return O.decimalInteger=function(w){var v=parseInt(this[w],10);return v>Number.MAX_SAFE_INTEGER?Infinity:v},O.hexadecimalInteger=function(w){if(this[w]){var v=(this[w]||"0x").slice(2);v=(v.length&1?"0":"")+v;for(var x=new Uint8Array(v.length/2),C=0;C<v.length/2;C++)x[C]=parseInt(v.slice(C*2,C*2+2),16);return x}else return null},O.hexadecimalIntegerAsNumber=function(w){var v=parseInt(this[w],16);return v>Number.MAX_SAFE_INTEGER?Infinity:v},O.decimalFloatingPoint=function(w){return parseFloat(this[w])},O.optionalFloat=function(w,v){var x=this[w];return x?parseFloat(x):v},O.enumeratedString=function(w){return this[w]},O.bool=function(w){return this[w]==="YES"},O.decimalResolution=function(w){var v=U.exec(this[w]);return v===null?void 0:{width:parseInt(v[1],10),height:parseInt(v[2],10)}},B.parseAttrList=function(w){var v,x={},C='"';for(L.lastIndex=0;(v=L.exec(w))!==null;){var E=v[2];E.indexOf(C)===0&&E.lastIndexOf(C)===E.length-1&&(E=E.slice(1,-1)),x[v[1]]=E}return x},B}()},"./src/utils/binary-search.ts":function(he,N,S){"use strict";S.r(N);var U={search:function(_,B){for(var O=0,k=_.length-1,w=null,v=null;O<=k;){w=(O+k)/2|0,v=_[w];var x=B(v);if(x>0)O=w+1;else if(x<0)k=w-1;else return v}return null}};N.default=U},"./src/utils/buffer-helper.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"BufferHelper",function(){return _});var U=S("./src/utils/logger.ts"),L={length:0,start:function(){return 0},end:function(){return 0}},_=function(){function B(){}return B.isBuffered=function(k,w){try{if(k){for(var v=B.getBuffered(k),x=0;x<v.length;x++)if(w>=v.start(x)&&w<=v.end(x))return!0}}catch(C){}return!1},B.bufferInfo=function(k,w,v){try{if(k){var x=B.getBuffered(k),C=[],E;for(E=0;E<x.length;E++)C.push({start:x.start(E),end:x.end(E)});return this.bufferedInfo(C,w,v)}}catch(b){}return{len:0,start:w,end:w,nextStart:void 0}},B.bufferedInfo=function(k,w,v){w=Math.max(0,w),k.sort(function(h,m){var c=h.start-m.start;return c||m.end-h.end});var x=[];if(v)for(var C=0;C<k.length;C++){var E=x.length;if(E){var b=x[E-1].end;k[C].start-b<v?k[C].end>b&&(x[E-1].end=k[C].end):x.push(k[C])}else x.push(k[C])}else x=k;for(var y=0,d,r=w,i=w,o=0;o<x.length;o++){var f=x[o].start,l=x[o].end;if(w+v>=f&&w<l)r=f,i=l,y=i-w;else if(w+v<f){d=f;break}}return{len:y,start:r||0,end:i||0,nextStart:d}},B.getBuffered=function(k){try{return k.buffered}catch(w){return U.logger.log("failed to get media.buffered",w),L}},B}()},"./src/utils/cea-608-parser.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"Row",function(){return i}),S.d(N,"CaptionScreen",function(){return o});var U=S("./src/utils/logger.ts"),L={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},_=function(e){var n=e;return L.hasOwnProperty(e)&&(n=L[e]),String.fromCharCode(n)},B=15,O=100,k={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},w={17:2,18:4,21:6,22:8,23:10,19:13,20:15},v={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},x={25:2,26:4,29:6,30:8,31:10,27:13,28:15},C=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],E;(function(u){u[u.ERROR=0]="ERROR",u[u.TEXT=1]="TEXT",u[u.WARNING=2]="WARNING",u[u.INFO=2]="INFO",u[u.DEBUG=3]="DEBUG",u[u.DATA=3]="DATA"})(E||(E={}));var b=function(){function u(){this.time=null,this.verboseLevel=E.ERROR}var e=u.prototype;return e.log=function(a,p){this.verboseLevel>=a&&U.logger.log(this.time+" ["+a+"] "+p)},u}(),y=function(e){for(var n=[],a=0;a<e.length;a++)n.push(e[a].toString(16));return n},d=function(){function u(n,a,p,g,T){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=n||"white",this.underline=a||!1,this.italics=p||!1,this.background=g||"black",this.flash=T||!1}var e=u.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(a){for(var p=["foreground","underline","italics","background","flash"],g=0;g<p.length;g++){var T=p[g];a.hasOwnProperty(T)&&(this[T]=a[T])}},e.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},e.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},e.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},e.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},u}(),r=function(){function u(n,a,p,g,T,P){this.uchar=void 0,this.penState=void 0,this.uchar=n||" ",this.penState=new d(a,p,g,T,P)}var e=u.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(a,p){this.uchar=a,this.penState.copy(p)},e.setPenState=function(a){this.penState.copy(a)},e.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},e.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},e.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},u}(),i=function(){function u(n){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<O;a++)this.chars.push(new r);this.logger=n,this.pos=0,this.currPenState=new d}var e=u.prototype;return e.equals=function(a){for(var p=!0,g=0;g<O;g++)if(!this.chars[g].equals(a.chars[g])){p=!1;break}return p},e.copy=function(a){for(var p=0;p<O;p++)this.chars[p].copy(a.chars[p])},e.isEmpty=function(){for(var a=!0,p=0;p<O;p++)if(!this.chars[p].isEmpty()){a=!1;break}return a},e.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(E.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>O&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=O)},e.moveCursor=function(a){var p=this.pos+a;if(a>1)for(var g=this.pos+1;g<p+1;g++)this.chars[g].setPenState(this.currPenState);this.setCursor(p)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(a){a>=144&&this.backSpace();var p=_(a);if(this.pos>=O){this.logger.log(E.ERROR,"Cannot insert "+a.toString(16)+" ("+p+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(p,this.currPenState),this.moveCursor(1)},e.clearFromPos=function(a){var p;for(p=a;p<O;p++)this.chars[p].reset()},e.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function(){this.clearFromPos(this.pos)},e.getTextString=function(){for(var a=[],p=!0,g=0;g<O;g++){var T=this.chars[g].uchar;T!==" "&&(p=!1),a.push(T)}return p?"":a.join("")},e.setPenStyles=function(a){this.currPenState.setStyles(a);var p=this.chars[this.pos];p.setPenState(this.currPenState)},u}(),o=function(){function u(n){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<B;a++)this.rows.push(new i(n));this.logger=n,this.currRow=B-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var e=u.prototype;return e.reset=function(){for(var a=0;a<B;a++)this.rows[a].clear();this.currRow=B-1},e.equals=function(a){for(var p=!0,g=0;g<B;g++)if(!this.rows[g].equals(a.rows[g])){p=!1;break}return p},e.copy=function(a){for(var p=0;p<B;p++)this.rows[p].copy(a.rows[p])},e.isEmpty=function(){for(var a=!0,p=0;p<B;p++)if(!this.rows[p].isEmpty()){a=!1;break}return a},e.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},e.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},e.insertChar=function(a){var p=this.rows[this.currRow];p.insertChar(a)},e.setPen=function(a){var p=this.rows[this.currRow];p.setPenStyles(a)},e.moveCursor=function(a){var p=this.rows[this.currRow];p.moveCursor(a)},e.setCursor=function(a){this.logger.log(E.INFO,"setCursor: "+a);var p=this.rows[this.currRow];p.setCursor(a)},e.setPAC=function(a){this.logger.log(E.INFO,"pacData = "+JSON.stringify(a));var p=a.row-1;if(this.nrRollUpRows&&p<this.nrRollUpRows-1&&(p=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==p){for(var g=0;g<B;g++)this.rows[g].clear();var T=this.currRow+1-this.nrRollUpRows,P=this.lastOutputScreen;if(P){var I=P.rows[T].cueStartTime,F=this.logger.time;if(I&&F!==null&&I<F)for(var W=0;W<this.nrRollUpRows;W++)this.rows[p-this.nrRollUpRows+W+1].copy(P.rows[T+W])}}this.currRow=p;var z=this.rows[this.currRow];if(a.indent!==null){var X=a.indent,K=Math.max(X-1,0);z.setCursor(a.indent),a.color=z.chars[K].penState.foreground}var J={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(J)},e.setBkgData=function(a){this.logger.log(E.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},e.setRollUpRows=function(a){this.nrRollUpRows=a},e.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(E.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(E.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,p=this.rows.splice(a,1)[0];p.clear(),this.rows.splice(this.currRow,0,p),this.logger.log(E.INFO,"Rolling up")},e.getDisplayText=function(a){a=a||!1;for(var p=[],g="",T=-1,P=0;P<B;P++){var I=this.rows[P].getTextString();I&&(T=P+1,a?p.push("Row "+T+": '"+I+"'"):p.push(I.trim()))}return p.length>0&&(a?g="["+p.join(" | ")+"]":g=p.join(`
|
|
`)),g},e.getTextAndFormat=function(){return this.rows},u}(),f=function(){function u(n,a,p){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=n,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new o(p),this.nonDisplayedMemory=new o(p),this.lastOutputScreen=new o(p),this.currRollUpRow=this.displayedMemory.rows[B-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=p}var e=u.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[B-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(a){this.outputFilter=a},e.setPAC=function(a){this.writeScreen.setPAC(a)},e.setBkgData=function(a){this.writeScreen.setBkgData(a)},e.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(E.INFO,"MODE="+a),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=a},e.insertChars=function(a){for(var p=0;p<a.length;p++)this.writeScreen.insertChar(a[p]);var g=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,g+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(E.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},e.ccRCL=function(){this.logger.log(E.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function(){if(this.logger.log(E.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},e.ccAOF=function(){},e.ccAON=function(){},e.ccDER=function(){this.logger.log(E.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function(a){this.logger.log(E.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},e.ccFON=function(){this.logger.log(E.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function(){this.logger.log(E.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function(){this.logger.log(E.INFO,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function(){this.logger.log(E.INFO,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function(){this.logger.log(E.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function(){this.logger.log(E.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function(){this.logger.log(E.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function(){if(this.logger.log(E.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(E.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},e.ccTO=function(a){this.logger.log(E.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},e.ccMIDROW=function(a){var p={flash:!1};if(p.underline=a%2===1,p.italics=a>=46,p.italics)p.foreground="white";else{var g=Math.floor(a/2)-16,T=["white","green","blue","cyan","red","yellow","magenta"];p.foreground=T[g]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(p)),this.writeScreen.setPen(p)},e.outputDataUpdate=function(a){a===void 0&&(a=!1);var p=this.logger.time;if(p===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=p:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,p,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:p),this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},u}(),l=function(){function u(n,a,p){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var g=new b;this.channels=[null,new f(n,a,g),new f(n+1,p,g)],this.cmdHistory=c(),this.logger=g}var e=u.prototype;return e.getHandler=function(a){return this.channels[a].getHandler()},e.setHandler=function(a,p){this.channels[a].setHandler(p)},e.addData=function(a,p){var g,T,P,I=!1;this.logger.time=a;for(var F=0;F<p.length;F+=2){if(T=p[F]&127,P=p[F+1]&127,T===0&&P===0)continue;if(this.logger.log(E.DATA,"["+y([p[F],p[F+1]])+"] -> ("+y([T,P])+")"),g=this.parseCmd(T,P),g||(g=this.parseMidrow(T,P)),g||(g=this.parsePAC(T,P)),g||(g=this.parseBackgroundAttributes(T,P)),!g&&(I=this.parseChars(T,P),I)){var W=this.currentChannel;if(W&&W>0){var z=this.channels[W];z.insertChars(I)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!g&&!I&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+y([T,P])+" orig: "+y([p[F],p[F+1]]))}},e.parseCmd=function(a,p){var g=this.cmdHistory,T=(a===20||a===28||a===21||a===29)&&p>=32&&p<=47,P=(a===23||a===31)&&p>=33&&p<=35;if(!(T||P))return!1;if(m(a,p,g))return h(null,null,g),this.logger.log(E.DEBUG,"Repeated command ("+y([a,p])+") is dropped"),!0;var I=a===20||a===21||a===23?1:2,F=this.channels[I];return a===20||a===21||a===28||a===29?p===32?F.ccRCL():p===33?F.ccBS():p===34?F.ccAOF():p===35?F.ccAON():p===36?F.ccDER():p===37?F.ccRU(2):p===38?F.ccRU(3):p===39?F.ccRU(4):p===40?F.ccFON():p===41?F.ccRDC():p===42?F.ccTR():p===43?F.ccRTD():p===44?F.ccEDM():p===45?F.ccCR():p===46?F.ccENM():p===47&&F.ccEOC():F.ccTO(p-32),h(a,p,g),this.currentChannel=I,!0},e.parseMidrow=function(a,p){var g=0;if((a===17||a===25)&&p>=32&&p<=47){if(a===17?g=1:g=2,g!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var T=this.channels[g];return T?(T.ccMIDROW(p),this.logger.log(E.DEBUG,"MIDROW ("+y([a,p])+")"),!0):!1}return!1},e.parsePAC=function(a,p){var g,T=this.cmdHistory,P=(a>=17&&a<=23||a>=25&&a<=31)&&p>=64&&p<=127,I=(a===16||a===24)&&p>=64&&p<=95;if(!(P||I))return!1;if(m(a,p,T))return h(null,null,T),!0;var F=a<=23?1:2;p>=64&&p<=95?g=F===1?k[a]:v[a]:g=F===1?w[a]:x[a];var W=this.channels[F];return W?(W.setPAC(this.interpretPAC(g,p)),h(a,p,T),this.currentChannel=F,!0):!1},e.interpretPAC=function(a,p){var g,T={color:null,italics:!1,indent:null,underline:!1,row:a};return p>95?g=p-96:g=p-64,T.underline=(g&1)===1,g<=13?T.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(g/2)]:g<=15?(T.italics=!0,T.color="white"):T.indent=Math.floor((g-16)/2)*4,T},e.parseChars=function(a,p){var g,T=null,P=null;if(a>=25?(g=2,P=a-8):(g=1,P=a),P>=17&&P<=19){var I;P===17?I=p+80:P===18?I=p+112:I=p+144,this.logger.log(E.INFO,"Special char '"+_(I)+"' in channel "+g),T=[I]}else a>=32&&a<=127&&(T=p===0?[a]:[a,p]);if(T){var F=y(T);this.logger.log(E.DEBUG,"Char codes = "+F.join(",")),h(a,p,this.cmdHistory)}return T},e.parseBackgroundAttributes=function(a,p){var g=(a===16||a===24)&&p>=32&&p<=47,T=(a===23||a===31)&&p>=45&&p<=47;if(!(g||T))return!1;var P,I={};a===16||a===24?(P=Math.floor((p-32)/2),I.background=C[P],p%2===1&&(I.background=I.background+"_semi")):p===45?I.background="transparent":(I.foreground="black",p===47&&(I.underline=!0));var F=a<=23?1:2,W=this.channels[F];return W.setBkgData(I),h(a,p,this.cmdHistory),!0},e.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var p=this.channels[a];p&&p.reset()}this.cmdHistory=c()},e.cueSplitAtTime=function(a){for(var p=0;p<this.channels.length;p++){var g=this.channels[p];g&&g.cueSplitAtTime(a)}},u}();function h(u,e,n){n.a=u,n.b=e}function m(u,e,n){return n.a===u&&n.b===e}function c(){return{a:null,b:null}}N.default=l},"./src/utils/codecs.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"isCodecType",function(){return L}),S.d(N,"isCodecSupportedInMp4",function(){return _});var U={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,av01:!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},text:{stpp:!0,wvtt:!0}};function L(B,O){var k=U[O];return!!k&&k[B.slice(0,4)]===!0}function _(B,O){return MediaSource.isTypeSupported((O||"video")+'/mp4;codecs="'+B+'"')}},"./src/utils/cues.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/utils/vttparser.ts"),L=S("./src/utils/webvtt-parser.ts"),_=S("./src/utils/texttrack-utils.ts"),B=/\s/,O={newCue:function(w,v,x,C){for(var E=[],b,y,d,r,i,o=self.VTTCue||self.TextTrackCue,f=0;f<C.rows.length;f++)if(b=C.rows[f],d=!0,r=0,i="",!b.isEmpty()){for(var l=0;l<b.chars.length;l++)B.test(b.chars[l].uchar)&&d?r++:(i+=b.chars[l].uchar,d=!1);b.cueStartTime=v,v===x&&(x+=1e-4),r>=16?r--:r++;var h=Object(U.fixLineBreaks)(i.trim()),m=Object(L.generateCueId)(v,x,h);(!w||!w.cues||!w.cues.getCueById(m))&&(y=new o(v,x,h),y.id=m,y.line=f+1,y.align="left",y.position=10+Math.min(80,Math.floor(r*8/32)*10),E.push(y))}return w&&E.length&&(E.sort(function(c,u){return c.line==="auto"||u.line==="auto"?0:c.line>8&&u.line>8?u.line-c.line:c.line-u.line}),E.forEach(function(c){return Object(_.addCueToTrack)(w,c)})),E}};N.default=O},"./src/utils/discontinuities.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"findFirstFragWithCC",function(){return B}),S.d(N,"shouldAlignOnDiscontinuities",function(){return O}),S.d(N,"findDiscontinuousReferenceFrag",function(){return k}),S.d(N,"adjustSlidingStart",function(){return v}),S.d(N,"alignStream",function(){return x}),S.d(N,"alignPDT",function(){return E}),S.d(N,"alignFragmentByPDTDelta",function(){return b}),S.d(N,"alignMediaPlaylistByPDT",function(){return y});var U=S("./src/polyfills/number.ts"),L=S("./src/utils/logger.ts"),_=S("./src/controller/level-helper.ts");function B(d,r){for(var i=null,o=0,f=d.length;o<f;o++){var l=d[o];if(l&&l.cc===r){i=l;break}}return i}function O(d,r,i){return!!(r.details&&(i.endCC>i.startCC||d&&d.cc<i.startCC))}function k(d,r){var i=d.fragments,o=r.fragments;if(!o.length||!i.length){L.logger.log("No fragments to align");return}var f=B(i,o[0].cc);if(!f||f&&!f.startPTS){L.logger.log("No frag in previous level to align on");return}return f}function w(d,r){if(d){var i=d.start+r;d.start=d.startPTS=i,d.endPTS=i+d.duration}}function v(d,r){for(var i=r.fragments,o=0,f=i.length;o<f;o++)w(i[o],d);r.fragmentHint&&w(r.fragmentHint,d),r.alignedSliding=!0}function x(d,r,i){if(!r)return;C(d,i,r),!i.alignedSliding&&r.details&&E(i,r.details),!i.alignedSliding&&r.details&&!i.skippedSegments&&Object(_.adjustSliding)(r.details,i)}function C(d,r,i){if(O(d,i,r)){var o=k(i.details,r);o&&Object(U.isFiniteNumber)(o.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+r.url),v(o.start,r))}}function E(d,r){if(!r.fragments.length||!d.hasProgramDateTime||!r.hasProgramDateTime)return;var i=r.fragments[0].programDateTime,o=d.fragments[0].programDateTime,f=(o-i)/1e3+r.fragments[0].start;f&&Object(U.isFiniteNumber)(f)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(o-i)+"ms, sliding:"+f.toFixed(3)+" "+d.url+" "),v(f,d))}function b(d,r){var i=d.programDateTime;if(!i)return;var o=(i-r)/1e3;d.start=d.startPTS=o,d.endPTS=o+d.duration}function y(d,r){if(!r.fragments.length||!d.hasProgramDateTime||!r.hasProgramDateTime)return;var i=r.fragments[0].programDateTime,o=r.fragments[0].start,f=i-o*1e3;d.fragments.forEach(function(l){b(l,f)}),d.fragmentHint&&b(d.fragmentHint,f),d.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/utils/ewma.ts"),L=function(){function _(O,k,w){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=w,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new U.default(O),this.fast_=new U.default(k)}var B=_.prototype;return B.update=function(k,w){var v=this.slow_,x=this.fast_;this.slow_.halfLife!==k&&(this.slow_=new U.default(k,v.getEstimate(),v.getTotalWeight())),this.fast_.halfLife!==w&&(this.fast_=new U.default(w,x.getEstimate(),x.getTotalWeight()))},B.sample=function(k,w){k=Math.max(k,this.minDelayMs_);var v=8*w,x=k/1e3,C=v/x;this.fast_.sample(x,C),this.slow_.sample(x,C)},B.canEstimate=function(){var k=this.fast_;return k&&k.getTotalWeight()>=this.minWeight_},B.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},B.destroy=function(){},_}();N.default=L},"./src/utils/ewma.ts":function(he,N,S){"use strict";S.r(N);var U=function(){function L(B,O,k){O===void 0&&(O=0),k===void 0&&(k=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=B,this.alpha_=B?Math.exp(Math.log(.5)/B):0,this.estimate_=O,this.totalWeight_=k}var _=L.prototype;return _.sample=function(O,k){var w=Math.pow(this.alpha_,O);this.estimate_=k*(1-w)+w*this.estimate_,this.totalWeight_+=O},_.getTotalWeight=function(){return this.totalWeight_},_.getEstimate=function(){if(this.alpha_){var O=1-Math.pow(this.alpha_,this.totalWeight_);if(O)return this.estimate_/O}return this.estimate_},L}();N.default=U},"./src/utils/fetch-loader.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"fetchSupported",function(){return b});var U=S("./src/polyfills/number.ts"),L=S("./src/loader/load-stats.ts"),_=S("./src/demux/chunk-cache.ts");function B(o,f){o.prototype=Object.create(f.prototype),o.prototype.constructor=o,x(o,f)}function O(o){var f=typeof Map=="function"?new Map:void 0;return O=function(h){if(h===null||!v(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof f!="undefined"){if(f.has(h))return f.get(h);f.set(h,m)}function m(){return k(h,arguments,C(this).constructor)}return m.prototype=Object.create(h.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),x(m,h)},O(o)}function k(o,f,l){return w()?k=Reflect.construct:k=function(m,c,u){var e=[null];e.push.apply(e,c);var n=Function.bind.apply(m,e),a=new n;return u&&x(a,u.prototype),a},k.apply(null,arguments)}function w(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(o){return!1}}function v(o){return Function.toString.call(o).indexOf("[native code]")!==-1}function x(o,f){return x=Object.setPrototypeOf||function(h,m){return h.__proto__=m,h},x(o,f)}function C(o){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},C(o)}function E(){return E=Object.assign||function(o){for(var f=1;f<arguments.length;f++){var l=arguments[f];for(var h in l)Object.prototype.hasOwnProperty.call(l,h)&&(o[h]=l[h])}return o},E.apply(this,arguments)}function b(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(o){}return!1}var y=function(){function o(l){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=l.fetchSetup||r,this.controller=new self.AbortController,this.stats=new L.LoadStats}var f=o.prototype;return f.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},f.abortInternal=function(){var h=this.response;(!h||!h.ok)&&(this.stats.aborted=!0,this.controller.abort())},f.abort=function(){var h;this.abortInternal(),(h=this.callbacks)!==null&&h!==void 0&&h.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},f.load=function(h,m,c){var u=this,e=this.stats;if(e.loading.start)throw new Error("Loader can only be used once.");e.loading.start=self.performance.now();var n=d(h,this.controller.signal),a=c.onProgress,p=h.responseType==="arraybuffer",g=p?"byteLength":"length";this.context=h,this.config=m,this.callbacks=c,this.request=this.fetchSetup(h,n),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){u.abortInternal(),c.onTimeout(e,h,u.response)},m.timeout),self.fetch(this.request).then(function(T){if(u.response=u.loader=T,!T.ok){var P=T.status,I=T.statusText;throw new i(I||"fetch, bad network response",P,T)}return e.loading.first=Math.max(self.performance.now(),e.loading.start),e.total=parseInt(T.headers.get("Content-Length")||"0"),a&&Object(U.isFiniteNumber)(m.highWaterMark)?u.loadProgressively(T,e,h,m.highWaterMark,a):p?T.arrayBuffer():T.text()}).then(function(T){var P=u.response;self.clearTimeout(u.requestTimeout),e.loading.end=Math.max(self.performance.now(),e.loading.first),e.loaded=e.total=T[g];var I={url:P.url,data:T};a&&!Object(U.isFiniteNumber)(m.highWaterMark)&&a(e,h,T,P),c.onSuccess(I,e,h,P)}).catch(function(T){if(self.clearTimeout(u.requestTimeout),e.aborted)return;var P=T.code||0;c.onError({code:P,text:T.message},h,T.details)})},f.getCacheAge=function(){var h=null;if(this.response){var m=this.response.headers.get("age");h=m?parseFloat(m):null}return h},f.loadProgressively=function(h,m,c,u,e){u===void 0&&(u=0);var n=new _.default,a=h.body.getReader(),p=function g(){return a.read().then(function(T){if(T.done)return n.dataLength&&e(m,c,n.flush(),h),Promise.resolve(new ArrayBuffer(0));var P=T.value,I=P.length;return m.loaded+=I,I<u||n.dataLength?(n.push(P),n.dataLength>=u&&e(m,c,n.flush(),h)):e(m,c,P,h),g()}).catch(function(){return Promise.reject()})};return p()},o}();function d(o,f){var l={method:"GET",mode:"cors",credentials:"same-origin",signal:f,headers:new self.Headers(E({},o.headers))};return o.rangeEnd&&l.headers.set("Range","bytes="+o.rangeStart+"-"+String(o.rangeEnd-1)),l}function r(o,f){return new self.Request(o.url,f)}var i=function(o){B(f,o);function f(l,h,m){var c;return c=o.call(this,l)||this,c.code=void 0,c.details=void 0,c.code=h,c.details=m,c}return f}(O(Error));N.default=y},"./src/utils/imsc1-ttml-parser.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"IMSC1_CODEC",function(){return v}),S.d(N,"parseIMSC1",function(){return b});var U=S("./src/utils/mp4-tools.ts"),L=S("./src/utils/vttparser.ts"),_=S("./src/utils/vttcue.ts"),B=S("./src/demux/id3.ts"),O=S("./src/utils/timescale-conversion.ts"),k=S("./src/utils/webvtt-parser.ts");function w(){return w=Object.assign||function(u){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(u[a]=n[a])}return u},w.apply(this,arguments)}var v="stpp.ttml.im1t",x=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,C=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,E={left:"start",center:"center",right:"end",start:"start",end:"end"};function b(u,e,n,a,p){var g=Object(U.findBox)(new Uint8Array(u),["mdat"]);if(g.length===0){p(new Error("Could not parse IMSC1 mdat"));return}var T=g[0],P=Object(B.utf8ArrayToStr)(new Uint8Array(u,T.start,T.end-T.start)),I=Object(O.toTimescaleFromScale)(e,1,n);try{a(y(P,I))}catch(F){p(F)}}function y(u,e){var n=new DOMParser,a=n.parseFromString(u,"text/xml"),p=a.getElementsByTagName("tt")[0];if(!p)throw new Error("Invalid ttml");var g={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},T=Object.keys(g).reduce(function(z,X){return z[X]=p.getAttribute("ttp:"+X)||g[X],z},{}),P=p.getAttribute("xml:space")!=="preserve",I=r(d(p,"styling","style")),F=r(d(p,"layout","region")),W=d(p,"body","[begin]");return[].map.call(W,function(z){var X=i(z,P);if(!X||!z.hasAttribute("begin"))return null;var K=h(z.getAttribute("begin"),T),J=h(z.getAttribute("dur"),T),ne=h(z.getAttribute("end"),T);if(K===null)throw l(z);if(ne===null){if(J===null)throw l(z);ne=K+J}var re=new _.default(K-e,ne-e,X);re.id=Object(k.generateCueId)(re.startTime,re.endTime,re.text);var be=F[z.getAttribute("region")],oe=I[z.getAttribute("style")];re.position=10,re.size=80;var ue=o(be,oe),de=ue.textAlign;if(de){var ce=E[de];ce&&(re.lineAlign=ce),re.align=de}return w(re,ue),re}).filter(function(z){return z!==null})}function d(u,e,n){var a=u.getElementsByTagName(e)[0];return a?[].slice.call(a.querySelectorAll(n)):[]}function r(u){return u.reduce(function(e,n){var a=n.getAttribute("xml:id");return a&&(e[a]=n),e},{})}function i(u,e){return[].slice.call(u.childNodes).reduce(function(n,a,p){var g;return a.nodeName==="br"&&p?n+`
|
|
`:(g=a.childNodes)!==null&&g!==void 0&&g.length?i(a,e):e?n+a.textContent.trim().replace(/\s+/g," "):n+a.textContent},"")}function o(u,e){var n="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(p,g){var T=f(e,n,g)||f(u,n,g);return T&&(p[g]=T),p},{})}function f(u,e,n){return u.hasAttributeNS(e,n)?u.getAttributeNS(e,n):null}function l(u){return new Error("Could not parse ttml timestamp "+u)}function h(u,e){if(!u)return null;var n=Object(L.parseTimeStamp)(u);return n===null&&(x.test(u)?n=m(u,e):C.test(u)&&(n=c(u,e))),n}function m(u,e){var n=x.exec(u),a=(n[4]|0)+(n[5]|0)/e.subFrameRate;return(n[1]|0)*3600+(n[2]|0)*60+(n[3]|0)+a/e.frameRate}function c(u,e){var n=C.exec(u),a=Number(n[1]),p=n[2];switch(p){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/e.frameRate;case"t":return a/e.tickRate}return a}},"./src/utils/logger.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"enableLogs",function(){return k}),S.d(N,"logger",function(){return w});var U=function(){},L={trace:U,debug:U,log:U,warn:U,info:U,error:U},_=L;function B(v){var x=self.console[v];return x?x.bind(self.console,"["+v+"] >"):U}function O(v){for(var x=arguments.length,C=new Array(x>1?x-1:0),E=1;E<x;E++)C[E-1]=arguments[E];C.forEach(function(b){_[b]=v[b]?v[b].bind(v):B(b)})}function k(v){if(self.console&&v===!0||typeof v=="object"){O(v,"debug","log","info","warn","error");try{_.log()}catch(x){_=L}}else _=L}var w=_},"./src/utils/mediakeys-helper.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"KeySystems",function(){return U}),S.d(N,"requestMediaKeySystemAccess",function(){return L});var U;(function(_){_.WIDEVINE="com.widevine.alpha",_.PLAYREADY="com.microsoft.playready"})(U||(U={}));var L=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"getMediaSource",function(){return U});function U(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"bin2str",function(){return O}),S.d(N,"readUint16",function(){return k}),S.d(N,"readUint32",function(){return w}),S.d(N,"writeUint32",function(){return v}),S.d(N,"findBox",function(){return x}),S.d(N,"parseSegmentIndex",function(){return C}),S.d(N,"parseInitSegment",function(){return E}),S.d(N,"getStartDTS",function(){return b}),S.d(N,"getDuration",function(){return y}),S.d(N,"computeRawDurationFromSamples",function(){return d}),S.d(N,"offsetStartDTS",function(){return r}),S.d(N,"segmentValidRange",function(){return i}),S.d(N,"appendUint8Array",function(){return o});var U=S("./src/utils/typed-array.ts"),L=S("./src/loader/fragment.ts"),_=Math.pow(2,32)-1,B=[].push;function O(f){return String.fromCharCode.apply(null,f)}function k(f,l){"data"in f&&(l+=f.start,f=f.data);var h=f[l]<<8|f[l+1];return h<0?65536+h:h}function w(f,l){"data"in f&&(l+=f.start,f=f.data);var h=f[l]<<24|f[l+1]<<16|f[l+2]<<8|f[l+3];return h<0?4294967296+h:h}function v(f,l,h){"data"in f&&(l+=f.start,f=f.data),f[l]=h>>24,f[l+1]=h>>16&255,f[l+2]=h>>8&255,f[l+3]=h&255}function x(f,l){var h=[];if(!l.length)return h;var m,c,u;"data"in f?(m=f.data,c=f.start,u=f.end):(m=f,c=0,u=m.byteLength);for(var e=c;e<u;){var n=w(m,e),a=O(m.subarray(e+4,e+8)),p=n>1?e+n:u;if(a===l[0])if(l.length===1)h.push({data:m,start:e+8,end:p});else{var g=x({data:m,start:e+8,end:p},l.slice(1));g.length&&B.apply(h,g)}e=p}return h}function C(f){var l=x(f,["moov"]),h=l[0],m=h?h.end:null,c=x(f,["sidx"]);if(!c||!c[0])return null;var u=[],e=c[0],n=e.data[0],a=n===0?8:16,p=w(e,a);a+=4;var g=0,T=0;n===0?a+=8:a+=16,a+=2;var P=e.end+T,I=k(e,a);a+=2;for(var F=0;F<I;F++){var W=a,z=w(e,W);W+=4;var X=z&2147483647,K=(z&2147483648)>>>31;if(K===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var J=w(e,W);W+=4,u.push({referenceSize:X,subsegmentDuration:J,info:{duration:J/p,start:P,end:P+X-1}}),P+=X,W+=4,a=W}return{earliestPresentationTime:g,timescale:p,version:n,referencesCount:I,references:u,moovEndOffset:m}}function E(f){for(var l=[],h=x(f,["moov","trak"]),m=0;m<h.length;m++){var c=h[m],u=x(c,["tkhd"])[0];if(u){var e=u.data[u.start],n=e===0?12:20,a=w(u,n),p=x(c,["mdia","mdhd"])[0];if(p){e=p.data[p.start],n=e===0?12:20;var g=w(p,n),T=x(c,["mdia","hdlr"])[0];if(T){var P=O(T.data.subarray(T.start+8,T.start+12)),I={soun:L.ElementaryStreamTypes.AUDIO,vide:L.ElementaryStreamTypes.VIDEO}[P];if(I){var F=x(c,["mdia","minf","stbl","stsd"])[0],W=void 0;F&&(W=O(F.data.subarray(F.start+12,F.start+16))),l[a]={timescale:g,type:I},l[I]={timescale:g,id:a,codec:W}}}}}}var z=x(f,["moov","mvex","trex"]);return z.forEach(function(X){var K=w(X,4),J=l[K];J&&(J.default={duration:w(X,12),flags:w(X,20)})}),l}function b(f,l){return x(l,["moof","traf"]).reduce(function(h,m){var c=x(m,["tfdt"])[0],u=c.data[c.start],e=x(m,["tfhd"]).reduce(function(n,a){var p=w(a,4),g=f[p];if(g){var T=w(c,4);u===1&&(T*=Math.pow(2,32),T+=w(c,8));var P=g.timescale||9e4,I=T/P;if(isFinite(I)&&(n===null||I<n))return I}return n},null);return e!==null&&isFinite(e)&&(h===null||e<h)?e:h},null)||0}function y(f,l){for(var h=0,m=0,c=0,u=x(f,["moof","traf"]),e=0;e<u.length;e++){var n=u[e],a=x(n,["tfhd"])[0],p=w(a,4),g=l[p];if(!g)continue;var T=g.default,P=w(a,0)|(T==null?void 0:T.flags),I=T==null?void 0:T.duration;P&8&&(P&2?I=w(a,12):I=w(a,8));for(var F=g.timescale||9e4,W=x(n,["trun"]),z=0;z<W.length;z++){if(I){var X=w(W[z],4);h=I*X}else h=d(W[z]);g.type===L.ElementaryStreamTypes.VIDEO?m+=h/F:g.type===L.ElementaryStreamTypes.AUDIO&&(c+=h/F)}}if(m===0&&c===0){var K=C(f);if(K!=null&&K.references)return K.references.reduce(function(J,ne){return J+ne.info.duration||0},0)}return m||c}function d(f){var l=w(f,0),h=8;l&1&&(h+=4),l&4&&(h+=4);for(var m=0,c=w(f,4),u=0;u<c;u++){if(l&256){var e=w(f,h);m+=e,h+=4}l&512&&(h+=4),l&1024&&(h+=4),l&2048&&(h+=4)}return m}function r(f,l,h){x(l,["moof","traf"]).forEach(function(m){x(m,["tfhd"]).forEach(function(c){var u=w(c,4),e=f[u];if(!e)return;var n=e.timescale||9e4;x(m,["tfdt"]).forEach(function(a){var p=a.data[a.start],g=w(a,4);if(p===0)v(a,4,g-h*n);else{g*=Math.pow(2,32),g+=w(a,8),g-=h*n,g=Math.max(g,0);var T=Math.floor(g/(_+1)),P=Math.floor(g%(_+1));v(a,4,T),v(a,8,P)}})})})}function i(f){var l={valid:null,remainder:null},h=x(f,["moof"]);if(h){if(h.length<2)return l.remainder=f,l}else return l;var m=h[h.length-1];return l.valid=Object(U.sliceUint8)(f,0,m.start-8),l.remainder=Object(U.sliceUint8)(f,m.start-8),l}function o(f,l){var h=new Uint8Array(f.length+l.length);return h.set(f),h.set(l,f.length),h}},"./src/utils/output-filter.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"default",function(){return U});var U=function(){function L(B,O){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=B,this.trackName=O}var _=L.prototype;return _.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},_.newCue=function(O,k,w){(this.startTime===null||this.startTime>O)&&(this.startTime=O),this.endTime=k,this.screen=w,this.timelineController.createCaptionsTrack(this.trackName)},_.reset=function(){this.cueRanges=[]},L}()},"./src/utils/texttrack-utils.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"sendAddTrackEvent",function(){return L}),S.d(N,"addCueToTrack",function(){return _}),S.d(N,"clearCurrentCues",function(){return B}),S.d(N,"removeCuesInRange",function(){return O}),S.d(N,"getCuesInRange",function(){return w});var U=S("./src/utils/logger.ts");function L(v,x){var C;try{C=new Event("addtrack")}catch(E){C=document.createEvent("Event"),C.initEvent("addtrack",!1,!1)}C.track=v,x.dispatchEvent(C)}function _(v,x){var C=v.mode;if(C==="disabled"&&(v.mode="hidden"),v.cues&&!v.cues.getCueById(x.id))try{if(v.addCue(x),!v.cues.getCueById(x.id))throw new Error("addCue is failed for: "+x)}catch(b){U.logger.debug("[texttrack-utils]: "+b);var E=new self.TextTrackCue(x.startTime,x.endTime,x.text);E.id=x.id,v.addCue(E)}C==="disabled"&&(v.mode=C)}function B(v){var x=v.mode;if(x==="disabled"&&(v.mode="hidden"),v.cues)for(var C=v.cues.length;C--;)v.removeCue(v.cues[C]);x==="disabled"&&(v.mode=x)}function O(v,x,C){var E=v.mode;if(E==="disabled"&&(v.mode="hidden"),v.cues&&v.cues.length>0)for(var b=w(v.cues,x,C),y=0;y<b.length;y++)v.removeCue(b[y]);E==="disabled"&&(v.mode=E)}function k(v,x){if(x<v[0].startTime)return 0;var C=v.length-1;if(x>v[C].endTime)return-1;for(var E=0,b=C;E<=b;){var y=Math.floor((b+E)/2);if(x<v[y].startTime)b=y-1;else if(x>v[y].startTime&&E<C)E=y+1;else return y}return v[E].startTime-x<x-v[b].startTime?E:b}function w(v,x,C){var E=[],b=k(v,x);if(b>-1)for(var y=b,d=v.length;y<d;y++){var r=v[y];if(r.startTime>=x&&r.endTime<=C)E.push(r);else if(r.startTime>C)return E}return E}},"./src/utils/time-ranges.ts":function(he,N,S){"use strict";S.r(N);var U={toString:function(_){for(var B="",O=_.length,k=0;k<O;k++)B+="["+_.start(k).toFixed(3)+","+_.end(k).toFixed(3)+"]";return B}};N.default=U},"./src/utils/timescale-conversion.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"toTimescaleFromBase",function(){return L}),S.d(N,"toTimescaleFromScale",function(){return _}),S.d(N,"toMsFromMpegTsClock",function(){return B}),S.d(N,"toMpegTsClockFromTimescale",function(){return O});var U=9e4;function L(k,w,v,x){v===void 0&&(v=1),x===void 0&&(x=!1);var C=k*w*v;return x?Math.round(C):C}function _(k,w,v,x){return v===void 0&&(v=1),x===void 0&&(x=!1),L(k,w,1/v,x)}function B(k,w){return w===void 0&&(w=!1),L(k,1e3,1/U,w)}function O(k,w){return w===void 0&&(w=1),L(k,U,1/w)}},"./src/utils/typed-array.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"sliceUint8",function(){return U});function U(L,_,B){return Uint8Array.prototype.slice?L.slice(_,B):new Uint8Array(Array.prototype.slice.call(L,_,B))}},"./src/utils/vttcue.ts":function(he,N,S){"use strict";S.r(N),N.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var U=["","lr","rl"],L=["start","middle","end","left","right"];function _(v,x){if(typeof x!="string")return!1;if(!Array.isArray(v))return!1;var C=x.toLowerCase();return~v.indexOf(C)?C:!1}function B(v){return _(U,v)}function O(v){return _(L,v)}function k(v){for(var x=arguments.length,C=new Array(x>1?x-1:0),E=1;E<x;E++)C[E-1]=arguments[E];for(var b=1;b<arguments.length;b++){var y=arguments[b];for(var d in y)v[d]=y[d]}return v}function w(v,x,C){var E=this,b={enumerable:!0};E.hasBeenReset=!1;var y="",d=!1,r=v,i=x,o=C,f=null,l="",h=!0,m="auto",c="start",u=50,e="middle",n=50,a="middle";Object.defineProperty(E,"id",k({},b,{get:function(){return y},set:function(g){y=""+g}})),Object.defineProperty(E,"pauseOnExit",k({},b,{get:function(){return d},set:function(g){d=!!g}})),Object.defineProperty(E,"startTime",k({},b,{get:function(){return r},set:function(g){if(typeof g!="number")throw new TypeError("Start time must be set to a number.");r=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",k({},b,{get:function(){return i},set:function(g){if(typeof g!="number")throw new TypeError("End time must be set to a number.");i=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",k({},b,{get:function(){return o},set:function(g){o=""+g,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",k({},b,{get:function(){return f},set:function(g){f=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",k({},b,{get:function(){return l},set:function(g){var T=B(g);if(T===!1)throw new SyntaxError("An invalid or illegal string was specified.");l=T,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",k({},b,{get:function(){return h},set:function(g){h=!!g,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",k({},b,{get:function(){return m},set:function(g){if(typeof g!="number"&&g!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");m=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",k({},b,{get:function(){return c},set:function(g){var T=O(g);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");c=T,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",k({},b,{get:function(){return u},set:function(g){if(g<0||g>100)throw new Error("Position must be between 0 and 100.");u=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",k({},b,{get:function(){return e},set:function(g){var T=O(g);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");e=T,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",k({},b,{get:function(){return n},set:function(g){if(g<0||g>100)throw new Error("Size must be between 0 and 100.");n=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",k({},b,{get:function(){return a},set:function(g){var T=O(g);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");a=T,this.hasBeenReset=!0}})),E.displayState=void 0}return w.prototype.getCueAsHTML=function(){var v=self.WebVTT;return v.convertCueToDOMTree(self,this.text)},w}()},"./src/utils/vttparser.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"parseTimeStamp",function(){return _}),S.d(N,"fixLineBreaks",function(){return x}),S.d(N,"VTTParser",function(){return C});var U=S("./src/utils/vttcue.ts"),L=function(){function E(){}var b=E.prototype;return b.decode=function(d,r){if(!d)return"";if(typeof d!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(d))},E}();function _(E){function b(d,r,i,o){return(d|0)*3600+(r|0)*60+(i|0)+parseFloat(o||0)}var y=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return y?parseFloat(y[2])>59?b(y[2],y[3],0,y[4]):b(y[1],y[2],y[3],y[4]):null}var B=function(){function E(){this.values=Object.create(null)}var b=E.prototype;return b.set=function(d,r){!this.get(d)&&r!==""&&(this.values[d]=r)},b.get=function(d,r,i){return i?this.has(d)?this.values[d]:r[i]:this.has(d)?this.values[d]:r},b.has=function(d){return d in this.values},b.alt=function(d,r,i){for(var o=0;o<i.length;++o)if(r===i[o]){this.set(d,r);break}},b.integer=function(d,r){/^-?\d+$/.test(r)&&this.set(d,parseInt(r,10))},b.percent=function(d,r){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(r)){var i=parseFloat(r);if(i>=0&&i<=100)return this.set(d,i),!0}return!1},E}();function O(E,b,y,d){var r=d?E.split(d):[E];for(var i in r){if(typeof r[i]!="string")continue;var o=r[i].split(y);if(o.length!==2)continue;var f=o[0],l=o[1];b(f,l)}}var k=new U.default(0,0,""),w=k.align==="middle"?"middle":"center";function v(E,b,y){var d=E;function r(){var f=_(E);if(f===null)throw new Error("Malformed timestamp: "+d);return E=E.replace(/^[^\sa-zA-Z-]+/,""),f}function i(f,l){var h=new B;O(f,function(u,e){var n;switch(u){case"region":for(var a=y.length-1;a>=0;a--)if(y[a].id===e){h.set(u,y[a].region);break}break;case"vertical":h.alt(u,e,["rl","lr"]);break;case"line":n=e.split(","),h.integer(u,n[0]),h.percent(u,n[0])&&h.set("snapToLines",!1),h.alt(u,n[0],["auto"]),n.length===2&&h.alt("lineAlign",n[1],["start",w,"end"]);break;case"position":n=e.split(","),h.percent(u,n[0]),n.length===2&&h.alt("positionAlign",n[1],["start",w,"end","line-left","line-right","auto"]);break;case"size":h.percent(u,e);break;case"align":h.alt(u,e,["start",w,"end","left","right"]);break}},/:/,/\s/),l.region=h.get("region",null),l.vertical=h.get("vertical","");var m=h.get("line","auto");m==="auto"&&k.line===-1&&(m=-1),l.line=m,l.lineAlign=h.get("lineAlign","start"),l.snapToLines=h.get("snapToLines",!0),l.size=h.get("size",100),l.align=h.get("align",w);var c=h.get("position","auto");c==="auto"&&k.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function o(){E=E.replace(/^\s+/,"")}if(o(),b.startTime=r(),o(),E.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+d);E=E.substr(3),o(),b.endTime=r(),o(),i(E,b)}function x(E){return E.replace(/<br(?: \/)?>/gi,`
|
|
`)}var C=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new L,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var b=E.prototype;return b.parse=function(d){var r=this;d&&(r.buffer+=r.decoder.decode(d,{stream:!0}));function i(){var c=r.buffer,u=0;for(c=x(c);u<c.length&&c[u]!=="\r"&&c[u]!==`
|
|
`;)++u;var e=c.substr(0,u);return c[u]==="\r"&&++u,c[u]===`
|
|
`&&++u,r.buffer=c.substr(u),e}function o(c){O(c,function(u,e){},/:/)}try{var f="";if(r.state==="INITIAL"){if(!/\r\n|\n/.test(r.buffer))return this;f=i();var l=f.match(/^()?WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Error("Malformed WebVTT signature.");r.state="HEADER"}for(var h=!1;r.buffer;){if(!/\r\n|\n/.test(r.buffer))return this;h?h=!1:f=i();switch(r.state){case"HEADER":/:/.test(f)?o(f):f||(r.state="ID");continue;case"NOTE":f||(r.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(f)){r.state="NOTE";break}if(!f)continue;if(r.cue=new U.default(0,0,""),r.state="CUE",f.indexOf("-->")===-1){r.cue.id=f;continue}case"CUE":if(!r.cue){r.state="BADCUE";continue}try{v(f,r.cue,r.regionList)}catch(c){r.cue=null,r.state="BADCUE";continue}r.state="CUETEXT";continue;case"CUETEXT":{var m=f.indexOf("-->")!==-1;if(!f||m&&(h=!0)){r.oncue&&r.cue&&r.oncue(r.cue),r.cue=null,r.state="ID";continue}if(r.cue===null)continue;r.cue.text&&(r.cue.text+=`
|
|
`),r.cue.text+=f}continue;case"BADCUE":f||(r.state="ID")}}}catch(c){r.state==="CUETEXT"&&r.cue&&r.oncue&&r.oncue(r.cue),r.cue=null,r.state=r.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},b.flush=function(){var d=this;try{if((d.cue||d.state==="HEADER")&&(d.buffer+=`
|
|
|
|
`,d.parse()),d.state==="INITIAL"||d.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(r){d.onparsingerror&&d.onparsingerror(r)}return d.onflush&&d.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(he,N,S){"use strict";S.r(N),S.d(N,"generateCueId",function(){return C}),S.d(N,"parseWebVTT",function(){return b});var U=S("./src/polyfills/number.ts"),L=S("./src/utils/vttparser.ts"),_=S("./src/demux/id3.ts"),B=S("./src/utils/timescale-conversion.ts"),O=S("./src/remux/mp4-remuxer.ts"),k=/\r\n|\n\r|\n|\r/g,w=function(d,r,i){return i===void 0&&(i=0),d.substr(i,r.length)===r},v=function(d){var r=parseInt(d.substr(-3)),i=parseInt(d.substr(-6,2)),o=parseInt(d.substr(-9,2)),f=d.length>9?parseInt(d.substr(0,d.indexOf(":"))):0;if(!Object(U.isFiniteNumber)(r)||!Object(U.isFiniteNumber)(i)||!Object(U.isFiniteNumber)(o)||!Object(U.isFiniteNumber)(f))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+d);return r+=1e3*i,r+=60*1e3*o,r+=60*60*1e3*f,r},x=function(d){for(var r=5381,i=d.length;i;)r=r*33^d.charCodeAt(--i);return(r>>>0).toString()};function C(y,d,r){return x(y.toString())+x(d.toString())+x(r)}var E=function(d,r,i){var o=d[r],f=d[o.prevCC];if(!f||!f.new&&o.new){d.ccOffset=d.presentationOffset=o.start,o.new=!1;return}for(;(l=f)!==null&&l!==void 0&&l.new;){var l;d.ccOffset+=o.start-f.start,o.new=!1,o=f,f=d[o.prevCC]}d.presentationOffset=i};function b(y,d,r,i,o,f,l,h){var m=new L.VTTParser,c=Object(_.utf8ArrayToStr)(new Uint8Array(y)).trim().replace(k,`
|
|
`).split(`
|
|
`),u=[],e=Object(B.toMpegTsClockFromTimescale)(d,r),n="00:00.000",a=0,p=0,g,T=!0,P=!1;m.oncue=function(I){var F=i[o],W=i.ccOffset,z=(a-e)/9e4;if(F!=null&&F.new&&(p!==void 0?W=i.ccOffset=F.start:E(i,o,z)),z&&(W=z-i.presentationOffset),P){var X=I.endTime-I.startTime,K=Object(O.normalizePts)((I.startTime+W-p)*9e4,f*9e4)/9e4;I.startTime=K,I.endTime=K+X}var J=I.text.trim();I.text=decodeURIComponent(encodeURIComponent(J)),I.id||(I.id=C(I.startTime,I.endTime,J)),I.endTime>0&&u.push(I)},m.onparsingerror=function(I){g=I},m.onflush=function(){if(g){h(g);return}l(u)},c.forEach(function(I){if(T)if(w(I,"X-TIMESTAMP-MAP=")){T=!1,P=!0,I.substr(16).split(",").forEach(function(F){w(F,"LOCAL:")?n=F.substr(6):w(F,"MPEGTS:")&&(a=parseInt(F.substr(7)))});try{p=v(n)/1e3}catch(F){P=!1,g=F}return}else I===""&&(T=!1);m.parse(I+`
|
|
`)}),m.flush()}},"./src/utils/xhr-loader.ts":function(he,N,S){"use strict";S.r(N);var U=S("./src/utils/logger.ts"),L=S("./src/loader/load-stats.ts"),_=/^age:\s*[\d.]+\s*$/m,B=function(){function O(w){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=w?w.xhrSetup:null,this.stats=new L.LoadStats,this.retryDelay=0}var k=O.prototype;return k.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},k.abortInternal=function(){var v=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),v&&(v.onreadystatechange=null,v.onprogress=null,v.readyState!==4&&(this.stats.aborted=!0,v.abort()))},k.abort=function(){var v;this.abortInternal(),(v=this.callbacks)!==null&&v!==void 0&&v.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},k.load=function(v,x,C){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=v,this.config=x,this.callbacks=C,this.retryDelay=x.retryDelay,this.loadInternal()},k.loadInternal=function(){var v=this.config,x=this.context;if(!v)return;var C=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var b=this.xhrSetup;try{if(b)try{b(C,x.url)}catch(r){C.open("GET",x.url,!0),b(C,x.url)}C.readyState||C.open("GET",x.url,!0);var y=this.context.headers;if(y)for(var d in y)C.setRequestHeader(d,y[d])}catch(r){this.callbacks.onError({code:C.status,text:r.message},x,C);return}x.rangeEnd&&C.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),C.onreadystatechange=this.readystatechange.bind(this),C.onprogress=this.loadprogress.bind(this),C.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout),C.send()},k.readystatechange=function(){var v=this.context,x=this.loader,C=this.stats;if(!v||!x)return;var E=x.readyState,b=this.config;if(C.aborted)return;if(E>=2)if(self.clearTimeout(this.requestTimeout),C.loading.first===0&&(C.loading.first=Math.max(self.performance.now(),C.loading.start)),E===4){x.onreadystatechange=null,x.onprogress=null;var y=x.status;if(y>=200&&y<300){C.loading.end=Math.max(self.performance.now(),C.loading.first);var d,r;if(v.responseType==="arraybuffer"?(d=x.response,r=d.byteLength):(d=x.responseText,r=d.length),C.loaded=C.total=r,!this.callbacks)return;var i=this.callbacks.onProgress;if(i&&i(C,v,d,x),!this.callbacks)return;var o={url:x.responseURL,data:d};this.callbacks.onSuccess(o,C,v,x)}else C.retry>=b.maxRetry||y>=400&&y<499?(U.logger.error(y+" while loading "+v.url),this.callbacks.onError({code:y,text:x.statusText},v,x)):(U.logger.warn(y+" while loading "+v.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,b.maxRetryDelay),C.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout)},k.loadtimeout=function(){U.logger.warn("timeout while loading "+this.context.url);var v=this.callbacks;v&&(this.abortInternal(),v.onTimeout(this.stats,this.context,this.loader))},k.loadprogress=function(v){var x=this.stats;x.loaded=v.loaded,v.lengthComputable&&(x.total=v.total)},k.getCacheAge=function(){var v=null;if(this.loader&&_.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");v=x?parseFloat(x):null}return v},O}();N.default=B}}).default})},vHTk:function(vt,tt,ae){vt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|