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.
367 lines
924 KiB
367 lines
924 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[165,5,7],{"+NIl":function(Et,ot,re){(function(oe){oe(re("VrN/"))})(function(oe){"use strict";oe.defineMode("stex",function(Z,_){"use strict";function X(A,x){A.cmdState.push(x)}function O(A){return A.cmdState.length>0?A.cmdState[A.cmdState.length-1]:null}function I(A){var x=A.cmdState.pop();x&&x.closeBracket()}function W(A){for(var x=A.cmdState,C=x.length-1;C>=0;C--){var u=x[C];if(u.name=="DEFAULT")continue;return u}return{styleIdentifier:function(){return null}}}function F(A,x,C){return function(){this.name=A,this.bracketNo=0,this.style=x,this.styles=C,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var M={};M.importmodule=F("importmodule","tag",["string","builtin"]),M.documentclass=F("documentclass","tag",["","atom"]),M.usepackage=F("usepackage","tag",["atom"]),M.begin=F("begin","tag",["atom"]),M.end=F("end","tag",["atom"]),M.label=F("label","tag",["atom"]),M.ref=F("ref","tag",["atom"]),M.eqref=F("eqref","tag",["atom"]),M.cite=F("cite","tag",["atom"]),M.bibitem=F("bibitem","tag",["atom"]),M.Bibitem=F("Bibitem","tag",["atom"]),M.RBibitem=F("RBibitem","tag",["atom"]),M.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function k(A,x){A.f=x}function v(A,x){var C;if(A.match(/^\\[a-zA-Z@]+/)){var u=A.current().slice(1);return C=M.hasOwnProperty(u)?M[u]:M.DEFAULT,C=new C,X(x,C),k(x,R),C.style}if(A.match(/^\\[$&%#{}_]/))return"tag";if(A.match(/^\\[,;!\/\\]/))return"tag";if(A.match("\\["))return k(x,function(l,h){return y(l,h,"\\]")}),"keyword";if(A.match("\\("))return k(x,function(l,h){return y(l,h,"\\)")}),"keyword";if(A.match("$$"))return k(x,function(l,h){return y(l,h,"$$")}),"keyword";if(A.match("$"))return k(x,function(l,h){return y(l,h,"$")}),"keyword";var o=A.next();if(o=="%")return A.skipToEnd(),"comment";if(o=="}"||o=="]"){if(C=O(x),C)C.closeBracket(o),k(x,R);else return"error";return"bracket"}else return o=="{"||o=="["?(C=M.DEFAULT,C=new C,X(x,C),"bracket"):/\d/.test(o)?(A.eatWhile(/[\w.%]/),"atom"):(A.eatWhile(/[\w\-_]/),C=W(x),C.name=="begin"&&(C.argument=A.current()),C.styleIdentifier())}function y(A,x,C){if(A.eatSpace())return null;if(C&&A.match(C))return k(x,v),"keyword";if(A.match(/^\\[a-zA-Z@]+/))return"tag";if(A.match(/^[a-zA-Z]+/))return"variable-2";if(A.match(/^\\[$&%#{}_]/))return"tag";if(A.match(/^\\[,;!\/]/))return"tag";if(A.match(/^[\^_&]/))return"tag";if(A.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(A.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var u=A.next();return u=="{"||u=="}"||u=="["||u=="]"||u=="("||u==")"?"bracket":u=="%"?(A.skipToEnd(),"comment"):"error"}function R(A,x){var C=A.peek(),u;return C=="{"||C=="["?(u=O(x),u.openBracket(C),A.eat(C),k(x,v),"bracket"):/[ \t\r]/.test(C)?(A.eat(C),null):(k(x,v),I(x),v(A,x))}return{startState:function(){var A=_.inMathMode?function(x,C){return y(x,C)}:v;return{cmdState:[],f:A}},copyState:function(A){return{cmdState:A.cmdState.slice(),f:A.f}},token:function(A,x){return x.f(A,x)},blankLine:function(A){A.f=v,A.cmdState.length=0},lineComment:"%"}}),oe.defineMIME("text/x-stex","stex"),oe.defineMIME("text/x-latex","stex")})},"19Vz":function(Et,ot,re){(function(oe){oe(re("VrN/"))})(function(oe){oe.defineOption("placeholder","",function(F,M,k){var v=k&&k!=oe.Init;if(M&&!v)F.on("blur",O),F.on("change",I),F.on("swapDoc",I),oe.on(F.getInputField(),"compositionupdate",F.state.placeholderCompose=function(){X(F)}),I(F);else if(!M&&v){F.off("blur",O),F.off("change",I),F.off("swapDoc",I),oe.off(F.getInputField(),"compositionupdate",F.state.placeholderCompose),Z(F);var y=F.getWrapperElement();y.className=y.className.replace(" CodeMirror-empty","")}M&&!F.hasFocus()&&O(F)});function Z(F){F.state.placeholder&&(F.state.placeholder.parentNode.removeChild(F.state.placeholder),F.state.placeholder=null)}function _(F){Z(F);var M=F.state.placeholder=document.createElement("pre");M.style.cssText="height: 0; overflow: visible",M.style.direction=F.getOption("direction"),M.className="CodeMirror-placeholder CodeMirror-line-like";var k=F.getOption("placeholder");typeof k=="string"&&(k=document.createTextNode(k)),M.appendChild(k),F.display.lineSpace.insertBefore(M,F.display.lineSpace.firstChild)}function X(F){setTimeout(function(){var M=!1,k=F.getInputField();k.nodeName=="TEXTAREA"?M=!k.value:F.lineCount()==1&&(M=!/[^\u200b]/.test(k.querySelector(".CodeMirror-line").textContent)),M?_(F):Z(F)},20)}function O(F){W(F)&&_(F)}function I(F){var M=F.getWrapperElement(),k=W(F);M.className=M.className.replace(" CodeMirror-empty","")+(k?" CodeMirror-empty":""),k?_(F):Z(F)}function W(F){return F.lineCount()===1&&F.getLine(0)===""}})},"1eCo":function(Et,ot,re){(function(oe){oe(re("VrN/"))})(function(oe){"use strict";var Z={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},_={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};oe.defineMode("xml",function(X,O){var I=X.indentUnit,W={},F=O.htmlMode?Z:_;for(var M in F)W[M]=F[M];for(var M in O)W[M]=O[M];var k,v;function y(a,E){function b(G){return E.tokenize=G,G(a,E)}var T=a.next();if(T=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?b(x("atom","]]>")):null:a.match("--")?b(x("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),b(C(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),E.tokenize=x("meta","?>"),"meta"):(k=a.eat("/")?"closeTag":"openTag",E.tokenize=R,"tag bracket");if(T=="&"){var P;return a.eat("#")?a.eat("x")?P=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):P=a.eatWhile(/[\d]/)&&a.eat(";"):P=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),P?"atom":"error"}else return a.eatWhile(/[^&<]/),null}y.isInText=!0;function R(a,E){var b=a.next();if(b==">"||b=="/"&&a.eat(">"))return E.tokenize=y,k=b==">"?"endTag":"selfcloseTag","tag bracket";if(b=="=")return k="equals",null;if(b=="<"){E.tokenize=y,E.state=h,E.tagName=E.tagStart=null;var T=E.tokenize(a,E);return T?T+" tag error":"tag error"}else return/[\'\"]/.test(b)?(E.tokenize=A(b),E.stringStartCol=a.column(),E.tokenize(a,E)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function A(a){var E=function(b,T){for(;!b.eol();)if(b.next()==a){T.tokenize=R;break}return"string"};return E.isInAttribute=!0,E}function x(a,E){return function(b,T){for(;!b.eol();){if(b.match(E)){T.tokenize=y;break}b.next()}return a}}function C(a){return function(E,b){for(var T;(T=E.next())!=null;){if(T=="<")return b.tokenize=C(a+1),b.tokenize(E,b);if(T==">")if(a==1){b.tokenize=y;break}else return b.tokenize=C(a-1),b.tokenize(E,b)}return"meta"}}function u(a,E,b){this.prev=a.context,this.tagName=E,this.indent=a.indented,this.startOfLine=b,(W.doNotIndent.hasOwnProperty(E)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function l(a,E){for(var b;;){if(!a.context)return;if(b=a.context.tagName,!W.contextGrabbers.hasOwnProperty(b)||!W.contextGrabbers[b].hasOwnProperty(E))return;o(a)}}function h(a,E,b){return a=="openTag"?(b.tagStart=E.column(),L):a=="closeTag"?f:h}function L(a,E,b){return a=="word"?(b.tagName=E.current(),v="tag",S):W.allowMissingTagName&&a=="endTag"?(v="tag bracket",S(a,E,b)):(v="error",L)}function f(a,E,b){if(a=="word"){var T=E.current();return b.context&&b.context.tagName!=T&&W.implicitlyClosed.hasOwnProperty(b.context.tagName)&&o(b),b.context&&b.context.tagName==T||W.matchClosing===!1?(v="tag",p):(v="tag error",D)}else return W.allowMissingTagName&&a=="endTag"?(v="tag bracket",p(a,E,b)):(v="error",D)}function p(a,E,b){return a!="endTag"?(v="error",p):(o(b),h)}function D(a,E,b){return v="error",p(a,E,b)}function S(a,E,b){if(a=="word")return v="attribute",g;if(a=="endTag"||a=="selfcloseTag"){var T=b.tagName,P=b.tagStart;return b.tagName=b.tagStart=null,a=="selfcloseTag"||W.autoSelfClosers.hasOwnProperty(T)?l(b,T):(l(b,T),b.context=new u(b,T,P==b.indented)),h}return v="error",S}function g(a,E,b){return a=="equals"?c:(W.allowMissing||(v="error"),S(a,E,b))}function c(a,E,b){return a=="string"?d:a=="word"&&W.allowUnquoted?(v="string",S):(v="error",S(a,E,b))}function d(a,E,b){return a=="string"?d:S(a,E,b)}return{startState:function(a){var E={tokenize:y,state:h,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(E.baseIndent=a),E},token:function(a,E){if(!E.tagName&&a.sol()&&(E.indented=a.indentation()),a.eatSpace())return null;k=null;var b=E.tokenize(a,E);return(b||k)&&b!="comment"&&(v=null,E.state=E.state(k||b,a,E),v&&(b=v=="error"?b+" error":v)),b},indent:function(a,E,b){var T=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+I;if(T&&T.noIndent)return oe.Pass;if(a.tokenize!=R&&a.tokenize!=y)return b?b.match(/^(\s*)/)[0].length:0;if(a.tagName)return W.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+I*(W.multilineTagIndentFactor||1);if(W.alignCDATA&&/<!\[CDATA\[/.test(E))return 0;var P=E&&/^<(\/)?([\w_:\.-]*)/.exec(E);if(P&&P[1])for(;T;)if(T.tagName==P[2]){T=T.prev;break}else if(W.implicitlyClosed.hasOwnProperty(T.tagName))T=T.prev;else break;else if(P)for(;T;){var G=W.contextGrabbers[T.tagName];if(G&&G.hasOwnProperty(P[2]))T=T.prev;else break}for(;T&&T.prev&&!T.startOfLine;)T=T.prev;return T?T.indent+I:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:W.htmlMode?"html":"xml",helperType:W.htmlMode?"html":"xml",skipAttribute:function(a){a.state==c&&(a.state=S)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var E=[],b=a.context;b;b=b.prev)b.tagName&&E.push(b.tagName);return E.reverse()}}}),oe.defineMIME("text/xml","xml"),oe.defineMIME("application/xml","xml"),oe.mimeModes.hasOwnProperty("text/html")||oe.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"30zm":function(Et,ot,re){"use strict";var oe=re("jCWc"),Z=re("kPKH"),_=re("k1fw"),X=re("tJVT"),O=re("PpiC"),I=re("B9cy"),W=re("Ol7k"),F=re("lUTK"),M=re("BvKs"),k=re("q1tI"),v=re.n(k),y=re("Ty5D"),R=re("55Ip"),A=re("9kvl"),x=re("m3rI"),C=re("kzJb"),u=re.n(C),o=M.a.SubMenu,l=W.a.Sider,h=W.a.Content,L=function(p){var D=p.messages,S=p.globalSetting,g=p.loading,c=p.user,d=p.dispatch,a=Object(O.a)(p,["messages","globalSetting","loading","user","dispatch"]),E=Object(y.i)(),b=c.userInfo,T=Object(y.h)(),P=D.tidingsList,G=D.privateMessage,Y=D.unreadInfo,Q=Object(k.useState)({per_page:10,page:1}),z=Object(X.a)(Q,2),j=z[0],q=z[1];Object(k.useEffect)(function(){ae()},[E.userId]);var ae=function(){d({type:"messages/unreadMessageInfo",payload:Object(_.a)(Object(_.a)({},j),E)})};return v.a.createElement(Z.a,{flex:"264px"},v.a.createElement("aside",{className:u.a.userInfo},v.a.createElement("img",{className:"mt40",src:x.a.IMG_SERVER+"/images/"+(b==null?void 0:b.image_url)}),v.a.createElement("p",{className:"font24 mt10"},b==null?void 0:b.username),v.a.createElement("p",{className:"mt20"},b==null?void 0:b.user_identity)),v.a.createElement("ul",{className:u.a.navInfo},v.a.createElement(R.a,{to:"/messages/".concat(b==null?void 0:b.login,"/user_tidings")},v.a.createElement("li",{className:T.pathname.indexOf("user_tidings")>-1&&u.a.actived},"\u6D88\u606F",!!(Y!=null&&Y.unread_tiding_count)&&v.a.createElement("span",{className:u.a.newTip},Y==null?void 0:Y.unread_tiding_count))),v.a.createElement(R.a,{to:"/messages/".concat(b==null?void 0:b.login,"/private_messages")},v.a.createElement("li",{className:(T.pathname.indexOf("private_messages")>-1||T.pathname.indexOf("message_detail")>-1)&&u.a.actived},"\u79C1\u4FE1",!!(Y!=null&&Y.unread_message_count)&&v.a.createElement("span",{className:u.a.newTip},Y==null?void 0:Y.unread_message_count)))))};ot.a=Object(A.a)(function(f){var p=f.messages,D=f.loading,S=f.user,g=f.globalSetting;return{messages:p,globalSetting:g,user:S,loading:D.effects}})(L)},"55Ip":function(Et,ot,re){"use strict";re.d(ot,"a",function(){return l}),re.d(ot,"b",function(){return S});var oe=re("Ty5D"),Z=re("dI71"),_=re("q1tI"),X=re.n(_),O=re("YS25"),I=re("17x9"),W=re.n(I),F=re("wx14"),M=re("zLVn"),k=re("9R94"),v=function(c){Object(Z.a)(d,c);function d(){for(var E,b=arguments.length,T=new Array(b),P=0;P<b;P++)T[P]=arguments[P];return E=c.call.apply(c,[this].concat(T))||this,E.history=Object(O.a)(E.props),E}var a=d.prototype;return a.render=function(){return X.a.createElement(oe.c,{history:this.history,children:this.props.children})},d}(X.a.Component),y=function(c){Object(Z.a)(d,c);function d(){for(var E,b=arguments.length,T=new Array(b),P=0;P<b;P++)T[P]=arguments[P];return E=c.call.apply(c,[this].concat(T))||this,E.history=Object(O.b)(E.props),E}var a=d.prototype;return a.render=function(){return X.a.createElement(oe.c,{history:this.history,children:this.props.children})},d}(X.a.Component),R=function(d,a){return typeof d=="function"?d(a):d},A=function(d,a){return typeof d=="string"?Object(O.c)(d,null,null,a):d},x=function(d){return d},C=X.a.forwardRef;typeof C=="undefined"&&(C=x);function u(c){return!!(c.metaKey||c.altKey||c.ctrlKey||c.shiftKey)}var o=C(function(c,d){var a=c.innerRef,E=c.navigate,b=c.onClick,T=Object(M.a)(c,["innerRef","navigate","onClick"]),P=T.target,G=Object(F.a)({},T,{onClick:function(Q){try{b&&b(Q)}catch(z){throw Q.preventDefault(),z}!Q.defaultPrevented&&Q.button===0&&(!P||P==="_self")&&!u(Q)&&(Q.preventDefault(),E())}});return x!==C?G.ref=d||a:G.ref=a,X.a.createElement("a",G)}),l=C(function(c,d){var a=c.component,E=a===void 0?o:a,b=c.replace,T=c.to,P=c.innerRef,G=Object(M.a)(c,["component","replace","to","innerRef"]);return X.a.createElement(oe.e.Consumer,null,function(Y){Y||Object(k.a)(!1);var Q=Y.history,z=A(R(T,Y.location),Y.location),j=z?Q.createHref(z):"",q=Object(F.a)({},G,{href:j,navigate:function(){var ce=R(T,Y.location),ve=b?Q.replace:Q.push;ve(ce)}});return x!==C?q.ref=d||P:q.innerRef=P,X.a.createElement(E,q)})});if(!1)var h,L;var f=function(d){return d},p=X.a.forwardRef;typeof p=="undefined"&&(p=f);function D(){for(var c=arguments.length,d=new Array(c),a=0;a<c;a++)d[a]=arguments[a];return d.filter(function(E){return E}).join(" ")}var S=p(function(c,d){var a=c["aria-current"],E=a===void 0?"page":a,b=c.activeClassName,T=b===void 0?"active":b,P=c.activeStyle,G=c.className,Y=c.exact,Q=c.isActive,z=c.location,j=c.sensitive,q=c.strict,ae=c.style,ce=c.to,ve=c.innerRef,ke=Object(M.a)(c,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return X.a.createElement(oe.e.Consumer,null,function(Ee){Ee||Object(k.a)(!1);var Ce=z||Ee.location,Le=A(R(ce,Ce),Ce),we=Le.pathname,me=we&&we.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),le=me?Object(oe.f)(Ce.pathname,{path:me,exact:Y,sensitive:j,strict:q}):null,Oe=!!(Q?Q(le,Ce):le),Ye=Oe?D(G,T):G,Ve=Oe?Object(F.a)({},ae,{},P):ae,$e=Object(F.a)({"aria-current":Oe&&E||null,className:Ye,style:Ve,to:Le},ke);return f!==p?$e.ref=d||ve:$e.innerRef=ve,X.a.createElement(l,$e)})});if(!1)var g},"7Cbv":function(Et,ot,re){"use strict";var oe=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),Z=new Uint8Array(16);function _(){if(!oe)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return oe(Z)}var X=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function O(R){return typeof R=="string"&&X.test(R)}for(var I=O,W=[],F=0;F<256;++F)W.push((F+256).toString(16).substr(1));function M(R){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,x=(W[R[A+0]]+W[R[A+1]]+W[R[A+2]]+W[R[A+3]]+"-"+W[R[A+4]]+W[R[A+5]]+"-"+W[R[A+6]]+W[R[A+7]]+"-"+W[R[A+8]]+W[R[A+9]]+"-"+W[R[A+10]]+W[R[A+11]]+W[R[A+12]]+W[R[A+13]]+W[R[A+14]]+W[R[A+15]]).toLowerCase();if(!I(x))throw TypeError("Stringified UUID is invalid");return x}var k=M;function v(R,A,x){R=R||{};var C=R.random||(R.rng||_)();if(C[6]=C[6]&15|64,C[8]=C[8]&63|128,A){x=x||0;for(var u=0;u<16;++u)A[x+u]=C[u];return A}return k(C)}var y=ot.a=v},"7ahc":function(Et,ot,re){"use strict";re.d(ot,"a",function(){return L});var oe=re("k1fw"),Z=re("0Owb"),_=re("+L6B"),X=re("2/Rp"),O=re("y8nQ"),I=re("Vl3Y"),W=re("tJVT"),F=re("OaEy"),M=re("2fM7"),k=re("q1tI"),v=re.n(k),y=re("VrN/"),R=re.n(y),A=re("p77/"),x=re.n(A),C=re("c5Ni"),u=re.n(C),o=M.a.Option,l={labelCol:{span:4},wrapperCol:{span:20}},h={asp:["ASP","vbscript"],actionscript:["ActionScript(3.0)/Flash/Flex","clike"],bash:["Bash/Bat","shell"],css:["CSS","css"],c:["C","clike"],cpp:["C++","clike"],csharp:["C#","clike"],coffeescript:["CoffeeScript","coffeescript"],d:["D","d"],dart:["Dart","dart"],delphi:["Delphi/Pascal","pascal"],erlang:["Erlang","erlang"],go:["Golang","go"],groovy:["Groovy","groovy"],html:["HTML","text/html"],java:["Java","clike"],json:["JSON","text/json"],javascript:["Javascript","javascript"],lua:["Lua","lua"],less:["LESS","css"],markdown:["Markdown","gfm"],"objective-c":["Objective-C","clike"],php:["PHP","php"],perl:["Perl","perl"],python:["Python","python"],r:["R","r"],rst:["reStructedText","rst"],ruby:["Ruby","ruby"],sql:["SQL","sql"],sass:["SASS/SCSS","sass"],shell:["Shell","shell"],scala:["Scala","clike"],swift:["Swift","clike"],vb:["VB/VBScript","vb"],xml:["XML","text/xml"],yaml:["YAML","yaml"]};ot.b=function(f){var p=f.callback,D=f.onCancel,S=Object(k.useState)("python"),g=Object(W.a)(S,2),c=g[0],d=g[1];function a(b){d(h[b][1])}function E(b){p(b)}return v.a.createElement(I.a,Object(Z.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:E}),v.a.createElement(I.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},v.a.createElement(M.a,{onChange:a},Object.keys(h).map(function(b){return v.a.createElement(o,{key:b,value:b},h[b][0])}))),v.a.createElement(I.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},v.a.createElement(L,{mode:c})),v.a.createElement("div",{className:"flex-container flex-end"},v.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),v.a.createElement(X.a,{type:"ghost",onClick:D},"\u53D6\u6D88")))};function L(f){var p=f.value,D=f.onChange,S=f.mode,g=f.options,c=g===void 0?{}:g,d=Object(k.useRef)(),a=Object(k.useState)(),E=Object(W.a)(a,2),b=E[0],T=E[1];return Object(k.useEffect)(function(){if(b){function P(G){var Y=G.getValue();D&&D(Y)}return b.on("change",P),function(){b.off("change",P)}}},[b,D]),Object(k.useEffect)(function(){b&&b.setOption("mode",S)},[b,S]),Object(k.useEffect)(function(){b&&((p!==b.getValue()||p==="")&&setTimeout(function(){b.setValue(p||" ")},300))},[b,p]),Object(k.useEffect)(function(){if(d.current&&!b){var P=R.a.fromTextArea(d.current,Object(oe.a)({mode:S,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},c));T(P)}},[d.current,b]),v.a.createElement("div",{className:"my-codemirror-container"},v.a.createElement("textarea",{ref:d}))}},"8EBN":function(Et,ot,re){(function(oe){oe(re("VrN/"))})(function(oe){"use strict";oe.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var Z=0;Z<oe.modeInfo.length;Z++){var _=oe.modeInfo[Z];_.mimes&&(_.mime=_.mimes[0])}oe.findModeByMIME=function(X){X=X.toLowerCase();for(var O=0;O<oe.modeInfo.length;O++){var I=oe.modeInfo[O];if(I.mime==X)return I;if(I.mimes){for(var W=0;W<I.mimes.length;W++)if(I.mimes[W]==X)return I}}if(/\+xml$/.test(X))return oe.findModeByMIME("application/xml");if(/\+json$/.test(X))return oe.findModeByMIME("application/json")},oe.findModeByExtension=function(X){X=X.toLowerCase();for(var O=0;O<oe.modeInfo.length;O++){var I=oe.modeInfo[O];if(I.ext){for(var W=0;W<I.ext.length;W++)if(I.ext[W]==X)return I}}},oe.findModeByFileName=function(X){for(var O=0;O<oe.modeInfo.length;O++){var I=oe.modeInfo[O];if(I.file&&I.file.test(X))return I}var W=X.lastIndexOf("."),F=W>-1&&X.substring(W+1,X.length);if(F)return oe.findModeByExtension(F)},oe.findModeByName=function(X){X=X.toLowerCase();for(var O=0;O<oe.modeInfo.length;O++){var I=oe.modeInfo[O];if(I.name.toLowerCase()==X)return I;if(I.alias){for(var W=0;W<I.alias.length;W++)if(I.alias[W].toLowerCase()==X)return I}}}})},"8hTe":function(Et,ot,re){Et.exports={button:"button___1wy9m"}},"9Bee":function(Et,ot,re){"use strict";var oe=re("DYRE"),Z=re("zeV3"),_=re("+L6B"),X=re("2/Rp"),O=re("k1fw"),I=re("9og8"),W=re("tJVT"),F=re("WmNS"),M=re.n(F),k=re("q1tI"),v=re.n(k),y=re("vg9a"),R=re("DlQD"),A=re.n(R),x=re("rUJ1");function C(H,s){var m=H.match(/^(\s+)(?:```)/);if(m===null)return s;var B=m[1];return s.split(`
|
|
`).map(function(K){var U=K.match(/^\s+/);if(U===null)return K;var he=Object(W.a)(U,1),Pe=he[0];return Pe.length>=B.length?K.slice(B.length):K}).join(`
|
|
`)}var u=[],o=["<ul>"],l=new A.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function L(){u.length=0,o=["<ul>"]}var f={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function p(H,s,m,B){if(s>=H.length||H[s].level<=m)return s;var K=H[s];B.push("<li><a href='#"+K.anchor+"'>"+K.text+"</a>"),s++;var U=[];return s=p(H,s,K.level,U),U.length>0&&(B.push("<ul>"),U.forEach(function(he){B.push(he)}),B.push("</ul>")),B.push("</li>"),s=p(H,s,m,B),s}function D(){return p(u,0,0,o),o.push("</ul>"),o.join("")}var S={heading:function(s){var m=h.exec(s);if(m)return{type:"heading",raw:m[0],depth:m[1].length,text:m[2]}},fences:function(s){var m=this.rules.block.fences.exec(s);if(m){var B=m[0],K=C(B,m[3]||""),U=m[2]?m[2].trim():m[2];if(["latex","katex","math"].indexOf(U)>=0){var he=d(),Pe=K;K=he,a[he]={type:"block",expression:Pe}}return{type:"code",raw:B,lang:U,text:K}}}},g=/(?:\${2})([^\n`]+?)(?:\${2})/gi,c=0,d=function(){return"__special_katext_id_".concat(c++,"__")},a={};function E(){return a}function b(){c=0,a={}}function T(H){return H=H.replace(g,function(s,m){var B=d();return a[B]={type:"inline",expression:m},B}),H}var P=l.listitem;l.listitem=function(H){return P(T(H))};var G=l.paragraph;l.paragraph=function(H){return G(T(H))};var Y=l.tablecell;l.tablecell=function(H,s){return Y(T(H),s)},l.code=function(H,s,m){var B=(s||"").match(/\S*/)[0];return B?["latex","katex","math"].indexOf(B)>=0?"<p class='editormd-tex'>".concat(H,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(m?H:Object(x.escape)(H,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(m?H:Object(x.escape)(H,!0))+"</code></pre>"},l.heading=function(H,s,m){var B=this.options.headerPrefix+m.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return u.push({anchor:B,level:s,text:H}),"<h"+s+' id="'+B+'">'+H+"</h"+s+">"},A.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),A.a.use({tokenizer:S,renderer:l});var Q=A.a,z=re("SJMd"),j=re("ulZh"),q=re.n(j),ae=re("m3rI"),ce=re("Oy/b"),ve=re("p5ED"),ke=re("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 Ee=function(H,s){return(Ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,B){m.__proto__=B}||function(m,B){for(var K in B)Object.prototype.hasOwnProperty.call(B,K)&&(m[K]=B[K])})(H,s)};function Ce(H,s){function m(){this.constructor=H}Ee(H,s),H.prototype=s===null?Object.create(s):(m.prototype=s.prototype,new m)}function Le(H,s,m,B){return new(m||(m=Promise))(function(K,U){function he(ct){try{et(B.next(ct))}catch(Be){U(Be)}}function Pe(ct){try{et(B.throw(ct))}catch(Be){U(Be)}}function et(ct){var Be;ct.done?K(ct.value):(Be=ct.value,Be instanceof m?Be:new m(function(Ct){Ct(Be)})).then(he,Pe)}et((B=B.apply(H,s||[])).next())})}function we(H,s){var m,B,K,U,he={label:0,sent:function(){if(1&K[0])throw K[1];return K[1]},trys:[],ops:[]};return U={next:Pe(0),throw:Pe(1),return:Pe(2)},typeof Symbol=="function"&&(U[Symbol.iterator]=function(){return this}),U;function Pe(et){return function(ct){return function(Be){if(m)throw new TypeError("Generator is already executing.");for(;he;)try{if(m=1,B&&(K=2&Be[0]?B.return:Be[0]?B.throw||((K=B.return)&&K.call(B),0):B.next)&&!(K=K.call(B,Be[1])).done)return K;switch(B=0,K&&(Be=[2&Be[0],K.value]),Be[0]){case 0:case 1:K=Be;break;case 4:return he.label++,{value:Be[1],done:!1};case 5:he.label++,B=Be[1],Be=[0];continue;case 7:Be=he.ops.pop(),he.trys.pop();continue;default:if(!(K=he.trys,(K=K.length>0&&K[K.length-1])||Be[0]!==6&&Be[0]!==2)){he=0;continue}if(Be[0]===3&&(!K||Be[1]>K[0]&&Be[1]<K[3])){he.label=Be[1];break}if(Be[0]===6&&he.label<K[1]){he.label=K[1],K=Be;break}if(K&&he.label<K[2]){he.label=K[2],he.ops.push(Be);break}K[2]&&he.ops.pop(),he.trys.pop();continue}Be=s.call(H,he)}catch(Ct){Be=[6,Ct],B=0}finally{m=K=0}if(5&Be[0])throw Be[1];return{value:Be[0]?Be[1]:void 0,done:!0}}([et,ct])}}}function me(){for(var H=0,s=0,m=arguments.length;s<m;s++)H+=arguments[s].length;var B=Array(H),K=0;for(s=0;s<m;s++)for(var U=arguments[s],he=0,Pe=U.length;he<Pe;he++,K++)B[K]=U[he];return B}var le=function(){function H(){}return H.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},H.setAttributes=function(s,m){for(var B=0,K=m;B<K.length;B++){var U=K[B],he=U[0],Pe=U[1];s.setAttribute(he,Pe)}},H.createRect=function(s,m,B){var K=document.createElementNS("http://www.w3.org/2000/svg","rect");return K.setAttribute("width",s.toString()),K.setAttribute("height",m.toString()),B&&H.setAttributes(K,B),K},H.createLine=function(s,m,B,K,U){var he=document.createElementNS("http://www.w3.org/2000/svg","line");return he.setAttribute("x1",s.toString()),he.setAttribute("y1",m.toString()),he.setAttribute("x2",B.toString()),he.setAttribute("y2",K.toString()),U&&H.setAttributes(he,U),he},H.createPolygon=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg","polygon");return B.setAttribute("points",s),m&&H.setAttributes(B,m),B},H.createCircle=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg","circle");return B.setAttribute("cx",(s/2).toString()),B.setAttribute("cy",(s/2).toString()),B.setAttribute("r",s.toString()),m&&H.setAttributes(B,m),B},H.createEllipse=function(s,m,B){var K=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return K.setAttribute("cx",(s/2).toString()),K.setAttribute("cy",(m/2).toString()),K.setAttribute("rx",(s/2).toString()),K.setAttribute("ry",(m/2).toString()),B&&H.setAttributes(K,B),K},H.createGroup=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&H.setAttributes(m,s),m},H.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},H.createMarker=function(s,m,B,K,U,he,Pe){var et=document.createElementNS("http://www.w3.org/2000/svg","marker");return H.setAttributes(et,[["id",s],["orient",m],["markerWidth",B.toString()],["markerHeight",K.toString()],["refX",U.toString()],["refY",he.toString()]]),et.appendChild(Pe),et},H.createText=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","text");return m.setAttribute("x","0"),m.setAttribute("y","0"),s&&H.setAttributes(m,s),m},H.createTSpan=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg","tspan");return B.textContent=s,m&&H.setAttributes(B,m),B},H.createImage=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&H.setAttributes(m,s),m},H.createPoint=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return B.x=s,B.y=m,B},H.createPath=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg","path");return B.setAttribute("d",s),m&&H.setAttributes(B,m),B},H}(),Oe=function(){function H(){}return H.addKey=function(s){H.key=s},Object.defineProperty(H,"isLicensed",{get:function(){return!!H.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(H.key)},enumerable:!1,configurable:!0}),H}(),Ye=function(){function H(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return H.prototype.rasterize=function(s,m,B){var K=this;return new Promise(function(U){var he=B!==void 0?B:document.createElement("canvas");s===null&&(K.markersOnly=!0,K.naturalSize=!1);var Pe=document.createElementNS("http://www.w3.org/2000/svg","svg");Pe.setAttribute("xmlns","http://www.w3.org/2000/svg"),Pe.setAttribute("width",m.width.baseVal.valueAsString),Pe.setAttribute("height",m.height.baseVal.valueAsString),Pe.setAttribute("viewBox","0 0 "+m.viewBox.baseVal.width.toString()+" "+m.viewBox.baseVal.height.toString()),Pe.innerHTML=m.innerHTML,K.naturalSize===!0?(Pe.width.baseVal.value=s.naturalWidth,Pe.height.baseVal.value=s.naturalHeight):K.width!==void 0&&K.height!==void 0&&(Pe.width.baseVal.value=K.width,Pe.height.baseVal.value=K.height),he.width=Pe.width.baseVal.value,he.height=Pe.height.baseVal.value;var et=Pe.outerHTML,ct=he.getContext("2d");K.markersOnly!==!0&&ct.drawImage(s,0,0,he.width,he.height);var Be=window.URL,Ct=new Image(he.width,he.height);Ct.setAttribute("crossOrigin","anonymous");var Ot=new Blob([et],{type:"image/svg+xml"}),Yt=Be.createObjectURL(Ot);Ct.onload=function(){ct.drawImage(Ct,0,0),Be.revokeObjectURL(Yt);var Wr=he.toDataURL(K.imageType,K.imageQuality);U(Wr)},Ct.src=Yt})},H}(),Ve=function(){},$e=function(){function H(s){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(H.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),H.prototype.addClass=function(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},H.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},H.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new ze("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new ze("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new ze("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new Se("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new Se("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},H.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},H}(),ze=function(H,s){this.selector=H,this.style=s},Se=function(H,s){this.localName=H,this.style=s},De=function(){function H(s,m,B,K,U){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=s,this.displayMode=m,this.markerItems=B,this.uiStyleSettings=K,this.styles=U,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return H.prototype.show=function(s){var m=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var B=document.createElement("div");B.className=this.toolbarBlockStyleClass.name,B.style.whiteSpace="nowrap",this.uiContainer.appendChild(B),this.addActionButton(B,'<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(B,'<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(B,'<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(B,'<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(B,'<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(B,'<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(B,'<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(B,'<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(U){var he=document.createElement("div");he.className=""+m.toolbarButtonStyleClass.name,he.setAttribute("data-type-name",U.typeName),he.innerHTML=U.icon,he.addEventListener("click",function(){m.markerToolbarButtonClicked(he,U)}),m.buttons.push(he),m.markerButtons.push(he)}),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 K=document.createElement("div");K.className=this.toolbarBlockStyleClass.name,K.style.whiteSpace="nowrap",K.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(K),this.addActionButton(K,'<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(K,'<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()},H.prototype.addButtonClickListener=function(s){this.buttonClickListeners.push(s)},H.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},H.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},H.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var s=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var m=0;m<this.markerButtons.length;m++)m<s||m===s&&this.markerButtons.length-1===s?this.markerButtonBlock.appendChild(this.markerButtons[m]):(m===s&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[m]))}},H.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")},H.prototype.resetButtonStyles=function(){var s=this;this.buttons.forEach(function(m){m.className=m.className.replace(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name,"").trim(),m.className=m.className.replace(s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:s.toolbarActiveButtonStyleColorsClass.name,"").trim(),m.className+=" "+(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name)})},H.prototype.addActionButton=function(s,m,B){var K=this,U=document.createElement("div");switch(U.className=""+this.toolbarButtonStyleClass.name,U.innerHTML=m,U.setAttribute("data-action",B),U.addEventListener("click",function(){K.actionToolbarButtonClicked(U,B)}),B){case"select":U.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":U.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":U.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":U.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":U.style.fill=this.uiStyleSettings.closeButtonColor}s.appendChild(U),this.buttons.push(U)},H.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Se("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 Se("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Se("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new Se("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 Se("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Se("toolbar_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.toolbarButtonStyleColorsClass=this.styles.addClass(new Se("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Se("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new ze("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new ze("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},H.prototype.markerToolbarButtonClicked=function(s,m){this.setActiveButton(s),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(B){return B("marker",m)}),this.markerButtonOverflowBlock.style.display="none"},H.prototype.actionToolbarButtonClicked=function(s,m){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(B){return B("action",m)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},H.prototype.setActiveButton=function(s){this.resetButtonStyles(),s.className=s.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),s.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},H.prototype.setActiveMarkerButton=function(s){var m=this.markerButtons.find(function(B){return B.getAttribute("data-type-name")===s});m&&this.setActiveButton(m)},H.prototype.setCurrentMarker=function(s){var m=this;this.currentMarker=s,this.buttons.filter(function(B){return/delete|notes/.test(B.getAttribute("data-action"))}).forEach(function(B){m.currentMarker===void 0?(B.style.fillOpacity="0.4",B.style.pointerEvents="none"):(B.style.fillOpacity="1",B.style.pointerEvents="all")})},H}(),Ne=function(){function H(s,m,B,K){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=m,this.uiStyleSettings=B,this.styles=K,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return H.prototype.addStyles=function(){var s;this.toolboxStyleClass=this.styles.addClass(new Se("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 Se("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var m=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new Se("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new Se("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new Se("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 Se("toolbox-panel-row_colors",`
|
|
background-color: `+((s=this.uiStyleSettings.toolboxBackgroundColor)!==null&&s!==void 0?s:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new Se("toolbox_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*m)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*m)+`px;
|
|
padding: `+m+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new Se("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new Se("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new ze("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new ze("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},H.prototype.show=function(s){var m;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolboxStyleClass.name+" "+((m=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&m!==void 0?m:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},H.prototype.setPanelButtons=function(s){var m,B,K=this;this.panels=s,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((m=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&m!==void 0?m:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((B=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&B!==void 0?B:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(U){var he;U.uiStyleSettings=K.uiStyleSettings;var Pe=document.createElement("div");Pe.className=K.toolboxButtonStyleClass.name+" "+((he=K.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&he!==void 0?he:K.toolboxButtonStyleColorsClass.name),Pe.innerHTML=U.icon,Pe.title=U.title,Pe.addEventListener("click",function(){K.panelButtonClick(U)}),K.panelButtons.push(Pe),K.buttonRow.appendChild(Pe)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},H.prototype.panelButtonClick=function(s){var m=this,B=-1;if(s!==this.activePanel){B=this.panels.indexOf(s),this.panelRow.innerHTML="";var K=s.getUi();K.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(K),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=s}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){m.displayMode==="inline"?m.panelRow.style.display="none":m.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(U,he){var Pe,et;U.className=m.toolboxButtonStyleClass.name+" "+(he===B?""+((Pe=m.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Pe!==void 0?Pe:m.toolboxActiveButtonStyleColorsClass.name):""+((et=m.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&et!==void 0?et:m.toolboxButtonStyleColorsClass.name))})},H}(),Ge=function(H,s){this.title=H,this.icon=s},je=function(H){function s(m,B,K,U){var he=H.call(this,m,U||'<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 he.colors=[],he.addTransparent=!1,he.colorBoxes=[],he.colors=B,he.currentColor=K,he.setCurrentColor=he.setCurrentColor.bind(he),he.getColorBox=he.getColorBox.bind(he),he}return Ce(s,H),s.prototype.getUi=function(){var m=this,B=document.createElement("div");return B.style.overflow="hidden",B.style.whiteSpace="nowrap",this.colors.forEach(function(K){var U=m.getColorBox(K);B.appendChild(U),m.colorBoxes.push(U)}),B},s.prototype.getColorBox=function(m){var B=this,K=this.uiStyleSettings.toolbarHeight/4,U=this.uiStyleSettings.toolbarHeight-K,he=document.createElement("div");he.style.display="inline-block",he.style.boxSizing="content-box",he.style.width=U-2+"px",he.style.height=U-2+"px",he.style.padding="1px",he.style.marginRight="2px",he.style.marginBottom="2px",he.style.borderWidth="2px",he.style.borderStyle="solid",he.style.borderRadius=(U+2)/2+"px",he.style.borderColor=m===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",he.addEventListener("click",function(){B.setCurrentColor(m,he)});var Pe=document.createElement("div");return Pe.style.display="inline-block",Pe.style.width=U-2+"px",Pe.style.height=U-2+"px",Pe.style.backgroundColor=m,Pe.style.borderRadius=U/2+"px",m==="transparent"&&(Pe.style.fill=this.uiStyleSettings.toolboxAccentColor,Pe.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>`),he.appendChild(Pe),he},s.prototype.setCurrentColor=function(m,B){var K=this;this.currentColor=m,this.colorBoxes.forEach(function(U){U.style.borderColor=U===B?K.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(m)},s}(Ge),Me=function(){function H(s,m,B){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=m,this.globalSettings=B,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(H.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),H.prototype.ownsTarget=function(s){return!1},Object.defineProperty(H.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),H.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},H.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},H.prototype.pointerDown=function(s,m){},H.prototype.dblClick=function(s,m){},H.prototype.manipulate=function(s){},H.prototype.pointerUp=function(s){this.stateChanged()},H.prototype.dispose=function(){},H.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},H.prototype.getState=function(){return{typeName:H.typeName,state:this.state,notes:this.notes}},H.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},H.prototype.scale=function(s,m){},H.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},H.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},H.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var s=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),s.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(s)&&this.onStateChanged(this)}},H.typeName="MarkerBase",H}(),Ie=function(){function H(){this.findGripByVisual=this.findGripByVisual.bind(this)}return H.prototype.findGripByVisual=function(s){return this.topLeft.ownsTarget(s)?this.topLeft:this.topCenter.ownsTarget(s)?this.topCenter:this.topRight.ownsTarget(s)?this.topRight:this.centerLeft.ownsTarget(s)?this.centerLeft:this.centerRight.ownsTarget(s)?this.centerRight:this.bottomLeft.ownsTarget(s)?this.bottomLeft:this.bottomCenter.ownsTarget(s)?this.bottomCenter:this.bottomRight.ownsTarget(s)?this.bottomRight:void 0},H}(),lt=function(){function H(){this.GRIP_SIZE=10,this.visual=le.createGroup(),this.visual.appendChild(le.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(le.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return H.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},H}(),tt=function(){function H(){}return H.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},H.toSVGMatrix=function(s,m){return s.a=m.a,s.b=m.b,s.c=m.c,s.d=m.d,s.e=m.e,s.f=m.f,s},H}(),qe=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.left=0,U.top=0,U.width=0,U.height=0,U.defaultSize={x:50,y:20},U.offsetX=0,U.offsetY=0,U.rotationAngle=0,U.CB_DISTANCE=10,U._suppressMarkerCreateEvent=!1,U.container.transform.baseVal.appendItem(le.createTransform()),U.setupControlBox(),U}return Ce(s,H),Object.defineProperty(s.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"visual",{get:function(){return this._visual},set:function(m){this._visual=m;var B=le.createTransform();this._visual.transform.baseVal.appendItem(B)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(m){return!!H.prototype.ownsTarget.call(this,m)||!!(this.controlGrips.findGripByVisual(m)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(m))},s.prototype.pointerDown=function(m,B){H.prototype.pointerDown.call(this,m,B),this.state==="new"&&(this.left=m.x,this.top=m.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var K=this.unrotatePoint(m);if(this.manipulationStartX=K.x,this.manipulationStartY=K.y,this.offsetX=K.x-this.left,this.offsetY=K.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(B),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(B)){this.activeGrip=this.rotatorGrip;var U=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=U.x-this.width/2,this.top=U.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var he=this.container.transform.baseVal.getItem(0);he.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(he,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(m){var B=this.state;H.prototype.pointerUp.call(this,m),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(m),this._state="select",B==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},s.prototype.moveVisual=function(m){this.visual.style.transform="translate("+m.x+"px, "+m.y+"px)"},s.prototype.manipulate=function(m){var B=this.unrotatePoint(m);this.state==="creating"?this.resize(m):this.state==="move"?(this.left=this.manipulationStartLeft+(B.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(B.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(B):this.state==="rotate"&&this.rotate(m)},s.prototype.resize=function(m){var B=this.manipulationStartLeft,K=this.manipulationStartWidth,U=this.manipulationStartTop,he=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:B=this.manipulationStartLeft+m.x-this.manipulationStartX,K=this.manipulationStartWidth+this.manipulationStartLeft-B;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:K=this.manipulationStartWidth+m.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:U=this.manipulationStartTop+m.y-this.manipulationStartY,he=this.manipulationStartHeight+this.manipulationStartTop-U;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:he=this.manipulationStartHeight+m.y-this.manipulationStartY}K>=0?(this.left=B,this.width=K):(this.left=B+K,this.width=-K),he>=0?(this.top=U,this.height=he):(this.top=U+he,this.height=-he),this.setSize()},s.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},s.prototype.rotate=function(m){if(Math.abs(m.x-this.centerX)>.1){var B=Math.sign(m.x-this.centerX);this.rotationAngle=180*Math.atan((m.y-this.centerY)/(m.x-this.centerX))/Math.PI+90*B,this.applyRotation()}},s.prototype.applyRotation=function(){var m=this.container.transform.baseVal.getItem(0);m.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(m,0)},s.prototype.rotatePoint=function(m){if(this.rotationAngle===0)return m;var B=this.container.getCTM(),K=le.createPoint(m.x,m.y);return{x:(K=K.matrixTransform(B)).x,y:K.y}},s.prototype.unrotatePoint=function(m){if(this.rotationAngle===0)return m;var B=this.container.getCTM();B=B.inverse();var K=le.createPoint(m.x,m.y);return{x:(K=K.matrixTransform(B)).x,y:K.y}},s.prototype.select=function(){H.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){H.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=le.createGroup();var m=le.createTransform();m.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(m),this.container.appendChild(this.controlBox),this.controlRect=le.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=le.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 Ie,this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){var m=this.controlBox.transform.baseVal.getItem(0);m.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(m,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()},s.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()},s.prototype.createGrip=function(){var m=new lt;return m.visual.transform.baseVal.appendItem(le.createTransform()),this.controlBox.appendChild(m.visual),m},s.prototype.positionGrips=function(){var m=this.controlGrips.topLeft.GRIP_SIZE,B=-m/2,K=B,U=(this.width+this.CB_DISTANCE)/2-m/2,he=(this.height+this.CB_DISTANCE)/2-m/2,Pe=this.height+this.CB_DISTANCE-m/2,et=this.width+this.CB_DISTANCE-m/2;this.positionGrip(this.controlGrips.topLeft.visual,B,K),this.positionGrip(this.controlGrips.topCenter.visual,U,K),this.positionGrip(this.controlGrips.topRight.visual,et,K),this.positionGrip(this.controlGrips.centerLeft.visual,B,he),this.positionGrip(this.controlGrips.centerRight.visual,et,he),this.positionGrip(this.controlGrips.bottomLeft.visual,B,Pe),this.positionGrip(this.controlGrips.bottomCenter.visual,U,Pe),this.positionGrip(this.controlGrips.bottomRight.visual,et,Pe),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,U,K-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(m,B,K){var U=m.transform.baseVal.getItem(0);U.setTranslate(B,K),m.transform.baseVal.replaceItem(U,0)},s.prototype.hideControlBox=function(){this.controlBox.style.display="none"},s.prototype.showControlBox=function(){this.controlBox.style.display=""},s.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:tt.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:tt.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},H.prototype.getState.call(this))},s.prototype.restoreState=function(m){H.prototype.restoreState.call(this,m);var B=m;this.left=B.left,this.top=B.top,this.width=B.width,this.height=B.height,this.rotationAngle=B.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(tt.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,B.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(tt.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,B.containerTransformMatrix))},s.prototype.scale=function(m,B){H.prototype.scale.call(this,m,B);var K=this.rotatePoint({x:this.left,y:this.top}),U=this.unrotatePoint({x:K.x*m,y:K.y*B});this.left=U.x,this.top=U.y,this.width=this.width*m,this.height=this.height*B,this.adjustControlBox()},s}(Me),Xe=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.fillColor="transparent",U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.opacity=1,U.setStrokeColor=U.setStrokeColor.bind(U),U.setFillColor=U.setFillColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.createVisual=U.createVisual.bind(U),U}return Ce(s,H),s.prototype.ownsTarget=function(m){return!(!H.prototype.ownsTarget.call(this,m)&&m!==this.visual)},s.prototype.createVisual=function(){this.visual=le.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)},s.prototype.pointerDown=function(m,B){H.prototype.pointerDown.call(this,m,B),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.manipulate=function(m){H.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){H.prototype.resize.call(this,m),this.setSize()},s.prototype.setSize=function(){H.prototype.setSize.call(this),le.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(m){H.prototype.pointerUp.call(this,m),this.setSize()},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.visual&&le.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(m),this.stateChanged()},s.prototype.setFillColor=function(m){this.fillColor=m,this.visual&&le.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.visual&&le.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.visual&&le.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},H.prototype.getState.call(this))},s.prototype.restoreState=function(m){var B=m;this.fillColor=B.fillColor,this.strokeColor=B.strokeColor,this.strokeWidth=B.strokeWidth,this.strokeDasharray=B.strokeDasharray,this.opacity=B.opacity,this.createVisual(),H.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,B){H.prototype.scale.call(this,m,B),this.setSize()},s.title="Rectangle marker",s}(qe),ht=function(H){function s(m,B,K,U){var he=H.call(this,m,U||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return he.widths=[],he.widthBoxes=[],he.widths=B,he.currentWidth=K,he.setCurrentWidth=he.setCurrentWidth.bind(he),he}return Ce(s,H),s.prototype.getUi=function(){var m=this,B=document.createElement("div");return B.style.display="flex",B.style.overflow="hidden",B.style.flexGrow="2",this.widths.forEach(function(K){var U=document.createElement("div");U.style.display="flex",U.style.flexGrow="2",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.borderColor=K===m.currentWidth?m.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){m.setCurrentWidth(K,U)}),B.appendChild(U);var he=document.createElement("div");he.innerText=K.toString(),he.style.marginRight="5px",U.appendChild(he);var Pe=document.createElement("div");Pe.style.minHeight="20px",Pe.style.flexGrow="2",Pe.style.display="flex",Pe.style.alignItems="center";var et=document.createElement("hr");et.style.minWidth="20px",et.style.border="0px",et.style.borderTop=K+"px solid "+m.uiStyleSettings.toolboxColor,et.style.flexGrow="2",Pe.appendChild(et),U.appendChild(Pe),m.widthBoxes.push(U)}),B},s.prototype.setCurrentWidth=function(m,B){var K=this;this.currentWidth=m,this.widthBoxes.forEach(function(U){U.style.borderColor=U===B?K.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}(Ge),nt=function(H){function s(m,B,K,U){var he=H.call(this,m,U||'<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 he.styles=[],he.styleBoxes=[],he.styles=B,he.currentStyle=K,he.setCurrentStyle=he.setCurrentStyle.bind(he),he}return Ce(s,H),s.prototype.getUi=function(){var m=this,B=document.createElement("div");return B.style.display="flex",B.style.overflow="hidden",B.style.flexGrow="2",this.styles.forEach(function(K){var U=document.createElement("div");U.style.display="flex",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.overflow="hidden",U.style.maxWidth=100/m.styles.length-5+"%",U.style.borderColor=K===m.currentStyle?m.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){m.setCurrentStyle(K,U)}),B.appendChild(U);var he=document.createElement("div");he.style.minHeight="20px",he.style.flexGrow="2",he.style.overflow="hidden";var Pe=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+m.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(K!==""?'stroke-dasharray="'+K+'"':"")+` />
|
|
</svg>`;he.innerHTML=Pe,U.appendChild(he),m.styleBoxes.push(U)}),B},s.prototype.setCurrentStyle=function(m,B){var K=this;this.currentStyle=m,this.styleBoxes.forEach(function(U){U.style.borderColor=U===B?K.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}(Ge),Je=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.strokeColor=K.defaultColor,U.strokeWidth=K.defaultStrokeWidth,U.strokeDasharray=K.defaultStrokeDasharray,U.strokePanel=new je("Line color",K.defaultColorSet,K.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new ht("Line width",K.defaultStrokeWidths,K.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new nt("Line style",K.defaultStrokeDasharrays,K.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,H),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=H.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="FrameMarker",s.title="Frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',s}(Xe),Te=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},ut=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.x1=0,U.y1=0,U.x2=0,U.y2=0,U.defaultLength=50,U.manipulationStartX=0,U.manipulationStartY=0,U.manipulationStartX1=0,U.manipulationStartY1=0,U.manipulationStartX2=0,U.manipulationStartY2=0,U.setupControlBox(),U}return Ce(s,H),s.prototype.ownsTarget=function(m){return!!H.prototype.ownsTarget.call(this,m)||!(!this.grip1.ownsTarget(m)&&!this.grip2.ownsTarget(m))},s.prototype.pointerDown=function(m,B){H.prototype.pointerDown.call(this,m,B),this.manipulationStartX=m.x,this.manipulationStartY=m.y,this.state==="new"&&(this.x1=m.x,this.y1=m.y,this.x2=m.x,this.y2=m.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(B)?this.activeGrip=this.grip1:this.grip2.ownsTarget(B)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(m){var B=this.state;H.prototype.pointerUp.call(this,m),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(m),this._state="select",B==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},s.prototype.adjustVisual=function(){},s.prototype.manipulate=function(m){this.state==="creating"?this.resize(m):this.state==="move"?(this.x1=this.manipulationStartX1+m.x-this.manipulationStartX,this.y1=this.manipulationStartY1+m.y-this.manipulationStartY,this.x2=this.manipulationStartX2+m.x-this.manipulationStartX,this.y2=this.manipulationStartY2+m.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(m)},s.prototype.resize=function(m){switch(this.activeGrip){case this.grip1:this.x1=m.x,this.y1=m.y;break;case this.grip2:case void 0:this.x2=m.x,this.y2=m.y}this.adjustVisual(),this.adjustControlBox()},s.prototype.select=function(){H.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){H.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=le.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){this.positionGrips()},s.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},s.prototype.createGrip=function(){var m=new lt;return m.visual.transform.baseVal.appendItem(le.createTransform()),this.controlBox.appendChild(m.visual),m},s.prototype.positionGrips=function(){var m=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-m/2,this.y1-m/2),this.positionGrip(this.grip2.visual,this.x2-m/2,this.y2-m/2)},s.prototype.positionGrip=function(m,B,K){var U=m.transform.baseVal.getItem(0);U.setTranslate(B,K),m.transform.baseVal.replaceItem(U,0)},s.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},H.prototype.getState.call(this))},s.prototype.restoreState=function(m){H.prototype.restoreState.call(this,m);var B=m;this.x1=B.x1,this.y1=B.y1,this.x2=B.x2,this.y2=B.y2},s.prototype.scale=function(m,B){H.prototype.scale.call(this,m,B),this.x1=this.x1*m,this.y1=this.y1*B,this.x2=this.x2*m,this.y2=this.y2*B,this.adjustVisual(),this.adjustControlBox()},s}(Me),at=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.setStrokeColor=U.setStrokeColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.strokeColor=K.defaultColor,U.strokeWidth=K.defaultStrokeWidth,U.strokeDasharray=K.defaultStrokeDasharray,U.strokePanel=new je("Line color",K.defaultColorSet,K.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new ht("Line width",K.defaultStrokeWidths,K.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new nt("Line style",K.defaultStrokeDasharrays,K.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,H),s.prototype.ownsTarget=function(m){return!(!H.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.selectorLine&&m!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=le.createGroup(),this.selectorLine=le.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=le.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)},s.prototype.pointerDown=function(m,B){H.prototype.pointerDown.call(this,m,B),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},s.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()),le.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),le.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),le.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.adjustVisual(),this.colorChanged(m)},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.adjustVisual()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},H.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){H.prototype.restoreState.call(this,m);var B=m;this.strokeColor=B.strokeColor,this.strokeWidth=B.strokeWidth,this.strokeDasharray=B.strokeDasharray,this.createVisual(),this.adjustVisual()},s.typeName="LineMarker",s.title="Line marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',s}(ut),Ae=function(H){function s(m,B,K,U){var he=H.call(this,m,U||'<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 he.fonts=[],he.fontBoxes=[],he.fonts=B,he.currentFont=K,he.setCurrentFont=he.setCurrentFont.bind(he),he}return Ce(s,H),s.prototype.getUi=function(){var m=this,B=document.createElement("div");return B.style.overflow="hidden",B.style.flexGrow="2",this.fonts.forEach(function(K){var U=document.createElement("div");U.style.display="inline-block",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.overflow="hidden",U.style.maxWidth=100/m.fonts.length-5+"%",U.style.borderColor=K===m.currentFont?m.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){m.setCurrentFont(K,U)}),B.appendChild(U);var he=document.createElement("div");he.style.display="flex",he.style.minHeight="20px",he.style.flexGrow="2",he.style.fontFamily=K,he.style.overflow="hidden";var Pe=document.createElement("div");Pe.style.whiteSpace="nowrap",Pe.style.overflow="hidden",Pe.style.textOverflow="ellipsis",Pe.innerHTML="The quick brown fox jumps over the lazy dog",he.appendChild(Pe),U.appendChild(he),m.fontBoxes.push(U)}),B},s.prototype.setCurrentFont=function(m,B){var K=this;this.currentFont=m,this.fontBoxes.forEach(function(U){U.style.borderColor=U===B?K.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}(Ge),Ue=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.color="transparent",U.padding=5,U.DEFAULT_TEXT="your text here",U.text=U.DEFAULT_TEXT,U.isMoved=!1,U.color=K.defaultColor,U.fontFamily=K.defaultFontFamily,U.defaultSize={x:100,y:30},U.setColor=U.setColor.bind(U),U.setFont=U.setFont.bind(U),U.renderText=U.renderText.bind(U),U.sizeText=U.sizeText.bind(U),U.textEditDivClicked=U.textEditDivClicked.bind(U),U.showTextEditor=U.showTextEditor.bind(U),U.setSize=U.setSize.bind(U),U.positionTextEditor=U.positionTextEditor.bind(U),U.colorPanel=new je("Color",K.defaultColorSet,K.defaultColor),U.colorPanel.onColorChanged=U.setColor,U.fontFamilyPanel=new Ae("Font",K.defaultFontFamilies,K.defaultFontFamily),U.fontFamilyPanel.onFontChanged=U.setFont,U}return Ce(s,H),s.prototype.ownsTarget=function(m){if(H.prototype.ownsTarget.call(this,m)||m===this.visual||m===this.textElement||m===this.bgRectangle)return!0;var B=!1;return this.textElement.childNodes.forEach(function(K){K===m&&(B=!0)}),B},s.prototype.createVisual=function(){this.visual=le.createGroup(),this.bgRectangle=le.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=le.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(le.createTransform()),this.textElement.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(m,B){H.prototype.pointerDown.call(this,m,B),this.isMoved=!1,this.pointerDownPoint=m,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.renderText=function(){var m=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(B){m.textElement.appendChild(le.createTSpan(B.trim()===""?" ":B.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var m=this.textElement.getBBox(),B=1;if(m.width>0&&m.height>0){var K=(1*this.width-this.width*this.padding*2/100)/m.width,U=(1*this.height-this.height*this.padding*2/100)/m.height;B=Math.min(K,U)}return B},s.prototype.getTextPosition=function(m){var B=this.textElement.getBBox(),K=0,U=0;return B.width>0&&B.height>0&&(K=(this.width-B.width*m)/2,U=this.height/2-B.height*m/2),{x:K,y:U}},s.prototype.sizeText=function(){var m=this.textElement.getBBox(),B=this.getTextScale(),K=this.getTextPosition(B);K.y-=m.y*B,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+K.x+"px, "+K.y+"px) scale("+B+", "+B+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(K.x,K.y),this.textElement.transform.baseVal.getItem(1).setScale(B,B))},s.prototype.manipulate=function(m){H.prototype.manipulate.call(this,m),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(m.x-this.pointerDownPoint.x)>5||Math.abs(m.y-this.pointerDownPoint.y)>5)},s.prototype.resize=function(m){H.prototype.resize.call(this,m),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){H.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(le.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),le.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(m){var B=this.state;B==="creating"&&(this._suppressMarkerCreateEvent=!0),H.prototype.pointerUp.call(this,m),this.setSize(),(B==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},s.prototype.showTextEditor=function(){var m=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(B){B.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var B=Number.parseFloat(m.textEditor.style.fontSize);m.textEditor.clientWidth>=Number.parseInt(m.textEditor.style.maxWidth)&&B>.9;)B-=.1,m.textEditor.style.fontSize=Math.max(B,.9)+"em"}),this.textEditor.addEventListener("keyup",function(B){B.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(B){if(B.clipboardData){var K=B.clipboardData.getData("text"),U=window.getSelection();if(!U.rangeCount)return!1;U.deleteFromDocument(),U.getRangeAt(0).insertNode(document.createTextNode(K)),B.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){m.textEditDivClicked(m.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},s.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var m=this.getTextScale(),B=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),K=this.textElement.getBBox(),U={x:K.width*m,y:K.height*m};B.x-=U.x/2,B.y-=U.y/2,this.textEditor.style.top=B.y+"px",this.textEditor.style.left=B.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-B.x+"px",this.textEditor.style.fontSize=Math.max(16*m,12)+"px",this.textElement.style.display="none"}},s.prototype.textEditDivClicked=function(m){this.text=m.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},s.prototype.select=function(){H.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),H.prototype.deselect.call(this)},s.prototype.dblClick=function(m,B){H.prototype.dblClick.call(this,m,B),this.showTextEditor()},s.prototype.setColor=function(m){this.textElement&&le.setAttributes(this.textElement,[["fill",m]]),this.color=m,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(m)},s.prototype.setFont=function(m){this.textElement&&le.setAttributes(this.textElement,[["font-family",m]]),this.fontFamily=m,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},s.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},s.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},H.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){var B=m;this.color=B.color,this.fontFamily=B.fontFamily,this.padding=B.padding,this.text=B.text,this.createVisual(),H.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,B){H.prototype.scale.call(this,m,B),this.setSize(),this.sizeText(),this.positionTextEditor()},s.typeName="TextMarker",s.title="Text marker",s.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>',s}(qe),pe=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.color="transparent",U.lineWidth=3,U.drawing=!1,U.pixelRatio=1,U.color=K.defaultColor,U.lineWidth=K.defaultStrokeWidth,U.pixelRatio=K.freehandPixelRatio,U.setColor=U.setColor.bind(U),U.addCanvas=U.addCanvas.bind(U),U.finishCreation=U.finishCreation.bind(U),U.setLineWidth=U.setLineWidth.bind(U),U.colorPanel=new je("Color",K.defaultColorSet,K.defaultColor),U.colorPanel.onColorChanged=U.setColor,U.lineWidthPanel=new ht("Line width",K.defaultStrokeWidths,K.defaultStrokeWidth),U.lineWidthPanel.onWidthChanged=U.setLineWidth,U}return Ce(s,H),s.prototype.ownsTarget=function(m){return!(!H.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=le.createGroup(),this.drawingImage=le.createImage(),this.visual.appendChild(this.drawingImage);var m=le.createTransform();this.visual.transform.baseVal.appendItem(m),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,B){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(m.x,m.y),this.drawing=!0):H.prototype.pointerDown.call(this,m,B)},s.prototype.manipulate=function(m){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(m.x,m.y),this.canvasContext.stroke()):H.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){H.prototype.resize.call(this,m),le.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),le.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(m){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):H.prototype.pointerUp.call(this,m)},s.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)},s.prototype.select=function(){this.state==="creating"&&this.finishCreation(),H.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),H.prototype.deselect.call(this)},s.prototype.finishCreation=function(){for(var m=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),B=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],K=B[0],U=B[1],he=B[2],Pe=B[3],et=!1,ct=0;ct<this.canvasElement.height;ct++)for(var Be=0;Be<this.canvasElement.width;Be++)m.data[ct*this.canvasElement.width*4+4*Be+3]>0&&(et=!0,ct<U&&(U=ct),Be<K&&(K=Be),ct>Pe&&(Pe=ct),Be>he&&(he=Be));if(et){this.left=K/this.pixelRatio,this.top=U/this.pixelRatio,this.width=(he-K)/this.pixelRatio,this.height=(Pe-U)/this.pixelRatio;var Ct=document.createElement("canvas");Ct.width=he-K,Ct.height=Pe-U,Ct.getContext("2d").putImageData(this.canvasContext.getImageData(K,U,he-K,Pe-U),0,0),this.drawingImgUrl=Ct.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},s.prototype.setDrawingImage=function(){le.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),le.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(m){this.color=m,this.colorChanged(m)},s.prototype.setLineWidth=function(m){this.lineWidth=m},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({drawingImgUrl:this.drawingImgUrl},H.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){this.createVisual(),H.prototype.restoreState.call(this,m),this.drawingImgUrl=m.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(m,B){H.prototype.scale.call(this,m,B),this.setDrawingImage()},s.typeName="FreehandMarker",s.title="Freehand marker",s.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>',s}(qe),ue=function(H){function s(m,B,K){var U=H.call(this,m,K||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return U.typeBoxes=[],U.currentType=B,U.setCurrentType=U.setCurrentType.bind(U),U}return Ce(s,H),s.prototype.getUi=function(){var m=this,B=document.createElement("div");B.style.display="flex",B.style.overflow="hidden",B.style.flexGrow="2";for(var K=function(Pe){var et="both";switch(Pe){case 0:et="both";break;case 1:et="start";break;case 2:et="end";break;case 3:et="none"}var ct=document.createElement("div");if(ct.style.display="flex",ct.style.flexGrow="2",ct.style.alignItems="center",ct.style.justifyContent="space-between",ct.style.padding="5px",ct.style.borderWidth="2px",ct.style.borderStyle="solid",ct.style.borderColor=et===U.currentType?U.uiStyleSettings.toolboxAccentColor:"transparent",ct.addEventListener("click",function(){m.setCurrentType(et,ct)}),B.appendChild(ct),et==="both"||et==="start"){var Be=document.createElement("div");Be.style.display="flex",Be.style.alignItems="center",Be.style.minHeight="20px",Be.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="`+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Be.style.marginLeft="5px",ct.appendChild(Be)}var Ct=document.createElement("div");Ct.style.display="flex",Ct.style.alignItems="center",Ct.style.minHeight="20px",Ct.style.flexGrow="2";var Ot=document.createElement("hr");if(Ot.style.minWidth="20px",Ot.style.border="0px",Ot.style.borderTop="3px solid "+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee"),Ot.style.flexGrow="2",Ct.appendChild(Ot),ct.appendChild(Ct),et==="both"||et==="end"){var Yt=document.createElement("div");Yt.style.display="flex",Yt.style.alignItems="center",Yt.style.minHeight="20px",Yt.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="`+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Yt.style.marginRight="5px",ct.appendChild(Yt)}U.typeBoxes.push(ct)},U=this,he=0;he<4;he++)K(he);return B},s.prototype.setCurrentType=function(m,B){var K=this;this.currentType=m,this.typeBoxes.forEach(function(U){U.style.borderColor=U===B?K.uiStyleSettings!==void 0?K.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}(Ge),fe=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.arrowType="end",U.arrowBaseHeight=10,U.arrowBaseWidth=10,U.getArrowPoints=U.getArrowPoints.bind(U),U.setArrowType=U.setArrowType.bind(U),U.arrowTypePanel=new ue("Arrow type","end"),U.arrowTypePanel.onArrowTypeChanged=U.setArrowType,U}return Ce(s,H),s.prototype.ownsTarget=function(m){return!(!H.prototype.ownsTarget.call(this,m)&&m!==this.arrow1&&m!==this.arrow2)},s.prototype.getArrowPoints=function(m,B){var K=this.arrowBaseWidth+2*this.strokeWidth,U=this.arrowBaseHeight+2*this.strokeWidth;return m-K/2+","+(B+U/2)+" "+m+","+(B-U/2)+" "+(m+K/2)+","+(B+U/2)},s.prototype.createTips=function(){this.arrow1=le.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=le.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(m,B){H.prototype.pointerDown.call(this,m,B),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(H.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",le.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),le.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var m=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),B=this.arrow1.transform.baseVal.getItem(0);B.setRotate(m,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(B,0);var K=this.arrow2.transform.baseVal.getItem(0);K.setRotate(m+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(K,0)}},s.prototype.setArrowType=function(m){this.arrowType=m,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({arrowType:this.arrowType},H.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){H.prototype.restoreState.call(this,m);var B=m;this.arrowType=B.arrowType,this.createTips(),this.adjustVisual()},s.typeName="ArrowMarker",s.title="Arrow marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',s}(at),ee=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.fillColor=K.defaultFillColor,U.strokeWidth=0,U.fillPanel=new je("Color",K.defaultColorSet,K.defaultFillColor),U.fillPanel.onColorChanged=U.setFillColor,U}return Ce(s,H),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=H.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="CoverMarker",s.title="Cover marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',s}(Xe),te=function(H){function s(m,B,K,U){var he=H.call(this,m,U||'<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 he.opacities=[],he.opacityBoxes=[],he.opacities=B,he.currentOpacity=K,he.setCurrentOpacity=he.setCurrentOpacity.bind(he),he}return Ce(s,H),s.prototype.getUi=function(){var m=this,B=document.createElement("div");return B.style.display="flex",B.style.overflow="hidden",B.style.flexGrow="2",B.style.justifyContent="space-between",this.opacities.forEach(function(K){var U=document.createElement("div");U.style.display="flex",U.style.alignItems="center",U.style.justifyContent="center",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.borderColor=K===m.currentOpacity?m.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){m.setCurrentOpacity(K,U)}),B.appendChild(U);var he=document.createElement("div");he.innerText=100*K+"%",U.appendChild(he),m.opacityBoxes.push(U)}),B},s.prototype.setCurrentOpacity=function(m,B){var K=this;this.currentOpacity=m,this.opacityBoxes.forEach(function(U){U.style.borderColor=U===B?K.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}(Ge),ie=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.setOpacity=U.setOpacity.bind(U),U.fillColor=K.defaultHighlightColor,U.strokeWidth=0,U.opacity=K.defaultHighlightOpacity,U.fillPanel=new je("Color",K.defaultColorSet,U.fillColor),U.fillPanel.onColorChanged=U.setFillColor,U.opacityPanel=new te("Opacity",K.defaultOpacitySteps,U.opacity),U.opacityPanel.onOpacityChanged=U.setOpacity,U}return Ce(s,H),s.prototype.setOpacity=function(m){this.opacity=m,this.visual&&le.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=H.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="HighlightMarker",s.title="Highlight marker",s.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>',s}(ee),ne='<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>',be=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.bgColor="transparent",U.tipPosition={x:0,y:0},U.tipBase1Position={x:0,y:0},U.tipBase2Position={x:0,y:0},U.tipMoving=!1,U.color=K.defaultStrokeColor,U.bgColor=K.defaultFillColor,U.fontFamily=K.defaultFontFamily,U.defaultSize={x:100,y:30},U.setBgColor=U.setBgColor.bind(U),U.getTipPoints=U.getTipPoints.bind(U),U.positionTip=U.positionTip.bind(U),U.setTipPoints=U.setTipPoints.bind(U),U.colorPanel=new je("Text color",K.defaultColorSet,U.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>'),U.colorPanel.onColorChanged=U.setColor,U.bgColorPanel=new je("Fill color",K.defaultColorSet,U.bgColor,ne),U.bgColorPanel.onColorChanged=U.setBgColor,U.fontFamilyPanel=new Ae("Font",K.defaultFontFamilies,K.defaultFontFamily),U.fontFamilyPanel.onFontChanged=U.setFont,U.tipGrip=new lt,U.tipGrip.visual.transform.baseVal.appendItem(le.createTransform()),U.controlBox.appendChild(U.tipGrip.visual),U}return Ce(s,H),s.prototype.ownsTarget=function(m){return H.prototype.ownsTarget.call(this,m)||this.tipGrip.ownsTarget(m)||this.tip===m},s.prototype.createTip=function(){le.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=le.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(m,B){this.state==="new"&&H.prototype.pointerDown.call(this,m,B),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(B)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):H.prototype.pointerDown.call(this,m,B)},s.prototype.pointerUp=function(m){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,H.prototype.pointerUp.call(this,m);else{var B=this.state==="creating";H.prototype.pointerUp.call(this,m),this.setTipPoints(B),this.positionTip()}},s.prototype.manipulate=function(m){if(this.tipMoving){var B=this.unrotatePoint(m);this.tipPosition={x:B.x-this.manipulationStartLeft,y:B.y-this.manipulationStartTop},this.positionTip()}else H.prototype.manipulate.call(this,m)},s.prototype.setBgColor=function(m){this.bgRectangle&&this.tip&&(le.setAttributes(this.bgRectangle,[["fill",m]]),le.setAttributes(this.tip,[["fill",m]])),this.bgColor=m,this.fillColorChanged(m)},s.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},s.prototype.setTipPoints=function(m){m===void 0&&(m=!1);var B=Math.min(this.height/2,15),K=this.height/5;m&&(this.tipPosition={x:B+K/2,y:this.height+20});var U=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?U<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(K=this.width/5,B=Math.min(this.width/2,15),this.tipBase1Position={x:B,y:0},this.tipBase2Position={x:B+K,y:0}):(this.tipBase1Position={x:0,y:B},this.tipBase2Position={x:0,y:B+K}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?U<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(K=this.width/5,B=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-B-K,y:0},this.tipBase2Position={x:this.width-B,y:0}):(this.tipBase1Position={x:this.width,y:B},this.tipBase2Position={x:this.width,y:B+K}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?U<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(K=this.width/5,B=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-B-K,y:this.height},this.tipBase2Position={x:this.width-B,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-B-K},this.tipBase2Position={x:this.width,y:this.height-B}):U<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(K=this.width/5,B=Math.min(this.width/2,15),this.tipBase1Position={x:B,y:this.height},this.tipBase2Position={x:B+K,y:this.height}):(this.tipBase1Position={x:0,y:this.height-B},this.tipBase2Position={x:0,y:this.height-B-K})},s.prototype.resize=function(m){H.prototype.resize.call(this,m),this.positionTip()},s.prototype.positionTip=function(){le.setAttributes(this.tip,[["points",this.getTipPoints()]]);var m=this.tipGrip.visual.transform.baseVal.getItem(0);m.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(m,0)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.select=function(){this.positionTip(),H.prototype.select.call(this)},s.prototype.getState=function(){var m=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},H.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){var B=m;this.bgColor=B.bgColor,this.tipPosition=B.tipPosition,H.prototype.restoreState.call(this,m),this.createTip(),this.setTipPoints()},s.prototype.scale=function(m,B){H.prototype.scale.call(this,m,B),this.tipPosition={x:this.tipPosition.x*m,y:this.tipPosition.y*B},this.positionTip()},s.typeName="CalloutMarker",s.title="Callout marker",s.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>',s}(Ue),ge=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.fillColor="transparent",U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.opacity=1,U.strokeColor=K.defaultColor,U.strokeWidth=K.defaultStrokeWidth,U.strokeDasharray=K.defaultStrokeDasharray,U.fillColor=K.defaultFillColor,U.setStrokeColor=U.setStrokeColor.bind(U),U.setFillColor=U.setFillColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.setOpacity=U.setOpacity.bind(U),U.createVisual=U.createVisual.bind(U),U.strokePanel=new je("Line color",me(K.defaultColorSet,["transparent"]),K.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.fillPanel=new je("Fill color",me(K.defaultColorSet,["transparent"]),U.fillColor,ne),U.fillPanel.onColorChanged=U.setFillColor,U.strokeWidthPanel=new ht("Line width",K.defaultStrokeWidths,K.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new nt("Line style",K.defaultStrokeDasharrays,K.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U.opacityPanel=new te("Opacity",K.defaultOpacitySteps,U.opacity),U.opacityPanel.onOpacityChanged=U.setOpacity,U}return Ce(s,H),s.prototype.ownsTarget=function(m){return!(!H.prototype.ownsTarget.call(this,m)&&m!==this.visual)},s.prototype.createVisual=function(){this.visual=le.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)},s.prototype.pointerDown=function(m,B){H.prototype.pointerDown.call(this,m,B),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.manipulate=function(m){H.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){H.prototype.resize.call(this,m),this.setSize()},s.prototype.setSize=function(){H.prototype.setSize.call(this),le.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},s.prototype.pointerUp=function(m){H.prototype.pointerUp.call(this,m),this.setSize()},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.visual&&le.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(m),this.stateChanged()},s.prototype.setFillColor=function(m){this.fillColor=m,this.visual&&le.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(m),this.stateChanged()},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.visual&&le.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.visual&&le.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.setOpacity=function(m){this.opacity=m,this.visual&&le.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},H.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){var B=m;this.fillColor=B.fillColor,this.strokeColor=B.strokeColor,this.strokeWidth=B.strokeWidth,this.strokeDasharray=B.strokeDasharray,this.opacity=B.opacity,this.createVisual(),H.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,B){H.prototype.scale.call(this,m,B),this.setSize()},s.typeName="EllipseMarker",s.title="Ellipse marker",s.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>',s}(qe),Re=function(H){function s(m,B,K){return H.call(this,m,B,K)||this}return Ce(s,H),Object.defineProperty(s.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(m){return!(!H.prototype.ownsTarget.call(this,m)&&m!==this.tip1&&m!==this.tip2)},s.prototype.createTips=function(){this.tip1=le.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(le.createTransform()),this.visual.appendChild(this.tip1),this.tip2=le.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(le.createTransform()),this.visual.appendChild(this.tip2)},s.prototype.pointerDown=function(m,B){H.prototype.pointerDown.call(this,m,B),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(H.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(le.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()]]),le.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 m=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),B=this.tip1.transform.baseVal.getItem(0);B.setRotate(m,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(B,0);var K=this.tip2.transform.baseVal.getItem(0);K.setRotate(m+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(K,0)}},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=H.prototype.getState.call(this);return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){H.prototype.restoreState.call(this,m),this.createTips(),this.adjustVisual()},s.typeName="MeasurementMarker",s.title="Measurement marker",s.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>',s}(at),He=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.strokePanel.colors=K.defaultColorSet,U.fillColor="transparent",U}return Ce(s,H),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=H.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="EllipseFrameMarker",s.title="Ellipse frame marker",s.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>',s}(ge),st=function(){function H(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(H.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),H.prototype.addUndoStep=function(s){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(s)||(this.undoStack.push(s),JSON.stringify(this.lastRedoStep)!==JSON.stringify(s)&&this.redoStack.splice(0,this.redoStack.length))},H.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},H.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},H.prototype.undo=function(){if(this.undoStack.length>1){var s=this.undoStack.pop();return s!==void 0&&this.redoStack.push(s),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},H.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},H}(),Ze=function(H){function s(m,B,K){var U=H.call(this,m,B,K)||this;return U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.curveX=0,U.curveY=0,U.manipulationStartCurveX=0,U.manipulationStartCurveY=0,U.setStrokeColor=U.setStrokeColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.positionGrips=U.positionGrips.bind(U),U.addControlGrips=U.addControlGrips.bind(U),U.adjustVisual=U.adjustVisual.bind(U),U.setupControlBox=U.setupControlBox.bind(U),U.resize=U.resize.bind(U),U.strokeColor=K.defaultColor,U.strokeWidth=K.defaultStrokeWidth,U.strokeDasharray=K.defaultStrokeDasharray,U.strokePanel=new je("Line color",K.defaultColorSet,K.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new ht("Line width",K.defaultStrokeWidths,K.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new nt("Line style",K.defaultStrokeDasharrays,K.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,H),s.prototype.ownsTarget=function(m){return!(!H.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.selectorCurve&&m!==this.visibleCurve&&!this.curveGrip.ownsTarget(m))},s.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},s.prototype.createVisual=function(){this.visual=le.createGroup(),this.selectorCurve=le.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=le.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)},s.prototype.pointerDown=function(m,B){H.prototype.pointerDown.call(this,m,B),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=m.x,this.curveY=m.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(B)&&(this.activeGrip=this.curveGrip,this._state="resize")},s.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),le.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),le.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),le.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){H.prototype.setupControlBox.call(this),this.curveControlLine1=le.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=le.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)},s.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,H.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){H.prototype.positionGrips.call(this);var m=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-m/2,this.curveY-m/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()))},s.prototype.manipulate=function(m){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+m.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+m.y-this.manipulationStartY),H.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){this.activeGrip===this.curveGrip&&(this.curveX=m.x,this.curveY=m.y),H.prototype.resize.call(this,m),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.adjustVisual(),this.colorChanged(m)},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.adjustVisual()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.adjustVisual()},s.prototype.scale=function(m,B){this.curveX=this.curveX*m,this.curveY=this.curveY*B,H.prototype.scale.call(this,m,B)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},H.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){H.prototype.restoreState.call(this,m);var B=m;this.strokeColor=B.strokeColor,this.strokeWidth=B.strokeWidth,this.strokeDasharray=B.strokeDasharray,this.curveX=B.curveX,this.curveY=B.curveY,this.createVisual(),this.adjustVisual()},s.typeName="CurveMarker",s.title="Curve marker",s.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>',s}(ut),mt=function(){function H(s,m){m===void 0&&(m=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=m}return Object.defineProperty(H.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),H.prototype.preventDefault=function(){this._defaultPrevented=!0},H}(),vt=function(H){function s(m,B,K){var U=H.call(this,m,!1)||this;return U.dataUrl=B,U.state=K,U}return Ce(s,H),s}(mt),Qe=function(H){function s(m,B,K){K===void 0&&(K=!1);var U=H.call(this,m,K)||this;return U.marker=B,U}return Ce(s,H),s}(mt),jt=function(){function H(){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 H.prototype.addEventListener=function(s,m){this[s].push(m)},H.prototype.removeEventListener=function(s,m){var B=this[s].indexOf(m);B>-1&&this[s].splice(B,1)},H}(),At=function(){function H(s){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new Te,this._isOpen=!1,this.undoRedoManager=new st,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 jt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=H.instanceCounter++,this.styles=new $e(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=s,this.targetRoot=document.body,this.width=s.clientWidth,this.height=s.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(H.prototype,"ALL_MARKER_TYPES",{get:function(){return[Je,pe,fe,Ue,He,ge,ie,be,Re,ee,at,Ze]},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[Je,pe,fe,Ue,ge,ie,be]},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"BASIC_MARKER_TYPES",{get:function(){return[Je,pe,fe,Ue,ie]},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var m=this;this._availableMarkerTypes.splice(0),s.forEach(function(B){if(typeof B=="string"){var K=m.ALL_MARKER_TYPES.find(function(U){return U.typeName===B});K!==void 0&&m._availableMarkerTypes.push(K)}else m._availableMarkerTypes.push(B)})},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(s){this._zoomLevel=s,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(H.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),H.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),Oe.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},H.prototype.show=function(){var s=this;this.styles.styleSheetRoot===void 0&&Ve.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=Ve.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(m){return m(new mt(s))})},H.prototype.render=function(){return Le(this,void 0,void 0,function(){var s;return we(this,function(m){switch(m.label){case 0:return this.setCurrentMarker(),(s=new Ye).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.markersOnly=this.renderMarkersOnly,s.width=this.renderWidth,s.height=this.renderHeight,[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return m.sent(),[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,m.sent()]}})})},H.prototype.close=function(s){var m=this;if(s===void 0&&(s=!1),this.isOpen){var B=!1;s||this.eventListeners.beforeclose.forEach(function(K){var U=new mt(m,!0);K(U),U.defaultPrevented&&(B=!0)}),B||(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(K){return K(new mt(m))}),this.detachEvents(),this._isOpen=!1)}},H.prototype.addMarkersToToolbar=function(){for(var s,m=[],B=0;B<arguments.length;B++)m[B]=arguments[B];(s=this._availableMarkerTypes).push.apply(s,m)},H.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(m){s(m.dataUrl,m.state)})},H.prototype.removeRenderEventListener=function(s){},H.prototype.addCloseEventListener=function(s){this.addEventListener("close",function(){s()})},H.prototype.removeCloseEventListener=function(s){},H.prototype.setupResizeObserver=function(){var s=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return s.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},H.prototype.onPopupTargetResize=function(){var s=1*this.target.clientWidth/this.target.clientHeight,m=this.editorCanvas.clientWidth/s>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*s:this.editorCanvas.clientWidth,B=m<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/s;this.resize(m,B)},H.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},H.prototype.resize=function(s,m){this._isResizing=!0;var B=s/this.imageWidth,K=m/this.imageHeight;this.imageWidth=Math.round(s),this.imageHeight=Math.round(m),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(B,K),this._isResizing=!1},H.prototype.scaleMarkers=function(s,m){var B,K=this;this._currentMarker&&this._currentMarker instanceof Ue?this._currentMarker.scale(s,m):(B=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(U){U!==K._currentMarker&&U.scale(s,m)}),B!==void 0&&this.setCurrentMarker(B)},H.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"},H.prototype.setTopLeft=function(){var s=this.editingTarget.getBoundingClientRect(),m=this.editorCanvas.getBoundingClientRect();this.left=s.left-m.left,this.top=s.top-m.top},H.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)},H.prototype.addDefs=function(){for(var s,m=[],B=0;B<arguments.length;B++)m[B]=arguments[B];this.defs=le.createDefs(),this.addDefsToImage(),(s=this.defs).append.apply(s,m)},H.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},H.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)},H.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},H.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},H.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)},H.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},H.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)},H.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 s=document.createElement("a");s.href="https://markerjs.com/",s.target="_blank",s.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>',s.title="Powered by marker.js",s.style.display="grid",s.style.alignItems="center",s.style.justifyItems="center",s.style.padding="3px",s.style.width="20px",s.style.height="20px",this.logoUI.appendChild(s),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},H.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")},H.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"},H.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},H.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 s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"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 De(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 Ne(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},H.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},H.prototype.removeMarker=function(s){this.markerImage.removeChild(s.container),this.markers.indexOf(s)>-1&&this.markers.splice(this.markers.indexOf(s),1),s.dispose()},H.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())},H.prototype.toolbarButtonClicked=function(s,m){if(s==="marker"&&m!==void 0)this.createNewMarker(m);else if(s==="action")switch(m){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()}},H.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var m=!1;if(this.eventListeners.markerbeforedelete.forEach(function(K){var U=new Qe(s,s._currentMarker,!0);K(U),U.defaultPrevented&&(m=!0)}),!m){var B=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(K){return K(new Qe(s,B))})}}},H.prototype.clear=function(){var s=this,m=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(he){var Pe=new Qe(s,void 0,!0);he(Pe),Pe.defaultPrevented&&(m=!0)}),!m)){this.setCurrentMarker();for(var B=function(he){var Pe=K.markers[he];K.setCurrentMarker(K.markers[he]),K._currentMarker.dispose(),K.markerImage.removeChild(K._currentMarker.container),K.markers.splice(K.markers.indexOf(K._currentMarker),1),K.eventListeners.markerdelete.forEach(function(et){return et(new Qe(s,Pe))})},K=this,U=this.markers.length-1;U>=0;U--)B(U);this.addUndoStep()}},Object.defineProperty(H.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),H.prototype.showNotesEditor=function(){var s;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=(s=this._currentMarker.notes)!==null&&s!==void 0?s:"",this.overlayContainer.appendChild(this.notesArea))},H.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)},H.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},H.prototype.addUndoStep=function(){var s=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var m=this.getState(),B=this.undoRedoManager.getLastUndoStep();if(!B||B.width===m.width&&B.height===m.height){var K=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(m),K<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(U){return U(new mt(s))})}else this.undoRedoManager.replaceLastUndoStep(m),this.eventListeners.statechange.forEach(function(U){return U(new mt(s))})}},H.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},H.prototype.undoStep=function(){var s=this,m=this.undoRedoManager.undo();m!==void 0&&(this.restoreState(m),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(B){return B(new mt(s))}))},H.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},H.prototype.redoStep=function(){var s=this,m=this.undoRedoManager.redo();m!==void 0&&(this.restoreState(m),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(B){return B(new mt(s))}))},H.prototype.stepZoom=function(){var s=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=s<this.zoomSteps.length-1?this.zoomSteps[s+1]:this.zoomSteps[0]},H.prototype.panTo=function(s){this.contentDiv.scrollBy({left:this.prevPanPoint.x-s.x,top:this.prevPanPoint.y-s.y}),this.prevPanPoint=s},H.prototype.startRenderAndClose=function(){return Le(this,void 0,void 0,function(){var s,m,B=this;return we(this,function(K){switch(K.label){case 0:return[4,this.render()];case 1:return s=K.sent(),m=this.getState(),this.eventListeners.render.forEach(function(U){return U(new vt(B,s,m))}),this.close(!0),[2]}})})},H.prototype.getState=function(s){s===!0&&this.setCurrentMarker();var m={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(B){return m.markers.push(B.getState())}),m},H.prototype.restoreState=function(s){var m=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);s.markers.forEach(function(B){var K=m._availableMarkerTypes.find(function(he){return he.typeName===B.typeName});if(K!==void 0){var U=m.addNewMarker(K);U.restoreState(B),m.markers.push(U)}}),s.width&&s.height&&(s.width!==this.imageWidth||s.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/s.width,this.imageHeight/s.height),this.eventListeners.restorestate.forEach(function(B){return B(new mt(m))})},H.prototype.addNewMarker=function(s){var m=le.createGroup();return this.markerImage.appendChild(m),new s(m,this.overlayContainer,this.settings)},H.prototype.createNewMarker=function(s){var m,B=this;(m=typeof s=="string"?this._availableMarkerTypes.find(function(K){return K.typeName===s}):s)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(m),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(m.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(K){return K(new Qe(B,B._currentMarker))}))},H.prototype.markerCreated=function(s){var m=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof pe&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(pe):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(B){return B(new Qe(m,m._currentMarker))})},H.prototype.colorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=s,this.settings.defaultStrokeColor=s)},H.prototype.fillColorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=s)},H.prototype.markerStateChanged=function(s){var m=this;this.eventListeners.markerchange.forEach(function(B){return B(new Qe(m,s))})},H.prototype.setCurrentMarker=function(s){var m=this;this._currentMarker!==s&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(B){return B(new Qe(m,m._currentMarker))})),this._currentMarker=s,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(B){return B(new Qe(m,m._currentMarker))}))},H.prototype.onPointerDown=function(s){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||s.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var m=this.markers.find(function(B){return B.ownsTarget(s.target)});m!==void 0?(this.setCurrentMarker(m),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:s.clientX,y:s.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY))},H.prototype.onDblClick=function(s){if(this._isFocused||this.focus(),this.mode==="select"){var m=this.markers.find(function(B){return B.ownsTarget(s.target)});m!==void 0&&m!==this._currentMarker&&this.setCurrentMarker(m),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target):this.setCurrentMarker()}},H.prototype.onPointerMove=function(s){this.touchPoints!==1&&s.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||s.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(s.clientX,s.clientY)):this.zoomLevel>1&&this.panTo({x:s.clientX,y:s.clientY}))},H.prototype.onPointerUp=function(s){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(s.clientX,s.clientY)),this.isDragging=!1,this.addUndoStep()},H.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},H.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},H.prototype.clientToLocalCoordinates=function(s,m){var B=this.markerImage.getBoundingClientRect();return{x:(s-B.left)/this.zoomLevel,y:(m-B.top)/this.zoomLevel}},H.prototype.onWindowResize=function(){this.positionUI()},H.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"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()},H.prototype.addLicenseKey=function(s){Oe.addKey(s)},H.prototype.addEventListener=function(s,m){this.eventListeners.addEventListener(s,m)},H.prototype.removeEventListener=function(s,m){this.eventListeners.removeEventListener(s,m)},H.prototype.renderState=function(s){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(s),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(H.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),H.prototype.focus=function(){var s=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(m){return m(new mt(s))}))},H.prototype.blur=function(){var s=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(m){return m(new mt(s))}))},H.instanceCounter=0,H}();/* **********************************
|
|
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 Nt=function(H,s){return(Nt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,B){m.__proto__=B}||function(m,B){for(var K in B)Object.prototype.hasOwnProperty.call(B,K)&&(m[K]=B[K])})(H,s)};function Ht(H,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function m(){this.constructor=H}Nt(H,s),H.prototype=s===null?Object.create(s):(m.prototype=s.prototype,new m)}function Dt(H,s,m,B){return new(m||(m=Promise))(function(K,U){function he(ct){try{et(B.next(ct))}catch(Be){U(Be)}}function Pe(ct){try{et(B.throw(ct))}catch(Be){U(Be)}}function et(ct){var Be;ct.done?K(ct.value):(Be=ct.value,Be instanceof m?Be:new m(function(Ct){Ct(Be)})).then(he,Pe)}et((B=B.apply(H,s||[])).next())})}function Tr(H,s){var m,B,K,U,he={label:0,sent:function(){if(1&K[0])throw K[1];return K[1]},trys:[],ops:[]};return U={next:Pe(0),throw:Pe(1),return:Pe(2)},typeof Symbol=="function"&&(U[Symbol.iterator]=function(){return this}),U;function Pe(et){return function(ct){return function(Be){if(m)throw new TypeError("Generator is already executing.");for(;he;)try{if(m=1,B&&(K=2&Be[0]?B.return:Be[0]?B.throw||((K=B.return)&&K.call(B),0):B.next)&&!(K=K.call(B,Be[1])).done)return K;switch(B=0,K&&(Be=[2&Be[0],K.value]),Be[0]){case 0:case 1:K=Be;break;case 4:return he.label++,{value:Be[1],done:!1};case 5:he.label++,B=Be[1],Be=[0];continue;case 7:Be=he.ops.pop(),he.trys.pop();continue;default:if(!(K=he.trys,(K=K.length>0&&K[K.length-1])||Be[0]!==6&&Be[0]!==2)){he=0;continue}if(Be[0]===3&&(!K||Be[1]>K[0]&&Be[1]<K[3])){he.label=Be[1];break}if(Be[0]===6&&he.label<K[1]){he.label=K[1],K=Be;break}if(K&&he.label<K[2]){he.label=K[2],he.ops.push(Be);break}K[2]&&he.ops.pop(),he.trys.pop();continue}Be=s.call(H,he)}catch(Ct){Be=[6,Ct],B=0}finally{m=K=0}if(5&Be[0])throw Be[1];return{value:Be[0]?Be[1]:void 0,done:!0}}([et,ct])}}}var Zr=function(){function H(){}return H.addKey=function(s){H.key=s},Object.defineProperty(H,"isLicensed",{get:function(){return!!H.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(H.key)},enumerable:!1,configurable:!0}),H}(),yt=function(){function H(){}return H.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},H.setAttributes=function(s,m){for(var B=0,K=m;B<K.length;B++){var U=K[B],he=U[0],Pe=U[1];s.setAttribute(he,Pe)}},H.createRect=function(s,m,B){var K=document.createElementNS("http://www.w3.org/2000/svg","rect");return K.setAttribute("width",s.toString()),K.setAttribute("height",m.toString()),B&&H.setAttributes(K,B),K},H.createLine=function(s,m,B,K,U){var he=document.createElementNS("http://www.w3.org/2000/svg","line");return he.setAttribute("x1",s.toString()),he.setAttribute("y1",m.toString()),he.setAttribute("x2",B.toString()),he.setAttribute("y2",K.toString()),U&&H.setAttributes(he,U),he},H.createPolygon=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg","polygon");return B.setAttribute("points",s),m&&H.setAttributes(B,m),B},H.createCircle=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg","circle");return B.setAttribute("cx",(s/2).toString()),B.setAttribute("cy",(s/2).toString()),B.setAttribute("r",s.toString()),m&&H.setAttributes(B,m),B},H.createEllipse=function(s,m,B){var K=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return K.setAttribute("cx",(s/2).toString()),K.setAttribute("cy",(m/2).toString()),K.setAttribute("rx",(s/2).toString()),K.setAttribute("ry",(m/2).toString()),B&&H.setAttributes(K,B),K},H.createGroup=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&H.setAttributes(m,s),m},H.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},H.createMarker=function(s,m,B,K,U,he,Pe){var et=document.createElementNS("http://www.w3.org/2000/svg","marker");return H.setAttributes(et,[["id",s],["orient",m],["markerWidth",B.toString()],["markerHeight",K.toString()],["refX",U.toString()],["refY",he.toString()]]),et.appendChild(Pe),et},H.createText=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","text");return m.setAttribute("x","0"),m.setAttribute("y","0"),s&&H.setAttributes(m,s),m},H.createTSpan=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg","tspan");return B.textContent=s,m&&H.setAttributes(B,m),B},H.createImage=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&H.setAttributes(m,s),m},H.createPoint=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return B.x=s,B.y=m,B},H.createPath=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg","path");return B.setAttribute("d",s),m&&H.setAttributes(B,m),B},H.createElement=function(s,m){var B=document.createElementNS("http://www.w3.org/2000/svg",s);return m&&H.setAttributes(B,m),B},H.getHollowRectanglePath=function(s,m,B,K,U,he,Pe,et){return"M"+s+","+m+"V"+(m+K)+"H"+(s+B)+"V"+m+"H"+U+"V"+he+"H"+(U+Pe)+"V"+(he+et)+"H"+U+"V"+m+"Z"},H}(),wr=function(){function H(s){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(H.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),H.prototype.addClass=function(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},H.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},H.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new tr("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new tr("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new tr("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new lr("_fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new lr("_fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},H.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},H}(),tr=function(H,s){this.selector=H,this.style=s},lr=function(H,s){this.localName=H,this.style=s},Bt=function(){function H(){this.blocks=[],this.display=""}return H.prototype.addButtonBlock=function(s){s.className=this.blockClassName,s.buttonClassName=this.buttonClassName,s.buttonColorsClassName=this.buttonColorsClassName,s.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(s)},H.prototype.addElementBlock=function(s){s.className===void 0&&(s.className=this.blockClassName),this.blocks.push(s)},H.prototype.getUI=function(){var s=document.createElement("div");return s.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,s.style.display=this.display,this.blocks.forEach(function(m){return s.appendChild(m.getUI())}),s},H}(),Qt=function(){function H(){}return H.prototype.getUI=function(){var s=document.createElement("div");if(s.className=this.className,this.minWidth!==void 0&&(s.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":s.style.justifyContent="flex-start";break;case"center":s.style.justifyContent="center";break;case"end":s.style.justifyContent="flex-end"}return s.style.whiteSpace="nowrap",s},H}(),Kt=function(H){function s(){var m=H!==null&&H.apply(this,arguments)||this;return m.buttons=[],m}return Ht(s,H),s.prototype.addButton=function(m){m.className=this.buttonClassName,m.colorsClassName=this.buttonColorsClassName,m.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(m)},s.prototype.getUI=function(){var m=H.prototype.getUI.call(this);return this.buttons.forEach(function(B){return m.appendChild(B.getUI())}),m},s}(Qt),Tt=function(){function H(s,m){this._isActive=!1,this._isHidden=!1,this._icon=s,this.title=m,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(H.prototype,"icon",{get:function(){return this._icon},set:function(s){this._icon=s,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isActive",{get:function(){return this._isActive},set:function(s){this._isActive=s,this.adjustClassName()},enumerable:!1,configurable:!0}),H.prototype.getUI=function(){var s=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 s.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},H.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,"")))},H.prototype.hide=function(){this._isHidden=!0},H}(),pt=function(H){function s(){var m=H!==null&&H.apply(this,arguments)||this;return m.elements=[],m}return Ht(s,H),s.prototype.addElement=function(m){this.elements.push(m)},s.prototype.getUI=function(){var m=H.prototype.getUI.call(this);return this.elements.forEach(function(B){return m.appendChild(B)}),m},s}(Qt),ur=function(){function H(s,m){this.horizontal=s,this.vertical=m}return Object.defineProperty(H.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),H.prototype.getVerticalLength=function(s){return s/this.ratio},H.prototype.getHorizontalLength=function(s){return s*this.ratio},H}(),Lr=function(){function H(){}return H.getIcon=function(s,m){if(s>0&&m>0){var B=new ur(s,m),K=B.ratio>=1?20:B.getHorizontalLength(20),U=B.ratio<1?20:B.getVerticalLength(20),he=document.createElementNS("http://www.w3.org/2000/svg","svg");he.setAttribute("xmlns","http://www.w3.org/2000/svg"),he.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(he);var Pe=yt.createDefs();he.appendChild(Pe);var et=yt.createElement("clipPath",[["id","text-bg-clip"]]);Pe.appendChild(et);var ct=yt.createPath(yt.getHollowRectanglePath((24-K)/2,(24-U)/2,K,U,(24-K)/2+2,(24-U)/2+2,K-4,U-4));he.appendChild(ct);var Be=yt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Be.appendChild(yt.createTSpan(s+":"+m)),he.appendChild(Be);var Ct=Be.getBBox();yt.setAttributes(Be,[["x",((24-Ct.width)/2).toString()],["y",((24-Ct.height)/2-Ct.y).toString()]]);var Ot=yt.createPath(yt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Ct.width))/2,(24-Math.ceil(Ct.height))/2,Math.ceil(Ct.width),Math.ceil(Ct.height)));return et.appendChild(Ot),yt.setAttributes(ct,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(he),he.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>'},H}(),Ar=function(H){function s(m,B,K){var U=H.call(this,m,B)||this;return U.isDropdownOpen=!1,U.onClick=U.dropdownButtonClicked,U.dropdownButtons=K,U}return Ht(s,H),s.prototype.setupDropdown=function(){var m=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(B){B.className=m.className,B.colorsClassName=m.colorsClassName,m.dropdownBlock.appendChild(B.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},s.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},s.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},s.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},s.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},s.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},s}(Tt),Rt=function(){function H(s,m){this.GRIP_SIZE=10,this.color=s,this.fillColor=m,this.visual=yt.createGroup(),this.visual.appendChild(yt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(yt.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return H.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},H.prototype.setCenter=function(s,m){this.visual.childNodes.forEach(function(B){return yt.setAttributes(B,[["cx",s.toString()],["cy",m.toString()]])})},H}(),jr=function(){function H(s,m,B,K){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=s,this.canvasHeight=m,this.margin=B,this.container=K,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(H.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(s){this._aspectRatio=s,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.gridContainer&&yt.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),H.prototype.open=function(){var s=this;this.cropShadeElement=yt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=yt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var m=0;m<this.numberOfGridLines;m++)this.horizontalGridLines.push(yt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(yt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(B){return s.gridContainer.appendChild(B)}),this.verticalGridLines.forEach(function(B){return s.gridContainer.appendChild(B)}),this.cropRectElement=yt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Rt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Rt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Rt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Rt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},H.prototype.setCropRectangle=function(s){this.cropRect=s;var m=Object.assign({},this.cropRect);this.zoomFactor!==1&&(m.width=this.cropRect.width*this.zoomFactor,m.height=this.cropRect.height*this.zoomFactor,m.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-m.width/2,m.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-m.height/2),yt.setAttributes(this.cropRectElement,[["x",m.x.toString()],["y",m.y.toString()],["width",m.width.toString()],["height",m.height.toString()]]);var B=m.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(U,he){var Pe=m.y+B*(he+1);yt.setAttributes(U,[["x1",""+m.x],["y1",""+Pe],["x2",""+(m.x+m.width)],["y2",""+Pe]])});var K=m.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(U,he){var Pe=m.x+K*(he+1);yt.setAttributes(U,[["x1",""+Pe],["y1",""+m.y],["x2",""+Pe],["y2",""+(m.y+m.height)]])}),yt.setAttributes(this.cropShadeElement,[["d",yt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,m.x,m.y,m.width,m.height)]]),this.topLeftGrip.setCenter(m.x,m.y),this.topRightGrip.setCenter(m.x+m.width,m.y),this.bottomLeftGrip.setCenter(m.x,m.y+m.height),this.bottomRightGrip.setCenter(m.x+m.width,m.y+m.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},H.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)},H.prototype.clientToLocalCoordinates=function(s,m){var B=this.container.getBoundingClientRect();return{x:s-B.left+this.margin,y:m-B.top+this.margin}},H.prototype.onPointerDown=function(s){this.container.setPointerCapture(s.pointerId),this.previousPoint=this.clientToLocalCoordinates(s.clientX,s.clientY),this.cropRectElement===s.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(s.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(s.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(s.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(s.target)&&(this.activeGrip=this.bottomRightGrip)},H.prototype.onPointerMove=function(s){if(this.isMoving)this.move(this.clientToLocalCoordinates(s.clientX,s.clientY));else if(this.activeGrip){var m=this.clientToLocalCoordinates(s.clientX,s.clientY);this.resize(m)}s.preventDefault()},H.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},H.prototype.move=function(s){var m=s.x-this.previousPoint.x,B=s.y-this.previousPoint.y;this.zoomFactor!==1&&(m=-m/this.zoomFactor,B=-B/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+m),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+B),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=s},H.prototype.resize=function(s){var m=Object.assign({},this.cropRect),B=s.x-this.previousPoint.x,K=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:m.x+B<this.margin&&(B=this.margin-m.x),m.x+=B,m.width=this.cropRect.x+this.cropRect.width-m.x;break;case this.bottomRightGrip:case this.topRightGrip:m.width+B>this.canvasWidth*this.zoomFactor&&(B=this.canvasWidth*this.zoomFactor-m.width),m.width+=B}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(m.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(B),m.height=this.aspectRatio.getVerticalLength(m.width)):(m.y+=K,m.height=this.cropRect.y+this.cropRect.height-m.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?m.height=this.aspectRatio.getVerticalLength(m.width):m.height+=K}m.width<10&&(m.x=this.cropRect.x,m.width=10),m.height<10&&(m.y=this.cropRect.y,m.height=10),this.previousPoint=s,m.x>=this.margin&&m.y>=this.margin&&m.x-this.margin+m.width<=this.canvasWidth&&m.y-this.margin+m.height<=this.canvasHeight&&(this.cropRect=m,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},H.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var s=this.cropRect.x+this.cropRect.width/2,m=this.cropRect.y+this.cropRect.height/2,B=this.aspectRatio.getHorizontalLength(this.cropRect.height),K=this.aspectRatio.getVerticalLength(this.cropRect.width);B/this.canvasWidth<K/this.canvasHeight?this.cropRect.width=B:this.cropRect.height=K,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=s-this.cropRect.width/2,this.cropRect.y=m-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)}},H.prototype.getRescaledRect=function(s,m,B,K,U,he){var Pe=B/s,et=K/m;return{x:(U.x-he)*Pe+he,y:(U.y-he)*et+he,width:U.width*Pe,height:U.height*et}},H.prototype.scaleCanvas=function(s,m){var B=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,m,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=m,this.onCropChange&&this.onCropChange(B),this.setCropRectangle(B)},H}(),Jr=function(){function H(s){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=s,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(H.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),H.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},H.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},H.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},H.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},H.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var s=this.angleLabelText.getBBox();yt.setAttributes(this.angleLabelElement,[["x",((this.width-s.width)/2).toString()],["y",(this.height/2).toString()]])}},H.prototype.positionScaleShape=function(){if(this.scaleShape){var s=this.scaleShape.transform.baseVal.getItem(0);s.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(s,0)}},H.prototype.getVisual=function(){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width",this.width+"px"),s.setAttribute("height",this.height+"px"),s.setAttribute("viewBox","0 0 "+this.width+" "+this.height),s.style.flexShrink="0",document.body.appendChild(s);for(var m="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,B=1;B<=this.width/5+10;B++){var K=B%5==0?this.height/3:this.height/6;m+="h4v"+-K+"h1v"+K}m+="v1H0Z",this.scaleShape=yt.createPath(m);var U=yt.createTransform();this.scaleShape.transform.baseVal.appendItem(U),s.appendChild(this.scaleShape),this.angleLabelElement=yt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=yt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var he=yt.createTSpan("");return he.innerHTML="°",this.angleLabelElement.appendChild(he),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},H}(),ui=function(){function H(){this.naturalSize=!1,this.imageType="image/png"}return H.prototype.rasterize=function(s,m,B,K,U,he,Pe){var et=this;return new Promise(function(ct){var Be=document.createElement("canvas");Be.width=s.width.baseVal.value-2*K,Be.height=s.height.baseVal.value-2*K;var Ct=1,Ot=1;et.naturalSize===!0?(Ct=m.naturalWidth/(s.width.baseVal.value-2*K)/he,Ot=m.naturalHeight/(s.height.baseVal.value-2*K)/Pe,Be.width=m.naturalWidth/he,Be.height=m.naturalHeight/Pe):et.width!==void 0&&et.height!==void 0&&(Ct=et.width/B.width,Ot=et.height/B.height,Be.width*=Ct,Be.height*=Ot);var Yt=Be.getContext("2d");Yt.translate(Be.width/2,Be.height/2),Yt.rotate(U*Math.PI/180),Yt.scale(he,Pe),Yt.translate(-Be.width/2,-Be.height/2),Yt.drawImage(m,0,0,Be.width,Be.height);var Wr=document.createElement("canvas");Wr.width=B.width*Ct,Wr.height=B.height*Ot,Wr.getContext("2d").putImageData(Yt.getImageData((B.x-K)*Ct,(B.y-K)*Ot,B.width*Ct,B.height*Ot),0,0),ct(Wr.toDataURL(et.imageType,et.imageQuality))})},H}(),We=function(){function H(s){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=H.instanceCounter++,this.styles=new wr(this.instanceNo),this.target=s,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(H.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"gridLines",{get:function(){return this._gridLines},set:function(s){this._gridLines=s,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(s){this._rotationAngle=s,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"aspectRatio",{get:function(){var s;return(s=this._aspectRatio)!==null&&s!==void 0?s:this.aspectRatios[0]},set:function(s){this._aspectRatio=s},enumerable:!1,configurable:!0}),H.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},H.prototype.show=function(){this.showUI(),this.open()},H.prototype.close=function(s){s===void 0&&(s=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),s||this.closeEventListeners.forEach(function(m){return m()}),this._isOpen=!1)},H.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},H.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},H.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},H.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},H.prototype.setupResizeObserver=function(){var s=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.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))},H.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var s=1*this.target.clientWidth/this.target.clientHeight,m=this.contentDiv.clientWidth/s>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*s:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,B=m+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/s;this.resize(m,B)}},H.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},H.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",yt.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},H.prototype.resize=function(s,m){this.imageWidth=Math.round(s),this.imageHeight=Math.round(m),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()},H.prototype.setEditingTarget=function(){var s=document.createElement("canvas");s.width=this.target.naturalWidth,s.height=this.target.naturalHeight,s.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var m=s.toDataURL();yt.setAttributes(this.editingTarget,[["href",m]]),this.setEditingTargetSize()},H.prototype.setTopLeft=function(){var s=this.target.getBoundingClientRect(),m=this.editorCanvas.getBoundingClientRect();this.left=s.left-m.left-this.CANVAS_MARGIN,this.top=s.top-m.top-this.CANVAS_MARGIN},H.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=yt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=yt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=yt.createGroup(),this.editingTargetRotationScaleContainer=yt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var s=yt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(s);var m=yt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(m),this.editingTargetContainer=yt.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)},H.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},H.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=yt.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new jr(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()},H.prototype.zoomToCrop=function(){if(this.cropRect){var s=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,m=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=s+"px "+m+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-s+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-m+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},H.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)},H.prototype.cropRectChanged=function(s){this.cropRect=s,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},H.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},H.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"},H.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},H.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 s=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,m=this.target.offsetTop>s+this.CANVAS_MARGIN?this.target.offsetTop-(s+this.CANVAS_MARGIN):0;this.coverDiv.style.top=m+"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},H.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},H.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new Bt,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 m=new Kt;m.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(m);var B=[];this.aspectRatios.forEach(function(Ot){var Yt=new Tt(Lr.getIcon(Ot.horizontal,Ot.vertical),Ot.horizontal===0&&Ot.vertical===0?"FREE":Ot.horizontal+":"+Ot.vertical);Yt.onClick=function(){return s.ratioButtonClicked(Ot)},B.push(Yt)}),this.aspectRatioButton=new Ar(Lr.getIcon(0,0),"Aspect ratio",B),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,m.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var K=new Tt('<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");K.isActive=this.isGridVisible,K.onClick=function(){s.isGridVisible=!s.isGridVisible,K.isActive=s.isGridVisible},m.addButton(K);var U=new Tt('<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(U.isActive=this.zoomToCropEnabled,U.onClick=function(){s.zoomToCropEnabled=!s.zoomToCropEnabled,U.isActive=s.zoomToCropEnabled},m.addButton(U),!Zr.isLicensed){var he=new pt;this.topToolbar.addElementBlock(he);var Pe=document.createElement("div");Pe.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var et=document.createElement("a");et.style.color="currentColor",et.href="https://markerjs.com/products/cropro",et.target="_blank",et.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>',Pe.appendChild(et),he.addElement(Pe)}var ct=new Kt;ct.minWidth=3*this.toolbarHeight+"px",ct.contentAlign="end",this.topToolbar.addButtonBlock(ct);var Be=new Tt('<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");Be.onClick=this.startRenderAndClose,ct.addButton(Be),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Be.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Ct=new Tt('<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");Ct.onClick=this.close,ct.addButton(Ct),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Ct.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},H.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new Bt,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 m=new Kt;m.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(m);var B=new Tt('<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");B.onClick=this.rotateLeftButtonClicked,m.addButton(B);var K=new Tt('<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");K.onClick=this.rotateRightButtonClicked,m.addButton(K);var U=new pt;U.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(U),this.straightener=new Jr("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(ct){s.rotateBy(ct),s.straightener.angle=s.rotationAngle},U.addElement(this.straightener.getUI());var he=new Kt;he.minWidth=2*this.toolbarHeight+"px",he.contentAlign="end",this.bottomToolbar.addButtonBlock(he);var Pe=new Tt('<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");Pe.onClick=this.flipHorizontallyButtonClicked,he.addButton(Pe);var et=new Tt('<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");et.onClick=this.flipVerticallyButtonClicked,he.addButton(et)},H.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},H.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=Lr.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},H.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new ur(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},H.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},H.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},H.prototype.restoreState=function(s){if(s){var m=this.cropLayer.getRescaledRect(s.width,s.height,this.imageWidth,this.imageHeight,s.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(m),this.cropRectChanged(m),this.flippedHorizontally=s.flippedHorizontally,this.flippedVertically=s.flippedVertically,this.applyFlip(),this.rotationAngle=s.rotationAngle,this.applyRotation()}},H.prototype.clientToLocalCoordinates=function(s,m){var B=this.cropImage.getBoundingClientRect();return{x:s-B.left,y:m-B.top}},H.prototype.onWindowResize=function(){this.positionUI()},H.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var s=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=s+"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()},H.prototype.rotateLeftButtonClicked=function(){var s=this.rotationAngle-90;this.rotationAngle%90!=0&&(s+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(s)},H.prototype.rotateRightButtonClicked=function(){var s=this.rotationAngle+90;this.rotationAngle%90!=0&&(s-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(s)},H.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},H.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},H.prototype.applyRotation=function(){var s=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var m=this.editingTargetRotationContainer.transform.baseVal.getItem(0);m.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(m,0);var B=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/B.width,this.imageHeight/B.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=s},H.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},H.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},H.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},H.prototype.startRenderAndClose=function(){return Dt(this,void 0,void 0,function(){var s,m;return Tr(this,function(B){switch(B.label){case 0:return[4,this.render()];case 1:return s=B.sent(),m=this.getState(),this.renderEventListeners.forEach(function(K){return K(s,m)}),this.close(!0),[2]}})})},H.prototype.render=function(){return Dt(this,void 0,void 0,function(){var s;return Tr(this,function(m){switch(m.label){case 0:return(s=new ui).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.width=this.renderWidth,s.height=this.renderHeight,this.unzoomFromCrop(),yt.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,s.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 m.sent(),[4,s.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,m.sent()]}})})},H.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new lr("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 lr("toolbar_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new lr("toolbar-block",`
|
|
display: flex;
|
|
align-items: center;
|
|
box-sizing: content-box;
|
|
`));var s=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new lr("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.toolbarHeight-2*s)+`px;
|
|
height: `+(this.toolbarHeight-2*s)+`px;
|
|
padding: `+s+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new lr("toolbar_button_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new lr("toolbar_active_button",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
|
|
`)),this.styles.addRule(new tr("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new tr("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
|
|
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new lr("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 lr("toolbar_dropdown_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new lr("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 lr("toolbar_straightener",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
height: `+(this.toolbarHeight-2*s)+`px;
|
|
padding: `+s+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new lr("toolbar_straightener_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`))},H.instanceCounter=0,H}(),wt=re("8hTe"),di=re.n(wt),Ai=/<pre[^>]*>/g;function hi(H){var s=document.createElement("div");return s.innerHTML=H,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var Di=ot.a=function(H){var s=H.value,m=s===void 0?"":s,B=H.edit,K=B===void 0?!1:B,U=H.className,he=H.showTextOnly,Pe=H.showLines,et=H.replaces,ct=H.zoomImg,Be=H.hasMask,Ct=H.style,Ot=Ct===void 0?{}:Ct,Yt=H.stylesPrev,Wr=Yt===void 0?{}:Yt,Hr=String(m),dr=Object(k.useRef)(),Xr=Object(k.useRef)(),Hi=Object(k.useState)(""),Dr=Object(W.a)(Hi,2),Gr=Dr[0],Nr=Dr[1],gi=Object(k.useState)("office"),Qr=Object(W.a)(gi,2),ci=Qr[0],ni=Qr[1],hn=function(){var Ut=new We(Xr.current);Ut.displayMode="popup",Ut.addRenderEventListener(function(){var vr=Object(I.a)(M.a.mark(function It(nr){var Gt;return M.a.wrap(function(rr){for(;;)switch(rr.prev=rr.next){case 0:return dr.current.style.display="none",rr.next=3,Object(ke.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:nr}});case 3:Gt=rr.sent,Gt!=null&&Gt.id&&et(Xr.current.getAttribute("src").replace(ae.a.API_SERVER,""),"/api/attachments/".concat(Gt==null?void 0:Gt.id,"?type=").concat(Gt.content_type));case 5:case"end":return rr.stop()}},It)}));return function(It){return vr.apply(this,arguments)}}()),Ut.show()},Gi=function(){var Ut=new At(Xr.current);Ut.settings.displayMode="popup",Ut.addEventListener("render",function(){var vr=Object(I.a)(M.a.mark(function It(nr){var Gt;return M.a.wrap(function(rr){for(;;)switch(rr.prev=rr.next){case 0:if(dr.current.style.display="none",!Xr.current){rr.next=6;break}return rr.next=4,Object(ke.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:nr.dataUrl}});case 4:Gt=rr.sent,Gt!=null&&Gt.id&&et(Xr.current.getAttribute("src").replace(ae.a.API_SERVER,""),"/api/attachments/".concat(Gt==null?void 0:Gt.id,"?type=").concat(Gt.content_type));case 6:case"end":return rr.stop()}},It)}));return function(It){return vr.apply(this,arguments)}}()),Ut.show(),window.markerArea=Ut},qr=Object(k.useMemo)(function(){try{var qt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Ut=/\"\/api\/attachments\/|\"\/attachments\/download\//g,vr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;Hr=Hr.replace(qt,"("+ae.a.API_SERVER+"/api/attachments/").replace(Ut,'"'+ae.a.API_SERVER+"/api/attachments/").replace(vr,'"'+ae.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,`
|
|
`),Hr=Hr.replace(new RegExp("(?<!\\n)\\n(?!\\n)","g"),`
|
|
`)}catch(ai){}var It=Q(Hr),nr=E();if(Hr.match(/\[TOC\]/)&&(It=It.replace("<p>[TOC]</p>",D()),L()),It=It.replace(/(__special_katext_id_\d+__)/g,function(ai,rr){var _r=nr[rr],zi=_r.type,Ki=_r.expression;return Object(ce.renderToString)(hi(Ki)||"",{displayMode:zi==="block",throwOnError:!1,output:"html"})}),It=It.replace(/▁/g,"\u2581\u2581\u2581"),b(),he){var Gt=document.createElement("div");return Gt.innerHTML=It,Gt.innerText}return setTimeout(function(){return Ri()},500),It},[Hr]),zr=Object(k.useRef)();f.WebkitLineClamp=Pe,Pe&&(Ot=Object(O.a)(Object(O.a)({},Ot),f));function _i(qt){var Ut=qt.target;if(Ut.tagName.toUpperCase()==="IMG"){if(ct){var vr=Ut.getAttribute("src");Nr(vr),ni("image")}}else if(Ut.tagName.toUpperCase()==="A"){var It=Ut.getAttribute("href");if(It.indexOf("office")>-1)qt.preventDefault(),Nr(It),ni("office");else if(It.indexOf("application/pdf")>-1)qt.preventDefault(),Nr(It),ni("pdf");else if(It.indexOf("type=text")>-1)qt.preventDefault(),Nr(It),ni("html");else if(It.startsWith("#")){qt.preventDefault();var nr=document.getElementById(It.replace("#",""));nr&&nr.scrollIntoView(!0)}}}var Ri=function(){var Ut,vr=(Ut=zr.current)===null||Ut===void 0?void 0:Ut.querySelectorAll("video");vr==null||vr.forEach(function(It){if(It.oncontextmenu=function(){return!1},It.src.indexOf(".m3u8")>-1&&!It.canPlayType("application/vnd.apple.mpegurl")){if(q.a.isSupported()){var nr=new q.a;nr.loadSource(It.src),nr.attachMedia(It)}}})};Object(k.useEffect)(function(){if(zr.current&&qr&&(qr.match(Ai)&&window.PR.prettyPrint()),zr.current)return zr.current.addEventListener("click",_i),function(){zr.current.removeEventListener("click",_i),b(),L()}},[qr,zr.current,_i]);var cn=function(Ut){if(!K)return;Ut.target.nodeName==="IMG"?(dr.current.style.display="flex",dr.current.style.width=Ut.target.clientWidth+"px",dr.current.style.height=Ut.target.clientHeight+"px",dr.current.style.top=Ut.target.offsetTop+"px",dr.current.style.left=Ut.target.offsetLeft+"px",Xr.current.src=Ut.target.getAttribute("src")):dr.current.style.display="none"};return v.a.createElement("div",{style:{position:"relative"}},v.a.createElement("div",{ref:zr,style:Object(O.a)({},Ot),className:"".concat(U||""," markdown-body ").concat(di.a.mdBody),onMouseOver:cn,dangerouslySetInnerHTML:{__html:qr}}),v.a.createElement("div",{ref:dr,className:di.a.button},v.a.createElement(Z.a,null,v.a.createElement(X.a,{onClick:function(){return hn()}},"\u88C1\u526A"),v.a.createElement(X.a,{onClick:function(){return Gi()}},"\u7F16\u8F91"))),v.a.createElement("img",{ref:Xr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),v.a.createElement(ve.a,{close:!0,data:Gr,hasMask:Be,type:Gr!=null&&Gr.length?ci:"",style:Object(O.a)({},Wr),onClose:function(){return Nr("")}}))}},"9VGf":function(Et,ot,re){"use strict";re.d(ot,"a",function(){return _});var oe=re("q1tI"),Z=re.n(oe);function _(X,O){var I=Object(oe.useRef)();Object(oe.useEffect)(function(){I.current=X}),Object(oe.useEffect)(function(){function W(){I.current()}if(O!==null){var F=setInterval(W,O);return function(){return clearInterval(F)}}},[O])}},BU3w:function(Et,ot,re){"use strict";re.d(ot,"a",function(){return I});var oe=re("MNnm"),Z="rc-util-key";function _(W){if(W.attachTo)return W.attachTo;var F=document.querySelector("head");return F||document.body}function X(W){var F,M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(oe.a)())return null;var k=document.createElement("style");if((F=M.csp)===null||F===void 0?void 0:F.nonce){var v;k.nonce=(v=M.csp)===null||v===void 0?void 0:v.nonce}k.innerHTML=W;var y=_(M),R=y.firstChild;return M.prepend&&y.prepend?y.prepend(k):M.prepend&&R?y.insertBefore(k,R):y.appendChild(k),k}var O=new Map;function I(W,F){var M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},k=_(M);if(!O.has(k)){var v=X("",M),y=v.parentNode;O.set(k,y),y.removeChild(v)}var R=Array.from(O.get(k).children).find(function(o){return o.tagName==="STYLE"&&o[Z]===F});if(R){var A,x;if(((A=M.csp)===null||A===void 0?void 0:A.nonce)&&R.nonce!==((x=M.csp)===null||x===void 0?void 0:x.nonce)){var C;R.nonce=(C=M.csp)===null||C===void 0?void 0:C.nonce}return R.innerHTML!==W&&(R.innerHTML=W),R}var u=X(W,M);return u[Z]=F,u}},Bd2K:function(Et,ot,re){(function(oe){oe(re("VrN/"),re("osHv"))})(function(oe){oe.defineOption("autoCloseTags",!1,function(M,k,v){if(v!=oe.Init&&v&&M.removeKeyMap("autoCloseTags"),!k)return;var y={name:"autoCloseTags"};(typeof k!="object"||k.whenClosing!==!1)&&(y["'/'"]=function(R){return I(R)}),(typeof k!="object"||k.whenOpening!==!1)&&(y["'>'"]=function(R){return X(R)}),M.addKeyMap(y)});var Z=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],_=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function X(M){if(M.getOption("disableInput"))return oe.Pass;for(var k=M.listSelections(),v=[],y=M.getOption("autoCloseTags"),R=0;R<k.length;R++){if(!k[R].empty())return oe.Pass;var A=k[R].head,x=M.getTokenAt(A),C=oe.innerMode(M.getMode(),x.state),u=C.state,o=C.mode.xmlCurrentTag&&C.mode.xmlCurrentTag(u),l=o&&o.name;if(!l)return oe.Pass;var h=C.mode.configuration=="html",L=typeof y=="object"&&y.dontCloseTags||h&&Z,f=typeof y=="object"&&y.indentTags||h&&_;x.end>A.ch&&(l=l.slice(0,l.length-x.end+A.ch));var p=l.toLowerCase();if(!l||x.type=="string"&&(x.end!=A.ch||!/[\"\']/.test(x.string.charAt(x.string.length-1))||x.string.length==1)||x.type=="tag"&&o.close||x.string.indexOf("/")==A.ch-x.start-1||L&&W(L,p)>-1||F(M,C.mode.xmlCurrentContext&&C.mode.xmlCurrentContext(u)||[],l,A,!0))return oe.Pass;var D=typeof y=="object"&&y.emptyTags;if(D&&W(D,l)>-1){v[R]={text:"/>",newPos:oe.Pos(A.line,A.ch+2)};continue}var S=f&&W(f,p)>-1;v[R]={indent:S,text:">"+(S?`
|
|
|
|
`:"")+"</"+l+">",newPos:S?oe.Pos(A.line+1,0):oe.Pos(A.line,A.ch+1)}}for(var g=typeof y=="object"&&y.dontIndentOnAutoClose,R=k.length-1;R>=0;R--){var c=v[R];M.replaceRange(c.text,k[R].head,k[R].anchor,"+insert");var d=M.listSelections().slice(0);d[R]={head:c.newPos,anchor:c.newPos},M.setSelections(d),!g&&c.indent&&(M.indentLine(c.newPos.line,null,!0),M.indentLine(c.newPos.line+1,null,!0))}}function O(M,k){for(var v=M.listSelections(),y=[],R=k?"/":"</",A=M.getOption("autoCloseTags"),x=typeof A=="object"&&A.dontIndentOnSlash,C=0;C<v.length;C++){if(!v[C].empty())return oe.Pass;var u=v[C].head,o=M.getTokenAt(u),l=oe.innerMode(M.getMode(),o.state),h=l.state;if(k&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=u.ch-1))return oe.Pass;var L,f=l.mode.name!="xml"&&M.getMode().name=="htmlmixed";if(f&&l.mode.name=="javascript")L=R+"script";else if(f&&l.mode.name=="css")L=R+"style";else{var p=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(h);if(!p||p.length&&F(M,p,p[p.length-1],u))return oe.Pass;L=R+p[p.length-1]}M.getLine(u.line).charAt(o.end)!=">"&&(L+=">"),y[C]=L}if(M.replaceSelections(y),v=M.listSelections(),!x)for(var C=0;C<v.length;C++)(C==v.length-1||v[C].head.line<v[C+1].head.line)&&M.indentLine(v[C].head.line)}function I(M){return M.getOption("disableInput")?oe.Pass:O(M,!0)}oe.commands.closeTag=function(M){return O(M)};function W(M,k){if(M.indexOf)return M.indexOf(k);for(var v=0,y=M.length;v<y;++v)if(M[v]==k)return v;return-1}function F(M,k,v,y,R){if(!oe.scanForClosingTag)return!1;var A=Math.min(M.lastLine()+1,y.line+500),x=oe.scanForClosingTag(M,y,null,A);if(!x||x.tag!=v)return!1;for(var C=R?1:0,u=k.length-1;u>=0&&k[u]==v;u--)++C;y=x.to;for(var u=1;u<C;u++){var o=oe.scanForClosingTag(M,y,null,A);if(!o||o.tag!=v)return!1;y=o.to}return!0}})},BjJ7:function(Et,ot,re){"use strict";re.d(ot,"d",function(){return Z}),re.d(ot,"c",function(){return _}),re.d(ot,"e",function(){return X}),re.d(ot,"b",function(){return O}),re.d(ot,"a",function(){return W});var oe=re("m3rI");function Z(F){var M=!0;if(F.length>0){for(var k=0;k<F.length;k++)if(F[k].compile_success==0||!F[k].compile_success){M=!1;break}}else M=!1;return M}function _(F){for(var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",k=[],v=0;v<F.length;v++){var y=F[v],R=M?"".concat(M,"/").concat(y.name):"".concat(y.name);k.push({title:y.name,isLeaf:!(y.type==="tree"),key:R})}return k}function X(F,M,k){for(var v=0;v<F.length;v++){var y=F[v];if(y.key===M){y.children=k;break}y.children&&X(y.children,M,k)}return F}function O(F,M,k){var v;return function(){var y=this,R=arguments,A=function(){v=null,k||F.apply(y,R)},x=k&&!v;clearTimeout(v),v=setTimeout(A,M),x&&F.apply(y,R)}}var I=!0,W=oe.a.API_SERVER},"C+DQ":function(Et,ot,re){},DlQD:function(Et,ot,re){(function(oe,Z){Et.exports=Z()})(this,function(){"use strict";function oe(pe,ue){for(var fe=0;fe<ue.length;fe++){var ee=ue[fe];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(pe,ee.key,ee)}}function Z(pe,ue,fe){return ue&&oe(pe.prototype,ue),fe&&oe(pe,fe),pe}function _(pe,ue){if(!pe)return;if(typeof pe=="string")return X(pe,ue);var fe=Object.prototype.toString.call(pe).slice(8,-1);if(fe==="Object"&&pe.constructor&&(fe=pe.constructor.name),fe==="Map"||fe==="Set")return Array.from(pe);if(fe==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(fe))return X(pe,ue)}function X(pe,ue){(ue==null||ue>pe.length)&&(ue=pe.length);for(var fe=0,ee=new Array(ue);fe<ue;fe++)ee[fe]=pe[fe];return ee}function O(pe,ue){var fe;if(typeof Symbol=="undefined"||pe[Symbol.iterator]==null){if(Array.isArray(pe)||(fe=_(pe))||ue&&pe&&typeof pe.length=="number"){fe&&(pe=fe);var ee=0;return function(){return ee>=pe.length?{done:!0}:{done:!1,value:pe[ee++]}}}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 fe=pe[Symbol.iterator](),fe.next.bind(fe)}function I(pe,ue){return ue={exports:{}},pe(ue,ue.exports),ue.exports}var W=I(function(pe){function ue(){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 fe(ee){pe.exports.defaults=ee}pe.exports={defaults:ue(),getDefaults:ue,changeDefaults:fe}}),F=W.defaults,M=W.getDefaults,k=W.changeDefaults,v=/[&<>"']/,y=/[&<>"']/g,R=/[<>"']|&(?!#?\w+;)/,A=/[<>"']|&(?!#?\w+;)/g,x={"&":"&","<":"<",">":">",'"':""","'":"'"},C=function(ue){return x[ue]};function u(pe,ue){if(ue){if(v.test(pe))return pe.replace(y,C)}else if(R.test(pe))return pe.replace(A,C);return pe}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(pe){return pe.replace(o,function(ue,fe){return fe=fe.toLowerCase(),fe==="colon"?":":fe.charAt(0)==="#"?fe.charAt(1)==="x"?String.fromCharCode(parseInt(fe.substring(2),16)):String.fromCharCode(+fe.substring(1)):""})}var h=/(^|[^\[])\^/g;function L(pe,ue){pe=pe.source||pe,ue=ue||"";var fe={replace:function(te,ie){return ie=ie.source||ie,ie=ie.replace(h,"$1"),pe=pe.replace(te,ie),fe},getRegex:function(){return new RegExp(pe,ue)}};return fe}var f=/[^\w:]/g,p=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function D(pe,ue,fe){if(pe){var ee;try{ee=decodeURIComponent(l(fe)).replace(f,"").toLowerCase()}catch(te){return null}if(ee.indexOf("javascript:")===0||ee.indexOf("vbscript:")===0||ee.indexOf("data:")===0)return null}ue&&!p.test(fe)&&(fe=a(ue,fe));try{fe=encodeURI(fe).replace(/%25/g,"%")}catch(te){return null}return fe}var S={},g=/^[^:]+:\/*[^/]*$/,c=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(pe,ue){S[" "+pe]||(g.test(pe)?S[" "+pe]=pe+"/":S[" "+pe]=P(pe,"/",!0)),pe=S[" "+pe];var fe=pe.indexOf(":")===-1;return ue.substring(0,2)==="//"?fe?ue:pe.replace(c,"$1")+ue:ue.charAt(0)==="/"?fe?ue:pe.replace(d,"$1")+ue:pe+ue}var E={exec:function(){}};function b(pe){for(var ue=1,fe,ee;ue<arguments.length;ue++){fe=arguments[ue];for(ee in fe)Object.prototype.hasOwnProperty.call(fe,ee)&&(pe[ee]=fe[ee])}return pe}function T(pe,ue){var fe=pe.replace(/\|/g,function(ie,ne,be){for(var ge=!1,Re=ne;--Re>=0&&be[Re]==="\\";)ge=!ge;return ge?"|":" |"}),ee=fe.split(/ \|/),te=0;if(ee.length>ue)ee.splice(ue);else for(;ee.length<ue;)ee.push("");for(;te<ee.length;te++)ee[te]=ee[te].trim().replace(/\\\|/g,"|");return ee}function P(pe,ue,fe){var ee=pe.length;if(ee===0)return"";for(var te=0;te<ee;){var ie=pe.charAt(ee-te-1);if(ie===ue&&!fe)te++;else if(ie!==ue&&fe)te++;else break}return pe.substr(0,ee-te)}function G(pe,ue){if(pe.indexOf(ue[1])===-1)return-1;for(var fe=pe.length,ee=0,te=0;te<fe;te++)if(pe[te]==="\\")te++;else if(pe[te]===ue[0])ee++;else if(pe[te]===ue[1]&&(ee--,ee<0))return te;return-1}function Y(pe){pe&&pe.sanitize&&!pe.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 Q={escape:u,unescape:l,edit:L,cleanUrl:D,resolveUrl:a,noopTest:E,merge:b,splitCells:T,rtrim:P,findClosingBracket:G,checkSanitizeDeprecation:Y},z=W.defaults,j=Q.rtrim,q=Q.splitCells,ae=Q.escape,ce=Q.findClosingBracket;function ve(pe,ue,fe){var ee=ue.href,te=ue.title?ae(ue.title):null,ie=pe[1].replace(/\\([\[\]])/g,"$1");return pe[0].charAt(0)!=="!"?{type:"link",raw:fe,href:ee,title:te,text:ie}:{type:"image",raw:fe,href:ee,title:te,text:ae(ie)}}function ke(pe,ue){var fe=pe.match(/^(\s+)(?:```)/);if(fe===null)return ue;var ee=fe[1];return ue.split(`
|
|
`).map(function(te){var ie=te.match(/^\s+/);if(ie===null)return te;var ne=ie[0];return ne.length>=ee.length?te.slice(ee.length):te}).join(`
|
|
`)}var Ee=function(){function pe(fe){this.options=fe||z}var ue=pe.prototype;return ue.space=function(ee){var te=this.rules.block.newline.exec(ee);if(te)return te[0].length>1?{type:"space",raw:te[0]}:{raw:`
|
|
`}},ue.code=function(ee,te){var ie=this.rules.block.code.exec(ee);if(ie){var ne=te[te.length-1];if(ne&&ne.type==="paragraph")return{raw:ie[0],text:ie[0].trimRight()};var be=ie[0].replace(/^ {4}/gm,"");return{type:"code",raw:ie[0],codeBlockStyle:"indented",text:this.options.pedantic?be:j(be,`
|
|
`)}}},ue.fences=function(ee){var te=this.rules.block.fences.exec(ee);if(te){var ie=te[0],ne=ke(ie,te[3]||"");return{type:"code",raw:ie,lang:te[2]?te[2].trim():te[2],text:ne}}},ue.heading=function(ee){var te=this.rules.block.heading.exec(ee);if(te)return{type:"heading",raw:te[0],depth:te[1].length,text:te[2]}},ue.nptable=function(ee){var te=this.rules.block.nptable.exec(ee);if(te){var ie={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[],raw:te[0]};if(ie.header.length===ie.align.length){var ne=ie.align.length,be;for(be=0;be<ne;be++)/^ *-+: *$/.test(ie.align[be])?ie.align[be]="right":/^ *:-+: *$/.test(ie.align[be])?ie.align[be]="center":/^ *:-+ *$/.test(ie.align[be])?ie.align[be]="left":ie.align[be]=null;for(ne=ie.cells.length,be=0;be<ne;be++)ie.cells[be]=q(ie.cells[be],ie.header.length);return ie}}},ue.hr=function(ee){var te=this.rules.block.hr.exec(ee);if(te)return{type:"hr",raw:te[0]}},ue.blockquote=function(ee){var te=this.rules.block.blockquote.exec(ee);if(te){var ie=te[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:te[0],text:ie}}},ue.list=function(ee){var te=this.rules.block.list.exec(ee);if(te){for(var ie=te[0],ne=te[2],be=ne.length>1,ge=ne[ne.length-1]===")",Re={type:"list",raw:ie,ordered:be,start:be?+ne.slice(0,-1):"",loose:!1,items:[]},He=te[0].match(this.rules.block.item),st=!1,Ze,mt,vt,Qe,jt,At,Nt,Ht=He.length,Dt=0;Dt<Ht;Dt++)Ze=He[Dt],ie=Ze,mt=Ze.length,Ze=Ze.replace(/^ *([*+-]|\d+[.)]) */,""),~Ze.indexOf(`
|
|
`)&&(mt-=Ze.length,Ze=this.options.pedantic?Ze.replace(/^ {1,4}/gm,""):Ze.replace(new RegExp("^ {1,"+mt+"}","gm"),"")),Dt!==Ht-1&&(vt=this.rules.block.bullet.exec(He[Dt+1])[0],(be?vt.length===1||!ge&&vt[vt.length-1]===")":vt.length>1||this.options.smartLists&&vt!==ne)&&(Qe=He.slice(Dt+1).join(`
|
|
`),Re.raw=Re.raw.substring(0,Re.raw.length-Qe.length),Dt=Ht-1)),jt=st||/\n\n(?!\s*$)/.test(Ze),Dt!==Ht-1&&(st=Ze.charAt(Ze.length-1)===`
|
|
`,jt||(jt=st)),jt&&(Re.loose=!0),At=/^\[[ xX]\] /.test(Ze),Nt=void 0,At&&(Nt=Ze[1]!==" ",Ze=Ze.replace(/^\[[ xX]\] +/,"")),Re.items.push({type:"list_item",raw:ie,task:At,checked:Nt,loose:jt,text:Ze});return Re}},ue.html=function(ee){var te=this.rules.block.html.exec(ee);if(te)return{type:this.options.sanitize?"paragraph":"html",raw:te[0],pre:!this.options.sanitizer&&(te[1]==="pre"||te[1]==="script"||te[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(te[0]):ae(te[0]):te[0]}},ue.def=function(ee){var te=this.rules.block.def.exec(ee);if(te){te[3]&&(te[3]=te[3].substring(1,te[3].length-1));var ie=te[1].toLowerCase().replace(/\s+/g," ");return{tag:ie,raw:te[0],href:te[2],title:te[3]}}},ue.table=function(ee){var te=this.rules.block.table.exec(ee);if(te){var ie={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[]};if(ie.header.length===ie.align.length){ie.raw=te[0];var ne=ie.align.length,be;for(be=0;be<ne;be++)/^ *-+: *$/.test(ie.align[be])?ie.align[be]="right":/^ *:-+: *$/.test(ie.align[be])?ie.align[be]="center":/^ *:-+ *$/.test(ie.align[be])?ie.align[be]="left":ie.align[be]=null;for(ne=ie.cells.length,be=0;be<ne;be++)ie.cells[be]=q(ie.cells[be].replace(/^ *\| *| *\| *$/g,""),ie.header.length);return ie}}},ue.lheading=function(ee){var te=this.rules.block.lheading.exec(ee);if(te)return{type:"heading",raw:te[0],depth:te[2].charAt(0)==="="?1:2,text:te[1]}},ue.paragraph=function(ee){var te=this.rules.block.paragraph.exec(ee);if(te)return{type:"paragraph",raw:te[0],text:te[1].charAt(te[1].length-1)===`
|
|
`?te[1].slice(0,-1):te[1]}},ue.text=function(ee,te){var ie=this.rules.block.text.exec(ee);if(ie){var ne=te[te.length-1];return ne&&ne.type==="text"?{raw:ie[0],text:ie[0]}:{type:"text",raw:ie[0],text:ie[0]}}},ue.escape=function(ee){var te=this.rules.inline.escape.exec(ee);if(te)return{type:"escape",raw:te[0],text:ae(te[1])}},ue.tag=function(ee,te,ie){var ne=this.rules.inline.tag.exec(ee);if(ne)return!te&&/^<a /i.test(ne[0])?te=!0:te&&/^<\/a>/i.test(ne[0])&&(te=!1),!ie&&/^<(pre|code|kbd|script)(\s|>)/i.test(ne[0])?ie=!0:ie&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ne[0])&&(ie=!1),{type:this.options.sanitize?"text":"html",raw:ne[0],inLink:te,inRawBlock:ie,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ne[0]):ae(ne[0]):ne[0]}},ue.link=function(ee){var te=this.rules.inline.link.exec(ee);if(te){var ie=ce(te[2],"()");if(ie>-1){var ne=te[0].indexOf("!")===0?5:4,be=ne+te[1].length+ie;te[2]=te[2].substring(0,ie),te[0]=te[0].substring(0,be).trim(),te[3]=""}var ge=te[2],Re="";if(this.options.pedantic){var He=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(ge);He?(ge=He[1],Re=He[3]):Re=""}else Re=te[3]?te[3].slice(1,-1):"";ge=ge.trim().replace(/^<([\s\S]*)>$/,"$1");var st=ve(te,{href:ge&&ge.replace(this.rules.inline._escapes,"$1"),title:Re&&Re.replace(this.rules.inline._escapes,"$1")},te[0]);return st}},ue.reflink=function(ee,te){var ie;if((ie=this.rules.inline.reflink.exec(ee))||(ie=this.rules.inline.nolink.exec(ee))){var ne=(ie[2]||ie[1]).replace(/\s+/g," ");if(ne=te[ne.toLowerCase()],!ne||!ne.href){var be=ie[0].charAt(0);return{type:"text",raw:be,text:be}}var ge=ve(ie,ne,ie[0]);return ge}},ue.strong=function(ee,te,ie){ie===void 0&&(ie="");var ne=this.rules.inline.strong.start.exec(ee);if(ne&&(!ne[1]||ne[1]&&(ie===""||this.rules.inline.punctuation.exec(ie)))){te=te.slice(-1*ee.length);var be=ne[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;be.lastIndex=0;for(var ge;(ne=be.exec(te))!=null;)if(ge=this.rules.inline.strong.middle.exec(te.slice(0,ne.index+3)),ge)return{type:"strong",raw:ee.slice(0,ge[0].length),text:ee.slice(2,ge[0].length-2)}}},ue.em=function(ee,te,ie){ie===void 0&&(ie="");var ne=this.rules.inline.em.start.exec(ee);if(ne&&(!ne[1]||ne[1]&&(ie===""||this.rules.inline.punctuation.exec(ie)))){te=te.slice(-1*ee.length);var be=ne[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;be.lastIndex=0;for(var ge;(ne=be.exec(te))!=null;)if(ge=this.rules.inline.em.middle.exec(te.slice(0,ne.index+2)),ge)return{type:"em",raw:ee.slice(0,ge[0].length),text:ee.slice(1,ge[0].length-1)}}},ue.codespan=function(ee){var te=this.rules.inline.code.exec(ee);if(te){var ie=te[2].replace(/\n/g," "),ne=/[^ ]/.test(ie),be=ie.startsWith(" ")&&ie.endsWith(" ");return ne&&be&&(ie=ie.substring(1,ie.length-1)),ie=ae(ie,!0),{type:"codespan",raw:te[0],text:ie}}},ue.br=function(ee){var te=this.rules.inline.br.exec(ee);if(te)return{type:"br",raw:te[0]}},ue.del=function(ee){var te=this.rules.inline.del.exec(ee);if(te)return{type:"del",raw:te[0],text:te[1]}},ue.autolink=function(ee,te){var ie=this.rules.inline.autolink.exec(ee);if(ie){var ne,be;return ie[2]==="@"?(ne=ae(this.options.mangle?te(ie[1]):ie[1]),be="mailto:"+ne):(ne=ae(ie[1]),be=ne),{type:"link",raw:ie[0],text:ne,href:be,tokens:[{type:"text",raw:ne,text:ne}]}}},ue.url=function(ee,te){var ie;if(ie=this.rules.inline.url.exec(ee)){var ne,be;if(ie[2]==="@")ne=ae(this.options.mangle?te(ie[0]):ie[0]),be="mailto:"+ne;else{var ge;do ge=ie[0],ie[0]=this.rules.inline._backpedal.exec(ie[0])[0];while(ge!==ie[0]);ne=ae(ie[0]),ie[1]==="www."?be="http://"+ne:be=ne}return{type:"link",raw:ie[0],text:ne,href:be,tokens:[{type:"text",raw:ne,text:ne}]}}},ue.inlineText=function(ee,te,ie){var ne=this.rules.inline.text.exec(ee);if(ne){var be;return te?be=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ne[0]):ae(ne[0]):ne[0]:be=ae(this.options.smartypants?ie(ne[0]):ne[0]),{type:"text",raw:ne[0],text:be}}},pe}(),Ce=Q.noopTest,Le=Q.edit,we=Q.merge,me={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:Ce,table:Ce,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};me._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,me._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,me.def=Le(me.def).replace("label",me._label).replace("title",me._title).getRegex(),me.bullet=/(?:[*+-]|\d{1,9}[.)])/,me.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,me.item=Le(me.item,"gm").replace(/bull/g,me.bullet).getRegex(),me.list=Le(me.list).replace(/bull/g,me.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+me.def.source+")").getRegex(),me._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",me._comment=/<!--(?!-?>)[\s\S]*?-->/,me.html=Le(me.html,"i").replace("comment",me._comment).replace("tag",me._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),me.paragraph=Le(me._paragraph).replace("hr",me.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",me._tag).getRegex(),me.blockquote=Le(me.blockquote).replace("paragraph",me.paragraph).getRegex(),me.normal=we({},me),me.gfm=we({},me.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*|$)"}),me.gfm.nptable=Le(me.gfm.nptable).replace("hr",me.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",me._tag).getRegex(),me.gfm.table=Le(me.gfm.table).replace("hr",me.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",me._tag).getRegex(),me.pedantic=we({},me.normal,{html:Le(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",me._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:Ce,paragraph:Le(me.normal._paragraph).replace("hr",me.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",me.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var le={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ce,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:Ce,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};le._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",le.punctuation=Le(le.punctuation).replace(/punctuation/g,le._punctuation).getRegex(),le._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",le._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",le.em.start=Le(le.em.start).replace(/punctuation/g,le._punctuation).getRegex(),le.em.middle=Le(le.em.middle).replace(/punctuation/g,le._punctuation).replace(/overlapSkip/g,le._overlapSkip).getRegex(),le.em.endAst=Le(le.em.endAst,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.em.endUnd=Le(le.em.endUnd,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.strong.start=Le(le.strong.start).replace(/punctuation/g,le._punctuation).getRegex(),le.strong.middle=Le(le.strong.middle).replace(/punctuation/g,le._punctuation).replace(/blockSkip/g,le._blockSkip).getRegex(),le.strong.endAst=Le(le.strong.endAst,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.strong.endUnd=Le(le.strong.endUnd,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.blockSkip=Le(le._blockSkip,"g").getRegex(),le.overlapSkip=Le(le._overlapSkip,"g").getRegex(),le._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,le._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,le._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])?)+(?![-_])/,le.autolink=Le(le.autolink).replace("scheme",le._scheme).replace("email",le._email).getRegex(),le._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,le.tag=Le(le.tag).replace("comment",me._comment).replace("attribute",le._attribute).getRegex(),le._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,le._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,le._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,le.link=Le(le.link).replace("label",le._label).replace("href",le._href).replace("title",le._title).getRegex(),le.reflink=Le(le.reflink).replace("label",le._label).getRegex(),le.reflinkSearch=Le(le.reflinkSearch,"g").replace("reflink",le.reflink).replace("nolink",le.nolink).getRegex(),le.normal=we({},le),le.pedantic=we({},le.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:Le(/^!?\[(label)\]\((.*?)\)/).replace("label",le._label).getRegex(),reflink:Le(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",le._label).getRegex()}),le.gfm=we({},le.normal,{escape:Le(le.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),le.gfm.url=Le(le.gfm.url,"i").replace("email",le.gfm._extended_email).getRegex(),le.breaks=we({},le.gfm,{br:Le(le.br).replace("{2,}","*").getRegex(),text:Le(le.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var Oe={block:me,inline:le},Ye=W.defaults,Ve=Oe.block,$e=Oe.inline;function ze(pe){return pe.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 Se(pe){var ue="",fe,ee,te=pe.length;for(fe=0;fe<te;fe++)ee=pe.charCodeAt(fe),Math.random()>.5&&(ee="x"+ee.toString(16)),ue+="&#"+ee+";";return ue}var De=function(){function pe(fe){this.tokens=[],this.tokens.links=Object.create(null),this.options=fe||Ye,this.options.tokenizer=this.options.tokenizer||new Ee,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ee={block:Ve.normal,inline:$e.normal};this.options.pedantic?(ee.block=Ve.pedantic,ee.inline=$e.pedantic):this.options.gfm&&(ee.block=Ve.gfm,this.options.breaks?ee.inline=$e.breaks:ee.inline=$e.gfm),this.tokenizer.rules=ee}pe.lex=function(ee,te){var ie=new pe(te);return ie.lex(ee)};var ue=pe.prototype;return ue.lex=function(ee){return ee=ee.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," "),this.blockTokens(ee,this.tokens,!0),this.inline(this.tokens),this.tokens},ue.blockTokens=function(ee,te,ie){te===void 0&&(te=[]),ie===void 0&&(ie=!0),ee=ee.replace(/^ +$/gm,"");for(var ne,be,ge,Re;ee;){if(ne=this.tokenizer.space(ee)){ee=ee.substring(ne.raw.length),ne.type&&te.push(ne);continue}if(ne=this.tokenizer.code(ee,te)){ee=ee.substring(ne.raw.length),ne.type?te.push(ne):(Re=te[te.length-1],Re.raw+=`
|
|
`+ne.raw,Re.text+=`
|
|
`+ne.text);continue}if(ne=this.tokenizer.fences(ee)){ee=ee.substring(ne.raw.length),te.push(ne);continue}if(ne=this.tokenizer.heading(ee)){ee=ee.substring(ne.raw.length),te.push(ne);continue}if(ne=this.tokenizer.nptable(ee)){ee=ee.substring(ne.raw.length),te.push(ne);continue}if(ne=this.tokenizer.hr(ee)){ee=ee.substring(ne.raw.length),te.push(ne);continue}if(ne=this.tokenizer.blockquote(ee)){ee=ee.substring(ne.raw.length),ne.tokens=this.blockTokens(ne.text,[],ie),te.push(ne);continue}if(ne=this.tokenizer.list(ee)){for(ee=ee.substring(ne.raw.length),ge=ne.items.length,be=0;be<ge;be++)ne.items[be].tokens=this.blockTokens(ne.items[be].text,[],!1);te.push(ne);continue}if(ne=this.tokenizer.html(ee)){ee=ee.substring(ne.raw.length),te.push(ne);continue}if(ie&&(ne=this.tokenizer.def(ee))){ee=ee.substring(ne.raw.length),this.tokens.links[ne.tag]||(this.tokens.links[ne.tag]={href:ne.href,title:ne.title});continue}if(ne=this.tokenizer.table(ee)){ee=ee.substring(ne.raw.length),te.push(ne);continue}if(ne=this.tokenizer.lheading(ee)){ee=ee.substring(ne.raw.length),te.push(ne);continue}if(ie&&(ne=this.tokenizer.paragraph(ee))){ee=ee.substring(ne.raw.length),te.push(ne);continue}if(ne=this.tokenizer.text(ee,te)){ee=ee.substring(ne.raw.length),ne.type?te.push(ne):(Re=te[te.length-1],Re.raw+=`
|
|
`+ne.raw,Re.text+=`
|
|
`+ne.text);continue}if(ee){var He="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(He);break}else throw new Error(He)}}return te},ue.inline=function(ee){var te,ie,ne,be,ge,Re,He=ee.length;for(te=0;te<He;te++){Re=ee[te];switch(Re.type){case"paragraph":case"text":case"heading":{Re.tokens=[],this.inlineTokens(Re.text,Re.tokens);break}case"table":{for(Re.tokens={header:[],cells:[]},be=Re.header.length,ie=0;ie<be;ie++)Re.tokens.header[ie]=[],this.inlineTokens(Re.header[ie],Re.tokens.header[ie]);for(be=Re.cells.length,ie=0;ie<be;ie++)for(ge=Re.cells[ie],Re.tokens.cells[ie]=[],ne=0;ne<ge.length;ne++)Re.tokens.cells[ie][ne]=[],this.inlineTokens(ge[ne],Re.tokens.cells[ie][ne]);break}case"blockquote":{this.inline(Re.tokens);break}case"list":{for(be=Re.items.length,ie=0;ie<be;ie++)this.inline(Re.items[ie].tokens);break}}}return ee},ue.inlineTokens=function(ee,te,ie,ne,be){te===void 0&&(te=[]),ie===void 0&&(ie=!1),ne===void 0&&(ne=!1),be===void 0&&(be="");var ge,Re=ee,He;if(this.tokens.links){var st=Object.keys(this.tokens.links);if(st.length>0)for(;(He=this.tokenizer.rules.inline.reflinkSearch.exec(Re))!=null;)st.includes(He[0].slice(He[0].lastIndexOf("[")+1,-1))&&(Re=Re.slice(0,He.index)+"["+"a".repeat(He[0].length-2)+"]"+Re.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(He=this.tokenizer.rules.inline.blockSkip.exec(Re))!=null;)Re=Re.slice(0,He.index)+"["+"a".repeat(He[0].length-2)+"]"+Re.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;ee;){if(ge=this.tokenizer.escape(ee)){ee=ee.substring(ge.raw.length),te.push(ge);continue}if(ge=this.tokenizer.tag(ee,ie,ne)){ee=ee.substring(ge.raw.length),ie=ge.inLink,ne=ge.inRawBlock,te.push(ge);continue}if(ge=this.tokenizer.link(ee)){ee=ee.substring(ge.raw.length),ge.type==="link"&&(ge.tokens=this.inlineTokens(ge.text,[],!0,ne)),te.push(ge);continue}if(ge=this.tokenizer.reflink(ee,this.tokens.links)){ee=ee.substring(ge.raw.length),ge.type==="link"&&(ge.tokens=this.inlineTokens(ge.text,[],!0,ne)),te.push(ge);continue}if(ge=this.tokenizer.strong(ee,Re,be)){ee=ee.substring(ge.raw.length),ge.tokens=this.inlineTokens(ge.text,[],ie,ne),te.push(ge);continue}if(ge=this.tokenizer.em(ee,Re,be)){ee=ee.substring(ge.raw.length),ge.tokens=this.inlineTokens(ge.text,[],ie,ne),te.push(ge);continue}if(ge=this.tokenizer.codespan(ee)){ee=ee.substring(ge.raw.length),te.push(ge);continue}if(ge=this.tokenizer.br(ee)){ee=ee.substring(ge.raw.length),te.push(ge);continue}if(ge=this.tokenizer.del(ee)){ee=ee.substring(ge.raw.length),ge.tokens=this.inlineTokens(ge.text,[],ie,ne),te.push(ge);continue}if(ge=this.tokenizer.autolink(ee,Se)){ee=ee.substring(ge.raw.length),te.push(ge);continue}if(!ie&&(ge=this.tokenizer.url(ee,Se))){ee=ee.substring(ge.raw.length),te.push(ge);continue}if(ge=this.tokenizer.inlineText(ee,ne,ze)){ee=ee.substring(ge.raw.length),be=ge.raw.slice(-1),te.push(ge);continue}if(ee){var Ze="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(Ze);break}else throw new Error(Ze)}}return te},Z(pe,null,[{key:"rules",get:function(){return{block:Ve,inline:$e}}}]),pe}(),Ne=W.defaults,Ge=Q.cleanUrl,je=Q.escape,Me=function(){function pe(fe){this.options=fe||Ne}var ue=pe.prototype;return ue.code=function(ee,te,ie){var ne=(te||"").match(/\S*/)[0];if(this.options.highlight){var be=this.options.highlight(ee,ne);be!=null&&be!==ee&&(ie=!0,ee=be)}return ne?'<pre><code class="'+this.options.langPrefix+je(ne,!0)+'">'+(ie?ee:je(ee,!0))+`</code></pre>
|
|
`:"<pre><code>"+(ie?ee:je(ee,!0))+`</code></pre>
|
|
`},ue.blockquote=function(ee){return`<blockquote>
|
|
`+ee+`</blockquote>
|
|
`},ue.html=function(ee){return ee},ue.heading=function(ee,te,ie,ne){return this.options.headerIds?"<h"+te+' id="'+this.options.headerPrefix+ne.slug(ie)+'">'+ee+"</h"+te+`>
|
|
`:"<h"+te+">"+ee+"</h"+te+`>
|
|
`},ue.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},ue.list=function(ee,te,ie){var ne=te?"ol":"ul",be=te&&ie!==1?' start="'+ie+'"':"";return"<"+ne+be+`>
|
|
`+ee+"</"+ne+`>
|
|
`},ue.listitem=function(ee){return"<li>"+ee+`</li>
|
|
`},ue.checkbox=function(ee){return"<input "+(ee?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},ue.paragraph=function(ee){return"<p>"+ee+`</p>
|
|
`},ue.table=function(ee,te){return te&&(te="<tbody>"+te+"</tbody>"),`<table>
|
|
<thead>
|
|
`+ee+`</thead>
|
|
`+te+`</table>
|
|
`},ue.tablerow=function(ee){return`<tr>
|
|
`+ee+`</tr>
|
|
`},ue.tablecell=function(ee,te){var ie=te.header?"th":"td",ne=te.align?"<"+ie+' align="'+te.align+'">':"<"+ie+">";return ne+ee+"</"+ie+`>
|
|
`},ue.strong=function(ee){return"<strong>"+ee+"</strong>"},ue.em=function(ee){return"<em>"+ee+"</em>"},ue.codespan=function(ee){return"<code>"+ee+"</code>"},ue.br=function(){return this.options.xhtml?"<br/>":"<br>"},ue.del=function(ee){return"<del>"+ee+"</del>"},ue.link=function(ee,te,ie){if(ee=Ge(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ie;var ne='<a href="'+je(ee)+'"';return te&&(ne+=' title="'+te+'"'),ne+=">"+ie+"</a>",ne},ue.image=function(ee,te,ie){if(ee=Ge(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ie;var ne='<img src="'+ee+'" alt="'+ie+'"';return te&&(ne+=' title="'+te+'"'),ne+=this.options.xhtml?"/>":">",ne},ue.text=function(ee){return ee},pe}(),Ie=function(){function pe(){}var ue=pe.prototype;return ue.strong=function(ee){return ee},ue.em=function(ee){return ee},ue.codespan=function(ee){return ee},ue.del=function(ee){return ee},ue.html=function(ee){return ee},ue.text=function(ee){return ee},ue.link=function(ee,te,ie){return""+ie},ue.image=function(ee,te,ie){return""+ie},ue.br=function(){return""},pe}(),lt=function(){function pe(){this.seen={}}var ue=pe.prototype;return ue.slug=function(ee){var te=ee.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(te)){var ie=te;do this.seen[ie]++,te=ie+"-"+this.seen[ie];while(this.seen.hasOwnProperty(te))}return this.seen[te]=0,te},pe}(),tt=W.defaults,qe=Q.unescape,Xe=function(){function pe(fe){this.options=fe||tt,this.options.renderer=this.options.renderer||new Me,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Ie,this.slugger=new lt}pe.parse=function(ee,te){var ie=new pe(te);return ie.parse(ee)};var ue=pe.prototype;return ue.parse=function(ee,te){te===void 0&&(te=!0);var ie="",ne,be,ge,Re,He,st,Ze,mt,vt,Qe,jt,At,Nt,Ht,Dt,Tr,Zr,yt,wr=ee.length;for(ne=0;ne<wr;ne++){Qe=ee[ne];switch(Qe.type){case"space":continue;case"hr":{ie+=this.renderer.hr();continue}case"heading":{ie+=this.renderer.heading(this.parseInline(Qe.tokens),Qe.depth,qe(this.parseInline(Qe.tokens,this.textRenderer)),this.slugger);continue}case"code":{ie+=this.renderer.code(Qe.text,Qe.lang,Qe.escaped);continue}case"table":{for(mt="",Ze="",Re=Qe.header.length,be=0;be<Re;be++)Ze+=this.renderer.tablecell(this.parseInline(Qe.tokens.header[be]),{header:!0,align:Qe.align[be]});for(mt+=this.renderer.tablerow(Ze),vt="",Re=Qe.cells.length,be=0;be<Re;be++){for(st=Qe.tokens.cells[be],Ze="",He=st.length,ge=0;ge<He;ge++)Ze+=this.renderer.tablecell(this.parseInline(st[ge]),{header:!1,align:Qe.align[ge]});vt+=this.renderer.tablerow(Ze)}ie+=this.renderer.table(mt,vt);continue}case"blockquote":{vt=this.parse(Qe.tokens),ie+=this.renderer.blockquote(vt);continue}case"list":{for(jt=Qe.ordered,At=Qe.start,Nt=Qe.loose,Re=Qe.items.length,vt="",be=0;be<Re;be++)Dt=Qe.items[be],Tr=Dt.checked,Zr=Dt.task,Ht="",Dt.task&&(yt=this.renderer.checkbox(Tr),Nt?Dt.tokens.length>0&&Dt.tokens[0].type==="text"?(Dt.tokens[0].text=yt+" "+Dt.tokens[0].text,Dt.tokens[0].tokens&&Dt.tokens[0].tokens.length>0&&Dt.tokens[0].tokens[0].type==="text"&&(Dt.tokens[0].tokens[0].text=yt+" "+Dt.tokens[0].tokens[0].text)):Dt.tokens.unshift({type:"text",text:yt}):Ht+=yt),Ht+=this.parse(Dt.tokens,Nt),vt+=this.renderer.listitem(Ht,Zr,Tr);ie+=this.renderer.list(vt,jt,At);continue}case"html":{ie+=this.renderer.html(Qe.text);continue}case"paragraph":{ie+=this.renderer.paragraph(this.parseInline(Qe.tokens));continue}case"text":{for(vt=Qe.tokens?this.parseInline(Qe.tokens):Qe.text;ne+1<wr&&ee[ne+1].type==="text";)Qe=ee[++ne],vt+=`
|
|
`+(Qe.tokens?this.parseInline(Qe.tokens):Qe.text);ie+=te?this.renderer.paragraph(vt):vt;continue}default:{var tr='Token with "'+Qe.type+'" type was not found.';if(this.options.silent){console.error(tr);return}else throw new Error(tr)}}}return ie},ue.parseInline=function(ee,te){te=te||this.renderer;var ie="",ne,be,ge=ee.length;for(ne=0;ne<ge;ne++){be=ee[ne];switch(be.type){case"escape":{ie+=te.text(be.text);break}case"html":{ie+=te.html(be.text);break}case"link":{ie+=te.link(be.href,be.title,this.parseInline(be.tokens,te));break}case"image":{ie+=te.image(be.href,be.title,be.text);break}case"strong":{ie+=te.strong(this.parseInline(be.tokens,te));break}case"em":{ie+=te.em(this.parseInline(be.tokens,te));break}case"codespan":{ie+=te.codespan(be.text);break}case"br":{ie+=te.br();break}case"del":{ie+=te.del(this.parseInline(be.tokens,te));break}case"text":{ie+=te.text(be.text);break}default:{var Re='Token with "'+be.type+'" type was not found.';if(this.options.silent){console.error(Re);return}else throw new Error(Re)}}}return ie},pe}(),ht=Q.merge,nt=Q.checkSanitizeDeprecation,Je=Q.escape,Te=W.getDefaults,ut=W.changeDefaults,at=W.defaults;function Ae(pe,ue,fe){if(typeof pe=="undefined"||pe===null)throw new Error("marked(): input parameter is undefined or null");if(typeof pe!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(pe)+", string expected");if(typeof ue=="function"&&(fe=ue,ue=null),ue=ht({},Ae.defaults,ue||{}),nt(ue),fe){var ee=ue.highlight,te;try{te=De.lex(pe,ue)}catch(ge){return fe(ge)}var ie=function(Re){var He;if(!Re)try{He=Xe.parse(te,ue)}catch(st){Re=st}return ue.highlight=ee,Re?fe(Re):fe(null,He)};if(!ee||ee.length<3)return ie();if(delete ue.highlight,!te.length)return ie();var ne=0;Ae.walkTokens(te,function(ge){ge.type==="code"&&(ne++,setTimeout(function(){ee(ge.text,ge.lang,function(Re,He){if(Re)return ie(Re);He!=null&&He!==ge.text&&(ge.text=He,ge.escaped=!0),ne--,ne===0&&ie()})},0))}),ne===0&&ie();return}try{var be=De.lex(pe,ue);return ue.walkTokens&&Ae.walkTokens(be,ue.walkTokens),Xe.parse(be,ue)}catch(ge){if(ge.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,ue.silent)return"<p>An error occurred:</p><pre>"+Je(ge.message+"",!0)+"</pre>";throw ge}}Ae.options=Ae.setOptions=function(pe){return ht(Ae.defaults,pe),ut(Ae.defaults),Ae},Ae.getDefaults=Te,Ae.defaults=at,Ae.use=function(pe){var ue=ht({},pe);if(pe.renderer&&function(){var ee=Ae.defaults.renderer||new Me,te=function(be){var ge=ee[be];ee[be]=function(){for(var Re=arguments.length,He=new Array(Re),st=0;st<Re;st++)He[st]=arguments[st];var Ze=pe.renderer[be].apply(ee,He);return Ze===!1&&(Ze=ge.apply(ee,He)),Ze}};for(var ie in pe.renderer)te(ie);ue.renderer=ee}(),pe.tokenizer&&function(){var ee=Ae.defaults.tokenizer||new Ee,te=function(be){var ge=ee[be];ee[be]=function(){for(var Re=arguments.length,He=new Array(Re),st=0;st<Re;st++)He[st]=arguments[st];var Ze=pe.tokenizer[be].apply(ee,He);return Ze===!1&&(Ze=ge.apply(ee,He)),Ze}};for(var ie in pe.tokenizer)te(ie);ue.tokenizer=ee}(),pe.walkTokens){var fe=Ae.defaults.walkTokens;ue.walkTokens=function(ee){pe.walkTokens(ee),fe&&fe(ee)}}Ae.setOptions(ue)},Ae.walkTokens=function(pe,ue){for(var fe=O(pe),ee;!(ee=fe()).done;){var te=ee.value;ue(te);switch(te.type){case"table":{for(var ie=O(te.tokens.header),ne;!(ne=ie()).done;){var be=ne.value;Ae.walkTokens(be,ue)}for(var ge=O(te.tokens.cells),Re;!(Re=ge()).done;)for(var He=Re.value,st=O(He),Ze;!(Ze=st()).done;){var mt=Ze.value;Ae.walkTokens(mt,ue)}break}case"list":{Ae.walkTokens(te.items,ue);break}default:te.tokens&&Ae.walkTokens(te.tokens,ue)}}},Ae.Parser=Xe,Ae.parser=Xe.parse,Ae.Renderer=Me,Ae.TextRenderer=Ie,Ae.Lexer=De,Ae.lexer=De.lex,Ae.Tokenizer=Ee,Ae.Slugger=lt,Ae.parse=Ae;var Ue=Ae;return Ue})},ELLl:function(Et,ot,re){(function(oe){oe(re("VrN/"))})(function(oe){var Z={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},_=oe.Pos;oe.defineOption("autoCloseBrackets",!1,function(x,C,u){u&&u!=oe.Init&&(x.removeKeyMap(O),x.state.closeBrackets=null),C&&(I(X(C,"pairs")),x.state.closeBrackets=C,x.addKeyMap(O))});function X(x,C){return C=="pairs"&&typeof x=="string"?x:typeof x=="object"&&x[C]!=null?x[C]:Z[C]}var O={Backspace:M,Enter:k};function I(x){for(var C=0;C<x.length;C++){var u=x.charAt(C),o="'"+u+"'";O[o]||(O[o]=W(u))}}I(Z.pairs+"`");function W(x){return function(C){return y(C,x)}}function F(x){var C=x.state.closeBrackets;if(!C||C.override)return C;var u=x.getModeAt(x.getCursor());return u.closeBrackets||C}function M(x){var C=F(x);if(!C||x.getOption("disableInput"))return oe.Pass;for(var u=X(C,"pairs"),o=x.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return oe.Pass;var h=R(x,o[l].head);if(!h||u.indexOf(h)%2!=0)return oe.Pass}for(var l=o.length-1;l>=0;l--){var L=o[l].head;x.replaceRange("",_(L.line,L.ch-1),_(L.line,L.ch+1),"+delete")}}function k(x){var C=F(x),u=C&&X(C,"explode");if(!u||x.getOption("disableInput"))return oe.Pass;for(var o=x.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return oe.Pass;var h=R(x,o[l].head);if(!h||u.indexOf(h)%2!=0)return oe.Pass}x.operation(function(){var L=x.lineSeparator()||`
|
|
`;x.replaceSelection(L+L,null),x.execCommand("goCharLeft"),o=x.listSelections();for(var f=0;f<o.length;f++){var p=o[f].head.line;x.indentLine(p,null,!0),x.indentLine(p+1,null,!0)}})}function v(x){var C=oe.cmpPos(x.anchor,x.head)>0;return{anchor:new _(x.anchor.line,x.anchor.ch+(C?-1:1)),head:new _(x.head.line,x.head.ch+(C?1:-1))}}function y(x,C){var u=F(x);if(!u||x.getOption("disableInput"))return oe.Pass;var o=X(u,"pairs"),l=o.indexOf(C);if(l==-1)return oe.Pass;for(var h=X(u,"closeBefore"),L=X(u,"triples"),f=o.charAt(l+1)==C,p=x.listSelections(),D=l%2==0,S,g=0;g<p.length;g++){var c=p[g],d=c.head,a,E=x.getRange(d,_(d.line,d.ch+1));if(D&&!c.empty())a="surround";else if((f||!D)&&E==C)f&&A(x,d)?a="both":L.indexOf(C)>=0&&x.getRange(d,_(d.line,d.ch+3))==C+C+C?a="skipThree":a="skip";else if(f&&d.ch>1&&L.indexOf(C)>=0&&x.getRange(_(d.line,d.ch-2),d)==C+C){if(d.ch>2&&/\bstring/.test(x.getTokenTypeAt(_(d.line,d.ch-2))))return oe.Pass;a="addFour"}else if(f){var b=d.ch==0?" ":x.getRange(_(d.line,d.ch-1),d);if(!oe.isWordChar(E)&&b!=C&&!oe.isWordChar(b))a="both";else return oe.Pass}else if(D&&(E.length===0||/\s/.test(E)||h.indexOf(E)>-1))a="both";else return oe.Pass;if(!S)S=a;else if(S!=a)return oe.Pass}var T=l%2?o.charAt(l-1):C,P=l%2?C:o.charAt(l+1);x.operation(function(){if(S=="skip")x.execCommand("goCharRight");else if(S=="skipThree")for(var G=0;G<3;G++)x.execCommand("goCharRight");else if(S=="surround"){for(var Y=x.getSelections(),G=0;G<Y.length;G++)Y[G]=T+Y[G]+P;x.replaceSelections(Y,"around"),Y=x.listSelections().slice();for(var G=0;G<Y.length;G++)Y[G]=v(Y[G]);x.setSelections(Y)}else S=="both"?(x.replaceSelection(T+P,null),x.triggerElectric(T+P),x.execCommand("goCharLeft")):S=="addFour"&&(x.replaceSelection(T+T+T+T,"before"),x.execCommand("goCharRight"))})}function R(x,C){var u=x.getRange(_(C.line,C.ch-1),_(C.line,C.ch+1));return u.length==2?u:null}function A(x,C){var u=x.getTokenAt(_(C.line,C.ch+1));return/\bstring/.test(u.type)&&u.start==C.ch&&(C.ch==0||!/\bstring/.test(x.getTokenTypeAt(C)))}})},HmJG:function(Et,ot,re){},LSTS:function(Et,ot,re){"use strict";Object.defineProperty(ot,"__esModule",{value:!0});var oe=function(){function y(R,A){for(var x=0;x<A.length;x++){var C=A[x];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(R,C.key,C)}}return function(R,A,x){return A&&y(R.prototype,A),x&&y(R,x),R}}(),Z=re("q1tI"),_=I(Z),X=re("17x9"),O=I(X);function I(y){return y&&y.__esModule?y:{default:y}}function W(y,R){var A={};for(var x in y){if(R.indexOf(x)>=0)continue;if(!Object.prototype.hasOwnProperty.call(y,x))continue;A[x]=y[x]}return A}function F(y,R){if(!(y instanceof R))throw new TypeError("Cannot call a class as a function")}function M(y,R){if(!y)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return R&&(typeof R=="object"||typeof R=="function")?R:y}function k(y,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof R);y.prototype=Object.create(R&&R.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),R&&(Object.setPrototypeOf?Object.setPrototypeOf(y,R):y.__proto__=R)}var v=function(y){k(R,y);function R(A){F(this,R);var x=M(this,(R.__proto__||Object.getPrototypeOf(R)).call(this,A));return x.scrollListener=x.scrollListener.bind(x),x.eventListenerOptions=x.eventListenerOptions.bind(x),x.mousewheelListener=x.mousewheelListener.bind(x),x}return oe(R,[{key:"componentDidMount",value:function(){this.pageLoaded=this.props.pageStart,this.options=this.eventListenerOptions(),this.attachScrollListener()}},{key:"componentDidUpdate",value:function(){if(this.props.isReverse&&this.loadMore){var x=this.getParentElement(this.scrollComponent);x.scrollTop=x.scrollHeight-this.beforeScrollHeight+this.beforeScrollTop,this.loadMore=!1}this.attachScrollListener()}},{key:"componentWillUnmount",value:function(){this.detachScrollListener(),this.detachMousewheelListener()}},{key:"isPassiveSupported",value:function(){var x=!1,C={get passive(){x=!0}};try{document.addEventListener("test",null,C),document.removeEventListener("test",null,C)}catch(u){}return x}},{key:"eventListenerOptions",value:function(){var x=this.props.useCapture;return this.isPassiveSupported()&&(x={useCapture:this.props.useCapture,passive:!0}),x}},{key:"setDefaultLoader",value:function(x){this.defaultLoader=x}},{key:"detachMousewheelListener",value:function(){var x=window;this.props.useWindow===!1&&(x=this.scrollComponent.parentNode),x.removeEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture)}},{key:"detachScrollListener",value:function(){var x=window;this.props.useWindow===!1&&(x=this.getParentElement(this.scrollComponent)),x.removeEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),x.removeEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture)}},{key:"getParentElement",value:function(x){var C=this.props.getScrollParent&&this.props.getScrollParent();return C!=null?C:x&&x.parentNode}},{key:"filterProps",value:function(x){return x}},{key:"attachScrollListener",value:function(){var x=this.getParentElement(this.scrollComponent);if(!this.props.hasMore||!x)return;var C=window;this.props.useWindow===!1&&(C=x),C.addEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture),C.addEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),C.addEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture),this.props.initialLoad&&this.scrollListener()}},{key:"mousewheelListener",value:function(x){x.deltaY===1&&!this.isPassiveSupported()&&x.preventDefault()}},{key:"scrollListener",value:function(){var x=this.scrollComponent,C=window,u=this.getParentElement(x),o=void 0;if(this.props.useWindow){var l=document.documentElement||document.body.parentNode||document.body,h=C.pageYOffset!==void 0?C.pageYOffset:l.scrollTop;this.props.isReverse?o=h:o=this.calculateOffset(x,h)}else this.props.isReverse?o=u.scrollTop:o=x.scrollHeight-u.scrollTop-u.clientHeight;o<Number(this.props.threshold)&&x&&x.offsetParent!==null&&(this.detachScrollListener(),this.beforeScrollHeight=u.scrollHeight,this.beforeScrollTop=u.scrollTop,typeof this.props.loadMore=="function"&&(this.props.loadMore(this.pageLoaded+=1),this.loadMore=!0))}},{key:"calculateOffset",value:function(x,C){return x?this.calculateTopPosition(x)+(x.offsetHeight-C-window.innerHeight):0}},{key:"calculateTopPosition",value:function(x){return x?x.offsetTop+this.calculateTopPosition(x.offsetParent):0}},{key:"render",value:function(){var x=this,C=this.filterProps(this.props),u=C.children,o=C.element,l=C.hasMore,h=C.initialLoad,L=C.isReverse,f=C.loader,p=C.loadMore,D=C.pageStart,S=C.ref,g=C.threshold,c=C.useCapture,d=C.useWindow,a=C.getScrollParent,E=W(C,["children","element","hasMore","initialLoad","isReverse","loader","loadMore","pageStart","ref","threshold","useCapture","useWindow","getScrollParent"]);E.ref=function(T){x.scrollComponent=T,S&&S(T)};var b=[u];return l&&(f?L?b.unshift(f):b.push(f):this.defaultLoader&&(L?b.unshift(this.defaultLoader):b.push(this.defaultLoader))),_.default.createElement(o,E,b)}}]),R}(Z.Component);v.propTypes={children:O.default.node.isRequired,element:O.default.node,hasMore:O.default.bool,initialLoad:O.default.bool,isReverse:O.default.bool,loader:O.default.node,loadMore:O.default.func.isRequired,pageStart:O.default.number,ref:O.default.func,getScrollParent:O.default.func,threshold:O.default.number,useCapture:O.default.bool,useWindow:O.default.bool},v.defaultProps={element:"div",hasMore:!1,initialLoad:!0,pageStart:0,ref:null,threshold:250,useWindow:!0,isReverse:!1,useCapture:!1,loader:null,getScrollParent:null},ot.default=v,Et.exports=ot.default},LdHM:function(Et,ot,re){"use strict";re.d(ot,"b",function(){return h}),re.d(ot,"a",function(){return f});var oe=re("1OyB"),Z=re("vuIU"),_=re("Ji7U"),X=re("LK+K"),O=re("q1tI"),I=re("rePB"),W=re("Ff2n"),F=re("ODXe"),M=re("4IlW"),k=re("bX4T"),v=re("YrtM"),y=re("TSYQ"),R=re.n(y),A=re("+nKL"),x=re("8OUc"),C=function(q,ae){var ce=q.prefixCls,ve=q.id,ke=q.flattenOptions,Ee=q.childrenAsData,Ce=q.values,Le=q.searchValue,we=q.multiple,me=q.defaultActiveFirstOption,le=q.height,Oe=q.itemHeight,Ye=q.notFoundContent,Ve=q.open,$e=q.menuItemSelectedIcon,ze=q.virtual,Se=q.onSelect,De=q.onToggleOpen,Ne=q.onActiveValue,Ge=q.onScroll,je=q.onMouseEnter,Me="".concat(ce,"-item"),Ie=Object(v.a)(function(){return ke},[Ve,ke],function(Ue,pe){return pe[0]&&Ue[1]!==pe[1]}),lt=O.useRef(null),tt=function(pe){pe.preventDefault()},qe=function(pe){lt.current&<.current.scrollTo({index:pe})},Xe=function(pe){for(var ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,fe=Ie.length,ee=0;ee<fe;ee+=1){var te=(pe+ee*ue+fe)%fe,ie=Ie[te],ne=ie.group,be=ie.data;if(!ne&&!be.disabled)return te}return-1},ht=O.useState(function(){return Xe(0)}),nt=Object(F.a)(ht,2),Je=nt[0],Te=nt[1],ut=function(pe){Te(pe);var ue=Ie[pe];if(!ue){Ne(null,-1);return}Ne(ue.data.value,pe)};O.useEffect(function(){ut(me!==!1?Xe(0):-1)},[Ie.length,Le]),O.useEffect(function(){var Ue=setTimeout(function(){if(!we&&Ve&&Ce.size===1){var pe=Array.from(Ce)[0],ue=Ie.findIndex(function(fe){var ee=fe.data;return ee.value===pe});ut(ue),qe(ue)}});return function(){return clearTimeout(Ue)}},[Ve]);var at=function(pe){pe!==void 0&&Se(pe,{selected:!Ce.has(pe)}),we||De(!1)};if(O.useImperativeHandle(ae,function(){return{onKeyDown:function(pe){var ue=pe.which;switch(ue){case M.a.UP:case M.a.DOWN:{var fe=0;if(ue===M.a.UP?fe=-1:ue===M.a.DOWN&&(fe=1),fe!==0){var ee=Xe(Je+fe,fe);qe(ee),ut(ee)}break}case M.a.ENTER:{var te=Ie[Je];te&&!te.data.disabled?at(te.data.value):at(void 0),Ve&&pe.preventDefault();break}case M.a.ESC:De(!1)}},onKeyUp:function(){},scrollTo:function(pe){qe(pe)}}}),Ie.length===0)return O.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),className:"".concat(Me,"-empty"),onMouseDown:tt},Ye);function Ae(Ue){var pe=Ie[Ue];if(!pe)return null;var ue=pe.data||{},fe=ue.value,ee=ue.label,te=ue.children,ie=Object(k.a)(ue,!0),ne=Ee?te:ee;return pe?O.createElement("div",Object.assign({"aria-label":typeof ne=="string"?ne:null},ie,{key:Ue,role:"option",id:"".concat(ve,"_list_").concat(Ue),"aria-selected":Ce.has(fe)}),fe):null}return O.createElement(O.Fragment,null,O.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),style:{height:0,width:0,overflow:"hidden"}},Ae(Je-1),Ae(Je),Ae(Je+1)),O.createElement(A.a,{itemKey:"key",ref:lt,data:Ie,height:le,itemHeight:Oe,fullHeight:!1,onMouseDown:tt,onScroll:Ge,virtual:ze,onMouseEnter:je},function(Ue,pe){var ue,fe=Ue.group,ee=Ue.groupOption,te=Ue.data,ie=te.label,ne=te.key;if(fe)return O.createElement("div",{className:R()(Me,"".concat(Me,"-group"))},ie!==void 0?ie:ne);var be=te.disabled,ge=te.value,Re=te.title,He=te.children,st=te.style,Ze=te.className,mt=Object(W.a)(te,["disabled","value","title","children","style","className"]),vt=Ce.has(ge),Qe="".concat(Me,"-option"),jt=R()(Me,Qe,Ze,(ue={},Object(I.a)(ue,"".concat(Qe,"-grouped"),ee),Object(I.a)(ue,"".concat(Qe,"-active"),Je===pe&&!be),Object(I.a)(ue,"".concat(Qe,"-disabled"),be),Object(I.a)(ue,"".concat(Qe,"-selected"),vt),ue)),At=Ee?He:ie,Nt=!$e||typeof $e=="function"||vt;return O.createElement("div",Object.assign({},mt,{"aria-selected":vt,className:jt,title:Re,onMouseMove:function(){if(Je===pe||be)return;ut(pe)},onClick:function(){be||at(ge)},style:st}),O.createElement("div",{className:"".concat(Qe,"-content")},At||ge),O.isValidElement($e)||vt,Nt&&O.createElement(x.a,{className:"".concat(Me,"-option-state"),customizeIcon:$e,customizeIconProps:{isSelected:vt}},vt?"\u2713":null))}))},u=O.forwardRef(C);u.displayName="OptionList";var o=u,l=function(){return null};l.isSelectOption=!0;var h=l,L=function(){return null};L.isSelectOptGroup=!0;var f=L,p=re("VTBJ"),D=re("Zm9Q");function S(j){var q=j.key,ae=j.props,ce=ae.children,ve=ae.value,ke=Object(W.a)(ae,["children","value"]);return Object(p.a)({key:q,value:ve!==void 0?ve:q,children:ce},ke)}function g(j){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(D.a)(j).map(function(ae,ce){if(!O.isValidElement(ae)||!ae.type)return null;var ve=ae.type.isSelectOptGroup,ke=ae.key,Ee=ae.props,Ce=Ee.children,Le=Object(W.a)(Ee,["children"]);return q||!ve?S(ae):Object(p.a)(Object(p.a)({key:"__RC_SELECT_GRP__".concat(ke===null?ce:ke,"__"),label:ke},Le),{},{options:g(Ce)})}).filter(function(ae){return ae})}var c=re("2Qr1"),d=re("qNPg"),a=re("U8pU"),E=re("Kwbf"),b=re("WKfj");function T(j){var q=j.mode,ae=j.options,ce=j.children,ve=j.backfill,ke=j.allowClear,Ee=j.placeholder,Ce=j.getInputElement,Le=j.showSearch,we=j.onSearch,me=j.defaultOpen,le=j.autoFocus,Oe=j.labelInValue,Ye=j.value,Ve=j.inputValue,$e=j.optionLabelProp,ze=q==="multiple"||q==="tags",Se=Le!==void 0?Le:ze||q==="combobox",De=ae||g(ce);if(Object(E.a)(q!=="tags"||De.every(function(Me){return!Me.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),q==="tags"||q==="combobox"){var Ne=De.some(function(Me){return Me.options?Me.options.some(function(Ie){return typeof("value"in Ie?Ie.value:Ie.key)=="number"}):typeof("value"in Me?Me.value:Me.key)=="number"});Object(E.a)(!Ne,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(E.a)(q!=="combobox"||!$e,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(E.a)(q==="combobox"||!ve,"`backfill` only works with `combobox` mode."),Object(E.a)(q==="combobox"||!Ce,"`getInputElement` only work with `combobox` mode."),Object(E.b)(q!=="combobox"||!Ce||!ke||!Ee,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),we&&!Se&&q!=="combobox"&&q!=="tags"&&Object(E.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(E.b)(!me||le,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Ye!=null){var Ge=Object(b.d)(Ye);Object(E.a)(!Oe||Ge.every(function(Me){return Object(a.a)(Me)==="object"&&("key"in Me||"value"in Me)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(E.a)(!ze||Array.isArray(Ye),"`value` should be array when `mode` is `multiple` or `tags`")}if(ce){var je=null;Object(D.a)(ce).some(function(Me){if(!O.isValidElement(Me)||!Me.type)return!1;var Ie=Me.type;if(Ie.isSelectOption)return!1;if(Ie.isSelectOptGroup){var lt=Object(D.a)(Me.props.children).every(function(tt){return!O.isValidElement(tt)||!Me.type||tt.type.isSelectOption?!0:(je=tt.type,!1)});return!lt}return je=Ie,!0}),je&&Object(E.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(je.displayName||je.name||je,"`.")),Object(E.a)(Ve===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var P=T,G=Object(d.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:g,flattenOptions:c.d,getLabeledValue:c.e,filterOptions:c.b,isValueDisabled:c.g,findValueOption:c.c,warningProps:P,fillOptionsWithMissingValue:c.a}),Y=function(j){Object(_.a)(ae,j);var q=Object(X.a)(ae);function ae(){var ce;return Object(oe.a)(this,ae),ce=q.apply(this,arguments),ce.selectRef=O.createRef(),ce.focus=function(){ce.selectRef.current.focus()},ce.blur=function(){ce.selectRef.current.blur()},ce}return Object(Z.a)(ae,[{key:"render",value:function(){return O.createElement(G,Object.assign({ref:this.selectRef},this.props))}}]),ae}(O.Component);Y.Option=h,Y.OptGroup=f;var Q=Y,z=ot.c=Q},M8RZ:function(Et,ot,re){"use strict";re.d(ot,"a",function(){return M});var oe=re("fWQN"),Z=re("mtLc"),_=re("yKVA"),X=re("879j"),O=re("q1tI"),I=re.n(O),W=re("i8i4"),F=re.n(W),M=function(k){Object(_.a)(y,k);var v=Object(X.a)(y);function y(R){var A;Object(oe.a)(this,y),A=v.call(this,R);var x=window.document;return A.node=x.createElement("div"),x.body.appendChild(A.node),A}return Object(Z.a)(y,[{key:"render",value:function(){var A=this.props.children;return Object(W.createPortal)(A,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),y}(I.a.Component)},Ot1p:function(Et,ot,re){"use strict";var oe=re("2qtc"),Z=re("kLXV"),_=re("rAM+"),X=re("miYZ"),O=re("tsqr"),I=re("9og8"),W=re("tJVT"),F=re("jrin"),M=re("WmNS"),k=re.n(M),v=re("q1tI"),y=re.n(v),R=re("VrN/"),A=re.n(R),x=re("bdgK"),C=re("p77/"),u=re("Bd2K"),o=re("ELLl"),l=re("19Vz"),h=re("lZu9"),L=re("+NIl"),f=re("kSUc"),p=re("9Bee"),D=function(ge){var Re=ge.value,He=Re===void 0?"":Re,st=ge.className,Ze=ge.showTextOnly,mt=ge.showLines,vt=ge.style,Qe=vt===void 0?{}:vt,jt=Object(v.useMemo)(function(){return""},[He]);return y.a.createElement(y.a.Fragment,null,y.a.createElement("div",{dangerouslySetInnerHTML:{__html:jt}}))},S=re("0Owb"),g=re("dejd"),c=re("C+DQ"),d=re("1vsH"),a=re("m3rI"),E=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function b(ge){var Re=ge.onActionCallback,He=ge.title,st=ge.icon,Ze=ge.actionName,mt=ge.className,vt=mt===void 0?"":mt,Qe=ge.children;function jt(){Re(Ze)}return y.a.createElement("a",{title:He,className:vt,onClick:jt},y.a.createElement("i",{className:"md-iconfont ".concat(st)}),Qe)}var T=function(ge){var Re=ge.watch,He=ge.showNullButton,st=ge.onActionCallback,Ze=ge.fullScreen,mt=ge.insertTemp,vt=ge.hidetoolBar,Qe=ge.uuid,jt=ge.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(d.E)("_educoder_session_login"),"&_educoder_session=").concat(Object(d.E)("_educoder_session"),"&key=").concat(Qe,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var At=[].concat(E,[{title:"".concat(Re?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(Re?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return y.a.createElement("ul",{className:"markdown-toolbar-container"},!vt&&At.map(function(Nt,Ht){return y.a.createElement("li",{key:Ht},Nt.actionName?y.a.createElement(b,Object(S.a)({},Nt,{onActionCallback:st})):y.a.createElement("span",{className:"v-line"}))}),He?y.a.createElement("li",null,y.a.createElement(b,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:st},y.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,mt&&y.a.createElement("li",null,y.a.createElement(b,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(mt),onActionCallback:st},y.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),y.a.createElement("li",{className:"btn-full-screen"},y.a.createElement(b,{icon:"".concat(Ze?"icon-shrink":"icon-enlarge"),title:Ze?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:st})))},P=re("M8RZ"),G=re("+L6B"),Y=re("2/Rp"),Q=re("y8nQ"),z=re("Vl3Y"),j=re("5NDa"),q=re("5rEg"),ae={labelCol:{span:4},wrapperCol:{span:20}},ce=function(ge){var Re=ge.callback,He=ge.onCancel;function st(Ze){Re(Ze)}return y.a.createElement(z.a,Object(S.a)({},ae,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:st}),y.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},y.a.createElement(q.a,null)),y.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},y.a.createElement(q.a,null)),y.a.createElement("div",{className:"flex-container flex-end"},y.a.createElement(Y.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),y.a.createElement(Y.a,{type:"ghost",onClick:He},"\u53D6\u6D88")))},ve=re("7ahc"),ke=re("k1fw"),Ee=re("HmJG"),Ce=re("BjJ7"),Le=z.a.useForm,we={width:280,marginRight:10},me={labelCol:{span:5},wrapperCol:{span:19}},le=function(ge){var Re=ge.callback,He=ge.onCancel,st=Le(),Ze=Object(W.a)(st,1),mt=Ze[0],vt=Object(v.useRef)();function Qe(Nt){Re(Object(ke.a)(Object(ke.a)({},Nt),{},{name:vt.current}))}function jt(Nt,Ht){mt.setFieldsValue({src:"/api/attachments/".concat(Nt.id,"?type=").concat(Nt.content_type),type:Ht.type})}function At(Nt){var Ht=Nt.target.files[0];vt.current=Ht.name,Ye(Ht,jt)}return y.a.createElement(z.a,Object(S.a)({form:mt},me,{className:"upload-image-panel",onFinish:Qe}),y.a.createElement(z.a.Item,{label:"\u6587\u4EF6\u5730\u5740",required:!0},y.a.createElement("div",{className:"flex-container"},y.a.createElement(z.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u6587\u4EF6\u5730\u5740"}]},y.a.createElement(q.a,{style:we})),y.a.createElement(Oe,{onFileChange:At}))),y.a.createElement(z.a.Item,{label:"\u6587\u4EF6\u63CF\u8FF0",name:"alt"},y.a.createElement(q.a,{style:{width:264}})),y.a.createElement(z.a.Item,{style:{textAlign:"right"}},y.a.createElement(Y.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),y.a.createElement(Y.a,{type:"ghost",onClick:He},"\u53D6\u6D88")))};function Oe(ge){var Re=ge.onFileChange;return y.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",y.a.createElement("input",{type:"file",onChange:Re}))}function Ye(ge,Re){if(!ge)throw new String("\u6CA1\u6709\u6587\u4EF6");var He=new FormData;He.append("editormd-image-file",ge),He.append("file_param_name","editormd-image-file"),He.append("byxhr","true");var st=new window.XMLHttpRequest;st.withCredentials=!0,st.addEventListener("load",function(Ze){Re(JSON.parse(Ze.target.responseText),ge)},!1),st.addEventListener("error",function(Ze){console.error(Ze)},!1),st.open("POST","".concat(Ce.a,"/api/attachments.json")),st.send(He)}var Ve=re("giR+"),$e=re("fyUT"),ze=re("7Kak"),Se=re("9yH6"),De=Se.a.Group,Ne={margin:"0 8px"},Ge=function(ge){var Re=ge.callback,He=ge.onCancel;function st(Ze){Re(Ze)}return y.a.createElement(z.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:st},y.a.createElement("div",{className:"flex-container"},y.a.createElement("span",{style:Ne},"\u5355\u5143\u683C\u6570\uFF1A"),y.a.createElement("span",{style:Ne},"\u884C\u6570"),y.a.createElement(z.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},y.a.createElement($e.a,null)),y.a.createElement("span",{style:Ne},"\u5217\u6570"),y.a.createElement(z.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},y.a.createElement($e.a,null))),y.a.createElement("div",{className:"flex-container",style:{marginTop:12}},y.a.createElement("span",{style:Ne},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),y.a.createElement(z.a.Item,{name:"align"},y.a.createElement(De,null,y.a.createElement(Se.a,{value:"default"},y.a.createElement("i",{className:"fa fa-align-justify"})),y.a.createElement(Se.a,{value:"left"},y.a.createElement("i",{className:"fa fa-align-left"})),y.a.createElement(Se.a,{value:"center"},y.a.createElement("i",{className:"fa fa-align-center"})),y.a.createElement(Se.a,{value:"right"},y.a.createElement("i",{className:"fa fa-align-right"}))))),y.a.createElement("div",{className:"flex-container flex-end"},y.a.createElement(Y.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),y.a.createElement(Y.a,{type:"ghost",onClick:He},"\u53D6\u6D88")))},je=re("ErOA"),Me=re("7Cbv"),Ie="link",lt="upload-image",tt="code-block",qe="add-table",Xe="------------",ht={default:Xe,left:":".concat(Xe),center:":".concat(Xe,":"),right:"".concat(Xe,":")},nt=re("9VGf"),Je,Te;function ut(){}var at=0,Ae=1e4,Ue="\u2581",pe=`
|
|
**\u6A21\u677F\u6807\u9898**
|
|
\u6A21\u677F\u6B63\u6587\u5185\u5BB9\uFF0C\u53EF\u8F93\u5165\u6587\u672C\u5185\u5BB9\u548C\u7C98\u8D34\u56FE\u7247\u7B49\u64CD\u4F5C`;function ue(ge){return/^\d+$/.test(ge)?"".concat(ge,"px"):ge}var fe=navigator.platform.toUpperCase().indexOf("MAC")>=0,ee=fe?"Cmd":"Ctrl",te=["pptm","pptx","ppt","pot","pps","ppa","potx","ppsx","ppam","pptm","potm","ppsm","doc","docx","dot","dotx","docm","dotm","xls","xlsx","csv","xlt","xla","xltx","xlsm","xltm","xlam","xlsb"],ie=(Je={},Object(F.a)(Je,ee+"-B","bold"),Object(F.a)(Je,ee+"-I","italic"),Je),ne=(Te={},Object(F.a)(Te,Ie,"\u6DFB\u52A0\u94FE\u63A5"),Object(F.a)(Te,tt,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(F.a)(Te,lt,"\u6DFB\u52A0\u6587\u4EF6"),Object(F.a)(Te,qe,"\u6DFB\u52A0\u8868\u683C"),Te),be=ot.a=function(ge){var Re=ge.defaultValue,He=Re===void 0?"":Re,st=ge.onChange,Ze=ge.width,mt=Ze===void 0?"100%":Ze,vt=ge.height,Qe=vt===void 0?400:vt,jt=ge.miniToolbar,At=jt===void 0?!1:jt,Nt=ge.isFocus,Ht=Nt===void 0?!1:Nt,Dt=ge.watch,Tr=ge.insertTemp,Zr=ge.mode,yt=Zr===void 0?"markdown":Zr,wr=ge.id,tr=wr===void 0?"markdown-editor-id":wr,lr=ge.showResizeBar,Bt=lr===void 0?!1:lr,Qt=ge.noStorage,Kt=Qt===void 0?!1:Qt,Tt=ge.showNullButton,pt=Tt===void 0?!1:Tt,ur=ge.hidetoolBar,Lr=ur===void 0?!1:ur,Ar=ge.fullScreen,Rt=Ar===void 0?!1:Ar,jr=ge.onBlur,Jr=ge.onCMBeforeChange,ui=ge.onFullScreen,We=ge.className,wt=We===void 0?"":We,di=ge.disablePaste,Ai=di===void 0?!1:di,hi=ge.placeholder,Di=hi===void 0?"":hi,H=ge.values,s=H===void 0?"":H,m=Object(v.useState)(null),B=Object(W.a)(m,2),K=B[0],U=B[1],he=Object(v.useState)(He),Pe=Object(W.a)(he,2),et=Pe[0],ct=Pe[1],Be=Object(v.useState)(Dt),Ct=Object(W.a)(Be,2),Ot=Ct[0],Yt=Ct[1],Wr=Object(v.useState)(Rt),Hr=Object(W.a)(Wr,2),dr=Hr[0],Xr=Hr[1],Hi=Object(v.useState)(""),Dr=Object(W.a)(Hi,2),Gr=Dr[0],Nr=Dr[1],gi=Object(v.useState)(0),Qr=Object(W.a)(gi,2),ci=Qr[0],ni=Qr[1],hn=Object(v.useState)(Qe),Gi=Object(W.a)(hn,2),qr=Gi[0],zr=Gi[1],_i=Object(v.useState)(!1),Ri=Object(W.a)(_i,2),cn=Ri[0],qt=Ri[1],Ut=Object(v.useRef)(Object(Me.a)()),vr=Object(v.useRef)(!1),It=Object(v.useRef)(),nr=Object(v.useRef)(),Gt=Object(v.useRef)(),ai=Object(v.useRef)(),rr=Object(v.useRef)(),_r=function(){var gt=Object(I.a)(k.a.mark(function Lt(){var xt,kt;return k.a.wrap(function(Vt){for(;;)switch(Vt.prev=Vt.next){case 0:return Vt.next=2,Object(je.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Ut.current}});case 2:kt=Vt.sent,kt!=null&&(xt=kt.attachments)!==null&&xt!==void 0&&xt.length&&(console.log("cm:",K,nr),kt.attachments.map(function(Pt){Pt.content_type.indexOf("image")>-1?K.replaceSelection(".concat(Pt.content_type,")")):Pt.content_type.indexOf("video")>-1?K.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Pt.content_type.indexOf("pdf")>-1?K.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Pt.id,"?type=").concat(Pt.content_type,'&disposition=inline" target="_blank">').concat(Pt.name,"</a>")):K.replaceSelection("[".concat(Pt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Pt.id,"?type=").concat(Pt.content_type,")"))}));case 4:case"end":return Vt.stop()}},Lt)}));return function(){return gt.apply(this,arguments)}}();Object(v.useEffect)(function(){ct(s),K==null||K.setValue(s)},[s]),Object(v.useEffect)(function(){ui==null||ui(dr)},[dr]),Object(v.useEffect)(function(){if(nr.current){var gt=A.a.fromTextArea(nr.current,{mode:yt,lineNumbers:!At,lineWrapping:!0,value:He,autoCloseTags:!0,autoCloseBrackets:!0});Ht&>.focus();function Lt(xt,kt){if(Ai){kt.preventDefault();return}var Ft=kt.clipboardData;if(Ft){var Vt=Ft.types.toString(),Pt=Ft.items;if(Vt==="Files"||Ft.types.indexOf("Files")>-1){if(kt.preventDefault(),yt=="stex")return;try{var ar,Rr=Pt[1];((ar=Pt[0])===null||ar===void 0?void 0:ar.kind)==="file"&&(Rr=Pt[0]);var Mt=Rr.getAsFile(),yi=Mt.name.split(".").pop();Ye(Mt,function(Wt){if(Wt.id){var cr,Yr,$r;(Mt==null||((cr=Mt.type)===null||cr===void 0)?void 0:cr.indexOf("image"))>-1?gt.replaceSelection(".concat(Wt.content_type,")")):(Mt==null||((Yr=Mt.type)===null||Yr===void 0)?void 0:Yr.indexOf("video"))>-1?gt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'"></video>')):(Mt==null||(($r=Mt.type)===null||$r===void 0)?void 0:$r.indexOf("pdf"))>-1?gt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Mt.type,'&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):te.includes(yi)?gt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'?type=office&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):gt.replaceSelection("[".concat(Mt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Wt.content_type,")"))}else(Wt==null?void 0:Wt.status)===401&&(document.location.href="/user/login")})}catch(Wt){O.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return gt.on("paste",Lt),gt.on("dragleave",function(xt,kt){Gt.current.classList.remove("mouse-hover-md")}),gt.on("dragover",function(xt,kt){Gt.current.classList.add("mouse-hover-md")}),gt.on("drop",function(xt,kt){Gt.current.classList.add("mouse-hover-md");var Ft;if(Ft=kt.dataTransfer.files,Ft.length>0){kt.preventDefault(),kt.stopPropagation();for(var Vt=function(Rr){var Mt=Ft[Rr],yi=Mt.name.split(".").pop();Ye(Mt,function(Wt){if(Wt.id){var cr,Yr,$r;(Mt==null||((cr=Mt.type)===null||cr===void 0)?void 0:cr.indexOf("image"))>-1?gt.replaceSelection(".concat(Wt.content_type,")")):(Mt==null||((Yr=Mt.type)===null||Yr===void 0)?void 0:Yr.indexOf("video"))>-1?gt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'"></video>')):(Mt==null||(($r=Mt.type)===null||$r===void 0)?void 0:$r.indexOf("pdf"))>-1?gt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Mt.type,'&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):te.includes(yi)?gt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'?type=office&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):gt.replaceSelection("[".concat(Mt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Wt.content_type,")"))}else(Wt==null?void 0:Wt.status)===401&&(document.location.href="/user/login")})},Pt=0;Pt<Ft.length;Pt++)Vt(Pt)}}),U(gt),function(){gt.off("paste",Lt)}}},[]);var zi=Object(v.useCallback)(function(){if(Gt.current)try{}catch(gt){console.log(gt,"---- to set md editor body height")}},[qr,Gt,dr]);Object(v.useEffect)(function(){function gt(){var xt=new x.default(function(kt){var Ft=Object(_.a)(kt),Vt;try{for(Ft.s();!(Vt=Ft.n()).done;){var Pt=Vt.value;(Pt.target.offsetHeight>0||Pt.target.offsetWidth>0)&&(zi(),K.setSize("100%","100%"),K.refresh())}}catch(ar){Ft.e(ar)}finally{Ft.f()}});return xt.observe(nr.current.parentElement),xt}if(K){var Lt=gt();return function(){Lt.unobserve(nr.current.parentElement)}}},[K,zi]),Object(v.useEffect)(function(){if(K){for(var gt=[],Lt=function(){var Pt=kt[xt];Ft=Object(W.a)(Pt,2);var ar=Ft[0],Rr=Ft[1],Mt=Object(F.a)({},ar,function(){Ki(Rr)});gt.push(Mt),K.addKeyMap(Mt)},xt=0,kt=Object.entries(ie);xt<kt.length;xt++){var Ft;Lt()}return It.current=setInterval(function(){vr.current&&_r()},4e3),function(){clearInterval(It.current);var Vt=Object(_.a)(gt),Pt;try{for(Vt.s();!(Pt=Vt.n()).done;){var ar=Pt.value;K.removeKeyMap(ar)}}catch(Rr){Vt.e(Rr)}finally{Vt.f()}}}},[K]),Object(v.useEffect)(function(){Rt!==dr&&Xr(Rt)},[Rt]),Object(nt.a)(function(){if(!Kt&&ci>0){var gt=new Date().getTime(),Lt=window.sessionStorage.getItem(tr);gt>=ci+Ae&&(!Lt||Lt!==et)&&(window.sessionStorage.setItem(tr,et),qt(!0))}},Ae),Object(v.useEffect)(function(){Yt(Dt)},[K,Dt]),Object(v.useEffect)(function(){K&&(Ht&&K.focus())},[K,Ht]),Object(v.useEffect)(function(){if(Ot&&K){var gt=K.getScrollerElement();function Lt(xt){var kt=xt.target;if(rr.current){var Ft=kt.scrollTop/kt.scrollHeight;rr.current.scrollTop=rr.current.scrollHeight*Ft}}return gt.addEventListener("scroll",Lt),function(){gt.removeEventListener("scroll",Lt)}}},[K,Ot]),Object(v.useEffect)(function(){if(K&&Jr){function gt(Lt,xt){Jr(Lt,xt)}return K.on("beforeChange",gt),function(){K.off("beforeChange",gt)}}},[K,Jr]),Object(v.useEffect)(function(){if(K&&jr){function gt(){jr(K.getValue())}return K.on("blur",gt),function(){K.off("blur",gt)}}},[K,jr]),Object(v.useEffect)(function(){if(K){function gt(Lt){var xt=Lt.getValue();ct(xt),ni(new Date().getTime()),Lt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),st&&st(xt)}return K.on("change",gt),function(){K.off("change",gt)}}},[K,st]),Object(v.useEffect)(function(){K&&(He==null?(K.setValue(""),ct("")):He!==K.getValue()&&(K.setValue(He),ct(He),K.setCursor(K.lineCount(),0)))},[K,He]);var Ki=Object(v.useCallback)(function(gt){var Lt=K.getCursor(),xt=K.getSelection(),kt=xt.split(`
|
|
`);switch(gt){case"bold":return K.replaceSelection("**"+xt+"**"),xt===""&&K.setCursor(Lt.line,Lt.ch+2),K.focus();case"italic":return K.replaceSelection("*"+xt+"*"),xt===""&&K.setCursor(Lt.line,Lt.ch+1),K.focus();case"code":return K.replaceSelection("`"+xt+"`"),xt===""&&K.setCursor(Lt.line,Lt.ch+1),K.focus();case"inline-latex":return K.replaceSelection("`$$"+xt+"$$`"),xt===""&&K.setCursor(Lt.line,Lt.ch+3),K.focus();case"latex":return K.replaceSelection("```latex\n"+xt+"\n```"),K.setCursor(Lt.line+1,xt.length+1),K.focus();case"line-break":return K.replaceSelection(`<br/>
|
|
`),K.focus();case"list-ul":return xt===""?K.replaceSelection("- "+xt):K.replaceSelection(kt.map(function(Ft){return Ft===""?"":"- ".concat(Ft)}).join(`
|
|
`)),K.focus();case"list-ol":return xt===""?K.replaceSelection("1. "+xt):K.replaceSelection(kt.map(function(Ft,Vt){return Ft===""?"":"".concat(Vt+1,". ").concat(Ft)}).join(`
|
|
`)),K.focus();case"add-null-ch":return xt===""&&K.setCursor(Lt.line,Lt.ch+1),K.replaceSelection(Ue),K.focus();case"inster-template-1":return xt===""&&K.setCursor(Lt.line,Lt.ch),K.replaceSelection(pe),K.focus();case"eraser":return K.setValue(""),K.focus();case"trigger-watch":return Yt(!Ot),K.focus();case"trigger-full-screen":return Xr(!dr),K.focus();case Ie:Nr(Ie);return;case tt:Nr(tt);return;case lt:Nr(lt);return;case qe:Nr(qe);return;default:throw new Error}},[K,Ot,dr]),vi=Object(v.useCallback)(function(gt){Nr("");switch(Gr){case Ie:var Lt=gt.title,xt=gt.link;return K.replaceSelection("[".concat(Lt,"](").concat(xt,")")),K.focus();case tt:var kt=gt.language,Ft=gt.content;return K.replaceSelection(["```"+kt,Ft,"```"].join(`
|
|
`)),K.focus();case lt:var Vt=gt.src,Pt=gt.alt,ar=gt.name;return Vt.indexOf("type=image")>-1?K.replaceSelection(".concat(Vt,' "').concat(Pt||"",'" )')):Vt.indexOf("type=application/pdf")>-1?K.replaceSelection('<a href="'.concat(Vt,'&disposition=inline" target="_blank">').concat(ar,"</a>")):K.replaceSelection('<a href="'.concat(Vt,'" target="_blank">').concat(ar,"</a>")),K.focus();case qe:for(var Rr=gt.row,Mt=gt.col,yi=gt.align,Wt=`
|
|
`,cr=0;cr<Rr;cr++){for(var Yr=[],$r=[],Wn=0;Wn<Mt;Wn++)cr===1&&$r.push(ht[yi]),Yr.push(" ");cr===1&&(Wt+="| ".concat($r.join(" | "),` |
|
|
`)),Wt+="| ".concat(Yr.join(Mt===1?"":" | "),` |
|
|
`)}return K.replaceSelection(Wt+`
|
|
`),K.focus();default:throw new Error}},[K,Gr]),Fn=Object(v.useMemo)(function(){switch(Gr){case Ie:return y.a.createElement(ce,{callback:vi,onCancel:Br});case tt:return y.a.createElement(ve.b,{callback:vi,onCancel:Br});case lt:return y.a.createElement(le,{callback:vi,onCancel:Br});case qe:return y.a.createElement(Ge,{callback:vi,onCancel:Br});default:return null}},[Gr]);function Br(){Nr("")}Object(v.useEffect)(function(){if(ai.current){var gt=ai.current,Lt=!1,xt=0;function kt(Pt){Lt=!0,xt=Pt.pageY}function Ft(){Lt=!1}function Vt(Pt){if(Lt){var ar=Pt.pageY-xt;ar<0&&(ar=0),ar>300&&(ar=300);var Rr=Qe+ar+"px";zr(Rr)}}return gt.addEventListener("mousedown",kt),document.addEventListener("mousemove",Vt),document.addEventListener("mouseup",Ft),function(){gt.removeEventListener("mousedown",kt),document.removeEventListener("mousemove",Vt),document.removeEventListener("mouseup",Ft)}}},[K,ai]),Object(v.useEffect)(function(){zr(Qe)},[Qe]);var fn=ue(mt),ei=ue(qr),Vi={width:fn,height:ei},jn=Object(v.useMemo)(function(){if(ci){var gt=new Date(ci),Lt=gt.getHours(),xt=gt.getMinutes(),kt=gt.getSeconds();return Lt=Lt<10?"0"+Lt:Lt,xt=xt<10?"0"+xt:xt,kt=kt<10?"0"+kt:kt,"".concat(Lt,":").concat(xt,":").concat(kt)}return 0},[ci]);function ki(){window.sessionStorage.removeItem(tr),qt(!1),ni(0)}function $a(){qt(!1),ni(0),K.setValue(window.sessionStorage.getItem(tr))}function da(gt,Lt){var xt=K.getValue();xt=xt.replace(gt,Lt),ct(xt),K==null||K.setValue(xt)}return y.a.createElement(v.Fragment,null,y.a.createElement("div",{className:"markdown-editor-wrapper",ref:Gt},y.a.createElement("div",{className:"markdown-editor-container ".concat(wt," ").concat(Ot?"on-preview":""," ").concat(At?"mini":""," ").concat(dr?"full-screen":""),style:Vi},y.a.createElement(T,{insertTemp:Tr,watch:Ot,fullScreen:dr,showNullButton:pt,onActionCallback:Ki,hidetoolBar:Lr,uuid:Ut.current,setOpenPhones:function(){vr.current=!0}}),y.a.createElement("div",{className:"markdown-editor-body"},y.a.createElement("div",{className:"codemirror-container"},y.a.createElement("textarea",{ref:nr,placeholder:Di})),Ot?y.a.createElement("div",{ref:rr,className:"preview-container"},yt==="stex"&&y.a.createElement(D,{value:et}),yt!=="stex"&&y.a.createElement(p.a,{edit:!0,value:et,replaces:da})):null))),Bt?y.a.createElement("a",{ref:ai,className:"editor-resize"}):null,y.a.createElement(P.a,null,ne[Gr]?y.a.createElement(Z.a,{centered:!0,title:ne[Gr],visible:!0,onCancel:Br,footer:null},Fn):null))}},RotF:function(Et,ot,re){Et.exports=re("LSTS")},SJMd:function(Et,ot){/**
|
|
* @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 re,oe,Z,_=!1,X,O;window.PR_SHOULD_USE_CONTINUATION=!0;var I,W;(function(){var F=window,M=["break,continue,do,else,for,if,return,while"],k=[M,"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=[k,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],y=[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"],R=[v,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],A=[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"],x="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",C=[v,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],u="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",o=[M,"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"],l=[M,"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"],h=[M,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],L=[y,A,R,C,u,o,l,h],f=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,p="str",D="kwd",S="com",g="typ",c="lit",d="pun",a="pln",E="tag",b="dec",T="src",P="atn",G="atv",Y="nocode",Q="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(Se){for(var De=0,Ne=!1,Ge=!1,je=0,Me=Se.length;je<Me;++je){var Ie=Se[je];if(Ie.ignoreCase)Ge=!0;else if(/[a-z]/i.test(Ie.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Ne=!0,Ge=!1;break}}var lt={b:8,t:9,n:10,v:11,f:12,r:13};function tt(Je){var Te=Je.charCodeAt(0);if(Te!==92)return Te;var ut=Je.charAt(1);return Te=lt[ut],Te||("0"<=ut&&ut<="7"?parseInt(Je.substring(1),8):ut==="u"||ut==="x"?parseInt(Je.substring(2),16):Je.charCodeAt(1))}function qe(Je){if(Je<32)return(Je<16?"\\x0":"\\x")+Je.toString(16);var Te=String.fromCharCode(Je);return Te==="\\"||Te==="-"||Te==="]"||Te==="^"?"\\"+Te:Te}function Xe(Je){var Te=Je.substring(1,Je.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")),ut=[],at=Te[0]==="^",Ae=["["];at&&Ae.push("^");for(var Ue=at?1:0,pe=Te.length;Ue<pe;++Ue){var ue=Te[Ue];if(/\\[bdsw]/i.test(ue))Ae.push(ue);else{var fe=tt(ue),ee;Ue+2<pe&&Te[Ue+1]==="-"?(ee=tt(Te[Ue+2]),Ue+=2):ee=fe,ut.push([fe,ee]),ee<65||fe>122||(ee<65||fe>90||ut.push([Math.max(65,fe)|32,Math.min(ee,90)|32]),ee<97||fe>122||ut.push([Math.max(97,fe)&~32,Math.min(ee,122)&~32]))}}ut.sort(function(be,ge){return be[0]-ge[0]||ge[1]-be[1]});for(var te=[],ie=[],Ue=0;Ue<ut.length;++Ue){var ne=ut[Ue];ne[0]<=ie[1]+1?ie[1]=Math.max(ie[1],ne[1]):te.push(ie=ne)}for(var Ue=0;Ue<te.length;++Ue){var ne=te[Ue];Ae.push(qe(ne[0])),ne[1]>ne[0]&&(ne[1]+1>ne[0]&&Ae.push("-"),Ae.push(qe(ne[1])))}return Ae.push("]"),Ae.join("")}function ht(Je){for(var Te=Je.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")),ut=Te.length,at=[],Ae=0,Ue=0;Ae<ut;++Ae){var pe=Te[Ae];if(pe==="(")++Ue;else if(pe.charAt(0)==="\\"){var ue=+pe.substring(1);ue&&(ue<=Ue?at[ue]=-1:Te[Ae]=qe(ue))}}for(var Ae=1;Ae<at.length;++Ae)at[Ae]===-1&&(at[Ae]=++De);for(var Ae=0,Ue=0;Ae<ut;++Ae){var pe=Te[Ae];if(pe==="(")++Ue,at[Ue]||(Te[Ae]="(?:");else if(pe.charAt(0)==="\\"){var ue=+pe.substring(1);ue&&ue<=Ue&&(Te[Ae]="\\"+at[ue])}}for(var Ae=0;Ae<ut;++Ae)Te[Ae]==="^"&&Te[Ae+1]!=="^"&&(Te[Ae]="");if(Je.ignoreCase&&Ne)for(var Ae=0;Ae<ut;++Ae){var pe=Te[Ae],fe=pe.charAt(0);pe.length>=2&&fe==="["?Te[Ae]=Xe(pe):fe!=="\\"&&(Te[Ae]=pe.replace(/[a-zA-Z]/g,function(ie){var ne=ie.charCodeAt(0);return"["+String.fromCharCode(ne&~32,ne|32)+"]"}))}return Te.join("")}for(var nt=[],je=0,Me=Se.length;je<Me;++je){var Ie=Se[je];if(Ie.global||Ie.multiline)throw new Error(""+Ie);nt.push("(?:"+ht(Ie)+")")}return new RegExp(nt.join("|"),Ge?"gi":"g")}function j(Se,De){var Ne=/(?:^|\s)nocode(?:\s|$)/,Ge=[],je=0,Me=[],Ie=0;function lt(tt){var qe=tt.nodeType;if(qe==1){if(Ne.test(tt.className))return;for(var Xe=tt.firstChild;Xe;Xe=Xe.nextSibling)lt(Xe);var ht=tt.nodeName.toLowerCase();(ht==="br"||ht==="li")&&(Ge[Ie]=`
|
|
`,Me[Ie<<1]=je++,Me[Ie++<<1|1]=tt)}else if(qe==3||qe==4){var nt=tt.nodeValue;nt.length&&(De?nt=nt.replace(/\r\n?/g,`
|
|
`):nt=nt.replace(/[ \t\r\n]+/g," "),Ge[Ie]=nt,Me[Ie<<1]=je,je+=nt.length,Me[Ie++<<1|1]=tt)}}return lt(Se),{sourceCode:Ge.join("").replace(/\n$/,""),spans:Me}}function q(Se,De,Ne,Ge,je){if(!Ne)return;var Me={sourceNode:Se,pre:1,langExtension:null,numberLines:null,sourceCode:Ne,spans:null,basePos:De,decorations:null};Ge(Me),je.push.apply(je,Me.decorations)}var ae=/\S/;function ce(Se){for(var De=void 0,Ne=Se.firstChild;Ne;Ne=Ne.nextSibling){var Ge=Ne.nodeType;De=Ge===1?De?Se:Ne:Ge===3&&ae.test(Ne.nodeValue)?Se:De}return De===Se?void 0:De}function ve(Se,De){var Ne={},Ge;(function(){for(var Ie=Se.concat(De),lt=[],tt={},qe=0,Xe=Ie.length;qe<Xe;++qe){var ht=Ie[qe],nt=ht[3];if(nt)for(var Je=nt.length;--Je>=0;)Ne[nt.charAt(Je)]=ht;var Te=ht[1],ut=""+Te;tt.hasOwnProperty(ut)||(lt.push(Te),tt[ut]=null)}lt.push(/[\0-\uffff]/),Ge=z(lt)})();var je=De.length,Me=function(Ie){for(var lt=Ie.sourceCode,tt=Ie.basePos,qe=Ie.sourceNode,Xe=[tt,a],ht=0,nt=lt.match(Ge)||[],Je={},Te=0,ut=nt.length;Te<ut;++Te){var at=nt[Te],Ae=Je[at],Ue=void 0,pe;if(typeof Ae=="string")pe=!1;else{var ue=Ne[at.charAt(0)];if(ue)Ue=at.match(ue[1]),Ae=ue[0];else{for(var fe=0;fe<je;++fe)if(ue=De[fe],Ue=at.match(ue[1]),Ue){Ae=ue[0];break}Ue||(Ae=a)}pe=Ae.length>=5&&Ae.substring(0,5)==="lang-",pe&&!(Ue&&typeof Ue[1]=="string")&&(pe=!1,Ae=T),pe||(Je[at]=Ae)}var ee=ht;if(ht+=at.length,!pe)Xe.push(tt+ee,Ae);else{var te=Ue[1],ie=at.indexOf(te),ne=ie+te.length;Ue[2]&&(ne=at.length-Ue[2].length,ie=ne-te.length);var be=Ae.substring(5);q(qe,tt+ee,at.substring(0,ie),Me,Xe),q(qe,tt+ee+ie,te,le(be,te),Xe),q(qe,tt+ee+ne,at.substring(ne),Me,Xe)}}Ie.decorations=Xe};return Me}function ke(Se){var De=[],Ne=[];Se.tripleQuotedStrings?De.push([p,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Se.multiLineStrings?De.push([p,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):De.push([p,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Se.verbatimStrings&&Ne.push([p,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Ge=Se.hashComments;Ge&&(Se.cStyleComments?(Ge>1?De.push([S,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):De.push([S,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Ne.push([p,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):De.push([S,/^#[^\r\n]*/,null,"#"])),Se.cStyleComments&&(Ne.push([S,/^\/\/[^\r\n]*/,null]),Ne.push([S,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var je=Se.regexLiterals;if(je){var Me=je>1?"":`
|
|
\r`,Ie=Me?".":"[\\S\\s]",lt="/(?=[^/*"+Me+"])(?:[^/\\x5B\\x5C"+Me+"]|\\x5C"+Ie+"|\\x5B(?:[^\\x5C\\x5D"+Me+"]|\\x5C"+Ie+")*(?:\\x5D|$))+/";Ne.push(["lang-regex",RegExp("^"+Q+"("+lt+")")])}var tt=Se.types;tt&&Ne.push([g,tt]);var qe=(""+Se.keywords).replace(/^ | $/g,"");qe.length&&Ne.push([D,new RegExp("^(?:"+qe.replace(/[\s,]+/g,"|")+")\\b"),null]),De.push([a,/^\s+/,null,` \r
|
|
\xA0`]);var Xe="^.[^\\s\\w.$@'\"`/\\\\]*";return Se.regexLiterals&&(Xe+="(?!s*/)"),Ne.push([c,/^@[a-z_$][a-z_$@0-9]*/i,null],[g,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[c,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[d,new RegExp(Xe),null]),ve(De,Ne)}var Ee=ke({keywords:L,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Ce(Se,De,Ne){for(var Ge=/(?:^|\s)nocode(?:\s|$)/,je=/\r\n?|\n/,Me=Se.ownerDocument,Ie=Me.createElement("li");Se.firstChild;)Ie.appendChild(Se.firstChild);var lt=[Ie];function tt(Te){var ut=Te.nodeType;if(ut==1&&!Ge.test(Te.className))if(Te.nodeName==="br")qe(Te),Te.parentNode&&Te.parentNode.removeChild(Te);else for(var at=Te.firstChild;at;at=at.nextSibling)tt(at);else if((ut==3||ut==4)&&Ne){var Ae=Te.nodeValue,Ue=Ae.match(je);if(Ue){var pe=Ae.substring(0,Ue.index);Te.nodeValue=pe;var ue=Ae.substring(Ue.index+Ue[0].length);if(ue){var fe=Te.parentNode;fe.insertBefore(Me.createTextNode(ue),Te.nextSibling)}qe(Te),pe||Te.parentNode.removeChild(Te)}}}function qe(Te){for(;!Te.nextSibling;)if(Te=Te.parentNode,!Te)return;function ut(Ue,pe){var ue=pe?Ue.cloneNode(!1):Ue,fe=Ue.parentNode;if(fe){var ee=ut(fe,1),te=Ue.nextSibling;ee.appendChild(ue);for(var ie=te;ie;ie=te)te=ie.nextSibling,ee.appendChild(ie)}return ue}for(var at=ut(Te.nextSibling,0),Ae;(Ae=at.parentNode)&&Ae.nodeType===1;)at=Ae;lt.push(at)}for(var Xe=0;Xe<lt.length;++Xe)tt(lt[Xe]);De===(De|0)&<[0].setAttribute("value",De);var ht=Me.createElement("ol");ht.className="linenums";for(var nt=Math.max(0,De-1|0)||0,Xe=0,Je=lt.length;Xe<Je;++Xe)Ie=lt[Xe],Ie.className="L"+(Xe+nt)%10,Ie.firstChild||Ie.appendChild(Me.createTextNode("\xA0")),ht.appendChild(Ie);Se.appendChild(ht)}function Le(Se){var De=/\bMSIE\s(\d+)/.exec(navigator.userAgent);De=De&&+De[1]<=8;var Ne=/\n/g,Ge=Se.sourceCode,je=Ge.length,Me=0,Ie=Se.spans,lt=Ie.length,tt=0,qe=Se.decorations,Xe=qe.length,ht=0;qe[Xe]=je;var nt,Je;for(Je=nt=0;Je<Xe;)qe[Je]!==qe[Je+2]?(qe[nt++]=qe[Je++],qe[nt++]=qe[Je++]):Je+=2;for(Xe=nt,Je=nt=0;Je<Xe;){for(var Te=qe[Je],ut=qe[Je+1],at=Je+2;at+2<=Xe&&qe[at+1]===ut;)at+=2;qe[nt++]=Te,qe[nt++]=ut,Je=at}Xe=qe.length=nt;var Ae=Se.sourceNode,Ue="";Ae&&(Ue=Ae.style.display,Ae.style.display="none");try{for(var pe=null;tt<lt;){var ue=Ie[tt],fe=Ie[tt+2]||je,ee=qe[ht+2]||je,at=Math.min(fe,ee),te=Ie[tt+1],ie;if(te.nodeType!==1&&(ie=Ge.substring(Me,at))){De&&(ie=ie.replace(Ne,"\r")),te.nodeValue=ie;var ne=te.ownerDocument,be=ne.createElement("span");be.className=qe[ht+1];var ge=te.parentNode;ge.replaceChild(be,te),be.appendChild(te),Me<fe&&(Ie[tt+1]=te=ne.createTextNode(Ge.substring(at,fe)),ge.insertBefore(te,be.nextSibling))}Me=at,Me>=fe&&(tt+=2),Me>=ee&&(ht+=2)}}finally{Ae&&(Ae.style.display=Ue)}}var we={};function me(Se,De){for(var Ne=De.length;--Ne>=0;){var Ge=De[Ne];we.hasOwnProperty(Ge)?F.console&&console.warn("cannot override language handler %s",Ge):we[Ge]=Se}}function le(Se,De){return Se&&we.hasOwnProperty(Se)||(Se=/^\s*</.test(De)?"default-markup":"default-code"),we[Se]}me(Ee,["default-code"]),me(ve([],[[a,/^[^<?]+/],[b,/^<!\w[^>]*(?:>|$)/],[S,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[d,/^(?:<[%?]|[%?]>)/],["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"]),me(ve([[a,/^[\s]+/,null,` \r
|
|
`],[G,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[E,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[d,/^[=<>\/]+/],["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"]),me(ve([],[[G,/^[\s\S]+/]]),["uq.val"]),me(ke({keywords:y,hashComments:!0,cStyleComments:!0,types:f}),["c","cc","cpp","cxx","cyc","m"]),me(ke({keywords:"null,true,false"}),["json"]),me(ke({keywords:A,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:f}),["cs"]),me(ke({keywords:R,cStyleComments:!0}),["java"]),me(ke({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),me(ke({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),me(ke({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),me(ke({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),me(ke({keywords:C,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),me(ke({keywords:x,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),me(ve([],[[p,/^[\s\S]+/]]),["regex"]);function Oe(Se){var De=Se.langExtension;try{var Ne=j(Se.sourceNode,Se.pre),Ge=Ne.sourceCode;Se.sourceCode=Ge,Se.spans=Ne.spans,Se.basePos=0,le(De,Ge)(Se),Le(Se)}catch(je){F.console&&console.log(je&&je.stack||je)}}function Ye(Se,De,Ne){var Ge=Ne||!1,je=De||null,Me=document.createElement("div");Me.innerHTML="<pre>"+Se+"</pre>",Me=Me.firstChild,Ge&&Ce(Me,Ge,!0);var Ie={langExtension:je,numberLines:Ge,sourceNode:Me,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return Oe(Ie),Me.innerHTML}function Ve(Se,De){var Ne=De||document.body,Ge=Ne.ownerDocument||document;function je(ue){return Ne.getElementsByTagName(ue)}for(var Me=[je("pre"),je("code"),je("xmp")],Ie=[],lt=0;lt<Me.length;++lt)for(var tt=0,qe=Me[lt].length;tt<qe;++tt)Ie.push(Me[lt][tt]);Me=null;var Xe=Date;Xe.now||(Xe={now:function(){return+new Date}});var ht=0,nt=/\blang(?:uage)?-([\w.]+)(?!\S)/,Je=/\bprettyprint\b/,Te=/\bprettyprinted\b/,ut=/pre|xmp/i,at=/^code$/i,Ae=/^(?:pre|code|xmp)$/i,Ue={};function pe(){for(var ue=F.PR_SHOULD_USE_CONTINUATION?Xe.now()+250:Infinity;ht<Ie.length&&Xe.now()<ue;ht++){for(var fe=Ie[ht],ee=Ue,te=fe;te=te.previousSibling;){var ie=te.nodeType,ne=(ie===7||ie===8)&&te.nodeValue;if(ne?!/^\??prettify\b/.test(ne):ie!==3||/\S/.test(te.nodeValue))break;if(ne){ee={},ne.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Ht,Dt,Tr){ee[Dt]=Tr});break}}var be=fe.className;if((ee!==Ue||Je.test(be))&&!Te.test(be)){for(var ge=!1,Re=fe.parentNode;Re;Re=Re.parentNode){var He=Re.tagName;if(Ae.test(He)&&Re.className&&Je.test(Re.className)){ge=!0;break}}if(!ge){fe.className+=" prettyprinted";var st=ee.lang;if(!st){st=be.match(nt);var Ze;!st&&(Ze=ce(fe))&&at.test(Ze.tagName)&&(st=Ze.className.match(nt)),st&&(st=st[1])}var mt;if(ut.test(fe.tagName))mt=1;else{var vt=fe.currentStyle,Qe=Ge.defaultView,jt=vt?vt.whiteSpace:Qe&&Qe.getComputedStyle?Qe.getComputedStyle(fe,null).getPropertyValue("white-space"):0;mt=jt&&jt.substring(0,3)==="pre"}var At=ee.linenums;(At=At==="true"||+At)||(At=be.match(/\blinenums\b(?::(\d+))?/),At=At?At[1]&&At[1].length?+At[1]:!0:!1),At&&Ce(fe,At,mt);var Nt={langExtension:st,sourceNode:fe,numberLines:At,pre:mt,sourceCode:null,basePos:null,spans:null,decorations:null};Oe(Nt)}}}ht<Ie.length?F.setTimeout(pe,250):typeof Se=="function"&&Se()}pe()}var $e=F.PR={createSimpleLexer:ve,registerLangHandler:me,sourceDecorator:ke,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:G,PR_COMMENT:S,PR_DECLARATION:b,PR_KEYWORD:D,PR_LITERAL:c,PR_NOCODE:Y,PR_PLAIN:a,PR_PUNCTUATION:d,PR_SOURCE:T,PR_STRING:p,PR_TAG:E,PR_TYPE:g,prettyPrintOne:_?F.prettyPrintOne=Ye:I=Ye,prettyPrint:W=_?F.prettyPrint=Ve:W=Ve},ze=F.define;typeof ze=="function"&&ze.amd&&ze("google-code-prettify",[],function(){return $e})})()},SbmS:function(Et,ot,re){Et.exports={flex_box_center:"flex_box_center___HG_ui",flex_space_between:"flex_space_between___i7dgQ",flex_box_vertical_center:"flex_box_vertical_center___25J9O",flex_box_center_end:"flex_box_center_end___Q7-xc",flex_box_column:"flex_box_column___2Q6GJ",userInfo:"userInfo___2ECUY",navInfo:"navInfo___3H3dt",actived:"actived___ilDpa",topBar:"topBar___2O4NK",tabs:"tabs___yp4Rb",active:"active___3Xgtk",list:"list___U4GMG",tags:"tags___2IWIk",searchWrp:"searchWrp___1-W5t",listMessage:"listMessage___1M4jE",deleteMsg:"deleteMsg___1HDtB",listRightMessage:"listRightMessage___1rCRK",content:"content___KsZrb",msg:"msg___35IM3",msgDate:"msgDate___ovoCe"}},UZu5:function(Et,ot,re){},"VrN/":function(Et,ot,re){(function(oe,Z){Et.exports=Z()})(this,function(){"use strict";var oe=navigator.userAgent,Z=navigator.platform,_=/gecko\/\d/i.test(oe),X=/MSIE \d/.test(oe),O=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(oe),I=/Edge\/(\d+)/.exec(oe),W=X||O||I,F=W&&(X?document.documentMode||6:+(I||O)[1]),M=!I&&/WebKit\//.test(oe),k=M&&/Qt\/\d+\.\d+/.test(oe),v=!I&&/Chrome\//.test(oe),y=/Opera\//.test(oe),R=/Apple Computer/.test(navigator.vendor),A=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(oe),x=/PhantomJS/.test(oe),C=!I&&/AppleWebKit/.test(oe)&&/Mobile\/\w+/.test(oe),u=/Android/.test(oe),o=C||u||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(oe),l=C||/Mac/.test(Z),h=/\bCrOS\b/.test(oe),L=/win/i.test(Z),f=y&&oe.match(/Version\/(\d*\.\d*)/);f&&(f=Number(f[1])),f&&f>=15&&(y=!1,M=!0);var p=l&&(k||y&&(f==null||f<12.11)),D=_||W&&F>=9;function S(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var g=function(e,t){var i=e.className,r=S(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function c(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function d(e,t){return c(e).appendChild(t)}function a(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var w=0;w<t.length;++w)n.appendChild(t[w]);return n}function E(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var b;document.createRange?b=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:b=function(e,t,i){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(n){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};function T(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function P(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function G(e,t){var i=e.className;S(t).test(i)||(e.className+=(i?" ":"")+t)}function Y(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!S(i[r]).test(t)&&(t+=" "+i[r]);return t}var Q=function(e){e.select()};C?Q=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:W&&(Q=function(e){try{e.select()}catch(t){}});function z(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function j(e,t,i){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function q(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var w=r||0,N=n||0;;){var V=e.indexOf(" ",w);if(V<0||V>=t)return N+(t-w);N+=V-w,N+=i-N%i,w=V+1}}var ae=function(){this.id=null,this.f=null,this.time=0,this.handler=z(this.onTimeout,this)};ae.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},ae.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=i)};function ce(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var ve=50,ke={toString:function(){return"CodeMirror.Pass"}},Ee={scroll:!1},Ce={origin:"*mouse"},Le={origin:"+move"};function we(e,t,i){for(var r=0,n=0;;){var w=e.indexOf(" ",r);w==-1&&(w=e.length);var N=w-r;if(w==e.length||n+N>=t)return r+Math.min(N,t-n);if(n+=w-r,n+=i-n%i,r=w+1,n>=t)return r}}var me=[""];function le(e){for(;me.length<=e;)me.push(Oe(me)+" ");return me[e]}function Oe(e){return e[e.length-1]}function Ye(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function Ve(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function $e(){}function ze(e,t){var i;return Object.create?i=Object.create(e):($e.prototype=e,i=new $e),t&&j(t,i),i}var Se=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function De(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Se.test(e))}function Ne(e,t){return t?t.source.indexOf("\\w")>-1&&De(e)?!0:t.test(e):De(e)}function Ge(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var je=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function Me(e){return e.charCodeAt(0)>=768&&je.test(e)}function Ie(e,t,i){for(;(i<0?t>0:t<e.length)&&Me(e.charAt(t));)t+=i;return t}function lt(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,w=r<0?Math.ceil(n):Math.floor(n);if(w==t)return e(w)?t:i;e(w)?i=w:t=w+r}}function tt(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,w=0;w<e.length;++w){var N=e[w];(N.from<i&&N.to>t||t==i&&N.to==t)&&(r(Math.max(N.from,t),Math.min(N.to,i),N.level==1?"rtl":"ltr",w),n=!0)}n||r(t,i,"ltr")}var qe=null;function Xe(e,t,i){var r;qe=null;for(var n=0;n<e.length;++n){var w=e[n];if(w.from<t&&w.to>t)return n;w.to==t&&(w.from!=w.to&&i=="before"?r=n:qe=n),w.from==t&&(w.from!=w.to&&i!="before"?r=n:qe=n)}return r!=null?r:qe}var ht=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(J){return J<=247?e.charAt(J):1424<=J&&J<=1524?"R":1536<=J&&J<=1785?t.charAt(J-1536):1774<=J&&J<=2220?"r":8192<=J&&J<=8203?"w":J==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,w=/[LRr]/,N=/[Lb1n]/,V=/[1n]/;function $(J,se,de){this.level=J,this.from=se,this.to=de}return function(J,se){var de=se=="ltr"?"L":"R";if(J.length==0||se=="ltr"&&!r.test(J))return!1;for(var xe=J.length,ye=[],_e=0;_e<xe;++_e)ye.push(i(J.charCodeAt(_e)));for(var Fe=0,Ke=de;Fe<xe;++Fe){var rt=ye[Fe];rt=="m"?ye[Fe]=Ke:Ke=rt}for(var dt=0,it=de;dt<xe;++dt){var ft=ye[dt];ft=="1"&&it=="r"?ye[dt]="n":w.test(ft)&&(it=ft,ft=="r"&&(ye[dt]="R"))}for(var St=1,bt=ye[0];St<xe-1;++St){var _t=ye[St];_t=="+"&&bt=="1"&&ye[St+1]=="1"?ye[St]="1":_t==","&&bt==ye[St+1]&&(bt=="1"||bt=="n")&&(ye[St]=bt),bt=_t}for(var $t=0;$t<xe;++$t){var mr=ye[$t];if(mr==",")ye[$t]="N";else if(mr=="%"){var Jt=void 0;for(Jt=$t+1;Jt<xe&&ye[Jt]=="%";++Jt);for(var Fr=$t&&ye[$t-1]=="!"||Jt<xe&&ye[Jt]=="1"?"1":"N",Mr=$t;Mr<Jt;++Mr)ye[Mr]=Fr;$t=Jt-1}}for(var or=0,Pr=de;or<xe;++or){var br=ye[or];Pr=="L"&&br=="1"?ye[or]="L":w.test(br)&&(Pr=br)}for(var hr=0;hr<xe;++hr)if(n.test(ye[hr])){var sr=void 0;for(sr=hr+1;sr<xe&&n.test(ye[sr]);++sr);for(var er=(hr?ye[hr-1]:de)=="L",Ir=(sr<xe?ye[sr]:de)=="L",un=er==Ir?er?"L":"R":de,Li=hr;Li<sr;++Li)ye[Li]=un;hr=sr-1}for(var Er=[],li,gr=0;gr<xe;)if(N.test(ye[gr])){var Xa=gr;for(++gr;gr<xe&&N.test(ye[gr]);++gr);Er.push(new $(0,Xa,gr))}else{var mi=gr,ji=Er.length,Wi=se=="rtl"?1:0;for(++gr;gr<xe&&ye[gr]!="L";++gr);for(var Cr=mi;Cr<gr;)if(V.test(ye[Cr])){mi<Cr&&(Er.splice(ji,0,new $(1,mi,Cr)),ji+=Wi);var dn=Cr;for(++Cr;Cr<gr&&V.test(ye[Cr]);++Cr);Er.splice(ji,0,new $(2,dn,Cr)),ji+=Wi,mi=Cr}else++Cr;mi<gr&&Er.splice(ji,0,new $(1,mi,gr))}return se=="ltr"&&(Er[0].level==1&&(li=J.match(/^\s+/))&&(Er[0].from=li[0].length,Er.unshift(new $(0,0,li[0].length))),Oe(Er).level==1&&(li=J.match(/\s+$/))&&(Oe(Er).to-=li[0].length,Er.push(new $(0,xe-li[0].length,xe)))),se=="rtl"?Er.reverse():Er}}();function nt(e,t){var i=e.order;return i==null&&(i=e.order=ht(e.text,t)),i}var Je=[],Te=function(e,t,i){if(e.addEventListener)e.addEventListener(t,i,!1);else if(e.attachEvent)e.attachEvent("on"+t,i);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||Je).concat(i)}};function ut(e,t){return e._handlers&&e._handlers[t]||Je}function at(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{var r=e._handlers,n=r&&r[t];if(n){var w=ce(n,i);w>-1&&(r[t]=n.slice(0,w).concat(n.slice(w+1)))}}}function Ae(e,t){var i=ut(e,t);if(!i.length)return;for(var r=Array.prototype.slice.call(arguments,2),n=0;n<i.length;++n)i[n].apply(null,r)}function Ue(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Ae(e,i||t.type,e,t),ie(t)||t.codemirrorIgnore}function pe(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;for(var i=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)ce(i,t[r])==-1&&i.push(t[r])}function ue(e,t){return ut(e,t).length>0}function fe(e){e.prototype.on=function(t,i){Te(this,t,i)},e.prototype.off=function(t,i){at(this,t,i)}}function ee(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function te(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ie(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ne(e){ee(e),te(e)}function be(e){return e.target||e.srcElement}function ge(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),l&&e.ctrlKey&&t==1&&(t=3),t}var Re=function(){if(W&&F<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),He;function st(e){if(He==null){var t=a("span","\u200B");d(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(He=t.offsetWidth<=1&&t.offsetHeight>2&&!(W&&F<8))}var i=He?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var Ze;function mt(e){if(Ze!=null)return Ze;var t=d(e,document.createTextNode("A\u062EA")),i=b(t,0,1).getBoundingClientRect(),r=b(t,1,2).getBoundingClientRect();return c(e),!i||i.left==i.right?!1:Ze=r.right-i.right<3}var vt=`
|
|
|
|
b`.split(/\n/).length!=3?function(e){for(var t=0,i=[],r=e.length;t<=r;){var n=e.indexOf(`
|
|
`,t);n==-1&&(n=e.length);var w=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),N=w.indexOf("\r");N!=-1?(i.push(w.slice(0,N)),t+=N+1):(i.push(w),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},Qe=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},jt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),At=null;function Nt(e){if(At!=null)return At;var t=d(e,a("span","x")),i=t.getBoundingClientRect(),r=b(t,0,1).getBoundingClientRect();return At=Math.abs(i.left-r.left)>1}var Ht={},Dt={};function Tr(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Ht[e]=t}function Zr(e,t){Dt[e]=t}function yt(e){if(typeof e=="string"&&Dt.hasOwnProperty(e))e=Dt[e];else if(e&&typeof e.name=="string"&&Dt.hasOwnProperty(e.name)){var t=Dt[e.name];typeof t=="string"&&(t={name:t}),e=ze(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return yt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return yt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function wr(e,t){t=yt(t);var i=Ht[t.name];if(!i)return wr(e,"text/plain");var r=i(e,t);if(tr.hasOwnProperty(t.name)){var n=tr[t.name];for(var w in n){if(!n.hasOwnProperty(w))continue;r.hasOwnProperty(w)&&(r["_"+w]=r[w]),r[w]=n[w]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var N in t.modeProps)r[N]=t.modeProps[N];return r}var tr={};function lr(e,t){var i=tr.hasOwnProperty(e)?tr[e]:tr[e]={};j(t,i)}function Bt(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var i={};for(var r in t){var n=t[r];n instanceof Array&&(n=n.concat([])),i[r]=n}return i}function Qt(e,t){for(var i;e.innerMode&&!(i=e.innerMode(t),!i||i.mode==e);)t=i.state,e=i.mode;return i||{mode:e,state:t}}function Kt(e,t,i){return e.startState?e.startState(t,i):!0}var Tt=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};Tt.prototype.eol=function(){return this.pos>=this.string.length},Tt.prototype.sol=function(){return this.pos==this.lineStart},Tt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Tt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Tt.prototype.eat=function(e){var t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e.test?e.test(t):e(t)),i)return++this.pos,t},Tt.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Tt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Tt.prototype.skipToEnd=function(){this.pos=this.string.length},Tt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Tt.prototype.backUp=function(e){this.pos-=e},Tt.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=q(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},Tt.prototype.indentation=function(){return q(this.string,null,this.tabSize)-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},Tt.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(N){return i?N.toLowerCase():N},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var w=this.string.slice(this.pos).match(e);return w&&w.index>0?null:(w&&t!==!1&&(this.pos+=w[0].length),w)}},Tt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Tt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Tt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Tt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function pt(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var i=e;!i.lines;)for(var r=0;;++r){var n=i.children[r],w=n.chunkSize();if(t<w){i=n;break}t-=w}return i.lines[t]}function ur(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(w){var N=w.text;n==i.line&&(N=N.slice(0,i.ch)),n==t.line&&(N=N.slice(t.ch)),r.push(N),++n}),r}function Lr(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function Ar(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function Rt(e){if(e.parent==null)return null;for(var t=e.parent,i=ce(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var n=0;!(r.children[n]==t);++n)i+=r.children[n].chunkSize();return i+t.first}function jr(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],w=n.height;if(t<w){e=n;continue e}t-=w,i+=n.chunkSize()}return i}while(!e.lines);for(var N=0;N<e.lines.length;++N){var V=e.lines[N],$=V.height;if(t<$)break;t-=$}return i+N}function Jr(e,t){return t>=e.first&&t<e.first+e.size}function ui(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function We(e,t,i){if(i===void 0&&(i=null),!(this instanceof We))return new We(e,t,i);this.line=e,this.ch=t,this.sticky=i}function wt(e,t){return e.line-t.line||e.ch-t.ch}function di(e,t){return e.sticky==t.sticky&&wt(e,t)==0}function Ai(e){return We(e.line,e.ch)}function hi(e,t){return wt(e,t)<0?t:e}function Di(e,t){return wt(e,t)<0?e:t}function H(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function s(e,t){if(t.line<e.first)return We(e.first,0);var i=e.first+e.size-1;return t.line>i?We(i,pt(e,i).text.length):m(t,pt(e,t.line).text.length)}function m(e,t){var i=e.ch;return i==null||i>t?We(e.line,t):i<0?We(e.line,0):e}function B(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=s(e,t[r]);return i}var K=function(e,t){this.state=e,this.lookAhead=t},U=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};U.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},U.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},U.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},U.fromSaved=function(e,t,i){return t instanceof K?new U(e,Bt(e.mode,t.state),i,t.lookAhead):new U(e,Bt(e.mode,t),i)},U.prototype.save=function(e){var t=e!==!1?Bt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new K(t,this.maxLookAhead):t};function he(e,t,i,r){var n=[e.state.modeGen],w={};Hr(e,t.text,e.doc.mode,i,function(J,se){return n.push(J,se)},w,r);for(var N=i.state,V=function(J){i.baseTokens=n;var se=e.state.overlays[J],de=1,xe=0;i.state=!0,Hr(e,t.text,se.mode,i,function(ye,_e){for(var Fe=de;xe<ye;){var Ke=n[de];Ke>ye&&n.splice(de,1,ye,n[de+1],Ke),de+=2,xe=Math.min(ye,Ke)}if(!_e)return;if(se.opaque)n.splice(Fe,de-Fe,ye,"overlay "+_e),de=Fe+2;else for(;Fe<de;Fe+=2){var rt=n[Fe+1];n[Fe+1]=(rt?rt+" ":"")+"overlay "+_e}},w),i.state=N,i.baseTokens=null,i.baseTokenPos=1},$=0;$<e.state.overlays.length;++$)V($);return{styles:n,classes:w.bgClass||w.textClass?w:null}}function Pe(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=et(e,Rt(t)),n=t.text.length>e.options.maxHighlightLength&&Bt(e.doc.mode,r.state),w=he(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=w.styles,w.classes?t.styleClasses=w.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function et(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new U(r,!0,t);var w=dr(e,t,i),N=w>r.first&&pt(r,w-1).stateAfter,V=N?U.fromSaved(r,N,w):new U(r,Kt(r.mode),w);return r.iter(w,t,function($){ct(e,$.text,V);var J=V.line;$.stateAfter=J==t-1||J%5==0||J>=n.viewFrom&&J<n.viewTo?V.save():null,V.nextLine()}),i&&(r.modeFrontier=V.line),V}function ct(e,t,i,r){var n=e.doc.mode,w=new Tt(t,e.options.tabSize,i);for(w.start=w.pos=r||0,t==""&&Be(n,i.state);!w.eol();)Ct(n,w,i.state),w.start=w.pos}function Be(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=Qt(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function Ct(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=Qt(e,i).mode);var w=e.token(t,i);if(t.pos>t.start)return w}throw new Error("Mode "+e.name+" failed to advance stream.")}var Ot=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Yt(e,t,i,r){var n=e.doc,w=n.mode,N;t=s(n,t);var V=pt(n,t.line),$=et(e,t.line,i),J=new Tt(V.text,e.options.tabSize,$),se;for(r&&(se=[]);(r||J.pos<t.ch)&&!J.eol();)J.start=J.pos,N=Ct(w,J,$.state),r&&se.push(new Ot(J,N,Bt(n.mode,$.state)));return r?se:new Ot(J,N,$.state)}function Wr(e,t){if(e)for(;;){var i=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i)break;e=e.slice(0,i.index)+e.slice(i.index+i[0].length);var r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+i[2])}return e}function Hr(e,t,i,r,n,w,N){var V=i.flattenSpans;V==null&&(V=e.options.flattenSpans);var $=0,J=null,se=new Tt(t,e.options.tabSize,r),de,xe=e.options.addModeClass&&[null];for(t==""&&Wr(Be(i,r.state),w);!se.eol();){if(se.pos>e.options.maxHighlightLength?(V=!1,N&&ct(e,t,r,se.pos),se.pos=t.length,de=null):de=Wr(Ct(i,se,r.state,xe),w),xe){var ye=xe[0].name;ye&&(de="m-"+(de?ye+" "+de:ye))}if(!V||J!=de){for(;$<se.start;)$=Math.min(se.start,$+5e3),n($,J);J=de}se.start=se.pos}for(;$<se.pos;){var _e=Math.min(se.pos,$+5e3);n(_e,J),$=_e}}function dr(e,t,i){for(var r,n,w=e.doc,N=i?-1:t-(e.doc.mode.innerMode?1e3:100),V=t;V>N;--V){if(V<=w.first)return w.first;var $=pt(w,V-1),J=$.stateAfter;if(J&&(!i||V+(J instanceof K?J.lookAhead:0)<=w.modeFrontier))return V;var se=q($.text,null,e.options.tabSize);(n==null||r>se)&&(n=V-1,r=se)}return n}function Xr(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var i=e.first,r=t-1;r>i;r--){var n=pt(e,r).stateAfter;if(n&&(!(n instanceof K)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Hi=!1,Dr=!1;function Gr(){Hi=!0}function Nr(){Dr=!0}function gi(e,t,i){this.marker=e,this.from=t,this.to=i}function Qr(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function ci(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function ni(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function hn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var w=e[n],N=w.marker,V=w.from==null||(N.inclusiveLeft?w.from<=t:w.from<t);if(V||w.from==t&&N.type=="bookmark"&&(!i||!w.marker.insertLeft)){var $=w.to==null||(N.inclusiveRight?w.to>=t:w.to>t);(r||(r=[])).push(new gi(N,w.from,$?null:w.to))}}return r}function Gi(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var w=e[n],N=w.marker,V=w.to==null||(N.inclusiveRight?w.to>=t:w.to>t);if(V||w.from==t&&N.type=="bookmark"&&(!i||w.marker.insertLeft)){var $=w.from==null||(N.inclusiveLeft?w.from<=t:w.from<t);(r||(r=[])).push(new gi(N,$?null:w.from-t,w.to==null?null:w.to-t))}}return r}function qr(e,t){if(t.full)return null;var i=Jr(e,t.from.line)&&pt(e,t.from.line).markedSpans,r=Jr(e,t.to.line)&&pt(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,w=t.to.ch,N=wt(t.from,t.to)==0,V=hn(i,n,N),$=Gi(r,w,N),J=t.text.length==1,se=Oe(t.text).length+(J?n:0);if(V)for(var de=0;de<V.length;++de){var xe=V[de];if(xe.to==null){var ye=Qr($,xe.marker);ye?J&&(xe.to=ye.to==null?null:ye.to+se):xe.to=n}}if($)for(var _e=0;_e<$.length;++_e){var Fe=$[_e];if(Fe.to!=null&&(Fe.to+=se),Fe.from==null){var Ke=Qr(V,Fe.marker);Ke||(Fe.from=se,J&&(V||(V=[])).push(Fe))}else Fe.from+=se,J&&(V||(V=[])).push(Fe)}V&&(V=zr(V)),$&&$!=V&&($=zr($));var rt=[V];if(!J){var dt=t.text.length-2,it;if(dt>0&&V)for(var ft=0;ft<V.length;++ft)V[ft].to==null&&(it||(it=[])).push(new gi(V[ft].marker,null,null));for(var St=0;St<dt;++St)rt.push(it);rt.push($)}return rt}function zr(e){for(var t=0;t<e.length;++t){var i=e[t];i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function _i(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(ye){if(ye.markedSpans)for(var _e=0;_e<ye.markedSpans.length;++_e){var Fe=ye.markedSpans[_e].marker;Fe.readOnly&&(!r||ce(r,Fe)==-1)&&(r||(r=[])).push(Fe)}}),!r)return null;for(var n=[{from:t,to:i}],w=0;w<r.length;++w)for(var N=r[w],V=N.find(0),$=0;$<n.length;++$){var J=n[$];if(wt(J.to,V.from)<0||wt(J.from,V.to)>0)continue;var se=[$,1],de=wt(J.from,V.from),xe=wt(J.to,V.to);(de<0||!N.inclusiveLeft&&!de)&&se.push({from:J.from,to:V.from}),(xe>0||!N.inclusiveRight&&!xe)&&se.push({from:V.to,to:J.to}),n.splice.apply(n,se),$+=se.length-3}return n}function Ri(e){var t=e.markedSpans;if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.detachLine(e);e.markedSpans=null}function cn(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function qt(e){return e.inclusiveLeft?-1:0}function Ut(e){return e.inclusiveRight?1:0}function vr(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),w=wt(r.from,n.from)||qt(e)-qt(t);if(w)return-w;var N=wt(r.to,n.to)||Ut(e)-Ut(t);return N||t.id-e.id}function It(e,t){var i=Dr&&e.markedSpans,r;if(i)for(var n=void 0,w=0;w<i.length;++w)n=i[w],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||vr(r,n.marker)<0)&&(r=n.marker);return r}function nr(e){return It(e,!0)}function Gt(e){return It(e,!1)}function ai(e,t){var i=Dr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var w=i[n];w.marker.collapsed&&(w.from==null||w.from<t)&&(w.to==null||w.to>t)&&(!r||vr(r,w.marker)<0)&&(r=w.marker)}return r}function rr(e,t,i,r,n){var w=pt(e,t),N=Dr&&w.markedSpans;if(N)for(var V=0;V<N.length;++V){var $=N[V];if(!$.marker.collapsed)continue;var J=$.marker.find(0),se=wt(J.from,i)||qt($.marker)-qt(n),de=wt(J.to,r)||Ut($.marker)-Ut(n);if(se>=0&&de<=0||se<=0&&de>=0)continue;if(se<=0&&($.marker.inclusiveRight&&n.inclusiveLeft?wt(J.to,i)>=0:wt(J.to,i)>0)||se>=0&&($.marker.inclusiveRight&&n.inclusiveLeft?wt(J.from,r)<=0:wt(J.from,r)<0))return!0}}function _r(e){for(var t;t=nr(e);)e=t.find(-1,!0).line;return e}function zi(e){for(var t;t=Gt(e);)e=t.find(1,!0).line;return e}function Ki(e){for(var t,i;t=Gt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function vi(e,t){var i=pt(e,t),r=_r(i);return i==r?t:Rt(r)}function Fn(e,t){if(t>e.lastLine())return t;var i=pt(e,t),r;if(!Br(e,i))return t;for(;r=Gt(i);)i=r.find(1,!0).line;return Rt(i)+1}function Br(e,t){var i=Dr&&t.markedSpans;if(i)for(var r=void 0,n=0;n<i.length;++n){if(r=i[n],!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&fn(e,t,r))return!0}}function fn(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return fn(e,r.line,Qr(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,w=0;w<t.markedSpans.length;++w)if(n=t.markedSpans[w],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&fn(e,t,n))return!0}function ei(e){e=_r(e);for(var t=0,i=e.parent,r=0;r<i.lines.length;++r){var n=i.lines[r];if(n==e)break;t+=n.height}for(var w=i.parent;w;i=w,w=i.parent)for(var N=0;N<w.children.length;++N){var V=w.children[N];if(V==i)break;t+=V.height}return t}function Vi(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=nr(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Gt(r);){var w=i.find(0,!0);t-=r.text.length-w.from.ch,r=w.to.line,t+=r.text.length-w.to.ch}return t}function jn(e){var t=e.display,i=e.doc;t.maxLine=pt(i,i.first),t.maxLineLength=Vi(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=Vi(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var ki=function(e,t,i){this.text=e,cn(this,t),this.height=i?i(this):1};ki.prototype.lineNo=function(){return Rt(this)},fe(ki);function $a(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Ri(e),cn(e,i);var n=r?r(e):1;n!=e.height&&Ar(e,n)}function da(e){e.parent=null,Ri(e)}var gt={},Lt={};function xt(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?Lt:gt;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function kt(e,t){var i=E("span",null,null,M?"padding-right: .1px":null),r={pre:E("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var n=0;n<=(t.rest?t.rest.length:0);n++){var w=n?t.rest[n-1]:t.line,N=void 0;r.pos=0,r.addToken=Vt,mt(e.display.measure)&&(N=nt(w,e.doc.direction))&&(r.addToken=ar(r.addToken,N)),r.map=[];var V=t!=e.display.externalMeasured&&Rt(w);Mt(w,r,Pe(e,w,V)),w.styleClasses&&(w.styleClasses.bgClass&&(r.bgClass=Y(w.styleClasses.bgClass,r.bgClass||"")),w.styleClasses.textClass&&(r.textClass=Y(w.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(st(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(M){var $=r.content.lastChild;(/\bcm-tab\b/.test($.className)||$.querySelector&&$.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Ae(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=Y(r.pre.className,r.textClass||"")),r}function Ft(e){var t=a("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Vt(e,t,i,r,n,w,N){if(!t)return;var V=e.splitSpaces?Pt(t,e.trailingSpace):t,$=e.cm.state.specialChars,J=!1,se;if(!$.test(t))e.col+=t.length,se=document.createTextNode(V),e.map.push(e.pos,e.pos+t.length,se),W&&F<9&&(J=!0),e.pos+=t.length;else{se=document.createDocumentFragment();for(var de=0;;){$.lastIndex=de;var xe=$.exec(t),ye=xe?xe.index-de:t.length-de;if(ye){var _e=document.createTextNode(V.slice(de,de+ye));W&&F<9?se.appendChild(a("span",[_e])):se.appendChild(_e),e.map.push(e.pos,e.pos+ye,_e),e.col+=ye,e.pos+=ye}if(!xe)break;de+=ye+1;var Fe=void 0;if(xe[0]==" "){var Ke=e.cm.options.tabSize,rt=Ke-e.col%Ke;Fe=se.appendChild(a("span",le(rt),"cm-tab")),Fe.setAttribute("role","presentation"),Fe.setAttribute("cm-text"," "),e.col+=rt}else xe[0]=="\r"||xe[0]==`
|
|
`?(Fe=se.appendChild(a("span",xe[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Fe.setAttribute("cm-text",xe[0]),e.col+=1):(Fe=e.cm.options.specialCharPlaceholder(xe[0]),Fe.setAttribute("cm-text",xe[0]),W&&F<9?se.appendChild(a("span",[Fe])):se.appendChild(Fe),e.col+=1);e.map.push(e.pos,e.pos+1,Fe),e.pos++}}if(e.trailingSpace=V.charCodeAt(t.length-1)==32,i||r||n||J||w||N){var dt=i||"";r&&(dt+=r),n&&(dt+=n);var it=a("span",[se],dt,w);if(N)for(var ft in N)N.hasOwnProperty(ft)&&ft!="style"&&ft!="class"&&it.setAttribute(ft,N[ft]);return e.content.appendChild(it)}e.content.appendChild(se)}function Pt(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var w=e.charAt(n);w==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(w="\xA0"),r+=w,i=w==" "}return r}function ar(e,t){return function(i,r,n,w,N,V,$){n=n?n+" cm-force-border":"cm-force-border";for(var J=i.pos,se=J+r.length;;){for(var de=void 0,xe=0;xe<t.length&&!(de=t[xe],de.to>J&&de.from<=J);xe++);if(de.to>=se)return e(i,r,n,w,N,V,$);e(i,r.slice(0,de.to-J),n,w,null,V,$),w=null,r=r.slice(de.to-J),J=de.to}}}function Rr(e,t,i,r){var n=!r&&i.widgetNode;n&&e.map.push(e.pos,e.pos+t,n),!r&&e.cm.display.input.needsContentAttribute&&(n||(n=e.content.appendChild(document.createElement("span"))),n.setAttribute("cm-marker",i.id)),n&&(e.cm.display.input.setUneditable(n),e.content.appendChild(n)),e.pos+=t,e.trailingSpace=!1}function Mt(e,t,i){var r=e.markedSpans,n=e.text,w=0;if(!r){for(var N=1;N<i.length;N+=2)t.addToken(t,n.slice(w,w=i[N]),xt(i[N+1],t.cm.options));return}for(var V=n.length,$=0,J=1,se="",de,xe,ye=0,_e,Fe,Ke,rt,dt;;){if(ye==$){_e=Fe=Ke=xe="",dt=null,rt=null,ye=Infinity;for(var it=[],ft=void 0,St=0;St<r.length;++St){var bt=r[St],_t=bt.marker;if(_t.type=="bookmark"&&bt.from==$&&_t.widgetNode)it.push(_t);else if(bt.from<=$&&(bt.to==null||bt.to>$||_t.collapsed&&bt.to==$&&bt.from==$)){if(bt.to!=null&&bt.to!=$&&ye>bt.to&&(ye=bt.to,Fe=""),_t.className&&(_e+=" "+_t.className),_t.css&&(xe=(xe?xe+";":"")+_t.css),_t.startStyle&&bt.from==$&&(Ke+=" "+_t.startStyle),_t.endStyle&&bt.to==ye&&(ft||(ft=[])).push(_t.endStyle,bt.to),_t.title&&((dt||(dt={})).title=_t.title),_t.attributes)for(var $t in _t.attributes)(dt||(dt={}))[$t]=_t.attributes[$t];_t.collapsed&&(!rt||vr(rt.marker,_t)<0)&&(rt=bt)}else bt.from>$&&ye>bt.from&&(ye=bt.from)}if(ft)for(var mr=0;mr<ft.length;mr+=2)ft[mr+1]==ye&&(Fe+=" "+ft[mr]);if(!rt||rt.from==$)for(var Jt=0;Jt<it.length;++Jt)Rr(t,0,it[Jt]);if(rt&&(rt.from||0)==$){if(Rr(t,(rt.to==null?V+1:rt.to)-$,rt.marker,rt.from==null),rt.to==null)return;rt.to==$&&(rt=!1)}}if($>=V)break;for(var Fr=Math.min(V,ye);;){if(se){var Mr=$+se.length;if(!rt){var or=Mr>Fr?se.slice(0,Fr-$):se;t.addToken(t,or,de?de+_e:_e,Ke,$+or.length==ye?Fe:"",xe,dt)}if(Mr>=Fr){se=se.slice(Fr-$),$=Fr;break}$=Mr,Ke=""}se=n.slice(w,w=i[J++]),de=xt(i[J++],t.cm.options)}}}function yi(e,t,i){this.line=t,this.rest=Ki(t),this.size=this.rest?Rt(Oe(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Br(e,t)}function Wt(e,t,i){for(var r=[],n,w=t;w<i;w=n){var N=new yi(e.doc,pt(e.doc,w),w);n=w+N.size,r.push(N)}return r}var cr=null;function Yr(e){cr?cr.ops.push(e):e.ownsGroup=cr={ops:[e],delayedCallbacks:[]}}function $r(e){var t=e.delayedCallbacks,i=0;do{for(;i<t.length;i++)t[i].call(null);for(var r=0;r<e.ops.length;r++){var n=e.ops[r];if(n.cursorActivityHandlers)for(;n.cursorActivityCalled<n.cursorActivityHandlers.length;)n.cursorActivityHandlers[n.cursorActivityCalled++].call(null,n.cm)}}while(i<t.length)}function Wn(e,t){var i=e.ownsGroup;if(!i)return;try{$r(i)}finally{cr=null,t(i)}}var pn=null;function yr(e,t){var i=ut(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;cr?n=cr.delayedCallbacks:pn?n=pn:(n=pn=[],setTimeout(Os,0));for(var w=function(V){n.push(function(){return i[V].apply(null,r)})},N=0;N<i.length;++N)w(N)}function Os(){var e=pn;pn=null;for(var t=0;t<e.length;++t)e[t]()}function Za(e,t,i,r){for(var n=0;n<t.changes.length;n++){var w=t.changes[n];w=="text"?Ps(e,t):w=="gutter"?Qa(e,t,i,r):w=="class"?ha(e,t):w=="widget"&&Is(e,t,r)}t.changes=null}function mn(e){return e.node==e.text&&(e.node=a("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),W&&F<8&&(e.node.style.zIndex=2)),e.node}function Ms(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=mn(t);t.background=r.insertBefore(a("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function Ja(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):kt(e,t)}function Ps(e,t){var i=t.text.className,r=Ja(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,ha(e,t)):i&&(t.text.className=i)}function ha(e,t){Ms(e,t),t.line.wrapClass?mn(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function Qa(e,t,i,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var n=mn(t);t.gutterBackground=a("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}var w=t.line.gutterMarkers;if(e.options.lineNumbers||w){var N=mn(t),V=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(V),N.insertBefore(V,t.text),t.line.gutterClass&&(V.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!w||!w["CodeMirror-linenumbers"])&&(t.lineNumber=V.appendChild(a("div",ui(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),w)for(var $=0;$<e.display.gutterSpecs.length;++$){var J=e.display.gutterSpecs[$].className,se=w.hasOwnProperty(J)&&w[J];se&&V.appendChild(a("div",[se],"CodeMirror-gutter-elt","left: "+r.gutterLeft[J]+"px; width: "+r.gutterWidth[J]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=S("CodeMirror-linewidget"),n=t.node.firstChild,w=void 0;n;n=w)w=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);qa(e,t,i)}function Ns(e,t,i,r){var n=Ja(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),ha(e,t),Qa(e,t,i,r),qa(e,t,r),t.node}function qa(e,t,i){if(eo(e,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)eo(e,t.rest[r],t,i,!1)}function eo(e,t,i,r,n){if(!t.widgets)return;for(var w=mn(i),N=0,V=t.widgets;N<V.length;++N){var $=V[N],J=a("div",[$.node],"CodeMirror-linewidget"+($.className?" "+$.className:""));$.handleMouseEvents||J.setAttribute("cm-ignore-events","true"),Bs($,J,i,r),e.display.input.setUneditable(J),n&&$.above?w.insertBefore(J,i.gutter||i.text):w.appendChild(J),yr($,"redraw")}}function Bs(e,t,i,r){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);var n=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(n-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=n+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function gn(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!T(document.body,e.node)){var i="position: relative;";e.coverGutter&&(i+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(i+="width: "+t.display.wrapper.clientWidth+"px;"),d(t.display.measure,a("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function fi(e,t){for(var i=be(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function Hn(e){return e.lineSpace.offsetTop}function ca(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function to(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=d(e.measure,a("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function oi(e){return ve-e.display.nativeBarWidth}function Oi(e){return e.display.scroller.clientWidth-oi(e)-e.display.barWidth}function fa(e){return e.display.scroller.clientHeight-oi(e)-e.display.barHeight}function Us(e,t,i){var r=e.options.lineWrapping,n=r&&Oi(e);if(!t.measure.heights||r&&t.measure.width!=n){var w=t.measure.heights=[];if(r){t.measure.width=n;for(var N=t.text.firstChild.getClientRects(),V=0;V<N.length-1;V++){var $=N[V],J=N[V+1];Math.abs($.bottom-J.bottom)>2&&w.push(($.bottom+J.top)/2-i.top)}}w.push(i.bottom-i.top)}}function ro(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var n=0;n<e.rest.length;n++)if(Rt(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Fs(e,t){t=_r(t);var i=Rt(t),r=e.display.externalMeasured=new yi(e.doc,t,i);r.lineN=i;var n=r.built=kt(e,r);return r.text=n.pre,d(e.display.lineMeasure,n.pre),r}function io(e,t,i,r){return si(e,Xi(e,t),i,r)}function pa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Ii(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function Xi(e,t){var i=Rt(t),r=pa(e,i);r&&!r.text?r=null:r&&r.changes&&(Za(e,r,i,xa(e)),e.curOp.forceUpdate=!0),r||(r=Fs(e,t));var n=ro(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function si(e,t,i,r,n){t.before&&(i=-1);var w=i+(r||""),N;return t.cache.hasOwnProperty(w)?N=t.cache[w]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Us(e,t.view,t.rect),t.hasHeights=!0),N=Ws(e,t,i,r),N.bogus||(t.cache[w]=N)),{left:N.left,right:N.right,top:n?N.rtop:N.top,bottom:n?N.rbottom:N.bottom}}var no={left:0,right:0,top:0,bottom:0};function ao(e,t,i){for(var r,n,w,N,V,$,J=0;J<e.length;J+=3)if(V=e[J],$=e[J+1],t<V?(n=0,w=1,N="left"):t<$?(n=t-V,w=n+1):(J==e.length-3||t==$&&e[J+3]>t)&&(w=$-V,n=w-1,t>=$&&(N="right")),n!=null){if(r=e[J+2],V==$&&i==(r.insertLeft?"left":"right")&&(N=i),i=="left"&&n==0)for(;J&&e[J-2]==e[J-3]&&e[J-1].insertLeft;)r=e[(J-=3)+2],N="left";if(i=="right"&&n==$-V)for(;J<e.length-3&&e[J+3]==e[J+4]&&!e[J+5].insertLeft;)r=e[(J+=3)+2],N="right";break}return{node:r,start:n,end:w,collapse:N,coverStart:V,coverEnd:$}}function js(e,t){var i=no;if(t=="left")for(var r=0;r<e.length&&!((i=e[r]).left!=i.right);r++);else for(var n=e.length-1;n>=0&&!((i=e[n]).left!=i.right);n--);return i}function Ws(e,t,i,r){var n=ao(t.map,i,r),w=n.node,N=n.start,V=n.end,$=n.collapse,J;if(w.nodeType==3){for(var se=0;se<4;se++){for(;N&&Me(t.line.text.charAt(n.coverStart+N));)--N;for(;n.coverStart+V<n.coverEnd&&Me(t.line.text.charAt(n.coverStart+V));)++V;if(W&&F<9&&N==0&&V==n.coverEnd-n.coverStart?J=w.parentNode.getBoundingClientRect():J=js(b(w,N,V).getClientRects(),r),J.left||J.right||N==0)break;V=N,N=N-1,$="right"}W&&F<11&&(J=Hs(e.display.measure,J))}else{N>0&&($=r="right");var de;e.options.lineWrapping&&(de=w.getClientRects()).length>1?J=de[r=="right"?de.length-1:0]:J=w.getBoundingClientRect()}if(W&&F<9&&!N&&(!J||!J.left&&!J.right)){var xe=w.parentNode.getClientRects()[0];xe?J={left:xe.left,right:xe.left+$i(e.display),top:xe.top,bottom:xe.bottom}:J=no}for(var ye=J.top-t.rect.top,_e=J.bottom-t.rect.top,Fe=(ye+_e)/2,Ke=t.view.measure.heights,rt=0;rt<Ke.length-1&&!(Fe<Ke[rt]);rt++);var dt=rt?Ke[rt-1]:0,it=Ke[rt],ft={left:($=="right"?J.right:J.left)-t.rect.left,right:($=="left"?J.left:J.right)-t.rect.left,top:dt,bottom:it};return!J.left&&!J.right&&(ft.bogus=!0),e.options.singleCursorHeightPerLine||(ft.rtop=ye,ft.rbottom=_e),ft}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Nt(e))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function oo(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function so(e){e.display.externalMeasure=null,c(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)oo(e.display.view[t])}function vn(e){so(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function lo(){return v&&u?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function uo(){return v&&u?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function ma(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=gn(e.widgets[i]));return t}function Gn(e,t,i,r,n){if(!n){var w=ma(t);i.top+=w,i.bottom+=w}if(r=="line")return i;r||(r="local");var N=ei(t);if(r=="local"?N+=Hn(e.display):N-=e.display.viewOffset,r=="page"||r=="window"){var V=e.display.lineSpace.getBoundingClientRect();N+=V.top+(r=="window"?0:uo());var $=V.left+(r=="window"?0:lo());i.left+=$,i.right+=$}return i.top+=N,i.bottom+=N,i}function ho(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=lo(),n-=uo();else if(i=="local"||!i){var w=e.display.sizer.getBoundingClientRect();r+=w.left,n+=w.top}var N=e.display.lineSpace.getBoundingClientRect();return{left:r-N.left,top:n-N.top}}function ga(e,t,i,r,n){return r||(r=pt(e.doc,t.line)),Gn(e,r,io(e,r,t.ch,n),i)}function ti(e,t,i,r,n,w){r=r||pt(e.doc,t.line),n||(n=Xi(e,r));function N(_e,Fe){var Ke=si(e,n,_e,Fe?"right":"left",w);return Fe?Ke.left=Ke.right:Ke.right=Ke.left,Gn(e,r,Ke,i)}var V=nt(r,e.doc.direction),$=t.ch,J=t.sticky;if($>=r.text.length?($=r.text.length,J="before"):$<=0&&($=0,J="after"),!V)return N(J=="before"?$-1:$,J=="before");function se(_e,Fe,Ke){var rt=V[Fe],dt=rt.level==1;return N(Ke?_e-1:_e,dt!=Ke)}var de=Xe(V,$,J),xe=qe,ye=se($,de,J=="before");return xe!=null&&(ye.other=se($,xe,J!="before")),ye}function co(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=$i(e.display)*t.ch);var r=pt(e.doc,t.line),n=ei(r)+Hn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function va(e,t,i,r,n){var w=We(e,t,i);return w.xRel=n,r&&(w.outside=r),w}function ya(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return va(r.first,0,null,-1,-1);var n=jr(r,i),w=r.first+r.size-1;if(n>w)return va(r.first+r.size-1,pt(r,w).text.length,null,1,1);t<0&&(t=0);for(var N=pt(r,n);;){var V=Gs(e,N,n,t,i),$=ai(N,V.ch+(V.xRel>0||V.outside>0?1:0));if(!$)return V;var J=$.find(1);if(J.line==n)return J;N=pt(r,n=J.line)}}function fo(e,t,i,r){r-=ma(t);var n=t.text.length,w=lt(function(N){return si(e,i,N-1).bottom<=r},n,0);return n=lt(function(N){return si(e,i,N).top>r},w,n),{begin:w,end:n}}function po(e,t,i,r){i||(i=Xi(e,t));var n=Gn(e,t,si(e,i,r),"line").top;return fo(e,t,i,n)}function ba(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Gs(e,t,i,r,n){n-=ei(t);var w=Xi(e,t),N=ma(t),V=0,$=t.text.length,J=!0,se=nt(t,e.doc.direction);if(se){var de=(e.options.lineWrapping?Ks:zs)(e,t,i,w,se,r,n);J=de.level!=1,V=J?de.from:de.to-1,$=J?de.to:de.from-1}var xe=null,ye=null,_e=lt(function(St){var bt=si(e,w,St);return bt.top+=N,bt.bottom+=N,ba(bt,r,n,!1)?(bt.top<=n&&bt.left<=r&&(xe=St,ye=bt),!0):!1},V,$),Fe,Ke,rt=!1;if(ye){var dt=r-ye.left<ye.right-r,it=dt==J;_e=xe+(it?0:1),Ke=it?"after":"before",Fe=dt?ye.left:ye.right}else{!J&&(_e==$||_e==V)&&_e++,Ke=_e==0?"after":_e==t.text.length?"before":si(e,w,_e-(J?1:0)).bottom+N<=n==J?"after":"before";var ft=ti(e,We(i,_e,Ke),"line",t,w);Fe=ft.left,rt=n<ft.top?-1:n>=ft.bottom?1:0}return _e=Ie(t.text,_e,1),va(i,_e,Ke,rt,r-Fe)}function zs(e,t,i,r,n,w,N){var V=lt(function(de){var xe=n[de],ye=xe.level!=1;return ba(ti(e,We(i,ye?xe.to:xe.from,ye?"before":"after"),"line",t,r),w,N,!0)},0,n.length-1),$=n[V];if(V>0){var J=$.level!=1,se=ti(e,We(i,J?$.from:$.to,J?"after":"before"),"line",t,r);ba(se,w,N,!0)&&se.top>N&&($=n[V-1])}return $}function Ks(e,t,i,r,n,w,N){var V=fo(e,t,r,N),$=V.begin,J=V.end;/\s/.test(t.text.charAt(J-1))&&J--;for(var se=null,de=null,xe=0;xe<n.length;xe++){var ye=n[xe];if(ye.from>=J||ye.to<=$)continue;var _e=ye.level!=1,Fe=si(e,r,_e?Math.min(J,ye.to)-1:Math.max($,ye.from)).right,Ke=Fe<w?w-Fe+1e9:Fe-w;(!se||de>Ke)&&(se=ye,de=Ke)}return se||(se=n[n.length-1]),se.from<$&&(se={from:$,to:se.to,level:se.level}),se.to>J&&(se={from:se.from,to:J,level:se.level}),se}var Mi;function Yi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Mi==null){Mi=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Mi.appendChild(document.createTextNode("x")),Mi.appendChild(a("br"));Mi.appendChild(document.createTextNode("x"))}d(e.measure,Mi);var i=Mi.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),c(e.measure),i||1}function $i(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),i=a("pre",[t],"CodeMirror-line-like");d(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function xa(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,w=t.gutters.firstChild,N=0;w;w=w.nextSibling,++N){var V=e.display.gutterSpecs[N].className;i[V]=w.offsetLeft+w.clientLeft+n,r[V]=w.clientWidth}return{fixedPos:Ea(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Ea(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function mo(e){var t=Yi(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/$i(e.display)-3);return function(n){if(Br(e.doc,n))return 0;var w=0;if(n.widgets)for(var N=0;N<n.widgets.length;N++)n.widgets[N].height&&(w+=n.widgets[N].height);return i?w+(Math.ceil(n.text.length/r)||1)*t:w+t}}function Sa(e){var t=e.doc,i=mo(e);t.iter(function(r){var n=i(r);n!=r.height&&Ar(r,n)})}function Pi(e,t,i,r){var n=e.display;if(!i&&be(t).getAttribute("cm-not-content")=="true")return null;var w,N,V=n.lineSpace.getBoundingClientRect();try{w=t.clientX-V.left,N=t.clientY-V.top}catch(de){return null}var $=ya(e,w,N),J;if(r&&$.xRel>0&&(J=pt(e.doc,$.line).text).length==$.ch){var se=q(J,J.length,e.options.tabSize)-J.length;$=We($.line,Math.max(0,Math.round((w-to(e.display).left)/$i(e.display))-se))}return $}function Ii(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var i=e.display.view,r=0;r<i.length;r++)if(t-=i[r].size,t<0)return r}function kr(e,t,i,r){t==null&&(t=e.doc.first),i==null&&(i=e.doc.first+e.doc.size),r||(r=0);var n=e.display;if(r&&i<n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>t)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)Dr&&vi(e.doc,t)<n.viewTo&&xi(e);else if(i<=n.viewFrom)Dr&&Fn(e.doc,i+r)>n.viewFrom?xi(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)xi(e);else if(t<=n.viewFrom){var w=zn(e,i,i+r,1);w?(n.view=n.view.slice(w.index),n.viewFrom=w.lineN,n.viewTo+=r):xi(e)}else if(i>=n.viewTo){var N=zn(e,t,t,-1);N?(n.view=n.view.slice(0,N.index),n.viewTo=N.lineN):xi(e)}else{var V=zn(e,t,t,-1),$=zn(e,i,i+r,1);V&&$?(n.view=n.view.slice(0,V.index).concat(Wt(e,V.lineN,$.lineN)).concat(n.view.slice($.index)),n.viewTo+=r):xi(e)}var J=n.externalMeasured;J&&(i<J.lineN?J.lineN+=r:t<J.lineN+J.size&&(n.externalMeasured=null))}function bi(e,t,i){e.curOp.viewChanged=!0;var r=e.display,n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)return;var w=r.view[Ii(e,t)];if(w.node==null)return;var N=w.changes||(w.changes=[]);ce(N,i)==-1&&N.push(i)}function xi(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function zn(e,t,i,r){var n=Ii(e,t),w,N=e.display.view;if(!Dr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var V=e.display.viewFrom,$=0;$<n;$++)V+=N[$].size;if(V!=t){if(r>0){if(n==N.length-1)return null;w=V+N[n].size-t,n++}else w=V-t;t+=w,i+=w}for(;vi(e.doc,i)!=i;){if(n==(r<0?0:N.length-1))return null;i+=r*N[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function Vs(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=Wt(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=Wt(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Ii(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(Wt(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,Ii(e,i)))),r.viewTo=i}function go(e){for(var t=e.display.view,i=0,r=0;r<t.length;r++){var n=t[r];!n.hidden&&(!n.node||n.changes)&&++i}return i}function yn(e){e.display.input.showSelection(e.display.input.prepareSelection())}function vo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),w=r.selection=document.createDocumentFragment(),N=0;N<i.sel.ranges.length;N++){if(!t&&N==i.sel.primIndex)continue;var V=i.sel.ranges[N];if(V.from().line>=e.display.viewTo||V.to().line<e.display.viewFrom)continue;var $=V.empty();($||e.options.showCursorWhenSelecting)&&yo(e,V.head,n),$||Xs(e,V,w)}return r}function yo(e,t,i){var r=ti(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(a("div","\xA0","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var w=i.appendChild(a("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));w.style.display="",w.style.left=r.other.left+"px",w.style.top=r.other.top+"px",w.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Kn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,w=document.createDocumentFragment(),N=to(e.display),V=N.left,$=Math.max(r.sizerWidth,Oi(e)-r.sizer.offsetLeft)-N.right,J=n.direction=="ltr";function se(it,ft,St,bt){ft<0&&(ft=0),ft=Math.round(ft),bt=Math.round(bt),w.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+it+`px;
|
|
top: `+ft+"px; width: "+(St==null?$-it:St)+`px;
|
|
height: `+(bt-ft)+"px"))}function de(it,ft,St){var bt=pt(n,it),_t=bt.text.length,$t,mr;function Jt(or,Pr){return ga(e,We(it,or),"div",bt,Pr)}function Fr(or,Pr,br){var hr=po(e,bt,null,or),sr=Pr=="ltr"==(br=="after")?"left":"right",er=br=="after"?hr.begin:hr.end-(/\s/.test(bt.text.charAt(hr.end-1))?2:1);return Jt(er,sr)[sr]}var Mr=nt(bt,n.direction);return tt(Mr,ft||0,St==null?_t:St,function(or,Pr,br,hr){var sr=br=="ltr",er=Jt(or,sr?"left":"right"),Ir=Jt(Pr-1,sr?"right":"left"),un=ft==null&&or==0,Li=St==null&&Pr==_t,Er=hr==0,li=!Mr||hr==Mr.length-1;if(Ir.top-er.top<=3){var gr=(J?un:Li)&&Er,Xa=(J?Li:un)&&li,mi=gr?V:(sr?er:Ir).left,ji=Xa?$:(sr?Ir:er).right;se(mi,er.top,ji-mi,er.bottom)}else{var Wi,Cr,dn,Ya;sr?(Wi=J&&un&&Er?V:er.left,Cr=J?$:Fr(or,br,"before"),dn=J?V:Fr(Pr,br,"after"),Ya=J&&Li&&li?$:Ir.right):(Wi=J?Fr(or,br,"before"):V,Cr=!J&&un&&Er?$:er.right,dn=!J&&Li&&li?V:Ir.left,Ya=J?Fr(Pr,br,"after"):$),se(Wi,er.top,Cr-Wi,er.bottom),er.bottom<Ir.top&&se(V,er.bottom,null,Ir.top),se(dn,Ir.top,Ya-dn,Ir.bottom)}(!$t||Kn(er,$t)<0)&&($t=er),Kn(Ir,$t)<0&&($t=Ir),(!mr||Kn(er,mr)<0)&&(mr=er),Kn(Ir,mr)<0&&(mr=Ir)}),{start:$t,end:mr}}var xe=t.from(),ye=t.to();if(xe.line==ye.line)de(xe.line,xe.ch,ye.ch);else{var _e=pt(n,xe.line),Fe=pt(n,ye.line),Ke=_r(_e)==_r(Fe),rt=de(xe.line,xe.ch,Ke?_e.text.length+1:null).end,dt=de(ye.line,Ke?0:null,ye.ch).start;Ke&&(rt.top<dt.top-2?(se(rt.right,rt.top,null,rt.bottom),se(V,dt.top,dt.left,dt.bottom)):se(rt.right,rt.top,dt.left-rt.right,rt.bottom)),rt.bottom<dt.top&&se(V,rt.bottom,null,dt.top)}i.appendChild(w)}function Ca(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Zi(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function bo(e){e.state.focused||(e.display.input.focus(),Ta(e))}function xo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Zi(e))},100)}function Ta(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(Ae(e,"focus",e,t),e.state.focused=!0,G(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),M&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Ca(e)}function Zi(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Ae(e,"blur",e,t),e.state.focused=!1,g(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Vn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],w=e.options.lineWrapping,N=void 0,V=0;if(n.hidden)continue;if(W&&F<8){var $=n.node.offsetTop+n.node.offsetHeight;N=$-i,i=$}else{var J=n.node.getBoundingClientRect();N=J.bottom-J.top,!w&&n.text.firstChild&&(V=n.text.firstChild.getBoundingClientRect().right-J.left-1)}var se=n.line.height-N;if((se>.005||se<-.005)&&(Ar(n.line,N),Eo(n.line),n.rest))for(var de=0;de<n.rest.length;de++)Eo(n.rest[de]);if(V>e.display.sizerWidth){var xe=Math.ceil(V/$i(e.display));xe>e.display.maxLineLength&&(e.display.maxLineLength=xe,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function Eo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function Xn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Hn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,w=jr(t,r),N=jr(t,n);if(i&&i.ensure){var V=i.ensure.from.line,$=i.ensure.to.line;V<w?(w=V,N=jr(t,ei(pt(t,V))+e.wrapper.clientHeight)):Math.min($,t.lastLine())>=N&&(w=jr(t,ei(pt(t,$))-e.wrapper.clientHeight),N=$)}return{from:w,to:Math.max(N,w+1)}}function Ys(e,t){if(Ue(e,"scrollCursorIntoView"))return;var i=e.display,r=i.sizer.getBoundingClientRect(),n=null;if(t.top+r.top<0?n=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(n=!1),n!=null&&!x){var w=a("div","\u200B",null,`position: absolute;
|
|
top: `+(t.top-i.viewOffset-Hn(e.display))+`px;
|
|
height: `+(t.bottom-t.top+oi(e)+i.barHeight)+`px;
|
|
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(w),w.scrollIntoView(n),e.display.lineSpace.removeChild(w)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?We(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?We(t.line,t.ch+1,"before"):t);for(var w=0;w<5;w++){var N=!1,V=ti(e,t),$=!i||i==t?V:ti(e,i);n={left:Math.min(V.left,$.left),top:Math.min(V.top,$.top)-r,right:Math.max(V.left,$.left),bottom:Math.max(V.bottom,$.bottom)+r};var J=wa(e,n),se=e.doc.scrollTop,de=e.doc.scrollLeft;if(J.scrollTop!=null&&(xn(e,J.scrollTop),Math.abs(e.doc.scrollTop-se)>1&&(N=!0)),J.scrollLeft!=null&&(Ni(e,J.scrollLeft),Math.abs(e.doc.scrollLeft-de)>1&&(N=!0)),!N)break}return n}function Zs(e,t){var i=wa(e,t);i.scrollTop!=null&&xn(e,i.scrollTop),i.scrollLeft!=null&&Ni(e,i.scrollLeft)}function wa(e,t){var i=e.display,r=Yi(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,w=fa(e),N={};t.bottom-t.top>w&&(t.bottom=t.top+w);var V=e.doc.height+ca(i),$=t.top<r,J=t.bottom>V-r;if(t.top<n)N.scrollTop=$?0:t.top;else if(t.bottom>n+w){var se=Math.min(t.top,(J?V:t.bottom)-w);se!=n&&(N.scrollTop=se)}var de=e.options.fixedGutter?0:i.gutters.offsetWidth,xe=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-de,ye=Oi(e)-i.gutters.offsetWidth,_e=t.right-t.left>ye;return _e&&(t.right=t.left+ye),t.left<10?N.scrollLeft=0:t.left<xe?N.scrollLeft=Math.max(0,t.left+de-(_e?0:10)):t.right>ye+xe-3&&(N.scrollLeft=t.right+(_e?0:10)-ye),N}function La(e,t){if(t==null)return;Yn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Ji(e){Yn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function bn(e,t,i){(t!=null||i!=null)&&Yn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Yn(e),e.curOp.scrollToPos=t}function Yn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=co(e,t.from),r=co(e,t.to);So(e,i,r,t.margin)}}function So(e,t,i,r){var n=wa(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});bn(e,n.scrollLeft,n.scrollTop)}function xn(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;_||Da(e,{top:t}),Co(e,t,!0),_&&Da(e),Cn(e,100)}function Co(e,t,i){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!i)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function Ni(e,t,i,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,Do(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function En(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+ca(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+oi(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var Bi=function(e,t,i){this.cm=i;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),Te(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Te(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,W&&F<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Bi.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var w=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+w)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},Bi.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Bi.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Bi.prototype.zeroWidthHack=function(){var e=l&&!A?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new ae,this.disableVert=new ae},Bi.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),w=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);w!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},Bi.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Sn=function(){};Sn.prototype.update=function(){return{bottom:0,right:0}},Sn.prototype.setScrollLeft=function(){},Sn.prototype.setScrollTop=function(){},Sn.prototype.clear=function(){};function Qi(e,t){t||(t=En(e));var i=e.display.barWidth,r=e.display.barHeight;To(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Vn(e),To(e,En(e)),i=e.display.barWidth,r=e.display.barHeight}function To(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var wo={native:Bi,null:Sn};function Lo(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&g(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new wo[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Te(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?Ni(e,t):xn(e,t)},e),e.display.scrollbars.addClass&&G(e.display.wrapper,e.display.scrollbars.addClass)}var Qs=0;function Ui(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Qs},Yr(e.curOp)}function Fi(e){var t=e.curOp;t&&Wn(t,function(i){for(var r=0;r<i.ops.length;r++)i.ops[r].cm.curOp=null;qs(i)})}function qs(e){for(var t=e.ops,i=0;i<t.length;i++)el(t[i]);for(var r=0;r<t.length;r++)tl(t[r]);for(var n=0;n<t.length;n++)rl(t[n]);for(var w=0;w<t.length;w++)il(t[w]);for(var N=0;N<t.length;N++)nl(t[N])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&jn(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new $n(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&Aa(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Vn(t),e.barMeasure=En(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=io(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+oi(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Oi(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function il(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Ni(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var i=e.focus&&e.focus==P();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Qi(t,e.barMeasure),e.updatedDisplay&&Ra(t,e.barMeasure),e.selectionChanged&&Ca(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&bo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&Ao(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&Co(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Ni(t,e.scrollLeft,!0,!0),e.scrollToPos){var n=$s(t,s(r,e.scrollToPos.from),s(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var w=e.maybeHiddenMarkers,N=e.maybeUnhiddenMarkers;if(w)for(var V=0;V<w.length;++V)w[V].lines.length||Ae(w[V],"hide");if(N)for(var $=0;$<N.length;++$)N[$].lines.length&&Ae(N[$],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Ae(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Ur(e,t){if(e.curOp)return t();Ui(e);try{return t()}finally{Fi(e)}}function fr(e,t){return function(){if(e.curOp)return t.apply(e,arguments);Ui(e);try{return t.apply(e,arguments)}finally{Fi(e)}}}function Sr(e){return function(){if(this.curOp)return e.apply(this,arguments);Ui(this);try{return e.apply(this,arguments)}finally{Fi(this)}}}function pr(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);Ui(t);try{return e.apply(this,arguments)}finally{Fi(t)}}}function Cn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,z(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=et(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(w){if(r.line>=e.display.viewFrom){var N=w.styles,V=w.text.length>e.options.maxHighlightLength?Bt(t.mode,r.state):null,$=he(e,w,r,!0);V&&(r.state=V),w.styles=$.styles;var J=w.styleClasses,se=$.classes;se?w.styleClasses=se:J&&(w.styleClasses=null);for(var de=!N||N.length!=w.styles.length||J!=se&&(!J||!se||J.bgClass!=se.bgClass||J.textClass!=se.textClass),xe=0;!de&&xe<N.length;++xe)de=N[xe]!=w.styles[xe];de&&n.push(r.line),w.stateAfter=r.save(),r.nextLine()}else w.text.length<=e.options.maxHighlightLength&&ct(e,w.text,r),w.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return Cn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&Ur(e,function(){for(var w=0;w<n.length;w++)bi(e,n[w],"text")})}var $n=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Xn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Oi(e),this.force=i,this.dims=xa(e),this.events=[]};$n.prototype.signal=function(e,t){ue(e,t)&&this.events.push(arguments)},$n.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Ae.apply(null,this.events[e])};function ol(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=oi(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=oi(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=P();if(!t||!T(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&T(e.display.lineDiv,r.anchorNode)&&(i.anchorNode=r.anchorNode,i.anchorOffset=r.anchorOffset,i.focusNode=r.focusNode,i.focusOffset=r.focusOffset)}return i}function ll(e){if(!e||!e.activeElt||e.activeElt==P())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&T(document.body,e.anchorNode)&&T(document.body,e.focusNode)){var t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset),i.collapse(!1),t.removeAllRanges(),t.addRange(i),t.extend(e.focusNode,e.focusOffset)}}function Aa(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return xi(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&go(e)==0)return!1;_o(e)&&(xi(e),t.dims=xa(e));var n=r.first+r.size,w=Math.max(t.visible.from-e.options.viewportMargin,r.first),N=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<w&&w-i.viewFrom<20&&(w=Math.max(r.first,i.viewFrom)),i.viewTo>N&&i.viewTo-N<20&&(N=Math.min(n,i.viewTo)),Dr&&(w=vi(e.doc,w),N=Fn(e.doc,N));var V=w!=i.viewFrom||N!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,w,N),i.viewOffset=ei(pt(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var $=go(e);if(!V&&$==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var J=sl(e);return $>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),$>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(J),c(i.cursorDiv),c(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,V&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,Cn(e,400)),i.updateLineNumbers=null,!0}function Ao(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Oi(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+ca(e.display)-fa(e),i.top)}),t.visible=Xn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Xn(e.display,e.doc,i));if(!Aa(e,t))break;Vn(e);var n=En(e);yn(e),Qi(e,n),Ra(e,n),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Da(e,t){var i=new $n(e,t);if(Aa(e,i)){Vn(e),Ao(e,i);var r=En(e);yn(e),Qi(e,r),Ra(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,w=r.lineDiv,N=w.firstChild;function V(_e){var Fe=_e.nextSibling;return M&&l&&e.display.currentWheelTarget==_e?_e.style.display="none":_e.parentNode.removeChild(_e),Fe}for(var $=r.view,J=r.viewFrom,se=0;se<$.length;se++){var de=$[se];if(!de.hidden)if(!de.node||de.node.parentNode!=w){var xe=Ns(e,de,J,i);w.insertBefore(xe,N)}else{for(;N!=de.node;)N=V(N);var ye=n&&t!=null&&t<=J&&de.lineNumber;de.changes&&(ce(de.changes,"gutter")>-1&&(ye=!1),Za(e,de,J,i)),ye&&(c(de.lineNumber),de.lineNumber.appendChild(document.createTextNode(ui(e.options,J)))),N=de.node.nextSibling}J+=de.size}for(;N;)N=V(N)}function _a(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Ra(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+oi(e)+"px"}function Do(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=Ea(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,w=r+"px",N=0;N<i.length;N++)if(!i[N].hidden){e.options.fixedGutter&&(i[N].gutter&&(i[N].gutter.style.left=w),i[N].gutterBackground&&(i[N].gutterBackground.style.left=w));var V=i[N].alignable;if(V)for(var $=0;$<V.length;$++)V[$].style.left=w}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function _o(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=ui(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(a("div",[a("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),w=n.firstChild.offsetWidth,N=n.offsetWidth-w;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(w,r.lineGutter.offsetWidth-N)+1,r.lineNumWidth=r.lineNumInnerWidth+N,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",_a(e.display),!0}return!1}function ka(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var w=e[n],N=null;if(typeof w!="string"&&(N=w.style,w=w.className),w=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:w,style:N})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function Ro(e){var t=e.gutters,i=e.gutterSpecs;c(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],w=n.className,N=n.style,V=t.appendChild(a("div",null,"CodeMirror-gutter "+w));N&&(V.style.cssText=N),w=="CodeMirror-linenumbers"&&(e.lineGutter=V,V.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",_a(e)}function Tn(e){Ro(e.display),kr(e),Do(e)}function dl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=a("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=a("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=E("div",null,"CodeMirror-code"),n.selectionDiv=a("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=a("div",null,"CodeMirror-cursors"),n.measure=a("div",null,"CodeMirror-measure"),n.lineMeasure=a("div",null,"CodeMirror-measure"),n.lineSpace=E("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var w=E("div",[n.lineSpace],"CodeMirror-lines");n.mover=a("div",[w],null,"position: relative"),n.sizer=a("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=a("div",null,null,"position: absolute; height: "+ve+"px; width: 1px;"),n.gutters=a("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=a("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=a("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),W&&F<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!M&&!(_&&o)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=ka(r.gutters,r.lineNumbers),Ro(n),i.init(n)}var Zn=0,Kr=null;W?Kr=-.53:_?Kr=15:v?Kr=-.7:R&&(Kr=-1/3);function ko(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function hl(e){var t=ko(e);return t.x*=Kr,t.y*=Kr,t}function Oo(e,t){var i=ko(t),r=i.x,n=i.y,w=e.display,N=w.scroller,V=N.scrollWidth>N.clientWidth,$=N.scrollHeight>N.clientHeight;if(!(r&&V||n&&$))return;if(n&&l&&M){e:for(var J=t.target,se=w.view;J!=N;J=J.parentNode)for(var de=0;de<se.length;de++)if(se[de].node==J){e.display.currentWheelTarget=J;break e}}if(r&&!_&&!y&&Kr!=null){n&&$&&xn(e,Math.max(0,N.scrollTop+n*Kr)),Ni(e,Math.max(0,N.scrollLeft+r*Kr)),(!n||n&&$)&&ee(t),w.wheelStartX=null;return}if(n&&Kr!=null){var xe=n*Kr,ye=e.doc.scrollTop,_e=ye+w.wrapper.clientHeight;xe<0?ye=Math.max(0,ye+xe-50):_e=Math.min(e.doc.height,_e+xe+50),Da(e,{top:ye,bottom:_e})}Zn<20&&(w.wheelStartX==null?(w.wheelStartX=N.scrollLeft,w.wheelStartY=N.scrollTop,w.wheelDX=r,w.wheelDY=n,setTimeout(function(){if(w.wheelStartX==null)return;var Fe=N.scrollLeft-w.wheelStartX,Ke=N.scrollTop-w.wheelStartY,rt=Ke&&w.wheelDY&&Ke/w.wheelDY||Fe&&w.wheelDX&&Fe/w.wheelDX;if(w.wheelStartX=w.wheelStartY=null,!rt)return;Kr=(Kr*Zn+rt)/(Zn+1),++Zn},200)):(w.wheelDX+=r,w.wheelDY+=n))}var Vr=function(e,t){this.ranges=e,this.primIndex=t};Vr.prototype.primary=function(){return this.ranges[this.primIndex]},Vr.prototype.equals=function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var i=this.ranges[t],r=e.ranges[t];if(!di(i.anchor,r.anchor)||!di(i.head,r.head))return!1}return!0},Vr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new zt(Ai(this.ranges[t].anchor),Ai(this.ranges[t].head));return new Vr(e,this.primIndex)},Vr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Vr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(wt(t,r.from())>=0&&wt(e,r.to())<=0)return i}return-1};var zt=function(e,t){this.anchor=e,this.head=t};zt.prototype.from=function(){return Di(this.anchor,this.head)},zt.prototype.to=function(){return hi(this.anchor,this.head)},zt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function ri(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(xe,ye){return wt(xe.from(),ye.from())}),i=ce(t,n);for(var w=1;w<t.length;w++){var N=t[w],V=t[w-1],$=wt(V.to(),N.from());if(r&&!N.empty()?$>0:$>=0){var J=Di(V.from(),N.from()),se=hi(V.to(),N.to()),de=V.empty()?N.from()==N.head:V.from()==V.head;w<=i&&--i,t.splice(--w,2,new zt(de?se:J,de?J:se))}}return new Vr(t,i)}function Ei(e,t){return new Vr([new zt(e,t||e)],0)}function Si(e){return e.text?We(e.from.line+e.text.length-1,Oe(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Mo(e,t){if(wt(e,t.from)<0)return e;if(wt(e,t.to)<=0)return Si(t);var i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Si(t).ch-t.to.ch),We(i,r)}function Oa(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new zt(Mo(n.anchor,t),Mo(n.head,t)))}return ri(e.cm,i,e.sel.primIndex)}function Po(e,t,i){return e.line==t.line?We(i.line,e.ch-t.ch+i.ch):We(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=We(e.first,0),w=n,N=0;N<t.length;N++){var V=t[N],$=Po(V.from,n,w),J=Po(Si(V),n,w);if(n=V.to,w=J,i=="around"){var se=e.sel.ranges[N],de=wt(se.head,se.anchor)<0;r[N]=new zt(de?J:$,de?$:J)}else r[N]=new zt($,$)}return new Vr(r,e.sel.primIndex)}function Ma(e){e.doc.mode=wr(e.options,e.doc.modeOption),wn(e)}function wn(e){e.doc.iter(function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,Cn(e,100),e.state.modeGen++,e.curOp&&kr(e)}function Io(e,t){return t.from.ch==0&&t.to.ch==0&&Oe(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(dt){return i?i[dt]:null}function w(dt,it,ft){$a(dt,it,ft,r),yr(dt,"change",dt,t)}function N(dt,it){for(var ft=[],St=dt;St<it;++St)ft.push(new ki(J[St],n(St),r));return ft}var V=t.from,$=t.to,J=t.text,se=pt(e,V.line),de=pt(e,$.line),xe=Oe(J),ye=n(J.length-1),_e=$.line-V.line;if(t.full)e.insert(0,N(0,J.length)),e.remove(J.length,e.size-J.length);else if(Io(e,t)){var Fe=N(0,J.length-1);w(de,de.text,ye),_e&&e.remove(V.line,_e),Fe.length&&e.insert(V.line,Fe)}else if(se==de)if(J.length==1)w(se,se.text.slice(0,V.ch)+xe+se.text.slice($.ch),ye);else{var Ke=N(1,J.length-1);Ke.push(new ki(xe+se.text.slice($.ch),ye,r)),w(se,se.text.slice(0,V.ch)+J[0],n(0)),e.insert(V.line+1,Ke)}else if(J.length==1)w(se,se.text.slice(0,V.ch)+J[0]+de.text.slice($.ch),n(0)),e.remove(V.line+1,_e);else{w(se,se.text.slice(0,V.ch)+J[0],n(0)),w(de,xe+de.text.slice($.ch),ye);var rt=N(1,J.length-1);_e>1&&e.remove(V.line+1,_e-1),e.insert(V.line+1,rt)}yr(e,"change",e,t)}function Ci(e,t,i){function r(n,w,N){if(n.linked)for(var V=0;V<n.linked.length;++V){var $=n.linked[V];if($.doc==w)continue;var J=N&&$.sharedHist;if(i&&!J)continue;t($.doc,J),r($.doc,n,J)}}r(e,null,!0)}function No(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Sa(e),Ma(e),Bo(e),e.options.lineWrapping||jn(e),e.options.mode=t.modeOption,kr(e)}function Bo(e){(e.doc.direction=="rtl"?G:g)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Ur(e,function(){Bo(e),kr(e)})}function Jn(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ia(e,t){var i={from:Ai(t.from),to:Si(t),text:ur(e,t.from,t.to)};return jo(e,i,t.from.line,t.to.line+1),Ci(e,function(r){return jo(r,i,t.from.line,t.to.line+1)},!0),i}function Uo(e){for(;e.length;){var t=Oe(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return Uo(e.done),Oe(e.done);if(e.done.length&&!Oe(e.done).ranges)return Oe(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Oe(e.done)}function Fo(e,t,i,r){var n=e.history;n.undone.length=0;var w=+new Date,N,V;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>w-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(N=pl(n,n.lastOp==r)))V=Oe(N.changes),wt(t.from,t.to)==0&&wt(t.from,V.to)==0?V.to=Si(t):N.changes.push(Ia(e,t));else{var $=Oe(n.done);for((!$||!$.ranges)&&Qn(e.sel,n.done),N={changes:[Ia(e,t)],generation:n.generation},n.done.push(N);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=w,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,V||Ae(e,"historyAdded")}function ml(e,t,i,r){var n=t.charAt(0);return n=="*"||n=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function gl(e,t,i,r){var n=e.history,w=r&&r.origin;i==n.lastSelOp||w&&n.lastSelOrigin==w&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==w||ml(e,w,Oe(n.done),t))?n.done[n.done.length-1]=t:Qn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=w,n.lastSelOp=i,r&&r.clearRedo!==!1&&Uo(n.undone)}function Qn(e,t){var i=Oe(t);i&&i.ranges&&i.equals(e)||t.push(e)}function jo(e,t,i,r){var n=t["spans_"+e.id],w=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(N){N.markedSpans&&((n||(n=t["spans_"+e.id]={}))[w]=N.markedSpans),++w})}function vl(e){if(!e)return null;for(var t,i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function yl(e,t){var i=t["spans_"+e.id];if(!i)return null;for(var r=[],n=0;n<t.text.length;++n)r.push(vl(i[n]));return r}function Wo(e,t){var i=yl(e,t),r=qr(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var w=i[n],N=r[n];if(w&&N){e:for(var V=0;V<N.length;++V){for(var $=N[V],J=0;J<w.length;++J)if(w[J].marker==$.marker)continue e;w.push($)}}else N&&(i[n]=N)}return i}function qi(e,t,i){for(var r=[],n=0;n<e.length;++n){var w=e[n];if(w.ranges){r.push(i?Vr.prototype.deepCopy.call(w):w);continue}var N=w.changes,V=[];r.push({changes:V});for(var $=0;$<N.length;++$){var J=N[$],se=void 0;if(V.push({from:J.from,to:J.to,text:J.text}),t)for(var de in J)(se=de.match(/^spans_(\d+)$/))&&(ce(t,Number(se[1]))>-1&&(Oe(V)[de]=J[de],delete J[de]))}}return r}function Na(e,t,i,r){if(r){var n=e.anchor;if(i){var w=wt(t,n)<0;w!=wt(i,n)<0?(n=t,t=i):w!=wt(t,i)<0&&(t=i)}return new zt(n,t)}else return new zt(i||t,t)}function qn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),xr(e,new Vr([Na(e.sel.primary(),t,i,n)],0),r)}function Ho(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),w=0;w<e.sel.ranges.length;w++)r[w]=Na(e.sel.ranges[w],t[w],null,n);var N=ri(e.cm,r,e.sel.primIndex);xr(e,N,i)}function Ba(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,xr(e,ri(e.cm,n,e.sel.primIndex),r)}function Go(e,t,i,r){xr(e,Ei(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var w=0;w<n.length;w++)this.ranges[w]=new zt(s(e,n[w].anchor),s(e,n[w].head))},origin:i&&i.origin};return Ae(e,"beforeSelectionChange",e,r),e.cm&&Ae(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?ri(e.cm,r.ranges,r.ranges.length-1):t}function zo(e,t,i){var r=e.history.done,n=Oe(r);n&&n.ranges?(r[r.length-1]=t,ea(e,t,i)):xr(e,t,i)}function xr(e,t,i){ea(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function ea(e,t,i){(ue(e,"beforeSelectionChange")||e.cm&&ue(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(wt(t.primary().head,e.sel.primary().head)<0?-1:1);Ko(e,Xo(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Ji(e.cm)}function Ko(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,pe(e.cm)),yr(e,"cursorActivity",e)}function Vo(e){Ko(e,Xo(e,e.sel,null,!1))}function Xo(e,t,i,r){for(var n,w=0;w<t.ranges.length;w++){var N=t.ranges[w],V=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[w],$=ta(e,N.anchor,V&&V.anchor,i,r),J=ta(e,N.head,V&&V.head,i,r);(n||$!=N.anchor||J!=N.head)&&(n||(n=t.ranges.slice(0,w)),n[w]=new zt($,J))}return n?ri(e.cm,n,t.primIndex):t}function en(e,t,i,r,n){var w=pt(e,t.line);if(w.markedSpans)for(var N=0;N<w.markedSpans.length;++N){var V=w.markedSpans[N],$=V.marker,J="selectLeft"in $?!$.selectLeft:$.inclusiveLeft,se="selectRight"in $?!$.selectRight:$.inclusiveRight;if((V.from==null||(J?V.from<=t.ch:V.from<t.ch))&&(V.to==null||(se?V.to>=t.ch:V.to>t.ch))){if(n&&(Ae($,"beforeCursorEnter"),$.explicitlyCleared))if(w.markedSpans){--N;continue}else break;if(!$.atomic)continue;if(i){var de=$.find(r<0?1:-1),xe=void 0;if((r<0?se:J)&&(de=Yo(e,de,-r,de&&de.line==t.line?w:null)),de&&de.line==t.line&&(xe=wt(de,i))&&(r<0?xe<0:xe>0))return en(e,de,t,r,n)}var ye=$.find(r<0?-1:1);return(r<0?J:se)&&(ye=Yo(e,ye,r,ye.line==t.line?w:null)),ye?en(e,ye,t,r,n):null}}return t}function ta(e,t,i,r,n){var w=r||1,N=en(e,t,i,w,n)||!n&&en(e,t,i,w,!0)||en(e,t,i,-w,n)||!n&&en(e,t,i,-w,!0);return N||(e.cantEdit=!0,We(e.first,0))}function Yo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?s(e,We(t.line-1)):null:i>0&&t.ch==(r||pt(e,t.line)).text.length?t.line<e.first+e.size-1?We(t.line+1,0):null:new We(t.line,t.ch+i)}function $o(e){e.setSelection(We(e.firstLine(),0),We(e.lastLine()),Ee)}function Zo(e,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return i&&(r.update=function(n,w,N,V){n&&(r.from=s(e,n)),w&&(r.to=s(e,w)),N&&(r.text=N),V!==void 0&&(r.origin=V)}),Ae(e,"beforeChange",e,r),e.cm&&Ae(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function tn(e,t,i){if(e.cm){if(!e.cm.curOp)return fr(e.cm,tn)(e,t,i);if(e.cm.state.suppressEdits)return}if((ue(e,"beforeChange")||e.cm&&ue(e.cm,"beforeChange"))&&(t=Zo(e,t,!0),!t))return;var r=Hi&&!i&&_i(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)Jo(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else Jo(e,t)}function Jo(e,t){if(t.text.length==1&&t.text[0]==""&&wt(t.from,t.to)==0)return;var i=Oa(e,t);Fo(e,t,i,e.cm?e.cm.curOp.id:NaN),Ln(e,t,i,qr(e,t));var r=[];Ci(e,function(n,w){!w&&ce(r,n.history)==-1&&(ts(n.history,t),r.push(n.history)),Ln(n,t,null,qr(n,t))})}function ra(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,w,N=e.sel,V=t=="undo"?n.done:n.undone,$=t=="undo"?n.undone:n.done,J=0;J<V.length&&!(w=V[J],i?w.ranges&&!w.equals(e.sel):!w.ranges);J++);if(J==V.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(w=V.pop(),w.ranges){if(Qn(w,$),i&&!w.equals(e.sel)){xr(e,w,{clearRedo:!1});return}N=w}else if(r){V.push(w);return}else break;var se=[];Qn(N,$),$.push({changes:se,generation:n.generation}),n.generation=w.generation||++n.maxGeneration;for(var de=ue(e,"beforeChange")||e.cm&&ue(e.cm,"beforeChange"),xe=function(Fe){var Ke=w.changes[Fe];if(Ke.origin=t,de&&!Zo(e,Ke,!1))return V.length=0,{};se.push(Ia(e,Ke));var rt=Fe?Oa(e,Ke):Oe(V);Ln(e,Ke,rt,Wo(e,Ke)),!Fe&&e.cm&&e.cm.scrollIntoView({from:Ke.from,to:Si(Ke)});var dt=[];Ci(e,function(it,ft){!ft&&ce(dt,it.history)==-1&&(ts(it.history,Ke),dt.push(it.history)),Ln(it,Ke,null,Wo(it,Ke))})},ye=w.changes.length-1;ye>=0;--ye){var _e=xe(ye);if(_e)return _e.v}}function Qo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Vr(Ye(e.sel.ranges,function(n){return new zt(We(n.anchor.line+t,n.anchor.ch),We(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){kr(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)bi(e.cm,r,"gutter")}}function Ln(e,t,i,r){if(e.cm&&!e.cm.curOp)return fr(e.cm,Ln)(e,t,i,r);if(t.to.line<e.first){Qo(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var n=t.text.length-1-(e.first-t.from.line);Qo(e,n),t={from:We(e.first,0),to:We(t.to.line+n,t.to.ch),text:[Oe(t.text)],origin:t.origin}}var w=e.lastLine();t.to.line>w&&(t={from:t.from,to:We(w,pt(e,w).text.length),text:[t.text[0]],origin:t.origin}),t.removed=ur(e,t.from,t.to),i||(i=Oa(e,t)),e.cm?xl(e.cm,t,r):Pa(e,t,r),ea(e,i,Ee),e.cantEdit&&ta(e,We(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,w=t.from,N=t.to,V=!1,$=w.line;e.options.lineWrapping||($=Rt(_r(pt(r,w.line))),r.iter($,N.line+1,function(ye){if(ye==n.maxLine)return V=!0,!0})),r.sel.contains(t.from,t.to)>-1&&pe(e),Pa(r,t,i,mo(e)),e.options.lineWrapping||(r.iter($,w.line+t.text.length,function(ye){var _e=Vi(ye);_e>n.maxLineLength&&(n.maxLine=ye,n.maxLineLength=_e,n.maxLineChanged=!0,V=!1)}),V&&(e.curOp.updateMaxLine=!0)),Xr(r,w.line),Cn(e,400);var J=t.text.length-(N.line-w.line)-1;t.full?kr(e):w.line==N.line&&t.text.length==1&&!Io(e.doc,t)?bi(e,w.line,"text"):kr(e,w.line,N.line+1,J);var se=ue(e,"changes"),de=ue(e,"change");if(de||se){var xe={from:w,to:N,text:t.text,removed:t.removed,origin:t.origin};de&&yr(e,"change",e,xe),se&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(xe)}e.display.selForContextMenu=null}function rn(e,t,i,r,n){var w;r||(r=i),wt(r,i)<0&&(w=[r,i],i=w[0],r=w[1]),typeof t=="string"&&(t=e.splitLines(t)),tn(e,{from:i,to:r,text:t,origin:n})}function qo(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function es(e,t,i,r){for(var n=0;n<e.length;++n){var w=e[n],N=!0;if(w.ranges){w.copied||(w=e[n]=w.deepCopy(),w.copied=!0);for(var V=0;V<w.ranges.length;V++)qo(w.ranges[V].anchor,t,i,r),qo(w.ranges[V].head,t,i,r);continue}for(var $=0;$<w.changes.length;++$){var J=w.changes[$];if(i<J.from.line)J.from=We(J.from.line+r,J.from.ch),J.to=We(J.to.line+r,J.to.ch);else if(t<=J.to.line){N=!1;break}}N||(e.splice(0,n+1),n=0)}}function ts(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;es(e.done,i,r,n),es(e.undone,i,r,n)}function An(e,t,i,r){var n=t,w=t;return typeof t=="number"?w=pt(e,H(e,t)):n=Rt(t),n==null?null:(r(w,n)&&e.cm&&bi(e.cm,n,i),w)}function Dn(e){this.lines=e,this.parent=null;for(var t=0,i=0;i<e.length;++i)e[i].parent=this,t+=e[i].height;this.height=t}Dn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var i=e,r=e+t;i<r;++i){var n=this.lines[i];this.height-=n.height,da(n),yr(n,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,i){this.height+=i,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,i){for(var r=e+t;e<r;++e)if(i(this.lines[e]))return!0}};function _n(e){this.children=e;for(var t=0,i=0,r=0;r<e.length;++r){var n=e[r];t+=n.chunkSize(),i+=n.height,n.parent=this}this.size=t,this.height=i,this.parent=null}_n.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var i=0;i<this.children.length;++i){var r=this.children[i],n=r.chunkSize();if(e<n){var w=Math.min(t,n-e),N=r.height;if(r.removeInner(e,w),this.height-=N-r.height,n==w&&(this.children.splice(i--,1),r.parent=null),(t-=w)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Dn))){var V=[];this.collapse(V),this.children=[new Dn(V)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,i){this.size+=t.length,this.height+=i;for(var r=0;r<this.children.length;++r){var n=this.children[r],w=n.chunkSize();if(e<=w){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var N=n.lines.length%25+25,V=N;V<n.lines.length;){var $=new Dn(n.lines.slice(V,V+=25));n.height-=$.height,this.children.splice(++r,0,$),$.parent=this}n.lines=n.lines.slice(0,N),this.maybeSpill()}break}e-=w}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new _n(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=ce(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new _n(e.children);r.parent=e,e.children=[r,i],e=r}i.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,i){for(var r=0;r<this.children.length;++r){var n=this.children[r],w=n.chunkSize();if(e<w){var N=Math.min(t,w-e);if(n.iterN(e,N,i))return!0;if((t-=N)==0)break;e=0}else e-=w}}};var Rn=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};Rn.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=Rt(i);if(r==null||!t)return;for(var n=0;n<t.length;++n)t[n]==this&&t.splice(n--,1);t.length||(i.widgets=null);var w=gn(this);Ar(i,Math.max(0,i.height-w)),e&&(Ur(e,function(){rs(e,i,-w),bi(e,r,"widget")}),yr(e,"lineWidgetCleared",e,this,r))},Rn.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=gn(this)-t;if(!n)return;Br(this.doc,r)||Ar(r,r.height+n),i&&Ur(i,function(){i.curOp.forceUpdate=!0,rs(i,r,n),yr(i,"lineWidgetChanged",i,e,Rt(r))})},fe(Rn);function rs(e,t,i){ei(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&La(e,i)}function El(e,t,i,r){var n=new Rn(e,i,r),w=e.cm;return w&&n.noHScroll&&(w.display.alignWidgets=!0),An(e,t,"widget",function(N){var V=N.widgets||(N.widgets=[]);if(n.insertAt==null?V.push(n):V.splice(Math.min(V.length-1,Math.max(0,n.insertAt)),0,n),n.line=N,w&&!Br(e,N)){var $=ei(N)<e.scrollTop;Ar(N,N.height+gn(n)),$&&La(w,n.height),w.curOp.forceUpdate=!0}return!0}),w&&yr(w,"lineWidgetAdded",w,n,typeof t=="number"?t:Rt(t)),n}var is=0,Ti=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++is};Ti.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&Ui(e),ue(this,"clear")){var i=this.find();i&&yr(this,"clear",i.from,i.to)}for(var r=null,n=null,w=0;w<this.lines.length;++w){var N=this.lines[w],V=Qr(N.markedSpans,this);e&&!this.collapsed?bi(e,Rt(N),"text"):e&&(V.to!=null&&(n=Rt(N)),V.from!=null&&(r=Rt(N))),N.markedSpans=ci(N.markedSpans,V),V.from==null&&this.collapsed&&!Br(this.doc,N)&&e&&Ar(N,Yi(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var $=0;$<this.lines.length;++$){var J=_r(this.lines[$]),se=Vi(J);se>e.display.maxLineLength&&(e.display.maxLine=J,e.display.maxLineLength=se,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&kr(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Vo(e.doc)),e&&yr(e,"markerCleared",e,this,r,n),t&&Fi(e),this.parent&&this.parent.clear()},Ti.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var w=this.lines[n],N=Qr(w.markedSpans,this);if(N.from!=null&&(i=We(t?w:Rt(w),N.from),e==-1))return i;if(N.to!=null&&(r=We(t?w:Rt(w),N.to),e==1))return r}return i&&{from:i,to:r}},Ti.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;Ur(r,function(){var n=t.line,w=Rt(t.line),N=pa(r,w);if(N&&(oo(N),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Br(i.doc,n)&&i.height!=null){var V=i.height;i.height=null;var $=gn(i)-V;$&&Ar(n,n.height+$)}yr(r,"markerChanged",r,e)})},Ti.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||ce(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Ti.prototype.detachLine=function(e){if(this.lines.splice(ce(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},fe(Ti);function nn(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return fr(e.cm,nn)(e,t,i,r,n);var w=new Ti(e,n),N=wt(t,i);if(r&&j(r,w,!1),N>0||N==0&&w.clearWhenEmpty!==!1)return w;if(w.replacedWith&&(w.collapsed=!0,w.widgetNode=E("span",[w.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||w.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(w.widgetNode.insertLeft=!0)),w.collapsed){if(rr(e,t.line,t,i,w)||t.line!=i.line&&rr(e,i.line,t,i,w))throw new Error("Inserting collapsed marker partially overlapping an existing one");Nr()}w.addToHistory&&Fo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var V=t.line,$=e.cm,J;if(e.iter(V,i.line+1,function(de){$&&w.collapsed&&!$.options.lineWrapping&&_r(de)==$.display.maxLine&&(J=!0),w.collapsed&&V!=t.line&&Ar(de,0),ni(de,new gi(w,V==t.line?t.ch:null,V==i.line?i.ch:null)),++V}),w.collapsed&&e.iter(t.line,i.line+1,function(de){Br(e,de)&&Ar(de,0)}),w.clearOnEnter&&Te(w,"beforeCursorEnter",function(){return w.clear()}),w.readOnly&&(Gr(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),w.collapsed&&(w.id=++is,w.atomic=!0),$){if(J&&($.curOp.updateMaxLine=!0),w.collapsed)kr($,t.line,i.line+1);else if(w.className||w.startStyle||w.endStyle||w.css||w.attributes||w.title)for(var se=t.line;se<=i.line;se++)bi($,se,"text");w.atomic&&Vo($.doc),yr($,"markerAdded",$,w)}return w}var kn=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};kn.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();yr(this,"clear")},kn.prototype.find=function(e,t){return this.primary.find(e,t)},fe(kn);function Sl(e,t,i,r,n){r=j(r),r.shared=!1;var w=[nn(e,t,i,r,n)],N=w[0],V=r.widgetNode;return Ci(e,function($){V&&(r.widgetNode=V.cloneNode(!0)),w.push(nn($,s($,t),s($,i),r,n));for(var J=0;J<$.linked.length;++J)if($.linked[J].isParent)return;N=Oe(w)}),new kn(w,N)}function ns(e){return e.findMarks(We(e.first,0),e.clipPos(We(e.lastLine())),function(t){return t.parent})}function Cl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),w=e.clipPos(n.from),N=e.clipPos(n.to);if(wt(w,N)){var V=nn(e,w,N,r.primary,r.primary.type);r.markers.push(V),V.parent=r}}}function Tl(e){for(var t=function(r){var n=e[r],w=[n.primary.doc];Ci(n.primary.doc,function($){return w.push($)});for(var N=0;N<n.markers.length;N++){var V=n.markers[N];ce(w,V.doc)==-1&&(V.parent=null,n.markers.splice(N--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,Or=function(e,t,i,r,n){if(!(this instanceof Or))return new Or(e,t,i,r,n);i==null&&(i=0),_n.call(this,[new Dn([new ki("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var w=We(i,0);this.sel=Ei(w),this.history=new Jn(null),this.id=++wl,this.modeOption=t,this.lineSep=r,this.direction=n=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),Pa(this,{from:w,to:w,text:e}),xr(this,Ei(w),Ee)};Or.prototype=ze(_n.prototype,{constructor:Or,iter:function(e,t,i){i?this.iterN(e-this.first,t-e,i):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var i=0,r=0;r<t.length;++r)i+=t[r].height;this.insertInner(e-this.first,t,i)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Lr(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:pr(function(e){var t=We(this.first,0),i=this.first+this.size-1;tn(this,{from:t,to:We(i,pt(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&bn(this.cm,0,0),xr(this,Ei(t),Ee)}),replaceRange:function(e,t,i,r){t=s(this,t),i=i?s(this,i):t,rn(this,e,t,i,r)},getRange:function(e,t,i){var r=ur(this,s(this,e),s(this,t));return i===!1?r:r.join(i||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Jr(this,e))return pt(this,e)},getLineNumber:function(e){return Rt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=pt(this,e)),_r(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return s(this,e)},getCursor:function(e){var t=this.sel.primary(),i;return e==null||e=="head"?i=t.head:e=="anchor"?i=t.anchor:e=="end"||e=="to"||e===!1?i=t.to():i=t.from(),i},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:pr(function(e,t,i){Go(this,s(this,typeof e=="number"?We(e,t||0):e),null,i)}),setSelection:pr(function(e,t,i){Go(this,s(this,e),s(this,t||e),i)}),extendSelection:pr(function(e,t,i){qn(this,s(this,e),t&&s(this,t),i)}),extendSelections:pr(function(e,t){Ho(this,B(this,e),t)}),extendSelectionsBy:pr(function(e,t){var i=Ye(this.sel.ranges,e);Ho(this,B(this,i),t)}),setSelections:pr(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new zt(s(this,e[n].anchor),s(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),xr(this,ri(this.cm,r,t),i)}),addSelection:pr(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new zt(s(this,e),s(this,t||e))),xr(this,ri(this.cm,r,r.length-1),i)}),getSelection:function(e){for(var t=this.sel.ranges,i,r=0;r<t.length;r++){var n=ur(this,t[r].from(),t[r].to());i=i?i.concat(n):n}return e===!1?i:i.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],i=this.sel.ranges,r=0;r<i.length;r++){var n=ur(this,i[r].from(),i[r].to());e!==!1&&(n=n.join(e||this.lineSeparator())),t[r]=n}return t},replaceSelection:function(e,t,i){for(var r=[],n=0;n<this.sel.ranges.length;n++)r[n]=e;this.replaceSelections(r,t,i||"+input")},replaceSelections:pr(function(e,t,i){for(var r=[],n=this.sel,w=0;w<n.ranges.length;w++){var N=n.ranges[w];r[w]={from:N.from(),to:N.to(),text:this.splitLines(e[w]),origin:i}}for(var V=t&&t!="end"&&cl(this,r,t),$=r.length-1;$>=0;$--)tn(this,r[$]);V?zo(this,V):this.cm&&Ji(this.cm)}),undo:pr(function(){ra(this,"undo")}),redo:pr(function(){ra(this,"redo")}),undoSelection:pr(function(){ra(this,"undo",!0)}),redoSelection:pr(function(){ra(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++i;return{undo:t,redo:i}},clearHistory:function(){var e=this;this.history=new Jn(this.history.maxGeneration),Ci(this,function(t){return t.history=e.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:qi(this.history.done),undone:qi(this.history.undone)}},setHistory:function(e){var t=this.history=new Jn(this.history.maxGeneration);t.done=qi(e.done.slice(0),null,!0),t.undone=qi(e.undone.slice(0),null,!0)},setGutterMarker:pr(function(e,t,i){return An(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&Ge(n)&&(r.gutterMarkers=null),!0})}),clearGutter:pr(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&An(t,i,"gutter",function(){return i.gutterMarkers[e]=null,Ge(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!Jr(this,e))return null;if(t=e,e=pt(this,e),!e)return null}else if(t=Rt(e),t==null)return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:pr(function(e,t,i){return An(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!r[n])r[n]=i;else{if(S(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:pr(function(e,t,i){return An(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",w=r[n];if(w)if(i==null)r[n]=null;else{var N=w.match(S(i));if(!N)return!1;var V=N.index+N[0].length;r[n]=w.slice(0,N.index)+(!N.index||V==w.length?"":" ")+w.slice(V)||null}else return!1;return!0})}),addLineWidget:pr(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return nn(this,s(this,e),s(this,t),i,i&&i.type||"range")},setBookmark:function(e,t){var i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=s(this,e),nn(this,e,e,i,"bookmark")},findMarksAt:function(e){e=s(this,e);var t=[],i=pt(this,e.line).markedSpans;if(i)for(var r=0;r<i.length;++r){var n=i[r];(n.from==null||n.from<=e.ch)&&(n.to==null||n.to>=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=s(this,e),t=s(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(w){var N=w.markedSpans;if(N)for(var V=0;V<N.length;V++){var $=N[V];!($.to!=null&&n==e.line&&e.ch>=$.to||$.from==null&&n!=e.line||$.from!=null&&n==t.line&&$.from>=t.ch)&&(!i||i($.marker))&&r.push($.marker.parent||$.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;r<i.length;++r)i[r].from!=null&&e.push(i[r].marker)}),e},posFromIndex:function(e){var t,i=this.first,r=this.lineSeparator().length;return this.iter(function(n){var w=n.text.length+r;if(w>e)return t=e,!0;e-=w,++i}),s(this,We(i,t))},indexFromPos:function(e){e=s(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var i=this.lineSeparator().length;return this.iter(this.first,e.line,function(r){t+=r.text.length+i}),t},copy:function(e){var t=new Or(Lr(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,i=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<i&&(i=e.to);var r=new Or(Lr(this,t,i),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Cl(r,ns(this)),r},unlinkDoc:function(e){if(e instanceof Zt&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){var i=this.linked[t];if(i.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Tl(ns(this));break}if(e.history==this.history){var r=[e.id];Ci(e,function(n){return r.push(n.id)},!0),e.history=new Jn(null),e.history.done=qi(this.history.done,r),e.history.undone=qi(this.history.undone,r)}},iterLinkedDocs:function(e){Ci(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):vt(e)},lineSeparator:function(){return this.lineSep||`
|
|
`},setDirection:pr(function(e){if(e!="rtl"&&(e="ltr"),e==this.direction)return;this.direction=e,this.iter(function(t){return t.order=null}),this.cm&&fl(this.cm)})}),Or.prototype.eachLine=Or.prototype.iter;var as=0;function Ll(e){var t=this;if(os(t),Ue(t,e)||fi(t.display,e))return;ee(e),W&&(as=+new Date);var i=Pi(t,e,!0),r=e.dataTransfer.files;if(!i||t.isReadOnly())return;if(r&&r.length&&window.FileReader&&window.File)for(var n=r.length,w=Array(n),N=0,V=function(){++N==n&&fr(t,function(){i=s(t.doc,i);var ye={from:i,to:i,text:t.doc.splitLines(w.filter(function(_e){return _e!=null}).join(t.doc.lineSeparator())),origin:"paste"};tn(t.doc,ye),zo(t.doc,Ei(s(t.doc,i),s(t.doc,Si(ye))))})()},$=function(ye,_e){if(t.options.allowDropFileTypes&&ce(t.options.allowDropFileTypes,ye.type)==-1){V();return}var Fe=new FileReader;Fe.onerror=function(){return V()},Fe.onload=function(){var Ke=Fe.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(Ke)){V();return}w[_e]=Ke,V()},Fe.readAsText(ye)},J=0;J<r.length;J++)$(r[J],J);else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var se=e.dataTransfer.getData("Text");if(se){var de;if(t.state.draggingText&&!t.state.draggingText.copy&&(de=t.listSelections()),ea(t.doc,Ei(i,i)),de)for(var xe=0;xe<de.length;++xe)rn(t.doc,"",de[xe].anchor,de[xe].head,"drag");t.replaceSelection(se,"around","paste"),t.display.input.focus()}}catch(ye){}}}function Al(e,t){if(W&&(!e.state.draggingText||+new Date-as<100)){ne(t);return}if(Ue(e,t)||fi(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!R){var i=a("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",y&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),y&&i.parentNode.removeChild(i)}}function Dl(e,t){var i=Pi(e,t);if(!i)return;var r=document.createDocumentFragment();yo(e,i,r),e.display.dragCursor||(e.display.dragCursor=a("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),d(e.display.dragCursor,r)}function os(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function ss(e){if(!document.getElementsByClassName)return;for(var t=document.getElementsByClassName("CodeMirror"),i=[],r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&i.push(n)}i.length&&i[0].operation(function(){for(var w=0;w<i.length;w++)e(i[w])})}var ls=!1;function _l(){if(ls)return;Rl(),ls=!0}function Rl(){var e;Te(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,ss(kl)},100))}),Te(window,"blur",function(){return ss(Zi)})}function kl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var wi={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},On=0;On<10;On++)wi[On+48]=wi[On+96]=String(On);for(var ia=65;ia<=90;ia++)wi[ia]=String.fromCharCode(ia);for(var Mn=1;Mn<=12;Mn++)wi[Mn+111]=wi[Mn+63235]="F"+Mn;var pi={};pi.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},pi.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},pi.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},pi.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},pi.default=l?pi.macDefault:pi.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,w,N=0;N<t.length-1;N++){var V=t[N];if(/^(cmd|meta|m)$/i.test(V))w=!0;else if(/^a(lt)?$/i.test(V))i=!0;else if(/^(c|ctrl|control)$/i.test(V))r=!0;else if(/^s(hift)?$/i.test(V))n=!0;else throw new Error("Unrecognized modifier name: "+V)}return i&&(e="Alt-"+e),r&&(e="Ctrl-"+e),w&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Ml(e){var t={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if(r=="..."){delete e[i];continue}for(var n=Ye(i.split(" "),Ol),w=0;w<n.length;w++){var N=void 0,V=void 0;w==n.length-1?(V=n.join(" "),N=r):(V=n.slice(0,w+1).join(" "),N="...");var $=t[V];if(!$)t[V]=N;else if($!=N)throw new Error("Inconsistent bindings for "+V)}delete e[i]}for(var J in t)e[J]=t[J];return e}function an(e,t,i,r){t=na(t);var n=t.call?t.call(e,r):t[e];if(n===!1)return"nothing";if(n==="...")return"multi";if(n!=null&&i(n))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return an(e,t.fallthrough,i,r);for(var w=0;w<t.fallthrough.length;w++){var N=an(e,t.fallthrough[w],i,r);if(N)return N}}}function us(e){var t=typeof e=="string"?e:wi[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ds(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(p?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(p?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function hs(e,t){if(y&&e.keyCode==34&&e.char)return!1;var i=wi[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),ds(i,e,t))}function na(e){return typeof e=="string"?pi[e]:e}function on(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var w=t(i[n]);r.length&&wt(w.from,Oe(r).to)<=0;){var N=r.pop();if(wt(N.from,w.from)<0){w.from=N.from;break}}r.push(w)}Ur(e,function(){for(var V=r.length-1;V>=0;V--)rn(e.doc,"",r[V].from,r[V].to,"+delete");Ji(e)})}function Ua(e,t,i){var r=Ie(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Fa(e,t,i){var r=Ua(e,t.ch,i);return r==null?null:new We(t.line,r,i<0?"after":"before")}function ja(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var w=nt(i,t.doc.direction);if(w){var N=n<0?Oe(w):w[0],V=n<0==(N.level==1),$=V?"after":"before",J;if(N.level>0||t.doc.direction=="rtl"){var se=Xi(t,i);J=n<0?i.text.length-1:0;var de=si(t,se,J).top;J=lt(function(xe){return si(t,se,xe).top==de},n<0==(N.level==1)?N.from:N.to-1,J),$=="before"&&(J=Ua(i,J,1))}else J=n<0?N.to:N.from;return new We(r,J,$)}}return new We(r,n<0?i.text.length:0,n<0?"before":"after")}function Pl(e,t,i,r){var n=nt(t,e.doc.direction);if(!n)return Fa(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var w=Xe(n,i.ch,i.sticky),N=n[w];if(e.doc.direction=="ltr"&&N.level%2==0&&(r>0?N.to>i.ch:N.from<i.ch))return Fa(t,i,r);var V=function(rt,dt){return Ua(t,rt instanceof We?rt.ch:rt,dt)},$,J=function(rt){return e.options.lineWrapping?($=$||Xi(e,t),po(e,t,$,rt)):{begin:0,end:t.text.length}},se=J(i.sticky=="before"?V(i,-1):i.ch);if(e.doc.direction=="rtl"||N.level==1){var de=N.level==1==r<0,xe=V(i,de?1:-1);if(xe!=null&&(de?xe<=N.to&&xe<=se.end:xe>=N.from&&xe>=se.begin)){var ye=de?"before":"after";return new We(i.line,xe,ye)}}var _e=function(rt,dt,it){for(var ft=function($t,mr){return mr?new We(i.line,V($t,1),"before"):new We(i.line,$t,"after")};rt>=0&&rt<n.length;rt+=dt){var St=n[rt],bt=dt>0==(St.level!=1),_t=bt?it.begin:V(it.end,-1);if(St.from<=_t&&_t<St.to)return ft(_t,bt);if(_t=bt?St.from:V(St.to,-1),it.begin<=_t&&_t<it.end)return ft(_t,bt)}},Fe=_e(w+r,r,se);if(Fe)return Fe;var Ke=r>0?se.end:V(se.begin,-1);return Ke!=null&&!(r>0&&Ke==t.text.length)&&(Fe=_e(r>0?0:n.length-1,r,J(Ke)),Fe)?Fe:null}var Pn={selectAll:$o,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ee)},killLine:function(e){return on(e,function(t){if(t.empty()){var i=pt(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:We(t.head.line+1,0)}:{from:t.head,to:We(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return on(e,function(t){return{from:We(t.from().line,0),to:s(e.doc,We(t.to().line+1,0))}})},delLineLeft:function(e){return on(e,function(t){return{from:We(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return on(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){return on(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div");return{from:t.from(),to:r}})},undo:function(e){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(We(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(We(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return cs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return fs(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return Il(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},Le)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:i},"div")},Le)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return r.ch<e.getLine(r.line).search(/\S/)?fs(e,t.head):r},Le)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],i=e.listSelections(),r=e.options.tabSize,n=0;n<i.length;n++){var w=i[n].from(),N=q(e.getLine(w.line),w.ch,r);t.push(le(r-N%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Ur(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,w=pt(e.doc,n.line).text;if(w){if(n.ch==w.length&&(n=new We(n.line,n.ch-1)),n.ch>0)n=new We(n.line,n.ch+1),e.replaceRange(w.charAt(n.ch-1)+w.charAt(n.ch-2),We(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var N=pt(e.doc,n.line-1).text;N&&(n=new We(n.line,1),e.replaceRange(w.charAt(0)+e.doc.lineSeparator()+N.charAt(N.length-1),We(n.line-1,N.length-1),n,"+transpose"))}}i.push(new zt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Ur(e,function(){for(var t=e.listSelections(),i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(var r=0;r<t.length;r++)e.indentLine(t[r].from().line,null,!0);Ji(e)})},openLine:function(e){return e.replaceSelection(`
|
|
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function cs(e,t){var i=pt(e.doc,t),r=_r(i);return r!=i&&(t=Rt(r)),ja(!0,e,r,t,1)}function Il(e,t){var i=pt(e.doc,t),r=zi(i);return r!=i&&(t=Rt(r)),ja(!0,e,i,t,-1)}function fs(e,t){var i=cs(e,t.line),r=pt(e.doc,i.line),n=nt(r,e.doc.direction);if(!n||n[0].level==0){var w=Math.max(i.ch,r.text.search(/\S/)),N=t.line==i.line&&t.ch<=w&&t.ch;return We(i.line,N?0:w,i.sticky)}return i}function aa(e,t,i){if(typeof t=="string"&&(t=Pn[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,n=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i&&(e.display.shift=!1),n=t(e)!=ke}finally{e.display.shift=r,e.state.suppressEdits=!1}return n}function Nl(e,t,i){for(var r=0;r<e.state.keyMaps.length;r++){var n=an(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&an(t,e.options.extraKeys,i,e)||an(t,e.options.keyMap,i,e)}var Bl=new ae;function In(e,t,i,r){var n=e.state.keySeq;if(n){if(us(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Bl.set(50,function(){e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())}),ps(e,n+" "+t,i,r))return!0}return ps(e,t,i,r)}function ps(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&yr(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(ee(i),Ca(e)),!!n}function ms(e,t){var i=hs(t,!0);return i?t.shiftKey&&!e.state.keySeq?In(e,"Shift-"+i,t,function(r){return aa(e,r,!0)})||In(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return aa(e,r)}):In(e,i,t,function(r){return aa(e,r)}):!1}function Ul(e,t,i){return In(e,"'"+i+"'",t,function(r){return aa(e,r,!0)})}var Wa=null;function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=P(),Ue(t,e))return;W&&F<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=ms(t,e);y&&(Wa=r?i:null,!r&&i==88&&!jt&&(l?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),_&&!l&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Fl(t)}function Fl(e){var t=e.display.lineDiv;G(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(g(t,"CodeMirror-crosshair"),at(document,"keyup",i),at(document,"mouseover",i))}Te(document,"keyup",i),Te(document,"mouseover",i)}function vs(e){e.keyCode==16&&(this.doc.sel.shift=!1),Ue(this,e)}function ys(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(fi(t.display,e)||Ue(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(y&&i==Wa){Wa=null,ee(e);return}if(y&&(!e.which||e.which<10)&&ms(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Ul(t,e,n))return;t.display.input.onKeyPress(e)}var jl=400,Ha=function(e,t,i){this.time=e,this.pos=t,this.button=i};Ha.prototype.compare=function(e,t,i){return this.time+jl>e&&wt(t,this.pos)==0&&i==this.button};var Nn,Bn;function Wl(e,t){var i=+new Date;return Bn&&Bn.compare(i,e,t)?(Nn=Bn=null,"triple"):Nn&&Nn.compare(i,e,t)?(Bn=new Ha(i,e,t),Nn=null,"double"):(Nn=new Ha(i,e,t),Bn=null,"single")}function bs(e){var t=this,i=t.display;if(Ue(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,fi(i,e)){M||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ga(t,e))return;var r=Pi(t,e),n=ge(e),w=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,w,e))return;n==1?r?zl(t,r,w,e):be(e)==i.scroller&&ee(e):n==2?(r&&qn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(D?t.display.input.onContextMenu(e):xo(t))}function Hl(e,t,i,r,n){var w="Click";return r=="double"?w="Double"+w:r=="triple"&&(w="Triple"+w),w=(t==1?"Left":t==2?"Middle":"Right")+w,In(e,ds(w,n),n,function(N){if(typeof N=="string"&&(N=Pn[N]),!N)return!1;var V=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),V=N(e,i)!=ke}finally{e.state.suppressEdits=!1}return V})}function Gl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var w=h?i.shiftKey&&i.metaKey:i.altKey;n.unit=w?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=l?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(l?i.altKey:i.ctrlKey)),n}function zl(e,t,i,r){W?setTimeout(z(bo,e),0):e.curOp.focus=P();var n=Gl(e,i,r),w=e.doc.sel,N;e.options.dragDrop&&Re&&!e.isReadOnly()&&i=="single"&&(N=w.contains(t))>-1&&(wt((N=w.ranges[N]).from(),t)<0||t.xRel>0)&&(wt(N.to(),t)>0||t.xRel<0)?Kl(e,r,t,n):Vl(e,r,t,n)}function Kl(e,t,i,r){var n=e.display,w=!1,N=fr(e,function(J){M&&(n.scroller.draggable=!1),e.state.draggingText=!1,at(n.wrapper.ownerDocument,"mouseup",N),at(n.wrapper.ownerDocument,"mousemove",V),at(n.scroller,"dragstart",$),at(n.scroller,"drop",N),w||(ee(J),r.addNew||qn(e.doc,i,null,null,r.extend),M&&!R||W&&F==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),V=function(J){w=w||Math.abs(t.clientX-J.clientX)+Math.abs(t.clientY-J.clientY)>=10},$=function(){return w=!0};M&&(n.scroller.draggable=!0),e.state.draggingText=N,N.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Te(n.wrapper.ownerDocument,"mouseup",N),Te(n.wrapper.ownerDocument,"mousemove",V),Te(n.scroller,"dragstart",$),Te(n.scroller,"drop",N),xo(e),setTimeout(function(){return n.input.focus()},20)}function xs(e,t,i){if(i=="char")return new zt(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new zt(We(t.line,0),s(e.doc,We(t.line+1,0)));var r=i(e,t);return new zt(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,w=e.doc;ee(t);var N,V,$=w.sel,J=$.ranges;if(r.addNew&&!r.extend?(V=w.sel.contains(i),V>-1?N=J[V]:N=new zt(i,i)):(N=w.sel.primary(),V=w.sel.primIndex),r.unit=="rectangle")r.addNew||(N=new zt(i,i)),i=Pi(e,t,!0,!0),V=-1;else{var se=xs(e,i,r.unit);r.extend?N=Na(N,se.anchor,se.head,r.extend):N=se}r.addNew?V==-1?(V=J.length,xr(w,ri(e,J.concat([N]),V),{scroll:!1,origin:"*mouse"})):J.length>1&&J[V].empty()&&r.unit=="char"&&!r.extend?(xr(w,ri(e,J.slice(0,V).concat(J.slice(V+1)),0),{scroll:!1,origin:"*mouse"}),$=w.sel):Ba(w,V,N,Ce):(V=0,xr(w,new Vr([N],0),Ce),$=w.sel);var de=i;function xe(it){if(wt(de,it)==0)return;if(de=it,r.unit=="rectangle"){for(var ft=[],St=e.options.tabSize,bt=q(pt(w,i.line).text,i.ch,St),_t=q(pt(w,it.line).text,it.ch,St),$t=Math.min(bt,_t),mr=Math.max(bt,_t),Jt=Math.min(i.line,it.line),Fr=Math.min(e.lastLine(),Math.max(i.line,it.line));Jt<=Fr;Jt++){var Mr=pt(w,Jt).text,or=we(Mr,$t,St);$t==mr?ft.push(new zt(We(Jt,or),We(Jt,or))):Mr.length>or&&ft.push(new zt(We(Jt,or),We(Jt,we(Mr,mr,St))))}ft.length||ft.push(new zt(i,i)),xr(w,ri(e,$.ranges.slice(0,V).concat(ft),V),{origin:"*mouse",scroll:!1}),e.scrollIntoView(it)}else{var Pr=N,br=xs(e,it,r.unit),hr=Pr.anchor,sr;wt(br.anchor,hr)>0?(sr=br.head,hr=Di(Pr.from(),br.anchor)):(sr=br.anchor,hr=hi(Pr.to(),br.head));var er=$.ranges.slice(0);er[V]=Xl(e,new zt(s(w,hr),sr)),xr(w,ri(e,er,V),Ce)}}var ye=n.wrapper.getBoundingClientRect(),_e=0;function Fe(it){var ft=++_e,St=Pi(e,it,!0,r.unit=="rectangle");if(!St)return;if(wt(St,de)!=0){e.curOp.focus=P(),xe(St);var bt=Xn(n,w);(St.line>=bt.to||St.line<bt.from)&&setTimeout(fr(e,function(){_e==ft&&Fe(it)}),150)}else{var _t=it.clientY<ye.top?-20:it.clientY>ye.bottom?20:0;_t&&setTimeout(fr(e,function(){if(_e!=ft)return;n.scroller.scrollTop+=_t,Fe(it)}),50)}}function Ke(it){e.state.selectingText=!1,_e=Infinity,it&&(ee(it),n.input.focus()),at(n.wrapper.ownerDocument,"mousemove",rt),at(n.wrapper.ownerDocument,"mouseup",dt),w.history.lastSelOrigin=null}var rt=fr(e,function(it){it.buttons===0||!ge(it)?Ke(it):Fe(it)}),dt=fr(e,Ke);e.state.selectingText=dt,Te(n.wrapper.ownerDocument,"mousemove",rt),Te(n.wrapper.ownerDocument,"mouseup",dt)}function Xl(e,t){var i=t.anchor,r=t.head,n=pt(e.doc,i.line);if(wt(i,r)==0&&i.sticky==r.sticky)return t;var w=nt(n);if(!w)return t;var N=Xe(w,i.ch,i.sticky),V=w[N];if(V.from!=i.ch&&V.to!=i.ch)return t;var $=N+(V.from==i.ch==(V.level!=1)?0:1);if($==0||$==w.length)return t;var J;if(r.line!=i.line)J=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var se=Xe(w,r.ch,r.sticky),de=se-N||(r.ch-i.ch)*(V.level==1?-1:1);se==$-1||se==$?J=de<0:J=de>0}var xe=w[$+(J?-1:0)],ye=J==(xe.level==1),_e=ye?xe.from:xe.to,Fe=ye?"after":"before";return i.ch==_e&&i.sticky==Fe?t:new zt(new We(i.line,_e,Fe),r)}function Es(e,t,i,r){var n,w;if(t.touches)n=t.touches[0].clientX,w=t.touches[0].clientY;else try{n=t.clientX,w=t.clientY}catch(xe){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ee(t);var N=e.display,V=N.lineDiv.getBoundingClientRect();if(w>V.bottom||!ue(e,i))return ie(t);w-=V.top-N.viewOffset;for(var $=0;$<e.display.gutterSpecs.length;++$){var J=N.gutters.childNodes[$];if(J&&J.getBoundingClientRect().right>=n){var se=jr(e.doc,w),de=e.display.gutterSpecs[$];return Ae(e,i,e,se,de.className,t),ie(t)}}}function Ga(e,t){return Es(e,t,"gutterClick",!0)}function Ss(e,t){if(fi(e.display,t)||Yl(e,t))return;if(Ue(e,t,"contextmenu"))return;D||e.display.input.onContextMenu(t)}function Yl(e,t){return ue(e,"gutterContextMenu")?Es(e,t,"gutterContextMenu",!1):!1}function Cs(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),vn(e)}var sn={toString:function(){return"CodeMirror.Init"}},Ts={},oa={};function $l(e){var t=e.optionHandlers;function i(r,n,w,N){e.defaults[r]=n,w&&(t[r]=N?function(V,$,J){J!=sn&&w(V,$,J)}:w)}e.defineOption=i,e.Init=sn,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,Ma(r)},!0),i("indentUnit",2,Ma,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){wn(r),vn(r),kr(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var w=[],N=r.doc.first;r.doc.iter(function($){for(var J=0;;){var se=$.text.indexOf(n,J);if(se==-1)break;J=se+n.length,w.push(We(N,se))}N++});for(var V=w.length-1;V>=0;V--)rn(r.doc,n,w[V],We(w[V].line,w[V].ch+n.length))}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,n,w){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),w!=sn&&r.refresh()}),i("specialCharPlaceholder",Ft,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",o?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!L),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Cs(r),Tn(r)},!0),i("keyMap","default",function(r,n,w){var N=na(n),V=w!=sn&&na(w);V&&V.detach&&V.detach(r,N),N.attach&&N.attach(r,V||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Jl,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=ka(n,r.options.lineNumbers),Tn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?Ea(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Qi(r)},!0),i("scrollbarStyle","native",function(r){Lo(r),Qi(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=ka(r.options.gutters,n),Tn(r)},!0),i("firstLineNumber",1,Tn,!0),i("lineNumberFormatter",function(r){return r},Tn,!0),i("showCursorWhenSelecting",!1,yn,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Zi(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,Zl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,yn,!0),i("singleCursorHeightPerLine",!0,yn,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,wn,!0),i("addModeClass",!1,wn,!0),i("pollInterval",100),i("undoDepth",200,function(r,n){return r.doc.history.undoDepth=n}),i("historyEventDelay",1250),i("viewportMargin",10,function(r){return r.refresh()},!0),i("maxHighlightLength",1e4,wn,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function Zl(e,t,i){var r=i&&i!=sn;if(!t!=!r){var n=e.display.dragFunctions,w=t?Te:at;w(e.display.scroller,"dragstart",n.start),w(e.display.scroller,"dragenter",n.enter),w(e.display.scroller,"dragover",n.over),w(e.display.scroller,"dragleave",n.leave),w(e.display.scroller,"drop",n.drop)}}function Jl(e){e.options.lineWrapping?(G(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(g(e.display.wrapper,"CodeMirror-wrap"),jn(e)),Sa(e),kr(e),vn(e),setTimeout(function(){return Qi(e)},100)}function Zt(e,t){var i=this;if(!(this instanceof Zt))return new Zt(e,t);this.options=t=t?j(t):{},j(Ts,t,!1);var r=t.value;typeof r=="string"?r=new Or(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Zt.inputStyles[t.inputStyle](this),w=this.display=new dl(e,r,n,t);w.wrapper.CodeMirror=this,Cs(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Lo(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new ae,keySeq:null,specialChars:null},t.autofocus&&!o&&w.input.focus(),W&&F<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),_l(),Ui(this),this.curOp.forceUpdate=!0,No(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Zi(this);for(var N in oa)oa.hasOwnProperty(N)&&oa[N](this,t[N],sn);_o(this),t.finishInit&&t.finishInit(this);for(var V=0;V<za.length;++V)za[V](this);Fi(this),M&&t.lineWrapping&&getComputedStyle(w.lineDiv).textRendering=="optimizelegibility"&&(w.lineDiv.style.textRendering="auto")}Zt.defaults=Ts,Zt.optionHandlers=oa;function Ql(e){var t=e.display;Te(t.scroller,"mousedown",fr(e,bs)),W&&F<11?Te(t.scroller,"dblclick",fr(e,function($){if(Ue(e,$))return;var J=Pi(e,$);if(!J||Ga(e,$)||fi(e.display,$))return;ee($);var se=e.findWordAt(J);qn(e.doc,se.anchor,se.head)})):Te(t.scroller,"dblclick",function($){return Ue(e,$)||ee($)}),Te(t.scroller,"contextmenu",function($){return Ss(e,$)}),Te(t.input.getField(),"contextmenu",function($){t.scroller.contains($.target)||Ss(e,$)});var i,r={end:0};function n(){t.activeTouch&&(i=setTimeout(function(){return t.activeTouch=null},1e3),r=t.activeTouch,r.end=+new Date)}function w($){if($.touches.length!=1)return!1;var J=$.touches[0];return J.radiusX<=1&&J.radiusY<=1}function N($,J){if(J.left==null)return!0;var se=J.left-$.left,de=J.top-$.top;return se*se+de*de>20*20}Te(t.scroller,"touchstart",function($){if(!Ue(e,$)&&!w($)&&!Ga(e,$)){t.input.ensurePolled(),clearTimeout(i);var J=+new Date;t.activeTouch={start:J,moved:!1,prev:J-r.end<=300?r:null},$.touches.length==1&&(t.activeTouch.left=$.touches[0].pageX,t.activeTouch.top=$.touches[0].pageY)}}),Te(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Te(t.scroller,"touchend",function($){var J=t.activeTouch;if(J&&!fi(t,$)&&J.left!=null&&!J.moved&&new Date-J.start<300){var se=e.coordsChar(t.activeTouch,"page"),de;!J.prev||N(J,J.prev)?de=new zt(se,se):!J.prev.prev||N(J,J.prev.prev)?de=e.findWordAt(se):de=new zt(We(se.line,0),s(e.doc,We(se.line+1,0))),e.setSelection(de.anchor,de.head),e.focus(),ee($)}n()}),Te(t.scroller,"touchcancel",n),Te(t.scroller,"scroll",function(){t.scroller.clientHeight&&(xn(e,t.scroller.scrollTop),Ni(e,t.scroller.scrollLeft,!0),Ae(e,"scroll",e))}),Te(t.scroller,"mousewheel",function($){return Oo(e,$)}),Te(t.scroller,"DOMMouseScroll",function($){return Oo(e,$)}),Te(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function($){Ue(e,$)||ne($)},over:function($){Ue(e,$)||(Dl(e,$),ne($))},start:function($){return Al(e,$)},drop:fr(e,Ll),leave:function($){Ue(e,$)||os(e)}};var V=t.input.getField();Te(V,"keyup",function($){return vs.call(e,$)}),Te(V,"keydown",fr(e,gs)),Te(V,"keypress",fr(e,ys)),Te(V,"focus",function($){return Ta(e,$)}),Te(V,"blur",function($){return Zi(e,$)})}var za=[];Zt.defineInitHook=function(e){return za.push(e)};function Un(e,t,i,r){var n=e.doc,w;i==null&&(i="add"),i=="smart"&&(n.mode.indent?w=et(e,t).state:i="prev");var N=e.options.tabSize,V=pt(n,t),$=q(V.text,null,N);V.stateAfter&&(V.stateAfter=null);var J=V.text.match(/^\s*/)[0],se;if(!r&&!/\S/.test(V.text))se=0,i="not";else if(i=="smart"&&(se=n.mode.indent(w,V.text.slice(J.length),V.text),se==ke||se>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?se=q(pt(n,t-1).text,null,N):se=0:i=="add"?se=$+e.options.indentUnit:i=="subtract"?se=$-e.options.indentUnit:typeof i=="number"&&(se=$+i),se=Math.max(0,se);var de="",xe=0;if(e.options.indentWithTabs)for(var ye=Math.floor(se/N);ye;--ye)xe+=N,de+=" ";if(xe<se&&(de+=le(se-xe)),de!=J)return rn(n,de,We(t,0),We(t,J.length),"+input"),V.stateAfter=null,!0;for(var _e=0;_e<n.sel.ranges.length;_e++){var Fe=n.sel.ranges[_e];if(Fe.head.line==t&&Fe.head.ch<J.length){var Ke=We(t,J.length);Ba(n,_e,new zt(Ke,Ke));break}}}var ii=null;function sa(e){ii=e}function Ka(e,t,i,r,n){var w=e.doc;e.display.shift=!1,r||(r=w.sel);var N=+new Date-200,V=n=="paste"||e.state.pasteIncoming>N,$=vt(t),J=null;if(V&&r.ranges.length>1)if(ii&&ii.text.join(`
|
|
`)==t){if(r.ranges.length%ii.text.length==0){J=[];for(var se=0;se<ii.text.length;se++)J.push(w.splitLines(ii.text[se]))}}else $.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(J=Ye($,function(rt){return[rt]}));for(var de=e.curOp.updateInput,xe=r.ranges.length-1;xe>=0;xe--){var ye=r.ranges[xe],_e=ye.from(),Fe=ye.to();ye.empty()&&(i&&i>0?_e=We(_e.line,_e.ch-i):e.state.overwrite&&!V?Fe=We(Fe.line,Math.min(pt(w,Fe.line).text.length,Fe.ch+Oe($).length)):V&&ii&&ii.lineWise&&ii.text.join(`
|
|
`)==$.join(`
|
|
`)&&(_e=Fe=We(_e.line,0)));var Ke={from:_e,to:Fe,text:J?J[xe%J.length]:$,origin:n||(V?"paste":e.state.cutIncoming>N?"cut":"+input")};tn(e.doc,Ke),yr(e,"inputRead",e,Ke)}t&&!V&&Ls(e,t),Ji(e),e.curOp.updateInput<2&&(e.curOp.updateInput=de),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function ws(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&Ur(t,function(){return Ka(t,i,0,null,"paste")}),!0}function Ls(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;for(var i=e.doc.sel,r=i.ranges.length-1;r>=0;r--){var n=i.ranges[r];if(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)continue;var w=e.getModeAt(n.head),N=!1;if(w.electricChars){for(var V=0;V<w.electricChars.length;V++)if(t.indexOf(w.electricChars.charAt(V))>-1){N=Un(e,n.head.line,"smart");break}}else w.electricInput&&(w.electricInput.test(pt(e.doc,n.head.line).text.slice(0,n.head.ch))&&(N=Un(e,n.head.line,"smart")));N&&yr(e,"electricInput",e,n.head.line)}}function As(e){for(var t=[],i=[],r=0;r<e.doc.sel.ranges.length;r++){var n=e.doc.sel.ranges[r].head.line,w={anchor:We(n,0),head:We(n+1,0)};i.push(w),t.push(e.getRange(w.anchor,w.head))}return{text:t,ranges:i}}function Ds(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function _s(){var e=a("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=a("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return M?e.style.width="1000px":e.setAttribute("wrap","off"),C&&(e.style.border="1px solid black"),Ds(e),t}function ql(e){var t=e.optionHandlers,i=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,n){var w=this.options,N=w[r];if(w[r]==n&&r!="mode")return;w[r]=n,t.hasOwnProperty(r)&&fr(this,t[r])(this,n,N),Ae(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,n){this.state.keyMaps[n?"push":"unshift"](na(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,w=0;w<n.length;++w)if(n[w]==r||n[w].name==r)return n.splice(w,1),!0},addOverlay:Sr(function(r,n){var w=r.token?r:e.getMode(this.options,r);if(w.startState)throw new Error("Overlays may not be stateful.");Ve(this.state.overlays,{mode:w,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(N){return N.priority}),this.state.modeGen++,kr(this)}),removeOverlay:Sr(function(r){for(var n=this.state.overlays,w=0;w<n.length;++w){var N=n[w].modeSpec;if(N==r||typeof r=="string"&&N.name==r){n.splice(w,1),this.state.modeGen++,kr(this);return}}}),indentLine:Sr(function(r,n,w){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),Jr(this.doc,r)&&Un(this,r,n,w)}),indentSelection:Sr(function(r){for(var n=this.doc.sel.ranges,w=-1,N=0;N<n.length;N++){var V=n[N];if(V.empty())V.head.line>w&&(Un(this,V.head.line,r,!0),w=V.head.line,N==this.doc.sel.primIndex&&Ji(this));else{var $=V.from(),J=V.to(),se=Math.max(w,$.line);w=Math.min(this.lastLine(),J.line-(J.ch?0:1))+1;for(var de=se;de<w;++de)Un(this,de,r);var xe=this.doc.sel.ranges;$.ch==0&&n.length==xe.length&&xe[N].from().ch>0&&Ba(this.doc,N,new zt($,xe[N].to()),Ee)}}}),getTokenAt:function(r,n){return Yt(this,r,n)},getLineTokens:function(r,n){return Yt(this,We(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=Pe(this,pt(this.doc,r.line)),w=0,N=(n.length-1)/2,V=r.ch,$;if(V==0)$=n[2];else for(;;){var J=w+N>>1;if((J?n[J*2-1]:0)>=V)N=J;else if(n[J*2+1]<V)w=J+1;else{$=n[J*2+2];break}}var se=$?$.indexOf("overlay "):-1;return se<0?$:se==0?null:$.slice(0,se-1)},getModeAt:function(r){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(r).state).mode:n},getHelper:function(r,n){return this.getHelpers(r,n)[0]},getHelpers:function(r,n){var w=[];if(!i.hasOwnProperty(n))return w;var N=i[n],V=this.getModeAt(r);if(typeof V[n]=="string")N[V[n]]&&w.push(N[V[n]]);else if(V[n])for(var $=0;$<V[n].length;$++){var J=N[V[n][$]];J&&w.push(J)}else V.helperType&&N[V.helperType]?w.push(N[V.helperType]):N[V.name]&&w.push(N[V.name]);for(var se=0;se<N._global.length;se++){var de=N._global[se];de.pred(V,this)&&ce(w,de.val)==-1&&w.push(de.val)}return w},getStateAfter:function(r,n){var w=this.doc;return r=H(w,r==null?w.first+w.size-1:r),et(this,r+1,n).state},cursorCoords:function(r,n){var w,N=this.doc.sel.primary();return r==null?w=N.head:typeof r=="object"?w=s(this.doc,r):w=r?N.from():N.to(),ti(this,w,n||"page")},charCoords:function(r,n){return ga(this,s(this.doc,r),n||"page")},coordsChar:function(r,n){return r=ho(this,r,n||"page"),ya(this,r.left,r.top)},lineAtHeight:function(r,n){return r=ho(this,{top:r,left:0},n||"page").top,jr(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,w){var N=!1,V;if(typeof r=="number"){var $=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>$&&(r=$,N=!0),V=pt(this.doc,r)}else V=r;return Gn(this,V,{top:0,left:0},n||"page",w||N).top+(N?this.doc.height-ei(V):0)},defaultTextHeight:function(){return Yi(this.display)},defaultCharWidth:function(){return $i(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,w,N,V){var $=this.display;r=ti(this,s(this.doc,r));var J=r.bottom,se=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),$.sizer.appendChild(n),N=="over")J=r.top;else if(N=="above"||N=="near"){var de=Math.max($.wrapper.clientHeight,this.doc.height),xe=Math.max($.sizer.clientWidth,$.lineSpace.clientWidth);(N=="above"||r.bottom+n.offsetHeight>de)&&r.top>n.offsetHeight?J=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=de&&(J=r.bottom),se+n.offsetWidth>xe&&(se=xe-n.offsetWidth)}n.style.top=J+"px",n.style.left=n.style.right="",V=="right"?(se=$.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(V=="left"?se=0:V=="middle"&&(se=($.sizer.clientWidth-n.offsetWidth)/2),n.style.left=se+"px"),w&&Zs(this,{left:se,top:J,right:se+n.offsetWidth,bottom:J+n.offsetHeight})},triggerOnKeyDown:Sr(gs),triggerOnKeyPress:Sr(ys),triggerOnKeyUp:vs,triggerOnMouseDown:Sr(bs),execCommand:function(r){if(Pn.hasOwnProperty(r))return Pn[r].call(null,this)},triggerElectric:Sr(function(r){Ls(this,r)}),findPosH:function(r,n,w,N){var V=1;n<0&&(V=-1,n=-n);for(var $=s(this.doc,r),J=0;J<n&&!($=Va(this.doc,$,V,w,N),$.hitSide);++J);return $},moveH:Sr(function(r,n){var w=this;this.extendSelectionsBy(function(N){return w.display.shift||w.doc.extend||N.empty()?Va(w.doc,N.head,r,n,w.options.rtlMoveVisually):r<0?N.from():N.to()},Le)}),deleteH:Sr(function(r,n){var w=this.doc.sel,N=this.doc;w.somethingSelected()?N.replaceSelection("",null,"+delete"):on(this,function(V){var $=Va(N,V.head,r,n,!1);return r<0?{from:$,to:V.head}:{from:V.head,to:$}})}),findPosV:function(r,n,w,N){var V=1,$=N;n<0&&(V=-1,n=-n);for(var J=s(this.doc,r),se=0;se<n;++se){var de=ti(this,J,"div");if($==null?$=de.left:de.left=$,J=Rs(this,de,V,w),J.hitSide)break}return J},moveV:Sr(function(r,n){var w=this,N=this.doc,V=[],$=!this.display.shift&&!N.extend&&N.sel.somethingSelected();if(N.extendSelectionsBy(function(se){if($)return r<0?se.from():se.to();var de=ti(w,se.head,"div");se.goalColumn!=null&&(de.left=se.goalColumn),V.push(de.left);var xe=Rs(w,de,r,n);return n=="page"&&se==N.sel.primary()&&La(w,ga(w,xe,"div").top-de.top),xe},Le),V.length)for(var J=0;J<N.sel.ranges.length;J++)N.sel.ranges[J].goalColumn=V[J]}),findWordAt:function(r){var n=this.doc,w=pt(n,r.line).text,N=r.ch,V=r.ch;if(w){var $=this.getHelper(r,"wordChars");(r.sticky=="before"||V==w.length)&&N?--N:++V;for(var J=w.charAt(N),se=Ne(J,$)?function(de){return Ne(de,$)}:/\s/.test(J)?function(de){return/\s/.test(de)}:function(de){return!/\s/.test(de)&&!Ne(de)};N>0&&se(w.charAt(N-1));)--N;for(;V<w.length&&se(w.charAt(V));)++V}return new zt(We(r.line,N),We(r.line,V))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?G(this.display.cursorDiv,"CodeMirror-overwrite"):g(this.display.cursorDiv,"CodeMirror-overwrite"),Ae(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==P()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:Sr(function(r,n){bn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-oi(this)-this.display.barHeight,width:r.scrollWidth-oi(this)-this.display.barWidth,clientHeight:fa(this),clientWidth:Oi(this)}},scrollIntoView:Sr(function(r,n){r==null?(r={from:this.doc.sel.primary().head,to:null},n==null&&(n=this.options.cursorScrollMargin)):typeof r=="number"?r={from:We(r,0),to:null}:r.from==null&&(r={from:r,to:null}),r.to||(r.to=r.from),r.margin=n||0,r.from.line!=null?Js(this,r):So(this,r.from,r.to,r.margin)}),setSize:Sr(function(r,n){var w=this,N=function($){return typeof $=="number"||/^\d+$/.test(String($))?$+"px":$};r!=null&&(this.display.wrapper.style.width=N(r)),n!=null&&(this.display.wrapper.style.height=N(n)),this.options.lineWrapping&&so(this);var V=this.display.viewFrom;this.doc.iter(V,this.display.viewTo,function($){if($.widgets){for(var J=0;J<$.widgets.length;J++)if($.widgets[J].noHScroll){bi(w,V,"widget");break}}++V}),this.curOp.forceUpdate=!0,Ae(this,"refresh",this)}),operation:function(r){return Ur(this,r)},startOperation:function(){return Ui(this)},endOperation:function(){return Fi(this)},refresh:Sr(function(){var r=this.display.cachedTextHeight;kr(this),this.curOp.forceUpdate=!0,vn(this),bn(this,this.doc.scrollLeft,this.doc.scrollTop),_a(this.display),(r==null||Math.abs(r-Yi(this.display))>.5||this.options.lineWrapping)&&Sa(this),Ae(this,"refresh",this)}),swapDoc:Sr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),No(this,r),vn(this),this.display.input.reset(),bn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,yr(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},fe(e),e.registerHelper=function(r,n,w){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=w},e.registerGlobalHelper=function(r,n,w,N){e.registerHelper(r,n,N),i[r]._global.push({pred:w,val:N})}}function Va(e,t,i,r,n){var w=t,N=i,V=pt(e,t.line),$=n&&e.direction=="rtl"?-i:i;function J(){var dt=t.line+$;return dt<e.first||dt>=e.first+e.size?!1:(t=new We(dt,t.ch,t.sticky),V=pt(e,dt))}function se(dt){var it;if(r=="codepoint"){var ft=V.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(ft)?it=null:it=new We(t.line,Math.max(0,Math.min(V.text.length,t.ch+i*(ft>=55296&&ft<56320?2:1))),-i)}else n?it=Pl(e.cm,V,t,i):it=Fa(V,t,i);if(it==null)if(!dt&&J())t=ja(n,e.cm,V,t.line,$);else return!1;else t=it;return!0}if(r=="char"||r=="codepoint")se();else if(r=="column")se(!0);else if(r=="word"||r=="group")for(var de=null,xe=r=="group",ye=e.cm&&e.cm.getHelper(t,"wordChars"),_e=!0;!(i<0&&!se(!_e));_e=!1){var Fe=V.text.charAt(t.ch)||`
|
|
`,Ke=Ne(Fe,ye)?"w":xe&&Fe==`
|
|
`?"n":!xe||/\s/.test(Fe)?null:"p";if(xe&&!_e&&!Ke&&(Ke="s"),de&&de!=Ke){i<0&&(i=1,se(),t.sticky="after");break}if(Ke&&(de=Ke),i>0&&!se(!_e))break}var rt=ta(e,t,w,N,!0);return di(w,rt)&&(rt.hitSide=!0),rt}function Rs(e,t,i,r){var n=e.doc,w=t.left,N;if(r=="page"){var V=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),$=Math.max(V-.5*Yi(e.display),3);N=(i>0?t.bottom:t.top)+i*$}else r=="line"&&(N=i>0?t.bottom+3:t.top-3);for(var J;!(J=ya(e,w,N),!J.outside);){if(i<0?N<=0:N>=n.height){J.hitSide=!0;break}N+=i*5}return J}var Xt=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new ae,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Xt.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;Ds(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function w(V){for(var $=V.target;$;$=$.parentNode){if($==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test($.className))break}return!1}Te(n,"paste",function(V){if(!w(V)||Ue(r,V)||ws(V,r))return;F<=11&&setTimeout(fr(r,function(){return t.updateFromDOM()}),20)}),Te(n,"compositionstart",function(V){t.composing={data:V.data,done:!1}}),Te(n,"compositionupdate",function(V){t.composing||(t.composing={data:V.data,done:!1})}),Te(n,"compositionend",function(V){t.composing&&(V.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Te(n,"touchstart",function(){return i.forceCompositionEnd()}),Te(n,"input",function(){t.composing||t.readFromDOMSoon()});function N(V){if(!w(V)||Ue(r,V))return;if(r.somethingSelected())sa({lineWise:!1,text:r.getSelections()}),V.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var $=As(r);sa({lineWise:!0,text:$.text}),V.type=="cut"&&r.operation(function(){r.setSelections($.ranges,0,Ee),r.replaceSelection("",null,"cut")})}else return;if(V.clipboardData){V.clipboardData.clearData();var J=ii.text.join(`
|
|
`);if(V.clipboardData.setData("Text",J),V.clipboardData.getData("Text")==J){V.preventDefault();return}}var se=_s(),de=se.firstChild;r.display.lineSpace.insertBefore(se,r.display.lineSpace.firstChild),de.value=ii.text.join(`
|
|
`);var xe=document.activeElement;Q(de),setTimeout(function(){r.display.lineSpace.removeChild(se),xe.focus(),xe==n&&i.showPrimarySelection()},50)}Te(n,"copy",N),Te(n,"cut",N)},Xt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Xt.prototype.prepareSelection=function(){var e=vo(this.cm,!1);return e.focus=document.activeElement==this.div,e},Xt.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Xt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Xt.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,i=t.doc.sel.primary(),r=i.from(),n=i.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||n.line<t.display.viewFrom){e.removeAllRanges();return}var w=la(t,e.anchorNode,e.anchorOffset),N=la(t,e.focusNode,e.focusOffset);if(w&&!w.bad&&N&&!N.bad&&wt(Di(w,N),r)==0&&wt(hi(w,N),n)==0)return;var V=t.display.view,$=r.line>=t.display.viewFrom&&ks(t,r)||{node:V[0].measure.map[2],offset:0},J=n.line<t.display.viewTo&&ks(t,n);if(!J){var se=V[V.length-1].measure,de=se.maps?se.maps[se.maps.length-1]:se.map;J={node:de[de.length-1],offset:de[de.length-2]-de[de.length-3]}}if(!$||!J){e.removeAllRanges();return}var xe=e.rangeCount&&e.getRangeAt(0),ye;try{ye=b($.node,$.offset,J.offset,J.node)}catch(_e){}ye&&(!_&&t.state.focused?(e.collapse($.node,$.offset),ye.collapsed||(e.removeAllRanges(),e.addRange(ye))):(e.removeAllRanges(),e.addRange(ye)),xe&&e.anchorNode==null?e.addRange(xe):_&&this.startGracePeriod()),this.rememberSelection()},Xt.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})},20)},Xt.prototype.showMultipleSelections=function(e){d(this.cm.display.cursorDiv,e.cursors),d(this.cm.display.selectionDiv,e.selection)},Xt.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Xt.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return T(this.div,t)},Xt.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Xt.prototype.blur=function(){this.div.blur()},Xt.prototype.getField=function(){return this.div},Xt.prototype.supportsTouch=function(){return!0},Xt.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():Ur(this.cm,function(){return e.cm.curOp.selectionChanged=!0});function t(){e.cm.state.focused&&(e.pollSelection(),e.polling.set(e.cm.options.pollInterval,t))}this.polling.set(this.cm.options.pollInterval,t)},Xt.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Xt.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(u&&v&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var i=la(t,e.anchorNode,e.anchorOffset),r=la(t,e.focusNode,e.focusOffset);i&&r&&Ur(t,function(){xr(t.doc,Ei(i,r),Ee),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},Xt.prototype.pollContent=function(){this.readDOMTimeout!=null&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,i=e.doc.sel.primary(),r=i.from(),n=i.to();if(r.ch==0&&r.line>e.firstLine()&&(r=We(r.line-1,pt(e.doc,r.line-1).length)),n.ch==pt(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=We(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var w,N,V;r.line==t.viewFrom||(w=Ii(e,r.line))==0?(N=Rt(t.view[0].line),V=t.view[0].node):(N=Rt(t.view[w].line),V=t.view[w-1].node.nextSibling);var $=Ii(e,n.line),J,se;if($==t.view.length-1?(J=t.viewTo-1,se=t.lineDiv.lastChild):(J=Rt(t.view[$+1].line)-1,se=t.view[$+1].node.previousSibling),!V)return!1;for(var de=e.doc.splitLines(tu(e,V,se,N,J)),xe=ur(e.doc,We(N,0),We(J,pt(e.doc,J).text.length));de.length>1&&xe.length>1;)if(Oe(de)==Oe(xe))de.pop(),xe.pop(),J--;else if(de[0]==xe[0])de.shift(),xe.shift(),N++;else break;for(var ye=0,_e=0,Fe=de[0],Ke=xe[0],rt=Math.min(Fe.length,Ke.length);ye<rt&&Fe.charCodeAt(ye)==Ke.charCodeAt(ye);)++ye;for(var dt=Oe(de),it=Oe(xe),ft=Math.min(dt.length-(de.length==1?ye:0),it.length-(xe.length==1?ye:0));_e<ft&&dt.charCodeAt(dt.length-_e-1)==it.charCodeAt(it.length-_e-1);)++_e;if(de.length==1&&xe.length==1&&N==r.line)for(;ye&&ye>r.ch&&dt.charCodeAt(dt.length-_e-1)==it.charCodeAt(it.length-_e-1);)ye--,_e++;de[de.length-1]=dt.slice(0,dt.length-_e).replace(/^\u200b+/,""),de[0]=de[0].slice(ye).replace(/\u200b+$/,"");var St=We(N,ye),bt=We(J,xe.length?Oe(xe).length-_e:0);if(de.length>1||de[0]||wt(St,bt))return rn(e.doc,de,St,bt,"+input"),!0},Xt.prototype.ensurePolled=function(){this.forceCompositionEnd()},Xt.prototype.reset=function(){this.forceCompositionEnd()},Xt.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Xt.prototype.readFromDOMSoon=function(){var e=this;if(this.readDOMTimeout!=null)return;this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing)if(e.composing.done)e.composing=null;else return;e.updateFromDOM()},80)},Xt.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Ur(this.cm,function(){return kr(e.cm)})},Xt.prototype.setUneditable=function(e){e.contentEditable="false"},Xt.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||fr(this.cm,Ka)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Xt.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Xt.prototype.onContextMenu=function(){},Xt.prototype.resetPosition=function(){},Xt.prototype.needsContentAttribute=!0;function ks(e,t){var i=pa(e,t.line);if(!i||i.hidden)return null;var r=pt(e.doc,t.line),n=ro(i,r,t.line),w=nt(r,e.doc.direction),N="left";if(w){var V=Xe(w,t.ch);N=V%2?"right":"left"}var $=ao(n.map,t.ch,N);return $.offset=$.collapse=="right"?$.end:$.start,$}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function ln(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var w="",N=!1,V=e.doc.lineSeparator(),$=!1;function J(ye){return function(_e){return _e.id==ye}}function se(){N&&(w+=V,$&&(w+=V),N=$=!1)}function de(ye){ye&&(se(),w+=ye)}function xe(ye){if(ye.nodeType==1){var _e=ye.getAttribute("cm-text");if(_e){de(_e);return}var Fe=ye.getAttribute("cm-marker"),Ke;if(Fe){var rt=e.findMarks(We(r,0),We(n+1,0),J(+Fe));rt.length&&(Ke=rt[0].find(0))&&de(ur(e.doc,Ke.from,Ke.to).join(V));return}if(ye.getAttribute("contenteditable")=="false")return;var dt=/^(pre|div|p|li|table|br)$/i.test(ye.nodeName);if(!/^br$/i.test(ye.nodeName)&&ye.textContent.length==0)return;dt&&se();for(var it=0;it<ye.childNodes.length;it++)xe(ye.childNodes[it]);/^(pre|p)$/i.test(ye.nodeName)&&($=!0),dt&&(N=!0)}else ye.nodeType==3&&de(ye.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(xe(t),t==i);)t=t.nextSibling,$=!1;return w}function la(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return ln(e.clipPos(We(e.display.viewTo-1)),!0);t=null,i=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var n=0;n<e.display.view.length;n++){var w=e.display.view[n];if(w.node==r)return ru(w,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!T(r,t))return ln(We(Rt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var w=e.rest?Oe(e.rest):e.line;return ln(We(Rt(w),w.text.length),n)}var N=t.nodeType==3?t:null,V=t;for(!N&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(N=t.firstChild,i&&(i=N.nodeValue.length));V.parentNode!=r;)V=V.parentNode;var $=e.measure,J=$.maps;function se(Ke,rt,dt){for(var it=-1;it<(J?J.length:0);it++)for(var ft=it<0?$.map:J[it],St=0;St<ft.length;St+=3){var bt=ft[St+2];if(bt==Ke||bt==rt){var _t=Rt(it<0?e.line:e.rest[it]),$t=ft[St]+dt;return(dt<0||bt!=Ke)&&($t=ft[St+(dt?1:0)]),We(_t,$t)}}}var de=se(N,V,i);if(de)return ln(de,n);for(var xe=V.nextSibling,ye=N?N.nodeValue.length-i:0;xe;xe=xe.nextSibling){if(de=se(xe,xe.firstChild,0),de)return ln(We(de.line,de.ch-ye),n);ye+=xe.textContent.length}for(var _e=V.previousSibling,Fe=i;_e;_e=_e.previousSibling){if(de=se(_e,_e.firstChild,-1),de)return ln(We(de.line,de.ch+Fe),n);Fe+=_e.textContent.length}}var ir=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new ae,this.hasSelection=!1,this.composing=null};ir.prototype.init=function(e){var t=this,i=this,r=this.cm;this.createField(e);var n=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),C&&(n.style.width="0px"),Te(n,"input",function(){W&&F>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Te(n,"paste",function(N){if(Ue(r,N)||ws(N,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function w(N){if(Ue(r,N))return;if(r.somethingSelected())sa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var V=As(r);sa({lineWise:!0,text:V.text}),N.type=="cut"?r.setSelections(V.ranges,null,Ee):(i.prevInput="",n.value=V.text.join(`
|
|
`),Q(n))}else return;N.type=="cut"&&(r.state.cutIncoming=+new Date)}Te(n,"cut",w),Te(n,"copy",w),Te(e.scroller,"paste",function(N){if(fi(e,N)||Ue(r,N))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var V=new Event("paste");V.clipboardData=N.clipboardData,n.dispatchEvent(V)}),Te(e.lineSpace,"selectstart",function(N){fi(e,N)||ee(N)}),Te(n,"compositionstart",function(){var N=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:N,range:r.markText(N,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Te(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},ir.prototype.createField=function(e){this.wrapper=_s(),this.textarea=this.wrapper.firstChild},ir.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},ir.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=vo(e);if(e.options.moveInputWithCursor){var n=ti(e,i.sel.primary().head,"div"),w=t.wrapper.getBoundingClientRect(),N=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+N.top-w.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+N.left-w.left))}return r},ir.prototype.showSelection=function(e){var t=this.cm,i=t.display;d(i.cursorDiv,e.cursors),d(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},ir.prototype.reset=function(e){if(this.contextMenuPending||this.composing)return;var t=this.cm;if(t.somethingSelected()){this.prevInput="";var i=t.getSelection();this.textarea.value=i,t.state.focused&&Q(this.textarea),W&&F>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",W&&F>=9&&(this.hasSelection=null))},ir.prototype.getField=function(){return this.textarea},ir.prototype.supportsTouch=function(){return!1},ir.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||P()!=this.textarea))try{this.textarea.focus()}catch(e){}},ir.prototype.blur=function(){this.textarea.blur()},ir.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},ir.prototype.receivedFocus=function(){this.slowPoll()},ir.prototype.slowPoll=function(){var e=this;if(this.pollingFast)return;this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},ir.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function i(){var r=t.poll();!r&&!e?(e=!0,t.polling.set(60,i)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,i)},ir.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||Qe(i)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var n=i.value;if(n==r&&!t.somethingSelected())return!1;if(W&&F>=9&&this.hasSelection===n||l&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var w=n.charCodeAt(0);if(w==8203&&!r&&(r="\u200B"),w==8666)return this.reset(),this.cm.execCommand("undo")}for(var N=0,V=Math.min(r.length,n.length);N<V&&r.charCodeAt(N)==n.charCodeAt(N);)++N;return Ur(t,function(){Ka(t,n.slice(N),r.length-N,null,e.composing?"*compose":null),n.length>1e3||n.indexOf(`
|
|
`)>-1?i.value=e.prevInput="":e.prevInput=n,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ir.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},ir.prototype.onKeyPress=function(){W&&F>=9&&(this.hasSelection=null),this.fastPoll()},ir.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var w=Pi(i,e),N=r.scroller.scrollTop;if(!w||y)return;var V=i.options.resetSelectionOnContextMenu;V&&i.doc.sel.contains(w)==-1&&fr(i,xr)(i.doc,Ei(w),Ee);var $=n.style.cssText,J=t.wrapper.style.cssText,se=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
|
|
top: `+(e.clientY-se.top-5)+"px; left: "+(e.clientX-se.left-5)+`px;
|
|
z-index: 1000; background: `+(W?"rgba(255, 255, 255, .05)":"transparent")+`;
|
|
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var de;M&&(de=window.scrollY),r.input.focus(),M&&window.scrollTo(null,de),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=ye,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function xe(){if(n.selectionStart!=null){var Fe=i.somethingSelected(),Ke="\u200B"+(Fe?n.value:"");n.value="\u21DA",n.value=Ke,t.prevInput=Fe?"":"\u200B",n.selectionStart=1,n.selectionEnd=Ke.length,r.selForContextMenu=i.doc.sel}}function ye(){if(t.contextMenuPending!=ye)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=J,n.style.cssText=$,W&&F<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=N),n.selectionStart!=null){(!W||W&&F<9)&&xe();var Fe=0,Ke=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?fr(i,$o)(i):Fe++<10?r.detectingSelectAll=setTimeout(Ke,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(Ke,200)}}if(W&&F>=9&&xe(),D){ne(e);var _e=function(){at(window,"mouseup",_e),setTimeout(ye,20)};Te(window,"mouseup",_e)}else setTimeout(ye,50)},ir.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},ir.prototype.setUneditable=function(){},ir.prototype.needsContentAttribute=!1;function iu(e,t){if(t=t?j(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=P();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=V.getValue()}var n;if(e.form&&(Te(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var w=e.form;n=w.submit;try{var N=w.submit=function(){r(),w.submit=n,w.submit(),w.submit=N}}catch($){}}t.finishInit=function($){$.save=r,$.getTextArea=function(){return e},$.toTextArea=function(){$.toTextArea=isNaN,r(),e.parentNode.removeChild($.getWrapperElement()),e.style.display="",e.form&&(at(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var V=Zt(function($){return e.parentNode.insertBefore($,e.nextSibling)},t);return V}function nu(e){e.off=at,e.on=Te,e.wheelEventPixels=hl,e.Doc=Or,e.splitLines=vt,e.countColumn=q,e.findColumn=we,e.isWordChar=De,e.Pass=ke,e.signal=Ae,e.Line=ki,e.changeEnd=Si,e.scrollbarModel=wo,e.Pos=We,e.cmpPos=wt,e.modes=Ht,e.mimeModes=Dt,e.resolveMode=yt,e.getMode=wr,e.modeExtensions=tr,e.extendMode=lr,e.copyState=Bt,e.startState=Kt,e.innerMode=Qt,e.commands=Pn,e.keyMap=pi,e.keyName=hs,e.isModifierKey=us,e.lookupKey=an,e.normalizeKeyMap=Ml,e.StringStream=Tt,e.SharedTextMarker=kn,e.TextMarker=Ti,e.LineWidget=Rn,e.e_preventDefault=ee,e.e_stopPropagation=te,e.e_stop=ne,e.addClass=G,e.contains=T,e.rmClass=g,e.keyNames=wi}$l(Zt),ql(Zt);var au="iter insert remove copy getEditor constructor".split(" ");for(var ua in Or.prototype)Or.prototype.hasOwnProperty(ua)&&ce(au,ua)<0&&(Zt.prototype[ua]=function(e){return function(){return e.apply(this.doc,arguments)}}(Or.prototype[ua]));return fe(Or),Zt.inputStyles={textarea:ir,contenteditable:Xt},Zt.defineMode=function(e){!Zt.defaults.mode&&e!="null"&&(Zt.defaults.mode=e),Tr.apply(this,arguments)},Zt.defineMIME=Zr,Zt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Zt.defineMIME("text/plain","null"),Zt.defineExtension=function(e,t){Zt.prototype[e]=t},Zt.defineDocExtension=function(e,t){Or.prototype[e]=t},Zt.fromTextArea=iu,nu(Zt),Zt.version="5.58.2",Zt})},Y1PL:function(Et,ot,re){"use strict";re.r(ot),re.d(ot,"ResizableTextArea",function(){return ce});var oe=re("wx14"),Z=re("1OyB"),_=re("vuIU"),X=re("Ji7U"),O=re("LK+K"),I=re("q1tI"),W=re("VTBJ"),F=re("rePB"),M=re("Zm9Q"),k=re("Kwbf"),v=re("c+Xe"),y=re("m+aA"),R=re("bdgK"),A=new Map;function x(Ee){Ee.forEach(function(Ce){var Le,we=Ce.target;(Le=A.get(we))===null||Le===void 0||Le.forEach(function(me){return me(we)})})}var C=new R.default(x),u=null,o=null;function l(Ee,Ce){A.has(Ee)||(A.set(Ee,new Set),C.observe(Ee)),A.get(Ee).add(Ce)}function h(Ee,Ce){A.has(Ee)&&(A.get(Ee).delete(Ce),A.get(Ee).size||(C.unobserve(Ee),A.delete(Ee)))}var L=function(Ee){Object(X.a)(Le,Ee);var Ce=Object(O.a)(Le);function Le(){return Object(Z.a)(this,Le),Ce.apply(this,arguments)}return Object(_.a)(Le,[{key:"render",value:function(){return this.props.children}}]),Le}(I.Component),f=I.createContext(null);function p(Ee){var Ce=Ee.children,Le=Ee.onBatchResize,we=I.useRef(0),me=I.useRef([]),le=I.useContext(f),Oe=I.useCallback(function(Ye,Ve,$e){we.current+=1;var ze=we.current;me.current.push({size:Ye,element:Ve,data:$e}),Promise.resolve().then(function(){ze===we.current&&(Le==null||Le(me.current),me.current=[])}),le==null||le(Ye,Ve,$e)},[Le,le]);return I.createElement(f.Provider,{value:Oe},Ce)}function D(Ee){var Ce=Ee.children,Le=Ee.disabled,we=I.useRef(null),me=I.useRef(null),le=I.useContext(f),Oe=I.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Ye=I.isValidElement(Ce)&&Object(v.c)(Ce),Ve=Ye?Ce.ref:null,$e=I.useMemo(function(){return Object(v.a)(Ve,we)},[Ve,we]),ze=I.useRef(Ee);ze.current=Ee;var Se=I.useCallback(function(De){var Ne=ze.current,Ge=Ne.onResize,je=Ne.data,Me=De.getBoundingClientRect(),Ie=Me.width,lt=Me.height,tt=De.offsetWidth,qe=De.offsetHeight,Xe=Math.floor(Ie),ht=Math.floor(lt);if(Oe.current.width!==Xe||Oe.current.height!==ht||Oe.current.offsetWidth!==tt||Oe.current.offsetHeight!==qe){var nt={width:Xe,height:ht,offsetWidth:tt,offsetHeight:qe};Oe.current=nt;var Je=tt===Math.round(Ie)?Ie:tt,Te=qe===Math.round(lt)?lt:qe,ut=Object(W.a)(Object(W.a)({},nt),{},{offsetWidth:Je,offsetHeight:Te});le==null||le(ut,De,je),Ge&&Promise.resolve().then(function(){Ge(ut,De)})}},[]);return I.useEffect(function(){var De=Object(y.a)(we.current)||Object(y.a)(me.current);return De&&!Le&&l(De,Se),function(){return h(De,Se)}},[we.current,Le]),I.createElement(L,{ref:me},Ye?I.cloneElement(Ce,{ref:$e}):Ce)}var S="rc-observer-key";function g(Ee){var Ce=Ee.children,Le=Object(M.a)(Ce);return Le.map(function(we,me){var le=(we==null?void 0:we.key)||"".concat(S,"-").concat(me);return I.createElement(D,Object(oe.a)({},Ee,{key:le}),we)})}g.Collection=p;var c=g,d=re("bT9E"),a=re("TSYQ"),E=re.n(a),b=`
|
|
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={},G;function Y(Ee){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Le=Ee.getAttribute("id")||Ee.getAttribute("data-reactid")||Ee.getAttribute("name");if(Ce&&P[Le])return P[Le];var we=window.getComputedStyle(Ee),me=we.getPropertyValue("box-sizing")||we.getPropertyValue("-moz-box-sizing")||we.getPropertyValue("-webkit-box-sizing"),le=parseFloat(we.getPropertyValue("padding-bottom"))+parseFloat(we.getPropertyValue("padding-top")),Oe=parseFloat(we.getPropertyValue("border-bottom-width"))+parseFloat(we.getPropertyValue("border-top-width")),Ye=T.map(function($e){return"".concat($e,":").concat(we.getPropertyValue($e))}).join(";"),Ve={sizingStyle:Ye,paddingSize:le,borderSize:Oe,boxSizing:me};return Ce&&Le&&(P[Le]=Ve),Ve}function Q(Ee){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Le=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,we=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;G||(G=document.createElement("textarea"),G.setAttribute("tab-index","-1"),G.setAttribute("aria-hidden","true"),document.body.appendChild(G)),Ee.getAttribute("wrap")?G.setAttribute("wrap",Ee.getAttribute("wrap")):G.removeAttribute("wrap");var me=Y(Ee,Ce),le=me.paddingSize,Oe=me.borderSize,Ye=me.boxSizing,Ve=me.sizingStyle;G.setAttribute("style","".concat(Ve,";").concat(b)),G.value=Ee.value||Ee.placeholder||"";var $e=Number.MIN_SAFE_INTEGER,ze=Number.MAX_SAFE_INTEGER,Se=G.scrollHeight,De;if(Ye==="border-box"?Se+=Oe:Ye==="content-box"&&(Se-=le),Le!==null||we!==null){G.value=" ";var Ne=G.scrollHeight-le;Le!==null&&($e=Ne*Le,Ye==="border-box"&&($e=$e+le+Oe),Se=Math.max($e,Se)),we!==null&&(ze=Ne*we,Ye==="border-box"&&(ze=ze+le+Oe),De=Se>ze?"":"hidden",Se=Math.min(ze,Se))}return{height:Se,minHeight:$e,maxHeight:ze,overflowY:De,resize:"none"}}var z=re("Gytx"),j=re.n(z),q;(function(Ee){Ee[Ee.NONE=0]="NONE",Ee[Ee.RESIZING=1]="RESIZING",Ee[Ee.RESIZED=2]="RESIZED"})(q||(q={}));var ae=function(Ee){Object(X.a)(Le,Ee);var Ce=Object(O.a)(Le);function Le(we){var me;return Object(Z.a)(this,Le),me=Ce.call(this,we),me.nextFrameActionId=void 0,me.resizeFrameId=void 0,me.textArea=void 0,me.saveTextArea=function(le){me.textArea=le},me.handleResize=function(le){var Oe=me.state.resizeStatus,Ye=me.props,Ve=Ye.autoSize,$e=Ye.onResize;if(Oe!==q.NONE)return;typeof $e=="function"&&$e(le),Ve&&me.resizeOnNextFrame()},me.resizeOnNextFrame=function(){cancelAnimationFrame(me.nextFrameActionId),me.nextFrameActionId=requestAnimationFrame(me.resizeTextarea)},me.resizeTextarea=function(){var le=me.props.autoSize;if(!le||!me.textArea)return;var Oe=le.minRows,Ye=le.maxRows,Ve=Q(me.textArea,!1,Oe,Ye);me.setState({textareaStyles:Ve,resizeStatus:q.RESIZING},function(){cancelAnimationFrame(me.resizeFrameId),me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:q.RESIZED},function(){me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:q.NONE}),me.fixFirefoxAutoScroll()})})})})},me.renderTextArea=function(){var le=me.props,Oe=le.prefixCls,Ye=Oe===void 0?"rc-textarea":Oe,Ve=le.autoSize,$e=le.onResize,ze=le.className,Se=le.disabled,De=me.state,Ne=De.textareaStyles,Ge=De.resizeStatus,je=Object(d.a)(me.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Me=E()(Ye,ze,Object(F.a)({},"".concat(Ye,"-disabled"),Se));"value"in je&&(je.value=je.value||"");var Ie=Object(W.a)(Object(W.a)(Object(W.a)({},me.props.style),Ne),Ge===q.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return I.createElement(c,{onResize:me.handleResize,disabled:!(Ve||$e)},I.createElement("textarea",Object(oe.a)({},je,{className:Me,style:Ie,ref:me.saveTextArea})))},me.state={textareaStyles:{},resizeStatus:q.NONE},me}return Object(_.a)(Le,[{key:"componentDidUpdate",value:function(me){(me.value!==this.props.value||!j()(me.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 me=this.textArea.selectionStart,le=this.textArea.selectionEnd;this.textArea.setSelectionRange(me,le)}}catch(Oe){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Le}(I.Component),ce=ae,ve=function(Ee){Object(X.a)(Le,Ee);var Ce=Object(O.a)(Le);function Le(we){var me;Object(Z.a)(this,Le),me=Ce.call(this,we),me.resizableTextArea=void 0,me.focus=function(){me.resizableTextArea.textArea.focus()},me.saveTextArea=function(Oe){me.resizableTextArea=Oe},me.handleChange=function(Oe){var Ye=me.props.onChange;me.setValue(Oe.target.value,function(){me.resizableTextArea.resizeTextarea()}),Ye&&Ye(Oe)},me.handleKeyDown=function(Oe){var Ye=me.props,Ve=Ye.onPressEnter,$e=Ye.onKeyDown;Oe.keyCode===13&&Ve&&Ve(Oe),$e&&$e(Oe)};var le=typeof we.value=="undefined"||we.value===null?we.defaultValue:we.value;return me.state={value:le},me}return Object(_.a)(Le,[{key:"setValue",value:function(me,le){"value"in this.props||this.setState({value:me},le)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return I.createElement(ce,Object(oe.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(me){return"value"in me?{value:me.value}:null}}]),Le}(I.Component),ke=ot.default=ve},ZW9T:function(Et,ot,re){"use strict";re.d(ot,"a",function(){return L});var oe=re("k1fw"),Z=re("miYZ"),_=re("tsqr"),X=re("rAM+"),O=re("tJVT"),I=re("PpiC"),W=re("q1tI"),F=re.n(W),M=re("bdgK");function k(f,p,D,S,g){var c=p.getWordUntilPosition(D),d={startLineNumber:D.lineNumber,endLineNumber:D.lineNumber,startColumn:c.startColumn,endColumn:c.endColumn},a=S.map(function(E){return{label:E,kind:f.languages.CompletionItemKind.Keyword,insertText:E,insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:d}});return g.map(function(E){a.push(Object(oe.a)(Object(oe.a)({},E),{},{range:d}))}),a}var v=function(f){var p={label:"ifelse",kind:f.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {"," $0","} else {"," ","}"].join(`
|
|
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet},D=["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"];f.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(d,a){var E=k(f,d,a,D,[p]);return{suggestions:E}}});var S=["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"];f.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(d,a){var E=[{label:"print",kind:f.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join(`
|
|
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet}],b=k(f,d,a,S,E);return{suggestions:b}}});var g=["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"];f.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(d,a){var E=[p,{label:"main",kind:f.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {"," $0","}"].join(`
|
|
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:f.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join(`
|
|
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet}],b=k(f,d,a,g,E);return{suggestions:b}}})},y="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",R=re("LvDl");function A(f){return/^\d+$/.test(f)?"".concat(f,"px"):f}function x(){}var C=!1,u={"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 o(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],p=f;if(Array.isArray(f)){for(var D=0;D<f.length;D++){var S=u[f[D]];if(S)return S}return p[0]}return u[p]||p}var l=null,h=ot.b=function(f){var p=f.width,D=p===void 0?"100%":p,S=f.height,g=S===void 0?"100%":S,c=f.value,d=f.language,a=d===void 0?"javascript":d,E=f.style,b=E===void 0?{}:E,T=f.options,P=T===void 0?{}:T,G=f.overrideServices,Y=G===void 0?{}:G,Q=f.theme,z=Q===void 0?"vs-dark":Q,j=f.onEditBlur,q=f.onSave,ae=f.autoHeight,ce=ae===void 0?!1:ae,ve=f.forbidCopy,ke=ve===void 0?!1:ve,Ee=f.onChange,Ce=Ee===void 0?x:Ee,Le=f.editorDidMount,we=Le===void 0?x:Le,me=f.onFocus,le=me===void 0?x:me,Oe=f.filename,Ye=Oe===void 0?"educoder.txt":Oe,Ve=Object(I.a)(f,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),$e=Object(W.useRef)(),ze=Object(W.useRef)({}),Se=Object(W.useRef)(),De=Object(W.useRef)(!1),Ne=Object(W.useRef)(),Ge=Object(W.useState)(!1),je=Object(O.a)(Ge,2),Me=je[0],Ie=je[1];function lt(){var ie;return $e.current&&(ie=new M.default(function(ne){var be=Object(X.a)(ne),ge;try{for(be.s();!(ge=be.n()).done;){var Re=ge.value;(Re.target.offsetHeight>0||Re.target.offsetWidth>0)&&ze.current.instance.layout()}}catch(He){be.e(He)}finally{be.f()}}),ie.observe($e.current)),ie}function tt(){_.b.warn(decodeURIComponent(y))}var qe=function(){var ne=ze.current.instance;if(c!=null&&ne&&Me){var be=ne.getModel();be&&c!==be.getValue()&&(C=!0,be.setValue(c),ne.layout(),C=!1)}};Object(W.useEffect)(function(){Se.current&&clearTimeout(Se.current),Se.current=setTimeout(function(){qe()},500)},[c,Me,ze.current]);function Xe(){var ie=ze.current.instance;if(ie){var ne=ie.getSelection(),be=ze.current.pastePos||{},ge=new l.Range(be.startLineNumber||ne.endLineNumber,be.startColumn||ne.endColumn,be.endLineNumber||ne.endLineNumber,be.endColumn||ne.endColumn);setTimeout(function(){ie.executeEdits("",[{range:ge,text:""}])},300)}}function ht(ie){(window.navigator.platform.match("Mac")?ie.metaKey:ie.ctrlKey)&&ie.keyCode==83&&(ie.preventDefault(),q())}var nt=function(){if(ce&&ze.current.instance){var ne=ze.current.instance.getContentHeight();ee(ne<g?g:ne)}else ee(g)};function Je(ie){var ne=document.createEvent("MouseEvents");ne.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),ie.dispatchEvent(ne)}function Te(ie,ne){var be=window.URL||window.webkitURL||window,ge=new Blob([ne]),Re=document.createElementNS("http://www.w3.org/1999/xhtml","a");Re.href=be.createObjectURL(ge),Re.download=ie,Je(Re)}Object(W.useEffect)(function(){nt()},[nt]),Object(W.useEffect)(function(){$e.current&&!Me&&re.e(27).then(re.t.bind(null,"M/lh",7)).then(function(ie){try{l=ie,ze.current.instance=l.editor.create($e.current,{value:c,language:o(a),theme:z,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},Y);var ne=ze.current.instance;if(we(ne,l),setTimeout(function(){nt(),ze.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){Te(Ye||"educoder.txt",ne.getValue())}})},500),ze.current.subscription=ne.onDidChangeModelContent(function(ge){De.current?clearTimeout(Ne.current):(nt(),Ce(ne.getValue(),ge)),Ne.current=setTimeout(function(){De.current=!1},500)}),window.Monaco||v(l),ke&&(ne.addCommand(l.KeyMod.CtrlCmd|l.KeyMod.Shift|l.KeyCode.KEY_V,function(){return tt(),null}),ne.addCommand(l.KeyMod.CtrlCmd|l.KeyCode.KEY_C,function(){return tt(),null})),window.Monaco=l,j&&ne.onDidBlurEditorWidget(function(){j(ne.getValue())}),le&&ne.onDidFocusEditorText(function(){le(ne.getValue())}),ke){ne.addCommand(l.KeyMod.CtrlCmd|l.KeyCode.KEY_V,function(){return tt(),null}),ne.onDidPaste(function(ge){ze.current.pastePos=ge});try{window.addEventListener("paste",Xe)}catch(ge){}}var be=lt();return Ie(!0),function(){var ge=ze.current.instance;ge.dispose();var Re=ge.getModel();Re&&Re.dispose(),ze.current.subscription&&ze.current.subscription.dispose(),ke&&window.removeEventListener("paste",Xe),be.unobserve($e.current)}}catch(ge){}})},[]),Object(W.useEffect)(function(){var ie=ze.current.instance;if(ie&&Me)return document.addEventListener("keydown",ht,!1),function(){document.removeEventListener("keydown",ht)}},[q,Me]),Object(W.useEffect)(function(){var ie=ze.current.instance;if(ie&&Me){var ne=o(a);l.editor.setModelLanguage(ie.getModel(),ne),console.log("language:",a,ie.getModel(),ne)}},[a,Me]),Object(W.useEffect)(function(){var ie=ze.current.instance;ie&&Me&&l.editor.setTheme(z)},[z,Me]),Object(W.useEffect)(function(){var ie=ze.current.instance;ie&&Me&&(ie.updateOptions(Object(oe.a)({},P)),setTimeout(function(){ie.getModel().updateOptions(Object(oe.a)({},P))},200))},[JSON.stringify(P),Me]),Object(W.useEffect)(function(){var ie=ze.current.instance;ie&&Me&&ie.layout()},[D,g,Me]);var ut=Object(W.useState)(A(D)),at=Object(O.a)(ut,2),Ae=at[0],Ue=at[1],pe=Object(W.useState)(A(g)),ue=Object(O.a)(pe,2),fe=ue[0],ee=ue[1],te=Object(oe.a)(Object(oe.a)({},b),{},{width:Ae,height:fe});return F.a.createElement("div",{className:"my-monaco-editor",ref:$e,style:te})};function L(f){var p=f.width,D=p===void 0?"100%":p,S=f.height,g=S===void 0?"100%":S,c=f.original,d=f.modified,a=f.language,E=f.options,b=E===void 0?{}:E,T=Object(W.useRef)(),P=Object(W.useState)(null),G=Object(O.a)(P,2),Y=G[0],Q=G[1];function z(ce){var ve;return T.current&&(ve=new M.default(function(ke){var Ee=Object(X.a)(ke),Ce;try{for(Ee.s();!(Ce=Ee.n()).done;){var Le=Ce.value;(Le.target.offsetHeight>0||Le.target.offsetWidth>0)&&ce.layout()}}catch(we){Ee.e(we)}finally{Ee.f()}}),ve.observe(T.current)),ve}Object(W.useEffect)(function(){T.current&&re.e(27).then(re.t.bind(null,"M/lh",7)).then(function(ce){l=ce;var ve=l.editor.createDiffEditor(T.current,Object(oe.a)(Object(oe.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},b),{},{wordWrap:!0}));Q(ve);var ke=z(ve);return function(){ve.dispose();var Ee=ve.getModel();Ee&&Ee.dispose(),ke.unobserve(T.current)}})},[]),Object(W.useEffect)(function(){Y&&Y.setModel({original:l.editor.createModel(c,a),modified:l.editor.createModel(d,a)})},[c,d,a,Y]);var j=A(D),q=A(g),ae={width:j,height:q};return F.a.createElement("div",{className:"my-diff-editor",ref:T,style:ae})}},ZpRC:function(Et,ot,re){"use strict";function oe(v){return typeof v=="object"&&v!=null&&v.nodeType===1}function Z(v,y){return(!y||v!=="hidden")&&v!=="visible"&&v!=="clip"}function _(v,y){if(v.clientHeight<v.scrollHeight||v.clientWidth<v.scrollWidth){var R=getComputedStyle(v,null);return Z(R.overflowY,y)||Z(R.overflowX,y)||function(A){var x=function(C){if(!C.ownerDocument||!C.ownerDocument.defaultView)return null;try{return C.ownerDocument.defaultView.frameElement}catch(u){return null}}(A);return!!x&&(x.clientHeight<A.scrollHeight||x.clientWidth<A.scrollWidth)}(v)}return!1}function X(v,y,R,A,x,C,u,o){return C<v&&u>y||C>v&&u<y?0:C<=v&&o<=R||u>=y&&o>=R?C-v-A:u>y&&o<R||C<v&&o>R?u-y+x:0}var O=function(v,y){var R=window,A=y.scrollMode,x=y.block,C=y.inline,u=y.boundary,o=y.skipOverflowHiddenElements,l=typeof u=="function"?u:function(Ne){return Ne!==u};if(!oe(v))throw new TypeError("Invalid target");for(var h=document.scrollingElement||document.documentElement,L=[],f=v;oe(f)&&l(f);){if((f=f.parentElement)===h){L.push(f);break}f!=null&&f===document.body&&_(f)&&!_(document.documentElement)||f!=null&&_(f,o)&&L.push(f)}for(var p=R.visualViewport?R.visualViewport.width:innerWidth,D=R.visualViewport?R.visualViewport.height:innerHeight,S=window.scrollX||pageXOffset,g=window.scrollY||pageYOffset,c=v.getBoundingClientRect(),d=c.height,a=c.width,E=c.top,b=c.right,T=c.bottom,P=c.left,G=x==="start"||x==="nearest"?E:x==="end"?T:E+d/2,Y=C==="center"?P+a/2:C==="end"?b:P,Q=[],z=0;z<L.length;z++){var j=L[z],q=j.getBoundingClientRect(),ae=q.height,ce=q.width,ve=q.top,ke=q.right,Ee=q.bottom,Ce=q.left;if(A==="if-needed"&&E>=0&&P>=0&&T<=D&&b<=p&&E>=ve&&T<=Ee&&P>=Ce&&b<=ke)return Q;var Le=getComputedStyle(j),we=parseInt(Le.borderLeftWidth,10),me=parseInt(Le.borderTopWidth,10),le=parseInt(Le.borderRightWidth,10),Oe=parseInt(Le.borderBottomWidth,10),Ye=0,Ve=0,$e="offsetWidth"in j?j.offsetWidth-j.clientWidth-we-le:0,ze="offsetHeight"in j?j.offsetHeight-j.clientHeight-me-Oe:0;if(h===j)Ye=x==="start"?G:x==="end"?G-D:x==="nearest"?X(g,g+D,D,me,Oe,g+G,g+G+d,d):G-D/2,Ve=C==="start"?Y:C==="center"?Y-p/2:C==="end"?Y-p:X(S,S+p,p,we,le,S+Y,S+Y+a,a),Ye=Math.max(0,Ye+g),Ve=Math.max(0,Ve+S);else{Ye=x==="start"?G-ve-me:x==="end"?G-Ee+Oe+ze:x==="nearest"?X(ve,Ee,ae,me,Oe+ze,G,G+d,d):G-(ve+ae/2)+ze/2,Ve=C==="start"?Y-Ce-we:C==="center"?Y-(Ce+ce/2)+$e/2:C==="end"?Y-ke+le+$e:X(Ce,ke,ce,we,le+$e,Y,Y+a,a);var Se=j.scrollLeft,De=j.scrollTop;G+=De-(Ye=Math.max(0,Math.min(De+Ye,j.scrollHeight-ae+ze))),Y+=Se-(Ve=Math.max(0,Math.min(Se+Ve,j.scrollWidth-ce+$e)))}Q.push({el:j,top:Ye,left:Ve})}return Q};function I(v){return v===Object(v)&&Object.keys(v).length!==0}function W(v,y){y===void 0&&(y="auto");var R="scrollBehavior"in document.body.style;v.forEach(function(A){var x=A.el,C=A.top,u=A.left;x.scroll&&R?x.scroll({top:C,left:u,behavior:y}):(x.scrollTop=C,x.scrollLeft=u)})}function F(v){return v===!1?{block:"end",inline:"nearest"}:I(v)?v:{block:"start",inline:"nearest"}}function M(v,y){var R=!v.ownerDocument.documentElement.contains(v);if(I(y)&&typeof y.behavior=="function")return y.behavior(R?[]:O(v,y));if(R)return;var A=F(y);return W(O(v,A),A.behavior)}var k=ot.a=M},bT9E:function(Et,ot,re){"use strict";re.d(ot,"a",function(){return Z});var oe=re("VTBJ");function Z(_,X){var O=Object(oe.a)({},_);return Array.isArray(X)&&X.forEach(function(I){delete O[I]}),O}},c5Ni:function(Et,ot,re){},dejd:function(Et,ot,re){},dmUQ:function(Et,ot,re){"use strict";var oe=re("Ff2n"),Z=re("rePB"),_=re("1OyB"),X=re("vuIU"),O=re("Ji7U"),I=re("md7G"),W=re("foSv"),F=re("q1tI"),M=re.n(F),k=re("TSYQ"),v=re.n(k),y=re("4IlW");function R(d,a){var E=Object.keys(d);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(d);a&&(b=b.filter(function(T){return Object.getOwnPropertyDescriptor(d,T).enumerable})),E.push.apply(E,b)}return E}function A(d){for(var a=1;a<arguments.length;a++){var E=arguments[a]!=null?arguments[a]:{};a%2?R(Object(E),!0).forEach(function(b){Object(Z.a)(d,b,E[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(E)):R(Object(E)).forEach(function(b){Object.defineProperty(d,b,Object.getOwnPropertyDescriptor(E,b))})}return d}function x(d){var a=C();return function(){var b=Object(W.a)(d),T;if(a){var P=Object(W.a)(this).constructor;T=Reflect.construct(b,arguments,P)}else T=b.apply(this,arguments);return Object(I.a)(this,T)}}function C(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(d){return!1}}function u(){}function o(d){d.preventDefault()}var l=function(a){return a.replace(/[^\w.-]+/g,"")},h=200,L=600,f=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,p=function(a){return a!=null},D=function(a,E){return E===a||typeof E=="number"&&typeof a=="number"&&isNaN(E)&&isNaN(a)},S=function(d){Object(O.a)(E,d);var a=x(E);function E(b){var T;Object(_.a)(this,E),T=a.call(this,b),T.onKeyDown=function(Y){var Q=T.props,z=Q.onKeyDown,j=Q.onPressEnter;if(Y.keyCode===y.a.UP){var q=T.getRatio(Y);T.up(Y,q,null),T.stop()}else if(Y.keyCode===y.a.DOWN){var ae=T.getRatio(Y);T.down(Y,ae,null),T.stop()}else Y.keyCode===y.a.ENTER&&j&&j(Y);if(T.recordCursorPosition(),T.lastKeyCode=Y.keyCode,z){for(var ce=arguments.length,ve=new Array(ce>1?ce-1:0),ke=1;ke<ce;ke++)ve[ke-1]=arguments[ke];z.apply(void 0,[Y].concat(ve))}},T.onKeyUp=function(Y){var Q=T.props.onKeyUp;if(T.stop(),T.recordCursorPosition(),Q){for(var z=arguments.length,j=new Array(z>1?z-1:0),q=1;q<z;q++)j[q-1]=arguments[q];Q.apply(void 0,[Y].concat(j))}},T.onChange=function(Y){var Q=T.props.onChange;T.state.focused&&(T.inputting=!0),T.rawInput=T.props.parser(T.getValueFromEvent(Y)),T.setState({inputValue:T.rawInput}),Q(T.toNumber(T.rawInput))},T.onMouseUp=function(){var Y=T.props.onMouseUp;T.recordCursorPosition(),Y&&Y.apply(void 0,arguments)},T.onFocus=function(){var Y;T.setState({focused:!0}),(Y=T.props).onFocus.apply(Y,arguments)},T.onBlur=function(){var Y=T.props.onBlur;T.inputting=!1,T.setState({focused:!1});var Q=T.getCurrentValidValue(T.state.inputValue),z=T.setValue(Q,u);if(Y){var j=T.input.value,q=T.getInputDisplayValue({focus:!1,value:z});T.input.value=q&&Number(q),Y.apply(void 0,arguments),T.input.value=j}},T.getRatio=function(Y){var Q=1;return Y.metaKey||Y.ctrlKey?Q=.1:Y.shiftKey&&(Q=10),Q},T.getFullNum=function(Y){return isNaN(Y)?Y:/e/i.test(String(Y))?Number(Y).toFixed(18).replace(/\.?0+$/,""):Y},T.getPrecision=function(Y){if(p(T.props.precision))return T.props.precision;var Q=String(Y);if(Q.indexOf("e-")>=0)return parseInt(Q.slice(Q.indexOf("e-")+2),10);var z=0;return Q.indexOf(".")>=0&&(z=Q.length-Q.indexOf(".")-1),z},T.getInputDisplayValue=function(Y){var Q=Y||T.state,z=Q.focused,j=Q.inputValue,q=Q.value,ae;z?ae=j:ae=T.toPrecisionAsStep(q),ae==null&&(ae="");var ce=T.formatWrapper(ae);return p(T.props.decimalSeparator)&&(ce=ce.toString().replace(".",T.props.decimalSeparator)),ce},T.recordCursorPosition=function(){try{T.cursorStart=T.input.selectionStart,T.cursorEnd=T.input.selectionEnd,T.currentValue=T.input.value,T.cursorBefore=T.input.value.substring(0,T.cursorStart),T.cursorAfter=T.input.value.substring(T.cursorEnd)}catch(Y){}},T.restoreByAfter=function(Y){if(Y===void 0)return!1;var Q=T.input.value,z=Q.lastIndexOf(Y);if(z===-1)return!1;var j=T.cursorBefore.length;return T.lastKeyCode===y.a.DELETE&&T.cursorBefore.charAt(j-1)===Y[0]?(T.fixCaret(j,j),!0):z+Y.length===Q.length?(T.fixCaret(z,z),!0):!1},T.partRestoreByAfter=function(Y){return Y===void 0?!1:Array.prototype.some.call(Y,function(Q,z){var j=Y.substring(z);return T.restoreByAfter(j)})},T.isNotCompleteNumber=function(Y){return isNaN(Y)||Y===""||Y===null||Y&&Y.toString().indexOf(".")===Y.toString().length-1},T.stop=function(){T.autoStepTimer&&clearTimeout(T.autoStepTimer)},T.down=function(Y,Q,z){T.pressingUpOrDown=!0,T.step("down",Y,Q,z)},T.up=function(Y,Q,z){T.pressingUpOrDown=!0,T.step("up",Y,Q,z)},T.saveInput=function(Y){T.input=Y};var P=b.value;P===void 0&&(P=b.defaultValue),T.state={focused:b.autoFocus};var G=T.getValidValue(T.toNumber(P));return T.state=A(A({},T.state),{},{inputValue:T.toPrecisionAsStep(G),value:G}),T}return Object(X.a)(E,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(T){var P=this.props,G=P.value,Y=P.onChange,Q=P.max,z=P.min,j=this.state.focused;if(T){if(!D(T.value,G)||!D(T.max,Q)||!D(T.min,z)){var q=j?G:this.getValidValue(G),ae;this.pressingUpOrDown?ae=q:this.inputting?ae=this.rawInput:ae=this.toPrecisionAsStep(q),this.setState({value:q,inputValue:ae})}var ce="value"in this.props?G:this.state.value;"max"in this.props&&T.max!==Q&&typeof ce=="number"&&ce>Q&&Y&&Y(Q),"min"in this.props&&T.min!==z&&typeof ce=="number"&&ce<z&&Y&&Y(z)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var ve=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===y.a.BACKSPACE?ve=this.cursorStart-1:this.lastKeyCode===y.a.DELETE&&(ve=this.cursorStart):ve=this.input.value.length,this.fixCaret(ve,ve)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case y.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case y.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(ke){}if(this.lastKeyCode=null,!this.pressingUpOrDown)return;this.props.focusOnUpDown&&this.state.focused&&(document.activeElement!==this.input&&this.focus())}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(T){var P=T;return P===""?P="":this.isNotCompleteNumber(parseFloat(P))?P=this.state.value:P=this.getValidValue(P),this.toNumber(P)}},{key:"getValueFromEvent",value:function(T){var P=T.target.value.trim().replace(/。/g,".");return p(this.props.decimalSeparator)&&(P=P.replace(this.props.decimalSeparator,".")),P}},{key:"getValidValue",value:function(T){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,Y=parseFloat(T);return isNaN(Y)?T:(Y<P&&(Y=P),Y>G&&(Y=G),Y)}},{key:"setValue",value:function(T,P){var G=this.props.precision,Y=this.isNotCompleteNumber(parseFloat(T))?null:parseFloat(T),Q=this.state.value,z=Q===void 0?null:Q,j=this.state.inputValue,q=j===void 0?null:j,ae=typeof Y=="number"?Y.toFixed(G):"".concat(Y),ce=Y!==z||ae!=="".concat(q);return"value"in this.props?(q=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:q},P)):this.setState({value:Y,inputValue:this.toPrecisionAsStep(T)},P),ce&&this.props.onChange(Y),Y}},{key:"getMaxPrecision",value:function(T){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.props,Y=G.precision,Q=G.step;if(p(Y))return Y;var z=this.getPrecision(P),j=this.getPrecision(Q),q=this.getPrecision(T);return T?Math.max(q,z+j):z+j}},{key:"getPrecisionFactor",value:function(T){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.getMaxPrecision(T,P);return Math.pow(10,G)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(T){return this.props.formatter?this.props.formatter(T):T}},{key:"toPrecisionAsStep",value:function(T){if(this.isNotCompleteNumber(T)||T==="")return T;var P=Math.abs(this.getMaxPrecision(T));return isNaN(P)?T.toString():Number(T).toFixed(P)}},{key:"toNumber",value:function(T){var P=this.props.precision,G=this.state.focused,Y=T&&T.length>16&&G;return this.isNotCompleteNumber(T)||Y?T:p(P)?Math.round(T*Math.pow(10,P))/Math.pow(10,P):Number(T)}},{key:"upStep",value:function(T,P){var G=this.props.step,Y=this.getPrecisionFactor(T,P),Q=Math.abs(this.getMaxPrecision(T,P)),z=((Y*T+Y*G*P)/Y).toFixed(Q);return this.toNumber(z)}},{key:"downStep",value:function(T,P){var G=this.props.step,Y=this.getPrecisionFactor(T,P),Q=Math.abs(this.getMaxPrecision(T,P)),z=((Y*T-Y*G*P)/Y).toFixed(Q);return this.toNumber(z)}},{key:"step",value:function(T,P){var G=this,Y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,Q=arguments.length>3?arguments[3]:void 0;this.stop(),P&&(P.persist(),P.preventDefault());var z=this.props;if(z.disabled)return;var j=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(j))return;var q=this["".concat(T,"Step")](j,Y),ae=q>z.max||q<z.min;if(q>z.max?q=z.max:q<z.min&&(q=z.min),this.setValue(q,null),this.setState({focused:!0},function(){G.pressingUpOrDown=!1}),ae)return;this.autoStepTimer=setTimeout(function(){G[T](P,Y,!0)},Q?h:L)}},{key:"fixCaret",value:function(T,P){if(T===void 0||P===void 0||!this.input||!this.input.value)return;try{var G=this.input.selectionStart,Y=this.input.selectionEnd;(T!==G||P!==Y)&&this.input.setSelectionRange(T,P)}catch(Q){}}},{key:"render",value:function(){var T,P=this.props,G=P.prefixCls,Y=P.disabled,Q=P.readOnly,z=P.useTouch,j=P.autoComplete,q=P.upHandler,ae=P.downHandler,ce=P.className,ve=P.max,ke=P.min,Ee=P.style,Ce=P.title,Le=P.onMouseEnter,we=P.onMouseLeave,me=P.onMouseOver,le=P.onMouseOut,Oe=P.required,Ye=P.onClick,Ve=P.tabIndex,$e=P.type,ze=P.placeholder,Se=P.id,De=P.inputMode,Ne=P.pattern,Ge=P.step,je=P.maxLength,Me=P.autoFocus,Ie=P.name,lt=P.onPaste,tt=P.onInput,qe=Object(oe.a)(P,["prefixCls","disabled","readOnly","useTouch","autoComplete","upHandler","downHandler","className","max","min","style","title","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","required","onClick","tabIndex","type","placeholder","id","inputMode","pattern","step","maxLength","autoFocus","name","onPaste","onInput"]),Xe=this.state,ht=Xe.value,nt=Xe.focused,Je=v()(G,(T={},Object(Z.a)(T,ce,!!ce),Object(Z.a)(T,"".concat(G,"-disabled"),Y),Object(Z.a)(T,"".concat(G,"-focused"),nt),T)),Te={};Object.keys(qe).forEach(function(ne){(ne.substr(0,5)==="data-"||ne.substr(0,5)==="aria-"||ne==="role")&&(Te[ne]=qe[ne])});var ut=!Q&&!Y,at=this.getInputDisplayValue(null),Ae=(ht||ht===0)&&(isNaN(ht)||Number(ht)>=ve),Ue=(ht||ht===0)&&(isNaN(ht)||Number(ht)<=ke),pe=Ae||Y||Q,ue=Ue||Y||Q,fe=v()("".concat(G,"-handler"),"".concat(G,"-handler-up"),Object(Z.a)({},"".concat(G,"-handler-up-disabled"),pe)),ee=v()("".concat(G,"-handler"),"".concat(G,"-handler-down"),Object(Z.a)({},"".concat(G,"-handler-down-disabled"),ue)),te=z?{onTouchStart:pe?u:this.up,onTouchEnd:this.stop}:{onMouseDown:pe?u:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},ie=z?{onTouchStart:ue?u:this.down,onTouchEnd:this.stop}:{onMouseDown:ue?u:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return M.a.createElement("div",{className:Je,style:Ee,title:Ce,onMouseEnter:Le,onMouseLeave:we,onMouseOver:me,onMouseOut:le,onFocus:function(){return null},onBlur:function(){return null}},M.a.createElement("div",{className:"".concat(G,"-handler-wrap")},M.a.createElement("span",Object.assign({unselectable:"on"},te,{role:"button","aria-label":"Increase Value","aria-disabled":pe,className:fe}),q||M.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-up-inner"),onClick:o})),M.a.createElement("span",Object.assign({unselectable:"on"},ie,{role:"button","aria-label":"Decrease Value","aria-disabled":ue,className:ee}),ae||M.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-down-inner"),onClick:o}))),M.a.createElement("div",{className:"".concat(G,"-input-wrap")},M.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":ke,"aria-valuemax":ve,"aria-valuenow":ht,required:Oe,type:$e,placeholder:ze,onPaste:lt,onClick:Ye,onMouseUp:this.onMouseUp,className:"".concat(G,"-input"),tabIndex:Ve,autoComplete:j,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:ut?this.onKeyDown:u,onKeyUp:ut?this.onKeyUp:u,autoFocus:Me,maxLength:je,readOnly:Q,disabled:Y,max:ve,min:ke,step:Ge,name:Ie,title:Ce,id:Se,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(at),pattern:Ne,inputMode:De,onInput:tt},Te))))}}]),E}(M.a.Component);S.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:f,min:-f,step:1,style:{},onChange:u,onKeyDown:u,onPressEnter:u,onFocus:u,onBlur:u,parser:l,required:!1,autoComplete:"off"};var g=S,c=ot.a=g},fB9n:function(Et,ot,re){"use strict";re.r(ot);var oe=re("14J3"),Z=re("BMrR"),_=re("jCWc"),X=re("kPKH"),O=re("k1fw"),I=re("9og8"),W=re("tJVT"),F=re("PpiC"),M=re("WmNS"),k=re.n(M),v=re("q1tI"),y=re.n(v),R=re("55Ip"),A=re("9kvl"),x=re("T2oS"),C=re("W9HT"),u=re("oBTY"),o=re("B9cy"),l=re("Ol7k"),h=re("lUTK"),L=re("BvKs"),f=re("Ty5D"),p=re("wd/R"),D=re.n(p),S=re("RotF"),g=re.n(S),c=re("m3rI"),d=re("9Bee"),a=re("SbmS"),E=re.n(a),b=L.a.SubMenu,T=l.a.Sider,P=l.a.Content,G=function(De){var Ne=De.messages,Ge=De.globalSetting,je=De.loading,Me=De.user,Ie=De.dispatch,lt=Object(F.a)(De,["messages","globalSetting","loading","user","dispatch"]),tt=Object(f.i)(),qe=Object(f.h)(),Xe=Me.userInfo,ht=Object(v.useState)(!1),nt=Object(W.a)(ht,2),Je=nt[0],Te=nt[1],ut=Object(v.useState)({per_page:20,page:1}),at=Object(W.a)(ut,2),Ae=at[0],Ue=at[1],pe=Object(v.useState)({per_page:20,page:1}),ue=Object(W.a)(pe,2),fe=ue[0],ee=ue[1],te=Object(v.useState)([]),ie=Object(W.a)(te,2),ne=ie[0],be=ie[1];Object(v.useEffect)(function(){Ae.page=1,Re()},[tt.userId]);var ge=function(st){var Ze,mt;A.d.push("/messages/".concat(Me==null||((Ze=Me.userInfo)===null||Ze===void 0)?void 0:Ze.login,"/message_detail?target_ids=").concat(st==null||((mt=st.target)===null||mt===void 0)?void 0:mt.id))},Re=function(){var He=Object(I.a)(k.a.mark(function st(){var Ze,mt;return k.a.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return Te(!1),Qe.next=3,Ie({type:"messages/getPrivateMessages",payload:Object(O.a)(Object(O.a)({},tt),fe)});case 3:Ze=Qe.sent,Ze!=null&&Ze.private_messages&&(be([].concat(Object(u.a)(ne),Object(u.a)(Ze.private_messages))),((mt=Ze.private_messages)===null||mt===void 0?void 0:mt.length)===20&&Te(!0));case 5:case"end":return Qe.stop()}},st)}));return function(){return He.apply(this,arguments)}}();return y.a.createElement("aside",{className:E.a.listRightMessage},y.a.createElement(g.a,{loadMore:function(){fe.page++,Re()},hasMore:Je,useWindow:!1},y.a.createElement(C.a,{spinning:je["messages/getPrivateMessages"]},y.a.createElement("div",{className:"minH500"},ne==null?void 0:ne.map(function(He,st){var Ze,mt;return y.a.createElement("aside",{key:st},y.a.createElement(Z.a,{onClick:function(){return ge(He)}},y.a.createElement(X.a,{flex:"58px"},y.a.createElement("img",{src:c.a.IMG_SERVER+"/images/"+(He==null||((Ze=He.target)===null||Ze===void 0)?void 0:Ze.image_url),alt:""})),y.a.createElement(X.a,{flex:"1"},y.a.createElement(Z.a,null,y.a.createElement(X.a,{span:24},y.a.createElement(Z.a,null,y.a.createElement(X.a,{flex:"1"},y.a.createElement("span",{className:E.a.userName},He==null||((mt=He.target)===null||mt===void 0)?void 0:mt.name)),y.a.createElement(X.a,null,y.a.createElement("span",{className:"ml15 c-grey-c"},D()(He.send_time).fromNow())))),y.a.createElement(X.a,{span:24},y.a.createElement("div",{className:["mt15",E.a.content].join(" ")},y.a.createElement(d.a,{value:He.content||""})))))))})))))},Y=Object(A.a)(function(Se){var De=Se.messages,Ne=Se.loading,Ge=Se.user,je=Se.globalSetting;return{messages:De,globalSetting:je,user:Ge,loading:Ne.effects}})(G),Q=re("+L6B"),z=re("2/Rp"),j=re("miYZ"),q=re("tsqr"),ae=re("y8nQ"),ce=re("Vl3Y"),ve=re("kaH+"),ke=re("1vsH"),Ee=re("5WQS"),Ce=re("Ot1p"),Le=re("dhSg"),we=L.a.SubMenu,me=l.a.Sider,le=l.a.Content,Oe=function(De){var Ne=De.messages,Ge=De.globalSetting,je=De.loading,Me=De.user,Ie=De.dispatch,lt=Object(F.a)(De,["messages","globalSetting","loading","user","dispatch"]),tt=Object(f.i)(),qe=Object(f.h)(),Xe=qe.query,ht=Object(v.useState)({per_page:20,page:1}),nt=Object(W.a)(ht,2),Je=nt[0],Te=nt[1],ut=Object(v.useState)([]),at=Object(W.a)(ut,2),Ae=at[0],Ue=at[1],pe=Object(v.useState)(!1),ue=Object(W.a)(pe,2),fe=ue[0],ee=ue[1],te=Object(v.useState)(!1),ie=Object(W.a)(te,2),ne=ie[0],be=ie[1],ge=Object(v.useState)(""),Re=Object(W.a)(ge,2),He=Re[0],st=Re[1],Ze=Object(v.useRef)(),mt=ce.a.useForm(),vt=Object(W.a)(mt,1),Qe=vt[0],jt=Object(v.useState)([]),At=Object(W.a)(jt,2),Nt=At[0],Ht=At[1],Dt=Object(v.useState)(!0),Tr=Object(W.a)(Dt,2),Zr=Tr[0],yt=Tr[1];Object(v.useEffect)(function(){Je.page=1,wr()},[Xe.target_ids]);var wr=function(){var Bt=Object(I.a)(k.a.mark(function Qt(){var Kt,Tt;return k.a.wrap(function(ur){for(;;)switch(ur.prev=ur.next){case 0:return ee(!1),ur.next=3,Ie({type:"messages/getPrivateMessageDetails",payload:Object(O.a)(Object(O.a)({},tt),{},{target_id:Xe==null?void 0:Xe.target_ids},Je)});case 3:Kt=ur.sent,Kt!=null&&Kt.messages&&(Nt=Kt==null?void 0:Kt.messages,((Tt=Nt)===null||Tt===void 0?void 0:Tt.length)===20&&setTimeout(function(){ee(!0),yt(!1)},500),Je.page===1?Ue(Object(u.a)(Kt==null?void 0:Kt.messages.reverse())):Ue([].concat(Object(u.a)(Ae),Object(u.a)(Kt==null?void 0:Kt.messages.reverse()))));case 5:case"end":return ur.stop()}},Qt)}));return function(){return Bt.apply(this,arguments)}}();Object(v.useEffect)(function(){console.log("newData.length:",Je,Nt.length,Nt),Je.page===1&&Zr&&(Ze.current.scrollTop=Ze.current.scrollHeight)},[Ae]),Object(v.useEffect)(function(){Ze.current.onclick=function(Bt){Bt.target.nodeName==="IMG"&&Bt.target.alt!==""&&Le.a.publish("preview-image",Bt.target.src)}},[]);var tr=function(){var Bt=Object(I.a)(k.a.mark(function Qt(Kt,Tt){var pt;return k.a.wrap(function(Lr){for(;;)switch(Lr.prev=Lr.next){case 0:return Lr.next=2,Object(Ee.a)(Object(O.a)(Object(O.a)({},tt),{},{id:Kt.id}));case 2:pt=Lr.sent,pt.status===0&&(Ae.splice(Tt,1),Ue(Object(u.a)(Ae)));case 5:case"end":return Lr.stop()}},Qt)}));return function(Kt,Tt){return Bt.apply(this,arguments)}}(),lr=function(){var Bt=Object(I.a)(k.a.mark(function Qt(){return k.a.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:if(!(He==="")){Tt.next=3;break}return q.b.error("\u8BF7\u8F93\u5165\u60A8\u7684\u56DE\u590D"),Tt.abrupt("return",!1);case 3:return st(""),be(!0),Tt.next=8,Object(Ee.g)(Object(O.a)(Object(O.a)({},tt),{},{content:He,target_id:Xe==null?void 0:Xe.target_ids}));case 8:be(!1),Je.page=1,Qe.resetFields(),wr();case 12:case"end":return Tt.stop()}},Qt)}));return function(){return Bt.apply(this,arguments)}}();return y.a.createElement("section",null,y.a.createElement("aside",{className:E.a.listMessage,ref:Ze},y.a.createElement(g.a,{isReverse:!0,loadMore:function(){Je.page++,wr()},hasMore:fe,useWindow:!1},!fe&&y.a.createElement("div",{className:"tc mt20 animated fadeIn"},y.a.createElement("span",{className:E.a.msgDate},"\u6CA1\u6709\u4FE1\u606F\u4E86\uFF5E\uFF5E")),y.a.createElement(C.a,{spinning:je["messages/getPrivateMessageDetails"]},y.a.createElement("aside",{className:"minH500"},Ae==null?void 0:Ae.map(function(Bt,Qt){var Kt;return y.a.createElement("aside",{key:Qt},y.a.createElement(Z.a,{justify:"center"},y.a.createElement(X.a,{flex:"1",className:"tc"},y.a.createElement("span",{className:E.a.msgDate},D()(Bt.send_time).format("YYYY-MM-DD")))),y.a.createElement(Z.a,{onClick:function(){return Object(ke.H)(Bt)}},y.a.createElement(X.a,{flex:"58px"},y.a.createElement("img",{src:c.a.IMG_SERVER+"/images/"+(Bt==null||((Kt=Bt.sender)===null||Kt===void 0)?void 0:Kt.image_url),alt:""})),y.a.createElement(X.a,null,y.a.createElement("div",{className:E.a.msg},y.a.createElement(d.a,{value:Bt.content||""}),y.a.createElement("span",{onClick:function(){return tr(Bt,Qt)},className:["current",E.a.deleteMsg].join(" ")},"\u5220\u9664"))),y.a.createElement(X.a,null,y.a.createElement("span",{className:"c-grey-c ml10"},D()(Bt.send_time).format("HH:mm")))))}))))),y.a.createElement("aside",{className:"pl30 pr30 mb30 mt30"},y.a.createElement(ce.a,{form:Qe},y.a.createElement(ce.a.Item,{name:"content"},y.a.createElement(Ce.a,{placeholder:"\u8BF7\u8F93\u5165\u4F60\u7684\u56DE\u590D",height:150,onChange:function(Qt){return st(Qt)}})),y.a.createElement(Z.a,null,y.a.createElement(X.a,{flex:"1"},y.a.createElement("span",{className:"c-red font14"},"\u5728\u95EE\u9898\u53CD\u9988\u65F6\uFF0C\u8BF7\u540C\u65F6\u53D1\u9001\u95EE\u9898\u53D1\u751F\u9875\u7684\u7F51\u5740\u94FE\u63A5\uFF0C\u4EE5\u4FBF\u6211\u4EEC\u9AD8\u6548\u7684\u4E3A\u60A8\u670D\u52A1")),y.a.createElement(X.a,null,y.a.createElement(z.a,{loading:ne,type:"primary",onClick:function(){return lr()}},"\u56DE\u590D"))))),y.a.createElement(ve.a,null))},Ye=Object(A.a)(function(Se){var De=Se.messages,Ne=Se.loading,Ge=Se.user,je=Se.globalSetting;return{messages:De,globalSetting:je,user:Ge,loading:Ne.effects}})(Oe),Ve=re("30zm"),$e=function(De){var Ne,Ge=De.messages,je=De.globalSetting,Me=De.loading,Ie=De.user,lt=De.dispatch,tt=Object(F.a)(De,["messages","globalSetting","loading","user","dispatch"]),qe=tt.match.params,Xe=tt.location.query,ht=Ie.userInfo,nt=Ge.tidingsList,Je=Ge.privateMessageDetails,Te=Object(v.useState)({per_page:20,page:1}),ut=Object(W.a)(Te,2),at=ut[0],Ae=ut[1],Ue=Object(v.useState)({per_page:20,page:1}),pe=Object(W.a)(Ue,2),ue=pe[0],fe=pe[1],ee=Object(v.useState)([]),te=Object(W.a)(ee,2),ie=te[0],ne=te[1],be=Object(v.useState)([]),ge=Object(W.a)(be,2),Re=ge[0],He=ge[1];Object(v.useEffect)(function(){at.page=1},[qe.userId]);var st=function(){var mt=Object(I.a)(k.a.mark(function vt(){var Qe;return k.a.wrap(function(At){for(;;)switch(At.prev=At.next){case 0:return At.next=2,lt({type:"messages/getPrivateMessageDetails",payload:Object(O.a)(Object(O.a)({},qe),{},{target_id:Xe==null?void 0:Xe.target_ids})});case 2:Qe=At.sent,Qe!=null&&Qe.messages&&ne(Qe.messages);case 4:case"end":return At.stop()}},vt)}));return function(){return mt.apply(this,arguments)}}(),Ze=function(){var mt=Object(I.a)(k.a.mark(function vt(){var Qe;return k.a.wrap(function(At){for(;;)switch(At.prev=At.next){case 0:return At.next=2,lt({type:"messages/getPrivateMessages",payload:Object(O.a)(Object(O.a)({},qe),ue)});case 2:Qe=At.sent,Qe!=null&&Qe.private_messages&&He(Qe.private_messages);case 4:case"end":return At.stop()}},vt)}));return function(){return mt.apply(this,arguments)}}();return y.a.createElement("section",{className:E.a.bg},y.a.createElement("section",{className:"edu-container mt20"},y.a.createElement(Z.a,{gutter:[20,20]},y.a.createElement(Ve.a,null),y.a.createElement(X.a,{flex:"1"},y.a.createElement("aside",{className:"bg-white"},y.a.createElement("aside",{className:["font16",E.a.topBar].join(" ")},y.a.createElement(Z.a,null,y.a.createElement(X.a,{flex:"30px",className:"tc"},y.a.createElement(R.a,{to:"/messages/".concat(qe.userId,"/private_messages"),className:"iconfont icon-zuojiantou c-black pl10"})),y.a.createElement(X.a,{flex:"1",className:"tc"},Je==null||((Ne=Je.target)===null||Ne===void 0)?void 0:Ne.name,"\u4E0E\u4F60\u7684\u79C1\u4FE1"),y.a.createElement(X.a,{flex:"290px",className:"tl"},y.a.createElement("span",{className:"pl30"},"\u79C1\u4FE1\u5217\u8868")))),y.a.createElement(Z.a,null,y.a.createElement(X.a,{flex:"1"},y.a.createElement(Ye,null)),y.a.createElement(X.a,{flex:"290px"},y.a.createElement(Y,null))))))))},ze=ot.default=Object(A.a)(function(Se){var De=Se.messages,Ne=Se.loading,Ge=Se.user,je=Se.globalSetting;return{messages:De,globalSetting:je,user:Ge,loading:Ne.effects}})($e)},kSUc:function(Et,ot,re){},"kaH+":function(Et,ot,re){"use strict";var oe=re("+L6B"),Z=re("2/Rp"),_=re("tJVT"),X=re("q1tI"),O=re.n(X),I=re("UZu5"),W=re.n(I),F=re("dhSg"),M=re("rLCj"),k=re("dF/Y"),v=re("4i/N");ot.a=function(){var y=Object(X.useState)(""),R=Object(_.a)(y,2),A=R[0],x=R[1],C=Object(X.useState)(0),u=Object(_.a)(C,2),o=u[0],l=u[1],h=Object(X.useRef)("");Object(X.useEffect)(function(){var D=F.a.subscribe("preview-image",function(S){x(S),document.body.style.overflow="hidden"});return D},[]),Object(X.useEffect)(function(){return document.addEventListener("keydown",L),function(){document.removeEventListener("keydown",L)}},[]),Object(X.useEffect)(function(){h.current=A},[A]);function L(D){D.keyCode==27&&h.current&&f()}function f(){document.body.style.overflow="auto",x("")}function p(){l(o+90)}return O.a.createElement(X.Fragment,null,A?O.a.createElement("div",{className:"image-preview-container"},O.a.createElement("div",{className:"button-group"},O.a.createElement(Z.a,{onClick:p},"\u65CB\u8F6C",O.a.createElement(M.a,null)),O.a.createElement(Z.a,{href:A},"\u4E0B\u8F7D",O.a.createElement(k.a,null)),O.a.createElement(Z.a,{onClick:f},"\u5173\u95ED",O.a.createElement(v.a,null))),O.a.createElement("div",{className:"preview-wrp-group"},O.a.createElement("img",{className:"image-preview",src:A,alt:"\u9884\u89C8\u5927\u56FE",style:{transform:"rotate(".concat(o,"deg)")}}))):null)}},kzJb:function(Et,ot,re){Et.exports={flex_box_center:"flex_box_center___2qtoc",flex_space_between:"flex_space_between___NF1Yf",flex_box_vertical_center:"flex_box_vertical_center___2qH_j",flex_box_center_end:"flex_box_center_end___22P0N",flex_box_column:"flex_box_column___1IKP8",userInfo:"userInfo___2Dupy",navInfo:"navInfo___3fEvD",actived:"actived___3F322",newTip:"newTip___1Ta-b"}},lZu9:function(Et,ot,re){(function(oe){oe(re("VrN/"),re("1eCo"),re("8EBN"))})(function(oe){"use strict";oe.defineMode("markdown",function(Z,_){var X=oe.getMode(Z,"text/html"),O=X.name=="null";function I(z){if(oe.findModeByName){var j=oe.findModeByName(z);j&&(z=j.mime||j.mimes[0])}var q=oe.getMode(Z,z);return q.name=="null"?null:q}_.highlightFormatting===void 0&&(_.highlightFormatting=!1),_.maxBlockquoteDepth===void 0&&(_.maxBlockquoteDepth=0),_.taskLists===void 0&&(_.taskLists=!1),_.strikethrough===void 0&&(_.strikethrough=!1),_.emoji===void 0&&(_.emoji=!1),_.fencedCodeBlockHighlighting===void 0&&(_.fencedCodeBlockHighlighting=!0),_.fencedCodeBlockDefaultMode===void 0&&(_.fencedCodeBlockDefaultMode="text/plain"),_.xml===void 0&&(_.xml=!0),_.tokenTypeOverrides===void 0&&(_.tokenTypeOverrides={});var W={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var F in W)W.hasOwnProperty(F)&&_.tokenTypeOverrides[F]&&(W[F]=_.tokenTypeOverrides[F]);var M=/^([*\-_])(?:\s*\1){2,}\s*$/,k=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,v=/^\[(x| )\](?=\s)/i,y=_.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,R=/^ {0,3}(?:\={1,}|-{2,})\s*$/,A=/^[^#!\[\]*_\\<>` "'(~:]+/,x=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,C=/^\s*\[[^\]]+?\]:.*$/,u=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function l(z,j,q){return j.f=j.inline=q,q(z,j)}function h(z,j,q){return j.f=j.block=q,q(z,j)}function L(z){return!z||!/\S/.test(z.string)}function f(z){if(z.linkTitle=!1,z.linkHref=!1,z.linkText=!1,z.em=!1,z.strong=!1,z.strikethrough=!1,z.quote=0,z.indentedCode=!1,z.f==D){var j=O;if(!j){var q=oe.innerMode(X,z.htmlState);j=q.mode.name=="xml"&&q.state.tagStart===null&&!q.state.context&&q.state.tokenize.isInText}j&&(z.f=d,z.block=p,z.htmlState=null)}return z.trailingSpace=0,z.trailingSpaceNewLine=!1,z.prevLine=z.thisLine,z.thisLine={stream:null},null}function p(z,j){var q=z.column()===j.indentation,ae=L(j.prevLine.stream),ce=j.indentedCode,ve=j.prevLine.hr,ke=j.list!==!1,Ee=(j.listStack[j.listStack.length-1]||0)+3;j.indentedCode=!1;var Ce=j.indentation;if(j.indentationDiff===null&&(j.indentationDiff=j.indentation,ke)){for(j.list=null;Ce<j.listStack[j.listStack.length-1];)j.listStack.pop(),j.listStack.length?j.indentation=j.listStack[j.listStack.length-1]:j.list=!1;j.list!==!1&&(j.indentationDiff=Ce-j.listStack[j.listStack.length-1])}var Le=!ae&&!ve&&!j.prevLine.header&&(!ke||!ce)&&!j.prevLine.fencedCodeEnd,we=(j.list===!1||ve||ae)&&j.indentation<=Ee&&z.match(M),me=null;if(j.indentationDiff>=4&&(ce||j.prevLine.fencedCodeEnd||j.prevLine.header||ae))return z.skipToEnd(),j.indentedCode=!0,W.code;if(z.eatSpace())return null;if(q&&j.indentation<=Ee&&(me=z.match(y))&&me[1].length<=6)return j.quote=0,j.header=me[1].length,j.thisLine.header=!0,_.highlightFormatting&&(j.formatting="header"),j.f=j.inline,g(j);if(j.indentation<=Ee&&z.eat(">"))return j.quote=q?1:j.quote+1,_.highlightFormatting&&(j.formatting="quote"),z.eatSpace(),g(j);if(!we&&!j.setext&&q&&j.indentation<=Ee&&(me=z.match(k))){var le=me[1]?"ol":"ul";return j.indentation=Ce+z.current().length,j.list=!0,j.quote=0,j.listStack.push(j.indentation),j.em=!1,j.strong=!1,j.code=!1,j.strikethrough=!1,_.taskLists&&z.match(v,!1)&&(j.taskList=!0),j.f=j.inline,_.highlightFormatting&&(j.formatting=["list","list-"+le]),g(j)}else{if(q&&j.indentation<=Ee&&(me=z.match(x,!0)))return j.quote=0,j.fencedEndRE=new RegExp(me[1]+"+ *$"),j.localMode=_.fencedCodeBlockHighlighting&&I(me[2]||_.fencedCodeBlockDefaultMode),j.localMode&&(j.localState=oe.startState(j.localMode)),j.f=j.block=S,_.highlightFormatting&&(j.formatting="code-block"),j.code=-1,g(j);if(j.setext||(!Le||!ke)&&!j.quote&&j.list===!1&&!j.code&&!we&&!C.test(z.string)&&(me=z.lookAhead(1))&&(me=me.match(R)))return j.setext?(j.header=j.setext,j.setext=0,z.skipToEnd(),_.highlightFormatting&&(j.formatting="header")):(j.header=me[0].charAt(0)=="="?1:2,j.setext=j.header),j.thisLine.header=!0,j.f=j.inline,g(j);if(we)return z.skipToEnd(),j.hr=!0,j.thisLine.hr=!0,W.hr;if(z.peek()==="[")return l(z,j,P)}return l(z,j,j.inline)}function D(z,j){var q=X.token(z,j.htmlState);if(!O){var ae=oe.innerMode(X,j.htmlState);(ae.mode.name=="xml"&&ae.state.tagStart===null&&!ae.state.context&&ae.state.tokenize.isInText||j.md_inside&&z.current().indexOf(">")>-1)&&(j.f=d,j.block=p,j.htmlState=null)}return q}function S(z,j){var q=j.listStack[j.listStack.length-1]||0,ae=j.indentation<q,ce=q+3;if(j.fencedEndRE&&j.indentation<=ce&&(ae||z.match(j.fencedEndRE))){_.highlightFormatting&&(j.formatting="code-block");var ve;return ae||(ve=g(j)),j.localMode=j.localState=null,j.block=p,j.f=d,j.fencedEndRE=null,j.code=0,j.thisLine.fencedCodeEnd=!0,ae?h(z,j,j.block):ve}else return j.localMode?j.localMode.token(z,j.localState):(z.skipToEnd(),W.code)}function g(z){var j=[];if(z.formatting){j.push(W.formatting),typeof z.formatting=="string"&&(z.formatting=[z.formatting]);for(var q=0;q<z.formatting.length;q++)j.push(W.formatting+"-"+z.formatting[q]),z.formatting[q]==="header"&&j.push(W.formatting+"-"+z.formatting[q]+"-"+z.header),z.formatting[q]==="quote"&&(!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=z.quote?j.push(W.formatting+"-"+z.formatting[q]+"-"+z.quote):j.push("error"))}if(z.taskOpen)return j.push("meta"),j.length?j.join(" "):null;if(z.taskClosed)return j.push("property"),j.length?j.join(" "):null;if(z.linkHref?j.push(W.linkHref,"url"):(z.strong&&j.push(W.strong),z.em&&j.push(W.em),z.strikethrough&&j.push(W.strikethrough),z.emoji&&j.push(W.emoji),z.linkText&&j.push(W.linkText),z.code&&j.push(W.code),z.image&&j.push(W.image),z.imageAltText&&j.push(W.imageAltText,"link"),z.imageMarker&&j.push(W.imageMarker)),z.header&&j.push(W.header,W.header+"-"+z.header),z.quote&&(j.push(W.quote),!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=z.quote?j.push(W.quote+"-"+z.quote):j.push(W.quote+"-"+_.maxBlockquoteDepth)),z.list!==!1){var ae=(z.listStack.length-1)%3;ae?ae===1?j.push(W.list2):j.push(W.list3):j.push(W.list1)}return z.trailingSpaceNewLine?j.push("trailing-space-new-line"):z.trailingSpace&&j.push("trailing-space-"+(z.trailingSpace%2?"a":"b")),j.length?j.join(" "):null}function c(z,j){return z.match(A,!0)?g(j):void 0}function d(z,j){var q=j.text(z,j);if(typeof q!="undefined")return q;if(j.list)return j.list=null,g(j);if(j.taskList){var ae=z.match(v,!0)[1]===" ";return ae?j.taskOpen=!0:j.taskClosed=!0,_.highlightFormatting&&(j.formatting="task"),j.taskList=!1,g(j)}if(j.taskOpen=!1,j.taskClosed=!1,j.header&&z.match(/^#+$/,!0))return _.highlightFormatting&&(j.formatting="header"),g(j);var ce=z.next();if(j.linkTitle){j.linkTitle=!1;var ve=ce;ce==="("&&(ve=")"),ve=(ve+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var ke="^\\s*(?:[^"+ve+"\\\\]+|\\\\\\\\|\\\\.)"+ve;if(z.match(new RegExp(ke),!0))return W.linkHref}if(ce==="`"){var Ee=j.formatting;_.highlightFormatting&&(j.formatting="code"),z.eatWhile("`");var Ce=z.current().length;if(j.code==0&&(!j.quote||Ce==1))return j.code=Ce,g(j);if(Ce==j.code){var Le=g(j);return j.code=0,Le}else return j.formatting=Ee,g(j)}else if(j.code)return g(j);if(ce==="\\"&&(z.next(),_.highlightFormatting)){var we=g(j),me=W.formatting+"-escape";return we?we+" "+me:me}if(ce==="!"&&z.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return j.imageMarker=!0,j.image=!0,_.highlightFormatting&&(j.formatting="image"),g(j);if(ce==="["&&j.imageMarker&&z.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return j.imageMarker=!1,j.imageAltText=!0,_.highlightFormatting&&(j.formatting="image"),g(j);if(ce==="]"&&j.imageAltText){_.highlightFormatting&&(j.formatting="image");var we=g(j);return j.imageAltText=!1,j.image=!1,j.inline=j.f=E,we}if(ce==="["&&!j.image)return j.linkText&&z.match(/^.*?\]/)||(j.linkText=!0,_.highlightFormatting&&(j.formatting="link")),g(j);if(ce==="]"&&j.linkText){_.highlightFormatting&&(j.formatting="link");var we=g(j);return j.linkText=!1,j.inline=j.f=z.match(/\(.*?\)| ?\[.*?\]/,!1)?E:d,we}if(ce==="<"&&z.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=a,_.highlightFormatting&&(j.formatting="link");var we=g(j);return we?we+=" ":we="",we+W.linkInline}if(ce==="<"&&z.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=a,_.highlightFormatting&&(j.formatting="link");var we=g(j);return we?we+=" ":we="",we+W.linkEmail}if(_.xml&&ce==="<"&&z.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var le=z.string.indexOf(">",z.pos);if(le!=-1){var Oe=z.string.substring(z.start,le);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(Oe)&&(j.md_inside=!0)}return z.backUp(1),j.htmlState=oe.startState(X),h(z,j,D)}if(_.xml&&ce==="<"&&z.match(/^\/\w*?>/))return j.md_inside=!1,"tag";if(ce==="*"||ce==="_"){for(var Ye=1,Ve=z.pos==1?" ":z.string.charAt(z.pos-2);Ye<3&&z.eat(ce);)Ye++;var $e=z.peek()||" ",ze=!/\s/.test($e)&&(!u.test($e)||/\s/.test(Ve)||u.test(Ve)),Se=!/\s/.test(Ve)&&(!u.test(Ve)||/\s/.test($e)||u.test($e)),De=null,Ne=null;if(Ye%2&&(!j.em&&ze&&(ce==="*"||!Se||u.test(Ve))?De=!0:j.em==ce&&Se&&(ce==="*"||!ze||u.test($e))&&(De=!1)),Ye>1&&(!j.strong&&ze&&(ce==="*"||!Se||u.test(Ve))?Ne=!0:j.strong==ce&&Se&&(ce==="*"||!ze||u.test($e))&&(Ne=!1)),Ne!=null||De!=null){_.highlightFormatting&&(j.formatting=De==null?"strong":Ne==null?"em":"strong em"),De===!0&&(j.em=ce),Ne===!0&&(j.strong=ce);var Le=g(j);return De===!1&&(j.em=!1),Ne===!1&&(j.strong=!1),Le}}else if(ce===" "&&(z.eat("*")||z.eat("_"))){if(z.peek()===" ")return g(j);z.backUp(1)}if(_.strikethrough){if(ce==="~"&&z.eatWhile(ce)){if(j.strikethrough){_.highlightFormatting&&(j.formatting="strikethrough");var Le=g(j);return j.strikethrough=!1,Le}else if(z.match(/^[^\s]/,!1))return j.strikethrough=!0,_.highlightFormatting&&(j.formatting="strikethrough"),g(j)}else if(ce===" "&&z.match(/^~~/,!0)){if(z.peek()===" ")return g(j);z.backUp(2)}}if(_.emoji&&ce===":"&&z.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){j.emoji=!0,_.highlightFormatting&&(j.formatting="emoji");var Ge=g(j);return j.emoji=!1,Ge}return ce===" "&&(z.match(/^ +$/,!1)?j.trailingSpace++:j.trailingSpace&&(j.trailingSpaceNewLine=!0)),g(j)}function a(z,j){var q=z.next();if(q===">"){j.f=j.inline=d,_.highlightFormatting&&(j.formatting="link");var ae=g(j);return ae?ae+=" ":ae="",ae+W.linkInline}return z.match(/^[^>]+/,!0),W.linkInline}function E(z,j){if(z.eatSpace())return null;var q=z.next();return q==="("||q==="["?(j.f=j.inline=T(q==="("?")":"]"),_.highlightFormatting&&(j.formatting="link-string"),j.linkHref=!0,g(j)):"error"}var b={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function T(z){return function(j,q){var ae=j.next();if(ae===z){q.f=q.inline=d,_.highlightFormatting&&(q.formatting="link-string");var ce=g(q);return q.linkHref=!1,ce}return j.match(b[z]),q.linkHref=!0,g(q)}}function P(z,j){return z.match(/^([^\]\\]|\\.)*\]:/,!1)?(j.f=G,z.next(),_.highlightFormatting&&(j.formatting="link"),j.linkText=!0,g(j)):l(z,j,d)}function G(z,j){if(z.match(/^\]:/,!0)){j.f=j.inline=Y,_.highlightFormatting&&(j.formatting="link");var q=g(j);return j.linkText=!1,q}return z.match(/^([^\]\\]|\\.)+/,!0),W.linkText}function Y(z,j){return z.eatSpace()?null:(z.match(/^[^\s]+/,!0),z.peek()===void 0?j.linkTitle=!0:z.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),j.f=j.inline=d,W.linkHref+" url")}var Q={startState:function(){return{f:p,prevLine:{stream:null},thisLine:{stream:null},block:p,htmlState:null,indentation:0,inline:d,text:c,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(z){return{f:z.f,prevLine:z.prevLine,thisLine:z.thisLine,block:z.block,htmlState:z.htmlState&&oe.copyState(X,z.htmlState),indentation:z.indentation,localMode:z.localMode,localState:z.localMode?oe.copyState(z.localMode,z.localState):null,inline:z.inline,text:z.text,formatting:!1,linkText:z.linkText,linkTitle:z.linkTitle,linkHref:z.linkHref,code:z.code,em:z.em,strong:z.strong,strikethrough:z.strikethrough,emoji:z.emoji,header:z.header,setext:z.setext,hr:z.hr,taskList:z.taskList,list:z.list,listStack:z.listStack.slice(0),quote:z.quote,indentedCode:z.indentedCode,trailingSpace:z.trailingSpace,trailingSpaceNewLine:z.trailingSpaceNewLine,md_inside:z.md_inside,fencedEndRE:z.fencedEndRE}},token:function(z,j){if(j.formatting=!1,z!=j.thisLine.stream){if(j.header=0,j.hr=!1,z.match(/^\s*$/,!0))return f(j),null;if(j.prevLine=j.thisLine,j.thisLine={stream:z},j.taskList=!1,j.trailingSpace=0,j.trailingSpaceNewLine=!1,!j.localState&&(j.f=j.block,j.f!=D)){var q=z.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(j.indentation=q,j.indentationDiff=null,q>0)return null}}return j.f(z,j)},innerMode:function(z){return z.block==D?{state:z.htmlState,mode:X}:z.localState?{state:z.localState,mode:z.localMode}:{state:z,mode:Q}},indent:function(z,j,q){return z.block==D&&X.indent?X.indent(z.htmlState,j,q):z.localState&&z.localMode.indent?z.localMode.indent(z.localState,j,q):oe.Pass},blankLine:f,getType:g,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return Q},"xml"),oe.defineMIME("text/markdown","markdown"),oe.defineMIME("text/x-markdown","markdown")})},osHv:function(Et,ot,re){(function(oe){oe(re("VrN/"))})(function(oe){"use strict";var Z=oe.Pos;function _(u,o){return u.line-o.line||u.ch-o.ch}var X="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",O=X+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",I=new RegExp("<(/?)(["+X+"]["+O+"]*)","g");function W(u,o,l,h){this.line=o,this.ch=l,this.cm=u,this.text=u.getLine(o),this.min=h?Math.max(h.from,u.firstLine()):u.firstLine(),this.max=h?Math.min(h.to-1,u.lastLine()):u.lastLine()}function F(u,o){var l=u.cm.getTokenTypeAt(Z(u.line,o));return l&&/\btag\b/.test(l)}function M(u){return u.line>=u.max?void 0:(u.ch=0,u.text=u.cm.getLine(++u.line),!0)}function k(u){return u.line<=u.min?void 0:(u.text=u.cm.getLine(--u.line),u.ch=u.text.length,!0)}function v(u){for(;;){var o=u.text.indexOf(">",u.ch);if(o==-1){if(M(u))continue;return}if(!F(u,o+1)){u.ch=o+1;continue}var l=u.text.lastIndexOf("/",o),h=l>-1&&!/\S/.test(u.text.slice(l+1,o));return u.ch=o+1,h?"selfClose":"regular"}}function y(u){for(;;){var o=u.ch?u.text.lastIndexOf("<",u.ch-1):-1;if(o==-1){if(k(u))continue;return}if(!F(u,o+1)){u.ch=o;continue}I.lastIndex=o,u.ch=o;var l=I.exec(u.text);if(l&&l.index==o)return l}}function R(u){for(;;){I.lastIndex=u.ch;var o=I.exec(u.text);if(!o){if(M(u))continue;return}if(!F(u,o.index+1)){u.ch=o.index+1;continue}return u.ch=o.index+o[0].length,o}}function A(u){for(;;){var o=u.ch?u.text.lastIndexOf(">",u.ch-1):-1;if(o==-1){if(k(u))continue;return}if(!F(u,o+1)){u.ch=o;continue}var l=u.text.lastIndexOf("/",o),h=l>-1&&!/\S/.test(u.text.slice(l+1,o));return u.ch=o+1,h?"selfClose":"regular"}}function x(u,o){for(var l=[];;){var h=R(u),L,f=u.line,p=u.ch-(h?h[0].length:0);if(!h||!(L=v(u)))return;if(L=="selfClose")continue;if(h[1]){for(var D=l.length-1;D>=0;--D)if(l[D]==h[2]){l.length=D;break}if(D<0&&(!o||o==h[2]))return{tag:h[2],from:Z(f,p),to:Z(u.line,u.ch)}}else l.push(h[2])}}function C(u,o){for(var l=[];;){var h=A(u);if(!h)return;if(h=="selfClose"){y(u);continue}var L=u.line,f=u.ch,p=y(u);if(!p)return;if(p[1])l.push(p[2]);else{for(var D=l.length-1;D>=0;--D)if(l[D]==p[2]){l.length=D;break}if(D<0&&(!o||o==p[2]))return{tag:p[2],from:Z(u.line,u.ch),to:Z(L,f)}}}}oe.registerHelper("fold","xml",function(u,o){for(var l=new W(u,o.line,0);;){var h=R(l);if(!h||l.line!=o.line)return;var L=v(l);if(!L)return;if(!h[1]&&L!="selfClose"){var f=Z(l.line,l.ch),p=x(l,h[2]);return p&&_(p.from,f)>0?{from:f,to:p.from}:null}}}),oe.findMatchingTag=function(u,o,l){var h=new W(u,o.line,o.ch,l);if(h.text.indexOf(">")==-1&&h.text.indexOf("<")==-1)return;var L=v(h),f=L&&Z(h.line,h.ch),p=L&&y(h);if(!L||!p||_(h,o)>0)return;var D={from:Z(h.line,h.ch),to:f,tag:p[2]};return L=="selfClose"?{open:D,close:null,at:"open"}:p[1]?{open:C(h,p[2]),close:D,at:"close"}:(h=new W(u,f.line,f.ch,l),{open:D,close:x(h,p[2]),at:"open"})},oe.findEnclosingTag=function(u,o,l,h){for(var L=new W(u,o.line,o.ch,l);;){var f=C(L,h);if(!f)break;var p=new W(u,o.line,o.ch,l),D=x(p,f.tag);if(D)return{open:f,close:D}}},oe.scanForClosingTag=function(u,o,l,h){var L=new W(u,o.line,o.ch,h?{from:0,to:h}:null);return x(L,l)}})},p5ED:function(Et,ot,re){"use strict";var oe=re("+L6B"),Z=re("2/Rp"),_=re("5Dmo"),X=re("3S7+"),O=re("k1fw"),I=re("9og8"),W=re("tJVT"),F=re("WmNS"),M=re.n(F),k=re("q1tI"),v=re.n(k),y=re("vHTk"),R=re.n(y),A=re("yEEn"),x=re("ZW9T"),C=re("1vsH"),u=re("V0Rq"),o=re("m3rI"),l=function(L){var f=L.name,p=L.data,D=L.theme,S=L.type,g=L.filename,c=L.monacoEditor,d=L.className,a=L.style,E=L.close,b=L.onClose,T=L.hasMask,P=L.otherData,G=P===void 0?{}:P,Y=Object(k.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),Q=Object(W.a)(Y,2),z=Q[0],j=Q[1],q=Object(k.useState)(""),ae=Object(W.a)(q,2),ce=ae[0],ve=ae[1],ke=Object(k.useState)(),Ee=Object(W.a)(ke,2),Ce=Ee[0],Le=Ee[1],we=window.ENV==="build"?"/react/build/office.html":"/office.html",me,le=1024*1024,Oe=10*le,Ye=Object(k.useRef)();S==="office"&&(me=Object(C.R)(p).filesize,me>Oe&&(S="other")),g&&(c.filename=g),Object(k.useEffect)(function(){var Se,De,Ne=(Se=document.cookie)===null||Se===void 0||((De=Se.replace(/\s/g,""))===null||De===void 0)?void 0:De.split(";");Ne==null||Ne.map(function(Ge){var je=Ge.split("=");je[0]==="_educoder_session"&&ve(je[1])})},[]),Object(k.useEffect)(function(){S==="office"&&Ve()},[S]);var Ve=function(){var Se=Object(I.a)(M.a.mark(function De(){var Ne,Ge,je;return M.a.wrap(function(Ie){for(;;)switch(Ie.prev=Ie.next){case 0:return console.log("data:",p),Ne=p,p.startsWith("http")||(Ne=location.origin+Ne),Ge=new URL(Ne).pathname.split("/").pop(),Ie.next=6,Object(u.U)({attachment_id:Ge});case 6:je=Ie.sent,Le(je);case 8:case"end":return Ie.stop()}},De)}));return function(){return Se.apply(this,arguments)}}(),$e=function(){if(p.startsWith("http")||p.startsWith("blob:")){ze();return}Object(C.x)(g||"educoder",p,g)},ze=function(){Object(C.v)(g||"educoder",decodeURIComponent(p))};return v.a.createElement("div",{style:Object(O.a)({},a||{}),className:"".concat(T&&R.a.bgBlack," ").concat(S?R.a.wrp:"hide")},E&&v.a.createElement("div",{className:R.a.close,ref:Ye},v.a.createElement(X.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return Ye.current}},v.a.createElement("span",{onClick:ze},v.a.createElement("i",{className:"icon-quxiaozhiding"}))),v.a.createElement(X.a,{title:"\u5173\u95ED",getPopupContainer:function(){return Ye.current}},v.a.createElement("span",{className:"",onClick:function(){b(),Le(null)}},v.a.createElement("i",{className:"icon-guanbi1"})))),v.a.createElement("div",{className:"".concat(R.a[d]," ").concat(d," ").concat(R.a.monaco," ").concat(S==="txt"?"show":"hide")},S==="txt"&&v.a.createElement(x.b,c)),S==="audio"&&v.a.createElement("audio",{src:"".concat((p==null?void 0:p.indexOf("http://"))>-1||(p==null?void 0:p.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(p),autoPlay:!0}),S==="video"&&v.a.createElement(v.a.Fragment,null,(p==null?void 0:p.indexOf("http"))>-1?v.a.createElement("video",{controls:!0,src:"".concat(p),autoPlay:!0}):v.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(p),autoPlay:!0})),S==="office"&&Ce&&v.a.createElement("iframe",{src:"".concat(we,"?key=").concat(Ce.key,"&url=").concat(o.a.API_SERVER+Ce.url,"&callbackUrl=").concat(o.a.API_SERVER+Ce.callbackUrl,"&fileType=").concat(Ce.fileType,"&title=").concat(Ce.title,"&model=view")}),(S==="xlsx"||S==="doc"||S==="pptx"||S==="docx")&&v.a.createElement("iframe",{src:"".concat(we,"?key=").concat(G.key,"&url=").concat(o.a.API_SERVER+G.url,"&callbackUrl=").concat(o.a.API_SERVER+G.callbackUrl,"&fileType=").concat(G.fileType,"&title=").concat(G.title,"&model=").concat(G.model)}),S==="html"&&v.a.createElement("iframe",{src:p+"&disposition=inline"}),S==="pdf"&&v.a.createElement("embed",{className:R.a.embed,src:p,type:"application/pdf"}),S==="image"&&v.a.createElement("img",{src:"".concat((p==null?void 0:p.indexOf("http://"))>-1||(p==null?void 0:p.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(p)}),S==="other"&&v.a.createElement("div",null,v.a.createElement(Z.a,{type:"primary",size:"large",onClick:$e},v.a.createElement(A.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),S==="download"&&v.a.createElement(Z.a,{type:"primary",size:"large",onClick:$e},v.a.createElement(A.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))};ot.a=l},"p77/":function(Et,ot,re){},"rAM+":function(Et,ot,re){"use strict";re.d(ot,"a",function(){return Z});var oe=re("Qw5x");function Z(_,X){var O;if(typeof Symbol=="undefined"||_[Symbol.iterator]==null){if(Array.isArray(_)||(O=Object(oe.a)(_))||X&&_&&typeof _.length=="number"){O&&(_=O);var I=0,W=function(){};return{s:W,n:function(){return I>=_.length?{done:!0}:{done:!1,value:_[I++]}},e:function(y){throw y},f:W}}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 F=!0,M=!1,k;return{s:function(){O=_[Symbol.iterator]()},n:function(){var y=O.next();return F=y.done,y},e:function(y){M=!0,k=y},f:function(){try{!F&&O.return!=null&&O.return()}finally{if(M)throw k}}}}},rUJ1:function(Et,ot){const re=/[&<>"']/,oe=/[&<>"']/g,Z=/[<>"']|&(?!#?\w+;)/,_=/[<>"']|&(?!#?\w+;)/g,X={"&":"&","<":"<",">":">",'"':""","'":"'"},O=S=>X[S];function I(S,g){if(g){if(re.test(S))return S.replace(oe,O)}else if(Z.test(S))return S.replace(_,O);return S}const W=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function F(S){return S.replace(W,(g,c)=>(c=c.toLowerCase(),c==="colon"?":":c.charAt(0)==="#"?c.charAt(1)==="x"?String.fromCharCode(parseInt(c.substring(2),16)):String.fromCharCode(+c.substring(1)):""))}const M=/(^|[^\[])\^/g;function k(S,g){S=S.source||S,g=g||"";const c={replace:(d,a)=>(a=a.source||a,a=a.replace(M,"$1"),S=S.replace(d,a),c),getRegex:()=>new RegExp(S,g)};return c}const v=/[^\w:]/g,y=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function R(S,g,c){if(S){let d;try{d=decodeURIComponent(F(c)).replace(v,"").toLowerCase()}catch(a){return null}if(d.indexOf("javascript:")===0||d.indexOf("vbscript:")===0||d.indexOf("data:")===0)return null}g&&!y.test(c)&&(c=o(g,c));try{c=encodeURI(c).replace(/%25/g,"%")}catch(d){return null}return c}const A={},x=/^[^:]+:\/*[^/]*$/,C=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(S,g){A[" "+S]||(x.test(S)?A[" "+S]=S+"/":A[" "+S]=f(S,"/",!0)),S=A[" "+S];const c=S.indexOf(":")===-1;return g.substring(0,2)==="//"?c?g:S.replace(C,"$1")+g:g.charAt(0)==="/"?c?g:S.replace(u,"$1")+g:S+g}const l={exec:function(){}};function h(S){let g=1,c,d;for(;g<arguments.length;g++){c=arguments[g];for(d in c)Object.prototype.hasOwnProperty.call(c,d)&&(S[d]=c[d])}return S}function L(S,g){const c=S.replace(/\|/g,(E,b,T)=>{let P=!1,G=b;for(;--G>=0&&T[G]==="\\";)P=!P;return P?"|":" |"}),d=c.split(/ \|/);let a=0;if(d.length>g)d.splice(g);else for(;d.length<g;)d.push("");for(;a<d.length;a++)d[a]=d[a].trim().replace(/\\\|/g,"|");return d}function f(S,g,c){const d=S.length;if(d===0)return"";let a=0;for(;a<d;){const E=S.charAt(d-a-1);if(E===g&&!c)a++;else if(E!==g&&c)a++;else break}return S.substr(0,d-a)}function p(S,g){if(S.indexOf(g[1])===-1)return-1;const c=S.length;let d=0,a=0;for(;a<c;a++)if(S[a]==="\\")a++;else if(S[a]===g[0])d++;else if(S[a]===g[1]&&(d--,d<0))return a;return-1}function D(S){S&&S.sanitize&&!S.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")}Et.exports={escape:I,unescape:F,edit:k,cleanUrl:R,resolveUrl:o,noopTest:l,merge:h,splitCells:L,rtrim:f,findClosingBracket:p,checkSanitizeDeprecation:D}},ulZh:function(Et,ot,re){typeof window!="undefined"&&function(Z,_){Et.exports=_()}(this,function(){return function(oe){var Z={};function _(X){if(Z[X])return Z[X].exports;var O=Z[X]={i:X,l:!1,exports:{}};return oe[X].call(O.exports,O,O.exports,_),O.l=!0,O.exports}return _.m=oe,_.c=Z,_.d=function(X,O,I){_.o(X,O)||Object.defineProperty(X,O,{enumerable:!0,get:I})},_.r=function(X){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(X,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(X,"__esModule",{value:!0})},_.t=function(X,O){if(O&1&&(X=_(X)),O&8)return X;if(O&4&&typeof X=="object"&&X&&X.__esModule)return X;var I=Object.create(null);if(_.r(I),Object.defineProperty(I,"default",{enumerable:!0,value:X}),O&2&&typeof X!="string")for(var W in X)_.d(I,W,function(F){return X[F]}.bind(null,W));return I},_.n=function(X){var O=X&&X.__esModule?function(){return X.default}:function(){return X};return _.d(O,"a",O),O},_.o=function(X,O){return Object.prototype.hasOwnProperty.call(X,O)},_.p="/dist/",_(_.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(oe,Z,_){"use strict";var X=Object.prototype.hasOwnProperty,O="~";function I(){}Object.create&&(I.prototype=Object.create(null),new I().__proto__||(O=!1));function W(v,y,R){this.fn=v,this.context=y,this.once=R||!1}function F(v,y,R,A,x){if(typeof R!="function")throw new TypeError("The listener must be a function");var C=new W(R,A||v,x),u=O?O+y:y;return v._events[u]?v._events[u].fn?v._events[u]=[v._events[u],C]:v._events[u].push(C):(v._events[u]=C,v._eventsCount++),v}function M(v,y){--v._eventsCount===0?v._events=new I:delete v._events[y]}function k(){this._events=new I,this._eventsCount=0}k.prototype.eventNames=function(){var y=[],R,A;if(this._eventsCount===0)return y;for(A in R=this._events)X.call(R,A)&&y.push(O?A.slice(1):A);return Object.getOwnPropertySymbols?y.concat(Object.getOwnPropertySymbols(R)):y},k.prototype.listeners=function(y){var R=O?O+y:y,A=this._events[R];if(!A)return[];if(A.fn)return[A.fn];for(var x=0,C=A.length,u=new Array(C);x<C;x++)u[x]=A[x].fn;return u},k.prototype.listenerCount=function(y){var R=O?O+y:y,A=this._events[R];return A?A.fn?1:A.length:0},k.prototype.emit=function(y,R,A,x,C,u){var o=O?O+y:y;if(!this._events[o])return!1;var l=this._events[o],h=arguments.length,L,f;if(l.fn){l.once&&this.removeListener(y,l.fn,void 0,!0);switch(h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,R),!0;case 3:return l.fn.call(l.context,R,A),!0;case 4:return l.fn.call(l.context,R,A,x),!0;case 5:return l.fn.call(l.context,R,A,x,C),!0;case 6:return l.fn.call(l.context,R,A,x,C,u),!0}for(f=1,L=new Array(h-1);f<h;f++)L[f-1]=arguments[f];l.fn.apply(l.context,L)}else{var p=l.length,D;for(f=0;f<p;f++){l[f].once&&this.removeListener(y,l[f].fn,void 0,!0);switch(h){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,R);break;case 3:l[f].fn.call(l[f].context,R,A);break;case 4:l[f].fn.call(l[f].context,R,A,x);break;default:if(!L)for(D=1,L=new Array(h-1);D<h;D++)L[D-1]=arguments[D];l[f].fn.apply(l[f].context,L)}}}return!0},k.prototype.on=function(y,R,A){return F(this,y,R,A,!1)},k.prototype.once=function(y,R,A){return F(this,y,R,A,!0)},k.prototype.removeListener=function(y,R,A,x){var C=O?O+y:y;if(!this._events[C])return this;if(!R)return M(this,C),this;var u=this._events[C];if(u.fn)u.fn===R&&(!x||u.once)&&(!A||u.context===A)&&M(this,C);else{for(var o=0,l=[],h=u.length;o<h;o++)(u[o].fn!==R||x&&!u[o].once||A&&u[o].context!==A)&&l.push(u[o]);l.length?this._events[C]=l.length===1?l[0]:l:M(this,C)}return this},k.prototype.removeAllListeners=function(y){var R;return y?(R=O?O+y:y,this._events[R]&&M(this,R)):(this._events=new I,this._eventsCount=0),this},k.prototype.off=k.prototype.removeListener,k.prototype.addListener=k.prototype.on,k.prefixed=O,k.EventEmitter=k,oe.exports=k},"./node_modules/url-toolkit/src/url-toolkit.js":function(oe,Z,_){(function(X){var O=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,I=/^([^\/?#]*)([^]*)$/,W=/(?:\/|^)\.(?=\/)/g,F=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,M={buildAbsoluteURL:function(k,v,y){if(y=y||{},k=k.trim(),v=v.trim(),!v){if(!y.alwaysNormalize)return k;var R=M.parseURL(k);if(!R)throw new Error("Error trying to parse base URL.");return R.path=M.normalizePath(R.path),M.buildURLFromParts(R)}var A=M.parseURL(v);if(!A)throw new Error("Error trying to parse relative URL.");if(A.scheme)return y.alwaysNormalize?(A.path=M.normalizePath(A.path),M.buildURLFromParts(A)):v;var x=M.parseURL(k);if(!x)throw new Error("Error trying to parse base URL.");if(!x.netLoc&&x.path&&x.path[0]!=="/"){var C=I.exec(x.path);x.netLoc=C[1],x.path=C[2]}x.netLoc&&!x.path&&(x.path="/");var u={scheme:x.scheme,netLoc:A.netLoc,path:null,params:A.params,query:A.query,fragment:A.fragment};if(!A.netLoc&&(u.netLoc=x.netLoc,A.path[0]!=="/"))if(!A.path)u.path=x.path,A.params||(u.params=x.params,A.query||(u.query=x.query));else{var o=x.path,l=o.substring(0,o.lastIndexOf("/")+1)+A.path;u.path=M.normalizePath(l)}return u.path===null&&(u.path=y.alwaysNormalize?M.normalizePath(A.path):A.path),M.buildURLFromParts(u)},parseURL:function(k){var v=O.exec(k);return v?{scheme:v[1]||"",netLoc:v[2]||"",path:v[3]||"",params:v[4]||"",query:v[5]||"",fragment:v[6]||""}:null},normalizePath:function(k){for(k=k.split("").reverse().join("").replace(W,"");k.length!==(k=k.replace(F,"")).length;);return k.split("").reverse().join("")},buildURLFromParts:function(k){return k.scheme+k.netLoc+k.path+k.params+k.query+k.fragment}};oe.exports=M})(this)},"./node_modules/webworkify-webpack/index.js":function(oe,Z,_){function X(y){var R={};function A(C){if(R[C])return R[C].exports;var u=R[C]={i:C,l:!1,exports:{}};return y[C].call(u.exports,u,u.exports,A),u.l=!0,u.exports}A.m=y,A.c=R,A.i=function(C){return C},A.d=function(C,u,o){A.o(C,u)||Object.defineProperty(C,u,{configurable:!1,enumerable:!0,get:o})},A.r=function(C){Object.defineProperty(C,"__esModule",{value:!0})},A.n=function(C){var u=C&&C.__esModule?function(){return C.default}:function(){return C};return A.d(u,"a",u),u},A.o=function(C,u){return Object.prototype.hasOwnProperty.call(C,u)},A.p="/",A.oe=function(C){throw console.error(C),C};var x=A(A.s=ENTRY_MODULE);return x.default||x}var O="[\\.|\\-|\\+|\\w|/|@]+",I="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+O+").*?\\)";function W(y){return(y+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function F(y){return!isNaN(1*y)}function M(y,R,A){var x={};x[A]=[];var C=R.toString(),u=C.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return x;for(var o=u[1],l=new RegExp("(\\\\n|\\W)"+W(o)+I,"g"),h;h=l.exec(C);){if(h[3]==="dll-reference")continue;x[A].push(h[3])}for(l=new RegExp("\\("+W(o)+'\\("(dll-reference\\s('+O+'))"\\)\\)'+I,"g");h=l.exec(C);)y[h[2]]||(x[A].push(h[1]),y[h[2]]=_(h[1]).m),x[h[2]]=x[h[2]]||[],x[h[2]].push(h[4]);for(var L=Object.keys(x),f=0;f<L.length;f++)for(var p=0;p<x[L[f]].length;p++)F(x[L[f]][p])&&(x[L[f]][p]=1*x[L[f]][p]);return x}function k(y){var R=Object.keys(y);return R.reduce(function(A,x){return A||y[x].length>0},!1)}function v(y,R){for(var A={main:[R]},x={main:[]},C={main:{}};k(A);)for(var u=Object.keys(A),o=0;o<u.length;o++){var l=u[o],h=A[l],L=h.pop();if(C[l]=C[l]||{},C[l][L]||!y[l][L])continue;C[l][L]=!0,x[l]=x[l]||[],x[l].push(L);for(var f=M(y,y[l][L],l),p=Object.keys(f),D=0;D<p.length;D++)A[p[D]]=A[p[D]]||[],A[p[D]]=A[p[D]].concat(f[p[D]])}return x}oe.exports=function(y,R){R=R||{};var A={main:_.m},x=R.all?{main:Object.keys(A.main)}:v(A,y),C="";Object.keys(x).filter(function(L){return L!=="main"}).forEach(function(L){for(var f=0;x[L][f];)f++;x[L].push(f),A[L][f]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",C=C+"var "+L+" = ("+X.toString().replace("ENTRY_MODULE",JSON.stringify(f))+")({"+x[L].map(function(p){return""+JSON.stringify(p)+": "+A[L][p].toString()}).join(",")+`});
|
|
`}),C=C+"new (("+X.toString().replace("ENTRY_MODULE",JSON.stringify(y))+")({"+x.main.map(function(L){return""+JSON.stringify(L)+": "+A.main[L].toString()}).join(",")+"}))(self);";var u=new window.Blob([C],{type:"text/javascript"});if(R.bare)return u;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,l=o.createObjectURL(u),h=new window.Worker(l);return h.objectURL=l,h}},"./src/config.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"hlsDefaultConfig",function(){return D}),_.d(Z,"mergeConfig",function(){return g}),_.d(Z,"enableStreamingMode",function(){return c});var X=_("./src/controller/abr-controller.ts"),O=_("./src/controller/audio-stream-controller.ts"),I=_("./src/controller/audio-track-controller.ts"),W=_("./src/controller/subtitle-stream-controller.ts"),F=_("./src/controller/subtitle-track-controller.ts"),M=_("./src/controller/buffer-controller.ts"),k=_("./src/controller/timeline-controller.ts"),v=_("./src/controller/cap-level-controller.ts"),y=_("./src/controller/fps-controller.ts"),R=_("./src/controller/eme-controller.ts"),A=_("./src/controller/cmcd-controller.ts"),x=_("./src/utils/xhr-loader.ts"),C=_("./src/utils/fetch-loader.ts"),u=_("./src/utils/cues.ts"),o=_("./src/utils/mediakeys-helper.ts"),l=_("./src/utils/logger.ts");function h(){return h=Object.assign||function(d){for(var a=1;a<arguments.length;a++){var E=arguments[a];for(var b in E)Object.prototype.hasOwnProperty.call(E,b)&&(d[b]=E[b])}return d},h.apply(this,arguments)}function L(d,a){var E=Object.keys(d);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(d);a&&(b=b.filter(function(T){return Object.getOwnPropertyDescriptor(d,T).enumerable})),E.push.apply(E,b)}return E}function f(d){for(var a=1;a<arguments.length;a++){var E=arguments[a]!=null?arguments[a]:{};a%2?L(Object(E),!0).forEach(function(b){p(d,b,E[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(E)):L(Object(E)).forEach(function(b){Object.defineProperty(d,b,Object.getOwnPropertyDescriptor(E,b))})}return d}function p(d,a,E){return a in d?Object.defineProperty(d,a,{value:E,enumerable:!0,configurable:!0,writable:!0}):d[a]=E,d}var D=f(f({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:x.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:X.default,bufferController:M.default,capLevelController:v.default,fpsController:y.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:o.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},S()),{},{subtitleStreamController:W.SubtitleStreamController,subtitleTrackController:F.default,timelineController:k.TimelineController,audioStreamController:O.default,audioTrackController:I.default,emeController:R.default,cmcdController:A.default});function S(){return{cueHandler:u.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 g(d,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 h({},d,a)}function c(d){var a=d.loader;if(a!==C.default&&a!==x.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var E=Object(C.fetchSupported)();E&&(d.loader=C.default,d.progressive=!0,d.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/polyfills/number.ts"),O=_("./src/utils/ewma-bandwidth-estimator.ts"),I=_("./src/events.ts"),W=_("./src/utils/buffer-helper.ts"),F=_("./src/errors.ts"),M=_("./src/types/loader.ts"),k=_("./src/utils/logger.ts");function v(A,x){for(var C=0;C<x.length;C++){var u=x[C];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(A,u.key,u)}}function y(A,x,C){return x&&v(A.prototype,x),C&&v(A,C),A}var R=function(){function A(C){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=C;var u=C.config;this.bwEstimator=new O.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var x=A.prototype;return x.registerListeners=function(){var u=this.hls;u.on(I.Events.FRAG_LOADING,this.onFragLoading,this),u.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(I.Events.ERROR,this.onError,this)},x.unregisterListeners=function(){var u=this.hls;u.off(I.Events.FRAG_LOADING,this.onFragLoading,this),u.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(I.Events.ERROR,this.onError,this)},x.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},x.onFragLoading=function(u,o){var l=o.frag;if(l.type===M.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=l,this.partCurrent=(h=o.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},x.onLevelLoaded=function(u,o){var l=this.hls.config;o.details.live?this.bwEstimator.update(l.abrEwmaSlowLive,l.abrEwmaFastLive):this.bwEstimator.update(l.abrEwmaSlowVoD,l.abrEwmaFastVoD)},x._abandonRulesCheck=function(){var u=this.fragCurrent,o=this.partCurrent,l=this.hls,h=l.autoLevelEnabled,L=l.config,f=l.media;if(!u||!f)return;var p=o?o.stats:u.stats,D=o?o.duration:u.duration;if(p.aborted){k.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!h||f.paused||!f.playbackRate||!f.readyState)return;var S=performance.now()-p.loading.start,g=Math.abs(f.playbackRate);if(S<=500*D/g)return;var c=l.levels,d=l.minAutoLevel,a=c[u.level],E=p.total||Math.max(p.loaded,Math.round(D*a.maxBitrate/8)),b=Math.max(1,p.bwEstimate?p.bwEstimate/8:p.loaded*1e3/S),T=(E-p.loaded)/b,P=f.currentTime,G=(W.BufferHelper.bufferInfo(f,P,L.maxBufferHole).end-P)/g;if(G>=2*D/g||T<=G)return;var Y=Number.POSITIVE_INFINITY,Q;for(Q=u.level-1;Q>d;Q--){var z=c[Q].maxBitrate;if(Y=D*z/(8*.8*b),Y<G)break}if(Y>=T)return;var j=this.bwEstimator.getEstimate();k.logger.warn("Fragment "+u.sn+(o?" part "+o.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+Q+`
|
|
Current BW estimate: `+(Object(X.isFiniteNumber)(j)?(j/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+T.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+Y.toFixed(3)+` s
|
|
Time to underbuffer: `+G.toFixed(3)+" s"),l.nextLoadLevel=Q,this.bwEstimator.sample(S,p.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),l.trigger(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:o,stats:p})},x.onFragLoaded=function(u,o){var l=o.frag,h=o.part;if(l.type===M.PlaylistLevelType.MAIN&&Object(X.isFiniteNumber)(l.sn)){var L=h?h.stats:l.stats,f=h?h.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var p=this.hls.levels[l.level],D=(p.loaded?p.loaded.bytes:0)+L.loaded,S=(p.loaded?p.loaded.duration:0)+f;p.loaded={bytes:D,duration:S},p.realBitrate=Math.round(8*D/S)}if(l.bitrateTest){var g={stats:L,frag:l,part:h,id:l.type};this.onFragBuffered(I.Events.FRAG_BUFFERED,g),l.bitrateTest=!1}}},x.onFragBuffered=function(u,o){var l=o.frag,h=o.part,L=h?h.stats:l.stats;if(L.aborted)return;if(l.type!==M.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var f=L.parsing.end-L.loading.start;this.bwEstimator.sample(f,L.loaded),L.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=f/1e3:this.bitrateTestDelay=0},x.onError=function(u,o){switch(o.details){case F.ErrorDetails.FRAG_LOAD_ERROR:case F.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},x.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},x.getNextABRAutoLevel=function(){var u=this.fragCurrent,o=this.partCurrent,l=this.hls,h=l.maxAutoLevel,L=l.config,f=l.minAutoLevel,p=l.media,D=o?o.duration:u?u.duration:0,S=p?p.currentTime:0,g=p&&p.playbackRate!==0?Math.abs(p.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():L.abrEwmaDefaultEstimate,d=(W.BufferHelper.bufferInfo(p,S,L.maxBufferHole).end-S)/g,a=this.findBestLevel(c,f,h,d,L.abrBandWidthFactor,L.abrBandWidthUpFactor);if(a>=0)return a;k.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var E=D?Math.min(D,L.maxStarvationDelay):L.maxStarvationDelay,b=L.abrBandWidthFactor,T=L.abrBandWidthUpFactor;if(!d){var P=this.bitrateTestDelay;if(P){var G=D?Math.min(D,L.maxLoadingDelay):L.maxLoadingDelay;E=G-P,k.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*E)+" ms"),b=T=1}}return a=this.findBestLevel(c,f,h,d+E,b,T),Math.max(a,0)},x.findBestLevel=function(u,o,l,h,L,f){for(var p,D=this.fragCurrent,S=this.partCurrent,g=this.lastLoadedFragLevel,c=this.hls.levels,d=c[g],a=!!(d!=null&&(p=d.details)!==null&&p!==void 0&&p.live),E=d==null?void 0:d.codecSet,b=S?S.duration:D?D.duration:0,T=l;T>=o;T--){var P=c[T];if(!P||E&&P.codecSet!==E)continue;var G=P.details,Y=(S?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||b,Q=void 0;T<=g?Q=L*u:Q=f*u;var z=c[T].maxBitrate,j=z*Y/Q;if(k.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+T+"/"+Math.round(Q)+"/"+z+"/"+Y+"/"+h+"/"+j),Q>z&&(!j||a&&!this.bitrateTestDelay||j<h))return T}return-1},y(A,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,o=this.bwEstimator;if(u!==-1&&(!o||!o.canEstimate()))return u;var l=this.getNextABRAutoLevel();return u!==-1&&(l=Math.min(u,l)),l},set:function(u){this._nextAutoLevel=u}}]),A}();Z.default=R},"./src/controller/audio-stream-controller.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/polyfills/number.ts"),O=_("./src/controller/base-stream-controller.ts"),I=_("./src/events.ts"),W=_("./src/utils/buffer-helper.ts"),F=_("./src/controller/fragment-tracker.ts"),M=_("./src/types/level.ts"),k=_("./src/types/loader.ts"),v=_("./src/loader/fragment.ts"),y=_("./src/demux/chunk-cache.ts"),R=_("./src/demux/transmuxer-interface.ts"),A=_("./src/types/transmuxer.ts"),x=_("./src/controller/fragment-finders.ts"),C=_("./src/utils/discontinuities.ts"),u=_("./src/errors.ts"),o=_("./src/utils/logger.ts");function l(){return l=Object.assign||function(D){for(var S=1;S<arguments.length;S++){var g=arguments[S];for(var c in g)Object.prototype.hasOwnProperty.call(g,c)&&(D[c]=g[c])}return D},l.apply(this,arguments)}function h(D,S){D.prototype=Object.create(S.prototype),D.prototype.constructor=D,L(D,S)}function L(D,S){return L=Object.setPrototypeOf||function(c,d){return c.__proto__=d,c},L(D,S)}var f=100,p=function(D){h(S,D);function S(c,d){var a;return a=D.call(this,c,d,"[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 g=S.prototype;return g.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},g._registerListeners=function(){var d=this.hls;d.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(I.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.on(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.on(I.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(I.Events.ERROR,this.onError,this),d.on(I.Events.BUFFER_RESET,this.onBufferReset,this),d.on(I.Events.BUFFER_CREATED,this.onBufferCreated,this),d.on(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.on(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g._unregisterListeners=function(){var d=this.hls;d.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(I.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.off(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.off(I.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(I.Events.ERROR,this.onError,this),d.off(I.Events.BUFFER_RESET,this.onBufferReset,this),d.off(I.Events.BUFFER_CREATED,this.onBufferCreated,this),d.off(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.off(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g.onInitPtsFound=function(d,a){var E=a.frag,b=a.id,T=a.initPTS;if(b==="main"){var P=E.cc;this.initPTS[E.cc]=T,this.log("InitPTS for cc: "+P+" found from main: "+T),this.videoTrackCC=P,this.state===O.State.WAITING_INIT_PTS&&this.tick()}},g.startLoad=function(d){if(!this.levels){this.startPosition=d,this.state=O.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(f),this.fragLoadError=0,a>0&&d===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=O.State.IDLE):(this.loadedmetadata=!1,this.state=O.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=d,this.tick()},g.doTick=function(){switch(this.state){case O.State.IDLE:this.doTickIdle();break;case O.State.WAITING_TRACK:{var d,a=this.levels,E=this.trackId,b=a==null||((d=a[E])===null||d===void 0)?void 0:d.details;if(b){if(this.waitForCdnTuneIn(b))break;this.state=O.State.WAITING_INIT_PTS}break}case O.State.FRAG_LOADING_WAITING_RETRY:{var T,P=performance.now(),G=this.retryDate;(!G||P>=G||(T=this.media)!==null&&T!==void 0&&T.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=O.State.IDLE);break}case O.State.WAITING_INIT_PTS:{var Y=this.waitingData;if(Y){var Q=Y.frag,z=Y.part,j=Y.cache,q=Y.complete;if(this.initPTS[Q.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=O.State.FRAG_LOADING;var ae=j.flush(),ce={frag:Q,part:z,payload:ae,networkDetails:null};this._handleFragmentLoadProgress(ce),q&&D.prototype._handleFragmentLoadComplete.call(this,ce)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+Q.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ve=this.getLoadPosition(),ke=W.BufferHelper.bufferInfo(this.mediaBuffer,ve,this.config.maxBufferHole),Ee=Object(x.fragmentWithinToleranceTest)(ke.end,this.config.maxFragLookUpTolerance,Q);Ee<0&&(o.logger.log("Waiting fragment cc ("+Q.cc+") @ "+Q.start+" cancelled because another fragment at "+ke.end+" is needed"),this.clearWaitingFragment())}}else this.state=O.State.IDLE}}this.onTickEnd()},g.clearWaitingFragment=function(){var d=this.waitingData;d&&(this.fragmentTracker.removeFragment(d.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=O.State.IDLE)},g.onTickEnd=function(){var d=this.media;if(!d||!d.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:d,E=a.buffered;!this.loadedmetadata&&E.length&&(this.loadedmetadata=!0),this.lastCurrentTime=d.currentTime},g.doTickIdle=function(){var d,a,E=this.hls,b=this.levels,T=this.media,P=this.trackId,G=E.config;if(!b||!b[P])return;if(!T&&(this.startFragRequested||!G.startFragPrefetch))return;var Y=b[P],Q=Y.details;if(!Q||Q.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(Q)){this.state=O.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,v.ElementaryStreamTypes.AUDIO,k.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,k.PlaylistLevelType.AUDIO);if(z===null)return;var j=z.len,q=this.getMaxBufferLength(),ae=this.audioSwitch;if(j>=q&&!ae)return;if(!ae&&this._streamEnded(z,Q)){E.trigger(I.Events.BUFFER_EOS,{type:"audio"}),this.state=O.State.ENDED;return}var ce=Q.fragments,ve=ce[0].start,ke=z.end;if(ae){var Ee=this.getLoadPosition();ke=Ee,Q.PTSKnown&&Ee<ve&&((z.end>ve||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),T.currentTime=ve+.05))}var Ce=this.getNextFragment(ke,Q);if(!Ce){this.bufferFlushed=!0;return}((d=Ce.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((a=Ce.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Ce,Q):this.loadFragment(Ce,Q,ke)},g.getMaxBufferLength=function(){var d=D.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,k.PlaylistLevelType.MAIN);return a===null?d:Math.max(d,a.len)},g.onMediaDetaching=function(){this.videoBuffer=null,D.prototype.onMediaDetaching.call(this)},g.onAudioTracksUpdated=function(d,a){var E=a.audioTracks;this.resetTransmuxer(),this.levels=E.map(function(b){return new M.Level(b)})},g.onAudioTrackSwitching=function(d,a){var E=!!a.url;this.trackId=a.id;var b=this.fragCurrent;b!=null&&b.loader&&b.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),E?this.setInterval(f):this.resetTransmuxer(),E?(this.audioSwitch=!0,this.state=O.State.IDLE):this.state=O.State.STOPPED,this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},g.onLevelLoaded=function(d,a){this.mainDetails=a.details},g.onAudioTrackLoaded=function(d,a){var E,b=this.levels,T=a.details,P=a.id;if(!b){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+T.startSN+","+T.endSN+"],duration:"+T.totalduration);var G=b[P],Y=0;if(T.live||(E=G.details)!==null&&E!==void 0&&E.live){var Q=this.mainDetails;if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed||!Q)return;!G.details&&T.hasProgramDateTime&&Q.hasProgramDateTime?(Object(C.alignMediaPlaylistByPDT)(T,Q),Y=T.fragments[0].start):Y=this.alignPlaylists(T,G.details)}G.details=T,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!T.live)&&this.setStartPosition(G.details,Y),this.state===O.State.WAITING_TRACK&&!this.waitForCdnTuneIn(T)&&(this.state=O.State.IDLE),this.tick()},g._handleFragmentLoadProgress=function(d){var a,E=d.frag,b=d.part,T=d.payload,P=this.config,G=this.trackId,Y=this.levels;if(!Y){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+E.sn+" of level "+E.level+" will not be buffered");return}var Q=Y[G];console.assert(Q,"Audio track is defined on fragment load progress");var z=Q.details;console.assert(z,"Audio track details are defined on fragment load progress");var j=P.defaultAudioCodec||Q.audioCodec||"mp4a.40.2",q=this.transmuxer;q||(q=this.transmuxer=new R.default(this.hls,k.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ae=this.initPTS[E.cc],ce=(a=E.initSegment)===null||a===void 0?void 0:a.data;if(ae!==void 0){var ve=!1,ke=b?b.index:-1,Ee=ke!==-1,Ce=new A.ChunkMetadata(E.level,E.sn,E.stats.chunkCount,T.byteLength,ke,Ee);q.push(T,ce,j,"",E,b,z.totalduration,ve,Ce,ae)}else{o.logger.log("Unknown video PTS for cc "+E.cc+", waiting for video PTS before demuxing audio frag "+E.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+G);var Le=this.waitingData=this.waitingData||{frag:E,part:b,cache:new y.default,complete:!1},we=Le.cache;we.push(new Uint8Array(T)),this.waitingVideoCC=this.videoTrackCC,this.state=O.State.WAITING_INIT_PTS}},g._handleFragmentLoadComplete=function(d){if(this.waitingData){this.waitingData.complete=!0;return}D.prototype._handleFragmentLoadComplete.call(this,d)},g.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},g.onBufferCreated=function(d,a){var E=a.tracks.audio;E&&(this.mediaBuffer=E.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},g.onFragBuffered=function(d,a){var E=a.frag,b=a.part;if(E.type!==k.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(E)){this.warn("Fragment "+E.sn+(b?" p: "+b.index:"")+" of level "+E.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}E.sn!=="initSegment"&&(this.fragPrevious=E,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(E,b)},g.onError=function(d,a){switch(a.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(k.PlaylistLevelType.AUDIO,a);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==O.State.ERROR&&this.state!==O.State.STOPPED&&(this.state=a.fatal?O.State.ERROR:O.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===O.State.PARSING||this.state===O.State.PARSED)){var E=!0,b=this.getFwdBufferInfo(this.mediaBuffer,k.PlaylistLevelType.AUDIO);b&&b.len>.5&&(E=!this.reduceMaxBufferLength(b.len)),E&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,D.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},g.onBufferFlushed=function(d,a){var E=a.type;E===v.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},g._handleTransmuxComplete=function(d){var a,E="audio",b=this.hls,T=d.remuxResult,P=d.chunkMeta,G=this.getCurrentContext(P);if(!G){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 Y=G.frag,Q=G.part,z=T.audio,j=T.text,q=T.id3,ae=T.initSegment;if(this.fragContextChanged(Y))return;if(this.state=O.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),ae!=null&&ae.tracks&&(this._bufferInitSegment(ae.tracks,Y,P),b.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:Y,id:E,tracks:ae.tracks})),z){var ce=z.startPTS,ve=z.endPTS,ke=z.startDTS,Ee=z.endDTS;Q&&(Q.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:ce,endPTS:ve,startDTS:ke,endDTS:Ee}),Y.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,ce,ve,ke,Ee),this.bufferFragmentData(z,Y,Q,P)}if(q!=null&&(a=q.samples)!==null&&a!==void 0&&a.length){var Ce=l({frag:Y,id:E},q);b.trigger(I.Events.FRAG_PARSING_METADATA,Ce)}if(j){var Le=l({frag:Y,id:E},j);b.trigger(I.Events.FRAG_PARSING_USERDATA,Le)}},g._bufferInitSegment=function(d,a,E){if(this.state!==O.State.PARSING)return;d.video&&delete d.video;var b=d.audio;if(!b)return;b.levelCodec=b.codec,b.id="audio",this.log("Init audio buffer, container:"+b.container+", codecs[parsed]=["+b.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,d);var T=b.initSegment;if(T!=null&&T.byteLength){var P={type:"audio",frag:a,part:null,chunkMeta:E,parent:a.type,data:T};this.hls.trigger(I.Events.BUFFER_APPENDING,P)}this.tick()},g.loadFragment=function(d,a,E){var b=this.fragmentTracker.getState(d);this.fragCurrent=d,(this.audioSwitch||b===F.FragmentState.NOT_LOADED||b===F.FragmentState.PARTIAL)&&(d.sn==="initSegment"?this._loadInitSegment(d):a.live&&!Object(X.isFiniteNumber)(this.initPTS[d.cc])?(this.log("Waiting for video PTS in continuity counter "+d.cc+" of live stream before loading audio fragment "+d.sn+" of level "+this.trackId),this.state=O.State.WAITING_INIT_PTS):(this.startFragRequested=!0,D.prototype.loadFragment.call(this,d,a,E)))},g.completeAudioSwitch=function(){var d=this.hls,a=this.media,E=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),D.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,d.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:E})},S}(O.default);Z.default=p},"./src/controller/audio-track-controller.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/events.ts"),O=_("./src/errors.ts"),I=_("./src/controller/base-playlist-controller.ts"),W=_("./src/types/loader.ts");function F(R,A){for(var x=0;x<A.length;x++){var C=A[x];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(R,C.key,C)}}function M(R,A,x){return A&&F(R.prototype,A),x&&F(R,x),R}function k(R,A){R.prototype=Object.create(A.prototype),R.prototype.constructor=R,v(R,A)}function v(R,A){return v=Object.setPrototypeOf||function(C,u){return C.__proto__=u,C},v(R,A)}var y=function(R){k(A,R);function A(C){var u;return u=R.call(this,C,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var x=A.prototype;return x.registerListeners=function(){var u=this.hls;u.on(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(X.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(X.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(X.Events.ERROR,this.onError,this)},x.unregisterListeners=function(){var u=this.hls;u.off(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(X.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(X.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(X.Events.ERROR,this.onError,this)},x.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,R.prototype.destroy.call(this)},x.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},x.onManifestParsed=function(u,o){this.tracks=o.audioTracks||[]},x.onAudioTrackLoaded=function(u,o){var l=o.id,h=o.details,L=this.tracksInGroup[l];if(!L){this.warn("Invalid audio track id "+l);return}var f=L.details;L.details=o.details,this.log("audioTrack "+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,o,f))},x.onLevelLoading=function(u,o){this.switchLevel(o.level)},x.onLevelSwitching=function(u,o){this.switchLevel(o.level)},x.switchLevel=function(u){var o=this.hls.levels[u];if(!(o!=null&&o.audioGroupIds))return;var l=o.audioGroupIds[o.urlId];if(this.groupId!==l){this.groupId=l;var h=this.tracks.filter(function(f){return!l||f.groupId===l});this.selectDefaultTrack&&!h.some(function(f){return f.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var L={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(X.Events.AUDIO_TRACKS_UPDATED,L),this.selectInitialTrack()}},x.onError=function(u,o){if(R.prototype.onError.call(this,u,o),o.fatal||!o.context)return;o.context.type===W.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},x.setAudioTrack=function(u){var o=this.tracksInGroup;if(u<0||u>=o.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=o[this.trackId];this.log("Now switching to audio-track index "+u);var h=o[u],L=h.id,f=h.groupId,p=f===void 0?"":f,D=h.name,S=h.type,g=h.url;if(this.trackId=u,this.trackName=D,this.selectDefaultTrack=!1,this.hls.trigger(X.Events.AUDIO_TRACK_SWITCHING,{id:L,groupId:p,name:D,type:S,url:g}),h.details&&!h.details.live)return;var c=this.switchParams(h.url,l==null?void 0:l.details);this.loadPlaylist(c)},x.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.length,"Initial audio track should be selected when tracks are known");var o=this.trackName,l=this.findTrackId(o)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},x.findTrackId=function(u){for(var o=this.tracksInGroup,l=0;l<o.length;l++){var h=o[l];if((!this.selectDefaultTrack||h.default)&&(!u||u===h.name))return h.id}return-1},x.loadPlaylist=function(u){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var l=o.id,h=o.groupId,L=o.url;if(u)try{L=u.addDirectives(L)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(X.Events.AUDIO_TRACK_LOADING,{url:L,id:l,groupId:h,deliveryDirectives:u||null})}},M(A,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),A}(I.default);Z.default=y},"./src/controller/base-playlist-controller.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return M});var X=_("./src/polyfills/number.ts"),O=_("./src/types/level.ts"),I=_("./src/controller/level-helper.ts"),W=_("./src/utils/logger.ts"),F=_("./src/errors.ts"),M=function(){function k(y,R){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=W.logger.log.bind(W.logger,R+":"),this.warn=W.logger.warn.bind(W.logger,R+":"),this.hls=y}var v=k.prototype;return v.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},v.onError=function(R,A){A.fatal&&A.type===F.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(R,A){var x=A==null?void 0:A.renditionReports;if(x)for(var C=0;C<x.length;C++){var u=x[C],o=""+u.URI;if(o===R.substr(-o.length)){var l=parseInt(u["LAST-MSN"]),h=parseInt(u["LAST-PART"]);if(A&&this.hls.config.lowLatencyMode){var L=Math.min(A.age-A.partTarget,A.targetduration);h!==void 0&&L>A.partTarget&&(h+=1)}if(Object(X.isFiniteNumber)(l))return new O.HlsUrlParameters(l,Object(X.isFiniteNumber)(h)?h:void 0,O.HlsSkip.No)}}},v.loadPlaylist=function(R){},v.shouldLoadTrack=function(R){return this.canLoad&&R&&!!R.url&&(!R.details||R.details.live)},v.playlistLoaded=function(R,A,x){var C=this,u=A.details,o=A.stats,l=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(u.advancedDateTime=Date.now()-l,u.live||x!=null&&x.live){if(u.reloaded(x),x&&this.log("live playlist "+R+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),x&&u.fragments.length>0&&Object(I.mergeDetails)(x,u),!this.canLoad||!u.live)return;var h,L=void 0,f=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var p=this.hls.config.lowLatencyMode,D=u.lastPartSn,S=u.endSN,g=u.lastPartIndex,c=g!==-1,d=D===S,a=p?0:g;c?(L=d?S+1:D,f=d?a:g+1):L=S+1;var E=u.age,b=E+u.ageHeader,T=Math.min(b-u.partTarget,u.targetduration*1.5);if(T>0){if(x&&T>x.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+x.tuneInGoal+" to: "+T+" with playlist age: "+u.age),T=0;else{var P=Math.floor(T/u.targetduration);if(L+=P,f!==void 0){var G=Math.round(T%u.targetduration/u.partTarget);f+=G}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+E.toFixed(2)+"s goal: "+T+" skip sn "+P+" to part "+f)}u.tuneInGoal=T}if(h=this.getDeliveryDirectives(u,A.deliveryDirectives,L,f),p||!d){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(u,A.deliveryDirectives,L,f);var Y=Object(I.computeReloadInterval)(u,o);L!==void 0&&u.canBlockReload&&(Y-=u.partTarget||1),this.log("reload live playlist "+R+" in "+Math.round(Y)+" ms"),this.timer=self.setTimeout(function(){return C.loadPlaylist(h)},Y)}else this.clearTimer()},v.getDeliveryDirectives=function(R,A,x,C){var u=Object(O.getSkipValue)(R,x);return A!=null&&A.skip&&R.deltaUpdateFailed&&(x=A.msn,C=A.part,u=O.HlsSkip.No),new O.HlsUrlParameters(x,C,u)},v.retryLoadingOrFail=function(R){var A=this,x=this.hls.config,C=this.retryCount<x.levelLoadingMaxRetry;if(C){var u;if(this.retryCount++,R.details.indexOf("LoadTimeOut")>-1&&(u=R.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+R.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*x.levelLoadingRetryDelay,x.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return A.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+R.details+'"')}}else this.warn('cannot recover from error "'+R.details+'"'),this.clearTimer(),R.fatal=!0;return C},k}()},"./src/controller/base-stream-controller.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"State",function(){return S}),_.d(Z,"default",function(){return g});var X=_("./src/polyfills/number.ts"),O=_("./src/task-loop.ts"),I=_("./src/controller/fragment-tracker.ts"),W=_("./src/utils/buffer-helper.ts"),F=_("./src/utils/logger.ts"),M=_("./src/events.ts"),k=_("./src/errors.ts"),v=_("./src/types/transmuxer.ts"),y=_("./src/utils/mp4-tools.ts"),R=_("./src/utils/discontinuities.ts"),A=_("./src/controller/fragment-finders.ts"),x=_("./src/controller/level-helper.ts"),C=_("./src/loader/fragment-loader.ts"),u=_("./src/crypt/decrypter.ts"),o=_("./src/utils/time-ranges.ts"),l=_("./src/types/loader.ts");function h(c,d){for(var a=0;a<d.length;a++){var E=d[a];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(c,E.key,E)}}function L(c,d,a){return d&&h(c.prototype,d),a&&h(c,a),c}function f(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function p(c,d){c.prototype=Object.create(d.prototype),c.prototype.constructor=c,D(c,d)}function D(c,d){return D=Object.setPrototypeOf||function(E,b){return E.__proto__=b,E},D(c,d)}var S={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"},g=function(c){p(d,c);function d(E,b,T){var P;return P=c.call(this)||this,P.hls=void 0,P.fragPrevious=null,P.fragCurrent=null,P.fragmentTracker=void 0,P.transmuxer=null,P._state=S.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=F.logger.log.bind(F.logger,T+":"),P.warn=F.logger.warn.bind(F.logger,T+":"),P.hls=E,P.fragmentLoader=new C.default(E.config),P.fragmentTracker=b,P.config=E.config,P.decrypter=new u.default(E,E.config),E.on(M.Events.KEY_LOADED,P.onKeyLoaded,f(P)),P}var a=d.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(b){},a.stopLoad=function(){this.fragmentLoader.abort();var b=this.fragCurrent;b&&this.fragmentTracker.removeFragment(b),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=S.STOPPED},a._streamEnded=function(b,T){var P=this.fragCurrent,G=this.fragmentTracker;if(!T.live&&P&&P.sn===T.endSN&&!b.nextStart){var Y=G.getState(P);return Y===I.FragmentState.PARTIAL||Y===I.FragmentState.OK}return!1},a.onMediaAttached=function(b,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 G=this.config;this.levels&&G.autoStartLoad&&this.state===S.STOPPED&&this.startLoad(G.startPosition)},a.onMediaDetaching=function(){var b=this.media;b!=null&&b.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),b&&(b.removeEventListener("seeking",this.onvseeking),b.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 b=this.config,T=this.fragCurrent,P=this.media,G=this.mediaBuffer,Y=this.state,Q=P?P.currentTime:0,z=W.BufferHelper.bufferInfo(G||P,Q,b.maxBufferHole);if(this.log("media seeking to "+(Object(X.isFiniteNumber)(Q)?Q.toFixed(3):Q)+", state: "+Y),Y===S.ENDED)this.resetLoadingState();else if(T&&!z.len){var j=b.maxFragLookUpTolerance,q=T.start-j,ae=T.start+T.duration+j,ce=Q>ae;(Q<q||ce)&&(ce&&T.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),T.loader.abort()),this.resetLoadingState())}P&&(this.lastCurrentTime=Q),!this.loadedmetadata&&!z.len&&(this.nextLoadPosition=this.startPosition=Q),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(b,T){if(this.state!==S.KEY_LOADING||T.frag!==this.fragCurrent||!this.levels)return;this.state=S.IDLE;var P=this.levels[T.frag.level].details;P&&this.loadFragment(T.frag,P,T.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=S.STOPPED,this.hls.off(M.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,c.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(b,T){this.log("Loading key for "+b.sn+" of ["+T.startSN+"-"+T.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+b.level),this.state=S.KEY_LOADING,this.fragCurrent=b,this.hls.trigger(M.Events.KEY_LOADING,{frag:b})},a.loadFragment=function(b,T,P){this._loadFragForPlayback(b,T,P)},a._loadFragForPlayback=function(b,T,P){var G=this,Y=function(z){if(G.fragContextChanged(b)){G.warn("Fragment "+b.sn+(z.part?" p: "+z.part.index:"")+" of level "+b.level+" was dropped during download."),G.fragmentTracker.removeFragment(b);return}b.stats.chunkCount++,G._handleFragmentLoadProgress(z)};this._doFragLoad(b,T,P,Y).then(function(Q){if(!Q)return;G.fragLoadError=0;var z=G.state;if(G.fragContextChanged(b)){(z===S.FRAG_LOADING||z===S.BACKTRACKING||!G.fragCurrent&&z===S.PARSING)&&(G.fragmentTracker.removeFragment(b),G.state=S.IDLE);return}if("payload"in Q&&(G.log("Loaded fragment "+b.sn+" of level "+b.level),G.hls.trigger(M.Events.FRAG_LOADED,Q),G.state===S.BACKTRACKING)){G.fragmentTracker.backtrack(b,Q),G.resetFragmentLoading(b);return}G._handleFragmentLoadComplete(Q)}).catch(function(Q){G.warn(Q),G.resetFragmentLoading(b)})},a.flushMainBuffer=function(b,T,P){if(P===void 0&&(P=null),!(b-T))return;var G={startOffset:b,endOffset:T,type:P};this.fragLoadError=0,this.hls.trigger(M.Events.BUFFER_FLUSHING,G)},a._loadInitSegment=function(b){var T=this;this._doFragLoad(b).then(function(P){if(!P||T.fragContextChanged(b)||!T.levels)throw new Error("init load aborted");return P}).then(function(P){var G=T.hls,Y=P.payload,Q=b.decryptdata;if(Y&&Y.byteLength>0&&Q&&Q.key&&Q.iv&&Q.method==="AES-128"){var z=self.performance.now();return T.decrypter.webCryptoDecrypt(new Uint8Array(Y),Q.key.buffer,Q.iv.buffer).then(function(j){var q=self.performance.now();return G.trigger(M.Events.FRAG_DECRYPTED,{frag:b,payload:j,stats:{tstart:z,tdecrypt:q}}),P.payload=j,P})}return P}).then(function(P){var G=T.fragCurrent,Y=T.hls,Q=T.levels;if(!Q)throw new Error("init load aborted, missing levels");var z=Q[b.level].details;console.assert(z,"Level details are defined when init segment is loaded");var j=b.stats;T.state=S.IDLE,T.fragLoadError=0,b.data=new Uint8Array(P.payload),j.parsing.start=j.buffering.start=self.performance.now(),j.parsing.end=j.buffering.end=self.performance.now(),P.frag===G&&Y.trigger(M.Events.FRAG_BUFFERED,{stats:j,frag:G,part:null,id:b.type}),T.tick()}).catch(function(P){T.warn(P),T.resetFragmentLoading(b)})},a.fragContextChanged=function(b){var T=this.fragCurrent;return!b||!T||b.level!==T.level||b.sn!==T.sn||b.urlId!==T.urlId},a.fragBufferedComplete=function(b,T){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+b.type+" sn: "+b.sn+(T?" part: "+T.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+b.level+" "+o.default.toString(W.BufferHelper.getBuffered(P))),this.state=S.IDLE,this.tick()},a._handleFragmentLoadComplete=function(b){var T=this.transmuxer;if(!T)return;var P=b.frag,G=b.part,Y=b.partsLoaded,Q=!Y||Y.length===0||Y.some(function(j){return!j}),z=new v.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,G?G.index:-1,!Q);T.flush(z)},a._handleFragmentLoadProgress=function(b){},a._doFragLoad=function(b,T,P,G){var Y=this;if(P===void 0&&(P=null),!this.levels)throw new Error("frag load aborted, missing levels");if(P=Math.max(b.start,P||0),this.config.lowLatencyMode&&T){var Q=T.partList;if(Q&&G){P>b.end&&T.fragmentHint&&(b=T.fragmentHint);var z=this.getNextPart(Q,b,P);if(z>-1){var j=Q[z];return this.log("Loading part sn: "+b.sn+" p: "+j.index+" cc: "+b.cc+" of playlist ["+T.startSN+"-"+T.endSN+"] parts [0-"+z+"-"+(Q.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=j.start+j.duration,this.state=S.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:b,part:Q[z],targetBufferTime:P}),this.doFragPartsLoad(b,Q,z,G).catch(function(q){return Y.handleFragLoadError(q)})}else if(!b.url||this.loadedEndOfParts(Q,P))return Promise.resolve(null)}}return this.log("Loading fragment "+b.sn+" cc: "+b.cc+" "+(T?"of ["+T.startSN+"-"+T.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(P.toFixed(3))),Object(X.isFiniteNumber)(b.sn)&&!this.bitrateTest&&(this.nextLoadPosition=b.start+b.duration),this.state=S.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:b,targetBufferTime:P}),this.fragmentLoader.load(b,G).catch(function(q){return Y.handleFragLoadError(q)})},a.doFragPartsLoad=function(b,T,P,G){var Y=this;return new Promise(function(Q,z){var j=[],q=function ae(ce){var ve=T[ce];Y.fragmentLoader.loadPart(b,ve,G).then(function(ke){j[ve.index]=ke;var Ee=ke.part;Y.hls.trigger(M.Events.FRAG_LOADED,ke);var Ce=T[ce+1];if(Ce&&Ce.fragment===b)ae(ce+1);else return Q({frag:b,part:Ee,partsLoaded:j})}).catch(z)};q(P)})},a.handleFragLoadError=function(b){var T=b.data;return T&&T.details===k.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(T.frag,T.part):this.hls.trigger(M.Events.ERROR,T),null},a._handleTransmuxerFlush=function(b){var T=this.getCurrentContext(b);if(!T||this.state!==S.PARSING){this.fragCurrent||(this.state=S.IDLE);return}var P=T.frag,G=T.part,Y=T.level,Q=self.performance.now();P.stats.parsing.end=Q,G&&(G.stats.parsing.end=Q),this.updateLevelTiming(P,G,Y,b.partial)},a.getCurrentContext=function(b){var T=this.levels,P=b.level,G=b.sn,Y=b.part;if(!T||!T[P])return this.warn("Levels object was unset while buffering fragment "+G+" of level "+P+". The current chunk will not be buffered."),null;var Q=T[P],z=Y>-1?Object(x.getPartWith)(Q,G,Y):null,j=z?z.fragment:Object(x.getFragmentWithSN)(Q,G,this.fragCurrent);return j?{frag:j,part:z,level:Q}:null},a.bufferFragmentData=function(b,T,P,G){if(!b||this.state!==S.PARSING)return;var Y=b.data1,Q=b.data2,z=Y;if(Y&&Q&&(z=Object(y.appendUint8Array)(Y,Q)),!z||!z.length)return;var j={type:b.type,frag:T,part:P,chunkMeta:G,parent:T.type,data:z};this.hls.trigger(M.Events.BUFFER_APPENDING,j),b.dropped&&b.independent&&!P&&this.flushBufferGap(T)},a.flushBufferGap=function(b){var T=this.media;if(!T)return;if(!W.BufferHelper.isBuffered(T,T.currentTime)){this.flushMainBuffer(0,b.start);return}var P=T.currentTime,G=W.BufferHelper.bufferInfo(T,P,0),Y=b.duration,Q=Math.min(this.config.maxFragLookUpTolerance*2,Y*.25),z=Math.max(Math.min(b.start-Q,G.end-Q),P+Q);b.start-z>Q&&this.flushMainBuffer(z,b.start)},a.getFwdBufferInfo=function(b,T){var P=this.config,G=this.getLoadPosition();if(!Object(X.isFiniteNumber)(G))return null;var Y=W.BufferHelper.bufferInfo(b,G,P.maxBufferHole);if(Y.len===0&&Y.nextStart!==void 0){var Q=this.fragmentTracker.getBufferedFrag(G,T);if(Q&&Y.nextStart<Q.end)return W.BufferHelper.bufferInfo(b,G,Math.max(Y.nextStart,P.maxBufferHole))}return Y},a.getMaxBufferLength=function(b){var T=this.config,P;return b?P=Math.max(8*T.maxBufferSize/b,T.maxBufferLength):P=T.maxBufferLength,Math.min(P,T.maxMaxBufferLength)},a.reduceMaxBufferLength=function(b){var T=this.config,P=b||T.maxBufferLength;return T.maxMaxBufferLength>=P?(T.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+T.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(b,T){var P,G,Y=T.fragments,Q=Y.length;if(!Q)return null;var z=this.config,j=Y[0].start,q;if(T.live){var ae=z.initialLiveManifestSize;if(Q<ae)return this.warn("Not enough fragments to start playback (have: "+Q+", need: "+ae+")"),null;!T.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(q=this.getInitialLiveFragment(T,Y),this.startPosition=q?this.hls.liveSyncPosition||q.start:b)}else b<=j&&(q=Y[0]);if(!q){var ce=z.lowLatencyMode?T.partEnd:T.fragmentEnd;q=this.getFragmentAtPosition(b,ce,T)}return(P=q)!==null&&P!==void 0&&P.initSegment&&!((G=q)!==null&&G!==void 0&&G.initSegment.data)&&!this.bitrateTest&&(q=q.initSegment),q},a.getNextPart=function(b,T,P){for(var G=-1,Y=!1,Q=!0,z=0,j=b.length;z<j;z++){var q=b[z];if(Q=Q&&!q.independent,G>-1&&P<q.start)break;var ae=q.loaded;!ae&&(Y||q.independent||Q)&&q.fragment===T&&(G=z),Y=ae}return G},a.loadedEndOfParts=function(b,T){var P=b[b.length-1];return P&&T>P.start&&P.loaded},a.getInitialLiveFragment=function(b,T){var P=this.fragPrevious,G=null;if(P){if(b.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),G=Object(A.findFragmentByPDT)(T,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!G){var Y=P.sn+1;if(Y>=b.startSN&&Y<=b.endSN){var Q=T[Y-b.startSN];P.cc===Q.cc&&(G=Q,this.log("Live playlist, switching playlist, load frag with next SN: "+G.sn))}G||(G=Object(A.findFragWithCC)(T,P.cc),G&&this.log("Live playlist, switching playlist, load frag with same CC: "+G.sn))}}else{var z=this.hls.liveSyncPosition;z!==null&&(G=this.getFragmentAtPosition(z,this.bitrateTest?b.fragmentEnd:b.edge,b))}return G},a.getFragmentAtPosition=function(b,T,P){var G=this.config,Y=this.fragPrevious,Q=P.fragments,z=P.endSN,j=P.fragmentHint,q=G.maxFragLookUpTolerance,ae=!!(G.lowLatencyMode&&P.partList&&j);ae&&j&&!this.bitrateTest&&(Q=Q.concat(j),z=j.sn);var ce;if(b<T){var ve=b>T-q?0:q;ce=Object(A.findFragmentByPTS)(Y,Q,b,ve)}else ce=Q[Q.length-1];if(ce){var ke=ce.sn-P.startSN,Ee=Y&&ce.level===Y.level,Ce=Q[ke+1],Le=this.fragmentTracker.getState(ce);if(Le===I.FragmentState.BACKTRACKED){ce=null;for(var we=ke;Q[we]&&this.fragmentTracker.getState(Q[we])===I.FragmentState.BACKTRACKED;)Y?ce=Q[we--]:ce=Q[--we];ce||(ce=Ce)}else Y&&ce.sn===Y.sn&&!ae&&(Ee&&(ce.sn<z&&this.fragmentTracker.getState(Ce)!==I.FragmentState.OK?(this.log("SN "+ce.sn+" just loaded, load next one: "+Ce.sn),ce=Ce):ce=null))}return ce},a.synchronizeToLiveEdge=function(b){var T=this.config,P=this.media;if(!P)return;var G=this.hls.liveSyncPosition,Y=P.currentTime,Q=b.fragments[0].start,z=b.edge,j=Y>=Q-T.maxFragLookUpTolerance&&Y<=z;if(G!==null&&P.duration>G&&(Y<G||!j)){var q=T.liveMaxLatencyDuration!==void 0?T.liveMaxLatencyDuration:T.liveMaxLatencyDurationCount*b.targetduration;(!j&&P.readyState<4||Y<z-q)&&(this.loadedmetadata||(this.nextLoadPosition=G),P.readyState&&(this.warn("Playback: "+Y.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+G.toFixed(3)),P.currentTime=G))}},a.alignPlaylists=function(b,T){var P=this.levels,G=this.levelLastLoaded,Y=this.fragPrevious,Q=G!==null?P[G]:null,z=b.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var j=b.fragments[0].start,q=!T,ae=b.alignedSliding&&Object(X.isFiniteNumber)(j);if(q||!ae&&!j){Object(R.alignStream)(Y,Q,b);var ce=b.fragments[0].start;return this.log("Live playlist sliding: "+ce.toFixed(2)+" start-sn: "+(T?T.startSN:"na")+"->"+b.startSN+" prev-sn: "+(Y?Y.sn:"na")+" fragments: "+z),ce}return j},a.waitForCdnTuneIn=function(b){var T=3;return b.live&&b.canBlockReload&&b.tuneInGoal>Math.max(b.partHoldBack,b.partTarget*T)},a.setStartPosition=function(b,T){var P=this.startPosition;if(P<T&&(P=-1),P===-1||this.lastCurrentTime===-1){var G=b.startTimeOffset;Object(X.isFiniteNumber)(G)?(P=T+G,G<0&&(P+=b.totalduration),P=Math.min(Math.max(T,P),T+b.totalduration),this.log("Start time offset "+G+" found in playlist, adjust startPosition to "+P),this.startPosition=P):b.live?P=this.hls.liveSyncPosition||T:this.startPosition=P=0,this.lastCurrentTime=P}this.nextLoadPosition=P},a.getLoadPosition=function(){var b=this.media,T=0;return this.loadedmetadata&&b?T=b.currentTime:this.nextLoadPosition&&(T=this.nextLoadPosition),T},a.handleFragLoadAborted=function(b,T){this.transmuxer&&b.sn!=="initSegment"&&b.stats.aborted&&(this.warn("Fragment "+b.sn+(T?" part"+T.index:"")+" of level "+b.level+" was aborted"),this.resetFragmentLoading(b))},a.resetFragmentLoading=function(b){(!this.fragCurrent||!this.fragContextChanged(b))&&(this.state=S.IDLE)},a.onFragmentOrKeyLoadError=function(b,T){if(T.fatal)return;var P=T.frag;if(!P||P.type!==b)return;var G=this.fragCurrent;console.assert(G&&P.sn===G.sn&&P.level===G.level&&P.urlId===G.urlId,"Frag load error must match current frag to retry");var Y=this.config;if(this.fragLoadError+1<=Y.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(P.level))return;var Q=Math.min(Math.pow(2,this.fragLoadError)*Y.fragLoadingRetryDelay,Y.fragLoadingMaxRetryTimeout);this.warn("Fragment "+P.sn+" of "+b+" "+P.level+" failed to load, retrying in "+Q+"ms"),this.retryDate=self.performance.now()+Q,this.fragLoadError++,this.state=S.FRAG_LOADING_WAITING_RETRY}else T.levelRetry?(b===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=S.IDLE):(F.logger.error(T.details+" reaches max retry, redispatch as fatal ..."),T.fatal=!0,this.hls.stopLoad(),this.state=S.ERROR)},a.afterBufferFlushed=function(b,T,P){if(!b)return;var G=W.BufferHelper.getBuffered(b);this.fragmentTracker.detectEvictedFragments(T,G,P),this.state===S.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=S.IDLE},a.resetLiveStartWhenNotLoaded=function(b){if(!this.loadedmetadata){this.startFragRequested=!1;var T=this.levels?this.levels[b].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(b,T,P,G){var Y=this,Q=P.details;console.assert(!!Q,"level.details must be defined");var z=Object.keys(b.elementaryStreams).reduce(function(j,q){var ae=b.elementaryStreams[q];if(ae){var ce=ae.endPTS-ae.startPTS;if(ce<=0)return Y.warn("Could not parse fragment "+b.sn+" "+q+" duration reliably ("+ce+") resetting transmuxer to fallback to playlist timing"),Y.resetTransmuxer(),j||!1;var ve=G?0:Object(x.updateFragPTSDTS)(Q,b,ae.startPTS,ae.endPTS,ae.startDTS,ae.endDTS);return Y.hls.trigger(M.Events.LEVEL_PTS_UPDATED,{details:Q,level:P,drift:ve,type:q,frag:b,start:ae.startPTS,end:ae.endPTS}),!0}return j},!1);z?(this.state=S.PARSED,this.hls.trigger(M.Events.FRAG_PARSED,{frag:b,part:T})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},L(d,[{key:"state",get:function(){return this._state},set:function(b){var T=this._state;T!==b&&(this._state=b,this.log(T+"->"+b))}}]),d}(O.default)},"./src/controller/buffer-controller.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return A});var X=_("./src/polyfills/number.ts"),O=_("./src/events.ts"),I=_("./src/utils/logger.ts"),W=_("./src/errors.ts"),F=_("./src/utils/buffer-helper.ts"),M=_("./src/utils/mediasource-helper.ts"),k=_("./src/loader/fragment.ts"),v=_("./src/controller/buffer-operation-queue.ts"),y=Object(M.getMediaSource)(),R=/([ha]vc.)(?:\.[^.,]+)+/,A=function(){function x(u){var o=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 l=o.hls,h=o.media,L=o.mediaSource;I.logger.log("[buffer-controller]: Media source opened"),h&&(o.updateMediaElementDuration(),l.trigger(O.Events.MEDIA_ATTACHED,{media:h})),L&&L.removeEventListener("sourceopen",o._onMediaSourceOpen),o.checkPendingTracks()},this._onMediaSourceClose=function(){I.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){I.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var C=x.prototype;return C.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},C.destroy=function(){this.unregisterListeners(),this.details=null},C.registerListeners=function(){var o=this.hls;o.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(O.Events.BUFFER_RESET,this.onBufferReset,this),o.on(O.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(O.Events.BUFFER_EOS,this.onBufferEos,this),o.on(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(O.Events.FRAG_PARSED,this.onFragParsed,this),o.on(O.Events.FRAG_CHANGED,this.onFragChanged,this)},C.unregisterListeners=function(){var o=this.hls;o.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(O.Events.BUFFER_RESET,this.onBufferReset,this),o.off(O.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(O.Events.BUFFER_EOS,this.onBufferEos,this),o.off(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(O.Events.FRAG_PARSED,this.onFragParsed,this),o.off(O.Events.FRAG_CHANGED,this.onFragChanged,this)},C._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new v.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},C.onManifestParsed=function(o,l){var h=2;(l.audio&&!l.video||!l.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,I.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},C.onMediaAttaching=function(o,l){var h=this.media=l.media;if(h&&y){var L=this.mediaSource=new y;L.addEventListener("sourceopen",this._onMediaSourceOpen),L.addEventListener("sourceended",this._onMediaSourceEnded),L.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(L),this._objectUrl=h.src}},C.onMediaDetaching=function(){var o=this.media,l=this.mediaSource,h=this._objectUrl;if(l){if(I.logger.log("[buffer-controller]: media source detaching"),l.readyState==="open")try{l.endOfStream()}catch(L){I.logger.warn("[buffer-controller]: onMediaDetaching: "+L.message+" while calling endOfStream")}this.onBufferReset(),l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(h&&self.URL.revokeObjectURL(h),o.src===h?(o.removeAttribute("src"),o.load()):I.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(O.Events.MEDIA_DETACHED,void 0)},C.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(l){var h=o.sourceBuffer[l];try{h&&(o.removeBufferListeners(l),o.mediaSource&&o.mediaSource.removeSourceBuffer(h),o.sourceBuffer[l]=void 0)}catch(L){I.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",L)}}),this._initSourceBuffer()},C.onBufferCodecs=function(o,l){var h=this,L=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(f){if(L){var p=h.tracks[f];if(p&&typeof p.buffer.changeType=="function"){var D=l[f],S=D.codec,g=D.levelCodec,c=D.container,d=(p.levelCodec||p.codec).replace(R,"$1"),a=(g||S).replace(R,"$1");if(d!==a){var E=c+";codecs="+(g||S);h.appendChangeType(f,E)}}}else h.pendingTracks[f]=l[f]}),L)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},C.appendChangeType=function(o,l){var h=this,L=this.operationQueue,f={execute:function(){var D=h.sourceBuffer[o];D&&(I.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+l),D.changeType(l)),L.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(D){I.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",D)}};L.append(f,o)},C.onBufferAppending=function(o,l){var h=this,L=this.hls,f=this.operationQueue,p=this.tracks,D=l.data,S=l.type,g=l.frag,c=l.part,d=l.chunkMeta,a=d.buffering[S],E=self.performance.now();a.start=E;var b=g.stats.buffering,T=c?c.stats.buffering:null;b.start===0&&(b.start=E),T&&T.start===0&&(T.start=E);var P=p.audio,G=S==="audio"&&d.id===1&&(P==null?void 0:P.container)==="audio/mpeg",Y={execute:function(){if(a.executeStart=self.performance.now(),G){var z=h.sourceBuffer[S];if(z){var j=g.start-z.timestampOffset;Math.abs(j)>=.1&&(I.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+g.start+" (delta: "+j+") sn: "+g.sn+")"),z.timestampOffset=g.start)}}h.appendExecutor(D,S)},onStart:function(){},onComplete:function(){var z=self.performance.now();a.executeEnd=a.end=z,b.first===0&&(b.first=z),T&&T.first===0&&(T.first=z);var j=h.sourceBuffer,q={};for(var ae in j)q[ae]=F.BufferHelper.getBuffered(j[ae]);h.appendError=0,h.hls.trigger(O.Events.BUFFER_APPENDED,{type:S,frag:g,part:c,chunkMeta:d,parent:g.type,timeRanges:q})},onError:function(z){I.logger.error("[buffer-controller]: Error encountered while trying to append to the "+S+" SourceBuffer",z);var j={type:W.ErrorTypes.MEDIA_ERROR,parent:g.type,details:W.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?j.details=W.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,j.details=W.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>L.config.appendErrorMaxRetry&&(I.logger.error("[buffer-controller]: Failed "+L.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),j.fatal=!0)),L.trigger(O.Events.ERROR,j)}};f.append(Y,S)},C.onBufferFlushing=function(o,l){var h=this,L=this.operationQueue,f=function(D){return{execute:h.removeExecutor.bind(h,D,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(O.Events.BUFFER_FLUSHED,{type:D})},onError:function(g){I.logger.warn("[buffer-controller]: Failed to remove from "+D+" SourceBuffer",g)}}};l.type?L.append(f(l.type),l.type):this.getSourceBufferTypes().forEach(function(p){L.append(f(p),p)})},C.onFragParsed=function(o,l){var h=this,L=l.frag,f=l.part,p=[],D=f?f.elementaryStreams:L.elementaryStreams;D[k.ElementaryStreamTypes.AUDIOVIDEO]?p.push("audiovideo"):(D[k.ElementaryStreamTypes.AUDIO]&&p.push("audio"),D[k.ElementaryStreamTypes.VIDEO]&&p.push("video"));var S=function(){var c=self.performance.now();L.stats.buffering.end=c,f&&(f.stats.buffering.end=c);var d=f?f.stats:L.stats;h.hls.trigger(O.Events.FRAG_BUFFERED,{frag:L,part:f,stats:d,id:L.type})};p.length===0&&I.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+L.type+" level: "+L.level+" sn: "+L.sn),this.blockBuffers(S,p)},C.onFragChanged=function(o,l){this.flushBackBuffer()},C.onBufferEos=function(o,l){var h=this,L=this.getSourceBufferTypes().reduce(function(f,p){var D=h.sourceBuffer[p];return(!l.type||l.type===p)&&(D&&!D.ended&&(D.ended=!0,I.logger.log("[buffer-controller]: "+p+" sourceBuffer now EOS"))),f&&!!(!D||D.ended)},!0);L&&this.blockBuffers(function(){var f=h.mediaSource;if(!f||f.readyState!=="open")return;f.endOfStream()})},C.onLevelUpdated=function(o,l){var h=l.details;if(!h.fragments.length)return;this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},C.flushBackBuffer=function(){var o=this.hls,l=this.details,h=this.media,L=this.sourceBuffer;if(!h||l===null)return;var f=this.getSourceBufferTypes();if(!f.length)return;var p=l.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(X.isFiniteNumber)(p)||p<0)return;var D=h.currentTime,S=l.levelTargetDuration,g=Math.max(p,S),c=Math.floor(D/S)*S-g;f.forEach(function(d){var a=L[d];if(a){var E=F.BufferHelper.getBuffered(a);E.length>0&&c>E.start(0)&&(o.trigger(O.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),l.live&&o.trigger(O.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),o.trigger(O.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:d}))}})},C.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,l=this.hls,h=this.media,L=this.mediaSource,f=o.fragments[0].start+o.totalduration,p=h.duration,D=Object(X.isFiniteNumber)(L.duration)?L.duration:0;o.live&&l.config.liveDurationInfinity?(I.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),L.duration=Infinity,this.updateSeekableRange(o)):(f>D&&f>p||!Object(X.isFiniteNumber)(p))&&(I.logger.log("[buffer-controller]: Updating Media Source duration to "+f.toFixed(3)),L.duration=f)},C.updateSeekableRange=function(o){var l=this.mediaSource,h=o.fragments,L=h.length;if(L&&o.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var f=Math.max(0,h[0].start),p=Math.max(f,f+o.totalduration);l.setLiveSeekableRange(f,p)}},C.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,l=this.operationQueue,h=this.pendingTracks,L=Object.keys(h).length;if(L&&!o||L===2){this.createSourceBuffers(h),this.pendingTracks={};var f=this.getSourceBufferTypes();if(f.length===0){this.hls.trigger(O.Events.ERROR,{type:W.ErrorTypes.MEDIA_ERROR,details:W.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}f.forEach(function(p){l.executeNext(p)})}},C.createSourceBuffers=function(o){var l=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var L=0;for(var f in o)if(!l[f]){var p=o[f];if(!p)throw Error("source buffer exists for track "+f+", however track does not");var D=p.levelCodec||p.codec,S=p.container+";codecs="+D;I.logger.log("[buffer-controller]: creating sourceBuffer("+S+")");try{var g=l[f]=h.addSourceBuffer(S),c=f;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[f]={buffer:g,codec:D,container:p.container,levelCodec:p.levelCodec,id:p.id},L++}catch(d){I.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+d.message),this.hls.trigger(O.Events.ERROR,{type:W.ErrorTypes.MEDIA_ERROR,details:W.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:S})}}L&&this.hls.trigger(O.Events.BUFFER_CREATED,{tracks:this.tracks})},C._onSBUpdateStart=function(o){var l=this.operationQueue,h=l.current(o);h.onStart()},C._onSBUpdateEnd=function(o){var l=this.operationQueue,h=l.current(o);h.onComplete(),l.shiftAndExecuteNext(o)},C._onSBUpdateError=function(o,l){I.logger.error("[buffer-controller]: "+o+" SourceBuffer error",l),this.hls.trigger(O.Events.ERROR,{type:W.ErrorTypes.MEDIA_ERROR,details:W.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(o);h&&h.onError(l)},C.removeExecutor=function(o,l,h){var L=this.media,f=this.mediaSource,p=this.operationQueue,D=this.sourceBuffer,S=D[o];if(!L||!f||!S){I.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),p.shiftAndExecuteNext(o);return}var g=Object(X.isFiniteNumber)(L.duration)?L.duration:Infinity,c=Object(X.isFiniteNumber)(f.duration)?f.duration:Infinity,d=Math.max(0,l),a=Math.min(h,g,c);a>d?(I.logger.log("[buffer-controller]: Removing ["+d+","+a+"] from the "+o+" SourceBuffer"),console.assert(!S.updating,o+" sourceBuffer must not be updating"),S.remove(d,a)):p.shiftAndExecuteNext(o)},C.appendExecutor=function(o,l){var h=this.operationQueue,L=this.sourceBuffer,f=L[l];if(!f){I.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(l);return}f.ended=!1,console.assert(!f.updating,l+" sourceBuffer must not be updating"),f.appendBuffer(o)},C.blockBuffers=function(o,l){var h=this;if(l===void 0&&(l=this.getSourceBufferTypes()),!l.length){I.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var L=this.operationQueue,f=l.map(function(p){return L.appendBlocker(p)});Promise.all(f).then(function(){o(),l.forEach(function(p){var D=h.sourceBuffer[p];(!D||!D.updating)&&L.shiftAndExecuteNext(p)})})},C.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},C.addBufferListener=function(o,l,h){var L=this.sourceBuffer[o];if(!L)return;var f=h.bind(this,o);this.listeners[o].push({event:l,listener:f}),L.addEventListener(l,f)},C.removeBufferListeners=function(o){var l=this.sourceBuffer[o];if(!l)return;this.listeners[o].forEach(function(h){l.removeEventListener(h.event,h.listener)})},x}()},"./src/controller/buffer-operation-queue.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return O});var X=_("./src/utils/logger.ts"),O=function(){function I(F){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=F}var W=I.prototype;return W.append=function(M,k){var v=this.queues[k];v.push(M),v.length===1&&this.buffers[k]&&this.executeNext(k)},W.insertAbort=function(M,k){var v=this.queues[k];v.unshift(M),this.executeNext(k)},W.appendBlocker=function(M){var k,v=new Promise(function(R){k=R}),y={execute:k,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(y,M),v},W.executeNext=function(M){var k=this.buffers,v=this.queues,y=k[M],R=v[M];if(R.length){var A=R[0];try{A.execute()}catch(x){X.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),A.onError(x),(!y||!y.updating)&&(R.shift(),this.executeNext(M))}}},W.shiftAndExecuteNext=function(M){this.queues[M].shift(),this.executeNext(M)},W.current=function(M){return this.queues[M][0]},I}()},"./src/controller/cap-level-controller.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/events.ts");function O(F,M){for(var k=0;k<M.length;k++){var v=M[k];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(F,v.key,v)}}function I(F,M,k){return M&&O(F.prototype,M),k&&O(F,k),F}var W=function(){function F(k){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=k,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var M=F.prototype;return M.setStreamController=function(v){this.streamController=v},M.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},M.registerListeners=function(){var v=this.hls;v.on(X.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.on(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.on(X.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.unregisterListener=function(){var v=this.hls;v.off(X.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.off(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.off(X.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.onFpsDropLevelCapping=function(v,y){F.isLevelAllowed(y.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(y.droppedLevel)},M.onMediaAttaching=function(v,y){this.media=y.media instanceof HTMLVideoElement?y.media:null},M.onManifestParsed=function(v,y){var R=this.hls;this.restrictedLevels=[],this.firstLevel=y.firstLevel,R.config.capLevelToPlayerSize&&y.video&&this.startCapping()},M.onBufferCodecs=function(v,y){var R=this.hls;R.config.capLevelToPlayerSize&&y.video&&this.startCapping()},M.onMediaDetaching=function(){this.stopCapping()},M.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var v=this.hls.levels;if(v.length){var y=this.hls;y.autoLevelCapping=this.getMaxLevel(v.length-1),y.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=y.autoLevelCapping}}},M.getMaxLevel=function(v){var y=this,R=this.hls.levels;if(!R.length)return-1;var A=R.filter(function(x,C){return F.isLevelAllowed(C,y.restrictedLevels)&&C<=v});return this.clientRect=null,F.getMaxLevelByMediaSize(A,this.mediaWidth,this.mediaHeight)},M.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()},M.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},M.getDimensions=function(){if(this.clientRect)return this.clientRect;var v=this.media,y={width:0,height:0};if(v){var R=v.getBoundingClientRect();y.width=R.width,y.height=R.height,!y.width&&!y.height&&(y.width=R.right-R.left||v.width||0,y.height=R.bottom-R.top||v.height||0)}return this.clientRect=y,y},F.isLevelAllowed=function(v,y){return y===void 0&&(y=[]),y.indexOf(v)===-1},F.getMaxLevelByMediaSize=function(v,y,R){if(!v||!v.length)return-1;for(var A=function(l,h){return h?l.width!==h.width||l.height!==h.height:!0},x=v.length-1,C=0;C<v.length;C+=1){var u=v[C];if((u.width>=y||u.height>=R)&&A(u,v[C+1])){x=C;break}}return x},I(F,[{key:"mediaWidth",get:function(){return this.getDimensions().width*F.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*F.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var v=1;try{v=self.devicePixelRatio}catch(y){}return v}}]),F}();Z.default=W},"./src/controller/cmcd-controller.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return A});var X=_("./src/events.ts"),O=_("./src/types/cmcd.ts"),I=_("./src/utils/buffer-helper.ts"),W=_("./src/utils/logger.ts");function F(x,C){for(var u=0;u<C.length;u++){var o=C[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(x,o.key,o)}}function M(x,C,u){return C&&F(x.prototype,C),u&&F(x,u),x}function k(x,C){var u=typeof Symbol!="undefined"&&x[Symbol.iterator]||x["@@iterator"];if(u)return(u=u.call(x)).next.bind(u);if(Array.isArray(x)||(u=v(x))||C&&x&&typeof x.length=="number"){u&&(x=u);var o=0;return function(){return o>=x.length?{done:!0}:{done:!1,value:x[o++]}}}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(x,C){if(!x)return;if(typeof x=="string")return y(x,C);var u=Object.prototype.toString.call(x).slice(8,-1);if(u==="Object"&&x.constructor&&(u=x.constructor.name),u==="Map"||u==="Set")return Array.from(x);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return y(x,C)}function y(x,C){(C==null||C>x.length)&&(C=x.length);for(var u=0,o=new Array(C);u<C;u++)o[u]=x[u];return o}function R(){return R=Object.assign||function(x){for(var C=1;C<arguments.length;C++){var u=arguments[C];for(var o in u)Object.prototype.hasOwnProperty.call(u,o)&&(x[o]=u[o])}return x},R.apply(this,arguments)}var A=function(){function x(u){var o=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(){o.initialized&&(o.starved=!0),o.buffering=!0},this.onPlaying=function(){o.initialized||(o.initialized=!0),o.buffering=!1},this.applyPlaylistData=function(L){try{o.apply(L,{ot:O.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(f){W.logger.warn("Could not generate manifest CMCD data.",f)}},this.applyFragmentData=function(L){try{var f=L.frag,p=o.hls.levels[f.level],D=o.getObjectType(f),S={d:f.duration*1e3,ot:D};(D===O.CMCDObjectType.VIDEO||D===O.CMCDObjectType.AUDIO||D==O.CMCDObjectType.MUXED)&&(S.br=p.bitrate/1e3,S.tb=o.getTopBandwidth(D),S.bl=o.getBufferLength(D)),o.apply(L,S)}catch(g){W.logger.warn("Could not generate segment CMCD data.",g)}},this.hls=u;var l=this.config=u.config,h=l.cmcd;h!=null&&(l.pLoader=this.createPlaylistLoader(),l.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||x.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var C=x.prototype;return C.registerListeners=function(){var o=this.hls;o.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on(X.Events.BUFFER_CREATED,this.onBufferCreated,this)},C.unregisterListeners=function(){var o=this.hls;o.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off(X.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},C.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},C.onMediaAttached=function(o,l){this.media=l.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},C.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},C.onBufferCreated=function(o,l){var h,L;this.audioBuffer=(h=l.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(L=l.tracks.video)===null||L===void 0?void 0:L.buffer},C.createData=function(){var o;return{v:O.CMCDVersion,sf:O.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(o=this.media)===null||o===void 0?void 0:o.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},C.apply=function(o,l){l===void 0&&(l={}),R(l,this.createData());var h=l.ot===O.CMCDObjectType.INIT||l.ot===O.CMCDObjectType.VIDEO||l.ot===O.CMCDObjectType.MUXED;if(this.starved&&h&&(l.bs=!0,l.su=!0,this.starved=!1),l.su==null&&(l.su=this.buffering),this.useHeaders){var L=x.toHeaders(l);if(!Object.keys(L).length)return;o.headers||(o.headers={}),R(o.headers,L)}else{var f=x.toQuery(l);if(!f)return;o.url=x.appendQueryToUri(o.url,f)}},C.getObjectType=function(o){var l=o.type;return l==="subtitle"?O.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?O.CMCDObjectType.INIT:l==="audio"?O.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?O.CMCDObjectType.VIDEO:O.CMCDObjectType.MUXED:void 0},C.getTopBandwidth=function(o){for(var l=0,h=o===O.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,L=k(h),f;!(f=L()).done;){var p=f.value;p.bitrate>l&&(l=p.bitrate)}return l>0?l:NaN},C.getBufferLength=function(o){var l=this.hls.media,h=o===O.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!l)return NaN;var L=I.BufferHelper.bufferInfo(h,l.currentTime,this.config.maxBufferHole);return L.len*1e3},C.createPlaylistLoader=function(){var o=this.config.pLoader,l=this.applyPlaylistData,h=o||this.config.loader;return function(){function L(p){this.loader=void 0,this.loader=new h(p)}var f=L.prototype;return f.destroy=function(){this.loader.destroy()},f.abort=function(){this.loader.abort()},f.load=function(D,S,g){l(D),this.loader.load(D,S,g)},M(L,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),L}()},C.createFragmentLoader=function(){var o=this.config.fLoader,l=this.applyFragmentData,h=o||this.config.loader;return function(){function L(p){this.loader=void 0,this.loader=new h(p)}var f=L.prototype;return f.destroy=function(){this.loader.destroy()},f.abort=function(){this.loader.abort()},f.load=function(D,S,g){l(D),this.loader.load(D,S,g)},M(L,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),L}()},x.uuid=function(){var o=URL.createObjectURL(new Blob),l=o.toString();return URL.revokeObjectURL(o),l.substr(l.lastIndexOf("/")+1)},x.serialize=function(o){for(var l=[],h=function(G){return!Number.isNaN(G)&&G!=null&&G!==""&&G!==!1},L=function(G){return Math.round(G)},f=function(G){return L(G/100)*100},p=function(G){return encodeURIComponent(G)},D={br:L,d:L,bl:f,dl:f,mtp:f,nor:p,rtp:f,tb:L},S=Object.keys(o||{}).sort(),g=k(S),c;!(c=g()).done;){var d=c.value,a=o[d];if(!h(a))continue;if(d==="v"&&a===1)continue;if(d=="pr"&&a===1)continue;var E=D[d];E&&(a=E(a));var b=typeof a,T=void 0;d==="ot"||d==="sf"||d==="st"?T=d+"="+a:b==="boolean"?T=d:b==="number"?T=d+"="+a:T=d+"="+JSON.stringify(a),l.push(T)}return l.join(",")},x.toHeaders=function(o){for(var l=Object.keys(o),h={},L=["Object","Request","Session","Status"],f=[{},{},{},{}],p={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},D=0,S=l;D<S.length;D++){var g=S[D],c=p[g]!=null?p[g]:1;f[c][g]=o[g]}for(var d=0;d<f.length;d++){var a=x.serialize(f[d]);a&&(h["CMCD-"+L[d]]=a)}return h},x.toQuery=function(o){return"CMCD="+encodeURIComponent(x.serialize(o))},x.appendQueryToUri=function(o,l){if(!l)return o;var h=o.includes("?")?"&":"?";return""+o+h+l},x}()},"./src/controller/eme-controller.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/events.ts"),O=_("./src/errors.ts"),I=_("./src/utils/logger.ts"),W=_("./src/utils/mediakeys-helper.ts");function F(A,x){for(var C=0;C<x.length;C++){var u=x[C];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(A,u.key,u)}}function M(A,x,C){return x&&F(A.prototype,x),C&&F(A,C),A}var k=3,v=function(x,C,u){var o={audioCapabilities:[],videoCapabilities:[]};return x.forEach(function(l){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:u.audioRobustness||""})}),C.forEach(function(l){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:u.videoRobustness||""})}),[o]},y=function(x,C,u,o){switch(x){case W.KeySystems.WIDEVINE:return v(C,u,o);default:throw new Error("Unknown key-system: "+x)}},R=function(){function A(C){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=C,this._config=C.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 x=A.prototype;return x.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},x._registerListeners=function(){this.hls.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this)},x._unregisterListeners=function(){this.hls.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this)},x.getLicenseServerUrl=function(u){switch(u){case W.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},x._attemptKeySystemAccess=function(u,o,l){var h=this,L=y(u,o,l,this._drmSystemOptions);I.logger.log("Requesting encrypted media key-system access");var f=this.requestMediaKeySystemAccess(u,L);this.mediaKeysPromise=f.then(function(p){return h._onMediaKeySystemAccessObtained(u,p)}),f.catch(function(p){I.logger.error('Failed to obtain key-system "'+u+'" access:',p)})},x._onMediaKeySystemAccessObtained=function(u,o){var l=this;I.logger.log('Access for key-system "'+u+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:u};this._mediaKeysList.push(h);var L=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(f){return h.mediaKeys=f,I.logger.log('Media-keys created for key-system "'+u+'"'),l._onMediaKeysCreated(),f});return L.catch(function(f){I.logger.error("Failed to create media-keys:",f)}),L},x._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),u._onNewMediaKeySession(o.mediaKeysSession))})},x._onNewMediaKeySession=function(u){var o=this;I.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(l){o._onKeySessionMessage(u,l.message)},!1)},x._onKeySessionMessage=function(u,o){I.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(l){I.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),u.update(l)})},x.onMediaEncrypted=function(u){var o=this;if(I.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){I.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(L){if(!o._media)return;o._attemptSetMediaKeys(L),o._generateRequestWithPreferredKeySession(u.initDataType,u.initData)};this.mediaKeysPromise.then(l).catch(l)},x._attemptSetMediaKeys=function(u){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var o=this._mediaKeysList[0];if(!o||!o.mediaKeys){I.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}I.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},x._generateRequestWithPreferredKeySession=function(u,o){var l=this,h=this._mediaKeysList[0];if(!h){I.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){I.logger.warn("Key-Session already initialized but requested again");return}var L=h.mediaKeysSession;if(!L){I.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!o){I.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}I.logger.log('Generating key-session request for "'+u+'" init data type'),h.mediaKeysSessionInitialized=!0,L.generateRequest(u,o).then(function(){I.logger.debug("Key-session generation succeeded")}).catch(function(f){I.logger.error("Error generating key-session request:",f),l.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},x._createLicenseXhr=function(u,o,l){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,u,o,l);var L=this._licenseXhrSetup;if(L)try{L.call(this.hls,h,u),L=void 0}catch(f){I.logger.error(f)}try{h.readyState||h.open("POST",u,!0),L&&L.call(this.hls,h,u)}catch(f){throw new Error("issue setting up KeySystem license XHR "+f)}return h},x._onLicenseRequestReadyStageChange=function(u,o,l,h){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,I.logger.log("License request succeeded");var L=u.response,f=this._licenseResponseCallback;if(f)try{L=f.call(this.hls,u,o)}catch(D){I.logger.error(D)}h(L)}else{if(I.logger.error("License Request XHR failed ("+o+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>k){this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var p=k-this._requestLicenseFailureCount+1;I.logger.warn("Retrying license request, "+p+" attempts left"),this._requestLicense(l,h)}break}},x._generateLicenseRequestChallenge=function(u,o){switch(u.mediaKeySystemDomain){case W.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},x._requestLicense=function(u,o){I.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){I.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(l.mediaKeySystemDomain),L=this._createLicenseXhr(h,u,o);I.logger.log("Sending license request to URL: "+h);var f=this._generateLicenseRequestChallenge(l,u);L.send(f)}catch(p){I.logger.error("Failure requesting DRM license: "+p),this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},x.onMediaAttached=function(u,o){if(!this._emeEnabled)return;var l=o.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},x.onMediaDetached=function(){var u=this._media,o=this._mediaKeysList;if(!u)return;u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(o.map(function(l){if(l.mediaKeysSession)return l.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){})},x.onManifestParsed=function(u,o){if(!this._emeEnabled)return;var l=o.levels.map(function(L){return L.audioCodec}).filter(function(L){return!!L}),h=o.levels.map(function(L){return L.videoCodec}).filter(function(L){return!!L});this._attemptKeySystemAccess(W.KeySystems.WIDEVINE,l,h)},M(A,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),A}();Z.default=R},"./src/controller/fps-controller.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/events.ts"),O=_("./src/utils/logger.ts"),I=function(){function W(M){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=M,this.registerListeners()}var F=W.prototype;return F.setStreamController=function(k){this.streamController=k},F.registerListeners=function(){this.hls.on(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},F.unregisterListeners=function(){this.hls.off(X.Events.MEDIA_ATTACHING,this.onMediaAttaching)},F.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},F.onMediaAttaching=function(k,v){var y=this.hls.config;if(y.capLevelOnFPSDrop){var R=v.media instanceof self.HTMLVideoElement?v.media:null;this.media=R,R&&typeof R.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),y.fpsDroppedMonitoringPeriod)}},F.checkFPS=function(k,v,y){var R=performance.now();if(v){if(this.lastTime){var A=R-this.lastTime,x=y-this.lastDroppedFrames,C=v-this.lastDecodedFrames,u=1e3*x/A,o=this.hls;if(o.trigger(X.Events.FPS_DROP,{currentDropped:x,currentDecoded:C,totalDroppedFrames:y}),u>0&&x>o.config.fpsDroppedMonitoringThreshold*C){var l=o.currentLevel;O.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=l)&&(l=l-1,o.trigger(X.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:o.currentLevel}),o.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=R,this.lastDroppedFrames=y,this.lastDecodedFrames=v}},F.checkFPSInterval=function(){var k=this.media;if(k)if(this.isVideoPlaybackQualityAvailable){var v=k.getVideoPlaybackQuality();this.checkFPS(k,v.totalVideoFrames,v.droppedVideoFrames)}else this.checkFPS(k,k.webkitDecodedFrameCount,k.webkitDroppedFrameCount)},W}();Z.default=I},"./src/controller/fragment-finders.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"findFragmentByPDT",function(){return I}),_.d(Z,"findFragmentByPTS",function(){return W}),_.d(Z,"fragmentWithinToleranceTest",function(){return F}),_.d(Z,"pdtWithinToleranceTest",function(){return M}),_.d(Z,"findFragWithCC",function(){return k});var X=_("./src/polyfills/number.ts"),O=_("./src/utils/binary-search.ts");function I(v,y,R){if(y===null||!Array.isArray(v)||!v.length||!Object(X.isFiniteNumber)(y))return null;var A=v[0].programDateTime;if(y<(A||0))return null;var x=v[v.length-1].endProgramDateTime;if(y>=(x||0))return null;R=R||0;for(var C=0;C<v.length;++C){var u=v[C];if(M(y,R,u))return u}return null}function W(v,y,R,A){R===void 0&&(R=0),A===void 0&&(A=0);var x=null;if(v?x=y[v.sn-y[0].sn+1]||null:R===0&&y[0].start===0&&(x=y[0]),x&&F(R,A,x)===0)return x;var C=O.default.search(y,F.bind(null,R,A));return C||x}function F(v,y,R){v===void 0&&(v=0),y===void 0&&(y=0);var A=Math.min(y,R.duration+(R.deltaPTS?R.deltaPTS:0));return R.start+R.duration-A<=v?1:R.start-A>v&&R.start?-1:0}function M(v,y,R){var A=Math.min(y,R.duration+(R.deltaPTS?R.deltaPTS:0))*1e3,x=R.endProgramDateTime||0;return x-A>v}function k(v,y){return O.default.search(v,function(R){return R.cc<y?1:R.cc>y?-1:0})}},"./src/controller/fragment-tracker.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"FragmentState",function(){return I}),_.d(Z,"FragmentTracker",function(){return W});var X=_("./src/events.ts"),O=_("./src/types/loader.ts"),I;(function(k){k.NOT_LOADED="NOT_LOADED",k.BACKTRACKED="BACKTRACKED",k.APPENDING="APPENDING",k.PARTIAL="PARTIAL",k.OK="OK"})(I||(I={}));var W=function(){function k(y){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=y,this._registerListeners()}var v=k.prototype;return v._registerListeners=function(){var R=this.hls;R.on(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),R.on(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),R.on(X.Events.FRAG_LOADED,this.onFragLoaded,this)},v._unregisterListeners=function(){var R=this.hls;R.off(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),R.off(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),R.off(X.Events.FRAG_LOADED,this.onFragLoaded,this)},v.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},v.getAppendedFrag=function(R,A){if(A===O.PlaylistLevelType.MAIN){var x=this.activeFragment,C=this.activeParts;if(!x)return null;if(C)for(var u=C.length;u--;){var o=C[u],l=o?o.end:x.appendedPTS;if(o.start<=R&&l!==void 0&&R<=l)return u>9&&(this.activeParts=C.slice(u-9)),o}else if(x.start<=R&&x.appendedPTS!==void 0&&R<=x.appendedPTS)return x}return this.getBufferedFrag(R,A)},v.getBufferedFrag=function(R,A){for(var x=this.fragments,C=Object.keys(x),u=C.length;u--;){var o=x[C[u]];if((o==null?void 0:o.body.type)===A&&o.buffered){var l=o.body;if(l.start<=R&&R<=l.end)return l}}return null},v.detectEvictedFragments=function(R,A,x){var C=this;Object.keys(this.fragments).forEach(function(u){var o=C.fragments[u];if(!o)return;if(!o.buffered){o.body.type===x&&C.removeFragment(o.body);return}var l=o.range[R];if(!l)return;l.time.some(function(h){var L=!C.isTimeBuffered(h.startPTS,h.endPTS,A);return L&&C.removeFragment(o.body),L})})},v.detectPartialFragments=function(R){var A=this,x=this.timeRanges,C=R.frag,u=R.part;if(!x||C.sn==="initSegment")return;var o=M(C),l=this.fragments[o];if(!l)return;Object.keys(x).forEach(function(h){var L=C.elementaryStreams[h];if(!L)return;var f=x[h],p=u!==null||L.partial===!0;l.range[h]=A.getBufferedTimes(C,u,p,f)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},v.fragBuffered=function(R){var A=M(R),x=this.fragments[A];x&&(x.backtrack=x.loaded=null,x.buffered=!0)},v.getBufferedTimes=function(R,A,x,C){for(var u={time:[],partial:x},o=A?A.start:R.start,l=A?A.end:R.end,h=R.minEndPTS||l,L=R.maxStartPTS||o,f=0;f<C.length;f++){var p=C.start(f)-this.bufferPadding,D=C.end(f)+this.bufferPadding;if(L>=p&&h<=D){u.time.push({startPTS:Math.max(o,C.start(f)),endPTS:Math.min(l,C.end(f))});break}else if(o<D&&l>p)u.partial=!0,u.time.push({startPTS:Math.max(o,C.start(f)),endPTS:Math.min(l,C.end(f))});else if(l<=p)break}return u},v.getPartialFragment=function(R){var A=null,x,C,u,o=0,l=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(L){var f=h[L];if(!f)return;F(f)&&(C=f.body.start-l,u=f.body.end+l,R>=C&&R<=u&&(x=Math.min(R-C,u-R),o<=x&&(A=f.body,o=x)))}),A},v.getState=function(R){var A=M(R),x=this.fragments[A];return x?x.buffered?F(x)?I.PARTIAL:I.OK:x.backtrack?I.BACKTRACKED:I.APPENDING:I.NOT_LOADED},v.backtrack=function(R,A){var x=M(R),C=this.fragments[x];if(!C||C.backtrack)return null;var u=C.backtrack=A||C.loaded;return C.loaded=null,u},v.getBacktrackData=function(R){var A=M(R),x=this.fragments[A];if(x){var C,u=x.backtrack;if(u!=null&&(C=u.payload)!==null&&C!==void 0&&C.byteLength)return u;this.removeFragment(R)}return null},v.isTimeBuffered=function(R,A,x){for(var C,u,o=0;o<x.length;o++){if(C=x.start(o)-this.bufferPadding,u=x.end(o)+this.bufferPadding,R>=C&&A<=u)return!0;if(A<=C)return!1}return!1},v.onFragLoaded=function(R,A){var x=A.frag,C=A.part;if(x.sn==="initSegment"||x.bitrateTest||C)return;var u=M(x);this.fragments[u]={body:x,loaded:A,backtrack:null,buffered:!1,range:Object.create(null)}},v.onBufferAppended=function(R,A){var x=this,C=A.frag,u=A.part,o=A.timeRanges;if(C.type===O.PlaylistLevelType.MAIN)if(this.activeFragment=C,u){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(u)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(h){var L=o[h];if(x.detectEvictedFragments(h,L),!u)for(var f=0;f<L.length;f++)C.appendedPTS=Math.max(L.end(f),C.appendedPTS||0)})},v.onFragBuffered=function(R,A){this.detectPartialFragments(A)},v.hasFragment=function(R){var A=M(R);return!!this.fragments[A]},v.removeFragmentsInRange=function(R,A,x){var C=this;Object.keys(this.fragments).forEach(function(u){var o=C.fragments[u];if(!o)return;if(o.buffered){var l=o.body;l.type===x&&l.start<A&&l.end>R&&C.removeFragment(l)}})},v.removeFragment=function(R){var A=M(R);R.stats.loaded=0,R.clearElementaryStreamInfo(),delete this.fragments[A]},v.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},k}();function F(k){var v,y;return k.buffered&&(((v=k.range.video)===null||v===void 0?void 0:v.partial)||((y=k.range.audio)===null||y===void 0?void 0:y.partial))}function M(k){return k.type+"_"+k.level+"_"+k.urlId+"_"+k.sn}},"./src/controller/gap-controller.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"STALL_MINIMUM_DURATION_MS",function(){return F}),_.d(Z,"MAX_START_GAP_JUMP",function(){return M}),_.d(Z,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return k}),_.d(Z,"SKIP_BUFFER_RANGE_START",function(){return v}),_.d(Z,"default",function(){return y});var X=_("./src/utils/buffer-helper.ts"),O=_("./src/errors.ts"),I=_("./src/events.ts"),W=_("./src/utils/logger.ts"),F=250,M=2,k=.1,v=.05,y=function(){function R(x,C,u,o){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=x,this.media=C,this.fragmentTracker=u,this.hls=o}var A=R.prototype;return A.destroy=function(){this.hls=this.fragmentTracker=this.media=null},A.poll=function(C){var u=this.config,o=this.media,l=this.stalled,h=o.currentTime,L=o.seeking,f=this.seeking&&!L,p=!this.seeking&&L;if(this.seeking=L,h!==C){if(this.moved=!0,l!==null){if(this.stallReported){var D=self.performance.now()-l;W.logger.warn("playback not stuck anymore @"+h+", after "+Math.round(D)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((p||f)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!X.BufferHelper.getBuffered(o).length)return;var S=X.BufferHelper.bufferInfo(o,h,0),g=S.len>0,c=S.nextStart||0;if(!g&&!c)return;if(L){var d=S.len>M,a=!c||c-h>M&&!this.fragmentTracker.getPartialFragment(h);if(d||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E,b=Math.max(c,S.start||0)-h,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=T==null||((E=T.details)===null||E===void 0)?void 0:E.live,G=P?T.details.targetduration*2:M;if(b>0&&b<=G){this._trySkipBufferHole(null);return}}var Y=self.performance.now();if(l===null){this.stalled=Y;return}var Q=Y-l;!L&&Q>=F&&this._reportStall(S.len);var z=X.BufferHelper.bufferInfo(o,h,u.maxBufferHole);this._tryFixBufferStall(z,Q)},A._tryFixBufferStall=function(C,u){var o=this.config,l=this.fragmentTracker,h=this.media,L=h.currentTime,f=l.getPartialFragment(L);if(f){var p=this._trySkipBufferHole(f);if(p)return}C.len>o.maxBufferHole&&u>o.highBufferWatchdogPeriod*1e3&&(W.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},A._reportStall=function(C){var u=this.hls,o=this.media,l=this.stallReported;l||(this.stallReported=!0,W.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+C+")"),u.trigger(I.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:C}))},A._trySkipBufferHole=function(C){for(var u=this.config,o=this.hls,l=this.media,h=l.currentTime,L=0,f=X.BufferHelper.getBuffered(l),p=0;p<f.length;p++){var D=f.start(p);if(h+u.maxBufferHole>=L&&h<D){var S=Math.max(D+v,l.currentTime+k);return W.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+S),this.moved=!0,this.stalled=null,l.currentTime=S,C&&o.trigger(I.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+S,frag:C}),S}L=f.end(p)}return 0},A._tryNudgeBuffer=function(){var C=this.config,u=this.hls,o=this.media,l=o.currentTime,h=(this.nudgeRetry||0)+1;if(this.nudgeRetry=h,h<C.nudgeMaxRetry){var L=l+h*C.nudgeOffset;W.logger.warn("Nudging 'currentTime' from "+l+" to "+L),o.currentTime=L,u.trigger(I.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else W.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+C.nudgeMaxRetry+" nudges"),u.trigger(I.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},R}()},"./src/controller/id3-track-controller.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/events.ts"),O=_("./src/utils/texttrack-utils.ts"),I=_("./src/demux/id3.ts"),W=.25,F=function(){function M(v){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=v,this._registerListeners()}var k=M.prototype;return k.destroy=function(){this._unregisterListeners()},k._registerListeners=function(){var y=this.hls;y.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),y.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),y.on(X.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),y.on(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},k._unregisterListeners=function(){var y=this.hls;y.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),y.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),y.off(X.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),y.off(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},k.onMediaAttached=function(y,R){this.media=R.media},k.onMediaDetaching=function(){if(!this.id3Track)return;Object(O.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},k.getID3Track=function(y){if(!this.media)return;for(var R=0;R<y.length;R++){var A=y[R];if(A.kind==="metadata"&&A.label==="id3")return Object(O.sendAddTrackEvent)(A,this.media),A}return this.media.addTextTrack("metadata","id3")},k.onFragParsingMetadata=function(y,R){if(!this.media)return;var A=R.frag,x=R.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var C=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<x.length;u++){var o=I.getID3Frames(x[u].data);if(o){var l=x[u].pts,h=u<x.length-1?x[u+1].pts:A.end,L=h-l;L<=0&&(h=l+W);for(var f=0;f<o.length;f++){var p=o[f];if(!I.isTimeStampFrame(p)){var D=new C(l,h,"");D.value=p,this.id3Track.addCue(D)}}}}},k.onBufferFlushing=function(y,R){var A=R.startOffset,x=R.endOffset,C=R.type;if(!C||C==="audio"){var u=this.id3Track;u&&Object(O.removeCuesInRange)(u,A,x)}},M}();Z.default=F},"./src/controller/latency-controller.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return M});var X=_("./src/errors.ts"),O=_("./src/events.ts"),I=_("./src/utils/logger.ts");function W(k,v){for(var y=0;y<v.length;y++){var R=v[y];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(k,R.key,R)}}function F(k,v,y){return v&&W(k.prototype,v),y&&W(k,y),k}var M=function(){function k(y){var R=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 R.timeupdate()},this.hls=y,this.config=y.config,this.registerListeners()}var v=k.prototype;return v.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},v.registerListeners=function(){this.hls.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(O.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){this.hls.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(O.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(O.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(O.Events.ERROR,this.onError)},v.onMediaAttached=function(R,A){this.media=A.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(R,A){var x=A.details;this.levelDetails=x,x.advanced&&this.timeupdate(),!x.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},v.onError=function(R,A){if(A.details!==X.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,I.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},v.timeupdate=function(){var R=this.media,A=this.levelDetails;if(!R||!A)return;this.currentTime=R.currentTime;var x=this.computeLatency();if(x===null)return;this._latency=x;var C=this.config,u=C.lowLatencyMode,o=C.maxLiveSyncPlaybackRate;if(!u||o===1)return;var l=this.targetLatency;if(l===null)return;var h=x-l,L=Math.min(this.maxLatency,l+A.targetduration),f=h<L;if(A.live&&f&&h>.05&&this.forwardBufferLength>1){var p=Math.min(2,Math.max(1,o)),D=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;R.playbackRate=Math.min(p,Math.max(1,D))}else R.playbackRate!==1&&R.playbackRate!==0&&(R.playbackRate=1)},v.estimateLiveEdge=function(){var R=this.levelDetails;return R===null?null:R.edge+R.age},v.computeLatency=function(){var R=this.estimateLiveEdge();return R===null?null:R-this.currentTime},F(k,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var R=this.config,A=this.levelDetails;return R.liveMaxLatencyDuration!==void 0?R.liveMaxLatencyDuration:A?R.liveMaxLatencyDurationCount*A.targetduration:0}},{key:"targetLatency",get:function(){var R=this.levelDetails;if(R===null)return null;var A=R.holdBack,x=R.partHoldBack,C=R.targetduration,u=this.config,o=u.liveSyncDuration,l=u.liveSyncDurationCount,h=u.lowLatencyMode,L=this.hls.userConfig,f=h&&x||A;(L.liveSyncDuration||L.liveSyncDurationCount||f===0)&&(f=o!==void 0?o:l*C);var p=C,D=1;return f+Math.min(this.stallCount*D,p)}},{key:"liveSyncPosition",get:function(){var R=this.estimateLiveEdge(),A=this.targetLatency,x=this.levelDetails;if(R===null||A===null||x===null)return null;var C=x.edge,u=R-A-this.edgeStalled,o=C-x.totalduration,l=C-(this.config.lowLatencyMode&&x.partTarget||x.targetduration);return Math.min(Math.max(o,u),l)}},{key:"drift",get:function(){var R=this.levelDetails;return R===null?1:R.drift}},{key:"edgeStalled",get:function(){var R=this.levelDetails;if(R===null)return 0;var A=(this.config.lowLatencyMode&&R.partTarget||R.targetduration)*3;return Math.max(R.age-A,0)}},{key:"forwardBufferLength",get:function(){var R=this.media,A=this.levelDetails;if(!R||!A)return 0;var x=R.buffered.length;return x?R.buffered.end(x-1):A.edge-this.currentTime}}]),k}()},"./src/controller/level-controller.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return u});var X=_("./src/types/level.ts"),O=_("./src/events.ts"),I=_("./src/errors.ts"),W=_("./src/utils/codecs.ts"),F=_("./src/controller/level-helper.ts"),M=_("./src/controller/base-playlist-controller.ts"),k=_("./src/types/loader.ts");function v(){return v=Object.assign||function(o){for(var l=1;l<arguments.length;l++){var h=arguments[l];for(var L in h)Object.prototype.hasOwnProperty.call(h,L)&&(o[L]=h[L])}return o},v.apply(this,arguments)}function y(o,l){for(var h=0;h<l.length;h++){var L=l[h];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(o,L.key,L)}}function R(o,l,h){return l&&y(o.prototype,l),h&&y(o,h),o}function A(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,x(o,l)}function x(o,l){return x=Object.setPrototypeOf||function(L,f){return L.__proto__=f,L},x(o,l)}var C=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(o){A(l,o);function l(L){var f;return f=o.call(this,L,"[level-controller]")||this,f._levels=[],f._firstLevel=-1,f._startLevel=void 0,f.currentLevelIndex=-1,f.manualLevelIndex=-1,f.onParsedComplete=void 0,f._registerListeners(),f}var h=l.prototype;return h._registerListeners=function(){var f=this.hls;f.on(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),f.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(O.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.on(O.Events.FRAG_LOADED,this.onFragLoaded,this),f.on(O.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var f=this.hls;f.off(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),f.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(O.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.off(O.Events.FRAG_LOADED,this.onFragLoaded,this),f.off(O.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},h.startLoad=function(){var f=this._levels;f.forEach(function(p){p.loadError=0}),o.prototype.startLoad.call(this)},h.onManifestLoaded=function(f,p){var D=[],S=[],g=[],c,d={},a,E=!1,b=!1,T=!1;if(p.levels.forEach(function(Q){var z=Q.attrs;E=E||!!(Q.width&&Q.height),b=b||!!Q.videoCodec,T=T||!!Q.audioCodec,C&&Q.audioCodec&&Q.audioCodec.indexOf("mp4a.40.34")!==-1&&(Q.audioCodec=void 0);var j=Q.bitrate+"-"+Q.attrs.RESOLUTION+"-"+Q.attrs.CODECS;a=d[j],a?a.url.push(Q.url):(a=new X.Level(Q),d[j]=a,D.push(a)),z&&(z.AUDIO&&Object(F.addGroupId)(a,"audio",z.AUDIO),z.SUBTITLES&&Object(F.addGroupId)(a,"text",z.SUBTITLES))}),(E||b)&&T&&(D=D.filter(function(Q){var z=Q.videoCodec,j=Q.width,q=Q.height;return!!z||!!(j&&q)})),D=D.filter(function(Q){var z=Q.audioCodec,j=Q.videoCodec;return(!z||Object(W.isCodecSupportedInMp4)(z,"audio"))&&(!j||Object(W.isCodecSupportedInMp4)(j,"video"))}),p.audioTracks&&(S=p.audioTracks.filter(function(Q){return!Q.audioCodec||Object(W.isCodecSupportedInMp4)(Q.audioCodec,"audio")}),Object(F.assignTrackIdsByGroup)(S)),p.subtitles&&(g=p.subtitles,Object(F.assignTrackIdsByGroup)(g)),D.length>0){c=D[0].bitrate,D.sort(function(Q,z){return Q.bitrate-z.bitrate}),this._levels=D;for(var P=0;P<D.length;P++)if(D[P].bitrate===c){this._firstLevel=P,this.log("manifest loaded, "+D.length+" level(s) found, first bitrate: "+c);break}var G=T&&!b,Y={levels:D,audioTracks:S,subtitleTracks:g,firstLevel:this._firstLevel,stats:p.stats,audio:T,video:b,altAudio:!G&&S.some(function(Q){return!!Q.url})};this.hls.trigger(O.Events.MANIFEST_PARSED,Y),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(O.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:p.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(f,p){if(o.prototype.onError.call(this,f,p),p.fatal)return;var D=p.context,S=this._levels[this.currentLevelIndex];if(D&&(D.type===k.PlaylistContextType.AUDIO_TRACK&&S.audioGroupIds&&D.groupId===S.audioGroupIds[S.urlId]||D.type===k.PlaylistContextType.SUBTITLE_TRACK&&S.textGroupIds&&D.groupId===S.textGroupIds[S.urlId])){this.redundantFailover(this.currentLevelIndex);return}var g=!1,c=!0,d;switch(p.details){case I.ErrorDetails.FRAG_LOAD_ERROR:case I.ErrorDetails.FRAG_LOAD_TIMEOUT:case I.ErrorDetails.KEY_LOAD_ERROR:case I.ErrorDetails.KEY_LOAD_TIMEOUT:if(p.frag){var a=this._levels[p.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(d=p.frag.level)):d=p.frag.level}break;case I.ErrorDetails.LEVEL_LOAD_ERROR:case I.ErrorDetails.LEVEL_LOAD_TIMEOUT:D&&(D.deliveryDirectives&&(c=!1),d=D.level),g=!0;break;case I.ErrorDetails.REMUX_ALLOC_ERROR:d=p.level,g=!0;break}d!==void 0&&this.recoverLevel(p,d,g,c)},h.recoverLevel=function(f,p,D,S){var g=f.details,c=this._levels[p];if(c.loadError++,D){var d=this.retryLoadingOrFail(f);if(d)f.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(S){var a=c.url.length;if(a>1&&c.loadError<a)f.levelRetry=!0,this.redundantFailover(p);else if(this.manualLevelIndex===-1){var E=p===0?this._levels.length-1:p-1;this.currentLevelIndex!==E&&this._levels[E].loadError===0&&(this.warn(g+": switch to "+E),f.levelRetry=!0,this.hls.nextAutoLevel=E)}}},h.redundantFailover=function(f){var p=this._levels[f],D=p.url.length;if(D>1){var S=(p.urlId+1)%D;this.warn("Switching to redundant URL-id "+S),this._levels.forEach(function(g){g.urlId=S}),this.level=f}},h.onFragLoaded=function(f,p){var D=p.frag;if(D!==void 0&&D.type===k.PlaylistLevelType.MAIN){var S=this._levels[D.level];S!==void 0&&(S.fragmentError=0,S.loadError=0)}},h.onLevelLoaded=function(f,p){var D,S=p.level,g=p.details,c=this._levels[S];if(!c){var d;this.warn("Invalid level index "+S),(d=p.deliveryDirectives)!==null&&d!==void 0&&d.skip&&(g.deltaUpdateFailed=!0);return}S===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(S,p,c.details)):(D=p.deliveryDirectives)!==null&&D!==void 0&&D.skip&&(g.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(f,p){var D=this.hls.levels[this.currentLevelIndex];if(!D)return;if(D.audioGroupIds){for(var S=-1,g=this.hls.audioTracks[p.id].groupId,c=0;c<D.audioGroupIds.length;c++)if(D.audioGroupIds[c]===g){S=c;break}S!==D.urlId&&(D.urlId=S,this.startLoad())}},h.loadPlaylist=function(f){var p=this.currentLevelIndex,D=this._levels[p];if(this.canLoad&&D&&D.url.length>0){var S=D.urlId,g=D.url[S];if(f)try{g=f.addDirectives(g)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+p+(f?" at sn "+f.msn+" part "+f.part:"")+" with URL-id "+S+" "+g),this.clearTimer(),this.hls.trigger(O.Events.LEVEL_LOADING,{url:g,level:p,id:S,deliveryDirectives:f||null})}},h.removeLevel=function(f,p){var D=function(c,d){return d!==p},S=this._levels.filter(function(g,c){return c!==f?!0:g.url.length>1&&p!==void 0?(g.url=g.url.filter(D),g.audioGroupIds&&(g.audioGroupIds=g.audioGroupIds.filter(D)),g.textGroupIds&&(g.textGroupIds=g.textGroupIds.filter(D)),g.urlId=0,!0):!1}).map(function(g,c){var d=g.details;return d!=null&&d.fragments&&d.fragments.forEach(function(a){a.level=c}),g});this._levels=S,this.hls.trigger(O.Events.LEVELS_UPDATED,{levels:S})},R(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(f){var p,D=this._levels;if(D.length===0)return;if(this.currentLevelIndex===f&&(p=D[f])!==null&&p!==void 0&&p.details)return;if(f<0||f>=D.length){var S=f<0;if(this.hls.trigger(O.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.LEVEL_SWITCH_ERROR,level:f,fatal:S,reason:"invalid level idx"}),S)return;f=Math.min(f,D.length-1)}this.clearTimer();var g=this.currentLevelIndex,c=D[g],d=D[f];this.log("switching to level "+f+" from "+g),this.currentLevelIndex=f;var a=v({},d,{level:f,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete a._urlId,this.hls.trigger(O.Events.LEVEL_SWITCHING,a);var E=d.details;if(!E||E.live){var b=this.switchParams(d.uri,c==null?void 0:c.details);this.loadPlaylist(b)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(f){this.manualLevelIndex=f,this._startLevel===void 0&&(this._startLevel=f),f!==-1&&(this.level=f)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(f){this._firstLevel=f}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var f=this.hls.config.startLevel;return f!==void 0?f:this._firstLevel}else return this._startLevel},set:function(f){this._startLevel=f}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(f){this.level=f,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=f)}}]),l}(M.default)},"./src/controller/level-helper.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"addGroupId",function(){return I}),_.d(Z,"assignTrackIdsByGroup",function(){return W}),_.d(Z,"updatePTS",function(){return F}),_.d(Z,"updateFragPTSDTS",function(){return k}),_.d(Z,"mergeDetails",function(){return v}),_.d(Z,"mapPartIntersection",function(){return y}),_.d(Z,"mapFragmentIntersection",function(){return R}),_.d(Z,"adjustSliding",function(){return A}),_.d(Z,"addSliding",function(){return x}),_.d(Z,"computeReloadInterval",function(){return C}),_.d(Z,"getFragmentWithSN",function(){return u}),_.d(Z,"getPartWith",function(){return o});var X=_("./src/polyfills/number.ts"),O=_("./src/utils/logger.ts");function I(l,h,L){switch(h){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(L);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(L);break}}function W(l){var h={};l.forEach(function(L){var f=L.groupId||"";L.id=h[f]=h[f]||0,h[f]++})}function F(l,h,L){var f=l[h],p=l[L];M(f,p)}function M(l,h){var L=h.startPTS;if(Object(X.isFiniteNumber)(L)){var f=0,p;h.sn>l.sn?(f=L-l.start,p=l):(f=l.start-L,p=h),p.duration!==f&&(p.duration=f)}else if(h.sn>l.sn){var D=l.cc===h.cc;D&&l.minEndPTS?h.start=l.start+(l.minEndPTS-l.start):h.start=l.start+l.duration}else h.start=Math.max(l.start-h.duration,0)}function k(l,h,L,f,p,D){var S=f-L;S<=0&&(O.logger.warn("Fragment should have a positive duration",h),f=L+h.duration,D=p+h.duration);var g=L,c=f,d=h.startPTS,a=h.endPTS;if(Object(X.isFiniteNumber)(d)){var E=Math.abs(d-L);Object(X.isFiniteNumber)(h.deltaPTS)?h.deltaPTS=Math.max(E,h.deltaPTS):h.deltaPTS=E,g=Math.max(L,d),L=Math.min(L,d),p=Math.min(p,h.startDTS),c=Math.min(f,a),f=Math.max(f,a),D=Math.max(D,h.endDTS)}h.duration=f-L;var b=L-h.start;h.appendedPTS=f,h.start=h.startPTS=L,h.maxStartPTS=g,h.startDTS=p,h.endPTS=f,h.minEndPTS=c,h.endDTS=D;var T=h.sn;if(!l||T<l.startSN||T>l.endSN)return 0;var P,G=T-l.startSN,Y=l.fragments;for(Y[G]=h,P=G;P>0;P--)M(Y[P],Y[P-1]);for(P=G;P<Y.length-1;P++)M(Y[P],Y[P+1]);return l.fragmentHint&&M(Y[Y.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,b}function v(l,h){for(var L=null,f=l.fragments,p=f.length-1;p>=0;p--){var D=f[p].initSegment;if(D){L=D;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var S=0,g;if(R(l,h,function(P,G){P.relurl&&(S=P.cc-G.cc),Object(X.isFiniteNumber)(P.startPTS)&&Object(X.isFiniteNumber)(P.endPTS)&&(G.start=G.startPTS=P.startPTS,G.startDTS=P.startDTS,G.appendedPTS=P.appendedPTS,G.maxStartPTS=P.maxStartPTS,G.endPTS=P.endPTS,G.endDTS=P.endDTS,G.minEndPTS=P.minEndPTS,G.duration=P.endPTS-P.startPTS,G.duration&&(g=G),h.PTSKnown=h.alignedSliding=!0),G.elementaryStreams=P.elementaryStreams,G.loader=P.loader,G.stats=P.stats,G.urlId=P.urlId,P.initSegment&&(G.initSegment=P.initSegment,L=P.initSegment)}),L){var c=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments;c.forEach(function(P){var G;(!P.initSegment||P.initSegment.relurl===((G=L)===null||G===void 0?void 0:G.relurl))&&(P.initSegment=L)})}if(h.skippedSegments&&(h.deltaUpdateFailed=h.fragments.some(function(P){return!P}),h.deltaUpdateFailed)){O.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=h.skippedSegments;d--;)h.fragments.shift();h.startSN=h.fragments[0].sn,h.startCC=h.fragments[0].cc}var a=h.fragments;if(S){O.logger.warn("discontinuity sliding from playlist, take drift into account");for(var E=0;E<a.length;E++)a[E].cc+=S}h.skippedSegments&&(h.startCC=h.fragments[0].cc),y(l.partList,h.partList,function(P,G){G.elementaryStreams=P.elementaryStreams,G.stats=P.stats}),g?k(h,g,g.startPTS,g.endPTS,g.startDTS,g.endDTS):A(l,h),a.length&&(h.totalduration=h.edge-a[0].start),h.driftStartTime=l.driftStartTime,h.driftStart=l.driftStart;var b=h.advancedDateTime;if(h.advanced&&b){var T=h.edge;h.driftStart||(h.driftStartTime=b,h.driftStart=T),h.driftEndTime=b,h.driftEnd=T}else h.driftEndTime=l.driftEndTime,h.driftEnd=l.driftEnd,h.advancedDateTime=l.advancedDateTime}function y(l,h,L){if(l&&h)for(var f=0,p=0,D=l.length;p<=D;p++){var S=l[p],g=h[p+f];S&&g&&S.index===g.index&&S.fragment.sn===g.fragment.sn?L(S,g):f--}}function R(l,h,L){for(var f=h.skippedSegments,p=Math.max(l.startSN,h.startSN)-h.startSN,D=(l.fragmentHint?1:0)+(f?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,S=h.startSN-l.startSN,g=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,c=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,d=p;d<=D;d++){var a=c[S+d],E=g[d];f&&!E&&d<f&&(E=h.fragments[d]=a),a&&E&&L(a,E)}}function A(l,h){var L=h.startSN+h.skippedSegments-l.startSN,f=l.fragments;if(L<0||L>=f.length)return;x(h,f[L].start)}function x(l,h){if(h){for(var L=l.fragments,f=l.skippedSegments;f<L.length;f++)L[f].start+=h;l.fragmentHint&&(l.fragmentHint.start+=h)}}function C(l,h){var L=1e3*l.levelTargetDuration,f=L/2,p=l.age,D=p>0&&p<L*3,S=h.loading.end-h.loading.start,g,c=l.availabilityDelay;if(l.updated===!1)if(D){var d=333*l.misses;g=Math.max(Math.min(f,S*2),d),l.availabilityDelay=(l.availabilityDelay||0)+g}else g=f;else D?(c=Math.min(c||L/2,p),l.availabilityDelay=c,g=c+L-p):g=L-S;return Math.round(g)}function u(l,h,L){if(!l||!l.details)return null;var f=l.details,p=f.fragments[h-f.startSN];return p||(p=f.fragmentHint,p&&p.sn===h?p:h<f.startSN&&L&&L.sn===h?L:null)}function o(l,h,L){if(!l||!l.details)return null;var f=l.details.partList;if(f)for(var p=f.length;p--;){var D=f[p];if(D.index===L&&D.fragment.sn===h)return D}return null}},"./src/controller/stream-controller.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return f});var X=_("./src/polyfills/number.ts"),O=_("./src/controller/base-stream-controller.ts"),I=_("./src/is-supported.ts"),W=_("./src/events.ts"),F=_("./src/utils/buffer-helper.ts"),M=_("./src/controller/fragment-tracker.ts"),k=_("./src/types/loader.ts"),v=_("./src/loader/fragment.ts"),y=_("./src/demux/transmuxer-interface.ts"),R=_("./src/types/transmuxer.ts"),A=_("./src/controller/gap-controller.ts"),x=_("./src/errors.ts"),C=_("./src/utils/logger.ts");function u(p,D){for(var S=0;S<D.length;S++){var g=D[S];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(p,g.key,g)}}function o(p,D,S){return D&&u(p.prototype,D),S&&u(p,S),p}function l(p,D){p.prototype=Object.create(D.prototype),p.prototype.constructor=p,h(p,D)}function h(p,D){return h=Object.setPrototypeOf||function(g,c){return g.__proto__=c,g},h(p,D)}var L=100,f=function(p){l(D,p);function D(g,c){var d;return d=p.call(this,g,c,"[stream-controller]")||this,d.audioCodecSwap=!1,d.gapController=null,d.level=-1,d._forceStartLoad=!1,d.altAudio=!1,d.audioOnly=!1,d.fragPlaying=null,d.onvplaying=null,d.onvseeked=null,d.fragLastKbps=0,d.stalled=!1,d.couldBacktrack=!1,d.audioCodecSwitch=!1,d.videoBuffer=null,d._registerListeners(),d}var S=D.prototype;return S._registerListeners=function(){var c=this.hls;c.on(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.on(W.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(W.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(W.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.on(W.Events.ERROR,this.onError,this),c.on(W.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(W.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.on(W.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(W.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(W.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.on(W.Events.FRAG_BUFFERED,this.onFragBuffered,this)},S._unregisterListeners=function(){var c=this.hls;c.off(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.off(W.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(W.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.off(W.Events.ERROR,this.onError,this),c.off(W.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(W.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.off(W.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(W.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(W.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.off(W.Events.FRAG_BUFFERED,this.onFragBuffered,this)},S.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},S.startLoad=function(c){if(this.levels){var d=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(L),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var E=a.startLevel;E===-1&&(a.config.testBandwidth?(E=0,this.bitrateTest=!0):E=a.nextAutoLevel),this.level=a.nextLoadLevel=E,this.loadedmetadata=!1}d>0&&c===-1&&(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),c=d),this.state=O.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()}else this._forceStartLoad=!0,this.state=O.State.STOPPED},S.stopLoad=function(){this._forceStartLoad=!1,p.prototype.stopLoad.call(this)},S.doTick=function(){switch(this.state){case O.State.IDLE:this.doTickIdle();break;case O.State.WAITING_LEVEL:{var c,d=this.levels,a=this.level,E=d==null||((c=d[a])===null||c===void 0)?void 0:c.details;if(E&&(!E.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(E))break;this.state=O.State.IDLE;break}break}case O.State.FRAG_LOADING_WAITING_RETRY:{var b,T=self.performance.now(),P=this.retryDate;(!P||T>=P||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=O.State.IDLE)}break;default:break}this.onTickEnd()},S.onTickEnd=function(){p.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},S.doTickIdle=function(){var c,d,a=this.hls,E=this.levelLastLoaded,b=this.levels,T=this.media,P=a.config,G=a.nextLoadLevel;if(E===null||!T&&(this.startFragRequested||!P.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!b||!b[G])return;var Y=b[G];this.level=a.nextLoadLevel=G;var Q=Y.details;if(!Q||this.state===O.State.WAITING_LEVEL||Q.live&&this.levelLastLoaded!==G){this.state=O.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:T,k.PlaylistLevelType.MAIN);if(z===null)return;var j=z.len,q=this.getMaxBufferLength(Y.maxBitrate);if(j>=q)return;if(this._streamEnded(z,Q)){var ae={};this.altAudio&&(ae.type="video"),this.hls.trigger(W.Events.BUFFER_EOS,ae),this.state=O.State.ENDED;return}var ce=z.end,ve=this.getNextFragment(ce,Q);if(this.couldBacktrack&&!this.fragPrevious&&ve&&ve.sn!=="initSegment"){var ke=ve.sn-Q.startSN;ke>1&&(ve=Q.fragments[ke-1],this.fragmentTracker.removeFragment(ve))}if(ve&&this.fragmentTracker.getState(ve)===M.FragmentState.OK&&this.nextLoadPosition>ce){var Ee=this.audioOnly&&!this.altAudio?v.ElementaryStreamTypes.AUDIO:v.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(T,Ee,k.PlaylistLevelType.MAIN),ve=this.getNextFragment(this.nextLoadPosition,Q)}if(!ve)return;ve.initSegment&&!ve.initSegment.data&&!this.bitrateTest&&(ve=ve.initSegment),((c=ve.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((d=ve.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(ve,Q):this.loadFragment(ve,Q,ce)},S.loadFragment=function(c,d,a){var E,b=this.fragmentTracker.getState(c);if(this.fragCurrent=c,b===M.FragmentState.BACKTRACKED){var T=this.fragmentTracker.getBacktrackData(c);if(T){this._handleFragmentLoadProgress(T),this._handleFragmentLoadComplete(T);return}else b=M.FragmentState.NOT_LOADED}b===M.FragmentState.NOT_LOADED||b===M.FragmentState.PARTIAL?c.sn==="initSegment"?this._loadInitSegment(c):this.bitrateTest?(c.bitrateTest=!0,this.log("Fragment "+c.sn+" of level "+c.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(c)):(this.startFragRequested=!0,p.prototype.loadFragment.call(this,c,d,a)):b===M.FragmentState.APPENDING?this.reduceMaxBufferLength(c.duration)&&this.fragmentTracker.removeFragment(c):((E=this.media)===null||E===void 0?void 0:E.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},S.getAppendedFrag=function(c){var d=this.fragmentTracker.getAppendedFrag(c,k.PlaylistLevelType.MAIN);return d&&"fragment"in d?d.fragment:d},S.getBufferedFrag=function(c){return this.fragmentTracker.getBufferedFrag(c,k.PlaylistLevelType.MAIN)},S.followingBufferedFrag=function(c){return c?this.getBufferedFrag(c.end+.5):null},S.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},S.nextLevelSwitch=function(){var c=this.levels,d=this.media;if(d!=null&&d.readyState){var a,E=this.getAppendedFrag(d.currentTime);if(E&&E.start>1&&this.flushMainBuffer(0,E.start-1),!d.paused&&c){var b=this.hls.nextLoadLevel,T=c[b],P=this.fragLastKbps;P&&this.fragCurrent?a=this.fragCurrent.duration*T.maxBitrate/(1e3*P)+1:a=0}else a=0;var G=this.getBufferedFrag(d.currentTime+a);if(G){var Y=this.followingBufferedFrag(G);if(Y){this.abortCurrentFrag();var Q=Y.maxStartPTS?Y.maxStartPTS:Y.start,z=Y.duration,j=Math.max(G.end,Q+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(j,Number.POSITIVE_INFINITY)}}}},S.abortCurrentFrag=function(){var c=this.fragCurrent;this.fragCurrent=null,c!=null&&c.loader&&c.loader.abort(),this.state===O.State.KEY_LOADING&&(this.state=O.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},S.flushMainBuffer=function(c,d){p.prototype.flushMainBuffer.call(this,c,d,this.altAudio?"video":null)},S.onMediaAttached=function(c,d){p.prototype.onMediaAttached.call(this,c,d);var a=d.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 A.default(this.config,a,this.fragmentTracker,this.hls)},S.onMediaDetaching=function(){var c=this.media;c&&(c.removeEventListener("playing",this.onvplaying),c.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),p.prototype.onMediaDetaching.call(this)},S.onMediaPlaying=function(){this.tick()},S.onMediaSeeked=function(){var c=this.media,d=c?c.currentTime:null;Object(X.isFiniteNumber)(d)&&this.log("Media seeked to "+d.toFixed(3)),this.tick()},S.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(W.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},S.onManifestParsed=function(c,d){var a=!1,E=!1,b;d.levels.forEach(function(T){b=T.audioCodec,b&&(b.indexOf("mp4a.40.2")!==-1&&(a=!0),b.indexOf("mp4a.40.5")!==-1&&(E=!0))}),this.audioCodecSwitch=a&&E&&!Object(I.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=d.levels,this.startFragRequested=!1},S.onLevelLoading=function(c,d){var a=this.levels;if(!a||this.state!==O.State.IDLE)return;var E=a[d.level];(!E.details||E.details.live&&this.levelLastLoaded!==d.level||this.waitForCdnTuneIn(E.details))&&(this.state=O.State.WAITING_LEVEL)},S.onLevelLoaded=function(c,d){var a,E=this.levels,b=d.level,T=d.details,P=T.totalduration;if(!E){this.warn("Levels were reset while loading level "+b);return}this.log("Level "+b+" loaded ["+T.startSN+","+T.endSN+"], cc ["+T.startCC+", "+T.endCC+"] duration:"+P);var G=this.fragCurrent;G&&(this.state===O.State.FRAG_LOADING||this.state===O.State.FRAG_LOADING_WAITING_RETRY)&&(G.level!==d.level&&G.loader&&(this.state=O.State.IDLE,G.loader.abort()));var Y=E[b],Q=0;if(T.live||(a=Y.details)!==null&&a!==void 0&&a.live){if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed)return;Q=this.alignPlaylists(T,Y.details)}if(Y.details=T,this.levelLastLoaded=b,this.hls.trigger(W.Events.LEVEL_UPDATED,{details:T,level:b}),this.state===O.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(T))return;this.state=O.State.IDLE}this.startFragRequested?T.live&&this.synchronizeToLiveEdge(T):this.setStartPosition(T,Q),this.tick()},S._handleFragmentLoadProgress=function(c){var d,a=c.frag,E=c.part,b=c.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],G=P.details;if(!G){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var Y=P.videoCodec,Q=G.PTSKnown||!G.live,z=(d=a.initSegment)===null||d===void 0?void 0:d.data,j=this._getAudioCodec(P),q=this.transmuxer=this.transmuxer||new y.default(this.hls,k.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ae=E?E.index:-1,ce=ae!==-1,ve=new R.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,b.byteLength,ae,ce),ke=this.initPTS[a.cc];q.push(b,z,j,Y,a,E,G.totalduration,Q,ve,ke)},S.onAudioTrackSwitching=function(c,d){var a=this.altAudio,E=!!d.url,b=d.id;if(!E){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(W.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(W.Events.AUDIO_TRACK_SWITCHED,{id:b})}},S.onAudioTrackSwitched=function(c,d){var a=d.id,E=!!this.hls.audioTracks[a].url;if(E){var b=this.videoBuffer;b&&this.mediaBuffer!==b&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=b)}this.altAudio=E,this.tick()},S.onBufferCreated=function(c,d){var a=d.tracks,E,b,T=!1;for(var P in a){var G=a[P];if(G.id==="main"){if(b=P,E=G,P==="video"){var Y=a[P];Y&&(this.videoBuffer=Y.buffer)}}else T=!0}T&&E?(this.log("Alternate track found, use "+b+".buffered to schedule main fragment loading"),this.mediaBuffer=E.buffer):this.mediaBuffer=this.media},S.onFragBuffered=function(c,d){var a=d.frag,E=d.part;if(a&&a.type!==k.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(E?" p: "+E.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===O.State.PARSED&&(this.state=O.State.IDLE);return}var b=E?E.stats:a.stats;this.fragLastKbps=Math.round(8*b.total/(b.buffering.end-b.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,E)},S.onError=function(c,d){switch(d.details){case x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:case x.ErrorDetails.KEY_LOAD_ERROR:case x.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(k.PlaylistLevelType.MAIN,d);break;case x.ErrorDetails.LEVEL_LOAD_ERROR:case x.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==O.State.ERROR&&(d.fatal?(this.warn(""+d.details),this.state=O.State.ERROR):!d.levelRetry&&this.state===O.State.WAITING_LEVEL&&(this.state=O.State.IDLE));break;case x.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="main"&&(this.state===O.State.PARSING||this.state===O.State.PARSED)){var a=!0,E=this.getFwdBufferInfo(this.media,k.PlaylistLevelType.MAIN);E&&E.len>.5&&(a=!this.reduceMaxBufferLength(E.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},S.checkBuffer=function(){var c=this.media,d=this.gapController;if(!c||!d||!c.readyState)return;var a=F.BufferHelper.getBuffered(c);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):d.poll(this.lastCurrentTime),this.lastCurrentTime=c.currentTime},S.onFragLoadEmergencyAborted=function(){this.state=O.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},S.onBufferFlushed=function(c,d){var a=d.type;if(a!==v.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var E=(a===v.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(E,a,k.PlaylistLevelType.MAIN)}},S.onLevelsUpdated=function(c,d){this.levels=d.levels},S.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},S.seekToStartPos=function(){var c=this.media,d=c.currentTime,a=this.startPosition;if(a>=0&&d<a){if(c.seeking){C.logger.log("could not seek to "+a+", already seeking at "+d);return}var E=F.BufferHelper.getBuffered(c),b=E.length?E.start(0):0,T=b-a;T>0&&(T<this.config.maxBufferHole||T<this.config.maxFragLookUpTolerance)&&(C.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 "+d),c.currentTime=a}},S._getAudioCodec=function(c){var d=this.config.defaultAudioCodec||c.audioCodec;return this.audioCodecSwap&&d&&(this.log("Swapping audio codec"),d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5"),d},S._loadBitrateTestFrag=function(c){var d=this;this._doFragLoad(c).then(function(a){var E=d.hls;if(!a||E.nextLoadLevel||d.fragContextChanged(c))return;d.fragLoadError=0,d.state=O.State.IDLE,d.startFragRequested=!1,d.bitrateTest=!1;var b=c.stats;b.parsing.start=b.parsing.end=b.buffering.start=b.buffering.end=self.performance.now(),E.trigger(W.Events.FRAG_LOADED,a)})},S._handleTransmuxComplete=function(c){var d,a="main",E=this.hls,b=c.remuxResult,T=c.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 G=P.frag,Y=P.part,Q=P.level,z=b.video,j=b.text,q=b.id3,ae=b.initSegment,ce=this.altAudio?void 0:b.audio;if(this.fragContextChanged(G))return;if(this.state=O.State.PARSING,ae){ae.tracks&&(this._bufferInitSegment(Q,ae.tracks,G,T),E.trigger(W.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:a,tracks:ae.tracks}));var ve=ae.initPTS,ke=ae.timescale;Object(X.isFiniteNumber)(ve)&&(this.initPTS[G.cc]=ve,E.trigger(W.Events.INIT_PTS_FOUND,{frag:G,id:a,initPTS:ve,timescale:ke}))}if(z&&b.independent!==!1){if(Q.details){var Ee=z.startPTS,Ce=z.endPTS,Le=z.startDTS,we=z.endDTS;if(Y)Y.elementaryStreams[z.type]={startPTS:Ee,endPTS:Ce,startDTS:Le,endDTS:we};else if(z.firstKeyFrame&&z.independent&&(this.couldBacktrack=!0),z.dropped&&z.independent){var me=this.getLoadPosition()+this.config.maxBufferHole;if(me<Ee){this.backtrack(G);return}G.setElementaryStreamInfo(z.type,G.start,Ce,G.start,we,!0)}G.setElementaryStreamInfo(z.type,Ee,Ce,Le,we),this.bufferFragmentData(z,G,Y,T)}}else if(b.independent===!1){this.backtrack(G);return}if(ce){var le=ce.startPTS,Oe=ce.endPTS,Ye=ce.startDTS,Ve=ce.endDTS;Y&&(Y.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:le,endPTS:Oe,startDTS:Ye,endDTS:Ve}),G.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,le,Oe,Ye,Ve),this.bufferFragmentData(ce,G,Y,T)}if(q!=null&&(d=q.samples)!==null&&d!==void 0&&d.length){var $e={frag:G,id:a,samples:q.samples};E.trigger(W.Events.FRAG_PARSING_METADATA,$e)}if(j){var ze={frag:G,id:a,samples:j.samples};E.trigger(W.Events.FRAG_PARSING_USERDATA,ze)}},S._bufferInitSegment=function(c,d,a,E){var b=this;if(this.state!==O.State.PARSING)return;this.audioOnly=!!d.audio&&!d.video,this.altAudio&&!this.audioOnly&&delete d.audio;var T=d.audio,P=d.video,G=d.audiovideo;if(T){var Y=c.audioCodec,Q=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(Y&&(Y.indexOf("mp4a.40.5")!==-1?Y="mp4a.40.2":Y="mp4a.40.5"),T.metadata.channelCount!==1&&Q.indexOf("firefox")===-1&&(Y="mp4a.40.5")),Q.indexOf("android")!==-1&&T.container!=="audio/mpeg"&&(Y="mp4a.40.2",this.log("Android: force audio codec to "+Y)),c.audioCodec&&c.audioCodec!==Y&&this.log('Swapping manifest audio codec "'+c.audioCodec+'" for "'+Y+'"'),T.levelCodec=Y,T.id="main",this.log("Init audio buffer, container:"+T.container+", codecs[selected/level/parsed]=["+(Y||"")+"/"+(c.audioCodec||"")+"/"+T.codec+"]")}P&&(P.levelCodec=c.videoCodec,P.id="main",this.log("Init video buffer, container:"+P.container+", codecs[level/parsed]=["+(c.videoCodec||"")+"/"+P.codec+"]")),G&&this.log("Init audiovideo buffer, container:"+G.container+", codecs[level/parsed]=["+(c.attrs.CODECS||"")+"/"+G.codec+"]"),this.hls.trigger(W.Events.BUFFER_CODECS,d),Object.keys(d).forEach(function(z){var j=d[z],q=j.initSegment;q!=null&&q.byteLength&&b.hls.trigger(W.Events.BUFFER_APPENDING,{type:z,data:q,frag:a,part:null,chunkMeta:E,parent:a.type})}),this.tick()},S.backtrack=function(c){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(c);var d=this.fragmentTracker.backtrack(c);this.fragPrevious=null,this.nextLoadPosition=c.start,d?this.resetFragmentLoading(c):this.state=O.State.BACKTRACKING},S.checkFragmentChanged=function(){var c=this.media,d=null;if(c&&c.readyState>1&&c.seeking===!1){var a=c.currentTime;if(F.BufferHelper.isBuffered(c,a)?d=this.getAppendedFrag(a):F.BufferHelper.isBuffered(c,a+.1)&&(d=this.getAppendedFrag(a+.1)),d){var E=this.fragPlaying,b=d.level;(!E||d.sn!==E.sn||E.level!==b||d.urlId!==E.urlId)&&(this.hls.trigger(W.Events.FRAG_CHANGED,{frag:d}),(!E||E.level!==b)&&this.hls.trigger(W.Events.LEVEL_SWITCHED,{level:b}),this.fragPlaying=d)}}},o(D,[{key:"nextLevel",get:function(){var c=this.nextBufferedFrag;return c?c.level:-1}},{key:"currentLevel",get:function(){var c=this.media;if(c){var d=this.getAppendedFrag(c.currentTime);if(d)return d.level}return-1}},{key:"nextBufferedFrag",get:function(){var c=this.media;if(c){var d=this.getAppendedFrag(c.currentTime);return this.followingBufferedFrag(d)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),D}(O.default)},"./src/controller/subtitle-stream-controller.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"SubtitleStreamController",function(){return l});var X=_("./src/events.ts"),O=_("./src/utils/logger.ts"),I=_("./src/utils/buffer-helper.ts"),W=_("./src/controller/fragment-finders.ts"),F=_("./src/utils/discontinuities.ts"),M=_("./src/controller/level-helper.ts"),k=_("./src/controller/fragment-tracker.ts"),v=_("./src/controller/base-stream-controller.ts"),y=_("./src/types/loader.ts"),R=_("./src/types/level.ts");function A(h,L){for(var f=0;f<L.length;f++){var p=L[f];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(h,p.key,p)}}function x(h,L,f){return L&&A(h.prototype,L),f&&A(h,f),h}function C(h,L){h.prototype=Object.create(L.prototype),h.prototype.constructor=h,u(h,L)}function u(h,L){return u=Object.setPrototypeOf||function(p,D){return p.__proto__=D,p},u(h,L)}var o=500,l=function(h){C(L,h);function L(p,D){var S;return S=h.call(this,p,D,"[subtitle-stream-controller]")||this,S.levels=[],S.currentTrackId=-1,S.tracksBuffered=[],S.mainDetails=null,S._registerListeners(),S}var f=L.prototype;return f.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},f._registerListeners=function(){var D=this.hls;D.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),D.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),D.on(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),D.on(X.Events.LEVEL_LOADED,this.onLevelLoaded,this),D.on(X.Events.ERROR,this.onError,this),D.on(X.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),D.on(X.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),D.on(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),D.on(X.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),D.on(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},f._unregisterListeners=function(){var D=this.hls;D.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),D.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),D.off(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),D.off(X.Events.LEVEL_LOADED,this.onLevelLoaded,this),D.off(X.Events.ERROR,this.onError,this),D.off(X.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),D.off(X.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),D.off(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),D.off(X.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),D.off(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},f.startLoad=function(){this.stopLoad(),this.state=v.State.IDLE,this.setInterval(o),this.tick()},f.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},f.onLevelLoaded=function(D,S){this.mainDetails=S.details},f.onSubtitleFragProcessed=function(D,S){var g=S.frag,c=S.success;if(this.fragPrevious=g,this.state=v.State.IDLE,!c)return;var d=this.tracksBuffered[this.currentTrackId];if(!d)return;for(var a,E=g.start,b=0;b<d.length;b++)if(E>=d[b].start&&E<=d[b].end){a=d[b];break}var T=g.start+g.duration;a?a.end=T:(a={start:E,end:T},d.push(a)),this.fragmentTracker.fragBuffered(g)},f.onBufferFlushing=function(D,S){var g=S.startOffset,c=S.endOffset;if(g===0&&c!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,a=this.levels;if(!a.length||!a[d]||!a[d].details)return;var E=a[d].details,b=E.targetduration,T=c-b;if(T<=0)return;S.endOffsetSubtitles=Math.max(0,T),this.tracksBuffered.forEach(function(P){for(var G=0;G<P.length;){if(P[G].end<=T){P.shift();continue}else if(P[G].start<T)P[G].start=T;else break;G++}}),this.fragmentTracker.removeFragmentsInRange(g,T,y.PlaylistLevelType.SUBTITLE)}},f.onError=function(D,S){var g,c=S.frag;if(!c||c.type!==y.PlaylistLevelType.SUBTITLE)return;(g=this.fragCurrent)!==null&&g!==void 0&&g.loader&&this.fragCurrent.loader.abort(),this.state=v.State.IDLE},f.onSubtitleTracksUpdated=function(D,S){var g=this,c=S.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(d){return new R.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){g.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},f.onSubtitleTrackSwitch=function(D,S){if(this.currentTrackId=S.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var g=this.levels[this.currentTrackId];g!=null&&g.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,g&&this.setInterval(o)},f.onSubtitleTrackLoaded=function(D,S){var g,c=S.details,d=S.id,a=this.currentTrackId,E=this.levels;if(!E.length)return;var b=E[a];if(d>=E.length||d!==a||!b)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(g=b.details)!==null&&g!==void 0&&g.live){var T=this.mainDetails;if(c.deltaUpdateFailed||!T)return;var P=T.fragments[0];if(!b.details)c.hasProgramDateTime&&T.hasProgramDateTime?Object(F.alignMediaPlaylistByPDT)(c,T):P&&Object(M.addSliding)(c,P.start);else{var G=this.alignPlaylists(c,b.details);G===0&&P&&Object(M.addSliding)(c,P.start)}}if(b.details=c,this.levelLastLoaded=d,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===v.State.IDLE){var Y=Object(W.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);Y||(this.warn("Subtitle playlist not aligned with playback"),b.details=void 0)}},f._handleFragmentLoadComplete=function(D){var S=D.frag,g=D.payload,c=S.decryptdata,d=this.hls;if(this.fragContextChanged(S))return;if(g&&g.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(g),c.key.buffer,c.iv.buffer).then(function(E){var b=performance.now();d.trigger(X.Events.FRAG_DECRYPTED,{frag:S,payload:E,stats:{tstart:a,tdecrypt:b}})})}},f.doTick=function(){if(!this.media){this.state=v.State.IDLE;return}if(this.state===v.State.IDLE){var D,S=this.currentTrackId,g=this.levels;if(!g.length||!g[S]||!g[S].details)return;var c=g[S].details,d=c.targetduration,a=this.config,E=this.media,b=I.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,E.currentTime-d,a.maxBufferHole),T=b.end,P=b.len,G=this.getMaxBufferLength()+d;if(P>G)return;console.assert(c,"Subtitle track details are defined on idle subtitle stream controller tick");var Y=c.fragments,Q=Y.length,z=c.edge,j,q=this.fragPrevious;if(T<z){var ae=a.maxFragLookUpTolerance;q&&c.hasProgramDateTime&&(j=Object(W.findFragmentByPDT)(Y,q.endProgramDateTime,ae)),j||(j=Object(W.findFragmentByPTS)(q,Y,T,ae),!j&&q&&q.start<Y[0].start&&(j=Y[0]))}else j=Y[Q-1];(D=j)!==null&&D!==void 0&&D.encrypted?(O.logger.log("Loading key for "+j.sn),this.state=v.State.KEY_LOADING,this.hls.trigger(X.Events.KEY_LOADING,{frag:j})):j&&this.fragmentTracker.getState(j)===k.FragmentState.NOT_LOADED&&this.loadFragment(j,c,T)}},f.loadFragment=function(D,S,g){this.fragCurrent=D,h.prototype.loadFragment.call(this,D,S,g)},x(L,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),L}(v.default)},"./src/controller/subtitle-track-controller.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/events.ts"),O=_("./src/utils/texttrack-utils.ts"),I=_("./src/controller/base-playlist-controller.ts"),W=_("./src/types/loader.ts");function F(A,x){for(var C=0;C<x.length;C++){var u=x[C];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(A,u.key,u)}}function M(A,x,C){return x&&F(A.prototype,x),C&&F(A,C),A}function k(A,x){A.prototype=Object.create(x.prototype),A.prototype.constructor=A,v(A,x)}function v(A,x){return v=Object.setPrototypeOf||function(u,o){return u.__proto__=o,u},v(A,x)}var y=function(A){k(x,A);function x(u){var o;return o=A.call(this,u,"[subtitle-track-controller]")||this,o.media=null,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.selectDefaultTrack=!0,o.queuedDefaultTrack=-1,o.trackChangeListener=function(){return o.onTextTracksChanged()},o.asyncPollTrackChange=function(){return o.pollTrackChange(0)},o.useTextTrackPolling=!1,o.subtitlePollingInterval=-1,o.subtitleDisplay=!0,o.registerListeners(),o}var C=x.prototype;return C.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,A.prototype.destroy.call(this)},C.registerListeners=function(){var o=this.hls;o.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(X.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(X.Events.ERROR,this.onError,this)},C.unregisterListeners=function(){var o=this.hls;o.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(X.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(X.Events.ERROR,this.onError,this)},C.onMediaAttached=function(o,l){if(this.media=l.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)},C.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},C.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 o=R(this.media.textTracks);o.forEach(function(l){Object(O.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},C.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},C.onManifestParsed=function(o,l){this.tracks=l.subtitleTracks},C.onSubtitleTrackLoaded=function(o,l){var h=l.id,L=l.details,f=this.trackId,p=this.tracksInGroup[f];if(!p){this.warn("Invalid subtitle track id "+h);return}var D=p.details;p.details=l.details,this.log("subtitle track "+h+" loaded ["+L.startSN+"-"+L.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,l,D))},C.onLevelLoading=function(o,l){this.switchLevel(l.level)},C.onLevelSwitching=function(o,l){this.switchLevel(l.level)},C.switchLevel=function(o){var l=this.hls.levels[o];if(!(l!=null&&l.textGroupIds))return;var h=l.textGroupIds[l.urlId];if(this.groupId!==h){var L=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,f=this.tracks.filter(function(S){return!h||S.groupId===h});this.tracksInGroup=f;var p=this.findTrackId(L==null?void 0:L.name)||this.findTrackId();this.groupId=h;var D={subtitleTracks:f};this.log("Updating subtitle tracks, "+f.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(X.Events.SUBTITLE_TRACKS_UPDATED,D),p!==-1&&this.setSubtitleTrack(p,L)}},C.findTrackId=function(o){for(var l=this.tracksInGroup,h=0;h<l.length;h++){var L=l[h];if((!this.selectDefaultTrack||L.default)&&(!o||o===L.name))return L.id}return-1},C.onError=function(o,l){if(A.prototype.onError.call(this,o,l),l.fatal||!l.context)return;l.context.type===W.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},C.loadPlaylist=function(o){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var h=l.id,L=l.groupId,f=l.url;if(o)try{f=o.addDirectives(f)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(X.Events.SUBTITLE_TRACK_LOADING,{url:f,id:h,groupId:L,deliveryDirectives:o||null})}},C.toggleTrackModes=function(o){var l=this,h=this.media,L=this.subtitleDisplay,f=this.trackId;if(!h)return;var p=R(h.textTracks),D=p.filter(function(c){return c.groupId===l.groupId});if(o===-1)[].slice.call(p).forEach(function(c){c.mode="disabled"});else{var S=D[f];S&&(S.mode="disabled")}var g=D[o];g&&(g.mode=L?"showing":"hidden")},C.setSubtitleTrack=function(o,l){var h,L=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(h=L[o])!==null&&h!==void 0&&h.details)||o<-1||o>=L.length)return;this.clearTimer();var f=L[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,f){var p=f.id,D=f.groupId,S=D===void 0?"":D,g=f.name,c=f.type,d=f.url;this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:S,name:g,type:c,url:d});var a=this.switchParams(f.url,l==null?void 0:l.details);this.loadPlaylist(a)}else this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:o})},C.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,l=R(this.media.textTracks),h=0;h<l.length;h++)if(l[h].mode==="hidden")o=h;else if(l[h].mode==="showing"){o=h;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},M(x,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(o,l)}}]),x}(I.default);function R(A){for(var x=[],C=0;C<A.length;C++){var u=A[C];u.kind==="subtitles"&&u.label&&x.push(A[C])}return x}Z.default=y},"./src/controller/timeline-controller.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"TimelineController",function(){return R});var X=_("./src/polyfills/number.ts"),O=_("./src/events.ts"),I=_("./src/utils/cea-608-parser.ts"),W=_("./src/utils/output-filter.ts"),F=_("./src/utils/webvtt-parser.ts"),M=_("./src/utils/texttrack-utils.ts"),k=_("./src/utils/imsc1-ttml-parser.ts"),v=_("./src/types/loader.ts"),y=_("./src/utils/logger.ts"),R=function(){function u(l){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=C(),this.captionsProperties=void 0,this.hls=l,this.config=l.config,this.Cues=l.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 h=new W.default(this,"textTrack1"),L=new W.default(this,"textTrack2"),f=new W.default(this,"textTrack3"),p=new W.default(this,"textTrack4");this.cea608Parser1=new I.default(1,h,L),this.cea608Parser2=new I.default(3,f,p)}l.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(O.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(O.Events.FRAG_LOADING,this.onFragLoading,this),l.on(O.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(O.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(O.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(O.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=u.prototype;return o.destroy=function(){var h=this.hls;h.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.off(O.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(O.Events.FRAG_LOADING,this.onFragLoading,this),h.off(O.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(O.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.off(O.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.off(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(O.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.off(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(h,L,f,p,D){for(var S=!1,g=D.length;g--;){var c=D[g],d=x(c[0],c[1],L,f);if(d>=0&&(c[0]=Math.min(c[0],L),c[1]=Math.max(c[1],f),S=!0,d/(f-L)>.5))return}if(S||D.push([L,f]),this.config.renderTextTracksNatively){var a=this.captionsTracks[h];this.Cues.newCue(a,L,f,p)}else{var E=this.Cues.newCue(null,L,f,p);this.hls.trigger(O.Events.CUES_PARSED,{type:"captions",cues:E,track:h})}},o.onInitPtsFound=function(h,L){var f=this,p=L.frag,D=L.id,S=L.initPTS,g=L.timescale,c=this.unparsedVttFrags;D==="main"&&(this.initPTS[p.cc]=S,this.timescale[p.cc]=g),c.length&&(this.unparsedVttFrags=[],c.forEach(function(d){f.onFragLoaded(O.Events.FRAG_LOADED,d)}))},o.getExistingTrack=function(h){var L=this.media;if(L)for(var f=0;f<L.textTracks.length;f++){var p=L.textTracks[f];if(p[h])return p}return null},o.createCaptionsTrack=function(h){this.config.renderTextTracksNatively?this.createNativeTrack(h):this.createNonNativeTrack(h)},o.createNativeTrack=function(h){if(this.captionsTracks[h])return;var L=this.captionsProperties,f=this.captionsTracks,p=this.media,D=L[h],S=D.label,g=D.languageCode,c=this.getExistingTrack(h);if(c)f[h]=c,Object(M.clearCurrentCues)(f[h]),Object(M.sendAddTrackEvent)(f[h],p);else{var d=this.createTextTrack("captions",S,g);d&&(d[h]=!0,f[h]=d)}},o.createNonNativeTrack=function(h){if(this.nonNativeCaptionsTracks[h])return;var L=this.captionsProperties[h];if(!L)return;var f=L.label,p={_id:h,label:f,kind:"captions",default:L.media?!!L.media.default:!1,closedCaptions:L.media};this.nonNativeCaptionsTracks[h]=p,this.hls.trigger(O.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[p]})},o.createTextTrack=function(h,L,f){var p=this.media;return p?p.addTextTrack(h,L,f):void 0},o.onMediaAttaching=function(h,L){this.media=L.media,this._cleanTracks()},o.onMediaDetaching=function(){var h=this.captionsTracks;Object.keys(h).forEach(function(L){Object(M.clearCurrentCues)(h[L]),delete h[L]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=C(),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())},o._cleanTracks=function(){var h=this.media;if(!h)return;var L=h.textTracks;if(L)for(var f=0;f<L.length;f++)Object(M.clearCurrentCues)(L[f])},o.onSubtitleTracksUpdated=function(h,L){var f=this;this.textTracks=[];var p=L.subtitleTracks||[],D=p.some(function(d){return d.textCodec===k.IMSC1_CODEC});if(this.config.enableWebVTT||D&&this.config.enableIMSC1){var S=this.tracks&&p&&this.tracks.length===p.length;if(this.tracks=p||[],this.config.renderTextTracksNatively){var g=this.media?this.media.textTracks:[];this.tracks.forEach(function(d,a){var E;if(a<g.length){for(var b=null,T=0;T<g.length;T++)if(A(g[T],d)){b=g[T];break}b&&(E=b)}E?Object(M.clearCurrentCues)(E):(E=f.createTextTrack("subtitles",d.name,d.lang),E&&(E.mode="disabled")),E&&(E.groupId=d.groupId,f.textTracks.push(E))})}else if(!S&&this.tracks&&this.tracks.length){var c=this.tracks.map(function(d){return{label:d.name,kind:d.type.toLowerCase(),default:d.default,subtitleTrack:d}});this.hls.trigger(O.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},o.onManifestLoaded=function(h,L){var f=this;this.config.enableCEA708Captions&&L.captions&&L.captions.forEach(function(p){var D=/(?:CC|SERVICE)([1-4])/.exec(p.instreamId);if(!D)return;var S="textTrack"+D[1],g=f.captionsProperties[S];if(!g)return;g.label=p.name,p.lang&&(g.languageCode=p.lang),g.media=p})},o.onFragLoading=function(h,L){var f=this.cea608Parser1,p=this.cea608Parser2,D=this.lastSn,S=this.lastPartIndex;if(!this.enabled||!(f&&p))return;if(L.frag.type===v.PlaylistLevelType.MAIN){var g,c,d=L.frag.sn,a=(g=L==null||((c=L.part)===null||c===void 0)?void 0:c.index)!=null?g:-1;d===D+1||d===D&&a===S+1||(f.reset(),p.reset()),this.lastSn=d,this.lastPartIndex=a}},o.onFragLoaded=function(h,L){var f=L.frag,p=L.payload,D=this.initPTS,S=this.unparsedVttFrags;if(f.type===v.PlaylistLevelType.SUBTITLE)if(p.byteLength){if(!Object(X.isFiniteNumber)(D[f.cc])){S.push(L),D.length&&this.hls.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:f,error:new Error("Missing initial subtitle PTS")});return}var g=f.decryptdata;if(g==null||g.key==null||g.method!=="AES-128"){var c=this.tracks[f.level],d=this.vttCCs;d[f.cc]||(d[f.cc]={start:f.start,prevCC:this.prevCC,new:!0},this.prevCC=f.cc),c&&c.textCodec===k.IMSC1_CODEC?this._parseIMSC1(f,p):this._parseVTTs(f,p,d)}}else this.hls.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:f,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(h,L){var f=this,p=this.hls;Object(k.parseIMSC1)(L,this.initPTS[h.cc],this.timescale[h.cc],function(D){f._appendCues(D,h.level),p.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(D){y.logger.log("Failed to parse IMSC1: "+D),p.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:D})})},o._parseVTTs=function(h,L,f){var p=this,D=this.hls;Object(F.parseWebVTT)(L,this.initPTS[h.cc],this.timescale[h.cc],f,h.cc,h.start,function(S){p._appendCues(S,h.level),D.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(S){p._fallbackToIMSC1(h,L),y.logger.log("Failed to parse VTT cue: "+S),D.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:S})})},o._fallbackToIMSC1=function(h,L){var f=this,p=this.tracks[h.level];p.textCodec||Object(k.parseIMSC1)(L,this.initPTS[h.cc],this.timescale[h.cc],function(){p.textCodec=k.IMSC1_CODEC,f._parseIMSC1(h,L)},function(){p.textCodec="wvtt"})},o._appendCues=function(h,L){var f=this.hls;if(this.config.renderTextTracksNatively){var p=this.textTracks[L];if(p.mode==="disabled")return;h.forEach(function(g){return Object(M.addCueToTrack)(p,g)})}else{var D=this.tracks[L],S=D.default?"default":"subtitles"+L;f.trigger(O.Events.CUES_PARSED,{type:"subtitles",cues:h,track:S})}},o.onFragDecrypted=function(h,L){var f=L.frag;if(f.type===v.PlaylistLevelType.SUBTITLE){if(!Object(X.isFiniteNumber)(this.initPTS[f.cc])){this.unparsedVttFrags.push(L);return}this.onFragLoaded(O.Events.FRAG_LOADED,L)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(h,L){var f=this.cea608Parser1,p=this.cea608Parser2;if(!this.enabled||!(f&&p))return;for(var D=0;D<L.samples.length;D++){var S=L.samples[D].bytes;if(S){var g=this.extractCea608Data(S);f.addData(L.samples[D].pts,g[0]),p.addData(L.samples[D].pts,g[1])}}},o.onBufferFlushing=function(h,L){var f=L.startOffset,p=L.endOffset,D=L.endOffsetSubtitles,S=L.type,g=this.media;if(!g||g.currentTime<p)return;if(!S||S==="video"){var c=this.captionsTracks;Object.keys(c).forEach(function(a){return Object(M.removeCuesInRange)(c[a],f,p)})}if(this.config.renderTextTracksNatively&&(f===0&&D!==void 0)){var d=this.textTracks;Object.keys(d).forEach(function(a){return Object(M.removeCuesInRange)(d[a],f,D)})}},o.extractCea608Data=function(h){for(var L=h[0]&31,f=2,p=[[],[]],D=0;D<L;D++){var S=h[f++],g=127&h[f++],c=127&h[f++],d=(4&S)!==0,a=3&S;if(g===0&&c===0)continue;d&&((a===0||a===1)&&(p[a].push(g),p[a].push(c)))}return p},u}();function A(u,o){return u&&u.label===o.name&&!(u.textTrack1||u.textTrack2)}function x(u,o,l,h){return Math.min(o,h)-Math.max(u,l)}function C(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return X});var X=function(){function O(W,F){this.subtle=void 0,this.aesIV=void 0,this.subtle=W,this.aesIV=F}var I=O.prototype;return I.decrypt=function(F,M){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},M,F)},O}()},"./src/crypt/aes-decryptor.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"removePadding",function(){return O}),_.d(Z,"default",function(){return I});var X=_("./src/utils/typed-array.ts");function O(W){var F=W.byteLength,M=F&&new DataView(W.buffer).getUint8(F-1);return M?Object(X.sliceUint8)(W,0,F-M):W}var I=function(){function W(){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 F=W.prototype;return F.uint8ArrayToUint32Array_=function(k){for(var v=new DataView(k),y=new Uint32Array(4),R=0;R<4;R++)y[R]=v.getUint32(R*4);return y},F.initTable=function(){var k=this.sBox,v=this.invSBox,y=this.subMix,R=y[0],A=y[1],x=y[2],C=y[3],u=this.invSubMix,o=u[0],l=u[1],h=u[2],L=u[3],f=new Uint32Array(256),p=0,D=0,S=0;for(S=0;S<256;S++)S<128?f[S]=S<<1:f[S]=S<<1^283;for(S=0;S<256;S++){var g=D^D<<1^D<<2^D<<3^D<<4;g=g>>>8^g&255^99,k[p]=g,v[g]=p;var c=f[p],d=f[c],a=f[d],E=f[g]*257^g*16843008;R[p]=E<<24|E>>>8,A[p]=E<<16|E>>>16,x[p]=E<<8|E>>>24,C[p]=E,E=a*16843009^d*65537^c*257^p*16843008,o[g]=E<<24|E>>>8,l[g]=E<<16|E>>>16,h[g]=E<<8|E>>>24,L[g]=E,p?(p=c^f[f[f[a^c]]],D^=f[f[D]]):p=D=1}},F.expandKey=function(k){for(var v=this.uint8ArrayToUint32Array_(k),y=!0,R=0;R<v.length&&y;)y=v[R]===this.key[R],R++;if(y)return;this.key=v;var A=this.keySize=v.length;if(A!==4&&A!==6&&A!==8)throw new Error("Invalid aes key size="+A);var x=this.ksRows=(A+6+1)*4,C,u,o=this.keySchedule=new Uint32Array(x),l=this.invKeySchedule=new Uint32Array(x),h=this.sBox,L=this.rcon,f=this.invSubMix,p=f[0],D=f[1],S=f[2],g=f[3],c,d;for(C=0;C<x;C++){if(C<A){c=o[C]=v[C];continue}d=c,C%A===0?(d=d<<8|d>>>24,d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255],d^=L[C/A|0]<<24):A>6&&C%A===4&&(d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255]),o[C]=c=(o[C-A]^d)>>>0}for(u=0;u<x;u++)C=x-u,u&3?d=o[C]:d=o[C-4],u<4||C<=4?l[u]=d:l[u]=p[h[d>>>24]]^D[h[d>>>16&255]]^S[h[d>>>8&255]]^g[h[d&255]],l[u]=l[u]>>>0},F.networkToHostOrderSwap=function(k){return k<<24|(k&65280)<<8|(k&16711680)>>8|k>>>24},F.decrypt=function(k,v,y){for(var R=this.keySize+6,A=this.invKeySchedule,x=this.invSBox,C=this.invSubMix,u=C[0],o=C[1],l=C[2],h=C[3],L=this.uint8ArrayToUint32Array_(y),f=L[0],p=L[1],D=L[2],S=L[3],g=new Int32Array(k),c=new Int32Array(g.length),d,a,E,b,T,P,G,Y,Q,z,j,q,ae,ce,ve=this.networkToHostOrderSwap;v<g.length;){for(Q=ve(g[v]),z=ve(g[v+1]),j=ve(g[v+2]),q=ve(g[v+3]),T=Q^A[0],P=q^A[1],G=j^A[2],Y=z^A[3],ae=4,ce=1;ce<R;ce++)d=u[T>>>24]^o[P>>16&255]^l[G>>8&255]^h[Y&255]^A[ae],a=u[P>>>24]^o[G>>16&255]^l[Y>>8&255]^h[T&255]^A[ae+1],E=u[G>>>24]^o[Y>>16&255]^l[T>>8&255]^h[P&255]^A[ae+2],b=u[Y>>>24]^o[T>>16&255]^l[P>>8&255]^h[G&255]^A[ae+3],T=d,P=a,G=E,Y=b,ae=ae+4;d=x[T>>>24]<<24^x[P>>16&255]<<16^x[G>>8&255]<<8^x[Y&255]^A[ae],a=x[P>>>24]<<24^x[G>>16&255]<<16^x[Y>>8&255]<<8^x[T&255]^A[ae+1],E=x[G>>>24]<<24^x[Y>>16&255]<<16^x[T>>8&255]<<8^x[P&255]^A[ae+2],b=x[Y>>>24]<<24^x[T>>16&255]<<16^x[P>>8&255]<<8^x[G&255]^A[ae+3],c[v]=ve(d^f),c[v+1]=ve(b^p),c[v+2]=ve(E^D),c[v+3]=ve(a^S),f=Q,p=z,D=j,S=q,v=v+4}return c.buffer},W}()},"./src/crypt/decrypter.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return v});var X=_("./src/crypt/aes-crypto.ts"),O=_("./src/crypt/fast-aes-key.ts"),I=_("./src/crypt/aes-decryptor.ts"),W=_("./src/utils/logger.ts"),F=_("./src/utils/mp4-tools.ts"),M=_("./src/utils/typed-array.ts"),k=16,v=function(){function y(A,x,C){var u=C===void 0?{}:C,o=u.removePKCS7Padding,l=o===void 0?!0:o;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=A,this.config=x,this.removePKCS7Padding=l,l)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch(L){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var R=y.prototype;return R.destroy=function(){this.observer=null},R.isSync=function(){return this.config.enableSoftwareAES},R.flush=function(){var x=this.currentResult;if(!x){this.reset();return}var C=new Uint8Array(x);return this.reset(),this.removePKCS7Padding?Object(I.removePadding)(C):C},R.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},R.decrypt=function(x,C,u,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(x),C,u);var l=this.flush();l&&o(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(x),C,u).then(o)},R.softwareDecrypt=function(x,C,u){var o=this.currentIV,l=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(x=Object(F.appendUint8Array)(h,x),this.remainderData=null);var L=this.getValidChunk(x);if(!L.length)return null;o&&(u=o);var f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new I.default),f.expandKey(C);var p=l;return this.currentResult=f.decrypt(L.buffer,0,u),this.currentIV=Object(M.sliceUint8)(L,-16).buffer,p||null},R.webCryptoDecrypt=function(x,C,u){var o=this,l=this.subtle;return(this.key!==C||!this.fastAesKey)&&(this.key=C,this.fastAesKey=new O.default(l,C)),this.fastAesKey.expandKey().then(function(h){if(!l)return Promise.reject(new Error("web crypto not initialized"));var L=new X.default(l,u);return L.decrypt(x.buffer,h)}).catch(function(h){return o.onWebCryptoError(h,x,C,u)})},R.onWebCryptoError=function(x,C,u,o){return W.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",x),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(C,u,o)},R.getValidChunk=function(x){var C=x,u=x.length-x.length%k;return u!==x.length&&(C=Object(M.sliceUint8)(x,0,u),this.remainderData=Object(M.sliceUint8)(x,u)),C},R.logOnce=function(x){if(!this.logEnabled)return;W.logger.log("[decrypter.ts]: "+x),this.logEnabled=!1},y}()},"./src/crypt/fast-aes-key.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return X});var X=function(){function O(W,F){this.subtle=void 0,this.key=void 0,this.subtle=W,this.key=F}var I=O.prototype;return I.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},O}()},"./src/demux/aacdemuxer.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/demux/base-audio-demuxer.ts"),O=_("./src/demux/adts.ts"),I=_("./src/utils/logger.ts"),W=_("./src/demux/id3.ts");function F(v,y){v.prototype=Object.create(y.prototype),v.prototype.constructor=v,M(v,y)}function M(v,y){return M=Object.setPrototypeOf||function(A,x){return A.__proto__=x,A},M(v,y)}var k=function(v){F(y,v);function y(A,x){var C;return C=v.call(this)||this,C.observer=void 0,C.config=void 0,C.observer=A,C.config=x,C}var R=y.prototype;return R.resetInitSegment=function(x,C,u){v.prototype.resetInitSegment.call(this,x,C,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:x,duration:u,inputTimeScale:9e4,dropped:0}},y.probe=function(x){if(!x)return!1;for(var C=W.getID3Data(x,0)||[],u=C.length,o=x.length;u<o;u++)if(O.probe(x,u))return I.logger.log("ADTS sync word found !"),!0;return!1},R.canParse=function(x,C){return O.canParse(x,C)},R.appendFrame=function(x,C,u){O.initTrackConfig(x,this.observer,C,u,x.manifestCodec);var o=O.appendFrame(x,C,u,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},y}(X.default);k.minProbeByteLength=9,Z.default=k},"./src/demux/adts.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"getAudioConfig",function(){return W}),_.d(Z,"isHeaderPattern",function(){return F}),_.d(Z,"getHeaderLength",function(){return M}),_.d(Z,"getFullFrameLength",function(){return k}),_.d(Z,"canGetFrameLength",function(){return v}),_.d(Z,"isHeader",function(){return y}),_.d(Z,"canParse",function(){return R}),_.d(Z,"probe",function(){return A}),_.d(Z,"initTrackConfig",function(){return x}),_.d(Z,"getFrameDuration",function(){return C}),_.d(Z,"parseFrameHeader",function(){return u}),_.d(Z,"appendFrame",function(){return o});var X=_("./src/utils/logger.ts"),O=_("./src/errors.ts"),I=_("./src/events.ts");function W(l,h,L,f){var p,D,S,g,c=navigator.userAgent.toLowerCase(),d=f,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];p=((h[L+2]&192)>>>6)+1;var E=(h[L+2]&60)>>>2;if(E>a.length-1){l.trigger(I.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+E});return}return S=(h[L+2]&1)<<2,S|=(h[L+3]&192)>>>6,X.logger.log("manifest codec:"+f+", ADTS type:"+p+", samplingIndex:"+E),/firefox/i.test(c)?E>=6?(p=5,g=new Array(4),D=E-3):(p=2,g=new Array(2),D=E):c.indexOf("android")!==-1?(p=2,g=new Array(2),D=E):(p=5,g=new Array(4),f&&(f.indexOf("mp4a.40.29")!==-1||f.indexOf("mp4a.40.5")!==-1)||!f&&E>=6?D=E-3:((f&&f.indexOf("mp4a.40.2")!==-1&&(E>=6&&S===1||/vivaldi/i.test(c))||!f&&S===1)&&(p=2,g=new Array(2)),D=E)),g[0]=p<<3,g[0]|=(E&14)>>1,g[1]|=(E&1)<<7,g[1]|=S<<3,p===5&&(g[1]|=(D&14)>>1,g[2]=(D&1)<<7,g[2]|=2<<2,g[3]=0),{config:g,samplerate:a[E],channelCount:S,codec:"mp4a.40."+p,manifestCodec:d}}function F(l,h){return l[h]===255&&(l[h+1]&246)===240}function M(l,h){return l[h+1]&1?7:9}function k(l,h){return(l[h+3]&3)<<11|l[h+4]<<3|(l[h+5]&224)>>>5}function v(l,h){return h+5<l.length}function y(l,h){return h+1<l.length&&F(l,h)}function R(l,h){return v(l,h)&&F(l,h)&&k(l,h)<=l.length-h}function A(l,h){if(y(l,h)){var L=M(l,h);if(h+L>=l.length)return!1;var f=k(l,h);if(f<=L)return!1;var p=h+f;return p===l.length||y(l,p)}return!1}function x(l,h,L,f,p){if(!l.samplerate){var D=W(h,L,f,p);if(!D)return;l.config=D.config,l.samplerate=D.samplerate,l.channelCount=D.channelCount,l.codec=D.codec,l.manifestCodec=D.manifestCodec,X.logger.log("parsed codec:"+l.codec+", rate:"+D.samplerate+", channels:"+D.channelCount)}}function C(l){return 1024*9e4/l}function u(l,h,L,f,p){var D=M(l,h),S=k(l,h);if(S-=D,S>0){var g=L+f*p;return{headerLength:D,frameLength:S,stamp:g}}}function o(l,h,L,f,p){var D=C(l.samplerate),S=u(h,L,f,p,D);if(S){var g=S.frameLength,c=S.headerLength,d=S.stamp,a=c+g,E=Math.max(0,L+a-h.length),b;E?(b=new Uint8Array(a-c),b.set(h.subarray(L+c,h.length),0)):b=h.subarray(L+c,L+a);var T={unit:b,pts:d};return E||l.samples.push(T),{sample:T,length:a,missing:E}}}},"./src/demux/base-audio-demuxer.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"initPTSFn",function(){return k});var X=_("./src/polyfills/number.ts"),O=_("./src/demux/id3.ts"),I=_("./src/demux/dummy-demuxed-track.ts"),W=_("./src/utils/mp4-tools.ts"),F=_("./src/utils/typed-array.ts"),M=function(){function v(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var y=v.prototype;return y.resetInitSegment=function(A,x,C){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},y.resetTimeStamp=function(){},y.resetContiguity=function(){},y.canParse=function(A,x){return!1},y.appendFrame=function(A,x,C){},y.demux=function(A,x){this.cachedData&&(A=Object(W.appendUint8Array)(this.cachedData,A),this.cachedData=null);var C=O.getID3Data(A,0),u=C?C.length:0,o,l,h=this._audioTrack,L=this._id3Track,f=C?O.getTimeStamp(C):void 0,p=A.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=k(f,x)),C&&C.length>0&&L.samples.push({pts:this.initPTS,dts:this.initPTS,data:C}),l=this.initPTS;u<p;){if(this.canParse(A,u)){var D=this.appendFrame(h,A,u);D?(this.frameIndex++,l=D.sample.pts,u+=D.length,o=u):u=p}else O.canParse(A,u)?(C=O.getID3Data(A,u),L.samples.push({pts:l,dts:l,data:C}),u+=C.length,o=u):u++;if(u===p&&o!==p){var S=Object(F.sliceUint8)(A,o);this.cachedData?this.cachedData=Object(W.appendUint8Array)(this.cachedData,S):this.cachedData=S}}return{audioTrack:h,avcTrack:Object(I.dummyTrack)(),id3Track:L,textTrack:Object(I.dummyTrack)()}},y.demuxSampleAes=function(A,x,C){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},y.flush=function(A){var x=this.cachedData;return x&&(this.cachedData=null,this.demux(x,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(I.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(I.dummyTrack)()}},y.destroy=function(){},v}(),k=function(y,R){return Object(X.isFiniteNumber)(y)?y*90:R*9e4};Z.default=M},"./src/demux/chunk-cache.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return X});var X=function(){function I(){this.chunks=[],this.dataLength=0}var W=I.prototype;return W.push=function(M){this.chunks.push(M),this.dataLength+=M.length},W.flush=function(){var M=this.chunks,k=this.dataLength,v;if(M.length)M.length===1?v=M[0]:v=O(M,k);else return new Uint8Array(0);return this.reset(),v},W.reset=function(){this.chunks.length=0,this.dataLength=0},I}();function O(I,W){for(var F=new Uint8Array(W),M=0,k=0;k<I.length;k++){var v=I[k];F.set(v,M),M+=v.length}return F}},"./src/demux/dummy-demuxed-track.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"dummyTrack",function(){return X});function X(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/utils/logger.ts"),O=function(){function I(F){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=F,this.bytesAvailable=F.byteLength,this.word=0,this.bitsAvailable=0}var W=I.prototype;return W.loadWord=function(){var M=this.data,k=this.bytesAvailable,v=M.byteLength-k,y=new Uint8Array(4),R=Math.min(4,k);if(R===0)throw new Error("no bytes available");y.set(M.subarray(v,v+R)),this.word=new DataView(y.buffer).getUint32(0),this.bitsAvailable=R*8,this.bytesAvailable-=R},W.skipBits=function(M){var k;this.bitsAvailable>M?(this.word<<=M,this.bitsAvailable-=M):(M-=this.bitsAvailable,k=M>>3,M-=k>>3,this.bytesAvailable-=k,this.loadWord(),this.word<<=M,this.bitsAvailable-=M)},W.readBits=function(M){var k=Math.min(this.bitsAvailable,M),v=this.word>>>32-k;return M>32&&X.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=k,this.bitsAvailable>0?this.word<<=k:this.bytesAvailable>0&&this.loadWord(),k=M-k,k>0&&this.bitsAvailable?v<<k|this.readBits(k):v},W.skipLZ=function(){var M;for(M=0;M<this.bitsAvailable;++M)if((this.word&2147483648>>>M)!==0)return this.word<<=M,this.bitsAvailable-=M,M;return this.loadWord(),M+this.skipLZ()},W.skipUEG=function(){this.skipBits(1+this.skipLZ())},W.skipEG=function(){this.skipBits(1+this.skipLZ())},W.readUEG=function(){var M=this.skipLZ();return this.readBits(M+1)-1},W.readEG=function(){var M=this.readUEG();return 1&M?1+M>>>1:-1*(M>>>1)},W.readBoolean=function(){return this.readBits(1)===1},W.readUByte=function(){return this.readBits(8)},W.readUShort=function(){return this.readBits(16)},W.readUInt=function(){return this.readBits(32)},W.skipScalingList=function(M){for(var k=8,v=8,y,R=0;R<M;R++)v!==0&&(y=this.readEG(),v=(k+y+256)%256),k=v===0?k:v},W.readSPS=function(){var M=0,k=0,v=0,y=0,R,A,x,C=this.readUByte.bind(this),u=this.readBits.bind(this),o=this.readUEG.bind(this),l=this.readBoolean.bind(this),h=this.skipBits.bind(this),L=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);C();var D=C();if(u(5),h(3),C(),f(),D===100||D===110||D===122||D===244||D===44||D===83||D===86||D===118||D===128){var S=o();if(S===3&&h(1),f(),f(),h(1),l())for(A=S!==3?8:12,x=0;x<A;x++)l()&&(x<6?p(16):p(64))}f();var g=o();if(g===0)o();else if(g===1)for(h(1),L(),L(),R=o(),x=0;x<R;x++)L();f(),h(1);var c=o(),d=o(),a=u(1);a===0&&h(1),h(1),l()&&(M=o(),k=o(),v=o(),y=o());var E=[1,1];if(l()&&l()){var b=C();switch(b){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:{E=[C()<<8|C(),C()<<8|C()];break}}}return{width:Math.ceil((c+1)*16-M*2-k*2),height:(2-a)*(d+1)*16-(a?2:4)*(v+y),pixelRatio:E}},W.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},I}();Z.default=O},"./src/demux/id3.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"isHeader",function(){return X}),_.d(Z,"isFooter",function(){return O}),_.d(Z,"getID3Data",function(){return I}),_.d(Z,"canParse",function(){return F}),_.d(Z,"getTimeStamp",function(){return M}),_.d(Z,"isTimeStampFrame",function(){return k}),_.d(Z,"getID3Frames",function(){return y}),_.d(Z,"decodeFrame",function(){return R}),_.d(Z,"utf8ArrayToStr",function(){return o}),_.d(Z,"testables",function(){return l});var X=function(p,D){return D+10<=p.length&&(p[D]===73&&p[D+1]===68&&p[D+2]===51&&(p[D+3]<255&&p[D+4]<255&&(p[D+6]<128&&p[D+7]<128&&p[D+8]<128&&p[D+9]<128)))},O=function(p,D){return D+10<=p.length&&(p[D]===51&&p[D+1]===68&&p[D+2]===73&&(p[D+3]<255&&p[D+4]<255&&(p[D+6]<128&&p[D+7]<128&&p[D+8]<128&&p[D+9]<128)))},I=function(p,D){for(var S=D,g=0;X(p,D);){g+=10;var c=W(p,D+6);g+=c,O(p,D+10)&&(g+=10),D+=g}return g>0?p.subarray(S,S+g):void 0},W=function(p,D){var S=0;return S=(p[D]&127)<<21,S|=(p[D+1]&127)<<14,S|=(p[D+2]&127)<<7,S|=p[D+3]&127,S},F=function(p,D){return X(p,D)&&W(p,D+6)+10<=p.length-D},M=function(p){for(var D=y(p),S=0;S<D.length;S++){var g=D[S];if(k(g))return u(g)}return},k=function(p){return p&&p.key==="PRIV"&&p.info==="com.apple.streaming.transportStreamTimestamp"},v=function(p){var D=String.fromCharCode(p[0],p[1],p[2],p[3]),S=W(p,4),g=10;return{type:D,size:S,data:p.subarray(g,g+S)}},y=function(p){for(var D=0,S=[];X(p,D);){var g=W(p,D+6);D+=10;for(var c=D+g;D+8<c;){var d=v(p.subarray(D)),a=R(d);a&&S.push(a),D+=d.size+10}O(p,D)&&(D+=10)}return S},R=function(p){return p.type==="PRIV"?A(p):p.type[0]==="W"?C(p):x(p)},A=function(p){if(p.size<2)return;var D=o(p.data,!0),S=new Uint8Array(p.data.subarray(D.length+1));return{key:p.type,info:D,data:S.buffer}},x=function(p){if(p.size<2)return;if(p.type==="TXXX"){var D=1,S=o(p.data.subarray(D),!0);D+=S.length+1;var g=o(p.data.subarray(D));return{key:p.type,info:S,data:g}}var c=o(p.data.subarray(1));return{key:p.type,data:c}},C=function(p){if(p.type==="WXXX"){if(p.size<2)return;var D=1,S=o(p.data.subarray(D),!0);D+=S.length+1;var g=o(p.data.subarray(D));return{key:p.type,info:S,data:g}}var c=o(p.data);return{key:p.type,data:c}},u=function(p){if(p.data.byteLength===8){var D=new Uint8Array(p.data),S=D[3]&1,g=(D[4]<<23)+(D[5]<<15)+(D[6]<<7)+D[7];return g/=45,S&&(g+=4772185884e-2),Math.round(g)}return},o=function(p,D){D===void 0&&(D=!1);var S=L();if(S){var g=S.decode(p);if(D){var c=g.indexOf("\0");return c!==-1?g.substring(0,c):g}return g.replace(/\0/g,"")}for(var d=p.length,a,E,b,T="",P=0;P<d;){if(a=p[P++],a===0&&D)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:E=p[P++],T+=String.fromCharCode((a&31)<<6|E&63);break;case 14:E=p[P++],b=p[P++],T+=String.fromCharCode((a&15)<<12|(E&63)<<6|(b&63)<<0);break;default:}}return T},l={decodeTextFrame:x},h;function L(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/demux/base-audio-demuxer.ts"),O=_("./src/demux/id3.ts"),I=_("./src/utils/logger.ts"),W=_("./src/demux/mpegaudio.ts");function F(v,y){v.prototype=Object.create(y.prototype),v.prototype.constructor=v,M(v,y)}function M(v,y){return M=Object.setPrototypeOf||function(A,x){return A.__proto__=x,A},M(v,y)}var k=function(v){F(y,v);function y(){return v.apply(this,arguments)||this}var R=y.prototype;return R.resetInitSegment=function(x,C,u){v.prototype.resetInitSegment.call(this,x,C,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:x,duration:u,inputTimeScale:9e4,dropped:0}},y.probe=function(x){if(!x)return!1;for(var C=O.getID3Data(x,0)||[],u=C.length,o=x.length;u<o;u++)if(W.probe(x,u))return I.logger.log("MPEG Audio sync word found !"),!0;return!1},R.canParse=function(x,C){return W.canParse(x,C)},R.appendFrame=function(x,C,u){return this.initPTS===null?void 0:W.appendFrame(x,C,u,this.initPTS,this.frameIndex)},y}(X.default);k.minProbeByteLength=4,Z.default=k},"./src/demux/mp4demuxer.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/utils/mp4-tools.ts"),O=_("./src/demux/dummy-demuxed-track.ts"),I=function(){function W(M,k){this.remainderData=null,this.config=void 0,this.config=k}var F=W.prototype;return F.resetTimeStamp=function(){},F.resetInitSegment=function(){},F.resetContiguity=function(){},W.probe=function(k){return Object(X.findBox)({data:k,start:0,end:Math.min(k.length,16384)},["moof"]).length>0},F.demux=function(k){var v=k,y=Object(O.dummyTrack)();if(this.config.progressive){this.remainderData&&(v=Object(X.appendUint8Array)(this.remainderData,k));var R=Object(X.segmentValidRange)(v);this.remainderData=R.remainder,y.samples=R.valid||new Uint8Array}else y.samples=v;return{audioTrack:Object(O.dummyTrack)(),avcTrack:y,id3Track:Object(O.dummyTrack)(),textTrack:Object(O.dummyTrack)()}},F.flush=function(){var k=Object(O.dummyTrack)();return k.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(O.dummyTrack)(),avcTrack:k,id3Track:Object(O.dummyTrack)(),textTrack:Object(O.dummyTrack)()}},F.demuxSampleAes=function(k,v,y){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},F.destroy=function(){},W}();I.minProbeByteLength=1024,Z.default=I},"./src/demux/mpegaudio.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"appendFrame",function(){return M}),_.d(Z,"parseHeader",function(){return k}),_.d(Z,"isHeaderPattern",function(){return v}),_.d(Z,"isHeader",function(){return y}),_.d(Z,"canParse",function(){return R}),_.d(Z,"probe",function(){return A});var X=null,O=[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],I=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],W=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],F=[0,1,1,4];function M(x,C,u,o,l){if(u+24>C.length)return;var h=k(C,u);if(h&&u+h.frameLength<=C.length){var L=h.samplesPerFrame*9e4/h.sampleRate,f=o+l*L,p={unit:C.subarray(u,u+h.frameLength),pts:f,dts:f};return x.config=[],x.channelCount=h.channelCount,x.samplerate=h.sampleRate,x.samples.push(p),{sample:p,length:h.frameLength,missing:0}}}function k(x,C){var u=x[C+1]>>3&3,o=x[C+1]>>1&3,l=x[C+2]>>4&15,h=x[C+2]>>2&3;if(u!==1&&l!==0&&l!==15&&h!==3){var L=x[C+2]>>1&1,f=x[C+3]>>6,p=u===3?3-o:o===3?3:4,D=O[p*14+l-1]*1e3,S=u===3?0:u===2?1:2,g=I[S*3+h],c=f===3?1:2,d=W[u][o],a=F[o],E=d*8*a,b=Math.floor(d*D/g+L)*a;if(X===null){var T=navigator.userAgent||"",P=T.match(/Chrome\/(\d+)/i);X=P?parseInt(P[1]):0}var G=!!X&&X<=87;return G&&o===2&&D>=224e3&&f===0&&(x[C+3]=x[C+3]|128),{sampleRate:g,channelCount:c,frameLength:b,samplesPerFrame:E}}}function v(x,C){return x[C]===255&&(x[C+1]&224)===224&&(x[C+1]&6)!==0}function y(x,C){return C+1<x.length&&v(x,C)}function R(x,C){var u=4;return v(x,C)&&u<=x.length-C}function A(x,C){if(C+1<x.length&&v(x,C)){var u=4,o=k(x,C),l=u;o!=null&&o.frameLength&&(l=o.frameLength);var h=C+l;return h===x.length||y(x,h)}return!1}},"./src/demux/sample-aes.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/crypt/decrypter.ts"),O=_("./src/demux/tsdemuxer.ts"),I=function(){function W(M,k,v){this.keyData=void 0,this.decrypter=void 0,this.keyData=v,this.decrypter=new X.default(M,k,{removePKCS7Padding:!1})}var F=W.prototype;return F.decryptBuffer=function(k,v){this.decrypter.decrypt(k,this.keyData.key.buffer,this.keyData.iv.buffer,v)},F.decryptAacSample=function(k,v,y,R){var A=k[v].unit,x=A.subarray(16,A.length-A.length%16),C=x.buffer.slice(x.byteOffset,x.byteOffset+x.length),u=this;this.decryptBuffer(C,function(o){var l=new Uint8Array(o);A.set(l,16),R||u.decryptAacSamples(k,v+1,y)})},F.decryptAacSamples=function(k,v,y){for(;;v++){if(v>=k.length){y();return}if(k[v].unit.length<32)continue;var R=this.decrypter.isSync();if(this.decryptAacSample(k,v,y,R),!R)return}},F.getAvcEncryptedData=function(k){for(var v=Math.floor((k.length-48)/160)*16+16,y=new Int8Array(v),R=0,A=32;A<=k.length-16;A+=160,R+=16)y.set(k.subarray(A,A+16),R);return y},F.getAvcDecryptedUnit=function(k,v){for(var y=new Uint8Array(v),R=0,A=32;A<=k.length-16;A+=160,R+=16)k.set(y.subarray(R,R+16),A);return k},F.decryptAvcSample=function(k,v,y,R,A,x){var C=Object(O.discardEPB)(A.data),u=this.getAvcEncryptedData(C),o=this;this.decryptBuffer(u.buffer,function(l){A.data=o.getAvcDecryptedUnit(C,l),x||o.decryptAvcSamples(k,v,y+1,R)})},F.decryptAvcSamples=function(k,v,y,R){if(k instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;v++,y=0){if(v>=k.length){R();return}for(var A=k[v].units;!(y>=A.length);y++){var x=A[y];if(x.data.length<=48||x.type!==1&&x.type!==5)continue;var C=this.decrypter.isSync();if(this.decryptAvcSample(k,v,y,R,x,C),!C)return}}},W}();Z.default=I},"./src/demux/transmuxer-interface.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return A});var X=_("./node_modules/webworkify-webpack/index.js"),O=_.n(X),I=_("./src/events.ts"),W=_("./src/demux/transmuxer.ts"),F=_("./src/utils/logger.ts"),M=_("./src/errors.ts"),k=_("./src/utils/mediasource-helper.ts"),v=_("./node_modules/eventemitter3/index.js"),y=_.n(v),R=Object(k.getMediaSource)()||{isTypeSupported:function(){return!1}},A=function(){function x(u,o,l,h){var L=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=u,this.id=o,this.onTransmuxComplete=l,this.onFlush=h;var f=u.config,p=function(d,a){a=a||{},a.frag=L.frag,a.id=L.id,u.trigger(d,a)};this.observer=new v.EventEmitter,this.observer.on(I.Events.FRAG_DECRYPTED,p),this.observer.on(I.Events.ERROR,p);var D={mp4:R.isTypeSupported("video/mp4"),mpeg:R.isTypeSupported("audio/mpeg"),mp3:R.isTypeSupported('audio/mp4; codecs="mp3"')},S=navigator.vendor;if(f.enableWorker&&typeof Worker!="undefined"){F.logger.log("demuxing in webworker");var g;try{g=this.worker=X("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(c){u.trigger(I.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},g.postMessage({cmd:"init",typeSupported:D,vendor:S,id:o,config:JSON.stringify(f)})}catch(c){F.logger.warn("Error in worker:",c),F.logger.error("Error while initializing DemuxerWorker, fallback to inline"),g&&self.URL.revokeObjectURL(g.objectURL),this.transmuxer=new W.default(this.observer,D,f,S,o),this.worker=null}}else this.transmuxer=new W.default(this.observer,D,f,S,o)}var C=x.prototype;return C.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var l=this.transmuxer;l&&(l.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.observer=null},C.push=function(o,l,h,L,f,p,D,S,g,c){var d=this;g.transmuxing.start=self.performance.now();var a=this.transmuxer,E=this.worker,b=p?p.start:f.start,T=f.decryptdata,P=this.frag,G=!(P&&f.cc===P.cc),Y=!(P&&g.level===P.level),Q=P?g.sn-P.sn:-1,z=this.part?g.part-this.part.index:1,j=!Y&&(Q===1||Q===0&&z===1),q=self.performance.now();(Y||Q||f.stats.parsing.start===0)&&(f.stats.parsing.start=q),p&&(z||!j)&&(p.stats.parsing.start=q);var ae=new W.TransmuxState(G,j,S,Y,b);if(!j||G){F.logger.log("[transmuxer-interface, "+f.type+"]: Starting new transmux session for sn: "+g.sn+" p: "+g.part+" level: "+g.level+" id: "+g.id+`
|
|
discontinuity: `+G+`
|
|
trackSwitch: `+Y+`
|
|
contiguous: `+j+`
|
|
accurateTimeOffset: `+S+`
|
|
timeOffset: `+b);var ce=new W.TransmuxConfig(h,L,l,D,c);this.configureTransmuxer(ce)}if(this.frag=f,this.part=p,E)E.postMessage({cmd:"demux",data:o,decryptdata:T,chunkMeta:g,state:ae},o instanceof ArrayBuffer?[o]:[]);else if(a){var ve=a.push(o,T,g,ae);Object(W.isPromise)(ve)?ve.then(function(ke){d.handleTransmuxComplete(ke)}):this.handleTransmuxComplete(ve)}},C.flush=function(o){var l=this;o.transmuxing.start=self.performance.now();var h=this.transmuxer,L=this.worker;if(L)L.postMessage({cmd:"flush",chunkMeta:o});else if(h){var f=h.flush(o);Object(W.isPromise)(f)?f.then(function(p){l.handleFlushResult(p,o)}):this.handleFlushResult(f,o)}},C.handleFlushResult=function(o,l){var h=this;o.forEach(function(L){h.handleTransmuxComplete(L)}),this.onFlush(l)},C.onWorkerMessage=function(o){var l=o.data,h=this.hls;switch(l.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.id=this.id,h.trigger(l.event,l.data);break}}},C.configureTransmuxer=function(o){var l=this.worker,h=this.transmuxer;l?l.postMessage({cmd:"configure",config:o}):h&&h.configure(o)},C.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},x}()},"./src/demux/transmuxer-worker.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return M});var X=_("./src/demux/transmuxer.ts"),O=_("./src/events.ts"),I=_("./src/utils/logger.ts"),W=_("./node_modules/eventemitter3/index.js"),F=_.n(W);function M(A){var x=new W.EventEmitter,C=function(o,l){A.postMessage({event:o,data:l})};x.on(O.Events.FRAG_DECRYPTED,C),x.on(O.Events.ERROR,C),A.addEventListener("message",function(u){var o=u.data;switch(o.cmd){case"init":{var l=JSON.parse(o.config);A.transmuxer=new X.default(x,o.typeSupported,l,o.vendor,o.id),Object(I.enableLogs)(l.debug),C("init",null);break}case"configure":{A.transmuxer.configure(o.config);break}case"demux":{var h=A.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(X.isPromise)(h)?h.then(function(p){k(A,p)}):k(A,h);break}case"flush":{var L=o.chunkMeta,f=A.transmuxer.flush(L);Object(X.isPromise)(f)?f.then(function(p){y(A,p,L)}):y(A,f,L);break}default:break}})}function k(A,x){if(R(x.remuxResult))return;var C=[],u=x.remuxResult,o=u.audio,l=u.video;o&&v(C,o),l&&v(C,l),A.postMessage({event:"transmuxComplete",data:x},C)}function v(A,x){x.data1&&A.push(x.data1.buffer),x.data2&&A.push(x.data2.buffer)}function y(A,x,C){x.forEach(function(u){k(A,u)}),A.postMessage({event:"flush",data:C})}function R(A){return!A.audio&&!A.video&&!A.text&&!A.id3&&!A.initSegment}},"./src/demux/transmuxer.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return l}),_.d(Z,"isPromise",function(){return f}),_.d(Z,"TransmuxConfig",function(){return p}),_.d(Z,"TransmuxState",function(){return D});var X=_("./src/events.ts"),O=_("./src/errors.ts"),I=_("./src/crypt/decrypter.ts"),W=_("./src/demux/aacdemuxer.ts"),F=_("./src/demux/mp4demuxer.ts"),M=_("./src/demux/tsdemuxer.ts"),k=_("./src/demux/mp3demuxer.ts"),v=_("./src/remux/mp4-remuxer.ts"),y=_("./src/remux/passthrough-remuxer.ts"),R=_("./src/demux/chunk-cache.ts"),A=_("./src/utils/mp4-tools.ts"),x=_("./src/utils/logger.ts"),C;try{C=self.performance.now.bind(self.performance)}catch(S){x.logger.debug("Unable to use Performance API on this environment"),C=self.Date.now}var u=[{demux:M.default,remux:v.default},{demux:F.default,remux:y.default},{demux:W.default,remux:v.default},{demux:k.default,remux:v.default}],o=1024;u.forEach(function(S){var g=S.demux;o=Math.max(o,g.minProbeByteLength)});var l=function(){function S(c,d,a,E,b){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 R.default,this.observer=c,this.typeSupported=d,this.config=a,this.vendor=E,this.id=b}var g=S.prototype;return g.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},g.push=function(d,a,E,b){var T=this,P=E.transmuxing;P.executeStart=C();var G=new Uint8Array(d),Y=this.cache,Q=this.config,z=this.currentTransmuxState,j=this.transmuxConfig;b&&(this.currentTransmuxState=b);var q=h(G,a);if(q&&q.method==="AES-128"){var ae=this.getDecrypter();if(Q.enableSoftwareAES){var ce=ae.softwareDecrypt(G,q.key.buffer,q.iv.buffer);if(!ce)return P.executeEnd=C(),L(E);G=new Uint8Array(ce)}else return this.decryptionPromise=ae.webCryptoDecrypt(G,q.key.buffer,q.iv.buffer).then(function(De){var Ne=T.push(De,null,E);return T.decryptionPromise=null,Ne}),this.decryptionPromise}var ve=b||z,ke=ve.contiguous,Ee=ve.discontinuity,Ce=ve.trackSwitch,Le=ve.accurateTimeOffset,we=ve.timeOffset,me=j.audioCodec,le=j.videoCodec,Oe=j.defaultInitPts,Ye=j.duration,Ve=j.initSegmentData;if((Ee||Ce)&&this.resetInitSegment(Ve,me,le,Ye),Ee&&this.resetInitialTimestamp(Oe),ke||this.resetContiguity(),this.needsProbing(G,Ee,Ce)){if(Y.dataLength){var $e=Y.flush();G=Object(A.appendUint8Array)($e,G)}this.configureTransmuxer(G,j)}var ze=this.transmux(G,q,we,Le,E),Se=this.currentTransmuxState;return Se.contiguous=!0,Se.discontinuity=!1,Se.trackSwitch=!1,P.executeEnd=C(),ze},g.flush=function(d){var a=this,E=d.transmuxing;E.executeStart=C();var b=this.decrypter,T=this.cache,P=this.currentTransmuxState,G=this.decryptionPromise;if(G)return G.then(function(){return a.flush(d)});var Y=[],Q=P.timeOffset;if(b){var z=b.flush();z&&Y.push(this.push(z,null,d))}var j=T.dataLength;T.reset();var q=this.demuxer,ae=this.remuxer;if(!q||!ae)return j>=o&&this.observer.emit(X.Events.ERROR,X.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),E.executeEnd=C(),[L(d)];var ce=q.flush(Q);return f(ce)?ce.then(function(ve){return a.flushRemux(Y,ve,d),Y}):(this.flushRemux(Y,ce,d),Y)},g.flushRemux=function(d,a,E){var b=a.audioTrack,T=a.avcTrack,P=a.id3Track,G=a.textTrack,Y=this.currentTransmuxState,Q=Y.accurateTimeOffset,z=Y.timeOffset;x.logger.log("[transmuxer.ts]: Flushed fragment "+E.sn+(E.part>-1?" p: "+E.part:"")+" of level "+E.level);var j=this.remuxer.remux(b,T,P,G,z,Q,!0,this.id);d.push({remuxResult:j,chunkMeta:E}),E.transmuxing.executeEnd=C()},g.resetInitialTimestamp=function(d){var a=this.demuxer,E=this.remuxer;if(!a||!E)return;a.resetTimeStamp(d),E.resetTimeStamp(d)},g.resetContiguity=function(){var d=this.demuxer,a=this.remuxer;if(!d||!a)return;d.resetContiguity(),a.resetNextTimestamp()},g.resetInitSegment=function(d,a,E,b){var T=this.demuxer,P=this.remuxer;if(!T||!P)return;T.resetInitSegment(a,E,b),P.resetInitSegment(d,a,E)},g.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},g.transmux=function(d,a,E,b,T){var P;return a&&a.method==="SAMPLE-AES"?P=this.transmuxSampleAes(d,a,E,b,T):P=this.transmuxUnencrypted(d,E,b,T),P},g.transmuxUnencrypted=function(d,a,E,b){var T=this.demuxer.demux(d,a,!1,!this.config.progressive),P=T.audioTrack,G=T.avcTrack,Y=T.id3Track,Q=T.textTrack,z=this.remuxer.remux(P,G,Y,Q,a,E,!1,this.id);return{remuxResult:z,chunkMeta:b}},g.transmuxSampleAes=function(d,a,E,b,T){var P=this;return this.demuxer.demuxSampleAes(d,a,E).then(function(G){var Y=P.remuxer.remux(G.audioTrack,G.avcTrack,G.id3Track,G.textTrack,E,b,!1,P.id);return{remuxResult:Y,chunkMeta:T}})},g.configureTransmuxer=function(d,a){for(var E=this.config,b=this.observer,T=this.typeSupported,P=this.vendor,G=a.audioCodec,Y=a.defaultInitPts,Q=a.duration,z=a.initSegmentData,j=a.videoCodec,q,ae=0,ce=u.length;ae<ce;ae++)if(u[ae].demux.probe(d)){q=u[ae];break}q||(x.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),q={demux:F.default,remux:y.default});var ve=this.demuxer,ke=this.remuxer,Ee=q.remux,Ce=q.demux;(!ke||!(ke instanceof Ee))&&(this.remuxer=new Ee(b,E,T,P)),(!ve||!(ve instanceof Ce))&&(this.demuxer=new Ce(b,E,T),this.probe=Ce.probe),this.resetInitSegment(z,G,j,Q),this.resetInitialTimestamp(Y)},g.needsProbing=function(d,a,E){return!this.demuxer||!this.remuxer||a||E},g.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new I.default(this.observer,this.config)),d},S}();function h(S,g){var c=null;return S.byteLength>0&&g!=null&&g.key!=null&&g.iv!==null&&g.method!=null&&(c=g),c}var L=function(g){return{remuxResult:{},chunkMeta:g}};function f(S){return"then"in S&&S.then instanceof Function}var p=function(g,c,d,a,E){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=g,this.videoCodec=c,this.initSegmentData=d,this.duration=a,this.defaultInitPts=E},D=function(g,c,d,a,E){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=g,this.contiguous=c,this.accurateTimeOffset=d,this.trackSwitch=a,this.timeOffset=E}},"./src/demux/tsdemuxer.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"discardEPB",function(){return L});var X=_("./src/demux/adts.ts"),O=_("./src/demux/mpegaudio.ts"),I=_("./src/demux/exp-golomb.ts"),W=_("./src/demux/id3.ts"),F=_("./src/demux/sample-aes.ts"),M=_("./src/events.ts"),k=_("./src/utils/mp4-tools.ts"),v=_("./src/utils/logger.ts"),y=_("./src/errors.ts"),R={video:1,audio:2,id3:3,text:4},A=function(){function f(D,S,g){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=D,this.config=S,this.typeSupported=g}f.probe=function(S){var g=f.syncOffset(S);return g<0?!1:(g&&v.logger.warn("MPEG2-TS detected but first sync word found @ offset "+g+", junk ahead ?"),!0)},f.syncOffset=function(S){for(var g=Math.min(1e3,S.length-3*188),c=0;c<g;){if(S[c]===71&&S[c+188]===71&&S[c+2*188]===71)return c;c++}return-1},f.createTrack=function(S,g){return{container:S==="video"||S==="audio"?"video/mp2t":void 0,type:S,id:R[S],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:S==="audio"?g:void 0}};var p=f.prototype;return p.resetInitSegment=function(S,g,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=f.createTrack("video",c),this._audioTrack=f.createTrack("audio",c),this._id3Track=f.createTrack("id3",c),this._txtTrack=f.createTrack("text",c),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=S,this.videoCodec=g,this._duration=c},p.resetTimeStamp=function(){},p.resetContiguity=function(){var S=this._audioTrack,g=this._avcTrack,c=this._id3Track;S&&(S.pesData=null),g&&(g.pesData=null),c&&(c.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},p.demux=function(S,g,c,d){c===void 0&&(c=!1),d===void 0&&(d=!1),c||(this.sampleAes=null);var a,E=this._avcTrack,b=this._audioTrack,T=this._id3Track,P=E.pid,G=E.pesData,Y=b.pid,Q=T.pid,z=b.pesData,j=T.pesData,q=!1,ae=this.pmtParsed,ce=this._pmtId,ve=S.length;if(this.remainderData&&(S=Object(k.appendUint8Array)(this.remainderData,S),ve=S.length,this.remainderData=null),ve<188&&!d)return this.remainderData=S,{audioTrack:b,avcTrack:E,id3Track:T,textTrack:this._txtTrack};var ke=Math.max(0,f.syncOffset(S));ve-=(ve+ke)%188,ve<S.byteLength&&!d&&(this.remainderData=new Uint8Array(S.buffer,ve,S.buffer.byteLength-ve));for(var Ee=ke;Ee<ve;Ee+=188)if(S[Ee]===71){var Ce=!!(S[Ee+1]&64),Le=((S[Ee+1]&31)<<8)+S[Ee+2],we=(S[Ee+3]&48)>>4,me=void 0;if(we>1){if(me=Ee+5+S[Ee+4],me===Ee+188)continue}else me=Ee+4;switch(Le){case P:Ce&&(G&&(a=o(G))&&this.parseAVCPES(a,!1),G={data:[],size:0}),G&&(G.data.push(S.subarray(me,Ee+188)),G.size+=Ee+188-me);break;case Y:Ce&&(z&&(a=o(z))&&(b.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),z={data:[],size:0}),z&&(z.data.push(S.subarray(me,Ee+188)),z.size+=Ee+188-me);break;case Q:Ce&&(j&&(a=o(j))&&this.parseID3PES(a),j={data:[],size:0}),j&&(j.data.push(S.subarray(me,Ee+188)),j.size+=Ee+188-me);break;case 0:Ce&&(me+=S[me]+1),ce=this._pmtId=C(S,me);break;case ce:{Ce&&(me+=S[me]+1);var le=u(S,me,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,c);P=le.avc,P>0&&(E.pid=P),Y=le.audio,Y>0&&(b.pid=Y,b.isAAC=le.isAAC),Q=le.id3,Q>0&&(T.pid=Q),q&&!ae&&(v.logger.log("reparse from beginning"),q=!1,Ee=ke-188),ae=this.pmtParsed=!0;break}case 17:case 8191:break;default:q=!0;break}}else this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});E.pesData=G,b.pesData=z,T.pesData=j;var Oe={audioTrack:b,avcTrack:E,id3Track:T,textTrack:this._txtTrack};return d&&this.extractRemainingSamples(Oe),Oe},p.flush=function(){var S=this.remainderData;this.remainderData=null;var g;return S?g=this.demux(S,-1,!1,!0):g={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(g),this.sampleAes?this.decrypt(g,this.sampleAes):g},p.extractRemainingSamples=function(S){var g=S.audioTrack,c=S.avcTrack,d=S.id3Track,a=c.pesData,E=g.pesData,b=d.pesData,T;a&&(T=o(a))?(this.parseAVCPES(T,!0),c.pesData=null):c.pesData=a,E&&(T=o(E))?(g.isAAC?this.parseAACPES(T):this.parseMPEGPES(T),g.pesData=null):(E!=null&&E.size&&v.logger.log("last AAC PES packet truncated,might overlap between fragments"),g.pesData=E),b&&(T=o(b))?(this.parseID3PES(T),d.pesData=null):d.pesData=b},p.demuxSampleAes=function(S,g,c){var d=this.demux(S,c,!0,!this.config.progressive),a=this.sampleAes=new F.default(this.observer,this.config,g);return this.decrypt(d,a)},p.decrypt=function(S,g){return new Promise(function(c){var d=S.audioTrack,a=S.avcTrack;d.samples&&d.isAAC?g.decryptAacSamples(d.samples,0,function(){a.samples?g.decryptAvcSamples(a.samples,0,0,function(){c(S)}):c(S)}):a.samples&&g.decryptAvcSamples(a.samples,0,0,function(){c(S)})})},p.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},p.parseAVCPES=function(S,g){var c=this,d=this._avcTrack,a=this.parseAVCNALu(S.data),E=!1,b=this.avcSample,T,P=!1;S.data=null,b&&a.length&&!d.audFound&&(l(b,d),b=this.avcSample=x(!1,S.pts,S.dts,"")),a.forEach(function(G){switch(G.type){case 1:{T=!0,b||(b=c.avcSample=x(!0,S.pts,S.dts,"")),E&&(b.debug+="NDR "),b.frame=!0;var Y=G.data;if(P&&Y.length>4){var Q=new I.default(Y).readSliceType();(Q===2||Q===4||Q===7||Q===9)&&(b.key=!0)}break}case 5:T=!0,b||(b=c.avcSample=x(!0,S.pts,S.dts,"")),E&&(b.debug+="IDR "),b.key=!0,b.frame=!0;break;case 6:{T=!0,E&&b&&(b.debug+="SEI ");var z=new I.default(L(G.data));z.readUByte();for(var j=0,q=0,ae=!1,ce=0;!ae&&z.bytesAvailable>1;){j=0;do ce=z.readUByte(),j+=ce;while(ce===255);q=0;do ce=z.readUByte(),q+=ce;while(ce===255);if(j===4&&z.bytesAvailable!==0){ae=!0;var ve=z.readUByte();if(ve===181){var ke=z.readUShort();if(ke===49){var Ee=z.readUInt();if(Ee===1195456820){var Ce=z.readUByte();if(Ce===3){for(var Le=z.readUByte(),we=z.readUByte(),me=31&Le,le=[Le,we],Oe=0;Oe<me;Oe++)le.push(z.readUByte()),le.push(z.readUByte()),le.push(z.readUByte());h(c._txtTrack.samples,{type:3,pts:S.pts,bytes:le})}}}}}else if(j===5&&z.bytesAvailable!==0){if(ae=!0,q>16){for(var Ye=[],Ve=0;Ve<16;Ve++)Ye.push(z.readUByte().toString(16)),(Ve===3||Ve===5||Ve===7||Ve===9)&&Ye.push("-");for(var $e=q-16,ze=new Uint8Array($e),Se=0;Se<$e;Se++)ze[Se]=z.readUByte();h(c._txtTrack.samples,{pts:S.pts,payloadType:j,uuid:Ye.join(""),userData:Object(W.utf8ArrayToStr)(ze),userDataBytes:ze})}}else if(q<z.bytesAvailable)for(var De=0;De<q;De++)z.readUByte()}break}case 7:if(T=!0,P=!0,E&&b&&(b.debug+="SPS "),!d.sps){var Ne=new I.default(G.data),Ge=Ne.readSPS();d.width=Ge.width,d.height=Ge.height,d.pixelRatio=Ge.pixelRatio,d.sps=[G.data],d.duration=c._duration;for(var je=G.data.subarray(1,4),Me="avc1.",Ie=0;Ie<3;Ie++){var lt=je[Ie].toString(16);lt.length<2&&(lt="0"+lt),Me+=lt}d.codec=Me}break;case 8:T=!0,E&&b&&(b.debug+="PPS "),d.pps||(d.pps=[G.data]);break;case 9:T=!1,d.audFound=!0,b&&l(b,d),b=c.avcSample=x(!1,S.pts,S.dts,E?"AUD ":"");break;case 12:T=!1;break;default:T=!1,b&&(b.debug+="unknown NAL "+G.type+" ");break}if(b&&T){var tt=b.units;tt.push(G)}}),g&&b&&(l(b,d),this.avcSample=null)},p.getLastNalUnit=function(){var S,g=this.avcSample,c;if(!g||g.units.length===0){var d=this._avcTrack.samples;g=d[d.length-1]}if((S=g)!==null&&S!==void 0&&S.units){var a=g.units;c=a[a.length-1]}return c},p.parseAVCNALu=function(S){var g=S.byteLength,c=this._avcTrack,d=c.naluState||0,a=d,E=[],b=0,T,P,G,Y=-1,Q=0;for(d===-1&&(Y=0,Q=S[0]&31,d=0,b=1);b<g;){if(T=S[b++],!d){d=T?0:1;continue}if(d===1){d=T?0:2;continue}if(!T)d=3;else if(T===1){if(Y>=0){var z={data:S.subarray(Y,b-d-1),type:Q};E.push(z)}else{var j=this.getLastNalUnit();if(j&&(a&&b<=4-a&&(j.state&&(j.data=j.data.subarray(0,j.data.byteLength-a))),P=b-d-1,P>0)){var q=new Uint8Array(j.data.byteLength+P);q.set(j.data,0),q.set(S.subarray(0,P),j.data.byteLength),j.data=q,j.state=0}}b<g?(G=S[b]&31,Y=b,Q=G,d=0):d=-1}else d=0}if(Y>=0&&d>=0){var ae={data:S.subarray(Y,g),type:Q,state:d};E.push(ae)}if(E.length===0){var ce=this.getLastNalUnit();if(ce){var ve=new Uint8Array(ce.data.byteLength+S.byteLength);ve.set(ce.data,0),ve.set(S,ce.data.byteLength),ce.data=ve}}return c.naluState=d,E},p.parseAACPES=function(S){var g=0,c=this._audioTrack,d=this.aacOverFlow,a=S.data;if(d){this.aacOverFlow=null;var E=d.sample.unit.byteLength,b=Math.min(d.missing,E),T=E-b;d.sample.unit.set(a.subarray(0,b),T),c.samples.push(d.sample),g=d.missing}var P,G;for(P=g,G=a.length;P<G-1&&!X.isHeader(a,P);P++);if(P!==g){var Y,Q;if(P<G-1?(Y="AAC PES did not start with ADTS header,offset:"+P,Q=!1):(Y="no ADTS header found in AAC PES",Q=!0),v.logger.warn("parsing error:"+Y),this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:Q,reason:Y}),Q)return}X.initTrackConfig(c,this.observer,a,P,this.audioCodec);var z;if(S.pts!==void 0)z=S.pts;else if(d){var j=X.getFrameDuration(c.samplerate);z=d.sample.pts+j}else{v.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var q=0;P<G;)if(X.isHeader(a,P)){if(P+5<G){var ae=X.appendFrame(c,a,P,z,q);if(ae)if(ae.missing)this.aacOverFlow=ae;else{P+=ae.length,q++;continue}}break}else P++},p.parseMPEGPES=function(S){var g=S.data,c=g.length,d=0,a=0,E=S.pts;if(E===void 0){v.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<c;)if(O.isHeader(g,a)){var b=O.appendFrame(this._audioTrack,g,a,E,d);if(b)a+=b.length,d++;else break}else a++},p.parseID3PES=function(S){if(S.pts===void 0){v.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(S)},f}();A.minProbeByteLength=188;function x(f,p,D,S){return{key:f,frame:!1,pts:p,dts:D,units:[],debug:S,length:0}}function C(f,p){return(f[p+10]&31)<<8|f[p+11]}function u(f,p,D,S){var g={audio:-1,avc:-1,id3:-1,isAAC:!0},c=(f[p+1]&15)<<8|f[p+2],d=p+3+c-4,a=(f[p+10]&15)<<8|f[p+11];for(p+=12+a;p<d;){var E=(f[p+1]&31)<<8|f[p+2];switch(f[p]){case 207:if(!S){v.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:g.audio===-1&&(g.audio=E);break;case 21:g.id3===-1&&(g.id3=E);break;case 219:if(!S){v.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:g.avc===-1&&(g.avc=E);break;case 3:case 4:D?g.audio===-1&&(g.audio=E,g.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}p+=((f[p+3]&15)<<8|f[p+4])+5}return g}function o(f){var p=0,D,S,g,c,d,a=f.data;if(!f||f.size===0)return null;for(;a[0].length<19&&a.length>1;){var E=new Uint8Array(a[0].length+a[1].length);E.set(a[0]),E.set(a[1],a[0].length),a[0]=E,a.splice(1,1)}D=a[0];var b=(D[0]<<16)+(D[1]<<8)+D[2];if(b===1){if(S=(D[4]<<8)+D[5],S&&S>f.size-6)return null;var T=D[7];T&192&&(c=(D[9]&14)*536870912+(D[10]&255)*4194304+(D[11]&254)*16384+(D[12]&255)*128+(D[13]&254)/2,T&64?(d=(D[14]&14)*536870912+(D[15]&255)*4194304+(D[16]&254)*16384+(D[17]&255)*128+(D[18]&254)/2,c-d>60*9e4&&(v.logger.warn(Math.round((c-d)/9e4)+"s delta between PTS and DTS, align them"),c=d)):d=c),g=D[8];var P=g+9;if(f.size<=P)return null;f.size-=P;for(var G=new Uint8Array(f.size),Y=0,Q=a.length;Y<Q;Y++){D=a[Y];var z=D.byteLength;if(P)if(P>z){P-=z;continue}else D=D.subarray(P),z-=P,P=0;G.set(D,p),p+=z}return S&&(S-=g+3),{data:G,pts:c,dts:d,len:S}}return null}function l(f,p){if(f.units.length&&f.frame){if(f.pts===void 0){var D=p.samples,S=D.length;if(S){var g=D[S-1];f.pts=g.pts,f.dts=g.dts}else{p.dropped++;return}}p.samples.push(f)}f.debug.length&&v.logger.log(f.pts+"/"+f.dts+":"+f.debug)}function h(f,p){var D=f.length;if(D>0){if(p.pts>=f[D-1].pts)f.push(p);else for(var S=D-1;S>=0;S--)if(p.pts<f[S].pts){f.splice(S,0,p);break}}else f.push(p)}function L(f){for(var p=f.byteLength,D=[],S=1;S<p-2;)f[S]===0&&f[S+1]===0&&f[S+2]===3?(D.push(S+2),S+=2):S++;if(D.length===0)return f;var g=p-D.length,c=new Uint8Array(g),d=0;for(S=0;S<g;d++,S++)d===D[0]&&(d++,D.shift()),c[S]=f[d];return c}Z.default=A},"./src/errors.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"ErrorTypes",function(){return X}),_.d(Z,"ErrorDetails",function(){return O});var X;(function(I){I.NETWORK_ERROR="networkError",I.MEDIA_ERROR="mediaError",I.KEY_SYSTEM_ERROR="keySystemError",I.MUX_ERROR="muxError",I.OTHER_ERROR="otherError"})(X||(X={}));var O;(function(I){I.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",I.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",I.KEY_SYSTEM_NO_SESSION="keySystemNoSession",I.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",I.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",I.MANIFEST_LOAD_ERROR="manifestLoadError",I.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",I.MANIFEST_PARSING_ERROR="manifestParsingError",I.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",I.LEVEL_EMPTY_ERROR="levelEmptyError",I.LEVEL_LOAD_ERROR="levelLoadError",I.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",I.LEVEL_SWITCH_ERROR="levelSwitchError",I.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",I.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",I.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",I.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",I.FRAG_LOAD_ERROR="fragLoadError",I.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",I.FRAG_DECRYPT_ERROR="fragDecryptError",I.FRAG_PARSING_ERROR="fragParsingError",I.REMUX_ALLOC_ERROR="remuxAllocError",I.KEY_LOAD_ERROR="keyLoadError",I.KEY_LOAD_TIMEOUT="keyLoadTimeOut",I.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",I.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",I.BUFFER_APPEND_ERROR="bufferAppendError",I.BUFFER_APPENDING_ERROR="bufferAppendingError",I.BUFFER_STALLED_ERROR="bufferStalledError",I.BUFFER_FULL_ERROR="bufferFullError",I.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",I.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",I.INTERNAL_EXCEPTION="internalException",I.INTERNAL_ABORTED="aborted",I.UNKNOWN="unknown"})(O||(O={}))},"./src/events.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"Events",function(){return X});var X;(function(O){O.MEDIA_ATTACHING="hlsMediaAttaching",O.MEDIA_ATTACHED="hlsMediaAttached",O.MEDIA_DETACHING="hlsMediaDetaching",O.MEDIA_DETACHED="hlsMediaDetached",O.BUFFER_RESET="hlsBufferReset",O.BUFFER_CODECS="hlsBufferCodecs",O.BUFFER_CREATED="hlsBufferCreated",O.BUFFER_APPENDING="hlsBufferAppending",O.BUFFER_APPENDED="hlsBufferAppended",O.BUFFER_EOS="hlsBufferEos",O.BUFFER_FLUSHING="hlsBufferFlushing",O.BUFFER_FLUSHED="hlsBufferFlushed",O.MANIFEST_LOADING="hlsManifestLoading",O.MANIFEST_LOADED="hlsManifestLoaded",O.MANIFEST_PARSED="hlsManifestParsed",O.LEVEL_SWITCHING="hlsLevelSwitching",O.LEVEL_SWITCHED="hlsLevelSwitched",O.LEVEL_LOADING="hlsLevelLoading",O.LEVEL_LOADED="hlsLevelLoaded",O.LEVEL_UPDATED="hlsLevelUpdated",O.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",O.LEVELS_UPDATED="hlsLevelsUpdated",O.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",O.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",O.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",O.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",O.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",O.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",O.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",O.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",O.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",O.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",O.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",O.CUES_PARSED="hlsCuesParsed",O.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",O.INIT_PTS_FOUND="hlsInitPtsFound",O.FRAG_LOADING="hlsFragLoading",O.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",O.FRAG_LOADED="hlsFragLoaded",O.FRAG_DECRYPTED="hlsFragDecrypted",O.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",O.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",O.FRAG_PARSING_METADATA="hlsFragParsingMetadata",O.FRAG_PARSED="hlsFragParsed",O.FRAG_BUFFERED="hlsFragBuffered",O.FRAG_CHANGED="hlsFragChanged",O.FPS_DROP="hlsFpsDrop",O.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",O.ERROR="hlsError",O.DESTROYING="hlsDestroying",O.KEY_LOADING="hlsKeyLoading",O.KEY_LOADED="hlsKeyLoaded",O.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",O.BACK_BUFFER_REACHED="hlsBackBufferReached"})(X||(X={}))},"./src/hls.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return f});var X=_("./node_modules/url-toolkit/src/url-toolkit.js"),O=_.n(X),I=_("./src/loader/playlist-loader.ts"),W=_("./src/loader/key-loader.ts"),F=_("./src/controller/id3-track-controller.ts"),M=_("./src/controller/latency-controller.ts"),k=_("./src/controller/level-controller.ts"),v=_("./src/controller/fragment-tracker.ts"),y=_("./src/controller/stream-controller.ts"),R=_("./src/is-supported.ts"),A=_("./src/utils/logger.ts"),x=_("./src/config.ts"),C=_("./node_modules/eventemitter3/index.js"),u=_.n(C),o=_("./src/events.ts"),l=_("./src/errors.ts");function h(p,D){for(var S=0;S<D.length;S++){var g=D[S];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(p,g.key,g)}}function L(p,D,S){return D&&h(p.prototype,D),S&&h(p,S),p}var f=function(){p.isSupported=function(){return Object(R.isSupported)()};function p(S){S===void 0&&(S={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new C.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 g=this.config=Object(x.mergeConfig)(p.DefaultConfig,S);this.userConfig=S,Object(A.enableLogs)(g.debug),this._autoLevelCapping=-1,g.progressive&&Object(x.enableStreamingMode)(g);var c=g.abrController,d=g.bufferController,a=g.capLevelController,E=g.fpsController,b=this.abrController=new c(this),T=this.bufferController=new d(this),P=this.capLevelController=new a(this),G=new E(this),Y=new I.default(this),Q=new W.default(this),z=new F.default(this),j=this.levelController=new k.default(this),q=new v.FragmentTracker(this),ae=this.streamController=new y.default(this,q);P.setStreamController(ae),G.setStreamController(ae);var ce=[j,ae];this.networkControllers=ce;var ve=[Y,Q,b,T,P,G,z,q];this.audioTrackController=this.createController(g.audioTrackController,null,ce),this.createController(g.audioStreamController,q,ce),this.subtitleTrackController=this.createController(g.subtitleTrackController,null,ce),this.createController(g.subtitleStreamController,q,ce),this.createController(g.timelineController,null,ve),this.emeController=this.createController(g.emeController,null,ve),this.cmcdController=this.createController(g.cmcdController,null,ve),this.latencyController=this.createController(M.default,null,ve),this.coreComponents=ve}var D=p.prototype;return D.createController=function(g,c,d){if(g){var a=c?new g(this,c):new g(this);return d&&d.push(a),a}return null},D.on=function(g,c,d){d===void 0&&(d=this),this._emitter.on(g,c,d)},D.once=function(g,c,d){d===void 0&&(d=this),this._emitter.once(g,c,d)},D.removeAllListeners=function(g){this._emitter.removeAllListeners(g)},D.off=function(g,c,d,a){d===void 0&&(d=this),this._emitter.off(g,c,d,a)},D.listeners=function(g){return this._emitter.listeners(g)},D.emit=function(g,c,d){return this._emitter.emit(g,c,d)},D.trigger=function(g,c){if(this.config.debug)return this.emit(g,g,c);try{return this.emit(g,g,c)}catch(d){A.logger.error("An internal error happened while handling event "+g+'. Error message: "'+d.message+'". Here is a stacktrace:',d),this.trigger(o.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:g,error:d})}return!1},D.listenerCount=function(g){return this._emitter.listenerCount(g)},D.destroy=function(){A.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(g){return g.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(g){return g.destroy()}),this.coreComponents.length=0},D.attachMedia=function(g){A.logger.log("attachMedia"),this._media=g,this.trigger(o.Events.MEDIA_ATTACHING,{media:g})},D.detachMedia=function(){A.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},D.loadSource=function(g){this.stopLoad();var c=this.media,d=this.url,a=this.url=X.buildAbsoluteURL(self.location.href,g,{alwaysNormalize:!0});A.logger.log("loadSource:"+a),c&&d&&d!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(o.Events.MANIFEST_LOADING,{url:g})},D.startLoad=function(g){g===void 0&&(g=-1),A.logger.log("startLoad("+g+")"),this.networkControllers.forEach(function(c){c.startLoad(g)})},D.stopLoad=function(){A.logger.log("stopLoad"),this.networkControllers.forEach(function(g){g.stopLoad()})},D.swapAudioCodec=function(){A.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},D.recoverMediaError=function(){A.logger.log("recoverMediaError");var g=this._media;this.detachMedia(),g&&this.attachMedia(g)},D.removeLevel=function(g,c){c===void 0&&(c=0),this.levelController.removeLevel(g,c)},L(p,[{key:"levels",get:function(){var g=this.levelController.levels;return g||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(g){A.logger.log("set currentLevel:"+g),this.loadLevel=g,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(g){A.logger.log("set nextLevel:"+g),this.levelController.manualLevel=g,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(g){A.logger.log("set loadLevel:"+g),this.levelController.manualLevel=g}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(g){this.levelController.nextLoadLevel=g}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(g){A.logger.log("set firstLevel:"+g),this.levelController.firstLevel=g}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(g){A.logger.log("set startLevel:"+g),g!==-1&&(g=Math.max(g,this.minAutoLevel)),this.levelController.startLevel=g}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(g){var c=!!g;c!==this.config.capLevelToPlayerSize&&(c?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=c)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(g){this._autoLevelCapping!==g&&(A.logger.log("set autoLevelCapping:"+g),this._autoLevelCapping=g)}},{key:"bandwidthEstimate",get:function(){var g=this.abrController.bwEstimator;return g?g.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var g=this.levels,c=this.config.minAutoBitrate;if(!g)return 0;for(var d=g.length,a=0;a<d;a++)if(g[a].maxBitrate>c)return a;return 0}},{key:"maxAutoLevel",get:function(){var g=this.levels,c=this.autoLevelCapping,d;return c===-1&&g&&g.length?d=g.length-1:d=c,d}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var c=this.audioTrackController;c&&(c.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var c=this.subtitleTrackController;c&&(c.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return g?g.subtitleDisplay:!1},set:function(g){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{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 o.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return p.defaultConfig?p.defaultConfig:x.hlsDefaultConfig},set:function(g){p.defaultConfig=g}}]),p}();f.defaultConfig=void 0},"./src/is-supported.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"isSupported",function(){return I}),_.d(Z,"changeTypeSupported",function(){return W});var X=_("./src/utils/mediasource-helper.ts");function O(){return self.SourceBuffer||self.WebKitSourceBuffer}function I(){var F=Object(X.getMediaSource)();if(!F)return!1;var M=O(),k=F&&typeof F.isTypeSupported=="function"&&F.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),v=!M||M.prototype&&typeof M.prototype.appendBuffer=="function"&&typeof M.prototype.remove=="function";return!!k&&!!v}function W(){var F,M=O();return typeof(M==null||((F=M.prototype)===null||F===void 0)?void 0:F.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return A}),_.d(Z,"LoadError",function(){return C});var X=_("./src/polyfills/number.ts"),O=_("./src/errors.ts");function I(u,o){u.prototype=Object.create(o.prototype),u.prototype.constructor=u,v(u,o)}function W(u){var o=typeof Map=="function"?new Map:void 0;return W=function(h){if(h===null||!k(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(h))return o.get(h);o.set(h,L)}function L(){return F(h,arguments,y(this).constructor)}return L.prototype=Object.create(h.prototype,{constructor:{value:L,enumerable:!1,writable:!0,configurable:!0}}),v(L,h)},W(u)}function F(u,o,l){return M()?F=Reflect.construct:F=function(L,f,p){var D=[null];D.push.apply(D,f);var S=Function.bind.apply(L,D),g=new S;return p&&v(g,p.prototype),g},F.apply(null,arguments)}function M(){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(u){return!1}}function k(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function v(u,o){return v=Object.setPrototypeOf||function(h,L){return h.__proto__=L,h},v(u,o)}function y(u){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},y(u)}var R=Math.pow(2,17),A=function(){function u(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var o=u.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(h,L){var f=this,p=h.url;if(!p)return Promise.reject(new C({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(p?"part list":"url")));this.abort();var D=this.config,S=D.fLoader,g=D.loader;return new Promise(function(c,d){f.loader&&f.loader.destroy();var a=f.loader=h.loader=S?new S(D):new g(D),E=x(h),b={timeout:D.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:D.fragLoadingMaxRetryTimeout,highWaterMark:R};h.stats=a.stats,a.load(E,b,{onSuccess:function(P,G,Y,Q){f.resetLoader(h,a),c({frag:h,part:null,payload:P.data,networkDetails:Q})},onError:function(P,G,Y){f.resetLoader(h,a),d(new C({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:P,networkDetails:Y}))},onAbort:function(P,G,Y){f.resetLoader(h,a),d(new C({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:Y}))},onTimeout:function(P,G,Y){f.resetLoader(h,a),d(new C({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:Y}))},onProgress:function(P,G,Y,Q){L&&L({frag:h,part:null,payload:Y,networkDetails:Q})}})})},o.loadPart=function(h,L,f){var p=this;this.abort();var D=this.config,S=D.fLoader,g=D.loader;return new Promise(function(c,d){p.loader&&p.loader.destroy();var a=p.loader=h.loader=S?new S(D):new g(D),E=x(h,L),b={timeout:D.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:D.fragLoadingMaxRetryTimeout,highWaterMark:R};L.stats=a.stats,a.load(E,b,{onSuccess:function(P,G,Y,Q){p.resetLoader(h,a),p.updateStatsFromPart(h,L);var z={frag:h,part:L,payload:P.data,networkDetails:Q};f(z),c(z)},onError:function(P,G,Y){p.resetLoader(h,a),d(new C({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:L,response:P,networkDetails:Y}))},onAbort:function(P,G,Y){h.stats.aborted=L.stats.aborted,p.resetLoader(h,a),d(new C({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:L,networkDetails:Y}))},onTimeout:function(P,G,Y){p.resetLoader(h,a),d(new C({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:L,networkDetails:Y}))}})})},o.updateStatsFromPart=function(h,L){var f=h.stats,p=L.stats,D=p.total;if(f.loaded+=p.loaded,D){var S=Math.round(h.duration/L.duration),g=Math.min(Math.round(f.loaded/D),S),c=S-g,d=c*Math.round(f.loaded/g);f.total=f.loaded+d}else f.total=Math.max(f.loaded,f.total);var a=f.loading,E=p.loading;a.start?a.first+=E.first-E.start:(a.start=E.start,a.first=E.first),a.end=E.end},o.resetLoader=function(h,L){h.loader=null,this.loader===L&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),L.destroy()},u}();function x(u,o){o===void 0&&(o=null);var l=o||u,h={frag:u,part:o,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},L=l.byteRangeStartOffset,f=l.byteRangeEndOffset;return Object(X.isFiniteNumber)(L)&&Object(X.isFiniteNumber)(f)&&(h.rangeStart=L,h.rangeEnd=f),h}var C=function(u){I(o,u);function o(l){for(var h,L=arguments.length,f=new Array(L>1?L-1:0),p=1;p<L;p++)f[p-1]=arguments[p];return h=u.call.apply(u,[this].concat(f))||this,h.data=void 0,h.data=l,h}return o}(W(Error))},"./src/loader/fragment.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"ElementaryStreamTypes",function(){return A}),_.d(Z,"BaseSegment",function(){return x}),_.d(Z,"Fragment",function(){return C}),_.d(Z,"Part",function(){return u});var X=_("./src/polyfills/number.ts"),O=_("./node_modules/url-toolkit/src/url-toolkit.js"),I=_.n(O),W=_("./src/utils/logger.ts"),F=_("./src/loader/level-key.ts"),M=_("./src/loader/load-stats.ts");function k(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,v(o,l)}function v(o,l){return v=Object.setPrototypeOf||function(L,f){return L.__proto__=f,L},v(o,l)}function y(o,l){for(var h=0;h<l.length;h++){var L=l[h];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(o,L.key,L)}}function R(o,l,h){return l&&y(o.prototype,l),h&&y(o,h),o}var A;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(A||(A={}));var x=function(){function o(h){var L;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(L={},L[A.AUDIO]=null,L[A.VIDEO]=null,L[A.AUDIOVIDEO]=null,L),this.baseurl=h}var l=o.prototype;return l.setByteRange=function(L,f){var p=L.split("@",2),D=[];p.length===1?D[0]=f?f.byteRangeEndOffset:0:D[0]=parseInt(p[1]),D[1]=parseInt(p[0])+D[0],this._byteRange=D},R(o,[{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(O.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(L){this._url=L}}]),o}(),C=function(o){k(l,o);function l(L,f){var p;return p=o.call(this,f)||this,p._decryptdata=null,p.rawProgramDateTime=null,p.programDateTime=null,p.tagList=[],p.duration=0,p.sn=0,p.levelkey=void 0,p.type=void 0,p.loader=null,p.level=-1,p.cc=0,p.startPTS=void 0,p.endPTS=void 0,p.appendedPTS=void 0,p.startDTS=void 0,p.endDTS=void 0,p.start=0,p.deltaPTS=void 0,p.maxStartPTS=void 0,p.minEndPTS=void 0,p.stats=new M.LoadStats,p.urlId=0,p.data=void 0,p.bitrateTest=!1,p.title=null,p.initSegment=null,p.type=L,p}var h=l.prototype;return h.createInitializationVector=function(f){for(var p=new Uint8Array(16),D=12;D<16;D++)p[D]=f>>8*(15-D)&255;return p},h.setDecryptDataFromLevelKey=function(f,p){var D=f;return(f==null?void 0:f.method)==="AES-128"&&f.uri&&!f.iv&&(D=F.LevelKey.fromURI(f.uri),D.method=f.method,D.iv=this.createInitializationVector(p),D.keyFormat="identity"),D},h.setElementaryStreamInfo=function(f,p,D,S,g,c){c===void 0&&(c=!1);var d=this.elementaryStreams,a=d[f];if(!a){d[f]={startPTS:p,endPTS:D,startDTS:S,endDTS:g,partial:c};return}a.startPTS=Math.min(a.startPTS,p),a.endPTS=Math.max(a.endPTS,D),a.startDTS=Math.min(a.startDTS,S),a.endDTS=Math.max(a.endDTS,g)},h.clearElementaryStreamInfo=function(){var f=this.elementaryStreams;f[A.AUDIO]=null,f[A.VIDEO]=null,f[A.AUDIOVIDEO]=null},R(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var f=this.sn;typeof f!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&W.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),f=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,f)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(X.isFiniteNumber)(this.programDateTime))return null;var f=Object(X.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+f*1e3}},{key:"encrypted",get:function(){var f;return!!((f=this.decryptdata)!==null&&f!==void 0&&f.keyFormat&&this.decryptdata.uri)}}]),l}(x),u=function(o){k(l,o);function l(h,L,f,p,D){var S;S=o.call(this,f)||this,S.fragOffset=0,S.duration=0,S.gap=!1,S.independent=!1,S.relurl=void 0,S.fragment=void 0,S.index=void 0,S.stats=new M.LoadStats,S.duration=h.decimalFloatingPoint("DURATION"),S.gap=h.bool("GAP"),S.independent=h.bool("INDEPENDENT"),S.relurl=h.enumeratedString("URI"),S.fragment=L,S.index=p;var g=h.enumeratedString("BYTERANGE");return g&&S.setByteRange(g,D),D&&(S.fragOffset=D.fragOffset+D.duration),S}return R(l,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var L=this.elementaryStreams;return!!(L.audio||L.video||L.audiovideo)}}]),l}(x)},"./src/loader/key-loader.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return W});var X=_("./src/events.ts"),O=_("./src/errors.ts"),I=_("./src/utils/logger.ts"),W=function(){function F(k){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=k,this._registerListeners()}var M=F.prototype;return M._registerListeners=function(){this.hls.on(X.Events.KEY_LOADING,this.onKeyLoading,this)},M._unregisterListeners=function(){this.hls.off(X.Events.KEY_LOADING,this.onKeyLoading)},M.destroy=function(){this._unregisterListeners();for(var v in this.loaders){var y=this.loaders[v];y&&y.destroy()}this.loaders={}},M.onKeyLoading=function(v,y){var R=y.frag,A=R.type,x=this.loaders[A];if(!R.decryptdata){I.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var C=R.decryptdata.uri;if(C!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(x&&(I.logger.warn("abort previous key loader for type:"+A),x.abort()),!C){I.logger.warn("key uri is falsy");return}var o=u.loader,l=R.loader=this.loaders[A]=new o(u);this.decrypturl=C,this.decryptkey=null;var h={url:C,frag:R,responseType:"arraybuffer"},L={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(h,L,f)}else this.decryptkey&&(R.decryptdata.key=this.decryptkey,this.hls.trigger(X.Events.KEY_LOADED,{frag:R}))},M.loadsuccess=function(v,y,R){var A=R.frag;if(!A.decryptdata){I.logger.error("after key load, decryptdata unset");return}this.decryptkey=A.decryptdata.key=new Uint8Array(v.data),A.loader=null,delete this.loaders[A.type],this.hls.trigger(X.Events.KEY_LOADED,{frag:A})},M.loaderror=function(v,y){var R=y.frag,A=R.loader;A&&A.abort(),delete this.loaders[R.type],this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:R,response:v})},M.loadtimeout=function(v,y){var R=y.frag,A=R.loader;A&&A.abort(),delete this.loaders[R.type],this.hls.trigger(X.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:R})},F}()},"./src/loader/level-details.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"LevelDetails",function(){return F});var X=_("./src/polyfills/number.ts");function O(M,k){for(var v=0;v<k.length;v++){var y=k[v];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(M,y.key,y)}}function I(M,k,v){return k&&O(M.prototype,k),v&&O(M,v),M}var W=10,F=function(){function M(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 k=M.prototype;return k.reloaded=function(y){if(!y){this.advanced=!0,this.updated=!0;return}var R=this.lastPartSn-y.lastPartSn,A=this.lastPartIndex-y.lastPartIndex;this.updated=this.endSN!==y.endSN||!!A||!!R,this.advanced=this.endSN>y.endSN||R>0||R===0&&A>0,this.updated||this.advanced?this.misses=Math.floor(y.misses*.6):this.misses=y.misses+1,this.availabilityDelay=y.availabilityDelay},I(M,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(X.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||W}},{key:"drift",get:function(){var y=this.driftEndTime-this.driftStartTime;if(y>0){var R=this.driftEnd-this.driftStart;return R*1e3/y}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var y;return(y=this.partList)!==null&&y!==void 0&&y.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var y;return(y=this.fragments)!==null&&y!==void 0&&y.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 y;return(y=this.partList)!==null&&y!==void 0&&y.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var y;return(y=this.partList)!==null&&y!==void 0&&y.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),M}()},"./src/loader/level-key.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"LevelKey",function(){return F});var X=_("./node_modules/url-toolkit/src/url-toolkit.js"),O=_.n(X);function I(M,k){for(var v=0;v<k.length;v++){var y=k[v];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(M,y.key,y)}}function W(M,k,v){return k&&I(M.prototype,k),v&&I(M,v),M}var F=function(){M.fromURL=function(v,y){return new M(v,y)},M.fromURI=function(v){return new M(v)};function M(k,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(X.buildAbsoluteURL)(k,v,{alwaysNormalize:!0}):this._uri=k}return W(M,[{key:"uri",get:function(){return this._uri}}]),M}()},"./src/loader/load-stats.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"LoadStats",function(){return X});var X=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(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return l});var X=_("./src/polyfills/number.ts"),O=_("./node_modules/url-toolkit/src/url-toolkit.js"),I=_.n(O),W=_("./src/loader/fragment.ts"),F=_("./src/loader/level-details.ts"),M=_("./src/loader/level-key.ts"),k=_("./src/utils/attr-list.ts"),v=_("./src/utils/logger.ts"),y=_("./src/utils/codecs.ts"),R=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,A=/#EXT-X-MEDIA:(.*)/g,x=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),C=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("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function o(D){var S,g;return u.test((S=(g=O.parseURL(D))===null||g===void 0?void 0:g.path)!=null?S:"")}var l=function(){function D(){}return D.findGroup=function(g,c){for(var d=0;d<g.length;d++){var a=g[d];if(a.id===c)return a}},D.convertAVC1ToAVCOTI=function(g){var c=g.split(".");if(c.length>2){var d=c.shift()+".";return d+=parseInt(c.shift()).toString(16),d+=("000"+parseInt(c.shift()).toString(16)).substr(-4),d}return g},D.resolve=function(g,c){return O.buildAbsoluteURL(c,g,{alwaysNormalize:!0})},D.parseMasterPlaylist=function(g,c){var d=[],a={},E=!1;R.lastIndex=0;for(var b;(b=R.exec(g))!=null;)if(b[1]){var T=new k.AttrList(b[1]),P={attrs:T,bitrate:T.decimalInteger("AVERAGE-BANDWIDTH")||T.decimalInteger("BANDWIDTH"),name:T.NAME,url:D.resolve(b[2],c)},G=T.decimalResolution("RESOLUTION");G&&(P.width=G.width,P.height=G.height),h((T.CODECS||"").split(/[ ,]+/).filter(function(Q){return Q}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=D.convertAVC1ToAVCOTI(P.videoCodec)),d.push(P)}else if(b[3]){var Y=new k.AttrList(b[3]);Y["DATA-ID"]&&(E=!0,a[Y["DATA-ID"]]=Y)}return{levels:d,sessionData:E?a:null}},D.parseMasterPlaylistMedia=function(g,c,d,a){a===void 0&&(a=[]);var E,b=[],T=0;for(A.lastIndex=0;(E=A.exec(g))!==null;){var P=new k.AttrList(E[1]);if(P.TYPE===d){var G={attrs:P,bitrate:0,id:T++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:d,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?D.resolve(P.URI,c):""};if(a.length){var Y=D.findGroup(a,G.groupId)||a[0];L(G,Y,"audioCodec"),L(G,Y,"textCodec")}b.push(G)}}return b},D.parseLevelPlaylist=function(g,c,d,a,E){var b=new F.LevelDetails(c),T=b.fragments,P=null,G=0,Y=0,Q=0,z=0,j=null,q=new W.Fragment(a,c),ae,ce,ve,ke=-1,Ee=!1;for(x.lastIndex=0,b.m3u8=g;(ae=x.exec(g))!==null;){Ee&&(Ee=!1,q=new W.Fragment(a,c),q.start=Q,q.sn=G,q.cc=z,q.level=d,P&&(q.initSegment=P,q.rawProgramDateTime=P.rawProgramDateTime));var Ce=ae[1];if(Ce){q.duration=parseFloat(Ce);var Le=(" "+ae[2]).slice(1);q.title=Le||null,q.tagList.push(Le?["INF",Ce,Le]:["INF",Ce])}else if(ae[3])Object(X.isFiniteNumber)(q.duration)&&(q.start=Q,ve&&(q.levelkey=ve),q.sn=G,q.level=d,q.cc=z,q.urlId=E,T.push(q),q.relurl=(" "+ae[3]).slice(1),p(q,j),j=q,Q+=q.duration,G++,Y=0,Ee=!0);else if(ae[4]){var we=(" "+ae[4]).slice(1);j?q.setByteRange(we,j):q.setByteRange(we)}else if(ae[5])q.rawProgramDateTime=(" "+ae[5]).slice(1),q.tagList.push(["PROGRAM-DATE-TIME",q.rawProgramDateTime]),ke===-1&&(ke=T.length);else{if(ae=ae[0].match(C),!ae){v.logger.warn("No matches on slow regex match for level playlist!");continue}for(ce=1;ce<ae.length&&!(typeof ae[ce]!="undefined");ce++);var me=(" "+ae[ce]).slice(1),le=(" "+ae[ce+1]).slice(1),Oe=ae[ce+2]?(" "+ae[ce+2]).slice(1):"";switch(me){case"PLAYLIST-TYPE":b.type=le.toUpperCase();break;case"MEDIA-SEQUENCE":G=b.startSN=parseInt(le);break;case"SKIP":{var Ye=new k.AttrList(le),Ve=Ye.decimalInteger("SKIPPED-SEGMENTS");if(Object(X.isFiniteNumber)(Ve)){b.skippedSegments=Ve;for(var $e=Ve;$e--;)T.unshift(null);G+=Ve}var ze=Ye.enumeratedString("RECENTLY-REMOVED-DATERANGES");ze&&(b.recentlyRemovedDateranges=ze.split(" "));break}case"TARGETDURATION":b.targetduration=parseFloat(le);break;case"VERSION":b.version=parseInt(le);break;case"EXTM3U":break;case"ENDLIST":b.live=!1;break;case"#":(le||Oe)&&q.tagList.push(Oe?[le,Oe]:[le]);break;case"DIS":z++;case"GAP":q.tagList.push([me]);break;case"BITRATE":q.tagList.push([me,le]);break;case"DISCONTINUITY-SEQ":z=parseInt(le);break;case"KEY":{var Se,De=new k.AttrList(le),Ne=De.enumeratedString("METHOD"),Ge=De.URI,je=De.hexadecimalInteger("IV"),Me=De.enumeratedString("KEYFORMATVERSIONS"),Ie=De.enumeratedString("KEYID"),lt=(Se=De.enumeratedString("KEYFORMAT"))!=null?Se:"identity",tt=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(tt.indexOf(lt)>-1){v.logger.warn("Keyformat "+lt+" is not supported from the manifest");continue}else if(lt!=="identity")continue;Ne&&(ve=M.LevelKey.fromURL(c,Ge),Ge&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Ne)>=0&&(ve.method=Ne,ve.keyFormat=lt,Ie&&(ve.keyID=Ie),Me&&(ve.keyFormatVersions=Me),ve.iv=je));break}case"START":{var qe=new k.AttrList(le),Xe=qe.decimalFloatingPoint("TIME-OFFSET");Object(X.isFiniteNumber)(Xe)&&(b.startTimeOffset=Xe);break}case"MAP":{var ht=new k.AttrList(le);q.relurl=ht.URI,ht.BYTERANGE&&q.setByteRange(ht.BYTERANGE),q.level=d,q.sn="initSegment",ve&&(q.levelkey=ve),q.initSegment=null,P=q,Ee=!0;break}case"SERVER-CONTROL":{var nt=new k.AttrList(le);b.canBlockReload=nt.bool("CAN-BLOCK-RELOAD"),b.canSkipUntil=nt.optionalFloat("CAN-SKIP-UNTIL",0),b.canSkipDateRanges=b.canSkipUntil>0&&nt.bool("CAN-SKIP-DATERANGES"),b.partHoldBack=nt.optionalFloat("PART-HOLD-BACK",0),b.holdBack=nt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Je=new k.AttrList(le);b.partTarget=Je.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Te=b.partList;Te||(Te=b.partList=[]);var ut=Y>0?Te[Te.length-1]:void 0,at=Y++,Ae=new W.Part(new k.AttrList(le),q,c,at,ut);Te.push(Ae),q.duration+=Ae.duration;break}case"PRELOAD-HINT":{var Ue=new k.AttrList(le);b.preloadHint=Ue;break}case"RENDITION-REPORT":{var pe=new k.AttrList(le);b.renditionReports=b.renditionReports||[],b.renditionReports.push(pe);break}default:v.logger.warn("line parsed but not handled: "+ae);break}}}j&&!j.relurl?(T.pop(),Q-=j.duration,b.partList&&(b.fragmentHint=j)):b.partList&&(p(q,j),q.cc=z,b.fragmentHint=q);var ue=T.length,fe=T[0],ee=T[ue-1];if(Q+=b.skippedSegments*b.targetduration,Q>0&&ue&&ee){b.averagetargetduration=Q/ue;var te=ee.sn;b.endSN=te!=="initSegment"?te:0,fe&&(b.startCC=fe.cc,fe.initSegment||b.fragments.every(function(ie){return ie.relurl&&o(ie.relurl)})&&(v.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),q=new W.Fragment(a,c),q.relurl=ee.relurl,q.level=d,q.sn="initSegment",fe.initSegment=q,b.needSidxRanges=!0))}else b.endSN=0,b.startCC=0;return b.fragmentHint&&(Q+=b.fragmentHint.duration),b.totalduration=Q,b.endCC=z,ke>0&&f(T,ke),b},D}();function h(D,S){["video","audio","text"].forEach(function(g){var c=D.filter(function(a){return Object(y.isCodecType)(a,g)});if(c.length){var d=c.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});S[g+"Codec"]=d.length>0?d[0]:c[0],D=D.filter(function(a){return c.indexOf(a)===-1})}}),S.unknownCodecs=D}function L(D,S,g){var c=S[g];c&&(D[g]=c)}function f(D,S){for(var g=D[S],c=S;c--;){var d=D[c];if(!d)return;d.programDateTime=g.programDateTime-d.duration*1e3,g=d}}function p(D,S){D.rawProgramDateTime?D.programDateTime=Date.parse(D.rawProgramDateTime):S!=null&&S.programDateTime&&(D.programDateTime=S.endProgramDateTime),Object(X.isFiniteNumber)(D.programDateTime)||(D.programDateTime=null,D.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/polyfills/number.ts"),O=_("./src/events.ts"),I=_("./src/errors.ts"),W=_("./src/utils/logger.ts"),F=_("./src/utils/mp4-tools.ts"),M=_("./src/loader/m3u8-parser.ts"),k=_("./src/types/loader.ts"),v=_("./src/utils/attr-list.ts");function y(x){var C=x.type;switch(C){case k.PlaylistContextType.AUDIO_TRACK:return k.PlaylistLevelType.AUDIO;case k.PlaylistContextType.SUBTITLE_TRACK:return k.PlaylistLevelType.SUBTITLE;default:return k.PlaylistLevelType.MAIN}}function R(x,C){var u=x.url;return(u===void 0||u.indexOf("data:")===0)&&(u=C.url),u}var A=function(){function x(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var C=x.prototype;return C.registerListeners=function(){var o=this.hls;o.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(O.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(O.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(O.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},C.unregisterListeners=function(){var o=this.hls;o.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(O.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(O.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(O.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},C.createInternalLoader=function(o){var l=this.hls.config,h=l.pLoader,L=l.loader,f=h||L,p=new f(l);return o.loader=p,this.loaders[o.type]=p,p},C.getInternalLoader=function(o){return this.loaders[o.type]},C.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},C.destroyInternalLoaders=function(){for(var o in this.loaders){var l=this.loaders[o];l&&l.destroy(),this.resetInternalLoader(o)}},C.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},C.onManifestLoading=function(o,l){var h=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:k.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},C.onLevelLoading=function(o,l){var h=l.id,L=l.level,f=l.url,p=l.deliveryDirectives;this.load({id:h,groupId:null,level:L,responseType:"text",type:k.PlaylistContextType.LEVEL,url:f,deliveryDirectives:p})},C.onAudioTrackLoading=function(o,l){var h=l.id,L=l.groupId,f=l.url,p=l.deliveryDirectives;this.load({id:h,groupId:L,level:null,responseType:"text",type:k.PlaylistContextType.AUDIO_TRACK,url:f,deliveryDirectives:p})},C.onSubtitleTrackLoading=function(o,l){var h=l.id,L=l.groupId,f=l.url,p=l.deliveryDirectives;this.load({id:h,groupId:L,level:null,responseType:"text",type:k.PlaylistContextType.SUBTITLE_TRACK,url:f,deliveryDirectives:p})},C.load=function(o){var l,h=this.hls.config,L=this.getInternalLoader(o);if(L){var f=L.context;if(f&&f.url===o.url){W.logger.trace("[playlist-loader]: playlist request ongoing");return}W.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),L.abort()}var p,D,S,g;switch(o.type){case k.PlaylistContextType.MANIFEST:p=h.manifestLoadingMaxRetry,D=h.manifestLoadingTimeOut,S=h.manifestLoadingRetryDelay,g=h.manifestLoadingMaxRetryTimeout;break;case k.PlaylistContextType.LEVEL:case k.PlaylistContextType.AUDIO_TRACK:case k.PlaylistContextType.SUBTITLE_TRACK:p=0,D=h.levelLoadingTimeOut;break;default:p=h.levelLoadingMaxRetry,D=h.levelLoadingTimeOut,S=h.levelLoadingRetryDelay,g=h.levelLoadingMaxRetryTimeout;break}if(L=this.createInternalLoader(o),(l=o.deliveryDirectives)!==null&&l!==void 0&&l.part){var c;if(o.type===k.PlaylistContextType.LEVEL&&o.level!==null?c=this.hls.levels[o.level].details:o.type===k.PlaylistContextType.AUDIO_TRACK&&o.id!==null?c=this.hls.audioTracks[o.id].details:o.type===k.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(c=this.hls.subtitleTracks[o.id].details),c){var d=c.partTarget,a=c.targetduration;d&&a&&(D=Math.min(Math.max(d*3,a*.8)*1e3,D))}}var E={timeout:D,maxRetry:p,retryDelay:S,maxRetryDelay:g,highWaterMark:0},b={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};L.load(o,E,b)},C.loadsuccess=function(o,l,h,L){if(L===void 0&&(L=null),h.isSidxRequest){this.handleSidxRequest(o,h),this.handlePlaylistLoaded(o,l,h,L);return}this.resetInternalLoader(h.type);var f=o.data;if(f.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,h,"no EXTM3U delimiter",L);return}l.parsing.start=performance.now(),f.indexOf("#EXTINF:")>0||f.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,l,h,L):this.handleMasterPlaylist(o,l,h,L)},C.loaderror=function(o,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!1,o)},C.loadtimeout=function(o,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!0)},C.handleMasterPlaylist=function(o,l,h,L){var f=this.hls,p=o.data,D=R(o,h),S=M.default.parseMasterPlaylist(p,D),g=S.levels,c=S.sessionData;if(!g.length){this.handleManifestParsingError(o,h,"no level found in manifest",L);return}var d=g.map(function(G){return{id:G.attrs.AUDIO,audioCodec:G.audioCodec}}),a=g.map(function(G){return{id:G.attrs.SUBTITLES,textCodec:G.textCodec}}),E=M.default.parseMasterPlaylistMedia(p,D,"AUDIO",d),b=M.default.parseMasterPlaylistMedia(p,D,"SUBTITLES",a),T=M.default.parseMasterPlaylistMedia(p,D,"CLOSED-CAPTIONS");if(E.length){var P=E.some(function(G){return!G.url});!P&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(W.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new v.AttrList({}),bitrate:0,url:""}))}f.trigger(O.Events.MANIFEST_LOADED,{levels:g,audioTracks:E,subtitles:b,captions:T,url:D,stats:l,networkDetails:L,sessionData:c})},C.handleTrackOrLevelPlaylist=function(o,l,h,L){var f=this.hls,p=h.id,D=h.level,S=h.type,g=R(o,h),c=Object(X.isFiniteNumber)(p)?p:0,d=Object(X.isFiniteNumber)(D)?D:c,a=y(h),E=M.default.parseLevelPlaylist(o.data,g,d,a,c);if(!E.fragments.length){f.trigger(O.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:g,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(S===k.PlaylistContextType.MANIFEST){var b={attrs:new v.AttrList({}),bitrate:0,details:E,name:"",url:g};f.trigger(O.Events.MANIFEST_LOADED,{levels:[b],audioTracks:[],url:g,stats:l,networkDetails:L,sessionData:null})}if(l.parsing.end=performance.now(),E.needSidxRanges){var T,P=(T=E.fragments[0].initSegment)===null||T===void 0?void 0:T.url;this.load({url:P,isSidxRequest:!0,type:S,level:D,levelDetails:E,id:p,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=E,this.handlePlaylistLoaded(o,l,h,L)},C.handleSidxRequest=function(o,l){var h=Object(F.parseSegmentIndex)(new Uint8Array(o.data));if(!h)return;var L=h.references,f=l.levelDetails;L.forEach(function(p,D){var S=p.info,g=f.fragments[D];g.byteRange.length===0&&g.setByteRange(String(1+S.end-S.start)+"@"+String(S.start)),g.initSegment&&g.initSegment.setByteRange(String(h.moovEndOffset)+"@0")})},C.handleManifestParsingError=function(o,l,h,L){this.hls.trigger(O.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===k.PlaylistContextType.MANIFEST,url:o.url,reason:h,response:o,context:l,networkDetails:L})},C.handleNetworkError=function(o,l,h,L){h===void 0&&(h=!1),W.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var f=I.ErrorDetails.UNKNOWN,p=!1,D=this.getInternalLoader(o);switch(o.type){case k.PlaylistContextType.MANIFEST:f=h?I.ErrorDetails.MANIFEST_LOAD_TIMEOUT:I.ErrorDetails.MANIFEST_LOAD_ERROR,p=!0;break;case k.PlaylistContextType.LEVEL:f=h?I.ErrorDetails.LEVEL_LOAD_TIMEOUT:I.ErrorDetails.LEVEL_LOAD_ERROR,p=!1;break;case k.PlaylistContextType.AUDIO_TRACK:f=h?I.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case k.PlaylistContextType.SUBTITLE_TRACK:f=h?I.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:I.ErrorDetails.SUBTITLE_LOAD_ERROR,p=!1;break}D&&this.resetInternalLoader(o.type);var S={type:I.ErrorTypes.NETWORK_ERROR,details:f,fatal:p,url:o.url,loader:D,context:o,networkDetails:l};L&&(S.response=L),this.hls.trigger(O.Events.ERROR,S)},C.handlePlaylistLoaded=function(o,l,h,L){var f=h.type,p=h.level,D=h.id,S=h.groupId,g=h.loader,c=h.levelDetails,d=h.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(o,h,"invalid target duration",L);return}if(!g)return;c.live&&(g.getCacheAge&&(c.ageHeader=g.getCacheAge()||0),(!g.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0));switch(f){case k.PlaylistContextType.MANIFEST:case k.PlaylistContextType.LEVEL:this.hls.trigger(O.Events.LEVEL_LOADED,{details:c,level:p||0,id:D||0,stats:l,networkDetails:L,deliveryDirectives:d});break;case k.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(O.Events.AUDIO_TRACK_LOADED,{details:c,id:D||0,groupId:S||"",stats:l,networkDetails:L,deliveryDirectives:d});break;case k.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(O.Events.SUBTITLE_TRACK_LOADED,{details:c,id:D||0,groupId:S||"",stats:l,networkDetails:L,deliveryDirectives:d});break}},x}();Z.default=A},"./src/polyfills/number.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"isFiniteNumber",function(){return X}),_.d(Z,"MAX_SAFE_INTEGER",function(){return O});var X=Number.isFinite||function(I){return typeof I=="number"&&isFinite(I)},O=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(oe,Z,_){"use strict";_.r(Z);var X=function(){function O(){}return O.getSilentFrame=function(W,F){switch(W){case"mp4a.40.2":if(F===1)return new Uint8Array([0,200,0,128,35,128]);if(F===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(F===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(F===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(F===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(F===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(F===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(F===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(F===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},O}();Z.default=X},"./src/remux/mp4-generator.ts":function(oe,Z,_){"use strict";_.r(Z);var X=Math.pow(2,32)-1,O=function(){function I(){}return I.init=function(){I.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var F;for(F in I.types)I.types.hasOwnProperty(F)&&(I.types[F]=[F.charCodeAt(0),F.charCodeAt(1),F.charCodeAt(2),F.charCodeAt(3)]);var M=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]),k=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]);I.HDLR_TYPES={video:M,audio:k};var v=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),y=new Uint8Array([0,0,0,0,0,0,0,0]);I.STTS=I.STSC=I.STCO=y,I.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),I.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),I.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),I.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var R=new Uint8Array([105,115,111,109]),A=new Uint8Array([97,118,99,49]),x=new Uint8Array([0,0,0,1]);I.FTYP=I.box(I.types.ftyp,R,x,R,A),I.DINF=I.box(I.types.dinf,I.box(I.types.dref,v))},I.box=function(F){for(var M=8,k=arguments.length,v=new Array(k>1?k-1:0),y=1;y<k;y++)v[y-1]=arguments[y];for(var R=v.length,A=R;R--;)M+=v[R].byteLength;var x=new Uint8Array(M);for(x[0]=M>>24&255,x[1]=M>>16&255,x[2]=M>>8&255,x[3]=M&255,x.set(F,4),R=0,M=8;R<A;R++)x.set(v[R],M),M+=v[R].byteLength;return x},I.hdlr=function(F){return I.box(I.types.hdlr,I.HDLR_TYPES[F])},I.mdat=function(F){return I.box(I.types.mdat,F)},I.mdhd=function(F,M){M*=F;var k=Math.floor(M/(X+1)),v=Math.floor(M%(X+1));return I.box(I.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,F>>24&255,F>>16&255,F>>8&255,F&255,k>>24,k>>16&255,k>>8&255,k&255,v>>24,v>>16&255,v>>8&255,v&255,85,196,0,0]))},I.mdia=function(F){return I.box(I.types.mdia,I.mdhd(F.timescale,F.duration),I.hdlr(F.type),I.minf(F))},I.mfhd=function(F){return I.box(I.types.mfhd,new Uint8Array([0,0,0,0,F>>24,F>>16&255,F>>8&255,F&255]))},I.minf=function(F){return F.type==="audio"?I.box(I.types.minf,I.box(I.types.smhd,I.SMHD),I.DINF,I.stbl(F)):I.box(I.types.minf,I.box(I.types.vmhd,I.VMHD),I.DINF,I.stbl(F))},I.moof=function(F,M,k){return I.box(I.types.moof,I.mfhd(F),I.traf(k,M))},I.moov=function(F){for(var M=F.length,k=[];M--;)k[M]=I.trak(F[M]);return I.box.apply(null,[I.types.moov,I.mvhd(F[0].timescale,F[0].duration)].concat(k).concat(I.mvex(F)))},I.mvex=function(F){for(var M=F.length,k=[];M--;)k[M]=I.trex(F[M]);return I.box.apply(null,[I.types.mvex].concat(k))},I.mvhd=function(F,M){M*=F;var k=Math.floor(M/(X+1)),v=Math.floor(M%(X+1)),y=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,F>>24&255,F>>16&255,F>>8&255,F&255,k>>24,k>>16&255,k>>8&255,k&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 I.box(I.types.mvhd,y)},I.sdtp=function(F){var M=F.samples||[],k=new Uint8Array(4+M.length),v,y;for(v=0;v<M.length;v++)y=M[v].flags,k[v+4]=y.dependsOn<<4|y.isDependedOn<<2|y.hasRedundancy;return I.box(I.types.sdtp,k)},I.stbl=function(F){return I.box(I.types.stbl,I.stsd(F),I.box(I.types.stts,I.STTS),I.box(I.types.stsc,I.STSC),I.box(I.types.stsz,I.STSZ),I.box(I.types.stco,I.STCO))},I.avc1=function(F){var M=[],k=[],v,y,R;for(v=0;v<F.sps.length;v++)y=F.sps[v],R=y.byteLength,M.push(R>>>8&255),M.push(R&255),M=M.concat(Array.prototype.slice.call(y));for(v=0;v<F.pps.length;v++)y=F.pps[v],R=y.byteLength,k.push(R>>>8&255),k.push(R&255),k=k.concat(Array.prototype.slice.call(y));var A=I.box(I.types.avcC,new Uint8Array([1,M[3],M[4],M[5],252|3,224|F.sps.length].concat(M).concat([F.pps.length]).concat(k))),x=F.width,C=F.height,u=F.pixelRatio[0],o=F.pixelRatio[1];return I.box(I.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,x>>8&255,x&255,C>>8&255,C&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]),A,I.box(I.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),I.box(I.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255])))},I.esds=function(F){var M=F.config.length;return new Uint8Array([0,0,0,0,3,23+M,0,1,0,4,15+M,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([M]).concat(F.config).concat([6,1,2]))},I.mp4a=function(F){var M=F.samplerate;return I.box(I.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,F.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]),I.box(I.types.esds,I.esds(F)))},I.mp3=function(F){var M=F.samplerate;return I.box(I.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,F.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]))},I.stsd=function(F){return F.type==="audio"?!F.isAAC&&F.codec==="mp3"?I.box(I.types.stsd,I.STSD,I.mp3(F)):I.box(I.types.stsd,I.STSD,I.mp4a(F)):I.box(I.types.stsd,I.STSD,I.avc1(F))},I.tkhd=function(F){var M=F.id,k=F.duration*F.timescale,v=F.width,y=F.height,R=Math.floor(k/(X+1)),A=Math.floor(k%(X+1));return I.box(I.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,M&255,0,0,0,0,R>>24,R>>16&255,R>>8&255,R&255,A>>24,A>>16&255,A>>8&255,A&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,y>>8&255,y&255,0,0]))},I.traf=function(F,M){var k=I.sdtp(F),v=F.id,y=Math.floor(M/(X+1)),R=Math.floor(M%(X+1));return I.box(I.types.traf,I.box(I.types.tfhd,new Uint8Array([0,0,0,0,v>>24,v>>16&255,v>>8&255,v&255])),I.box(I.types.tfdt,new Uint8Array([1,0,0,0,y>>24,y>>16&255,y>>8&255,y&255,R>>24,R>>16&255,R>>8&255,R&255])),I.trun(F,k.length+16+20+8+16+8+8),k)},I.trak=function(F){return F.duration=F.duration||4294967295,I.box(I.types.trak,I.tkhd(F),I.mdia(F))},I.trex=function(F){var M=F.id;return I.box(I.types.trex,new Uint8Array([0,0,0,0,M>>24,M>>16&255,M>>8&255,M&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},I.trun=function(F,M){var k=F.samples||[],v=k.length,y=12+16*v,R=new Uint8Array(y),A,x,C,u,o,l;for(M+=8+y,R.set([0,0,15,1,v>>>24&255,v>>>16&255,v>>>8&255,v&255,M>>>24&255,M>>>16&255,M>>>8&255,M&255],0),A=0;A<v;A++)x=k[A],C=x.duration,u=x.size,o=x.flags,l=x.cts,R.set([C>>>24&255,C>>>16&255,C>>>8&255,C&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*A);return I.box(I.types.trun,R)},I.initSegment=function(F){I.types||I.init();var M=I.moov(F),k=new Uint8Array(I.FTYP.byteLength+M.byteLength);return k.set(I.FTYP),k.set(M,I.FTYP.byteLength),k},I}();O.types=void 0,O.HDLR_TYPES=void 0,O.STTS=void 0,O.STSC=void 0,O.STCO=void 0,O.STSZ=void 0,O.VMHD=void 0,O.SMHD=void 0,O.STSD=void 0,O.FTYP=void 0,O.DINF=void 0,Z.default=O},"./src/remux/mp4-remuxer.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return l}),_.d(Z,"normalizePts",function(){return h});var X=_("./src/polyfills/number.ts"),O=_("./src/remux/aac-helper.ts"),I=_("./src/remux/mp4-generator.ts"),W=_("./src/events.ts"),F=_("./src/errors.ts"),M=_("./src/utils/logger.ts"),k=_("./src/types/loader.ts"),v=_("./src/utils/timescale-conversion.ts");function y(){return y=Object.assign||function(D){for(var S=1;S<arguments.length;S++){var g=arguments[S];for(var c in g)Object.prototype.hasOwnProperty.call(g,c)&&(D[c]=g[c])}return D},y.apply(this,arguments)}var R=10*1e3,A=1024,x=1152,C=null,u=null,o=!1,l=function(){function D(g,c,d,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=g,this.config=c,this.typeSupported=d,this.ISGenerated=!1,C===null){var E=navigator.userAgent||"",b=E.match(/Chrome\/(\d+)/i);C=b?parseInt(b[1]):0}if(u===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);u=T?parseInt(T[1]):0}o=!!C&&C<75||!!u&&u<600}var S=D.prototype;return S.destroy=function(){},S.resetTimeStamp=function(c){M.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=c},S.resetNextTimestamp=function(){M.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},S.resetInitSegment=function(){M.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},S.getVideoStartPts=function(c){var d=!1,a=c.reduce(function(E,b){var T=b.pts-E;return T<-4294967296?(d=!0,h(E,b.pts)):T>0?E:b.pts},c[0].pts);return d&&M.logger.debug("PTS rollover detected"),a},S.remux=function(c,d,a,E,b,T,P,G){var Y,Q,z,j,q,ae,ce=b,ve=b,ke=c.pid>-1,Ee=d.pid>-1,Ce=d.samples.length,Le=c.samples.length>0,we=Ce>1,me=(!ke||Le)&&(!Ee||we)||this.ISGenerated||P;if(me){this.ISGenerated||(z=this.generateIS(c,d,b));var le=this.isVideoContiguous,Oe=-1;if(we&&(Oe=L(d.samples),!le&&this.config.forceKeyFrameOnDiscontinuity))if(ae=!0,Oe>0){M.logger.warn("[mp4-remuxer]: Dropped "+Oe+" out of "+Ce+" video samples due to a missing keyframe");var Ye=this.getVideoStartPts(d.samples);d.samples=d.samples.slice(Oe),d.dropped+=Oe,ve+=(d.samples[0].pts-Ye)/(d.timescale||9e4)}else Oe===-1&&(M.logger.warn("[mp4-remuxer]: No keyframe found out of "+Ce+" video samples"),ae=!1);if(this.ISGenerated){if(Le&&we){var Ve=this.getVideoStartPts(d.samples),$e=h(c.samples[0].pts,Ve)-Ve,ze=$e/d.inputTimeScale;ce+=Math.max(0,ze),ve+=Math.max(0,-ze)}if(Le){if(c.samplerate||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(c,d,b)),Q=this.remuxAudio(c,ce,this.isAudioContiguous,T,Ee||we||G===k.PlaylistLevelType.AUDIO?ve:void 0),we){var Se=Q?Q.endPTS-Q.startPTS:0;d.inputTimeScale||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(c,d,b)),Y=this.remuxVideo(d,ve,le,Se)}}else we&&(Y=this.remuxVideo(d,ve,le,0));Y&&(Y.firstKeyFrame=Oe,Y.independent=Oe!==-1)}}return this.ISGenerated&&(a.samples.length&&(q=this.remuxID3(a,b)),E.samples.length&&(j=this.remuxText(E,b))),{audio:Q,video:Y,initSegment:z,independent:ae,text:j,id3:q}},S.generateIS=function(c,d,a){var E=c.samples,b=d.samples,T=this.typeSupported,P={},G=!Object(X.isFiniteNumber)(this._initPTS),Y="audio/mp4",Q,z,j;if(G&&(Q=z=Infinity),c.config&&E.length&&(c.timescale=c.samplerate,c.isAAC||(T.mpeg?(Y="audio/mpeg",c.codec=""):T.mp3&&(c.codec="mp3")),P.audio={id:"audio",container:Y,codec:c.codec,initSegment:!c.isAAC&&T.mpeg?new Uint8Array(0):I.default.initSegment([c]),metadata:{channelCount:c.channelCount}},G&&(j=c.inputTimeScale,Q=z=E[0].pts-Math.round(j*a))),d.sps&&d.pps&&b.length&&(d.timescale=d.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:d.codec,initSegment:I.default.initSegment([d]),metadata:{width:d.width,height:d.height}},G)){j=d.inputTimeScale;var q=this.getVideoStartPts(b),ae=Math.round(j*a);z=Math.min(z,h(b[0].dts,q)-ae),Q=Math.min(Q,q-ae)}if(Object.keys(P).length)return this.ISGenerated=!0,G&&(this._initPTS=Q,this._initDTS=z),{tracks:P,initPTS:Q,timescale:j}},S.remuxVideo=function(c,d,a,E){var b=c.inputTimeScale,T=c.samples,P=[],G=T.length,Y=this._initPTS,Q=this.nextAvcDts,z=8,j,q,ae,ce=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,ke=0,Ee=!1;if(!a||Q===null){var Ce=d*b,Le=T[0].pts-h(T[0].dts,T[0].pts);Q=Ce-Le}for(var we=0;we<G;we++){var me=T[we];if(me.pts=h(me.pts-Y,Q),me.dts=h(me.dts-Y,Q),me.dts>me.pts){var le=9e4*.2;ke=Math.max(Math.min(ke,me.pts-me.dts),-1*le)}me.dts<T[we>0?we-1:we].dts&&(Ee=!0)}Ee&&T.sort(function(mt,vt){var Qe=mt.dts-vt.dts,jt=mt.pts-vt.pts;return Qe||jt}),q=T[0].dts,ae=T[T.length-1].dts;var Oe=Math.round((ae-q)/(G-1));if(ke<0){if(ke<Oe*-2){M.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(v.toMsFromMpegTsClock)(-Oe,!0)+" ms");for(var Ye=ke,Ve=0;Ve<G;Ve++)T[Ve].dts=Ye=Math.max(Ye,T[Ve].pts-Oe),T[Ve].pts=Math.max(Ye,T[Ve].pts)}else{M.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(v.toMsFromMpegTsClock)(ke,!0)+" ms to overcome this issue");for(var $e=0;$e<G;$e++)T[$e].dts=T[$e].dts+ke}q=T[0].dts}if(a){var ze=q-Q,Se=ze>Oe,De=ze<-1;if(Se||De){Se?M.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(ze,!0)+" ms ("+ze+"dts) hole between fragments detected, filling it"):M.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(-ze,!0)+" ms ("+ze+"dts) overlapping between fragments detected"),q=Q;var Ne=T[0].pts-ze;T[0].dts=q,T[0].pts=Ne,M.logger.log("Video: First PTS/DTS adjusted: "+Object(v.toMsFromMpegTsClock)(Ne,!0)+"/"+Object(v.toMsFromMpegTsClock)(q,!0)+", delta: "+Object(v.toMsFromMpegTsClock)(ze,!0)+" ms")}}o&&(q=Math.max(0,q));for(var Ge=0,je=0,Me=0;Me<G;Me++){for(var Ie=T[Me],lt=Ie.units,tt=lt.length,qe=0,Xe=0;Xe<tt;Xe++)qe+=lt[Xe].data.length;je+=qe,Ge+=tt,Ie.length=qe,Ie.dts=Math.max(Ie.dts,q),Ie.pts=Math.max(Ie.pts,Ie.dts,0),ce=Math.min(Ie.pts,ce),ve=Math.max(Ie.pts,ve)}ae=T[G-1].dts;var ht=je+4*Ge+8,nt;try{nt=new Uint8Array(ht)}catch(mt){this.observer.emit(W.Events.ERROR,W.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ht,reason:"fail allocating video mdat "+ht});return}var Je=new DataView(nt.buffer);Je.setUint32(0,ht),nt.set(I.default.types.mdat,4);for(var Te=0;Te<G;Te++){for(var ut=T[Te],at=ut.units,Ae=0,Ue=0,pe=at.length;Ue<pe;Ue++){var ue=at[Ue],fe=ue.data,ee=ue.data.byteLength;Je.setUint32(z,ee),z+=4,nt.set(fe,z),z+=ee,Ae+=4+ee}if(Te<G-1)j=T[Te+1].dts-ut.dts;else{var te=this.config,ie=ut.dts-T[Te>0?Te-1:Te].dts;if(te.stretchShortVideoTrack&&this.nextAudioPts!==null){var ne=Math.floor(te.maxBufferHole*b),be=(E?ce+E*b:this.nextAudioPts)-ut.pts;be>ne?(j=be-ie,j<0&&(j=ie),M.logger.log("[mp4-remuxer]: It is approximately "+be/90+" ms to the next segment; using duration "+j/90+" ms for the last video frame.")):j=ie}else j=ie}var ge=Math.round(ut.pts-ut.dts);P.push(new f(ut.key,j,Ae,ge))}if(P.length&&C&&C<70){var Re=P[0].flags;Re.dependsOn=2,Re.isNonSync=0}console.assert(j!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=Q=ae+j,this.isVideoContiguous=!0;var He=I.default.moof(c.sequenceNumber++,q,y({},c,{samples:P})),st="video",Ze={data1:He,data2:nt,startPTS:ce/b,endPTS:(ve+j)/b,startDTS:q/b,endDTS:Q/b,type:st,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:c.dropped};return c.samples=[],c.dropped=0,console.assert(nt.length,"MDAT length must not be zero"),Ze},S.remuxAudio=function(c,d,a,E,b){var T=c.inputTimeScale,P=c.samplerate?c.samplerate:T,G=T/P,Y=c.isAAC?A:x,Q=Y*G,z=this._initPTS,j=!c.isAAC&&this.typeSupported.mpeg,q=[],ae=c.samples,ce=j?0:8,ve=this.nextAudioPts||-1,ke=d*T;if(this.isAudioContiguous=a=a||ae.length&&ve>0&&(E&&Math.abs(ke-ve)<9e3||Math.abs(h(ae[0].pts-z,ke)-ve)<20*Q),ae.forEach(function(fe){fe.pts=h(fe.pts-z,ke)}),!a||ve<0){if(ae=ae.filter(function(fe){return fe.pts>=0}),!ae.length)return;b===0?ve=0:E?ve=Math.max(0,ke):ve=ae[0].pts}if(c.isAAC)for(var Ee=b!==void 0,Ce=this.config.maxAudioFramesDrift,Le=0,we=ve;Le<ae.length;Le++){var me=ae[Le],le=me.pts,Oe=le-we,Ye=Math.abs(1e3*Oe/T);if(Oe<=-Ce*Q&&Ee)Le===0&&(M.logger.warn("Audio frame @ "+(le/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Oe/T)+" ms."),this.nextAudioPts=ve=we=le);else if(Oe>=Ce*Q&&Ye<R&&Ee){var Ve=Math.round(Oe/Q);we=le-Ve*Q,we<0&&(Ve--,we+=Q),Le===0&&(this.nextAudioPts=ve=we),M.logger.warn("[mp4-remuxer]: Injecting "+Ve+" audio frame @ "+(we/T).toFixed(3)+"s due to "+Math.round(1e3*Oe/T)+" ms gap.");for(var $e=0;$e<Ve;$e++){var ze=Math.max(we,0),Se=O.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);Se||(M.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Se=me.unit.subarray()),ae.splice(Le,0,{unit:Se,pts:ze}),we+=Q,Le++}}me.pts=we,we+=Q}for(var De=null,Ne=null,Ge,je=0,Me=ae.length;Me--;)je+=ae[Me].unit.byteLength;for(var Ie=0,lt=ae.length;Ie<lt;Ie++){var tt=ae[Ie],qe=tt.unit,Xe=tt.pts;if(Ne!==null){var ht=q[Ie-1];ht.duration=Math.round((Xe-Ne)/G)}else if(a&&c.isAAC&&(Xe=ve),De=Xe,je>0){je+=ce;try{Ge=new Uint8Array(je)}catch(fe){this.observer.emit(W.Events.ERROR,W.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:je,reason:"fail allocating audio mdat "+je});return}if(!j){var nt=new DataView(Ge.buffer);nt.setUint32(0,je),Ge.set(I.default.types.mdat,4)}}else return;Ge.set(qe,ce);var Je=qe.byteLength;ce+=Je,q.push(new f(!0,Y,Je,0)),Ne=Xe}var Te=q.length;if(!Te)return;var ut=q[q.length-1];this.nextAudioPts=ve=Ne+G*ut.duration;var at=j?new Uint8Array(0):I.default.moof(c.sequenceNumber++,De/G,y({},c,{samples:q}));c.samples=[];var Ae=De/T,Ue=ve/T,pe="audio",ue={data1:at,data2:Ge,startPTS:Ae,endPTS:Ue,startDTS:Ae,endDTS:Ue,type:pe,hasAudio:!0,hasVideo:!1,nb:Te};return this.isAudioContiguous=!0,console.assert(Ge.length,"MDAT length must not be zero"),ue},S.remuxEmptyAudio=function(c,d,a,E){var b=c.inputTimeScale,T=c.samplerate?c.samplerate:b,P=b/T,G=this.nextAudioPts,Y=(G!==null?G:E.startDTS*b)+this._initDTS,Q=E.endDTS*b+this._initDTS,z=P*A,j=Math.ceil((Q-Y)/z),q=O.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);if(M.logger.warn("[mp4-remuxer]: remux empty Audio"),!q){M.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ae=[],ce=0;ce<j;ce++){var ve=Y+ce*z;ae.push({unit:q,pts:ve,dts:ve})}return c.samples=ae,this.remuxAudio(c,d,a,!1)},S.remuxID3=function(c,d){var a=c.samples.length;if(!a)return;for(var E=c.inputTimeScale,b=this._initPTS,T=this._initDTS,P=0;P<a;P++){var G=c.samples[P];G.pts=h(G.pts-b,d*E)/E,G.dts=h(G.dts-T,d*E)/E}var Y=c.samples;return c.samples=[],{samples:Y}},S.remuxText=function(c,d){var a=c.samples.length;if(!a)return;for(var E=c.inputTimeScale,b=this._initPTS,T=0;T<a;T++){var P=c.samples[T];P.pts=h(P.pts-b,d*E)/E}c.samples.sort(function(Y,Q){return Y.pts-Q.pts});var G=c.samples;return c.samples=[],{samples:G}},D}();function h(D,S){var g;if(S===null)return D;for(S<D?g=-8589934592:g=8589934592;Math.abs(D-S)>4294967296;)D+=g;return D}function L(D){for(var S=0;S<D.length;S++)if(D[S].key)return S;return-1}var f=function(S,g,c,d){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=g,this.size=c,this.cts=d,this.flags=new p(S)},p=function(S){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=S?2:1,this.isNonSync=S?0:1}},"./src/remux/passthrough-remuxer.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/polyfills/number.ts"),O=_("./src/utils/mp4-tools.ts"),I=_("./src/loader/fragment.ts"),W=_("./src/utils/logger.ts"),F=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 y=v.prototype;return y.destroy=function(){},y.resetTimeStamp=function(A){this.initPTS=A,this.lastEndDTS=null},y.resetNextTimestamp=function(){this.lastEndDTS=null},y.resetInitSegment=function(A,x,C){this.audioCodec=x,this.videoCodec=C,this.generateInitSegment(A),this.emitInitSegment=!0},y.generateInitSegment=function(A){var x=this.audioCodec,C=this.videoCodec;if(!A||!A.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(O.parseInitSegment)(A);x||(x=k(u.audio,I.ElementaryStreamTypes.AUDIO)),C||(C=k(u.video,I.ElementaryStreamTypes.VIDEO));var o={};u.audio&&u.video?o.audiovideo={container:"video/mp4",codec:x+","+C,initSegment:A,id:"main"}:u.audio?o.audio={container:"audio/mp4",codec:x,initSegment:A,id:"audio"}:u.video?o.video={container:"video/mp4",codec:C,initSegment:A,id:"main"}:W.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},y.remux=function(A,x,C,u,o){var l=this.initPTS,h=this.lastEndDTS,L={audio:void 0,video:void 0,text:u,id3:C,initSegment:void 0};Object(X.isFiniteNumber)(h)||(h=this.lastEndDTS=o||0);var f=x.samples;if(!f||!f.length)return L;var p={initPTS:void 0,timescale:1},D=this.initData;if((!D||!D.length)&&(this.generateInitSegment(f),D=this.initData),!D||!D.length)return W.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),L;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1),Object(X.isFiniteNumber)(l)||(this.initPTS=p.initPTS=l=M(D,f,h));var S=Object(O.getDuration)(f,D),g=h,c=S+g;Object(O.offsetStartDTS)(D,f,l),S>0?this.lastEndDTS=c:(W.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!D.audio,a=!!D.video,E="";d&&(E+="audio"),a&&(E+="video");var b={data1:f,startPTS:g,startDTS:g,endPTS:c,endDTS:c,type:E,hasAudio:d,hasVideo:a,nb:1,dropped:0};return L.audio=b.type==="audio"?b:void 0,L.video=b.type!=="audio"?b:void 0,L.text=u,L.id3=C,L.initSegment=p,L},v}(),M=function(y,R,A){return Object(O.getStartDTS)(y,R)-A};function k(v,y){var R=v==null?void 0:v.codec;return R&&R.length>4?R:R==="hvc1"?"hvc1.1.c.L120.90":R==="av01"?"av01.0.04M.08":R==="avc1"||y===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}Z.default=F},"./src/task-loop.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return X});var X=function(){function O(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var I=O.prototype;return I.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},I.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},I.onHandlerDestroyed=function(){},I.hasInterval=function(){return!!this._tickInterval},I.hasNextTick=function(){return!!this._tickTimer},I.setInterval=function(F){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,F),!0)},I.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},I.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},I.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},I.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},I.doTick=function(){},O}()},"./src/types/cmcd.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"CMCDVersion",function(){return X}),_.d(Z,"CMCDObjectType",function(){return O}),_.d(Z,"CMCDStreamingFormat",function(){return I}),_.d(Z,"CMCDStreamType",function(){return W});var X=1,O;(function(F){F.MANIFEST="m",F.AUDIO="a",F.VIDEO="v",F.MUXED="av",F.INIT="i",F.CAPTION="c",F.TIMED_TEXT="tt",F.KEY="k",F.OTHER="o"})(O||(O={}));var I;(function(F){F.DASH="d",F.HLS="h",F.SMOOTH="s",F.OTHER="o"})(I||(I={}));var W;(function(F){F.VOD="v",F.LIVE="l"})(W||(W={}))},"./src/types/level.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"HlsSkip",function(){return I}),_.d(Z,"getSkipValue",function(){return W}),_.d(Z,"HlsUrlParameters",function(){return F}),_.d(Z,"Level",function(){return M});function X(k,v){for(var y=0;y<v.length;y++){var R=v[y];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(k,R.key,R)}}function O(k,v,y){return v&&X(k.prototype,v),y&&X(k,y),k}var I;(function(k){k.No="",k.Yes="YES",k.v2="v2"})(I||(I={}));function W(k,v){var y=k.canSkipUntil,R=k.canSkipDateRanges,A=k.endSN,x=v!==void 0?v-A:0;return y&&x<y?R?I.v2:I.Yes:I.No}var F=function(){function k(y,R,A){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=y,this.part=R,this.skip=A}var v=k.prototype;return v.addDirectives=function(R){var A=new self.URL(R);return this.msn!==void 0&&A.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&A.searchParams.set("_HLS_part",this.part.toString()),this.skip&&A.searchParams.set("_HLS_skip",this.skip),A.toString()},k}(),M=function(){function k(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(y){return y}).join(",").replace(/\.[^.,]+/g,"")}return O(k,[{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(y){var R=y%this.url.length;this._urlId!==R&&(this.details=void 0,this._urlId=R)}}]),k}()},"./src/types/loader.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"PlaylistContextType",function(){return X}),_.d(Z,"PlaylistLevelType",function(){return O});var X;(function(I){I.MANIFEST="manifest",I.LEVEL="level",I.AUDIO_TRACK="audioTrack",I.SUBTITLE_TRACK="subtitleTrack"})(X||(X={}));var O;(function(I){I.MAIN="main",I.AUDIO="audio",I.SUBTITLE="subtitle"})(O||(O={}))},"./src/types/transmuxer.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"ChunkMetadata",function(){return X});var X=function(W,F,M,k,v,y){k===void 0&&(k=0),v===void 0&&(v=-1),y===void 0&&(y=!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=O(),this.buffering={audio:O(),video:O(),audiovideo:O()},this.level=W,this.sn=F,this.id=M,this.size=k,this.part=v,this.partial=y};function O(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"AttrList",function(){return I});var X=/^(\d+)x(\d+)$/,O=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,I=function(){function W(M){typeof M=="string"&&(M=W.parseAttrList(M));for(var k in M)M.hasOwnProperty(k)&&(this[k]=M[k])}var F=W.prototype;return F.decimalInteger=function(k){var v=parseInt(this[k],10);return v>Number.MAX_SAFE_INTEGER?Infinity:v},F.hexadecimalInteger=function(k){if(this[k]){var v=(this[k]||"0x").slice(2);v=(v.length&1?"0":"")+v;for(var y=new Uint8Array(v.length/2),R=0;R<v.length/2;R++)y[R]=parseInt(v.slice(R*2,R*2+2),16);return y}else return null},F.hexadecimalIntegerAsNumber=function(k){var v=parseInt(this[k],16);return v>Number.MAX_SAFE_INTEGER?Infinity:v},F.decimalFloatingPoint=function(k){return parseFloat(this[k])},F.optionalFloat=function(k,v){var y=this[k];return y?parseFloat(y):v},F.enumeratedString=function(k){return this[k]},F.bool=function(k){return this[k]==="YES"},F.decimalResolution=function(k){var v=X.exec(this[k]);return v===null?void 0:{width:parseInt(v[1],10),height:parseInt(v[2],10)}},W.parseAttrList=function(k){var v,y={},R='"';for(O.lastIndex=0;(v=O.exec(k))!==null;){var A=v[2];A.indexOf(R)===0&&A.lastIndexOf(R)===A.length-1&&(A=A.slice(1,-1)),y[v[1]]=A}return y},W}()},"./src/utils/binary-search.ts":function(oe,Z,_){"use strict";_.r(Z);var X={search:function(I,W){for(var F=0,M=I.length-1,k=null,v=null;F<=M;){k=(F+M)/2|0,v=I[k];var y=W(v);if(y>0)F=k+1;else if(y<0)M=k-1;else return v}return null}};Z.default=X},"./src/utils/buffer-helper.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"BufferHelper",function(){return I});var X=_("./src/utils/logger.ts"),O={length:0,start:function(){return 0},end:function(){return 0}},I=function(){function W(){}return W.isBuffered=function(M,k){try{if(M){for(var v=W.getBuffered(M),y=0;y<v.length;y++)if(k>=v.start(y)&&k<=v.end(y))return!0}}catch(R){}return!1},W.bufferInfo=function(M,k,v){try{if(M){var y=W.getBuffered(M),R=[],A;for(A=0;A<y.length;A++)R.push({start:y.start(A),end:y.end(A)});return this.bufferedInfo(R,k,v)}}catch(x){}return{len:0,start:k,end:k,nextStart:void 0}},W.bufferedInfo=function(M,k,v){k=Math.max(0,k),M.sort(function(p,D){var S=p.start-D.start;return S||D.end-p.end});var y=[];if(v)for(var R=0;R<M.length;R++){var A=y.length;if(A){var x=y[A-1].end;M[R].start-x<v?M[R].end>x&&(y[A-1].end=M[R].end):y.push(M[R])}else y.push(M[R])}else y=M;for(var C=0,u,o=k,l=k,h=0;h<y.length;h++){var L=y[h].start,f=y[h].end;if(k+v>=L&&k<f)o=L,l=f,C=l-k;else if(k+v<L){u=L;break}}return{len:C,start:o||0,end:l||0,nextStart:u}},W.getBuffered=function(M){try{return M.buffered}catch(k){return X.logger.log("failed to get media.buffered",k),O}},W}()},"./src/utils/cea-608-parser.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"Row",function(){return l}),_.d(Z,"CaptionScreen",function(){return h});var X=_("./src/utils/logger.ts"),O={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},I=function(c){var d=c;return O.hasOwnProperty(c)&&(d=O[c]),String.fromCharCode(d)},W=15,F=100,M={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},k={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},y={25:2,26:4,29:6,30:8,31:10,27:13,28:15},R=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],A;(function(g){g[g.ERROR=0]="ERROR",g[g.TEXT=1]="TEXT",g[g.WARNING=2]="WARNING",g[g.INFO=2]="INFO",g[g.DEBUG=3]="DEBUG",g[g.DATA=3]="DATA"})(A||(A={}));var x=function(){function g(){this.time=null,this.verboseLevel=A.ERROR}var c=g.prototype;return c.log=function(a,E){this.verboseLevel>=a&&X.logger.log(this.time+" ["+a+"] "+E)},g}(),C=function(c){for(var d=[],a=0;a<c.length;a++)d.push(c[a].toString(16));return d},u=function(){function g(d,a,E,b,T){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=d||"white",this.underline=a||!1,this.italics=E||!1,this.background=b||"black",this.flash=T||!1}var c=g.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(a){for(var E=["foreground","underline","italics","background","flash"],b=0;b<E.length;b++){var T=E[b];a.hasOwnProperty(T)&&(this[T]=a[T])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},c.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},g}(),o=function(){function g(d,a,E,b,T,P){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new u(a,E,b,T,P)}var c=g.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(a,E){this.uchar=a,this.penState.copy(E)},c.setPenState=function(a){this.penState.copy(a)},c.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},c.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},g}(),l=function(){function g(d){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<F;a++)this.chars.push(new o);this.logger=d,this.pos=0,this.currPenState=new u}var c=g.prototype;return c.equals=function(a){for(var E=!0,b=0;b<F;b++)if(!this.chars[b].equals(a.chars[b])){E=!1;break}return E},c.copy=function(a){for(var E=0;E<F;E++)this.chars[E].copy(a.chars[E])},c.isEmpty=function(){for(var a=!0,E=0;E<F;E++)if(!this.chars[E].isEmpty()){a=!1;break}return a},c.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(A.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>F&&(this.logger.log(A.DEBUG,"Too large cursor position "+this.pos),this.pos=F)},c.moveCursor=function(a){var E=this.pos+a;if(a>1)for(var b=this.pos+1;b<E+1;b++)this.chars[b].setPenState(this.currPenState);this.setCursor(E)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(a){a>=144&&this.backSpace();var E=I(a);if(this.pos>=F){this.logger.log(A.ERROR,"Cannot insert "+a.toString(16)+" ("+E+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(E,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(a){var E;for(E=a;E<F;E++)this.chars[E].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var a=[],E=!0,b=0;b<F;b++){var T=this.chars[b].uchar;T!==" "&&(E=!1),a.push(T)}return E?"":a.join("")},c.setPenStyles=function(a){this.currPenState.setStyles(a);var E=this.chars[this.pos];E.setPenState(this.currPenState)},g}(),h=function(){function g(d){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<W;a++)this.rows.push(new l(d));this.logger=d,this.currRow=W-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=g.prototype;return c.reset=function(){for(var a=0;a<W;a++)this.rows[a].clear();this.currRow=W-1},c.equals=function(a){for(var E=!0,b=0;b<W;b++)if(!this.rows[b].equals(a.rows[b])){E=!1;break}return E},c.copy=function(a){for(var E=0;E<W;E++)this.rows[E].copy(a.rows[E])},c.isEmpty=function(){for(var a=!0,E=0;E<W;E++)if(!this.rows[E].isEmpty()){a=!1;break}return a},c.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},c.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},c.insertChar=function(a){var E=this.rows[this.currRow];E.insertChar(a)},c.setPen=function(a){var E=this.rows[this.currRow];E.setPenStyles(a)},c.moveCursor=function(a){var E=this.rows[this.currRow];E.moveCursor(a)},c.setCursor=function(a){this.logger.log(A.INFO,"setCursor: "+a);var E=this.rows[this.currRow];E.setCursor(a)},c.setPAC=function(a){this.logger.log(A.INFO,"pacData = "+JSON.stringify(a));var E=a.row-1;if(this.nrRollUpRows&&E<this.nrRollUpRows-1&&(E=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==E){for(var b=0;b<W;b++)this.rows[b].clear();var T=this.currRow+1-this.nrRollUpRows,P=this.lastOutputScreen;if(P){var G=P.rows[T].cueStartTime,Y=this.logger.time;if(G&&Y!==null&&G<Y)for(var Q=0;Q<this.nrRollUpRows;Q++)this.rows[E-this.nrRollUpRows+Q+1].copy(P.rows[T+Q])}}this.currRow=E;var z=this.rows[this.currRow];if(a.indent!==null){var j=a.indent,q=Math.max(j-1,0);z.setCursor(a.indent),a.color=z.chars[q].penState.foreground}var ae={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ae)},c.setBkgData=function(a){this.logger.log(A.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},c.setRollUpRows=function(a){this.nrRollUpRows=a},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(A.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(A.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,E=this.rows.splice(a,1)[0];E.clear(),this.rows.splice(this.currRow,0,E),this.logger.log(A.INFO,"Rolling up")},c.getDisplayText=function(a){a=a||!1;for(var E=[],b="",T=-1,P=0;P<W;P++){var G=this.rows[P].getTextString();G&&(T=P+1,a?E.push("Row "+T+": '"+G+"'"):E.push(G.trim()))}return E.length>0&&(a?b="["+E.join(" | ")+"]":b=E.join(`
|
|
`)),b},c.getTextAndFormat=function(){return this.rows},g}(),L=function(){function g(d,a,E){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=d,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new h(E),this.nonDisplayedMemory=new h(E),this.lastOutputScreen=new h(E),this.currRollUpRow=this.displayedMemory.rows[W-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=E}var c=g.prototype;return c.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[W-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(a){this.outputFilter=a},c.setPAC=function(a){this.writeScreen.setPAC(a)},c.setBkgData=function(a){this.writeScreen.setBkgData(a)},c.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(A.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},c.insertChars=function(a){for(var E=0;E<a.length;E++)this.writeScreen.insertChar(a[E]);var b=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(A.INFO,b+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(A.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(A.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){if(this.logger.log(A.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},c.ccAOF=function(){},c.ccAON=function(){},c.ccDER=function(){this.logger.log(A.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(a){this.logger.log(A.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},c.ccFON=function(){this.logger.log(A.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(A.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(A.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(A.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(A.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(A.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(A.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(A.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(A.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(a){this.logger.log(A.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},c.ccMIDROW=function(a){var E={flash:!1};if(E.underline=a%2===1,E.italics=a>=46,E.italics)E.foreground="white";else{var b=Math.floor(a/2)-16,T=["white","green","blue","cyan","red","yellow","magenta"];E.foreground=T[b]}this.logger.log(A.INFO,"MIDROW: "+JSON.stringify(E)),this.writeScreen.setPen(E)},c.outputDataUpdate=function(a){a===void 0&&(a=!1);var E=this.logger.time;if(E===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=E:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,E,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:E),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},g}(),f=function(){function g(d,a,E){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var b=new x;this.channels=[null,new L(d,a,b),new L(d+1,E,b)],this.cmdHistory=S(),this.logger=b}var c=g.prototype;return c.getHandler=function(a){return this.channels[a].getHandler()},c.setHandler=function(a,E){this.channels[a].setHandler(E)},c.addData=function(a,E){var b,T,P,G=!1;this.logger.time=a;for(var Y=0;Y<E.length;Y+=2){if(T=E[Y]&127,P=E[Y+1]&127,T===0&&P===0)continue;if(this.logger.log(A.DATA,"["+C([E[Y],E[Y+1]])+"] -> ("+C([T,P])+")"),b=this.parseCmd(T,P),b||(b=this.parseMidrow(T,P)),b||(b=this.parsePAC(T,P)),b||(b=this.parseBackgroundAttributes(T,P)),!b&&(G=this.parseChars(T,P),G)){var Q=this.currentChannel;if(Q&&Q>0){var z=this.channels[Q];z.insertChars(G)}else this.logger.log(A.WARNING,"No channel found yet. TEXT-MODE?")}!b&&!G&&this.logger.log(A.WARNING,"Couldn't parse cleaned data "+C([T,P])+" orig: "+C([E[Y],E[Y+1]]))}},c.parseCmd=function(a,E){var b=this.cmdHistory,T=(a===20||a===28||a===21||a===29)&&E>=32&&E<=47,P=(a===23||a===31)&&E>=33&&E<=35;if(!(T||P))return!1;if(D(a,E,b))return p(null,null,b),this.logger.log(A.DEBUG,"Repeated command ("+C([a,E])+") is dropped"),!0;var G=a===20||a===21||a===23?1:2,Y=this.channels[G];return a===20||a===21||a===28||a===29?E===32?Y.ccRCL():E===33?Y.ccBS():E===34?Y.ccAOF():E===35?Y.ccAON():E===36?Y.ccDER():E===37?Y.ccRU(2):E===38?Y.ccRU(3):E===39?Y.ccRU(4):E===40?Y.ccFON():E===41?Y.ccRDC():E===42?Y.ccTR():E===43?Y.ccRTD():E===44?Y.ccEDM():E===45?Y.ccCR():E===46?Y.ccENM():E===47&&Y.ccEOC():Y.ccTO(E-32),p(a,E,b),this.currentChannel=G,!0},c.parseMidrow=function(a,E){var b=0;if((a===17||a===25)&&E>=32&&E<=47){if(a===17?b=1:b=2,b!==this.currentChannel)return this.logger.log(A.ERROR,"Mismatch channel in midrow parsing"),!1;var T=this.channels[b];return T?(T.ccMIDROW(E),this.logger.log(A.DEBUG,"MIDROW ("+C([a,E])+")"),!0):!1}return!1},c.parsePAC=function(a,E){var b,T=this.cmdHistory,P=(a>=17&&a<=23||a>=25&&a<=31)&&E>=64&&E<=127,G=(a===16||a===24)&&E>=64&&E<=95;if(!(P||G))return!1;if(D(a,E,T))return p(null,null,T),!0;var Y=a<=23?1:2;E>=64&&E<=95?b=Y===1?M[a]:v[a]:b=Y===1?k[a]:y[a];var Q=this.channels[Y];return Q?(Q.setPAC(this.interpretPAC(b,E)),p(a,E,T),this.currentChannel=Y,!0):!1},c.interpretPAC=function(a,E){var b,T={color:null,italics:!1,indent:null,underline:!1,row:a};return E>95?b=E-96:b=E-64,T.underline=(b&1)===1,b<=13?T.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(b/2)]:b<=15?(T.italics=!0,T.color="white"):T.indent=Math.floor((b-16)/2)*4,T},c.parseChars=function(a,E){var b,T=null,P=null;if(a>=25?(b=2,P=a-8):(b=1,P=a),P>=17&&P<=19){var G;P===17?G=E+80:P===18?G=E+112:G=E+144,this.logger.log(A.INFO,"Special char '"+I(G)+"' in channel "+b),T=[G]}else a>=32&&a<=127&&(T=E===0?[a]:[a,E]);if(T){var Y=C(T);this.logger.log(A.DEBUG,"Char codes = "+Y.join(",")),p(a,E,this.cmdHistory)}return T},c.parseBackgroundAttributes=function(a,E){var b=(a===16||a===24)&&E>=32&&E<=47,T=(a===23||a===31)&&E>=45&&E<=47;if(!(b||T))return!1;var P,G={};a===16||a===24?(P=Math.floor((E-32)/2),G.background=R[P],E%2===1&&(G.background=G.background+"_semi")):E===45?G.background="transparent":(G.foreground="black",E===47&&(G.underline=!0));var Y=a<=23?1:2,Q=this.channels[Y];return Q.setBkgData(G),p(a,E,this.cmdHistory),!0},c.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var E=this.channels[a];E&&E.reset()}this.cmdHistory=S()},c.cueSplitAtTime=function(a){for(var E=0;E<this.channels.length;E++){var b=this.channels[E];b&&b.cueSplitAtTime(a)}},g}();function p(g,c,d){d.a=g,d.b=c}function D(g,c,d){return d.a===g&&d.b===c}function S(){return{a:null,b:null}}Z.default=f},"./src/utils/codecs.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"isCodecType",function(){return O}),_.d(Z,"isCodecSupportedInMp4",function(){return I});var X={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 O(W,F){var M=X[F];return!!M&&M[W.slice(0,4)]===!0}function I(W,F){return MediaSource.isTypeSupported((F||"video")+'/mp4;codecs="'+W+'"')}},"./src/utils/cues.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/utils/vttparser.ts"),O=_("./src/utils/webvtt-parser.ts"),I=_("./src/utils/texttrack-utils.ts"),W=/\s/,F={newCue:function(k,v,y,R){for(var A=[],x,C,u,o,l,h=self.VTTCue||self.TextTrackCue,L=0;L<R.rows.length;L++)if(x=R.rows[L],u=!0,o=0,l="",!x.isEmpty()){for(var f=0;f<x.chars.length;f++)W.test(x.chars[f].uchar)&&u?o++:(l+=x.chars[f].uchar,u=!1);x.cueStartTime=v,v===y&&(y+=1e-4),o>=16?o--:o++;var p=Object(X.fixLineBreaks)(l.trim()),D=Object(O.generateCueId)(v,y,p);(!k||!k.cues||!k.cues.getCueById(D))&&(C=new h(v,y,p),C.id=D,C.line=L+1,C.align="left",C.position=10+Math.min(80,Math.floor(o*8/32)*10),A.push(C))}return k&&A.length&&(A.sort(function(S,g){return S.line==="auto"||g.line==="auto"?0:S.line>8&&g.line>8?g.line-S.line:S.line-g.line}),A.forEach(function(S){return Object(I.addCueToTrack)(k,S)})),A}};Z.default=F},"./src/utils/discontinuities.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"findFirstFragWithCC",function(){return W}),_.d(Z,"shouldAlignOnDiscontinuities",function(){return F}),_.d(Z,"findDiscontinuousReferenceFrag",function(){return M}),_.d(Z,"adjustSlidingStart",function(){return v}),_.d(Z,"alignStream",function(){return y}),_.d(Z,"alignPDT",function(){return A}),_.d(Z,"alignFragmentByPDTDelta",function(){return x}),_.d(Z,"alignMediaPlaylistByPDT",function(){return C});var X=_("./src/polyfills/number.ts"),O=_("./src/utils/logger.ts"),I=_("./src/controller/level-helper.ts");function W(u,o){for(var l=null,h=0,L=u.length;h<L;h++){var f=u[h];if(f&&f.cc===o){l=f;break}}return l}function F(u,o,l){return!!(o.details&&(l.endCC>l.startCC||u&&u.cc<l.startCC))}function M(u,o){var l=u.fragments,h=o.fragments;if(!h.length||!l.length){O.logger.log("No fragments to align");return}var L=W(l,h[0].cc);if(!L||L&&!L.startPTS){O.logger.log("No frag in previous level to align on");return}return L}function k(u,o){if(u){var l=u.start+o;u.start=u.startPTS=l,u.endPTS=l+u.duration}}function v(u,o){for(var l=o.fragments,h=0,L=l.length;h<L;h++)k(l[h],u);o.fragmentHint&&k(o.fragmentHint,u),o.alignedSliding=!0}function y(u,o,l){if(!o)return;R(u,l,o),!l.alignedSliding&&o.details&&A(l,o.details),!l.alignedSliding&&o.details&&!l.skippedSegments&&Object(I.adjustSliding)(o.details,l)}function R(u,o,l){if(F(u,l,o)){var h=M(l.details,o);h&&Object(X.isFiniteNumber)(h.start)&&(O.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),v(h.start,o))}}function A(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,h=u.fragments[0].programDateTime,L=(h-l)/1e3+o.fragments[0].start;L&&Object(X.isFiniteNumber)(L)&&(O.logger.log("Adjusting PTS using programDateTime delta "+(h-l)+"ms, sliding:"+L.toFixed(3)+" "+u.url+" "),v(L,u))}function x(u,o){var l=u.programDateTime;if(!l)return;var h=(l-o)/1e3;u.start=u.startPTS=h,u.endPTS=h+u.duration}function C(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,h=o.fragments[0].start,L=l-h*1e3;u.fragments.forEach(function(f){x(f,L)}),u.fragmentHint&&x(u.fragmentHint,L),u.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/utils/ewma.ts"),O=function(){function I(F,M,k){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=k,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new X.default(F),this.fast_=new X.default(M)}var W=I.prototype;return W.update=function(M,k){var v=this.slow_,y=this.fast_;this.slow_.halfLife!==M&&(this.slow_=new X.default(M,v.getEstimate(),v.getTotalWeight())),this.fast_.halfLife!==k&&(this.fast_=new X.default(k,y.getEstimate(),y.getTotalWeight()))},W.sample=function(M,k){M=Math.max(M,this.minDelayMs_);var v=8*k,y=M/1e3,R=v/y;this.fast_.sample(y,R),this.slow_.sample(y,R)},W.canEstimate=function(){var M=this.fast_;return M&&M.getTotalWeight()>=this.minWeight_},W.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},W.destroy=function(){},I}();Z.default=O},"./src/utils/ewma.ts":function(oe,Z,_){"use strict";_.r(Z);var X=function(){function O(W,F,M){F===void 0&&(F=0),M===void 0&&(M=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=W,this.alpha_=W?Math.exp(Math.log(.5)/W):0,this.estimate_=F,this.totalWeight_=M}var I=O.prototype;return I.sample=function(F,M){var k=Math.pow(this.alpha_,F);this.estimate_=M*(1-k)+k*this.estimate_,this.totalWeight_+=F},I.getTotalWeight=function(){return this.totalWeight_},I.getEstimate=function(){if(this.alpha_){var F=1-Math.pow(this.alpha_,this.totalWeight_);if(F)return this.estimate_/F}return this.estimate_},O}();Z.default=X},"./src/utils/fetch-loader.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"fetchSupported",function(){return x});var X=_("./src/polyfills/number.ts"),O=_("./src/loader/load-stats.ts"),I=_("./src/demux/chunk-cache.ts");function W(h,L){h.prototype=Object.create(L.prototype),h.prototype.constructor=h,y(h,L)}function F(h){var L=typeof Map=="function"?new Map:void 0;return F=function(p){if(p===null||!v(p))return p;if(typeof p!="function")throw new TypeError("Super expression must either be null or a function");if(typeof L!="undefined"){if(L.has(p))return L.get(p);L.set(p,D)}function D(){return M(p,arguments,R(this).constructor)}return D.prototype=Object.create(p.prototype,{constructor:{value:D,enumerable:!1,writable:!0,configurable:!0}}),y(D,p)},F(h)}function M(h,L,f){return k()?M=Reflect.construct:M=function(D,S,g){var c=[null];c.push.apply(c,S);var d=Function.bind.apply(D,c),a=new d;return g&&y(a,g.prototype),a},M.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(h){return!1}}function v(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function y(h,L){return y=Object.setPrototypeOf||function(p,D){return p.__proto__=D,p},y(h,L)}function R(h){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(f){return f.__proto__||Object.getPrototypeOf(f)},R(h)}function A(){return A=Object.assign||function(h){for(var L=1;L<arguments.length;L++){var f=arguments[L];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(h[p]=f[p])}return h},A.apply(this,arguments)}function x(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(h){}return!1}var C=function(){function h(f){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=f.fetchSetup||o,this.controller=new self.AbortController,this.stats=new O.LoadStats}var L=h.prototype;return L.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},L.abortInternal=function(){var p=this.response;(!p||!p.ok)&&(this.stats.aborted=!0,this.controller.abort())},L.abort=function(){var p;this.abortInternal(),(p=this.callbacks)!==null&&p!==void 0&&p.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},L.load=function(p,D,S){var g=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var d=u(p,this.controller.signal),a=S.onProgress,E=p.responseType==="arraybuffer",b=E?"byteLength":"length";this.context=p,this.config=D,this.callbacks=S,this.request=this.fetchSetup(p,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){g.abortInternal(),S.onTimeout(c,p,g.response)},D.timeout),self.fetch(this.request).then(function(T){if(g.response=g.loader=T,!T.ok){var P=T.status,G=T.statusText;throw new l(G||"fetch, bad network response",P,T)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(T.headers.get("Content-Length")||"0"),a&&Object(X.isFiniteNumber)(D.highWaterMark)?g.loadProgressively(T,c,p,D.highWaterMark,a):E?T.arrayBuffer():T.text()}).then(function(T){var P=g.response;self.clearTimeout(g.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=T[b];var G={url:P.url,data:T};a&&!Object(X.isFiniteNumber)(D.highWaterMark)&&a(c,p,T,P),S.onSuccess(G,c,p,P)}).catch(function(T){if(self.clearTimeout(g.requestTimeout),c.aborted)return;var P=T.code||0;S.onError({code:P,text:T.message},p,T.details)})},L.getCacheAge=function(){var p=null;if(this.response){var D=this.response.headers.get("age");p=D?parseFloat(D):null}return p},L.loadProgressively=function(p,D,S,g,c){g===void 0&&(g=0);var d=new I.default,a=p.body.getReader(),E=function b(){return a.read().then(function(T){if(T.done)return d.dataLength&&c(D,S,d.flush(),p),Promise.resolve(new ArrayBuffer(0));var P=T.value,G=P.length;return D.loaded+=G,G<g||d.dataLength?(d.push(P),d.dataLength>=g&&c(D,S,d.flush(),p)):c(D,S,P,p),b()}).catch(function(){return Promise.reject()})};return E()},h}();function u(h,L){var f={method:"GET",mode:"cors",credentials:"same-origin",signal:L,headers:new self.Headers(A({},h.headers))};return h.rangeEnd&&f.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),f}function o(h,L){return new self.Request(h.url,L)}var l=function(h){W(L,h);function L(f,p,D){var S;return S=h.call(this,f)||this,S.code=void 0,S.details=void 0,S.code=p,S.details=D,S}return L}(F(Error));Z.default=C},"./src/utils/imsc1-ttml-parser.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"IMSC1_CODEC",function(){return v}),_.d(Z,"parseIMSC1",function(){return x});var X=_("./src/utils/mp4-tools.ts"),O=_("./src/utils/vttparser.ts"),I=_("./src/utils/vttcue.ts"),W=_("./src/demux/id3.ts"),F=_("./src/utils/timescale-conversion.ts"),M=_("./src/utils/webvtt-parser.ts");function k(){return k=Object.assign||function(g){for(var c=1;c<arguments.length;c++){var d=arguments[c];for(var a in d)Object.prototype.hasOwnProperty.call(d,a)&&(g[a]=d[a])}return g},k.apply(this,arguments)}var v="stpp.ttml.im1t",y=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,R=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,A={left:"start",center:"center",right:"end",start:"start",end:"end"};function x(g,c,d,a,E){var b=Object(X.findBox)(new Uint8Array(g),["mdat"]);if(b.length===0){E(new Error("Could not parse IMSC1 mdat"));return}var T=b[0],P=Object(W.utf8ArrayToStr)(new Uint8Array(g,T.start,T.end-T.start)),G=Object(F.toTimescaleFromScale)(c,1,d);try{a(C(P,G))}catch(Y){E(Y)}}function C(g,c){var d=new DOMParser,a=d.parseFromString(g,"text/xml"),E=a.getElementsByTagName("tt")[0];if(!E)throw new Error("Invalid ttml");var b={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},T=Object.keys(b).reduce(function(z,j){return z[j]=E.getAttribute("ttp:"+j)||b[j],z},{}),P=E.getAttribute("xml:space")!=="preserve",G=o(u(E,"styling","style")),Y=o(u(E,"layout","region")),Q=u(E,"body","[begin]");return[].map.call(Q,function(z){var j=l(z,P);if(!j||!z.hasAttribute("begin"))return null;var q=p(z.getAttribute("begin"),T),ae=p(z.getAttribute("dur"),T),ce=p(z.getAttribute("end"),T);if(q===null)throw f(z);if(ce===null){if(ae===null)throw f(z);ce=q+ae}var ve=new I.default(q-c,ce-c,j);ve.id=Object(M.generateCueId)(ve.startTime,ve.endTime,ve.text);var ke=Y[z.getAttribute("region")],Ee=G[z.getAttribute("style")];ve.position=10,ve.size=80;var Ce=h(ke,Ee),Le=Ce.textAlign;if(Le){var we=A[Le];we&&(ve.lineAlign=we),ve.align=Le}return k(ve,Ce),ve}).filter(function(z){return z!==null})}function u(g,c,d){var a=g.getElementsByTagName(c)[0];return a?[].slice.call(a.querySelectorAll(d)):[]}function o(g){return g.reduce(function(c,d){var a=d.getAttribute("xml:id");return a&&(c[a]=d),c},{})}function l(g,c){return[].slice.call(g.childNodes).reduce(function(d,a,E){var b;return a.nodeName==="br"&&E?d+`
|
|
`:(b=a.childNodes)!==null&&b!==void 0&&b.length?l(a,c):c?d+a.textContent.trim().replace(/\s+/g," "):d+a.textContent},"")}function h(g,c){var d="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(E,b){var T=L(c,d,b)||L(g,d,b);return T&&(E[b]=T),E},{})}function L(g,c,d){return g.hasAttributeNS(c,d)?g.getAttributeNS(c,d):null}function f(g){return new Error("Could not parse ttml timestamp "+g)}function p(g,c){if(!g)return null;var d=Object(O.parseTimeStamp)(g);return d===null&&(y.test(g)?d=D(g,c):R.test(g)&&(d=S(g,c))),d}function D(g,c){var d=y.exec(g),a=(d[4]|0)+(d[5]|0)/c.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+a/c.frameRate}function S(g,c){var d=R.exec(g),a=Number(d[1]),E=d[2];switch(E){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/c.frameRate;case"t":return a/c.tickRate}return a}},"./src/utils/logger.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"enableLogs",function(){return M}),_.d(Z,"logger",function(){return k});var X=function(){},O={trace:X,debug:X,log:X,warn:X,info:X,error:X},I=O;function W(v){var y=self.console[v];return y?y.bind(self.console,"["+v+"] >"):X}function F(v){for(var y=arguments.length,R=new Array(y>1?y-1:0),A=1;A<y;A++)R[A-1]=arguments[A];R.forEach(function(x){I[x]=v[x]?v[x].bind(v):W(x)})}function M(v){if(self.console&&v===!0||typeof v=="object"){F(v,"debug","log","info","warn","error");try{I.log()}catch(y){I=O}}else I=O}var k=I},"./src/utils/mediakeys-helper.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"KeySystems",function(){return X}),_.d(Z,"requestMediaKeySystemAccess",function(){return O});var X;(function(I){I.WIDEVINE="com.widevine.alpha",I.PLAYREADY="com.microsoft.playready"})(X||(X={}));var O=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"getMediaSource",function(){return X});function X(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"bin2str",function(){return F}),_.d(Z,"readUint16",function(){return M}),_.d(Z,"readUint32",function(){return k}),_.d(Z,"writeUint32",function(){return v}),_.d(Z,"findBox",function(){return y}),_.d(Z,"parseSegmentIndex",function(){return R}),_.d(Z,"parseInitSegment",function(){return A}),_.d(Z,"getStartDTS",function(){return x}),_.d(Z,"getDuration",function(){return C}),_.d(Z,"computeRawDurationFromSamples",function(){return u}),_.d(Z,"offsetStartDTS",function(){return o}),_.d(Z,"segmentValidRange",function(){return l}),_.d(Z,"appendUint8Array",function(){return h});var X=_("./src/utils/typed-array.ts"),O=_("./src/loader/fragment.ts"),I=Math.pow(2,32)-1,W=[].push;function F(L){return String.fromCharCode.apply(null,L)}function M(L,f){"data"in L&&(f+=L.start,L=L.data);var p=L[f]<<8|L[f+1];return p<0?65536+p:p}function k(L,f){"data"in L&&(f+=L.start,L=L.data);var p=L[f]<<24|L[f+1]<<16|L[f+2]<<8|L[f+3];return p<0?4294967296+p:p}function v(L,f,p){"data"in L&&(f+=L.start,L=L.data),L[f]=p>>24,L[f+1]=p>>16&255,L[f+2]=p>>8&255,L[f+3]=p&255}function y(L,f){var p=[];if(!f.length)return p;var D,S,g;"data"in L?(D=L.data,S=L.start,g=L.end):(D=L,S=0,g=D.byteLength);for(var c=S;c<g;){var d=k(D,c),a=F(D.subarray(c+4,c+8)),E=d>1?c+d:g;if(a===f[0])if(f.length===1)p.push({data:D,start:c+8,end:E});else{var b=y({data:D,start:c+8,end:E},f.slice(1));b.length&&W.apply(p,b)}c=E}return p}function R(L){var f=y(L,["moov"]),p=f[0],D=p?p.end:null,S=y(L,["sidx"]);if(!S||!S[0])return null;var g=[],c=S[0],d=c.data[0],a=d===0?8:16,E=k(c,a);a+=4;var b=0,T=0;d===0?a+=8:a+=16,a+=2;var P=c.end+T,G=M(c,a);a+=2;for(var Y=0;Y<G;Y++){var Q=a,z=k(c,Q);Q+=4;var j=z&2147483647,q=(z&2147483648)>>>31;if(q===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ae=k(c,Q);Q+=4,g.push({referenceSize:j,subsegmentDuration:ae,info:{duration:ae/E,start:P,end:P+j-1}}),P+=j,Q+=4,a=Q}return{earliestPresentationTime:b,timescale:E,version:d,referencesCount:G,references:g,moovEndOffset:D}}function A(L){for(var f=[],p=y(L,["moov","trak"]),D=0;D<p.length;D++){var S=p[D],g=y(S,["tkhd"])[0];if(g){var c=g.data[g.start],d=c===0?12:20,a=k(g,d),E=y(S,["mdia","mdhd"])[0];if(E){c=E.data[E.start],d=c===0?12:20;var b=k(E,d),T=y(S,["mdia","hdlr"])[0];if(T){var P=F(T.data.subarray(T.start+8,T.start+12)),G={soun:O.ElementaryStreamTypes.AUDIO,vide:O.ElementaryStreamTypes.VIDEO}[P];if(G){var Y=y(S,["mdia","minf","stbl","stsd"])[0],Q=void 0;Y&&(Q=F(Y.data.subarray(Y.start+12,Y.start+16))),f[a]={timescale:b,type:G},f[G]={timescale:b,id:a,codec:Q}}}}}}var z=y(L,["moov","mvex","trex"]);return z.forEach(function(j){var q=k(j,4),ae=f[q];ae&&(ae.default={duration:k(j,12),flags:k(j,20)})}),f}function x(L,f){return y(f,["moof","traf"]).reduce(function(p,D){var S=y(D,["tfdt"])[0],g=S.data[S.start],c=y(D,["tfhd"]).reduce(function(d,a){var E=k(a,4),b=L[E];if(b){var T=k(S,4);g===1&&(T*=Math.pow(2,32),T+=k(S,8));var P=b.timescale||9e4,G=T/P;if(isFinite(G)&&(d===null||G<d))return G}return d},null);return c!==null&&isFinite(c)&&(p===null||c<p)?c:p},null)||0}function C(L,f){for(var p=0,D=0,S=0,g=y(L,["moof","traf"]),c=0;c<g.length;c++){var d=g[c],a=y(d,["tfhd"])[0],E=k(a,4),b=f[E];if(!b)continue;var T=b.default,P=k(a,0)|(T==null?void 0:T.flags),G=T==null?void 0:T.duration;P&8&&(P&2?G=k(a,12):G=k(a,8));for(var Y=b.timescale||9e4,Q=y(d,["trun"]),z=0;z<Q.length;z++){if(G){var j=k(Q[z],4);p=G*j}else p=u(Q[z]);b.type===O.ElementaryStreamTypes.VIDEO?D+=p/Y:b.type===O.ElementaryStreamTypes.AUDIO&&(S+=p/Y)}}if(D===0&&S===0){var q=R(L);if(q!=null&&q.references)return q.references.reduce(function(ae,ce){return ae+ce.info.duration||0},0)}return D||S}function u(L){var f=k(L,0),p=8;f&1&&(p+=4),f&4&&(p+=4);for(var D=0,S=k(L,4),g=0;g<S;g++){if(f&256){var c=k(L,p);D+=c,p+=4}f&512&&(p+=4),f&1024&&(p+=4),f&2048&&(p+=4)}return D}function o(L,f,p){y(f,["moof","traf"]).forEach(function(D){y(D,["tfhd"]).forEach(function(S){var g=k(S,4),c=L[g];if(!c)return;var d=c.timescale||9e4;y(D,["tfdt"]).forEach(function(a){var E=a.data[a.start],b=k(a,4);if(E===0)v(a,4,b-p*d);else{b*=Math.pow(2,32),b+=k(a,8),b-=p*d,b=Math.max(b,0);var T=Math.floor(b/(I+1)),P=Math.floor(b%(I+1));v(a,4,T),v(a,8,P)}})})})}function l(L){var f={valid:null,remainder:null},p=y(L,["moof"]);if(p){if(p.length<2)return f.remainder=L,f}else return f;var D=p[p.length-1];return f.valid=Object(X.sliceUint8)(L,0,D.start-8),f.remainder=Object(X.sliceUint8)(L,D.start-8),f}function h(L,f){var p=new Uint8Array(L.length+f.length);return p.set(L),p.set(f,L.length),p}},"./src/utils/output-filter.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"default",function(){return X});var X=function(){function O(W,F){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=W,this.trackName=F}var I=O.prototype;return I.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},I.newCue=function(F,M,k){(this.startTime===null||this.startTime>F)&&(this.startTime=F),this.endTime=M,this.screen=k,this.timelineController.createCaptionsTrack(this.trackName)},I.reset=function(){this.cueRanges=[]},O}()},"./src/utils/texttrack-utils.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"sendAddTrackEvent",function(){return O}),_.d(Z,"addCueToTrack",function(){return I}),_.d(Z,"clearCurrentCues",function(){return W}),_.d(Z,"removeCuesInRange",function(){return F}),_.d(Z,"getCuesInRange",function(){return k});var X=_("./src/utils/logger.ts");function O(v,y){var R;try{R=new Event("addtrack")}catch(A){R=document.createEvent("Event"),R.initEvent("addtrack",!1,!1)}R.track=v,y.dispatchEvent(R)}function I(v,y){var R=v.mode;if(R==="disabled"&&(v.mode="hidden"),v.cues&&!v.cues.getCueById(y.id))try{if(v.addCue(y),!v.cues.getCueById(y.id))throw new Error("addCue is failed for: "+y)}catch(x){X.logger.debug("[texttrack-utils]: "+x);var A=new self.TextTrackCue(y.startTime,y.endTime,y.text);A.id=y.id,v.addCue(A)}R==="disabled"&&(v.mode=R)}function W(v){var y=v.mode;if(y==="disabled"&&(v.mode="hidden"),v.cues)for(var R=v.cues.length;R--;)v.removeCue(v.cues[R]);y==="disabled"&&(v.mode=y)}function F(v,y,R){var A=v.mode;if(A==="disabled"&&(v.mode="hidden"),v.cues&&v.cues.length>0)for(var x=k(v.cues,y,R),C=0;C<x.length;C++)v.removeCue(x[C]);A==="disabled"&&(v.mode=A)}function M(v,y){if(y<v[0].startTime)return 0;var R=v.length-1;if(y>v[R].endTime)return-1;for(var A=0,x=R;A<=x;){var C=Math.floor((x+A)/2);if(y<v[C].startTime)x=C-1;else if(y>v[C].startTime&&A<R)A=C+1;else return C}return v[A].startTime-y<y-v[x].startTime?A:x}function k(v,y,R){var A=[],x=M(v,y);if(x>-1)for(var C=x,u=v.length;C<u;C++){var o=v[C];if(o.startTime>=y&&o.endTime<=R)A.push(o);else if(o.startTime>R)return A}return A}},"./src/utils/time-ranges.ts":function(oe,Z,_){"use strict";_.r(Z);var X={toString:function(I){for(var W="",F=I.length,M=0;M<F;M++)W+="["+I.start(M).toFixed(3)+","+I.end(M).toFixed(3)+"]";return W}};Z.default=X},"./src/utils/timescale-conversion.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"toTimescaleFromBase",function(){return O}),_.d(Z,"toTimescaleFromScale",function(){return I}),_.d(Z,"toMsFromMpegTsClock",function(){return W}),_.d(Z,"toMpegTsClockFromTimescale",function(){return F});var X=9e4;function O(M,k,v,y){v===void 0&&(v=1),y===void 0&&(y=!1);var R=M*k*v;return y?Math.round(R):R}function I(M,k,v,y){return v===void 0&&(v=1),y===void 0&&(y=!1),O(M,k,1/v,y)}function W(M,k){return k===void 0&&(k=!1),O(M,1e3,1/X,k)}function F(M,k){return k===void 0&&(k=1),O(M,X,1/k)}},"./src/utils/typed-array.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"sliceUint8",function(){return X});function X(O,I,W){return Uint8Array.prototype.slice?O.slice(I,W):new Uint8Array(Array.prototype.slice.call(O,I,W))}},"./src/utils/vttcue.ts":function(oe,Z,_){"use strict";_.r(Z),Z.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var X=["","lr","rl"],O=["start","middle","end","left","right"];function I(v,y){if(typeof y!="string")return!1;if(!Array.isArray(v))return!1;var R=y.toLowerCase();return~v.indexOf(R)?R:!1}function W(v){return I(X,v)}function F(v){return I(O,v)}function M(v){for(var y=arguments.length,R=new Array(y>1?y-1:0),A=1;A<y;A++)R[A-1]=arguments[A];for(var x=1;x<arguments.length;x++){var C=arguments[x];for(var u in C)v[u]=C[u]}return v}function k(v,y,R){var A=this,x={enumerable:!0};A.hasBeenReset=!1;var C="",u=!1,o=v,l=y,h=R,L=null,f="",p=!0,D="auto",S="start",g=50,c="middle",d=50,a="middle";Object.defineProperty(A,"id",M({},x,{get:function(){return C},set:function(b){C=""+b}})),Object.defineProperty(A,"pauseOnExit",M({},x,{get:function(){return u},set:function(b){u=!!b}})),Object.defineProperty(A,"startTime",M({},x,{get:function(){return o},set:function(b){if(typeof b!="number")throw new TypeError("Start time must be set to a number.");o=b,this.hasBeenReset=!0}})),Object.defineProperty(A,"endTime",M({},x,{get:function(){return l},set:function(b){if(typeof b!="number")throw new TypeError("End time must be set to a number.");l=b,this.hasBeenReset=!0}})),Object.defineProperty(A,"text",M({},x,{get:function(){return h},set:function(b){h=""+b,this.hasBeenReset=!0}})),Object.defineProperty(A,"region",M({},x,{get:function(){return L},set:function(b){L=b,this.hasBeenReset=!0}})),Object.defineProperty(A,"vertical",M({},x,{get:function(){return f},set:function(b){var T=W(b);if(T===!1)throw new SyntaxError("An invalid or illegal string was specified.");f=T,this.hasBeenReset=!0}})),Object.defineProperty(A,"snapToLines",M({},x,{get:function(){return p},set:function(b){p=!!b,this.hasBeenReset=!0}})),Object.defineProperty(A,"line",M({},x,{get:function(){return D},set:function(b){if(typeof b!="number"&&b!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");D=b,this.hasBeenReset=!0}})),Object.defineProperty(A,"lineAlign",M({},x,{get:function(){return S},set:function(b){var T=F(b);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");S=T,this.hasBeenReset=!0}})),Object.defineProperty(A,"position",M({},x,{get:function(){return g},set:function(b){if(b<0||b>100)throw new Error("Position must be between 0 and 100.");g=b,this.hasBeenReset=!0}})),Object.defineProperty(A,"positionAlign",M({},x,{get:function(){return c},set:function(b){var T=F(b);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");c=T,this.hasBeenReset=!0}})),Object.defineProperty(A,"size",M({},x,{get:function(){return d},set:function(b){if(b<0||b>100)throw new Error("Size must be between 0 and 100.");d=b,this.hasBeenReset=!0}})),Object.defineProperty(A,"align",M({},x,{get:function(){return a},set:function(b){var T=F(b);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");a=T,this.hasBeenReset=!0}})),A.displayState=void 0}return k.prototype.getCueAsHTML=function(){var v=self.WebVTT;return v.convertCueToDOMTree(self,this.text)},k}()},"./src/utils/vttparser.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"parseTimeStamp",function(){return I}),_.d(Z,"fixLineBreaks",function(){return y}),_.d(Z,"VTTParser",function(){return R});var X=_("./src/utils/vttcue.ts"),O=function(){function A(){}var x=A.prototype;return x.decode=function(u,o){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},A}();function I(A){function x(u,o,l,h){return(u|0)*3600+(o|0)*60+(l|0)+parseFloat(h||0)}var C=A.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return C?parseFloat(C[2])>59?x(C[2],C[3],0,C[4]):x(C[1],C[2],C[3],C[4]):null}var W=function(){function A(){this.values=Object.create(null)}var x=A.prototype;return x.set=function(u,o){!this.get(u)&&o!==""&&(this.values[u]=o)},x.get=function(u,o,l){return l?this.has(u)?this.values[u]:o[l]:this.has(u)?this.values[u]:o},x.has=function(u){return u in this.values},x.alt=function(u,o,l){for(var h=0;h<l.length;++h)if(o===l[h]){this.set(u,o);break}},x.integer=function(u,o){/^-?\d+$/.test(o)&&this.set(u,parseInt(o,10))},x.percent=function(u,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var l=parseFloat(o);if(l>=0&&l<=100)return this.set(u,l),!0}return!1},A}();function F(A,x,C,u){var o=u?A.split(u):[A];for(var l in o){if(typeof o[l]!="string")continue;var h=o[l].split(C);if(h.length!==2)continue;var L=h[0],f=h[1];x(L,f)}}var M=new X.default(0,0,""),k=M.align==="middle"?"middle":"center";function v(A,x,C){var u=A;function o(){var L=I(A);if(L===null)throw new Error("Malformed timestamp: "+u);return A=A.replace(/^[^\sa-zA-Z-]+/,""),L}function l(L,f){var p=new W;F(L,function(g,c){var d;switch(g){case"region":for(var a=C.length-1;a>=0;a--)if(C[a].id===c){p.set(g,C[a].region);break}break;case"vertical":p.alt(g,c,["rl","lr"]);break;case"line":d=c.split(","),p.integer(g,d[0]),p.percent(g,d[0])&&p.set("snapToLines",!1),p.alt(g,d[0],["auto"]),d.length===2&&p.alt("lineAlign",d[1],["start",k,"end"]);break;case"position":d=c.split(","),p.percent(g,d[0]),d.length===2&&p.alt("positionAlign",d[1],["start",k,"end","line-left","line-right","auto"]);break;case"size":p.percent(g,c);break;case"align":p.alt(g,c,["start",k,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");var D=p.get("line","auto");D==="auto"&&M.line===-1&&(D=-1),f.line=D,f.lineAlign=p.get("lineAlign","start"),f.snapToLines=p.get("snapToLines",!0),f.size=p.get("size",100),f.align=p.get("align",k);var S=p.get("position","auto");S==="auto"&&M.position===50&&(S=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=S}function h(){A=A.replace(/^\s+/,"")}if(h(),x.startTime=o(),h(),A.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);A=A.substr(3),h(),x.endTime=o(),h(),l(A,x)}function y(A){return A.replace(/<br(?: \/)?>/gi,`
|
|
`)}var R=function(){function A(){this.state="INITIAL",this.buffer="",this.decoder=new O,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var x=A.prototype;return x.parse=function(u){var o=this;u&&(o.buffer+=o.decoder.decode(u,{stream:!0}));function l(){var S=o.buffer,g=0;for(S=y(S);g<S.length&&S[g]!=="\r"&&S[g]!==`
|
|
`;)++g;var c=S.substr(0,g);return S[g]==="\r"&&++g,S[g]===`
|
|
`&&++g,o.buffer=S.substr(g),c}function h(S){F(S,function(g,c){},/:/)}try{var L="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;L=l();var f=L.match(/^()?WEBVTT([ \t].*)?$/);if(!f||!f[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var p=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;p?p=!1:L=l();switch(o.state){case"HEADER":/:/.test(L)?h(L):L||(o.state="ID");continue;case"NOTE":L||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(L)){o.state="NOTE";break}if(!L)continue;if(o.cue=new X.default(0,0,""),o.state="CUE",L.indexOf("-->")===-1){o.cue.id=L;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{v(L,o.cue,o.regionList)}catch(S){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var D=L.indexOf("-->")!==-1;if(!L||D&&(p=!0)){o.oncue&&o.cue&&o.oncue(o.cue),o.cue=null,o.state="ID";continue}if(o.cue===null)continue;o.cue.text&&(o.cue.text+=`
|
|
`),o.cue.text+=L}continue;case"BADCUE":L||(o.state="ID")}}}catch(S){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},x.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
|
|
|
|
`,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){u.onparsingerror&&u.onparsingerror(o)}return u.onflush&&u.onflush(),this},A}()},"./src/utils/webvtt-parser.ts":function(oe,Z,_){"use strict";_.r(Z),_.d(Z,"generateCueId",function(){return R}),_.d(Z,"parseWebVTT",function(){return x});var X=_("./src/polyfills/number.ts"),O=_("./src/utils/vttparser.ts"),I=_("./src/demux/id3.ts"),W=_("./src/utils/timescale-conversion.ts"),F=_("./src/remux/mp4-remuxer.ts"),M=/\r\n|\n\r|\n|\r/g,k=function(u,o,l){return l===void 0&&(l=0),u.substr(l,o.length)===o},v=function(u){var o=parseInt(u.substr(-3)),l=parseInt(u.substr(-6,2)),h=parseInt(u.substr(-9,2)),L=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object(X.isFiniteNumber)(o)||!Object(X.isFiniteNumber)(l)||!Object(X.isFiniteNumber)(h)||!Object(X.isFiniteNumber)(L))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return o+=1e3*l,o+=60*1e3*h,o+=60*60*1e3*L,o},y=function(u){for(var o=5381,l=u.length;l;)o=o*33^u.charCodeAt(--l);return(o>>>0).toString()};function R(C,u,o){return y(C.toString())+y(u.toString())+y(o)}var A=function(u,o,l){var h=u[o],L=u[h.prevCC];if(!L||!L.new&&h.new){u.ccOffset=u.presentationOffset=h.start,h.new=!1;return}for(;(f=L)!==null&&f!==void 0&&f.new;){var f;u.ccOffset+=h.start-L.start,h.new=!1,h=L,L=u[h.prevCC]}u.presentationOffset=l};function x(C,u,o,l,h,L,f,p){var D=new O.VTTParser,S=Object(I.utf8ArrayToStr)(new Uint8Array(C)).trim().replace(M,`
|
|
`).split(`
|
|
`),g=[],c=Object(W.toMpegTsClockFromTimescale)(u,o),d="00:00.000",a=0,E=0,b,T=!0,P=!1;D.oncue=function(G){var Y=l[h],Q=l.ccOffset,z=(a-c)/9e4;if(Y!=null&&Y.new&&(E!==void 0?Q=l.ccOffset=Y.start:A(l,h,z)),z&&(Q=z-l.presentationOffset),P){var j=G.endTime-G.startTime,q=Object(F.normalizePts)((G.startTime+Q-E)*9e4,L*9e4)/9e4;G.startTime=q,G.endTime=q+j}var ae=G.text.trim();G.text=decodeURIComponent(encodeURIComponent(ae)),G.id||(G.id=R(G.startTime,G.endTime,ae)),G.endTime>0&&g.push(G)},D.onparsingerror=function(G){b=G},D.onflush=function(){if(b){p(b);return}f(g)},S.forEach(function(G){if(T)if(k(G,"X-TIMESTAMP-MAP=")){T=!1,P=!0,G.substr(16).split(",").forEach(function(Y){k(Y,"LOCAL:")?d=Y.substr(6):k(Y,"MPEGTS:")&&(a=parseInt(Y.substr(7)))});try{E=v(d)/1e3}catch(Y){P=!1,b=Y}return}else G===""&&(T=!1);D.parse(G+`
|
|
`)}),D.flush()}},"./src/utils/xhr-loader.ts":function(oe,Z,_){"use strict";_.r(Z);var X=_("./src/utils/logger.ts"),O=_("./src/loader/load-stats.ts"),I=/^age:\s*[\d.]+\s*$/m,W=function(){function F(k){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=k?k.xhrSetup:null,this.stats=new O.LoadStats,this.retryDelay=0}var M=F.prototype;return M.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},M.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()))},M.abort=function(){var v;this.abortInternal(),(v=this.callbacks)!==null&&v!==void 0&&v.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},M.load=function(v,y,R){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=y,this.callbacks=R,this.retryDelay=y.retryDelay,this.loadInternal()},M.loadInternal=function(){var v=this.config,y=this.context;if(!v)return;var R=this.loader=new self.XMLHttpRequest,A=this.stats;A.loading.first=0,A.loaded=0;var x=this.xhrSetup;try{if(x)try{x(R,y.url)}catch(o){R.open("GET",y.url,!0),x(R,y.url)}R.readyState||R.open("GET",y.url,!0);var C=this.context.headers;if(C)for(var u in C)R.setRequestHeader(u,C[u])}catch(o){this.callbacks.onError({code:R.status,text:o.message},y,R);return}y.rangeEnd&&R.setRequestHeader("Range","bytes="+y.rangeStart+"-"+(y.rangeEnd-1)),R.onreadystatechange=this.readystatechange.bind(this),R.onprogress=this.loadprogress.bind(this),R.responseType=y.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout),R.send()},M.readystatechange=function(){var v=this.context,y=this.loader,R=this.stats;if(!v||!y)return;var A=y.readyState,x=this.config;if(R.aborted)return;if(A>=2)if(self.clearTimeout(this.requestTimeout),R.loading.first===0&&(R.loading.first=Math.max(self.performance.now(),R.loading.start)),A===4){y.onreadystatechange=null,y.onprogress=null;var C=y.status;if(C>=200&&C<300){R.loading.end=Math.max(self.performance.now(),R.loading.first);var u,o;if(v.responseType==="arraybuffer"?(u=y.response,o=u.byteLength):(u=y.responseText,o=u.length),R.loaded=R.total=o,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(R,v,u,y),!this.callbacks)return;var h={url:y.responseURL,data:u};this.callbacks.onSuccess(h,R,v,y)}else R.retry>=x.maxRetry||C>=400&&C<499?(X.logger.error(C+" while loading "+v.url),this.callbacks.onError({code:C,text:y.statusText},v,y)):(X.logger.warn(C+" 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,x.maxRetryDelay),R.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),x.timeout)},M.loadtimeout=function(){X.logger.warn("timeout while loading "+this.context.url);var v=this.callbacks;v&&(this.abortInternal(),v.onTimeout(this.stats,this.context,this.loader))},M.loadprogress=function(v){var y=this.stats;y.loaded=v.loaded,v.lengthComputable&&(y.total=v.total)},M.getCacheAge=function(){var v=null;if(this.loader&&I.test(this.loader.getAllResponseHeaders())){var y=this.loader.getResponseHeader("age");v=y?parseFloat(y):null}return v},F}();Z.default=W}}).default})},vHTk:function(Et,ot,re){Et.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|