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
945 KiB
367 lines
945 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[168,5,7,17],{"+NIl":function(dt,qe,te){(function(ie){ie(te("VrN/"))})(function(ie){"use strict";ie.defineMode("stex",function(Y,_){"use strict";function V(T,g){T.cmdState.push(g)}function I(T){return T.cmdState.length>0?T.cmdState[T.cmdState.length-1]:null}function P(T){var g=T.cmdState.pop();g&&g.closeBracket()}function B(T){for(var g=T.cmdState,b=g.length-1;b>=0;b--){var u=g[b];if(u.name=="DEFAULT")continue;return u}return{styleIdentifier:function(){return null}}}function N(T,g,b){return function(){this.name=T,this.bracketNo=0,this.style=g,this.styles=b,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var O={};O.importmodule=N("importmodule","tag",["string","builtin"]),O.documentclass=N("documentclass","tag",["","atom"]),O.usepackage=N("usepackage","tag",["atom"]),O.begin=N("begin","tag",["atom"]),O.end=N("end","tag",["atom"]),O.label=N("label","tag",["atom"]),O.ref=N("ref","tag",["atom"]),O.eqref=N("eqref","tag",["atom"]),O.cite=N("cite","tag",["atom"]),O.bibitem=N("bibitem","tag",["atom"]),O.Bibitem=N("Bibitem","tag",["atom"]),O.RBibitem=N("RBibitem","tag",["atom"]),O.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function R(T,g){T.f=g}function f(T,g){var b;if(T.match(/^\\[a-zA-Z@]+/)){var u=T.current().slice(1);return b=O.hasOwnProperty(u)?O[u]:O.DEFAULT,b=new b,V(g,b),R(g,k),b.style}if(T.match(/^\\[$&%#{}_]/))return"tag";if(T.match(/^\\[,;!\/\\]/))return"tag";if(T.match("\\["))return R(g,function(l,h){return c(l,h,"\\]")}),"keyword";if(T.match("\\("))return R(g,function(l,h){return c(l,h,"\\)")}),"keyword";if(T.match("$$"))return R(g,function(l,h){return c(l,h,"$$")}),"keyword";if(T.match("$"))return R(g,function(l,h){return c(l,h,"$")}),"keyword";var a=T.next();if(a=="%")return T.skipToEnd(),"comment";if(a=="}"||a=="]"){if(b=I(g),b)b.closeBracket(a),R(g,k);else return"error";return"bracket"}else return a=="{"||a=="["?(b=O.DEFAULT,b=new b,V(g,b),"bracket"):/\d/.test(a)?(T.eatWhile(/[\w.%]/),"atom"):(T.eatWhile(/[\w\-_]/),b=B(g),b.name=="begin"&&(b.argument=T.current()),b.styleIdentifier())}function c(T,g,b){if(T.eatSpace())return null;if(b&&T.match(b))return R(g,f),"keyword";if(T.match(/^\\[a-zA-Z@]+/))return"tag";if(T.match(/^[a-zA-Z]+/))return"variable-2";if(T.match(/^\\[$&%#{}_]/))return"tag";if(T.match(/^\\[,;!\/]/))return"tag";if(T.match(/^[\^_&]/))return"tag";if(T.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(T.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var u=T.next();return u=="{"||u=="}"||u=="["||u=="]"||u=="("||u==")"?"bracket":u=="%"?(T.skipToEnd(),"comment"):"error"}function k(T,g){var b=T.peek(),u;return b=="{"||b=="["?(u=I(g),u.openBracket(b),T.eat(b),R(g,f),"bracket"):/[ \t\r]/.test(b)?(T.eat(b),null):(R(g,f),P(g),f(T,g))}return{startState:function(){var T=_.inMathMode?function(g,b){return c(g,b)}:f;return{cmdState:[],f:T}},copyState:function(T){return{cmdState:T.cmdState.slice(),f:T.f}},token:function(T,g){return g.f(T,g)},blankLine:function(T){T.f=f,T.cmdState.length=0},lineComment:"%"}}),ie.defineMIME("text/x-stex","stex"),ie.defineMIME("text/x-latex","stex")})},"19Vz":function(dt,qe,te){(function(ie){ie(te("VrN/"))})(function(ie){ie.defineOption("placeholder","",function(N,O,R){var f=R&&R!=ie.Init;if(O&&!f)N.on("blur",I),N.on("change",P),N.on("swapDoc",P),ie.on(N.getInputField(),"compositionupdate",N.state.placeholderCompose=function(){V(N)}),P(N);else if(!O&&f){N.off("blur",I),N.off("change",P),N.off("swapDoc",P),ie.off(N.getInputField(),"compositionupdate",N.state.placeholderCompose),Y(N);var c=N.getWrapperElement();c.className=c.className.replace(" CodeMirror-empty","")}O&&!N.hasFocus()&&I(N)});function Y(N){N.state.placeholder&&(N.state.placeholder.parentNode.removeChild(N.state.placeholder),N.state.placeholder=null)}function _(N){Y(N);var O=N.state.placeholder=document.createElement("pre");O.style.cssText="height: 0; overflow: visible",O.style.direction=N.getOption("direction"),O.className="CodeMirror-placeholder CodeMirror-line-like";var R=N.getOption("placeholder");typeof R=="string"&&(R=document.createTextNode(R)),O.appendChild(R),N.display.lineSpace.insertBefore(O,N.display.lineSpace.firstChild)}function V(N){setTimeout(function(){var O=!1,R=N.getInputField();R.nodeName=="TEXTAREA"?O=!R.value:N.lineCount()==1&&(O=!/[^\u200b]/.test(R.querySelector(".CodeMirror-line").textContent)),O?_(N):Y(N)},20)}function I(N){B(N)&&_(N)}function P(N){var O=N.getWrapperElement(),R=B(N);O.className=O.className.replace(" CodeMirror-empty","")+(R?" CodeMirror-empty":""),R?_(N):Y(N)}function B(N){return N.lineCount()===1&&N.getLine(0)===""}})},"1eCo":function(dt,qe,te){(function(ie){ie(te("VrN/"))})(function(ie){"use strict";var Y={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};ie.defineMode("xml",function(V,I){var P=V.indentUnit,B={},N=I.htmlMode?Y:_;for(var O in N)B[O]=N[O];for(var O in I)B[O]=I[O];var R,f;function c(o,C){function S(F){return C.tokenize=F,F(o,C)}var x=o.next();if(x=="<")return o.eat("!")?o.eat("[")?o.match("CDATA[")?S(g("atom","]]>")):null:o.match("--")?S(g("comment","-->")):o.match("DOCTYPE",!0,!0)?(o.eatWhile(/[\w\._\-]/),S(b(1))):null:o.eat("?")?(o.eatWhile(/[\w\._\-]/),C.tokenize=g("meta","?>"),"meta"):(R=o.eat("/")?"closeTag":"openTag",C.tokenize=k,"tag bracket");if(x=="&"){var M;return o.eat("#")?o.eat("x")?M=o.eatWhile(/[a-fA-F\d]/)&&o.eat(";"):M=o.eatWhile(/[\d]/)&&o.eat(";"):M=o.eatWhile(/[\w\.\-:]/)&&o.eat(";"),M?"atom":"error"}else return o.eatWhile(/[^&<]/),null}c.isInText=!0;function k(o,C){var S=o.next();if(S==">"||S=="/"&&o.eat(">"))return C.tokenize=c,R=S==">"?"endTag":"selfcloseTag","tag bracket";if(S=="=")return R="equals",null;if(S=="<"){C.tokenize=c,C.state=h,C.tagName=C.tagStart=null;var x=C.tokenize(o,C);return x?x+" tag error":"tag error"}else return/[\'\"]/.test(S)?(C.tokenize=T(S),C.stringStartCol=o.column(),C.tokenize(o,C)):(o.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function T(o){var C=function(S,x){for(;!S.eol();)if(S.next()==o){x.tokenize=k;break}return"string"};return C.isInAttribute=!0,C}function g(o,C){return function(S,x){for(;!S.eol();){if(S.match(C)){x.tokenize=c;break}S.next()}return o}}function b(o){return function(C,S){for(var x;(x=C.next())!=null;){if(x=="<")return S.tokenize=b(o+1),S.tokenize(C,S);if(x==">")if(o==1){S.tokenize=c;break}else return S.tokenize=b(o-1),S.tokenize(C,S)}return"meta"}}function u(o,C,S){this.prev=o.context,this.tagName=C,this.indent=o.indented,this.startOfLine=S,(B.doNotIndent.hasOwnProperty(C)||o.context&&o.context.noIndent)&&(this.noIndent=!0)}function a(o){o.context&&(o.context=o.context.prev)}function l(o,C){for(var S;;){if(!o.context)return;if(S=o.context.tagName,!B.contextGrabbers.hasOwnProperty(S)||!B.contextGrabbers[S].hasOwnProperty(C))return;a(o)}}function h(o,C,S){return o=="openTag"?(S.tagStart=C.column(),A):o=="closeTag"?m:h}function A(o,C,S){return o=="word"?(S.tagName=C.current(),f="tag",w):B.allowMissingTagName&&o=="endTag"?(f="tag bracket",w(o,C,S)):(f="error",A)}function m(o,C,S){if(o=="word"){var x=C.current();return S.context&&S.context.tagName!=x&&B.implicitlyClosed.hasOwnProperty(S.context.tagName)&&a(S),S.context&&S.context.tagName==x||B.matchClosing===!1?(f="tag",E):(f="tag error",D)}else return B.allowMissingTagName&&o=="endTag"?(f="tag bracket",E(o,C,S)):(f="error",D)}function E(o,C,S){return o!="endTag"?(f="error",E):(a(S),h)}function D(o,C,S){return f="error",E(o,C,S)}function w(o,C,S){if(o=="word")return f="attribute",y;if(o=="endTag"||o=="selfcloseTag"){var x=S.tagName,M=S.tagStart;return S.tagName=S.tagStart=null,o=="selfcloseTag"||B.autoSelfClosers.hasOwnProperty(x)?l(S,x):(l(S,x),S.context=new u(S,x,M==S.indented)),h}return f="error",w}function y(o,C,S){return o=="equals"?p:(B.allowMissing||(f="error"),w(o,C,S))}function p(o,C,S){return o=="string"?d:o=="word"&&B.allowUnquoted?(f="string",w):(f="error",w(o,C,S))}function d(o,C,S){return o=="string"?d:w(o,C,S)}return{startState:function(o){var C={tokenize:c,state:h,indented:o||0,tagName:null,tagStart:null,context:null};return o!=null&&(C.baseIndent=o),C},token:function(o,C){if(!C.tagName&&o.sol()&&(C.indented=o.indentation()),o.eatSpace())return null;R=null;var S=C.tokenize(o,C);return(S||R)&&S!="comment"&&(f=null,C.state=C.state(R||S,o,C),f&&(S=f=="error"?S+" error":f)),S},indent:function(o,C,S){var x=o.context;if(o.tokenize.isInAttribute)return o.tagStart==o.indented?o.stringStartCol+1:o.indented+P;if(x&&x.noIndent)return ie.Pass;if(o.tokenize!=k&&o.tokenize!=c)return S?S.match(/^(\s*)/)[0].length:0;if(o.tagName)return B.multilineTagIndentPastTag!==!1?o.tagStart+o.tagName.length+2:o.tagStart+P*(B.multilineTagIndentFactor||1);if(B.alignCDATA&&/<!\[CDATA\[/.test(C))return 0;var M=C&&/^<(\/)?([\w_:\.-]*)/.exec(C);if(M&&M[1])for(;x;)if(x.tagName==M[2]){x=x.prev;break}else if(B.implicitlyClosed.hasOwnProperty(x.tagName))x=x.prev;else break;else if(M)for(;x;){var F=B.contextGrabbers[x.tagName];if(F&&F.hasOwnProperty(M[2]))x=x.prev;else break}for(;x&&x.prev&&!x.startOfLine;)x=x.prev;return x?x.indent+P:o.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:B.htmlMode?"html":"xml",helperType:B.htmlMode?"html":"xml",skipAttribute:function(o){o.state==p&&(o.state=w)},xmlCurrentTag:function(o){return o.tagName?{name:o.tagName,close:o.type=="closeTag"}:null},xmlCurrentContext:function(o){for(var C=[],S=o.context;S;S=S.prev)S.tagName&&C.push(S.tagName);return C.reverse()}}}),ie.defineMIME("text/xml","xml"),ie.defineMIME("application/xml","xml"),ie.mimeModes.hasOwnProperty("text/html")||ie.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"30zm":function(dt,qe,te){"use strict";var ie=te("jCWc"),Y=te("kPKH"),_=te("k1fw"),V=te("tJVT"),I=te("PpiC"),P=te("B9cy"),B=te("Ol7k"),N=te("lUTK"),O=te("BvKs"),R=te("q1tI"),f=te.n(R),c=te("Ty5D"),k=te("55Ip"),T=te("9kvl"),g=te("m3rI"),b=te("kzJb"),u=te.n(b),a=O.a.SubMenu,l=B.a.Sider,h=B.a.Content,A=function(E){var D=E.messages,w=E.globalSetting,y=E.loading,p=E.user,d=E.dispatch,o=Object(I.a)(E,["messages","globalSetting","loading","user","dispatch"]),C=Object(c.i)(),S=p.userInfo,x=Object(c.h)(),M=D.tidingsList,F=D.privateMessage,G=D.unreadInfo,J=Object(R.useState)({per_page:10,page:1}),K=Object(V.a)(J,2),j=K[0],q=K[1];Object(R.useEffect)(function(){oe()},[C.userId]);var oe=function(){d({type:"messages/unreadMessageInfo",payload:Object(_.a)(Object(_.a)({},j),C)})};return f.a.createElement(Y.a,{flex:"264px"},f.a.createElement("aside",{className:u.a.userInfo},f.a.createElement("img",{className:"mt40",src:g.a.IMG_SERVER+"/images/"+(S==null?void 0:S.image_url)}),f.a.createElement("p",{className:"font24 mt10"},S==null?void 0:S.username),f.a.createElement("p",{className:"mt20"},S==null?void 0:S.user_identity)),f.a.createElement("ul",{className:u.a.navInfo},f.a.createElement(k.a,{to:"/messages/".concat(S==null?void 0:S.login,"/user_tidings")},f.a.createElement("li",{className:x.pathname.indexOf("user_tidings")>-1&&u.a.actived},"\u6D88\u606F",!!(G!=null&&G.unread_tiding_count)&&f.a.createElement("span",{className:u.a.newTip},G==null?void 0:G.unread_tiding_count))),f.a.createElement(k.a,{to:"/messages/".concat(S==null?void 0:S.login,"/private_messages")},f.a.createElement("li",{className:(x.pathname.indexOf("private_messages")>-1||x.pathname.indexOf("message_detail")>-1)&&u.a.actived},"\u79C1\u4FE1",!!(G!=null&&G.unread_message_count)&&f.a.createElement("span",{className:u.a.newTip},G==null?void 0:G.unread_message_count)))))};qe.a=Object(T.a)(function(m){var E=m.messages,D=m.loading,w=m.user,y=m.globalSetting;return{messages:E,globalSetting:y,user:w,loading:D.effects}})(A)},"55Ip":function(dt,qe,te){"use strict";te.d(qe,"a",function(){return l}),te.d(qe,"b",function(){return w});var ie=te("Ty5D"),Y=te("dI71"),_=te("q1tI"),V=te.n(_),I=te("YS25"),P=te("17x9"),B=te.n(P),N=te("wx14"),O=te("zLVn"),R=te("9R94"),f=function(p){Object(Y.a)(d,p);function d(){for(var C,S=arguments.length,x=new Array(S),M=0;M<S;M++)x[M]=arguments[M];return C=p.call.apply(p,[this].concat(x))||this,C.history=Object(I.a)(C.props),C}var o=d.prototype;return o.render=function(){return V.a.createElement(ie.c,{history:this.history,children:this.props.children})},d}(V.a.Component),c=function(p){Object(Y.a)(d,p);function d(){for(var C,S=arguments.length,x=new Array(S),M=0;M<S;M++)x[M]=arguments[M];return C=p.call.apply(p,[this].concat(x))||this,C.history=Object(I.b)(C.props),C}var o=d.prototype;return o.render=function(){return V.a.createElement(ie.c,{history:this.history,children:this.props.children})},d}(V.a.Component),k=function(d,o){return typeof d=="function"?d(o):d},T=function(d,o){return typeof d=="string"?Object(I.c)(d,null,null,o):d},g=function(d){return d},b=V.a.forwardRef;typeof b=="undefined"&&(b=g);function u(p){return!!(p.metaKey||p.altKey||p.ctrlKey||p.shiftKey)}var a=b(function(p,d){var o=p.innerRef,C=p.navigate,S=p.onClick,x=Object(O.a)(p,["innerRef","navigate","onClick"]),M=x.target,F=Object(N.a)({},x,{onClick:function(J){try{S&&S(J)}catch(K){throw J.preventDefault(),K}!J.defaultPrevented&&J.button===0&&(!M||M==="_self")&&!u(J)&&(J.preventDefault(),C())}});return g!==b?F.ref=d||o:F.ref=o,V.a.createElement("a",F)}),l=b(function(p,d){var o=p.component,C=o===void 0?a:o,S=p.replace,x=p.to,M=p.innerRef,F=Object(O.a)(p,["component","replace","to","innerRef"]);return V.a.createElement(ie.e.Consumer,null,function(G){G||Object(R.a)(!1);var J=G.history,K=T(k(x,G.location),G.location),j=K?J.createHref(K):"",q=Object(N.a)({},F,{href:j,navigate:function(){var ue=k(x,G.location),ge=S?J.replace:J.push;ge(ue)}});return g!==b?q.ref=d||M:q.innerRef=M,V.a.createElement(C,q)})});if(!1)var h,A;var m=function(d){return d},E=V.a.forwardRef;typeof E=="undefined"&&(E=m);function D(){for(var p=arguments.length,d=new Array(p),o=0;o<p;o++)d[o]=arguments[o];return d.filter(function(C){return C}).join(" ")}var w=E(function(p,d){var o=p["aria-current"],C=o===void 0?"page":o,S=p.activeClassName,x=S===void 0?"active":S,M=p.activeStyle,F=p.className,G=p.exact,J=p.isActive,K=p.location,j=p.sensitive,q=p.strict,oe=p.style,ue=p.to,ge=p.innerRef,_e=Object(O.a)(p,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return V.a.createElement(ie.e.Consumer,null,function(be){be||Object(R.a)(!1);var Se=K||be.location,Te=T(k(ue,Se),Se),Ce=Te.pathname,pe=Ce&&Ce.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),se=pe?Object(ie.f)(Se.pathname,{path:pe,exact:G,sensitive:j,strict:q}):null,Re=!!(J?J(se,Se):se),Je=Re?D(F,x):F,Xe=Re?Object(N.a)({},oe,{},M):oe,Ze=Object(N.a)({"aria-current":Re&&C||null,className:Je,style:Xe,to:Te},_e);return m!==E?Ze.ref=d||ge:Ze.innerRef=ge,V.a.createElement(l,Ze)})});if(!1)var y},"7Cbv":function(dt,qe,te){"use strict";var ie=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),Y=new Uint8Array(16);function _(){if(!ie)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ie(Y)}var V=/^(?:[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 I(k){return typeof k=="string"&&V.test(k)}for(var P=I,B=[],N=0;N<256;++N)B.push((N+256).toString(16).substr(1));function O(k){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,g=(B[k[T+0]]+B[k[T+1]]+B[k[T+2]]+B[k[T+3]]+"-"+B[k[T+4]]+B[k[T+5]]+"-"+B[k[T+6]]+B[k[T+7]]+"-"+B[k[T+8]]+B[k[T+9]]+"-"+B[k[T+10]]+B[k[T+11]]+B[k[T+12]]+B[k[T+13]]+B[k[T+14]]+B[k[T+15]]).toLowerCase();if(!P(g))throw TypeError("Stringified UUID is invalid");return g}var R=O;function f(k,T,g){k=k||{};var b=k.random||(k.rng||_)();if(b[6]=b[6]&15|64,b[8]=b[8]&63|128,T){g=g||0;for(var u=0;u<16;++u)T[g+u]=b[u];return T}return R(b)}var c=qe.a=f},"7ahc":function(dt,qe,te){"use strict";te.d(qe,"a",function(){return A});var ie=te("k1fw"),Y=te("0Owb"),_=te("+L6B"),V=te("2/Rp"),I=te("y8nQ"),P=te("Vl3Y"),B=te("tJVT"),N=te("OaEy"),O=te("2fM7"),R=te("q1tI"),f=te.n(R),c=te("VrN/"),k=te.n(c),T=te("p77/"),g=te.n(T),b=te("c5Ni"),u=te.n(b),a=O.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"]};qe.b=function(m){var E=m.callback,D=m.onCancel,w=Object(R.useState)("python"),y=Object(B.a)(w,2),p=y[0],d=y[1];function o(S){d(h[S][1])}function C(S){E(S)}return f.a.createElement(P.a,Object(Y.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:C}),f.a.createElement(P.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},f.a.createElement(O.a,{onChange:o},Object.keys(h).map(function(S){return f.a.createElement(a,{key:S,value:S},h[S][0])}))),f.a.createElement(P.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},f.a.createElement(A,{mode:p})),f.a.createElement("div",{className:"flex-container flex-end"},f.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),f.a.createElement(V.a,{type:"ghost",onClick:D},"\u53D6\u6D88")))};function A(m){var E=m.value,D=m.onChange,w=m.mode,y=m.options,p=y===void 0?{}:y,d=Object(R.useRef)(),o=Object(R.useState)(),C=Object(B.a)(o,2),S=C[0],x=C[1];return Object(R.useEffect)(function(){if(S){function M(F){var G=F.getValue();D&&D(G)}return S.on("change",M),function(){S.off("change",M)}}},[S,D]),Object(R.useEffect)(function(){S&&S.setOption("mode",w)},[S,w]),Object(R.useEffect)(function(){S&&((E!==S.getValue()||E==="")&&setTimeout(function(){S.setValue(E||" ")},300))},[S,E]),Object(R.useEffect)(function(){if(d.current&&!S){var M=k.a.fromTextArea(d.current,Object(ie.a)({mode:w,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},p));x(M)}},[d.current,S]),f.a.createElement("div",{className:"my-codemirror-container"},f.a.createElement("textarea",{ref:d}))}},"8EBN":function(dt,qe,te){(function(ie){ie(te("VrN/"))})(function(ie){"use strict";ie.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 Y=0;Y<ie.modeInfo.length;Y++){var _=ie.modeInfo[Y];_.mimes&&(_.mime=_.mimes[0])}ie.findModeByMIME=function(V){V=V.toLowerCase();for(var I=0;I<ie.modeInfo.length;I++){var P=ie.modeInfo[I];if(P.mime==V)return P;if(P.mimes){for(var B=0;B<P.mimes.length;B++)if(P.mimes[B]==V)return P}}if(/\+xml$/.test(V))return ie.findModeByMIME("application/xml");if(/\+json$/.test(V))return ie.findModeByMIME("application/json")},ie.findModeByExtension=function(V){V=V.toLowerCase();for(var I=0;I<ie.modeInfo.length;I++){var P=ie.modeInfo[I];if(P.ext){for(var B=0;B<P.ext.length;B++)if(P.ext[B]==V)return P}}},ie.findModeByFileName=function(V){for(var I=0;I<ie.modeInfo.length;I++){var P=ie.modeInfo[I];if(P.file&&P.file.test(V))return P}var B=V.lastIndexOf("."),N=B>-1&&V.substring(B+1,V.length);if(N)return ie.findModeByExtension(N)},ie.findModeByName=function(V){V=V.toLowerCase();for(var I=0;I<ie.modeInfo.length;I++){var P=ie.modeInfo[I];if(P.name.toLowerCase()==V)return P;if(P.alias){for(var B=0;B<P.alias.length;B++)if(P.alias[B].toLowerCase()==V)return P}}}})},"8hTe":function(dt,qe,te){dt.exports={button:"button___1wy9m"}},"9Bee":function(dt,qe,te){"use strict";var ie=te("DYRE"),Y=te("zeV3"),_=te("+L6B"),V=te("2/Rp"),I=te("k1fw"),P=te("9og8"),B=te("tJVT"),N=te("WmNS"),O=te.n(N),R=te("q1tI"),f=te.n(R),c=te("vg9a"),k=te("DlQD"),T=te.n(k),g=te("rUJ1");function b(z,s){var v=z.match(/^(\s+)(?:```)/);if(v===null)return s;var W=v[1];return s.split(`
|
|
`).map(function(Q){var H=Q.match(/^\s+/);if(H===null)return Q;var ce=Object(B.a)(H,1),Pe=ce[0];return Pe.length>=W.length?Q.slice(W.length):Q}).join(`
|
|
`)}var u=[],a=["<ul>"],l=new T.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function A(){u.length=0,a=["<ul>"]}var m={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function E(z,s,v,W){if(s>=z.length||z[s].level<=v)return s;var Q=z[s];W.push("<li><a href='#"+Q.anchor+"'>"+Q.text+"</a>"),s++;var H=[];return s=E(z,s,Q.level,H),H.length>0&&(W.push("<ul>"),H.forEach(function(ce){W.push(ce)}),W.push("</ul>")),W.push("</li>"),s=E(z,s,v,W),s}function D(){return E(u,0,0,a),a.push("</ul>"),a.join("")}var w={heading:function(s){var v=h.exec(s);if(v)return{type:"heading",raw:v[0],depth:v[1].length,text:v[2]}},fences:function(s){var v=this.rules.block.fences.exec(s);if(v){var W=v[0],Q=b(W,v[3]||""),H=v[2]?v[2].trim():v[2];if(["latex","katex","math"].indexOf(H)>=0){var ce=d(),Pe=Q;Q=ce,o[ce]={type:"block",expression:Pe}}return{type:"code",raw:W,lang:H,text:Q}}}},y=/(?:\${2})([^\n`]+?)(?:\${2})/gi,p=0,d=function(){return"__special_katext_id_".concat(p++,"__")},o={};function C(){return o}function S(){p=0,o={}}function x(z){return z=z.replace(y,function(s,v){var W=d();return o[W]={type:"inline",expression:v},W}),z}var M=l.listitem;l.listitem=function(z){return M(x(z))};var F=l.paragraph;l.paragraph=function(z){return F(x(z))};var G=l.tablecell;l.tablecell=function(z,s){return G(x(z),s)},l.code=function(z,s,v){var W=(s||"").match(/\S*/)[0];return W?["latex","katex","math"].indexOf(W)>=0?"<p class='editormd-tex'>".concat(z,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(v?z:Object(g.escape)(z,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(v?z:Object(g.escape)(z,!0))+"</code></pre>"},l.heading=function(z,s,v){var W=this.options.headerPrefix+v.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return u.push({anchor:W,level:s,text:z}),"<h"+s+' id="'+W+'">'+z+"</h"+s+">"},T.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),T.a.use({tokenizer:w,renderer:l});var J=T.a,K=te("SJMd"),j=te("ulZh"),q=te.n(j),oe=te("m3rI"),ue=te("Oy/b"),ge=te("p5ED"),_e=te("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 be=function(z,s){return(be=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,W){v.__proto__=W}||function(v,W){for(var Q in W)Object.prototype.hasOwnProperty.call(W,Q)&&(v[Q]=W[Q])})(z,s)};function Se(z,s){function v(){this.constructor=z}be(z,s),z.prototype=s===null?Object.create(s):(v.prototype=s.prototype,new v)}function Te(z,s,v,W){return new(v||(v=Promise))(function(Q,H){function ce(gt){try{Ee(W.next(gt))}catch(Be){H(Be)}}function Pe(gt){try{Ee(W.throw(gt))}catch(Be){H(Be)}}function Ee(gt){var Be;gt.done?Q(gt.value):(Be=gt.value,Be instanceof v?Be:new v(function(wt){wt(Be)})).then(ce,Pe)}Ee((W=W.apply(z,s||[])).next())})}function Ce(z,s){var v,W,Q,H,ce={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return H={next:Pe(0),throw:Pe(1),return:Pe(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function Pe(Ee){return function(gt){return function(Be){if(v)throw new TypeError("Generator is already executing.");for(;ce;)try{if(v=1,W&&(Q=2&Be[0]?W.return:Be[0]?W.throw||((Q=W.return)&&Q.call(W),0):W.next)&&!(Q=Q.call(W,Be[1])).done)return Q;switch(W=0,Q&&(Be=[2&Be[0],Q.value]),Be[0]){case 0:case 1:Q=Be;break;case 4:return ce.label++,{value:Be[1],done:!1};case 5:ce.label++,W=Be[1],Be=[0];continue;case 7:Be=ce.ops.pop(),ce.trys.pop();continue;default:if(!(Q=ce.trys,(Q=Q.length>0&&Q[Q.length-1])||Be[0]!==6&&Be[0]!==2)){ce=0;continue}if(Be[0]===3&&(!Q||Be[1]>Q[0]&&Be[1]<Q[3])){ce.label=Be[1];break}if(Be[0]===6&&ce.label<Q[1]){ce.label=Q[1],Q=Be;break}if(Q&&ce.label<Q[2]){ce.label=Q[2],ce.ops.push(Be);break}Q[2]&&ce.ops.pop(),ce.trys.pop();continue}Be=s.call(z,ce)}catch(wt){Be=[6,wt],W=0}finally{v=Q=0}if(5&Be[0])throw Be[1];return{value:Be[0]?Be[1]:void 0,done:!0}}([Ee,gt])}}}function pe(){for(var z=0,s=0,v=arguments.length;s<v;s++)z+=arguments[s].length;var W=Array(z),Q=0;for(s=0;s<v;s++)for(var H=arguments[s],ce=0,Pe=H.length;ce<Pe;ce++,Q++)W[Q]=H[ce];return W}var se=function(){function z(){}return z.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},z.setAttributes=function(s,v){for(var W=0,Q=v;W<Q.length;W++){var H=Q[W],ce=H[0],Pe=H[1];s.setAttribute(ce,Pe)}},z.createRect=function(s,v,W){var Q=document.createElementNS("http://www.w3.org/2000/svg","rect");return Q.setAttribute("width",s.toString()),Q.setAttribute("height",v.toString()),W&&z.setAttributes(Q,W),Q},z.createLine=function(s,v,W,Q,H){var ce=document.createElementNS("http://www.w3.org/2000/svg","line");return ce.setAttribute("x1",s.toString()),ce.setAttribute("y1",v.toString()),ce.setAttribute("x2",W.toString()),ce.setAttribute("y2",Q.toString()),H&&z.setAttributes(ce,H),ce},z.createPolygon=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg","polygon");return W.setAttribute("points",s),v&&z.setAttributes(W,v),W},z.createCircle=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg","circle");return W.setAttribute("cx",(s/2).toString()),W.setAttribute("cy",(s/2).toString()),W.setAttribute("r",s.toString()),v&&z.setAttributes(W,v),W},z.createEllipse=function(s,v,W){var Q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Q.setAttribute("cx",(s/2).toString()),Q.setAttribute("cy",(v/2).toString()),Q.setAttribute("rx",(s/2).toString()),Q.setAttribute("ry",(v/2).toString()),W&&z.setAttributes(Q,W),Q},z.createGroup=function(s){var v=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&z.setAttributes(v,s),v},z.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},z.createMarker=function(s,v,W,Q,H,ce,Pe){var Ee=document.createElementNS("http://www.w3.org/2000/svg","marker");return z.setAttributes(Ee,[["id",s],["orient",v],["markerWidth",W.toString()],["markerHeight",Q.toString()],["refX",H.toString()],["refY",ce.toString()]]),Ee.appendChild(Pe),Ee},z.createText=function(s){var v=document.createElementNS("http://www.w3.org/2000/svg","text");return v.setAttribute("x","0"),v.setAttribute("y","0"),s&&z.setAttributes(v,s),v},z.createTSpan=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg","tspan");return W.textContent=s,v&&z.setAttributes(W,v),W},z.createImage=function(s){var v=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&z.setAttributes(v,s),v},z.createPoint=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return W.x=s,W.y=v,W},z.createPath=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg","path");return W.setAttribute("d",s),v&&z.setAttributes(W,v),W},z}(),Re=function(){function z(){}return z.addKey=function(s){z.key=s},Object.defineProperty(z,"isLicensed",{get:function(){return!!z.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(z.key)},enumerable:!1,configurable:!0}),z}(),Je=function(){function z(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return z.prototype.rasterize=function(s,v,W){var Q=this;return new Promise(function(H){var ce=W!==void 0?W:document.createElement("canvas");s===null&&(Q.markersOnly=!0,Q.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",v.width.baseVal.valueAsString),Pe.setAttribute("height",v.height.baseVal.valueAsString),Pe.setAttribute("viewBox","0 0 "+v.viewBox.baseVal.width.toString()+" "+v.viewBox.baseVal.height.toString()),Pe.innerHTML=v.innerHTML,Q.naturalSize===!0?(Pe.width.baseVal.value=s.naturalWidth,Pe.height.baseVal.value=s.naturalHeight):Q.width!==void 0&&Q.height!==void 0&&(Pe.width.baseVal.value=Q.width,Pe.height.baseVal.value=Q.height),ce.width=Pe.width.baseVal.value,ce.height=Pe.height.baseVal.value;var Ee=Pe.outerHTML,gt=ce.getContext("2d");Q.markersOnly!==!0&>.drawImage(s,0,0,ce.width,ce.height);var Be=window.URL,wt=new Image(ce.width,ce.height);wt.setAttribute("crossOrigin","anonymous");var Nt=new Blob([Ee],{type:"image/svg+xml"}),Gt=Be.createObjectURL(Nt);wt.onload=function(){gt.drawImage(wt,0,0),Be.revokeObjectURL(Gt);var zr=ce.toDataURL(Q.imageType,Q.imageQuality);H(zr)},wt.src=Gt})},z}(),Xe=function(){},Ze=function(){function z(s){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(z.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(z.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(z.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),z.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},z.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)},z.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 Ke("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Ke("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new Ke("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new Ae("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new Ae("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},z.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},z}(),Ke=function(z,s){this.selector=z,this.style=s},Ae=function(z,s){this.localName=z,this.style=s},ke=function(){function z(s,v,W,Q,H){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=s,this.displayMode=v,this.markerItems=W,this.uiStyleSettings=Q,this.styles=H,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return z.prototype.show=function(s){var v=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 W=document.createElement("div");W.className=this.toolbarBlockStyleClass.name,W.style.whiteSpace="nowrap",this.uiContainer.appendChild(W),this.addActionButton(W,'<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(W,'<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(W,'<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(W,'<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(W,'<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(W,'<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(W,'<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(W,'<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(H){var ce=document.createElement("div");ce.className=""+v.toolbarButtonStyleClass.name,ce.setAttribute("data-type-name",H.typeName),ce.innerHTML=H.icon,ce.addEventListener("click",function(){v.markerToolbarButtonClicked(ce,H)}),v.buttons.push(ce),v.markerButtons.push(ce)}),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 Q=document.createElement("div");Q.className=this.toolbarBlockStyleClass.name,Q.style.whiteSpace="nowrap",Q.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(Q),this.addActionButton(Q,'<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(Q,'<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()},z.prototype.addButtonClickListener=function(s){this.buttonClickListeners.push(s)},z.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},z.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},z.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 v=0;v<this.markerButtons.length;v++)v<s||v===s&&this.markerButtons.length-1===s?this.markerButtonBlock.appendChild(this.markerButtons[v]):(v===s&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[v]))}},z.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")},z.prototype.resetButtonStyles=function(){var s=this;this.buttons.forEach(function(v){v.className=v.className.replace(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name,"").trim(),v.className=v.className.replace(s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:s.toolbarActiveButtonStyleColorsClass.name,"").trim(),v.className+=" "+(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name)})},z.prototype.addActionButton=function(s,v,W){var Q=this,H=document.createElement("div");switch(H.className=""+this.toolbarButtonStyleClass.name,H.innerHTML=v,H.setAttribute("data-action",W),H.addEventListener("click",function(){Q.actionToolbarButtonClicked(H,W)}),W){case"select":H.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":H.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":H.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":H.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":H.style.fill=this.uiStyleSettings.closeButtonColor}s.appendChild(H),this.buttons.push(H)},z.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Ae("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 Ae("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Ae("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new Ae("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 Ae("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Ae("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 Ae("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Ae("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Ke("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new Ke("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},z.prototype.markerToolbarButtonClicked=function(s,v){this.setActiveButton(s),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(W){return W("marker",v)}),this.markerButtonOverflowBlock.style.display="none"},z.prototype.actionToolbarButtonClicked=function(s,v){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(W){return W("action",v)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},z.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)},z.prototype.setActiveMarkerButton=function(s){var v=this.markerButtons.find(function(W){return W.getAttribute("data-type-name")===s});v&&this.setActiveButton(v)},z.prototype.setCurrentMarker=function(s){var v=this;this.currentMarker=s,this.buttons.filter(function(W){return/delete|notes/.test(W.getAttribute("data-action"))}).forEach(function(W){v.currentMarker===void 0?(W.style.fillOpacity="0.4",W.style.pointerEvents="none"):(W.style.fillOpacity="1",W.style.pointerEvents="all")})},z}(),He=function(){function z(s,v,W,Q){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=v,this.uiStyleSettings=W,this.styles=Q,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return z.prototype.addStyles=function(){var s;this.toolboxStyleClass=this.styles.addClass(new Ae("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 Ae("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var v=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new Ae("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new Ae("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new Ae("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 Ae("toolbox-panel-row_colors",`
|
|
background-color: `+((s=this.uiStyleSettings.toolboxBackgroundColor)!==null&&s!==void 0?s:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new Ae("toolbox_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*v)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*v)+`px;
|
|
padding: `+v+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new Ae("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new Ae("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new Ke("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Ke("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},z.prototype.show=function(s){var v;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolboxStyleClass.name+" "+((v=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&v!==void 0?v:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},z.prototype.setPanelButtons=function(s){var v,W,Q=this;this.panels=s,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((v=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&v!==void 0?v:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((W=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&W!==void 0?W:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(H){var ce;H.uiStyleSettings=Q.uiStyleSettings;var Pe=document.createElement("div");Pe.className=Q.toolboxButtonStyleClass.name+" "+((ce=Q.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ce!==void 0?ce:Q.toolboxButtonStyleColorsClass.name),Pe.innerHTML=H.icon,Pe.title=H.title,Pe.addEventListener("click",function(){Q.panelButtonClick(H)}),Q.panelButtons.push(Pe),Q.buttonRow.appendChild(Pe)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},z.prototype.panelButtonClick=function(s){var v=this,W=-1;if(s!==this.activePanel){W=this.panels.indexOf(s),this.panelRow.innerHTML="";var Q=s.getUi();Q.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(Q),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(){v.displayMode==="inline"?v.panelRow.style.display="none":v.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(H,ce){var Pe,Ee;H.className=v.toolboxButtonStyleClass.name+" "+(ce===W?""+((Pe=v.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Pe!==void 0?Pe:v.toolboxActiveButtonStyleColorsClass.name):""+((Ee=v.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Ee!==void 0?Ee:v.toolboxButtonStyleColorsClass.name))})},z}(),$e=function(z,s){this.title=z,this.icon=s},ze=function(z){function s(v,W,Q,H){var ce=z.call(this,v,H||'<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 ce.colors=[],ce.addTransparent=!1,ce.colorBoxes=[],ce.colors=W,ce.currentColor=Q,ce.setCurrentColor=ce.setCurrentColor.bind(ce),ce.getColorBox=ce.getColorBox.bind(ce),ce}return Se(s,z),s.prototype.getUi=function(){var v=this,W=document.createElement("div");return W.style.overflow="hidden",W.style.whiteSpace="nowrap",this.colors.forEach(function(Q){var H=v.getColorBox(Q);W.appendChild(H),v.colorBoxes.push(H)}),W},s.prototype.getColorBox=function(v){var W=this,Q=this.uiStyleSettings.toolbarHeight/4,H=this.uiStyleSettings.toolbarHeight-Q,ce=document.createElement("div");ce.style.display="inline-block",ce.style.boxSizing="content-box",ce.style.width=H-2+"px",ce.style.height=H-2+"px",ce.style.padding="1px",ce.style.marginRight="2px",ce.style.marginBottom="2px",ce.style.borderWidth="2px",ce.style.borderStyle="solid",ce.style.borderRadius=(H+2)/2+"px",ce.style.borderColor=v===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ce.addEventListener("click",function(){W.setCurrentColor(v,ce)});var Pe=document.createElement("div");return Pe.style.display="inline-block",Pe.style.width=H-2+"px",Pe.style.height=H-2+"px",Pe.style.backgroundColor=v,Pe.style.borderRadius=H/2+"px",v==="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>`),ce.appendChild(Pe),ce},s.prototype.setCurrentColor=function(v,W){var Q=this;this.currentColor=v,this.colorBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(v)},s}($e),Ie=function(){function z(s,v,W){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=v,this.globalSettings=W,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(z.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),z.prototype.ownsTarget=function(s){return!1},Object.defineProperty(z.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),z.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},z.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},z.prototype.pointerDown=function(s,v){},z.prototype.dblClick=function(s,v){},z.prototype.manipulate=function(s){},z.prototype.pointerUp=function(s){this.stateChanged()},z.prototype.dispose=function(){},z.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},z.prototype.getState=function(){return{typeName:z.typeName,state:this.state,notes:this.notes}},z.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},z.prototype.scale=function(s,v){},z.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},z.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},z.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)}},z.typeName="MarkerBase",z}(),Fe=function(){function z(){this.findGripByVisual=this.findGripByVisual.bind(this)}return z.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},z}(),ht=function(){function z(){this.GRIP_SIZE=10,this.visual=se.createGroup(),this.visual.appendChild(se.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(se.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return z.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},z}(),at=function(){function z(){}return z.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},z.toSVGMatrix=function(s,v){return s.a=v.a,s.b=v.b,s.c=v.c,s.d=v.d,s.e=v.e,s.f=v.f,s},z}(),tt=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.left=0,H.top=0,H.width=0,H.height=0,H.defaultSize={x:50,y:20},H.offsetX=0,H.offsetY=0,H.rotationAngle=0,H.CB_DISTANCE=10,H._suppressMarkerCreateEvent=!1,H.container.transform.baseVal.appendItem(se.createTransform()),H.setupControlBox(),H}return Se(s,z),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(v){this._visual=v;var W=se.createTransform();this._visual.transform.baseVal.appendItem(W)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(v){return!!z.prototype.ownsTarget.call(this,v)||!!(this.controlGrips.findGripByVisual(v)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(v))},s.prototype.pointerDown=function(v,W){z.prototype.pointerDown.call(this,v,W),this.state==="new"&&(this.left=v.x,this.top=v.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var Q=this.unrotatePoint(v);if(this.manipulationStartX=Q.x,this.manipulationStartY=Q.y,this.offsetX=Q.x-this.left,this.offsetY=Q.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(W),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(W)){this.activeGrip=this.rotatorGrip;var H=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=H.x-this.width/2,this.top=H.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var ce=this.container.transform.baseVal.getItem(0);ce.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(ce,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(v){var W=this.state;z.prototype.pointerUp.call(this,v),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(v),this._state="select",W==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},s.prototype.moveVisual=function(v){this.visual.style.transform="translate("+v.x+"px, "+v.y+"px)"},s.prototype.manipulate=function(v){var W=this.unrotatePoint(v);this.state==="creating"?this.resize(v):this.state==="move"?(this.left=this.manipulationStartLeft+(W.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(W.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(W):this.state==="rotate"&&this.rotate(v)},s.prototype.resize=function(v){var W=this.manipulationStartLeft,Q=this.manipulationStartWidth,H=this.manipulationStartTop,ce=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:W=this.manipulationStartLeft+v.x-this.manipulationStartX,Q=this.manipulationStartWidth+this.manipulationStartLeft-W;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:Q=this.manipulationStartWidth+v.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:H=this.manipulationStartTop+v.y-this.manipulationStartY,ce=this.manipulationStartHeight+this.manipulationStartTop-H;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:ce=this.manipulationStartHeight+v.y-this.manipulationStartY}Q>=0?(this.left=W,this.width=Q):(this.left=W+Q,this.width=-Q),ce>=0?(this.top=H,this.height=ce):(this.top=H+ce,this.height=-ce),this.setSize()},s.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},s.prototype.rotate=function(v){if(Math.abs(v.x-this.centerX)>.1){var W=Math.sign(v.x-this.centerX);this.rotationAngle=180*Math.atan((v.y-this.centerY)/(v.x-this.centerX))/Math.PI+90*W,this.applyRotation()}},s.prototype.applyRotation=function(){var v=this.container.transform.baseVal.getItem(0);v.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(v,0)},s.prototype.rotatePoint=function(v){if(this.rotationAngle===0)return v;var W=this.container.getCTM(),Q=se.createPoint(v.x,v.y);return{x:(Q=Q.matrixTransform(W)).x,y:Q.y}},s.prototype.unrotatePoint=function(v){if(this.rotationAngle===0)return v;var W=this.container.getCTM();W=W.inverse();var Q=se.createPoint(v.x,v.y);return{x:(Q=Q.matrixTransform(W)).x,y:Q.y}},s.prototype.select=function(){z.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){z.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=se.createGroup();var v=se.createTransform();v.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(v),this.container.appendChild(this.controlBox),this.controlRect=se.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=se.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 Fe,this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){var v=this.controlBox.transform.baseVal.getItem(0);v.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(v,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 v=new ht;return v.visual.transform.baseVal.appendItem(se.createTransform()),this.controlBox.appendChild(v.visual),v},s.prototype.positionGrips=function(){var v=this.controlGrips.topLeft.GRIP_SIZE,W=-v/2,Q=W,H=(this.width+this.CB_DISTANCE)/2-v/2,ce=(this.height+this.CB_DISTANCE)/2-v/2,Pe=this.height+this.CB_DISTANCE-v/2,Ee=this.width+this.CB_DISTANCE-v/2;this.positionGrip(this.controlGrips.topLeft.visual,W,Q),this.positionGrip(this.controlGrips.topCenter.visual,H,Q),this.positionGrip(this.controlGrips.topRight.visual,Ee,Q),this.positionGrip(this.controlGrips.centerLeft.visual,W,ce),this.positionGrip(this.controlGrips.centerRight.visual,Ee,ce),this.positionGrip(this.controlGrips.bottomLeft.visual,W,Pe),this.positionGrip(this.controlGrips.bottomCenter.visual,H,Pe),this.positionGrip(this.controlGrips.bottomRight.visual,Ee,Pe),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,H,Q-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(v,W,Q){var H=v.transform.baseVal.getItem(0);H.setTranslate(W,Q),v.transform.baseVal.replaceItem(H,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:at.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:at.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},z.prototype.getState.call(this))},s.prototype.restoreState=function(v){z.prototype.restoreState.call(this,v);var W=v;this.left=W.left,this.top=W.top,this.width=W.width,this.height=W.height,this.rotationAngle=W.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(at.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,W.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(at.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,W.containerTransformMatrix))},s.prototype.scale=function(v,W){z.prototype.scale.call(this,v,W);var Q=this.rotatePoint({x:this.left,y:this.top}),H=this.unrotatePoint({x:Q.x*v,y:Q.y*W});this.left=H.x,this.top=H.y,this.width=this.width*v,this.height=this.height*W,this.adjustControlBox()},s}(Ie),Ye=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.fillColor="transparent",H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.opacity=1,H.setStrokeColor=H.setStrokeColor.bind(H),H.setFillColor=H.setFillColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.createVisual=H.createVisual.bind(H),H}return Se(s,z),s.prototype.ownsTarget=function(v){return!(!z.prototype.ownsTarget.call(this,v)&&v!==this.visual)},s.prototype.createVisual=function(){this.visual=se.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(v,W){z.prototype.pointerDown.call(this,v,W),this.state==="new"&&(this.createVisual(),this.moveVisual(v),this._state="creating")},s.prototype.manipulate=function(v){z.prototype.manipulate.call(this,v)},s.prototype.resize=function(v){z.prototype.resize.call(this,v),this.setSize()},s.prototype.setSize=function(){z.prototype.setSize.call(this),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(v){z.prototype.pointerUp.call(this,v),this.setSize()},s.prototype.setStrokeColor=function(v){this.strokeColor=v,this.visual&&se.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(v),this.stateChanged()},s.prototype.setFillColor=function(v){this.fillColor=v,this.visual&&se.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(v){this.strokeWidth=v,this.visual&&se.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(v){this.strokeDasharray=v,this.visual&&se.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},z.prototype.getState.call(this))},s.prototype.restoreState=function(v){var W=v;this.fillColor=W.fillColor,this.strokeColor=W.strokeColor,this.strokeWidth=W.strokeWidth,this.strokeDasharray=W.strokeDasharray,this.opacity=W.opacity,this.createVisual(),z.prototype.restoreState.call(this,v),this.setSize()},s.prototype.scale=function(v,W){z.prototype.scale.call(this,v,W),this.setSize()},s.title="Rectangle marker",s}(tt),lt=function(z){function s(v,W,Q,H){var ce=z.call(this,v,H||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return ce.widths=[],ce.widthBoxes=[],ce.widths=W,ce.currentWidth=Q,ce.setCurrentWidth=ce.setCurrentWidth.bind(ce),ce}return Se(s,z),s.prototype.getUi=function(){var v=this,W=document.createElement("div");return W.style.display="flex",W.style.overflow="hidden",W.style.flexGrow="2",this.widths.forEach(function(Q){var H=document.createElement("div");H.style.display="flex",H.style.flexGrow="2",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.borderColor=Q===v.currentWidth?v.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){v.setCurrentWidth(Q,H)}),W.appendChild(H);var ce=document.createElement("div");ce.innerText=Q.toString(),ce.style.marginRight="5px",H.appendChild(ce);var Pe=document.createElement("div");Pe.style.minHeight="20px",Pe.style.flexGrow="2",Pe.style.display="flex",Pe.style.alignItems="center";var Ee=document.createElement("hr");Ee.style.minWidth="20px",Ee.style.border="0px",Ee.style.borderTop=Q+"px solid "+v.uiStyleSettings.toolboxColor,Ee.style.flexGrow="2",Pe.appendChild(Ee),H.appendChild(Pe),v.widthBoxes.push(H)}),W},s.prototype.setCurrentWidth=function(v,W){var Q=this;this.currentWidth=v,this.widthBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}($e),et=function(z){function s(v,W,Q,H){var ce=z.call(this,v,H||'<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 ce.styles=[],ce.styleBoxes=[],ce.styles=W,ce.currentStyle=Q,ce.setCurrentStyle=ce.setCurrentStyle.bind(ce),ce}return Se(s,z),s.prototype.getUi=function(){var v=this,W=document.createElement("div");return W.style.display="flex",W.style.overflow="hidden",W.style.flexGrow="2",this.styles.forEach(function(Q){var H=document.createElement("div");H.style.display="flex",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.overflow="hidden",H.style.maxWidth=100/v.styles.length-5+"%",H.style.borderColor=Q===v.currentStyle?v.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){v.setCurrentStyle(Q,H)}),W.appendChild(H);var ce=document.createElement("div");ce.style.minHeight="20px",ce.style.flexGrow="2",ce.style.overflow="hidden";var Pe=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+v.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(Q!==""?'stroke-dasharray="'+Q+'"':"")+` />
|
|
</svg>`;ce.innerHTML=Pe,H.appendChild(ce),v.styleBoxes.push(H)}),W},s.prototype.setCurrentStyle=function(v,W){var Q=this;this.currentStyle=v,this.styleBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}($e),Qe=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.strokePanel=new ze("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new lt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new et("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return Se(s,z),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var v=z.prototype.getState.call(this);return v.typeName=s.typeName,v},s.typeName="FrameMarker",s.title="Frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',s}(Ye),Le=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},st=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.x1=0,H.y1=0,H.x2=0,H.y2=0,H.defaultLength=50,H.manipulationStartX=0,H.manipulationStartY=0,H.manipulationStartX1=0,H.manipulationStartY1=0,H.manipulationStartX2=0,H.manipulationStartY2=0,H.setupControlBox(),H}return Se(s,z),s.prototype.ownsTarget=function(v){return!!z.prototype.ownsTarget.call(this,v)||!(!this.grip1.ownsTarget(v)&&!this.grip2.ownsTarget(v))},s.prototype.pointerDown=function(v,W){z.prototype.pointerDown.call(this,v,W),this.manipulationStartX=v.x,this.manipulationStartY=v.y,this.state==="new"&&(this.x1=v.x,this.y1=v.y,this.x2=v.x,this.y2=v.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(W)?this.activeGrip=this.grip1:this.grip2.ownsTarget(W)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(v){var W=this.state;z.prototype.pointerUp.call(this,v),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(v),this._state="select",W==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},s.prototype.adjustVisual=function(){},s.prototype.manipulate=function(v){this.state==="creating"?this.resize(v):this.state==="move"?(this.x1=this.manipulationStartX1+v.x-this.manipulationStartX,this.y1=this.manipulationStartY1+v.y-this.manipulationStartY,this.x2=this.manipulationStartX2+v.x-this.manipulationStartX,this.y2=this.manipulationStartY2+v.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(v)},s.prototype.resize=function(v){switch(this.activeGrip){case this.grip1:this.x1=v.x,this.y1=v.y;break;case this.grip2:case void 0:this.x2=v.x,this.y2=v.y}this.adjustVisual(),this.adjustControlBox()},s.prototype.select=function(){z.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){z.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=se.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 v=new ht;return v.visual.transform.baseVal.appendItem(se.createTransform()),this.controlBox.appendChild(v.visual),v},s.prototype.positionGrips=function(){var v=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-v/2,this.y1-v/2),this.positionGrip(this.grip2.visual,this.x2-v/2,this.y2-v/2)},s.prototype.positionGrip=function(v,W,Q){var H=v.transform.baseVal.getItem(0);H.setTranslate(W,Q),v.transform.baseVal.replaceItem(H,0)},s.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},z.prototype.getState.call(this))},s.prototype.restoreState=function(v){z.prototype.restoreState.call(this,v);var W=v;this.x1=W.x1,this.y1=W.y1,this.x2=W.x2,this.y2=W.y2},s.prototype.scale=function(v,W){z.prototype.scale.call(this,v,W),this.x1=this.x1*v,this.y1=this.y1*W,this.x2=this.x2*v,this.y2=this.y2*W,this.adjustVisual(),this.adjustControlBox()},s}(Ie),rt=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.setStrokeColor=H.setStrokeColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.strokePanel=new ze("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new lt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new et("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return Se(s,z),s.prototype.ownsTarget=function(v){return!(!z.prototype.ownsTarget.call(this,v)&&v!==this.visual&&v!==this.selectorLine&&v!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.selectorLine=se.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=se.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(v,W){z.prototype.pointerDown.call(this,v,W),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()),se.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),se.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(v){this.strokeColor=v,this.adjustVisual(),this.colorChanged(v)},s.prototype.setStrokeWidth=function(v){this.strokeWidth=v,this.adjustVisual()},s.prototype.setStrokeDasharray=function(v){this.strokeDasharray=v,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 v=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},z.prototype.getState.call(this));return v.typeName=s.typeName,v},s.prototype.restoreState=function(v){z.prototype.restoreState.call(this,v);var W=v;this.strokeColor=W.strokeColor,this.strokeWidth=W.strokeWidth,this.strokeDasharray=W.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}(st),De=function(z){function s(v,W,Q,H){var ce=z.call(this,v,H||'<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 ce.fonts=[],ce.fontBoxes=[],ce.fonts=W,ce.currentFont=Q,ce.setCurrentFont=ce.setCurrentFont.bind(ce),ce}return Se(s,z),s.prototype.getUi=function(){var v=this,W=document.createElement("div");return W.style.overflow="hidden",W.style.flexGrow="2",this.fonts.forEach(function(Q){var H=document.createElement("div");H.style.display="inline-block",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.overflow="hidden",H.style.maxWidth=100/v.fonts.length-5+"%",H.style.borderColor=Q===v.currentFont?v.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){v.setCurrentFont(Q,H)}),W.appendChild(H);var ce=document.createElement("div");ce.style.display="flex",ce.style.minHeight="20px",ce.style.flexGrow="2",ce.style.fontFamily=Q,ce.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",ce.appendChild(Pe),H.appendChild(ce),v.fontBoxes.push(H)}),W},s.prototype.setCurrentFont=function(v,W){var Q=this;this.currentFont=v,this.fontBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}($e),Ne=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.color="transparent",H.padding=5,H.DEFAULT_TEXT="your text here",H.text=H.DEFAULT_TEXT,H.isMoved=!1,H.color=Q.defaultColor,H.fontFamily=Q.defaultFontFamily,H.defaultSize={x:100,y:30},H.setColor=H.setColor.bind(H),H.setFont=H.setFont.bind(H),H.renderText=H.renderText.bind(H),H.sizeText=H.sizeText.bind(H),H.textEditDivClicked=H.textEditDivClicked.bind(H),H.showTextEditor=H.showTextEditor.bind(H),H.setSize=H.setSize.bind(H),H.positionTextEditor=H.positionTextEditor.bind(H),H.colorPanel=new ze("Color",Q.defaultColorSet,Q.defaultColor),H.colorPanel.onColorChanged=H.setColor,H.fontFamilyPanel=new De("Font",Q.defaultFontFamilies,Q.defaultFontFamily),H.fontFamilyPanel.onFontChanged=H.setFont,H}return Se(s,z),s.prototype.ownsTarget=function(v){if(z.prototype.ownsTarget.call(this,v)||v===this.visual||v===this.textElement||v===this.bgRectangle)return!0;var W=!1;return this.textElement.childNodes.forEach(function(Q){Q===v&&(W=!0)}),W},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.bgRectangle=se.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=se.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(se.createTransform()),this.textElement.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(v,W){z.prototype.pointerDown.call(this,v,W),this.isMoved=!1,this.pointerDownPoint=v,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(v),this._state="creating")},s.prototype.renderText=function(){var v=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(W){v.textElement.appendChild(se.createTSpan(W.trim()===""?" ":W.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var v=this.textElement.getBBox(),W=1;if(v.width>0&&v.height>0){var Q=(1*this.width-this.width*this.padding*2/100)/v.width,H=(1*this.height-this.height*this.padding*2/100)/v.height;W=Math.min(Q,H)}return W},s.prototype.getTextPosition=function(v){var W=this.textElement.getBBox(),Q=0,H=0;return W.width>0&&W.height>0&&(Q=(this.width-W.width*v)/2,H=this.height/2-W.height*v/2),{x:Q,y:H}},s.prototype.sizeText=function(){var v=this.textElement.getBBox(),W=this.getTextScale(),Q=this.getTextPosition(W);Q.y-=v.y*W,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+Q.x+"px, "+Q.y+"px) scale("+W+", "+W+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(Q.x,Q.y),this.textElement.transform.baseVal.getItem(1).setScale(W,W))},s.prototype.manipulate=function(v){z.prototype.manipulate.call(this,v),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(v.x-this.pointerDownPoint.x)>5||Math.abs(v.y-this.pointerDownPoint.y)>5)},s.prototype.resize=function(v){z.prototype.resize.call(this,v),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){z.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(v){var W=this.state;W==="creating"&&(this._suppressMarkerCreateEvent=!0),z.prototype.pointerUp.call(this,v),this.setSize(),(W==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},s.prototype.showTextEditor=function(){var v=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(W){W.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var W=Number.parseFloat(v.textEditor.style.fontSize);v.textEditor.clientWidth>=Number.parseInt(v.textEditor.style.maxWidth)&&W>.9;)W-=.1,v.textEditor.style.fontSize=Math.max(W,.9)+"em"}),this.textEditor.addEventListener("keyup",function(W){W.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(W){if(W.clipboardData){var Q=W.clipboardData.getData("text"),H=window.getSelection();if(!H.rangeCount)return!1;H.deleteFromDocument(),H.getRangeAt(0).insertNode(document.createTextNode(Q)),W.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){v.textEditDivClicked(v.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 v=this.getTextScale(),W=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),Q=this.textElement.getBBox(),H={x:Q.width*v,y:Q.height*v};W.x-=H.x/2,W.y-=H.y/2,this.textEditor.style.top=W.y+"px",this.textEditor.style.left=W.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-W.x+"px",this.textEditor.style.fontSize=Math.max(16*v,12)+"px",this.textElement.style.display="none"}},s.prototype.textEditDivClicked=function(v){this.text=v.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},s.prototype.select=function(){z.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),z.prototype.deselect.call(this)},s.prototype.dblClick=function(v,W){z.prototype.dblClick.call(this,v,W),this.showTextEditor()},s.prototype.setColor=function(v){this.textElement&&se.setAttributes(this.textElement,[["fill",v]]),this.color=v,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(v)},s.prototype.setFont=function(v){this.textElement&&se.setAttributes(this.textElement,[["font-family",v]]),this.fontFamily=v,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 v=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},z.prototype.getState.call(this));return v.typeName=s.typeName,v},s.prototype.restoreState=function(v){var W=v;this.color=W.color,this.fontFamily=W.fontFamily,this.padding=W.padding,this.text=W.text,this.createVisual(),z.prototype.restoreState.call(this,v),this.setSize()},s.prototype.scale=function(v,W){z.prototype.scale.call(this,v,W),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}(tt),me=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.color="transparent",H.lineWidth=3,H.drawing=!1,H.pixelRatio=1,H.color=Q.defaultColor,H.lineWidth=Q.defaultStrokeWidth,H.pixelRatio=Q.freehandPixelRatio,H.setColor=H.setColor.bind(H),H.addCanvas=H.addCanvas.bind(H),H.finishCreation=H.finishCreation.bind(H),H.setLineWidth=H.setLineWidth.bind(H),H.colorPanel=new ze("Color",Q.defaultColorSet,Q.defaultColor),H.colorPanel.onColorChanged=H.setColor,H.lineWidthPanel=new lt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.lineWidthPanel.onWidthChanged=H.setLineWidth,H}return Se(s,z),s.prototype.ownsTarget=function(v){return!(!z.prototype.ownsTarget.call(this,v)&&v!==this.visual&&v!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.drawingImage=se.createImage(),this.visual.appendChild(this.drawingImage);var v=se.createTransform();this.visual.transform.baseVal.appendItem(v),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(v,W){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(v.x,v.y),this.drawing=!0):z.prototype.pointerDown.call(this,v,W)},s.prototype.manipulate=function(v){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(v.x,v.y),this.canvasContext.stroke()):z.prototype.manipulate.call(this,v)},s.prototype.resize=function(v){z.prototype.resize.call(this,v),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(v){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):z.prototype.pointerUp.call(this,v)},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(),z.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),z.prototype.deselect.call(this)},s.prototype.finishCreation=function(){for(var v=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),W=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],Q=W[0],H=W[1],ce=W[2],Pe=W[3],Ee=!1,gt=0;gt<this.canvasElement.height;gt++)for(var Be=0;Be<this.canvasElement.width;Be++)v.data[gt*this.canvasElement.width*4+4*Be+3]>0&&(Ee=!0,gt<H&&(H=gt),Be<Q&&(Q=Be),gt>Pe&&(Pe=gt),Be>ce&&(ce=Be));if(Ee){this.left=Q/this.pixelRatio,this.top=H/this.pixelRatio,this.width=(ce-Q)/this.pixelRatio,this.height=(Pe-H)/this.pixelRatio;var wt=document.createElement("canvas");wt.width=ce-Q,wt.height=Pe-H,wt.getContext("2d").putImageData(this.canvasContext.getImageData(Q,H,ce-Q,Pe-H),0,0),this.drawingImgUrl=wt.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},s.prototype.setDrawingImage=function(){se.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(v){this.color=v,this.colorChanged(v)},s.prototype.setLineWidth=function(v){this.lineWidth=v},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 v=Object.assign({drawingImgUrl:this.drawingImgUrl},z.prototype.getState.call(this));return v.typeName=s.typeName,v},s.prototype.restoreState=function(v){this.createVisual(),z.prototype.restoreState.call(this,v),this.drawingImgUrl=v.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(v,W){z.prototype.scale.call(this,v,W),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}(tt),de=function(z){function s(v,W,Q){var H=z.call(this,v,Q||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return H.typeBoxes=[],H.currentType=W,H.setCurrentType=H.setCurrentType.bind(H),H}return Se(s,z),s.prototype.getUi=function(){var v=this,W=document.createElement("div");W.style.display="flex",W.style.overflow="hidden",W.style.flexGrow="2";for(var Q=function(Pe){var Ee="both";switch(Pe){case 0:Ee="both";break;case 1:Ee="start";break;case 2:Ee="end";break;case 3:Ee="none"}var gt=document.createElement("div");if(gt.style.display="flex",gt.style.flexGrow="2",gt.style.alignItems="center",gt.style.justifyContent="space-between",gt.style.padding="5px",gt.style.borderWidth="2px",gt.style.borderStyle="solid",gt.style.borderColor=Ee===H.currentType?H.uiStyleSettings.toolboxAccentColor:"transparent",gt.addEventListener("click",function(){v.setCurrentType(Ee,gt)}),W.appendChild(gt),Ee==="both"||Ee==="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="`+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Be.style.marginLeft="5px",gt.appendChild(Be)}var wt=document.createElement("div");wt.style.display="flex",wt.style.alignItems="center",wt.style.minHeight="20px",wt.style.flexGrow="2";var Nt=document.createElement("hr");if(Nt.style.minWidth="20px",Nt.style.border="0px",Nt.style.borderTop="3px solid "+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee"),Nt.style.flexGrow="2",wt.appendChild(Nt),gt.appendChild(wt),Ee==="both"||Ee==="end"){var Gt=document.createElement("div");Gt.style.display="flex",Gt.style.alignItems="center",Gt.style.minHeight="20px",Gt.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="`+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Gt.style.marginRight="5px",gt.appendChild(Gt)}H.typeBoxes.push(gt)},H=this,ce=0;ce<4;ce++)Q(ce);return W},s.prototype.setCurrentType=function(v,W){var Q=this;this.currentType=v,this.typeBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings!==void 0?Q.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}($e),fe=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.arrowType="end",H.arrowBaseHeight=10,H.arrowBaseWidth=10,H.getArrowPoints=H.getArrowPoints.bind(H),H.setArrowType=H.setArrowType.bind(H),H.arrowTypePanel=new de("Arrow type","end"),H.arrowTypePanel.onArrowTypeChanged=H.setArrowType,H}return Se(s,z),s.prototype.ownsTarget=function(v){return!(!z.prototype.ownsTarget.call(this,v)&&v!==this.arrow1&&v!==this.arrow2)},s.prototype.getArrowPoints=function(v,W){var Q=this.arrowBaseWidth+2*this.strokeWidth,H=this.arrowBaseHeight+2*this.strokeWidth;return v-Q/2+","+(W+H/2)+" "+v+","+(W-H/2)+" "+(v+Q/2)+","+(W+H/2)},s.prototype.createTips=function(){this.arrow1=se.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=se.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(v,W){z.prototype.pointerDown.call(this,v,W),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(z.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",se.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),se.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var v=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),W=this.arrow1.transform.baseVal.getItem(0);W.setRotate(v,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(W,0);var Q=this.arrow2.transform.baseVal.getItem(0);Q.setRotate(v+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(Q,0)}},s.prototype.setArrowType=function(v){this.arrowType=v,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 v=Object.assign({arrowType:this.arrowType},z.prototype.getState.call(this));return v.typeName=s.typeName,v},s.prototype.restoreState=function(v){z.prototype.restoreState.call(this,v);var W=v;this.arrowType=W.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}(rt),ee=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.fillColor=Q.defaultFillColor,H.strokeWidth=0,H.fillPanel=new ze("Color",Q.defaultColorSet,Q.defaultFillColor),H.fillPanel.onColorChanged=H.setFillColor,H}return Se(s,z),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var v=z.prototype.getState.call(this);return v.typeName=s.typeName,v},s.typeName="CoverMarker",s.title="Cover marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',s}(Ye),re=function(z){function s(v,W,Q,H){var ce=z.call(this,v,H||'<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 ce.opacities=[],ce.opacityBoxes=[],ce.opacities=W,ce.currentOpacity=Q,ce.setCurrentOpacity=ce.setCurrentOpacity.bind(ce),ce}return Se(s,z),s.prototype.getUi=function(){var v=this,W=document.createElement("div");return W.style.display="flex",W.style.overflow="hidden",W.style.flexGrow="2",W.style.justifyContent="space-between",this.opacities.forEach(function(Q){var H=document.createElement("div");H.style.display="flex",H.style.alignItems="center",H.style.justifyContent="center",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.borderColor=Q===v.currentOpacity?v.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){v.setCurrentOpacity(Q,H)}),W.appendChild(H);var ce=document.createElement("div");ce.innerText=100*Q+"%",H.appendChild(ce),v.opacityBoxes.push(H)}),W},s.prototype.setCurrentOpacity=function(v,W){var Q=this;this.currentOpacity=v,this.opacityBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}($e),ne=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.setOpacity=H.setOpacity.bind(H),H.fillColor=Q.defaultHighlightColor,H.strokeWidth=0,H.opacity=Q.defaultHighlightOpacity,H.fillPanel=new ze("Color",Q.defaultColorSet,H.fillColor),H.fillPanel.onColorChanged=H.setFillColor,H.opacityPanel=new re("Opacity",Q.defaultOpacitySteps,H.opacity),H.opacityPanel.onOpacityChanged=H.setOpacity,H}return Se(s,z),s.prototype.setOpacity=function(v){this.opacity=v,this.visual&&se.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 v=z.prototype.getState.call(this);return v.typeName=s.typeName,v},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),ae='<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>',ye=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.bgColor="transparent",H.tipPosition={x:0,y:0},H.tipBase1Position={x:0,y:0},H.tipBase2Position={x:0,y:0},H.tipMoving=!1,H.color=Q.defaultStrokeColor,H.bgColor=Q.defaultFillColor,H.fontFamily=Q.defaultFontFamily,H.defaultSize={x:100,y:30},H.setBgColor=H.setBgColor.bind(H),H.getTipPoints=H.getTipPoints.bind(H),H.positionTip=H.positionTip.bind(H),H.setTipPoints=H.setTipPoints.bind(H),H.colorPanel=new ze("Text color",Q.defaultColorSet,H.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>'),H.colorPanel.onColorChanged=H.setColor,H.bgColorPanel=new ze("Fill color",Q.defaultColorSet,H.bgColor,ae),H.bgColorPanel.onColorChanged=H.setBgColor,H.fontFamilyPanel=new De("Font",Q.defaultFontFamilies,Q.defaultFontFamily),H.fontFamilyPanel.onFontChanged=H.setFont,H.tipGrip=new ht,H.tipGrip.visual.transform.baseVal.appendItem(se.createTransform()),H.controlBox.appendChild(H.tipGrip.visual),H}return Se(s,z),s.prototype.ownsTarget=function(v){return z.prototype.ownsTarget.call(this,v)||this.tipGrip.ownsTarget(v)||this.tip===v},s.prototype.createTip=function(){se.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=se.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(v,W){this.state==="new"&&z.prototype.pointerDown.call(this,v,W),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(W)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):z.prototype.pointerDown.call(this,v,W)},s.prototype.pointerUp=function(v){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,z.prototype.pointerUp.call(this,v);else{var W=this.state==="creating";z.prototype.pointerUp.call(this,v),this.setTipPoints(W),this.positionTip()}},s.prototype.manipulate=function(v){if(this.tipMoving){var W=this.unrotatePoint(v);this.tipPosition={x:W.x-this.manipulationStartLeft,y:W.y-this.manipulationStartTop},this.positionTip()}else z.prototype.manipulate.call(this,v)},s.prototype.setBgColor=function(v){this.bgRectangle&&this.tip&&(se.setAttributes(this.bgRectangle,[["fill",v]]),se.setAttributes(this.tip,[["fill",v]])),this.bgColor=v,this.fillColorChanged(v)},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(v){v===void 0&&(v=!1);var W=Math.min(this.height/2,15),Q=this.height/5;v&&(this.tipPosition={x:W+Q/2,y:this.height+20});var H=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?H<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(Q=this.width/5,W=Math.min(this.width/2,15),this.tipBase1Position={x:W,y:0},this.tipBase2Position={x:W+Q,y:0}):(this.tipBase1Position={x:0,y:W},this.tipBase2Position={x:0,y:W+Q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?H<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(Q=this.width/5,W=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-W-Q,y:0},this.tipBase2Position={x:this.width-W,y:0}):(this.tipBase1Position={x:this.width,y:W},this.tipBase2Position={x:this.width,y:W+Q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?H<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(Q=this.width/5,W=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-W-Q,y:this.height},this.tipBase2Position={x:this.width-W,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-W-Q},this.tipBase2Position={x:this.width,y:this.height-W}):H<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(Q=this.width/5,W=Math.min(this.width/2,15),this.tipBase1Position={x:W,y:this.height},this.tipBase2Position={x:W+Q,y:this.height}):(this.tipBase1Position={x:0,y:this.height-W},this.tipBase2Position={x:0,y:this.height-W-Q})},s.prototype.resize=function(v){z.prototype.resize.call(this,v),this.positionTip()},s.prototype.positionTip=function(){se.setAttributes(this.tip,[["points",this.getTipPoints()]]);var v=this.tipGrip.visual.transform.baseVal.getItem(0);v.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(v,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(),z.prototype.select.call(this)},s.prototype.getState=function(){var v=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},z.prototype.getState.call(this));return v.typeName=s.typeName,v},s.prototype.restoreState=function(v){var W=v;this.bgColor=W.bgColor,this.tipPosition=W.tipPosition,z.prototype.restoreState.call(this,v),this.createTip(),this.setTipPoints()},s.prototype.scale=function(v,W){z.prototype.scale.call(this,v,W),this.tipPosition={x:this.tipPosition.x*v,y:this.tipPosition.y*W},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}(Ne),we=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.fillColor="transparent",H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.opacity=1,H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.fillColor=Q.defaultFillColor,H.setStrokeColor=H.setStrokeColor.bind(H),H.setFillColor=H.setFillColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.setOpacity=H.setOpacity.bind(H),H.createVisual=H.createVisual.bind(H),H.strokePanel=new ze("Line color",pe(Q.defaultColorSet,["transparent"]),Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.fillPanel=new ze("Fill color",pe(Q.defaultColorSet,["transparent"]),H.fillColor,ae),H.fillPanel.onColorChanged=H.setFillColor,H.strokeWidthPanel=new lt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new et("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H.opacityPanel=new re("Opacity",Q.defaultOpacitySteps,H.opacity),H.opacityPanel.onOpacityChanged=H.setOpacity,H}return Se(s,z),s.prototype.ownsTarget=function(v){return!(!z.prototype.ownsTarget.call(this,v)&&v!==this.visual)},s.prototype.createVisual=function(){this.visual=se.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(v,W){z.prototype.pointerDown.call(this,v,W),this.state==="new"&&(this.createVisual(),this.moveVisual(v),this._state="creating")},s.prototype.manipulate=function(v){z.prototype.manipulate.call(this,v)},s.prototype.resize=function(v){z.prototype.resize.call(this,v),this.setSize()},s.prototype.setSize=function(){z.prototype.setSize.call(this),se.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(v){z.prototype.pointerUp.call(this,v),this.setSize()},s.prototype.setStrokeColor=function(v){this.strokeColor=v,this.visual&&se.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(v),this.stateChanged()},s.prototype.setFillColor=function(v){this.fillColor=v,this.visual&&se.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(v),this.stateChanged()},s.prototype.setStrokeWidth=function(v){this.strokeWidth=v,this.visual&&se.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(v){this.strokeDasharray=v,this.visual&&se.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.setOpacity=function(v){this.opacity=v,this.visual&&se.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 v=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},z.prototype.getState.call(this));return v.typeName=s.typeName,v},s.prototype.restoreState=function(v){var W=v;this.fillColor=W.fillColor,this.strokeColor=W.strokeColor,this.strokeWidth=W.strokeWidth,this.strokeDasharray=W.strokeDasharray,this.opacity=W.opacity,this.createVisual(),z.prototype.restoreState.call(this,v),this.setSize()},s.prototype.scale=function(v,W){z.prototype.scale.call(this,v,W),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}(tt),je=function(z){function s(v,W,Q){return z.call(this,v,W,Q)||this}return Se(s,z),Object.defineProperty(s.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(v){return!(!z.prototype.ownsTarget.call(this,v)&&v!==this.tip1&&v!==this.tip2)},s.prototype.createTips=function(){this.tip1=se.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(se.createTransform()),this.visual.appendChild(this.tip1),this.tip2=se.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(se.createTransform()),this.visual.appendChild(this.tip2)},s.prototype.pointerDown=function(v,W){z.prototype.pointerDown.call(this,v,W),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(z.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(se.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()]]),se.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 v=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),W=this.tip1.transform.baseVal.getItem(0);W.setRotate(v,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(W,0);var Q=this.tip2.transform.baseVal.getItem(0);Q.setRotate(v+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(Q,0)}},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var v=z.prototype.getState.call(this);return v.typeName=s.typeName,v},s.prototype.restoreState=function(v){z.prototype.restoreState.call(this,v),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}(rt),ot=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.strokePanel.colors=Q.defaultColorSet,H.fillColor="transparent",H}return Se(s,z),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var v=z.prototype.getState.call(this);return v.typeName=s.typeName,v},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}(we),xt=function(){function z(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(z.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),z.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))},z.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},z.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},z.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}},z.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},z}(),Oe=function(z){function s(v,W,Q){var H=z.call(this,v,W,Q)||this;return H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.curveX=0,H.curveY=0,H.manipulationStartCurveX=0,H.manipulationStartCurveY=0,H.setStrokeColor=H.setStrokeColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.positionGrips=H.positionGrips.bind(H),H.addControlGrips=H.addControlGrips.bind(H),H.adjustVisual=H.adjustVisual.bind(H),H.setupControlBox=H.setupControlBox.bind(H),H.resize=H.resize.bind(H),H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.strokePanel=new ze("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new lt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new et("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return Se(s,z),s.prototype.ownsTarget=function(v){return!(!z.prototype.ownsTarget.call(this,v)&&v!==this.visual&&v!==this.selectorCurve&&v!==this.visibleCurve&&!this.curveGrip.ownsTarget(v))},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=se.createGroup(),this.selectorCurve=se.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=se.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(v,W){z.prototype.pointerDown.call(this,v,W),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=v.x,this.curveY=v.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(W)&&(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()),se.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),se.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){z.prototype.setupControlBox.call(this),this.curveControlLine1=se.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=se.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,z.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){z.prototype.positionGrips.call(this);var v=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-v/2,this.curveY-v/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(v){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+v.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+v.y-this.manipulationStartY),z.prototype.manipulate.call(this,v)},s.prototype.resize=function(v){this.activeGrip===this.curveGrip&&(this.curveX=v.x,this.curveY=v.y),z.prototype.resize.call(this,v),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(v){this.strokeColor=v,this.adjustVisual(),this.colorChanged(v)},s.prototype.setStrokeWidth=function(v){this.strokeWidth=v,this.adjustVisual()},s.prototype.setStrokeDasharray=function(v){this.strokeDasharray=v,this.adjustVisual()},s.prototype.scale=function(v,W){this.curveX=this.curveX*v,this.curveY=this.curveY*W,z.prototype.scale.call(this,v,W)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var v=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},z.prototype.getState.call(this));return v.typeName=s.typeName,v},s.prototype.restoreState=function(v){z.prototype.restoreState.call(this,v);var W=v;this.strokeColor=W.strokeColor,this.strokeWidth=W.strokeWidth,this.strokeDasharray=W.strokeDasharray,this.curveX=W.curveX,this.curveY=W.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}(st),ct=function(){function z(s,v){v===void 0&&(v=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=v}return Object.defineProperty(z.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),z.prototype.preventDefault=function(){this._defaultPrevented=!0},z}(),ft=function(z){function s(v,W,Q){var H=z.call(this,v,!1)||this;return H.dataUrl=W,H.state=Q,H}return Se(s,z),s}(ct),Ge=function(z){function s(v,W,Q){Q===void 0&&(Q=!1);var H=z.call(this,v,Q)||this;return H.marker=W,H}return Se(s,z),s}(ct),_t=function(){function z(){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 z.prototype.addEventListener=function(s,v){this[s].push(v)},z.prototype.removeEventListener=function(s,v){var W=this[s].indexOf(v);W>-1&&this[s].splice(W,1)},z}(),Ct=function(){function z(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 Le,this._isOpen=!1,this.undoRedoManager=new xt,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 _t,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=z.instanceCounter++,this.styles=new Ze(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(z.prototype,"ALL_MARKER_TYPES",{get:function(){return[Qe,me,fe,Ne,ot,we,ne,ye,je,ee,rt,Oe]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[Qe,me,fe,Ne,we,ne,ye]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"BASIC_MARKER_TYPES",{get:function(){return[Qe,me,fe,Ne,ne]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var v=this;this._availableMarkerTypes.splice(0),s.forEach(function(W){if(typeof W=="string"){var Q=v.ALL_MARKER_TYPES.find(function(H){return H.typeName===W});Q!==void 0&&v._availableMarkerTypes.push(Q)}else v._availableMarkerTypes.push(W)})},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.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(z.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),z.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),Re.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},z.prototype.show=function(){var s=this;this.styles.styleSheetRoot===void 0&&Xe.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=Xe.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(v){return v(new ct(s))})},z.prototype.render=function(){return Te(this,void 0,void 0,function(){var s;return Ce(this,function(v){switch(v.label){case 0:return this.setCurrentMarker(),(s=new Je).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 v.sent(),[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,v.sent()]}})})},z.prototype.close=function(s){var v=this;if(s===void 0&&(s=!1),this.isOpen){var W=!1;s||this.eventListeners.beforeclose.forEach(function(Q){var H=new ct(v,!0);Q(H),H.defaultPrevented&&(W=!0)}),W||(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(Q){return Q(new ct(v))}),this.detachEvents(),this._isOpen=!1)}},z.prototype.addMarkersToToolbar=function(){for(var s,v=[],W=0;W<arguments.length;W++)v[W]=arguments[W];(s=this._availableMarkerTypes).push.apply(s,v)},z.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(v){s(v.dataUrl,v.state)})},z.prototype.removeRenderEventListener=function(s){},z.prototype.addCloseEventListener=function(s){this.addEventListener("close",function(){s()})},z.prototype.removeCloseEventListener=function(s){},z.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))},z.prototype.onPopupTargetResize=function(){var s=1*this.target.clientWidth/this.target.clientHeight,v=this.editorCanvas.clientWidth/s>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*s:this.editorCanvas.clientWidth,W=v<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/s;this.resize(v,W)},z.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},z.prototype.resize=function(s,v){this._isResizing=!0;var W=s/this.imageWidth,Q=v/this.imageHeight;this.imageWidth=Math.round(s),this.imageHeight=Math.round(v),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(W,Q),this._isResizing=!1},z.prototype.scaleMarkers=function(s,v){var W,Q=this;this._currentMarker&&this._currentMarker instanceof Ne?this._currentMarker.scale(s,v):(W=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(H){H!==Q._currentMarker&&H.scale(s,v)}),W!==void 0&&this.setCurrentMarker(W)},z.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"},z.prototype.setTopLeft=function(){var s=this.editingTarget.getBoundingClientRect(),v=this.editorCanvas.getBoundingClientRect();this.left=s.left-v.left,this.top=s.top-v.top},z.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)},z.prototype.addDefs=function(){for(var s,v=[],W=0;W<arguments.length;W++)v[W]=arguments[W];this.defs=se.createDefs(),this.addDefsToImage(),(s=this.defs).append.apply(s,v)},z.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},z.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)},z.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},z.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},z.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)},z.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},z.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)},z.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()},z.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")},z.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"},z.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},z.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 ke(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 He(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},z.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},z.prototype.removeMarker=function(s){this.markerImage.removeChild(s.container),this.markers.indexOf(s)>-1&&this.markers.splice(this.markers.indexOf(s),1),s.dispose()},z.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())},z.prototype.toolbarButtonClicked=function(s,v){if(s==="marker"&&v!==void 0)this.createNewMarker(v);else if(s==="action")switch(v){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()}},z.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var v=!1;if(this.eventListeners.markerbeforedelete.forEach(function(Q){var H=new Ge(s,s._currentMarker,!0);Q(H),H.defaultPrevented&&(v=!0)}),!v){var W=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(Q){return Q(new Ge(s,W))})}}},z.prototype.clear=function(){var s=this,v=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ce){var Pe=new Ge(s,void 0,!0);ce(Pe),Pe.defaultPrevented&&(v=!0)}),!v)){this.setCurrentMarker();for(var W=function(ce){var Pe=Q.markers[ce];Q.setCurrentMarker(Q.markers[ce]),Q._currentMarker.dispose(),Q.markerImage.removeChild(Q._currentMarker.container),Q.markers.splice(Q.markers.indexOf(Q._currentMarker),1),Q.eventListeners.markerdelete.forEach(function(Ee){return Ee(new Ge(s,Pe))})},Q=this,H=this.markers.length-1;H>=0;H--)W(H);this.addUndoStep()}},Object.defineProperty(z.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),z.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))},z.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)},z.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},z.prototype.addUndoStep=function(){var s=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var v=this.getState(),W=this.undoRedoManager.getLastUndoStep();if(!W||W.width===v.width&&W.height===v.height){var Q=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(v),Q<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(H){return H(new ct(s))})}else this.undoRedoManager.replaceLastUndoStep(v),this.eventListeners.statechange.forEach(function(H){return H(new ct(s))})}},z.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},z.prototype.undoStep=function(){var s=this,v=this.undoRedoManager.undo();v!==void 0&&(this.restoreState(v),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(W){return W(new ct(s))}))},z.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},z.prototype.redoStep=function(){var s=this,v=this.undoRedoManager.redo();v!==void 0&&(this.restoreState(v),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(W){return W(new ct(s))}))},z.prototype.stepZoom=function(){var s=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=s<this.zoomSteps.length-1?this.zoomSteps[s+1]:this.zoomSteps[0]},z.prototype.panTo=function(s){this.contentDiv.scrollBy({left:this.prevPanPoint.x-s.x,top:this.prevPanPoint.y-s.y}),this.prevPanPoint=s},z.prototype.startRenderAndClose=function(){return Te(this,void 0,void 0,function(){var s,v,W=this;return Ce(this,function(Q){switch(Q.label){case 0:return[4,this.render()];case 1:return s=Q.sent(),v=this.getState(),this.eventListeners.render.forEach(function(H){return H(new ft(W,s,v))}),this.close(!0),[2]}})})},z.prototype.getState=function(s){s===!0&&this.setCurrentMarker();var v={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(W){return v.markers.push(W.getState())}),v},z.prototype.restoreState=function(s){var v=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);s.markers.forEach(function(W){var Q=v._availableMarkerTypes.find(function(ce){return ce.typeName===W.typeName});if(Q!==void 0){var H=v.addNewMarker(Q);H.restoreState(W),v.markers.push(H)}}),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(W){return W(new ct(v))})},z.prototype.addNewMarker=function(s){var v=se.createGroup();return this.markerImage.appendChild(v),new s(v,this.overlayContainer,this.settings)},z.prototype.createNewMarker=function(s){var v,W=this;(v=typeof s=="string"?this._availableMarkerTypes.find(function(Q){return Q.typeName===s}):s)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(v),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(v.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(Q){return Q(new Ge(W,W._currentMarker))}))},z.prototype.markerCreated=function(s){var v=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof me&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(me):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(W){return W(new Ge(v,v._currentMarker))})},z.prototype.colorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=s,this.settings.defaultStrokeColor=s)},z.prototype.fillColorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=s)},z.prototype.markerStateChanged=function(s){var v=this;this.eventListeners.markerchange.forEach(function(W){return W(new Ge(v,s))})},z.prototype.setCurrentMarker=function(s){var v=this;this._currentMarker!==s&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(W){return W(new Ge(v,v._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(W){return W(new Ge(v,v._currentMarker))}))},z.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 v=this.markers.find(function(W){return W.ownsTarget(s.target)});v!==void 0?(this.setCurrentMarker(v),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))},z.prototype.onDblClick=function(s){if(this._isFocused||this.focus(),this.mode==="select"){var v=this.markers.find(function(W){return W.ownsTarget(s.target)});v!==void 0&&v!==this._currentMarker&&this.setCurrentMarker(v),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target):this.setCurrentMarker()}},z.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}))},z.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()},z.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},z.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},z.prototype.clientToLocalCoordinates=function(s,v){var W=this.markerImage.getBoundingClientRect();return{x:(s-W.left)/this.zoomLevel,y:(v-W.top)/this.zoomLevel}},z.prototype.onWindowResize=function(){this.positionUI()},z.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()},z.prototype.addLicenseKey=function(s){Re.addKey(s)},z.prototype.addEventListener=function(s,v){this.eventListeners.addEventListener(s,v)},z.prototype.removeEventListener=function(s,v){this.eventListeners.removeEventListener(s,v)},z.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(z.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),z.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(v){return v(new ct(s))}))},z.prototype.blur=function(){var s=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(v){return v(new ct(s))}))},z.instanceCounter=0,z}();/* **********************************
|
|
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 Ut=function(z,s){return(Ut=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,W){v.__proto__=W}||function(v,W){for(var Q in W)Object.prototype.hasOwnProperty.call(W,Q)&&(v[Q]=W[Q])})(z,s)};function Ft(z,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function v(){this.constructor=z}Ut(z,s),z.prototype=s===null?Object.create(s):(v.prototype=s.prototype,new v)}function Dt(z,s,v,W){return new(v||(v=Promise))(function(Q,H){function ce(gt){try{Ee(W.next(gt))}catch(Be){H(Be)}}function Pe(gt){try{Ee(W.throw(gt))}catch(Be){H(Be)}}function Ee(gt){var Be;gt.done?Q(gt.value):(Be=gt.value,Be instanceof v?Be:new v(function(wt){wt(Be)})).then(ce,Pe)}Ee((W=W.apply(z,s||[])).next())})}function sr(z,s){var v,W,Q,H,ce={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return H={next:Pe(0),throw:Pe(1),return:Pe(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function Pe(Ee){return function(gt){return function(Be){if(v)throw new TypeError("Generator is already executing.");for(;ce;)try{if(v=1,W&&(Q=2&Be[0]?W.return:Be[0]?W.throw||((Q=W.return)&&Q.call(W),0):W.next)&&!(Q=Q.call(W,Be[1])).done)return Q;switch(W=0,Q&&(Be=[2&Be[0],Q.value]),Be[0]){case 0:case 1:Q=Be;break;case 4:return ce.label++,{value:Be[1],done:!1};case 5:ce.label++,W=Be[1],Be=[0];continue;case 7:Be=ce.ops.pop(),ce.trys.pop();continue;default:if(!(Q=ce.trys,(Q=Q.length>0&&Q[Q.length-1])||Be[0]!==6&&Be[0]!==2)){ce=0;continue}if(Be[0]===3&&(!Q||Be[1]>Q[0]&&Be[1]<Q[3])){ce.label=Be[1];break}if(Be[0]===6&&ce.label<Q[1]){ce.label=Q[1],Q=Be;break}if(Q&&ce.label<Q[2]){ce.label=Q[2],ce.ops.push(Be);break}Q[2]&&ce.ops.pop(),ce.trys.pop();continue}Be=s.call(z,ce)}catch(wt){Be=[6,wt],W=0}finally{v=Q=0}if(5&Be[0])throw Be[1];return{value:Be[0]?Be[1]:void 0,done:!0}}([Ee,gt])}}}var rr=function(){function z(){}return z.addKey=function(s){z.key=s},Object.defineProperty(z,"isLicensed",{get:function(){return!!z.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(z.key)},enumerable:!1,configurable:!0}),z}(),vt=function(){function z(){}return z.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},z.setAttributes=function(s,v){for(var W=0,Q=v;W<Q.length;W++){var H=Q[W],ce=H[0],Pe=H[1];s.setAttribute(ce,Pe)}},z.createRect=function(s,v,W){var Q=document.createElementNS("http://www.w3.org/2000/svg","rect");return Q.setAttribute("width",s.toString()),Q.setAttribute("height",v.toString()),W&&z.setAttributes(Q,W),Q},z.createLine=function(s,v,W,Q,H){var ce=document.createElementNS("http://www.w3.org/2000/svg","line");return ce.setAttribute("x1",s.toString()),ce.setAttribute("y1",v.toString()),ce.setAttribute("x2",W.toString()),ce.setAttribute("y2",Q.toString()),H&&z.setAttributes(ce,H),ce},z.createPolygon=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg","polygon");return W.setAttribute("points",s),v&&z.setAttributes(W,v),W},z.createCircle=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg","circle");return W.setAttribute("cx",(s/2).toString()),W.setAttribute("cy",(s/2).toString()),W.setAttribute("r",s.toString()),v&&z.setAttributes(W,v),W},z.createEllipse=function(s,v,W){var Q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Q.setAttribute("cx",(s/2).toString()),Q.setAttribute("cy",(v/2).toString()),Q.setAttribute("rx",(s/2).toString()),Q.setAttribute("ry",(v/2).toString()),W&&z.setAttributes(Q,W),Q},z.createGroup=function(s){var v=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&z.setAttributes(v,s),v},z.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},z.createMarker=function(s,v,W,Q,H,ce,Pe){var Ee=document.createElementNS("http://www.w3.org/2000/svg","marker");return z.setAttributes(Ee,[["id",s],["orient",v],["markerWidth",W.toString()],["markerHeight",Q.toString()],["refX",H.toString()],["refY",ce.toString()]]),Ee.appendChild(Pe),Ee},z.createText=function(s){var v=document.createElementNS("http://www.w3.org/2000/svg","text");return v.setAttribute("x","0"),v.setAttribute("y","0"),s&&z.setAttributes(v,s),v},z.createTSpan=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg","tspan");return W.textContent=s,v&&z.setAttributes(W,v),W},z.createImage=function(s){var v=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&z.setAttributes(v,s),v},z.createPoint=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return W.x=s,W.y=v,W},z.createPath=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg","path");return W.setAttribute("d",s),v&&z.setAttributes(W,v),W},z.createElement=function(s,v){var W=document.createElementNS("http://www.w3.org/2000/svg",s);return v&&z.setAttributes(W,v),W},z.getHollowRectanglePath=function(s,v,W,Q,H,ce,Pe,Ee){return"M"+s+","+v+"V"+(v+Q)+"H"+(s+W)+"V"+v+"H"+H+"V"+ce+"H"+(H+Pe)+"V"+(ce+Ee)+"H"+H+"V"+v+"Z"},z}(),Lr=function(){function z(s){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(z.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(z.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(z.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),z.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},z.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)},z.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 fr("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new fr("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new fr("@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;
|
|
`))},z.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},z}(),fr=function(z,s){this.selector=z,this.style=s},lr=function(z,s){this.localName=z,this.style=s},Mt=function(){function z(){this.blocks=[],this.display=""}return z.prototype.addButtonBlock=function(s){s.className=this.blockClassName,s.buttonClassName=this.buttonClassName,s.buttonColorsClassName=this.buttonColorsClassName,s.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(s)},z.prototype.addElementBlock=function(s){s.className===void 0&&(s.className=this.blockClassName),this.blocks.push(s)},z.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(v){return s.appendChild(v.getUI())}),s},z}(),er=function(){function z(){}return z.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},z}(),jt=function(z){function s(){var v=z!==null&&z.apply(this,arguments)||this;return v.buttons=[],v}return Ft(s,z),s.prototype.addButton=function(v){v.className=this.buttonClassName,v.colorsClassName=this.buttonColorsClassName,v.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(v)},s.prototype.getUI=function(){var v=z.prototype.getUI.call(this);return this.buttons.forEach(function(W){return v.appendChild(W.getUI())}),v},s}(er),Lt=function(){function z(s,v){this._isActive=!1,this._isHidden=!1,this._icon=s,this.title=v,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(z.prototype,"icon",{get:function(){return this._icon},set:function(s){this._icon=s,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isActive",{get:function(){return this._isActive},set:function(s){this._isActive=s,this.adjustClassName()},enumerable:!1,configurable:!0}),z.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},z.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,"")))},z.prototype.hide=function(){this._isHidden=!0},z}(),mt=function(z){function s(){var v=z!==null&&z.apply(this,arguments)||this;return v.elements=[],v}return Ft(s,z),s.prototype.addElement=function(v){this.elements.push(v)},s.prototype.getUI=function(){var v=z.prototype.getUI.call(this);return this.elements.forEach(function(W){return v.appendChild(W)}),v},s}(er),ur=function(){function z(s,v){this.horizontal=s,this.vertical=v}return Object.defineProperty(z.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),z.prototype.getVerticalLength=function(s){return s/this.ratio},z.prototype.getHorizontalLength=function(s){return s*this.ratio},z}(),_r=function(){function z(){}return z.getIcon=function(s,v){if(s>0&&v>0){var W=new ur(s,v),Q=W.ratio>=1?20:W.getHorizontalLength(20),H=W.ratio<1?20:W.getVerticalLength(20),ce=document.createElementNS("http://www.w3.org/2000/svg","svg");ce.setAttribute("xmlns","http://www.w3.org/2000/svg"),ce.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(ce);var Pe=vt.createDefs();ce.appendChild(Pe);var Ee=vt.createElement("clipPath",[["id","text-bg-clip"]]);Pe.appendChild(Ee);var gt=vt.createPath(vt.getHollowRectanglePath((24-Q)/2,(24-H)/2,Q,H,(24-Q)/2+2,(24-H)/2+2,Q-4,H-4));ce.appendChild(gt);var Be=vt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Be.appendChild(vt.createTSpan(s+":"+v)),ce.appendChild(Be);var wt=Be.getBBox();vt.setAttributes(Be,[["x",((24-wt.width)/2).toString()],["y",((24-wt.height)/2-wt.y).toString()]]);var Nt=vt.createPath(vt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(wt.width))/2,(24-Math.ceil(wt.height))/2,Math.ceil(wt.width),Math.ceil(wt.height)));return Ee.appendChild(Nt),vt.setAttributes(gt,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(ce),ce.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>'},z}(),Rr=function(z){function s(v,W,Q){var H=z.call(this,v,W)||this;return H.isDropdownOpen=!1,H.onClick=H.dropdownButtonClicked,H.dropdownButtons=Q,H}return Ft(s,z),s.prototype.setupDropdown=function(){var v=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(W){W.className=v.className,W.colorsClassName=v.colorsClassName,v.dropdownBlock.appendChild(W.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}(Lt),Pt=function(){function z(s,v){this.GRIP_SIZE=10,this.color=s,this.fillColor=v,this.visual=vt.createGroup(),this.visual.appendChild(vt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(vt.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return z.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},z.prototype.setCenter=function(s,v){this.visual.childNodes.forEach(function(W){return vt.setAttributes(W,[["cx",s.toString()],["cy",v.toString()]])})},z}(),Yr=function(){function z(s,v,W,Q){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=s,this.canvasHeight=v,this.margin=W,this.container=Q,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(z.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(z.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.gridContainer&&vt.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),z.prototype.open=function(){var s=this;this.cropShadeElement=vt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=vt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var v=0;v<this.numberOfGridLines;v++)this.horizontalGridLines.push(vt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(vt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(W){return s.gridContainer.appendChild(W)}),this.verticalGridLines.forEach(function(W){return s.gridContainer.appendChild(W)}),this.cropRectElement=vt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Pt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Pt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Pt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Pt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},z.prototype.setCropRectangle=function(s){this.cropRect=s;var v=Object.assign({},this.cropRect);this.zoomFactor!==1&&(v.width=this.cropRect.width*this.zoomFactor,v.height=this.cropRect.height*this.zoomFactor,v.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-v.width/2,v.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-v.height/2),vt.setAttributes(this.cropRectElement,[["x",v.x.toString()],["y",v.y.toString()],["width",v.width.toString()],["height",v.height.toString()]]);var W=v.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(H,ce){var Pe=v.y+W*(ce+1);vt.setAttributes(H,[["x1",""+v.x],["y1",""+Pe],["x2",""+(v.x+v.width)],["y2",""+Pe]])});var Q=v.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(H,ce){var Pe=v.x+Q*(ce+1);vt.setAttributes(H,[["x1",""+Pe],["y1",""+v.y],["x2",""+Pe],["y2",""+(v.y+v.height)]])}),vt.setAttributes(this.cropShadeElement,[["d",vt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,v.x,v.y,v.width,v.height)]]),this.topLeftGrip.setCenter(v.x,v.y),this.topRightGrip.setCenter(v.x+v.width,v.y),this.bottomLeftGrip.setCenter(v.x,v.y+v.height),this.bottomRightGrip.setCenter(v.x+v.width,v.y+v.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},z.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)},z.prototype.clientToLocalCoordinates=function(s,v){var W=this.container.getBoundingClientRect();return{x:s-W.left+this.margin,y:v-W.top+this.margin}},z.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)},z.prototype.onPointerMove=function(s){if(this.isMoving)this.move(this.clientToLocalCoordinates(s.clientX,s.clientY));else if(this.activeGrip){var v=this.clientToLocalCoordinates(s.clientX,s.clientY);this.resize(v)}s.preventDefault()},z.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},z.prototype.move=function(s){var v=s.x-this.previousPoint.x,W=s.y-this.previousPoint.y;this.zoomFactor!==1&&(v=-v/this.zoomFactor,W=-W/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+v),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+W),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=s},z.prototype.resize=function(s){var v=Object.assign({},this.cropRect),W=s.x-this.previousPoint.x,Q=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:v.x+W<this.margin&&(W=this.margin-v.x),v.x+=W,v.width=this.cropRect.x+this.cropRect.width-v.x;break;case this.bottomRightGrip:case this.topRightGrip:v.width+W>this.canvasWidth*this.zoomFactor&&(W=this.canvasWidth*this.zoomFactor-v.width),v.width+=W}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(v.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(W),v.height=this.aspectRatio.getVerticalLength(v.width)):(v.y+=Q,v.height=this.cropRect.y+this.cropRect.height-v.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?v.height=this.aspectRatio.getVerticalLength(v.width):v.height+=Q}v.width<10&&(v.x=this.cropRect.x,v.width=10),v.height<10&&(v.y=this.cropRect.y,v.height=10),this.previousPoint=s,v.x>=this.margin&&v.y>=this.margin&&v.x-this.margin+v.width<=this.canvasWidth&&v.y-this.margin+v.height<=this.canvasHeight&&(this.cropRect=v,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},z.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,v=this.cropRect.y+this.cropRect.height/2,W=this.aspectRatio.getHorizontalLength(this.cropRect.height),Q=this.aspectRatio.getVerticalLength(this.cropRect.width);W/this.canvasWidth<Q/this.canvasHeight?this.cropRect.width=W:this.cropRect.height=Q,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=v-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)}},z.prototype.getRescaledRect=function(s,v,W,Q,H,ce){var Pe=W/s,Ee=Q/v;return{x:(H.x-ce)*Pe+ce,y:(H.y-ce)*Ee+ce,width:H.width*Pe,height:H.height*Ee}},z.prototype.scaleCanvas=function(s,v){var W=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,v,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=v,this.onCropChange&&this.onCropChange(W),this.setCropRectangle(W)},z}(),ui=function(){function z(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(z.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),z.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},z.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},z.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},z.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},z.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var s=this.angleLabelText.getBBox();vt.setAttributes(this.angleLabelElement,[["x",((this.width-s.width)/2).toString()],["y",(this.height/2).toString()]])}},z.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)}},z.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 v="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,W=1;W<=this.width/5+10;W++){var Q=W%5==0?this.height/3:this.height/6;v+="h4v"+-Q+"h1v"+Q}v+="v1H0Z",this.scaleShape=vt.createPath(v);var H=vt.createTransform();this.scaleShape.transform.baseVal.appendItem(H),s.appendChild(this.scaleShape),this.angleLabelElement=vt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=vt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var ce=vt.createTSpan("");return ce.innerHTML="°",this.angleLabelElement.appendChild(ce),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},z}(),gi=function(){function z(){this.naturalSize=!1,this.imageType="image/png"}return z.prototype.rasterize=function(s,v,W,Q,H,ce,Pe){var Ee=this;return new Promise(function(gt){var Be=document.createElement("canvas");Be.width=s.width.baseVal.value-2*Q,Be.height=s.height.baseVal.value-2*Q;var wt=1,Nt=1;Ee.naturalSize===!0?(wt=v.naturalWidth/(s.width.baseVal.value-2*Q)/ce,Nt=v.naturalHeight/(s.height.baseVal.value-2*Q)/Pe,Be.width=v.naturalWidth/ce,Be.height=v.naturalHeight/Pe):Ee.width!==void 0&&Ee.height!==void 0&&(wt=Ee.width/W.width,Nt=Ee.height/W.height,Be.width*=wt,Be.height*=Nt);var Gt=Be.getContext("2d");Gt.translate(Be.width/2,Be.height/2),Gt.rotate(H*Math.PI/180),Gt.scale(ce,Pe),Gt.translate(-Be.width/2,-Be.height/2),Gt.drawImage(v,0,0,Be.width,Be.height);var zr=document.createElement("canvas");zr.width=W.width*wt,zr.height=W.height*Nt,zr.getContext("2d").putImageData(Gt.getImageData((W.x-Q)*wt,(W.y-Q)*Nt,W.width*wt,W.height*Nt),0,0),gt(zr.toDataURL(Ee.imageType,Ee.imageQuality))})},z}(),We=function(){function z(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=z.instanceCounter++,this.styles=new Lr(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(z.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(z.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(z.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(z.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(z.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(z.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}),z.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},z.prototype.show=function(){this.showUI(),this.open()},z.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(v){return v()}),this._isOpen=!1)},z.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},z.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},z.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},z.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},z.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))},z.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var s=1*this.target.clientWidth/this.target.clientHeight,v=this.contentDiv.clientWidth/s>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*s:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,W=v+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/s;this.resize(v,W)}},z.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},z.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",vt.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},z.prototype.resize=function(s,v){this.imageWidth=Math.round(s),this.imageHeight=Math.round(v),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()},z.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 v=s.toDataURL();vt.setAttributes(this.editingTarget,[["href",v]]),this.setEditingTargetSize()},z.prototype.setTopLeft=function(){var s=this.target.getBoundingClientRect(),v=this.editorCanvas.getBoundingClientRect();this.left=s.left-v.left-this.CANVAS_MARGIN,this.top=s.top-v.top-this.CANVAS_MARGIN},z.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=vt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=vt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=vt.createGroup(),this.editingTargetRotationScaleContainer=vt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var s=vt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(s);var v=vt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(v),this.editingTargetContainer=vt.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)},z.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},z.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=vt.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Yr(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()},z.prototype.zoomToCrop=function(){if(this.cropRect){var s=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,v=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 "+v+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-s+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-v+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},z.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)},z.prototype.cropRectChanged=function(s){this.cropRect=s,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},z.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},z.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"},z.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},z.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,v=this.target.offsetTop>s+this.CANVAS_MARGIN?this.target.offsetTop-(s+this.CANVAS_MARGIN):0;this.coverDiv.style.top=v+"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},z.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},z.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new Mt,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 v=new jt;v.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(v);var W=[];this.aspectRatios.forEach(function(Nt){var Gt=new Lt(_r.getIcon(Nt.horizontal,Nt.vertical),Nt.horizontal===0&&Nt.vertical===0?"FREE":Nt.horizontal+":"+Nt.vertical);Gt.onClick=function(){return s.ratioButtonClicked(Nt)},W.push(Gt)}),this.aspectRatioButton=new Rr(_r.getIcon(0,0),"Aspect ratio",W),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,v.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var Q=new Lt('<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");Q.isActive=this.isGridVisible,Q.onClick=function(){s.isGridVisible=!s.isGridVisible,Q.isActive=s.isGridVisible},v.addButton(Q);var H=new Lt('<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(H.isActive=this.zoomToCropEnabled,H.onClick=function(){s.zoomToCropEnabled=!s.zoomToCropEnabled,H.isActive=s.zoomToCropEnabled},v.addButton(H),!rr.isLicensed){var ce=new mt;this.topToolbar.addElementBlock(ce);var Pe=document.createElement("div");Pe.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Ee=document.createElement("a");Ee.style.color="currentColor",Ee.href="https://markerjs.com/products/cropro",Ee.target="_blank",Ee.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(Ee),ce.addElement(Pe)}var gt=new jt;gt.minWidth=3*this.toolbarHeight+"px",gt.contentAlign="end",this.topToolbar.addButtonBlock(gt);var Be=new Lt('<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,gt.addButton(Be),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Be.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var wt=new Lt('<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");wt.onClick=this.close,gt.addButton(wt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(wt.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},z.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new Mt,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 v=new jt;v.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(v);var W=new Lt('<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");W.onClick=this.rotateLeftButtonClicked,v.addButton(W);var Q=new Lt('<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");Q.onClick=this.rotateRightButtonClicked,v.addButton(Q);var H=new mt;H.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(H),this.straightener=new ui("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(gt){s.rotateBy(gt),s.straightener.angle=s.rotationAngle},H.addElement(this.straightener.getUI());var ce=new jt;ce.minWidth=2*this.toolbarHeight+"px",ce.contentAlign="end",this.bottomToolbar.addButtonBlock(ce);var Pe=new Lt('<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,ce.addButton(Pe);var Ee=new Lt('<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");Ee.onClick=this.flipVerticallyButtonClicked,ce.addButton(Ee)},z.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},z.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=_r.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},z.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)},z.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},z.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},z.prototype.restoreState=function(s){if(s){var v=this.cropLayer.getRescaledRect(s.width,s.height,this.imageWidth,this.imageHeight,s.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(v),this.cropRectChanged(v),this.flippedHorizontally=s.flippedHorizontally,this.flippedVertically=s.flippedVertically,this.applyFlip(),this.rotationAngle=s.rotationAngle,this.applyRotation()}},z.prototype.clientToLocalCoordinates=function(s,v){var W=this.cropImage.getBoundingClientRect();return{x:s-W.left,y:v-W.top}},z.prototype.onWindowResize=function(){this.positionUI()},z.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()},z.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)},z.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)},z.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},z.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},z.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 v=this.editingTargetRotationContainer.transform.baseVal.getItem(0);v.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(v,0);var W=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/W.width,this.imageHeight/W.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=s},z.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},z.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},z.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},z.prototype.startRenderAndClose=function(){return Dt(this,void 0,void 0,function(){var s,v;return sr(this,function(W){switch(W.label){case 0:return[4,this.render()];case 1:return s=W.sent(),v=this.getState(),this.renderEventListeners.forEach(function(Q){return Q(s,v)}),this.close(!0),[2]}})})},z.prototype.render=function(){return Dt(this,void 0,void 0,function(){var s;return sr(this,function(v){switch(v.label){case 0:return(s=new gi).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.width=this.renderWidth,s.height=this.renderHeight,this.unzoomFromCrop(),vt.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 v.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,v.sent()]}})})},z.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 fr("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new fr("."+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;
|
|
`))},z.instanceCounter=0,z}(),Tt=te("8hTe"),ri=te.n(Tt),di=/<pre[^>]*>/g;function hi(z){var s=document.createElement("div");return s.innerHTML=z,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var Ri=qe.a=function(z){var s=z.value,v=s===void 0?"":s,W=z.edit,Q=W===void 0?!1:W,H=z.className,ce=z.showTextOnly,Pe=z.showLines,Ee=z.replaces,gt=z.zoomImg,Be=z.hasMask,wt=z.style,Nt=wt===void 0?{}:wt,Gt=z.stylesPrev,zr=Gt===void 0?{}:Gt,Gr=String(v),pr=Object(R.useRef)(),$r=Object(R.useRef)(),Ki=Object(R.useState)(""),kr=Object(B.a)(Ki,2),Or=kr[0],ii=kr[1],vi=Object(R.useState)("office"),Jr=Object(B.a)(vi,2),ni=Jr[0],Kr=Jr[1],fn=function(){var Wt=new We($r.current);Wt.displayMode="popup",Wt.addRenderEventListener(function(){var xr=Object(P.a)(O.a.mark(function Ht(Er){var $t;return O.a.wrap(function(dr){for(;;)switch(dr.prev=dr.next){case 0:return pr.current.style.display="none",dr.next=3,Object(_e.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:Er}});case 3:$t=dr.sent,$t!=null&&$t.id&&Ee($r.current.getAttribute("src").replace(oe.a.API_SERVER,""),"/api/attachments/".concat($t==null?void 0:$t.id,"?type=").concat($t.content_type));case 5:case"end":return dr.stop()}},Ht)}));return function(Ht){return xr.apply(this,arguments)}}()),Wt.show()},Vi=function(){var Wt=new Ct($r.current);Wt.settings.displayMode="popup",Wt.addEventListener("render",function(){var xr=Object(P.a)(O.a.mark(function Ht(Er){var $t;return O.a.wrap(function(dr){for(;;)switch(dr.prev=dr.next){case 0:if(pr.current.style.display="none",!$r.current){dr.next=6;break}return dr.next=4,Object(_e.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:Er.dataUrl}});case 4:$t=dr.sent,$t!=null&&$t.id&&Ee($r.current.getAttribute("src").replace(oe.a.API_SERVER,""),"/api/attachments/".concat($t==null?void 0:$t.id,"?type=").concat($t.content_type));case 6:case"end":return dr.stop()}},Ht)}));return function(Ht){return xr.apply(this,arguments)}}()),Wt.show(),window.markerArea=Wt},Ur=Object(R.useMemo)(function(){try{var ir=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Wt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,xr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;Gr=Gr.replace(ir,"("+oe.a.API_SERVER+"/api/attachments/").replace(Wt,'"'+oe.a.API_SERVER+"/api/attachments/").replace(xr,'"'+oe.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,`
|
|
`),Gr=Gr.replace(new RegExp("(?<!\\n)\\n(?!\\n)","g"),`
|
|
`)}catch(yi){}var Ht=J(Gr),Er=C();if(Gr.match(/\[TOC\]/)&&(Ht=Ht.replace("<p>[TOC]</p>",D()),A()),Ht=Ht.replace(/(__special_katext_id_\d+__)/g,function(yi,dr){var hr=Er[dr],ai=hr.type,bi=hr.expression;return Object(ue.renderToString)(hi(bi)||"",{displayMode:ai==="block",throwOnError:!1,output:"html"})}),Ht=Ht.replace(/▁/g,"\u2581\u2581\u2581"),S(),ce){var $t=document.createElement("div");return $t.innerHTML=Ht,$t.innerText}return setTimeout(function(){return Oi()},500),Ht},[Gr]),Fr=Object(R.useRef)();m.WebkitLineClamp=Pe,Pe&&(Nt=Object(I.a)(Object(I.a)({},Nt),m));function ki(ir){var Wt=ir.target;if(Wt.tagName.toUpperCase()==="IMG"){if(gt){var xr=Wt.getAttribute("src");ii(xr),Kr("image")}}else if(Wt.tagName.toUpperCase()==="A"){var Ht=Wt.getAttribute("href");if(Ht.indexOf("office")>-1)ir.preventDefault(),ii(Ht),Kr("office");else if(Ht.indexOf("application/pdf")>-1)ir.preventDefault(),ii(Ht),Kr("pdf");else if(Ht.indexOf("type=text")>-1)ir.preventDefault(),ii(Ht),Kr("html");else if(Ht.startsWith("#")){ir.preventDefault();var Er=document.getElementById(Ht.replace("#",""));Er&&Er.scrollIntoView(!0)}}}var Oi=function(){var Wt,xr=(Wt=Fr.current)===null||Wt===void 0?void 0:Wt.querySelectorAll("video");xr==null||xr.forEach(function(Ht){if(Ht.oncontextmenu=function(){return!1},Ht.src.indexOf(".m3u8")>-1&&!Ht.canPlayType("application/vnd.apple.mpegurl")){if(q.a.isSupported()){var Er=new q.a;Er.loadSource(Ht.src),Er.attachMedia(Ht)}}})};Object(R.useEffect)(function(){if(Fr.current&&Ur&&(Ur.match(di)&&window.PR.prettyPrint()),Fr.current)return Fr.current.addEventListener("click",ki),function(){Fr.current.removeEventListener("click",ki),S(),A()}},[Ur,Fr.current,ki]);var Mi=function(Wt){if(!Q)return;Wt.target.nodeName==="IMG"?(pr.current.style.display="flex",pr.current.style.width=Wt.target.clientWidth+"px",pr.current.style.height=Wt.target.clientHeight+"px",pr.current.style.top=Wt.target.offsetTop+"px",pr.current.style.left=Wt.target.offsetLeft+"px",$r.current.src=Wt.target.getAttribute("src")):pr.current.style.display="none"};return f.a.createElement("div",{style:{position:"relative"}},f.a.createElement("div",{ref:Fr,style:Object(I.a)({},Nt),className:"".concat(H||""," markdown-body ").concat(ri.a.mdBody),onMouseOver:Mi,dangerouslySetInnerHTML:{__html:Ur}}),f.a.createElement("div",{ref:pr,className:ri.a.button},f.a.createElement(Y.a,null,f.a.createElement(V.a,{onClick:function(){return fn()}},"\u88C1\u526A"),f.a.createElement(V.a,{onClick:function(){return Vi()}},"\u7F16\u8F91"))),f.a.createElement("img",{ref:$r,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1,top:"-10000px"}}),f.a.createElement(ge.a,{close:!0,data:Or,hasMask:Be,type:Or!=null&&Or.length?ni:"",style:Object(I.a)({},zr),onClose:function(){return ii("")}}))}},"9VGf":function(dt,qe,te){"use strict";te.d(qe,"a",function(){return _});var ie=te("q1tI"),Y=te.n(ie);function _(V,I){var P=Object(ie.useRef)();Object(ie.useEffect)(function(){P.current=V}),Object(ie.useEffect)(function(){function B(){P.current()}if(I!==null){var N=setInterval(B,I);return function(){return clearInterval(N)}}},[I])}},BU3w:function(dt,qe,te){"use strict";te.d(qe,"a",function(){return P});var ie=te("MNnm"),Y="rc-util-key";function _(B){if(B.attachTo)return B.attachTo;var N=document.querySelector("head");return N||document.body}function V(B){var N,O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(ie.a)())return null;var R=document.createElement("style");if((N=O.csp)===null||N===void 0?void 0:N.nonce){var f;R.nonce=(f=O.csp)===null||f===void 0?void 0:f.nonce}R.innerHTML=B;var c=_(O),k=c.firstChild;return O.prepend&&c.prepend?c.prepend(R):O.prepend&&k?c.insertBefore(R,k):c.appendChild(R),R}var I=new Map;function P(B,N){var O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},R=_(O);if(!I.has(R)){var f=V("",O),c=f.parentNode;I.set(R,c),c.removeChild(f)}var k=Array.from(I.get(R).children).find(function(a){return a.tagName==="STYLE"&&a[Y]===N});if(k){var T,g;if(((T=O.csp)===null||T===void 0?void 0:T.nonce)&&k.nonce!==((g=O.csp)===null||g===void 0?void 0:g.nonce)){var b;k.nonce=(b=O.csp)===null||b===void 0?void 0:b.nonce}return k.innerHTML!==B&&(k.innerHTML=B),k}var u=V(B,O);return u[Y]=N,u}},Bd2K:function(dt,qe,te){(function(ie){ie(te("VrN/"),te("osHv"))})(function(ie){ie.defineOption("autoCloseTags",!1,function(O,R,f){if(f!=ie.Init&&f&&O.removeKeyMap("autoCloseTags"),!R)return;var c={name:"autoCloseTags"};(typeof R!="object"||R.whenClosing!==!1)&&(c["'/'"]=function(k){return P(k)}),(typeof R!="object"||R.whenOpening!==!1)&&(c["'>'"]=function(k){return V(k)}),O.addKeyMap(c)});var Y=["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 V(O){if(O.getOption("disableInput"))return ie.Pass;for(var R=O.listSelections(),f=[],c=O.getOption("autoCloseTags"),k=0;k<R.length;k++){if(!R[k].empty())return ie.Pass;var T=R[k].head,g=O.getTokenAt(T),b=ie.innerMode(O.getMode(),g.state),u=b.state,a=b.mode.xmlCurrentTag&&b.mode.xmlCurrentTag(u),l=a&&a.name;if(!l)return ie.Pass;var h=b.mode.configuration=="html",A=typeof c=="object"&&c.dontCloseTags||h&&Y,m=typeof c=="object"&&c.indentTags||h&&_;g.end>T.ch&&(l=l.slice(0,l.length-g.end+T.ch));var E=l.toLowerCase();if(!l||g.type=="string"&&(g.end!=T.ch||!/[\"\']/.test(g.string.charAt(g.string.length-1))||g.string.length==1)||g.type=="tag"&&a.close||g.string.indexOf("/")==T.ch-g.start-1||A&&B(A,E)>-1||N(O,b.mode.xmlCurrentContext&&b.mode.xmlCurrentContext(u)||[],l,T,!0))return ie.Pass;var D=typeof c=="object"&&c.emptyTags;if(D&&B(D,l)>-1){f[k]={text:"/>",newPos:ie.Pos(T.line,T.ch+2)};continue}var w=m&&B(m,E)>-1;f[k]={indent:w,text:">"+(w?`
|
|
|
|
`:"")+"</"+l+">",newPos:w?ie.Pos(T.line+1,0):ie.Pos(T.line,T.ch+1)}}for(var y=typeof c=="object"&&c.dontIndentOnAutoClose,k=R.length-1;k>=0;k--){var p=f[k];O.replaceRange(p.text,R[k].head,R[k].anchor,"+insert");var d=O.listSelections().slice(0);d[k]={head:p.newPos,anchor:p.newPos},O.setSelections(d),!y&&p.indent&&(O.indentLine(p.newPos.line,null,!0),O.indentLine(p.newPos.line+1,null,!0))}}function I(O,R){for(var f=O.listSelections(),c=[],k=R?"/":"</",T=O.getOption("autoCloseTags"),g=typeof T=="object"&&T.dontIndentOnSlash,b=0;b<f.length;b++){if(!f[b].empty())return ie.Pass;var u=f[b].head,a=O.getTokenAt(u),l=ie.innerMode(O.getMode(),a.state),h=l.state;if(R&&(a.type=="string"||a.string.charAt(0)!="<"||a.start!=u.ch-1))return ie.Pass;var A,m=l.mode.name!="xml"&&O.getMode().name=="htmlmixed";if(m&&l.mode.name=="javascript")A=k+"script";else if(m&&l.mode.name=="css")A=k+"style";else{var E=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(h);if(!E||E.length&&N(O,E,E[E.length-1],u))return ie.Pass;A=k+E[E.length-1]}O.getLine(u.line).charAt(a.end)!=">"&&(A+=">"),c[b]=A}if(O.replaceSelections(c),f=O.listSelections(),!g)for(var b=0;b<f.length;b++)(b==f.length-1||f[b].head.line<f[b+1].head.line)&&O.indentLine(f[b].head.line)}function P(O){return O.getOption("disableInput")?ie.Pass:I(O,!0)}ie.commands.closeTag=function(O){return I(O)};function B(O,R){if(O.indexOf)return O.indexOf(R);for(var f=0,c=O.length;f<c;++f)if(O[f]==R)return f;return-1}function N(O,R,f,c,k){if(!ie.scanForClosingTag)return!1;var T=Math.min(O.lastLine()+1,c.line+500),g=ie.scanForClosingTag(O,c,null,T);if(!g||g.tag!=f)return!1;for(var b=k?1:0,u=R.length-1;u>=0&&R[u]==f;u--)++b;c=g.to;for(var u=1;u<b;u++){var a=ie.scanForClosingTag(O,c,null,T);if(!a||a.tag!=f)return!1;c=a.to}return!0}})},BjJ7:function(dt,qe,te){"use strict";te.d(qe,"d",function(){return Y}),te.d(qe,"c",function(){return _}),te.d(qe,"e",function(){return V}),te.d(qe,"b",function(){return I}),te.d(qe,"a",function(){return B});var ie=te("m3rI");function Y(N){var O=!0;if(N.length>0){for(var R=0;R<N.length;R++)if(N[R].compile_success==0||!N[R].compile_success){O=!1;break}}else O=!1;return O}function _(N){for(var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",R=[],f=0;f<N.length;f++){var c=N[f],k=O?"".concat(O,"/").concat(c.name):"".concat(c.name);R.push({title:c.name,isLeaf:!(c.type==="tree"),key:k})}return R}function V(N,O,R){for(var f=0;f<N.length;f++){var c=N[f];if(c.key===O){c.children=R;break}c.children&&V(c.children,O,R)}return N}function I(N,O,R){var f;return function(){var c=this,k=arguments,T=function(){f=null,R||N.apply(c,k)},g=R&&!f;clearTimeout(f),f=setTimeout(T,O),g&&N.apply(c,k)}}var P=!0,B=ie.a.API_SERVER},"C+DQ":function(dt,qe,te){},D1Df:function(dt,qe,te){"use strict";function ie(x){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ie=function(F){return typeof F}:ie=function(F){return F&&typeof Symbol=="function"&&F.constructor===Symbol&&F!==Symbol.prototype?"symbol":typeof F},ie(x)}function Y(){return Y=Object.assign||function(x){for(var M=1;M<arguments.length;M++){var F=arguments[M];for(var G in F)Object.prototype.hasOwnProperty.call(F,G)&&(x[G]=F[G])}return x},Y.apply(this,arguments)}function _(x,M){var F=Object.keys(x);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(x);M&&(G=G.filter(function(J){return Object.getOwnPropertyDescriptor(x,J).enumerable})),F.push.apply(F,G)}return F}function V(x){for(var M=1;M<arguments.length;M++){var F=arguments[M]!=null?arguments[M]:{};M%2?_(F,!0).forEach(function(G){g(x,G,F[G])}):Object.getOwnPropertyDescriptors?Object.defineProperties(x,Object.getOwnPropertyDescriptors(F)):_(F).forEach(function(G){Object.defineProperty(x,G,Object.getOwnPropertyDescriptor(F,G))})}return x}function I(x,M){if(x==null)return{};var F=P(x,M),G,J;if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(x);for(J=0;J<K.length;J++){if(G=K[J],M.indexOf(G)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(x,G))continue;F[G]=x[G]}}return F}function P(x,M){if(x==null)return{};var F={},G=Object.keys(x),J,K;for(K=0;K<G.length;K++){if(J=G[K],M.indexOf(J)>=0)continue;F[J]=x[J]}return F}function B(x,M){if(!(x instanceof M))throw new TypeError("Cannot call a class as a function")}function N(x,M){for(var F=0;F<M.length;F++){var G=M[F];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(x,G.key,G)}}function O(x,M,F){return M&&N(x.prototype,M),F&&N(x,F),x}function R(x,M){return M&&(ie(M)==="object"||typeof M=="function")?M:c(x)}function f(x){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(F){return F.__proto__||Object.getPrototypeOf(F)},f(x)}function c(x){if(x===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x}function k(x,M){if(typeof M!="function"&&M!==null)throw new TypeError("Super expression must either be null or a function");x.prototype=Object.create(M&&M.prototype,{constructor:{value:x,writable:!0,configurable:!0}}),M&&T(x,M)}function T(x,M){return T=Object.setPrototypeOf||function(G,J){return G.__proto__=J,G},T(x,M)}function g(x,M,F){return M in x?Object.defineProperty(x,M,{value:F,enumerable:!0,configurable:!0,writable:!0}):x[M]=F,x}var b=te("q1tI"),u=te("17x9"),a=te("H38U"),l=te("aRTE");function h(x){for(var M="",F=0;F<x.length;F++){var G=x.charCodeAt(F);G<128?M+=String.fromCharCode(G):G<2048?(M+=String.fromCharCode(192|G>>6),M+=String.fromCharCode(128|G&63)):G<55296||G>=57344?(M+=String.fromCharCode(224|G>>12),M+=String.fromCharCode(128|G>>6&63),M+=String.fromCharCode(128|G&63)):(F++,G=65536+((G&1023)<<10|x.charCodeAt(F)&1023),M+=String.fromCharCode(240|G>>18),M+=String.fromCharCode(128|G>>12&63),M+=String.fromCharCode(128|G>>6&63),M+=String.fromCharCode(128|G&63))}return M}var A={size:128,level:"L",bgColor:"#FFFFFF",fgColor:"#000000",includeMargin:!1},m={},E=4,D=.1;function w(x){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,F=[];return x.forEach(function(G,J){var K=null;G.forEach(function(j,q){if(!j&&K!==null){F.push("M".concat(K+M," ").concat(J+M,"h").concat(q-K,"v1H").concat(K+M,"z")),K=null;return}if(q===G.length-1){if(!j)return;K===null?F.push("M".concat(q+M,",").concat(J+M," h1v1H").concat(q+M,"z")):F.push("M".concat(K+M,",").concat(J+M," h").concat(q+1-K,"v1H").concat(K+M,"z"));return}j&&K===null&&(K=q)})}),F.join("")}function y(x,M){return x.slice().map(function(F,G){return G<M.y||G>=M.y+M.h?F:F.map(function(J,K){return K<M.x||K>=M.x+M.w?J:!1})})}function p(x,M){var F=x.imageSettings,G=x.size,J=x.includeMargin;if(F==null)return null;var K=J?E:0,j=M.length+K*2,q=Math.floor(G*D),oe=j/G,ue=(F.width||q)*oe,ge=(F.height||q)*oe,_e=F.x==null?M.length/2-ue/2:F.x*oe,be=F.y==null?M.length/2-ge/2:F.y*oe,Se=null;if(F.excavate){var Te=Math.floor(_e),Ce=Math.floor(be),pe=Math.ceil(ue+_e-Te),se=Math.ceil(ge+be-Ce);Se={x:Te,y:Ce,w:pe,h:se}}return{x:_e,y:be,h:ge,w:ue,excavation:Se}}var d=function(){try{new Path2D().addPath(new Path2D)}catch(x){return!1}return!0}(),o=function(x){k(M,x);function M(){var F,G;B(this,M);for(var J=arguments.length,K=new Array(J),j=0;j<J;j++)K[j]=arguments[j];return G=R(this,(F=f(M)).call.apply(F,[this].concat(K))),g(c(G),"_canvas",void 0),g(c(G),"_image",void 0),g(c(G),"state",{imgLoaded:!1}),g(c(G),"handleImageLoad",function(){G.setState({imgLoaded:!0})}),G}return O(M,[{key:"componentDidMount",value:function(){this.update()}},{key:"componentDidUpdate",value:function(){this.update()}},{key:"update",value:function(){var G=this.props,J=G.value,K=G.size,j=G.level,q=G.bgColor,oe=G.fgColor,ue=G.includeMargin,ge=G.imageSettings,_e=new a(-1,l[j]);if(_e.addData(h(J)),_e.make(),this._canvas!=null){var be=this._canvas,Se=be.getContext("2d");if(!Se)return;var Te=_e.modules;if(Te===null)return;var Ce=ue?E:0,pe=Te.length+Ce*2,se=p(this.props,Te);ge!=null&&se!=null&&(se.excavation!=null&&(Te=y(Te,se.excavation)));var Re=window.devicePixelRatio||1;be.height=be.width=K*Re;var Je=K/pe*Re;Se.scale(Je,Je),Se.fillStyle=q,Se.fillRect(0,0,pe,pe),Se.fillStyle=oe,d?Se.fill(new Path2D(w(Te,Ce))):Te.forEach(function(Xe,Ze){Xe.forEach(function(Ke,Ae){Ke&&Se.fillRect(Ae+Ce,Ze+Ce,1,1)})}),this.state.imgLoaded&&this._image&&se!=null&&Se.drawImage(this._image,se.x+Ce,se.y+Ce,se.w,se.h)}}},{key:"render",value:function(){var G=this,J=this.props,K=J.value,j=J.size,q=J.level,oe=J.bgColor,ue=J.fgColor,ge=J.style,_e=J.includeMargin,be=J.imageSettings,Se=I(J,["value","size","level","bgColor","fgColor","style","includeMargin","imageSettings"]),Te=V({height:j,width:j},ge),Ce=null,pe=be&&be.src;return be!=null&&pe!=null&&(Ce=b.createElement("img",{src:pe,style:{display:"none"},onLoad:this.handleImageLoad,ref:function(Re){return G._image=Re}})),b.createElement(b.Fragment,null,b.createElement("canvas",Y({style:Te,height:j,width:j,ref:function(Re){return G._canvas=Re}},Se)),Ce)}}]),M}(b.PureComponent);g(o,"defaultProps",A);var C=function(x){k(M,x);function M(){return B(this,M),R(this,f(M).apply(this,arguments))}return O(M,[{key:"render",value:function(){var G=this.props,J=G.value,K=G.size,j=G.level,q=G.bgColor,oe=G.fgColor,ue=G.includeMargin,ge=G.imageSettings,_e=I(G,["value","size","level","bgColor","fgColor","includeMargin","imageSettings"]),be=new a(-1,l[j]);be.addData(h(J)),be.make();var Se=be.modules;if(Se===null)return null;var Te=ue?E:0,Ce=Se.length+Te*2,pe=p(this.props,Se),se=null;ge!=null&&pe!=null&&(pe.excavation!=null&&(Se=y(Se,pe.excavation)),se=b.createElement("image",{xlinkHref:ge.src,height:pe.h,width:pe.w,x:pe.x+Te,y:pe.y+Te,preserveAspectRatio:"none"}));var Re=w(Se,Te);return b.createElement("svg",Y({shapeRendering:"crispEdges",height:K,width:K,viewBox:"0 0 ".concat(Ce," ").concat(Ce)},_e),b.createElement("path",{fill:q,d:"M0,0 h".concat(Ce,"v").concat(Ce,"H0z")}),b.createElement("path",{fill:oe,d:Re}),se)}}]),M}(b.PureComponent);g(C,"defaultProps",A);var S=function(M){var F=M.renderAs,G=I(M,["renderAs"]),J=F==="svg"?C:o;return b.createElement(J,G)};S.defaultProps=V({renderAs:"canvas"},A),dt.exports=S},DlQD:function(dt,qe,te){(function(ie,Y){dt.exports=Y()})(this,function(){"use strict";function ie(me,de){for(var fe=0;fe<de.length;fe++){var ee=de[fe];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(me,ee.key,ee)}}function Y(me,de,fe){return de&&ie(me.prototype,de),fe&&ie(me,fe),me}function _(me,de){if(!me)return;if(typeof me=="string")return V(me,de);var fe=Object.prototype.toString.call(me).slice(8,-1);if(fe==="Object"&&me.constructor&&(fe=me.constructor.name),fe==="Map"||fe==="Set")return Array.from(me);if(fe==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(fe))return V(me,de)}function V(me,de){(de==null||de>me.length)&&(de=me.length);for(var fe=0,ee=new Array(de);fe<de;fe++)ee[fe]=me[fe];return ee}function I(me,de){var fe;if(typeof Symbol=="undefined"||me[Symbol.iterator]==null){if(Array.isArray(me)||(fe=_(me))||de&&me&&typeof me.length=="number"){fe&&(me=fe);var ee=0;return function(){return ee>=me.length?{done:!0}:{done:!1,value:me[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=me[Symbol.iterator](),fe.next.bind(fe)}function P(me,de){return de={exports:{}},me(de,de.exports),de.exports}var B=P(function(me){function de(){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){me.exports.defaults=ee}me.exports={defaults:de(),getDefaults:de,changeDefaults:fe}}),N=B.defaults,O=B.getDefaults,R=B.changeDefaults,f=/[&<>"']/,c=/[&<>"']/g,k=/[<>"']|&(?!#?\w+;)/,T=/[<>"']|&(?!#?\w+;)/g,g={"&":"&","<":"<",">":">",'"':""","'":"'"},b=function(de){return g[de]};function u(me,de){if(de){if(f.test(me))return me.replace(c,b)}else if(k.test(me))return me.replace(T,b);return me}var a=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(me){return me.replace(a,function(de,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 A(me,de){me=me.source||me,de=de||"";var fe={replace:function(re,ne){return ne=ne.source||ne,ne=ne.replace(h,"$1"),me=me.replace(re,ne),fe},getRegex:function(){return new RegExp(me,de)}};return fe}var m=/[^\w:]/g,E=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function D(me,de,fe){if(me){var ee;try{ee=decodeURIComponent(l(fe)).replace(m,"").toLowerCase()}catch(re){return null}if(ee.indexOf("javascript:")===0||ee.indexOf("vbscript:")===0||ee.indexOf("data:")===0)return null}de&&!E.test(fe)&&(fe=o(de,fe));try{fe=encodeURI(fe).replace(/%25/g,"%")}catch(re){return null}return fe}var w={},y=/^[^:]+:\/*[^/]*$/,p=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(me,de){w[" "+me]||(y.test(me)?w[" "+me]=me+"/":w[" "+me]=M(me,"/",!0)),me=w[" "+me];var fe=me.indexOf(":")===-1;return de.substring(0,2)==="//"?fe?de:me.replace(p,"$1")+de:de.charAt(0)==="/"?fe?de:me.replace(d,"$1")+de:me+de}var C={exec:function(){}};function S(me){for(var de=1,fe,ee;de<arguments.length;de++){fe=arguments[de];for(ee in fe)Object.prototype.hasOwnProperty.call(fe,ee)&&(me[ee]=fe[ee])}return me}function x(me,de){var fe=me.replace(/\|/g,function(ne,ae,ye){for(var we=!1,je=ae;--je>=0&&ye[je]==="\\";)we=!we;return we?"|":" |"}),ee=fe.split(/ \|/),re=0;if(ee.length>de)ee.splice(de);else for(;ee.length<de;)ee.push("");for(;re<ee.length;re++)ee[re]=ee[re].trim().replace(/\\\|/g,"|");return ee}function M(me,de,fe){var ee=me.length;if(ee===0)return"";for(var re=0;re<ee;){var ne=me.charAt(ee-re-1);if(ne===de&&!fe)re++;else if(ne!==de&&fe)re++;else break}return me.substr(0,ee-re)}function F(me,de){if(me.indexOf(de[1])===-1)return-1;for(var fe=me.length,ee=0,re=0;re<fe;re++)if(me[re]==="\\")re++;else if(me[re]===de[0])ee++;else if(me[re]===de[1]&&(ee--,ee<0))return re;return-1}function G(me){me&&me.sanitize&&!me.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 J={escape:u,unescape:l,edit:A,cleanUrl:D,resolveUrl:o,noopTest:C,merge:S,splitCells:x,rtrim:M,findClosingBracket:F,checkSanitizeDeprecation:G},K=B.defaults,j=J.rtrim,q=J.splitCells,oe=J.escape,ue=J.findClosingBracket;function ge(me,de,fe){var ee=de.href,re=de.title?oe(de.title):null,ne=me[1].replace(/\\([\[\]])/g,"$1");return me[0].charAt(0)!=="!"?{type:"link",raw:fe,href:ee,title:re,text:ne}:{type:"image",raw:fe,href:ee,title:re,text:oe(ne)}}function _e(me,de){var fe=me.match(/^(\s+)(?:```)/);if(fe===null)return de;var ee=fe[1];return de.split(`
|
|
`).map(function(re){var ne=re.match(/^\s+/);if(ne===null)return re;var ae=ne[0];return ae.length>=ee.length?re.slice(ee.length):re}).join(`
|
|
`)}var be=function(){function me(fe){this.options=fe||K}var de=me.prototype;return de.space=function(ee){var re=this.rules.block.newline.exec(ee);if(re)return re[0].length>1?{type:"space",raw:re[0]}:{raw:`
|
|
`}},de.code=function(ee,re){var ne=this.rules.block.code.exec(ee);if(ne){var ae=re[re.length-1];if(ae&&ae.type==="paragraph")return{raw:ne[0],text:ne[0].trimRight()};var ye=ne[0].replace(/^ {4}/gm,"");return{type:"code",raw:ne[0],codeBlockStyle:"indented",text:this.options.pedantic?ye:j(ye,`
|
|
`)}}},de.fences=function(ee){var re=this.rules.block.fences.exec(ee);if(re){var ne=re[0],ae=_e(ne,re[3]||"");return{type:"code",raw:ne,lang:re[2]?re[2].trim():re[2],text:ae}}},de.heading=function(ee){var re=this.rules.block.heading.exec(ee);if(re)return{type:"heading",raw:re[0],depth:re[1].length,text:re[2]}},de.nptable=function(ee){var re=this.rules.block.nptable.exec(ee);if(re){var ne={type:"table",header:q(re[1].replace(/^ *| *\| *$/g,"")),align:re[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:re[3]?re[3].replace(/\n$/,"").split(`
|
|
`):[],raw:re[0]};if(ne.header.length===ne.align.length){var ae=ne.align.length,ye;for(ye=0;ye<ae;ye++)/^ *-+: *$/.test(ne.align[ye])?ne.align[ye]="right":/^ *:-+: *$/.test(ne.align[ye])?ne.align[ye]="center":/^ *:-+ *$/.test(ne.align[ye])?ne.align[ye]="left":ne.align[ye]=null;for(ae=ne.cells.length,ye=0;ye<ae;ye++)ne.cells[ye]=q(ne.cells[ye],ne.header.length);return ne}}},de.hr=function(ee){var re=this.rules.block.hr.exec(ee);if(re)return{type:"hr",raw:re[0]}},de.blockquote=function(ee){var re=this.rules.block.blockquote.exec(ee);if(re){var ne=re[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:re[0],text:ne}}},de.list=function(ee){var re=this.rules.block.list.exec(ee);if(re){for(var ne=re[0],ae=re[2],ye=ae.length>1,we=ae[ae.length-1]===")",je={type:"list",raw:ne,ordered:ye,start:ye?+ae.slice(0,-1):"",loose:!1,items:[]},ot=re[0].match(this.rules.block.item),xt=!1,Oe,ct,ft,Ge,_t,Ct,Ut,Ft=ot.length,Dt=0;Dt<Ft;Dt++)Oe=ot[Dt],ne=Oe,ct=Oe.length,Oe=Oe.replace(/^ *([*+-]|\d+[.)]) */,""),~Oe.indexOf(`
|
|
`)&&(ct-=Oe.length,Oe=this.options.pedantic?Oe.replace(/^ {1,4}/gm,""):Oe.replace(new RegExp("^ {1,"+ct+"}","gm"),"")),Dt!==Ft-1&&(ft=this.rules.block.bullet.exec(ot[Dt+1])[0],(ye?ft.length===1||!we&&ft[ft.length-1]===")":ft.length>1||this.options.smartLists&&ft!==ae)&&(Ge=ot.slice(Dt+1).join(`
|
|
`),je.raw=je.raw.substring(0,je.raw.length-Ge.length),Dt=Ft-1)),_t=xt||/\n\n(?!\s*$)/.test(Oe),Dt!==Ft-1&&(xt=Oe.charAt(Oe.length-1)===`
|
|
`,_t||(_t=xt)),_t&&(je.loose=!0),Ct=/^\[[ xX]\] /.test(Oe),Ut=void 0,Ct&&(Ut=Oe[1]!==" ",Oe=Oe.replace(/^\[[ xX]\] +/,"")),je.items.push({type:"list_item",raw:ne,task:Ct,checked:Ut,loose:_t,text:Oe});return je}},de.html=function(ee){var re=this.rules.block.html.exec(ee);if(re)return{type:this.options.sanitize?"paragraph":"html",raw:re[0],pre:!this.options.sanitizer&&(re[1]==="pre"||re[1]==="script"||re[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(re[0]):oe(re[0]):re[0]}},de.def=function(ee){var re=this.rules.block.def.exec(ee);if(re){re[3]&&(re[3]=re[3].substring(1,re[3].length-1));var ne=re[1].toLowerCase().replace(/\s+/g," ");return{tag:ne,raw:re[0],href:re[2],title:re[3]}}},de.table=function(ee){var re=this.rules.block.table.exec(ee);if(re){var ne={type:"table",header:q(re[1].replace(/^ *| *\| *$/g,"")),align:re[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:re[3]?re[3].replace(/\n$/,"").split(`
|
|
`):[]};if(ne.header.length===ne.align.length){ne.raw=re[0];var ae=ne.align.length,ye;for(ye=0;ye<ae;ye++)/^ *-+: *$/.test(ne.align[ye])?ne.align[ye]="right":/^ *:-+: *$/.test(ne.align[ye])?ne.align[ye]="center":/^ *:-+ *$/.test(ne.align[ye])?ne.align[ye]="left":ne.align[ye]=null;for(ae=ne.cells.length,ye=0;ye<ae;ye++)ne.cells[ye]=q(ne.cells[ye].replace(/^ *\| *| *\| *$/g,""),ne.header.length);return ne}}},de.lheading=function(ee){var re=this.rules.block.lheading.exec(ee);if(re)return{type:"heading",raw:re[0],depth:re[2].charAt(0)==="="?1:2,text:re[1]}},de.paragraph=function(ee){var re=this.rules.block.paragraph.exec(ee);if(re)return{type:"paragraph",raw:re[0],text:re[1].charAt(re[1].length-1)===`
|
|
`?re[1].slice(0,-1):re[1]}},de.text=function(ee,re){var ne=this.rules.block.text.exec(ee);if(ne){var ae=re[re.length-1];return ae&&ae.type==="text"?{raw:ne[0],text:ne[0]}:{type:"text",raw:ne[0],text:ne[0]}}},de.escape=function(ee){var re=this.rules.inline.escape.exec(ee);if(re)return{type:"escape",raw:re[0],text:oe(re[1])}},de.tag=function(ee,re,ne){var ae=this.rules.inline.tag.exec(ee);if(ae)return!re&&/^<a /i.test(ae[0])?re=!0:re&&/^<\/a>/i.test(ae[0])&&(re=!1),!ne&&/^<(pre|code|kbd|script)(\s|>)/i.test(ae[0])?ne=!0:ne&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ae[0])&&(ne=!1),{type:this.options.sanitize?"text":"html",raw:ae[0],inLink:re,inRawBlock:ne,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ae[0]):oe(ae[0]):ae[0]}},de.link=function(ee){var re=this.rules.inline.link.exec(ee);if(re){var ne=ue(re[2],"()");if(ne>-1){var ae=re[0].indexOf("!")===0?5:4,ye=ae+re[1].length+ne;re[2]=re[2].substring(0,ne),re[0]=re[0].substring(0,ye).trim(),re[3]=""}var we=re[2],je="";if(this.options.pedantic){var ot=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(we);ot?(we=ot[1],je=ot[3]):je=""}else je=re[3]?re[3].slice(1,-1):"";we=we.trim().replace(/^<([\s\S]*)>$/,"$1");var xt=ge(re,{href:we&&we.replace(this.rules.inline._escapes,"$1"),title:je&&je.replace(this.rules.inline._escapes,"$1")},re[0]);return xt}},de.reflink=function(ee,re){var ne;if((ne=this.rules.inline.reflink.exec(ee))||(ne=this.rules.inline.nolink.exec(ee))){var ae=(ne[2]||ne[1]).replace(/\s+/g," ");if(ae=re[ae.toLowerCase()],!ae||!ae.href){var ye=ne[0].charAt(0);return{type:"text",raw:ye,text:ye}}var we=ge(ne,ae,ne[0]);return we}},de.strong=function(ee,re,ne){ne===void 0&&(ne="");var ae=this.rules.inline.strong.start.exec(ee);if(ae&&(!ae[1]||ae[1]&&(ne===""||this.rules.inline.punctuation.exec(ne)))){re=re.slice(-1*ee.length);var ye=ae[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ye.lastIndex=0;for(var we;(ae=ye.exec(re))!=null;)if(we=this.rules.inline.strong.middle.exec(re.slice(0,ae.index+3)),we)return{type:"strong",raw:ee.slice(0,we[0].length),text:ee.slice(2,we[0].length-2)}}},de.em=function(ee,re,ne){ne===void 0&&(ne="");var ae=this.rules.inline.em.start.exec(ee);if(ae&&(!ae[1]||ae[1]&&(ne===""||this.rules.inline.punctuation.exec(ne)))){re=re.slice(-1*ee.length);var ye=ae[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ye.lastIndex=0;for(var we;(ae=ye.exec(re))!=null;)if(we=this.rules.inline.em.middle.exec(re.slice(0,ae.index+2)),we)return{type:"em",raw:ee.slice(0,we[0].length),text:ee.slice(1,we[0].length-1)}}},de.codespan=function(ee){var re=this.rules.inline.code.exec(ee);if(re){var ne=re[2].replace(/\n/g," "),ae=/[^ ]/.test(ne),ye=ne.startsWith(" ")&&ne.endsWith(" ");return ae&&ye&&(ne=ne.substring(1,ne.length-1)),ne=oe(ne,!0),{type:"codespan",raw:re[0],text:ne}}},de.br=function(ee){var re=this.rules.inline.br.exec(ee);if(re)return{type:"br",raw:re[0]}},de.del=function(ee){var re=this.rules.inline.del.exec(ee);if(re)return{type:"del",raw:re[0],text:re[1]}},de.autolink=function(ee,re){var ne=this.rules.inline.autolink.exec(ee);if(ne){var ae,ye;return ne[2]==="@"?(ae=oe(this.options.mangle?re(ne[1]):ne[1]),ye="mailto:"+ae):(ae=oe(ne[1]),ye=ae),{type:"link",raw:ne[0],text:ae,href:ye,tokens:[{type:"text",raw:ae,text:ae}]}}},de.url=function(ee,re){var ne;if(ne=this.rules.inline.url.exec(ee)){var ae,ye;if(ne[2]==="@")ae=oe(this.options.mangle?re(ne[0]):ne[0]),ye="mailto:"+ae;else{var we;do we=ne[0],ne[0]=this.rules.inline._backpedal.exec(ne[0])[0];while(we!==ne[0]);ae=oe(ne[0]),ne[1]==="www."?ye="http://"+ae:ye=ae}return{type:"link",raw:ne[0],text:ae,href:ye,tokens:[{type:"text",raw:ae,text:ae}]}}},de.inlineText=function(ee,re,ne){var ae=this.rules.inline.text.exec(ee);if(ae){var ye;return re?ye=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ae[0]):oe(ae[0]):ae[0]:ye=oe(this.options.smartypants?ne(ae[0]):ae[0]),{type:"text",raw:ae[0],text:ye}}},me}(),Se=J.noopTest,Te=J.edit,Ce=J.merge,pe={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:Se,table:Se,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};pe._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,pe._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,pe.def=Te(pe.def).replace("label",pe._label).replace("title",pe._title).getRegex(),pe.bullet=/(?:[*+-]|\d{1,9}[.)])/,pe.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,pe.item=Te(pe.item,"gm").replace(/bull/g,pe.bullet).getRegex(),pe.list=Te(pe.list).replace(/bull/g,pe.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+pe.def.source+")").getRegex(),pe._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",pe._comment=/<!--(?!-?>)[\s\S]*?-->/,pe.html=Te(pe.html,"i").replace("comment",pe._comment).replace("tag",pe._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),pe.paragraph=Te(pe._paragraph).replace("hr",pe.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",pe._tag).getRegex(),pe.blockquote=Te(pe.blockquote).replace("paragraph",pe.paragraph).getRegex(),pe.normal=Ce({},pe),pe.gfm=Ce({},pe.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*|$)"}),pe.gfm.nptable=Te(pe.gfm.nptable).replace("hr",pe.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",pe._tag).getRegex(),pe.gfm.table=Te(pe.gfm.table).replace("hr",pe.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",pe._tag).getRegex(),pe.pedantic=Ce({},pe.normal,{html:Te(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",pe._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:Se,paragraph:Te(pe.normal._paragraph).replace("hr",pe.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",pe.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var se={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Se,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:Se,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};se._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",se.punctuation=Te(se.punctuation).replace(/punctuation/g,se._punctuation).getRegex(),se._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",se._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",se.em.start=Te(se.em.start).replace(/punctuation/g,se._punctuation).getRegex(),se.em.middle=Te(se.em.middle).replace(/punctuation/g,se._punctuation).replace(/overlapSkip/g,se._overlapSkip).getRegex(),se.em.endAst=Te(se.em.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.em.endUnd=Te(se.em.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.start=Te(se.strong.start).replace(/punctuation/g,se._punctuation).getRegex(),se.strong.middle=Te(se.strong.middle).replace(/punctuation/g,se._punctuation).replace(/blockSkip/g,se._blockSkip).getRegex(),se.strong.endAst=Te(se.strong.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.endUnd=Te(se.strong.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.blockSkip=Te(se._blockSkip,"g").getRegex(),se.overlapSkip=Te(se._overlapSkip,"g").getRegex(),se._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,se._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,se._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])?)+(?![-_])/,se.autolink=Te(se.autolink).replace("scheme",se._scheme).replace("email",se._email).getRegex(),se._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,se.tag=Te(se.tag).replace("comment",pe._comment).replace("attribute",se._attribute).getRegex(),se._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,se._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,se._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,se.link=Te(se.link).replace("label",se._label).replace("href",se._href).replace("title",se._title).getRegex(),se.reflink=Te(se.reflink).replace("label",se._label).getRegex(),se.reflinkSearch=Te(se.reflinkSearch,"g").replace("reflink",se.reflink).replace("nolink",se.nolink).getRegex(),se.normal=Ce({},se),se.pedantic=Ce({},se.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:Te(/^!?\[(label)\]\((.*?)\)/).replace("label",se._label).getRegex(),reflink:Te(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",se._label).getRegex()}),se.gfm=Ce({},se.normal,{escape:Te(se.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),se.gfm.url=Te(se.gfm.url,"i").replace("email",se.gfm._extended_email).getRegex(),se.breaks=Ce({},se.gfm,{br:Te(se.br).replace("{2,}","*").getRegex(),text:Te(se.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var Re={block:pe,inline:se},Je=B.defaults,Xe=Re.block,Ze=Re.inline;function Ke(me){return me.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 Ae(me){var de="",fe,ee,re=me.length;for(fe=0;fe<re;fe++)ee=me.charCodeAt(fe),Math.random()>.5&&(ee="x"+ee.toString(16)),de+="&#"+ee+";";return de}var ke=function(){function me(fe){this.tokens=[],this.tokens.links=Object.create(null),this.options=fe||Je,this.options.tokenizer=this.options.tokenizer||new be,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ee={block:Xe.normal,inline:Ze.normal};this.options.pedantic?(ee.block=Xe.pedantic,ee.inline=Ze.pedantic):this.options.gfm&&(ee.block=Xe.gfm,this.options.breaks?ee.inline=Ze.breaks:ee.inline=Ze.gfm),this.tokenizer.rules=ee}me.lex=function(ee,re){var ne=new me(re);return ne.lex(ee)};var de=me.prototype;return de.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},de.blockTokens=function(ee,re,ne){re===void 0&&(re=[]),ne===void 0&&(ne=!0),ee=ee.replace(/^ +$/gm,"");for(var ae,ye,we,je;ee;){if(ae=this.tokenizer.space(ee)){ee=ee.substring(ae.raw.length),ae.type&&re.push(ae);continue}if(ae=this.tokenizer.code(ee,re)){ee=ee.substring(ae.raw.length),ae.type?re.push(ae):(je=re[re.length-1],je.raw+=`
|
|
`+ae.raw,je.text+=`
|
|
`+ae.text);continue}if(ae=this.tokenizer.fences(ee)){ee=ee.substring(ae.raw.length),re.push(ae);continue}if(ae=this.tokenizer.heading(ee)){ee=ee.substring(ae.raw.length),re.push(ae);continue}if(ae=this.tokenizer.nptable(ee)){ee=ee.substring(ae.raw.length),re.push(ae);continue}if(ae=this.tokenizer.hr(ee)){ee=ee.substring(ae.raw.length),re.push(ae);continue}if(ae=this.tokenizer.blockquote(ee)){ee=ee.substring(ae.raw.length),ae.tokens=this.blockTokens(ae.text,[],ne),re.push(ae);continue}if(ae=this.tokenizer.list(ee)){for(ee=ee.substring(ae.raw.length),we=ae.items.length,ye=0;ye<we;ye++)ae.items[ye].tokens=this.blockTokens(ae.items[ye].text,[],!1);re.push(ae);continue}if(ae=this.tokenizer.html(ee)){ee=ee.substring(ae.raw.length),re.push(ae);continue}if(ne&&(ae=this.tokenizer.def(ee))){ee=ee.substring(ae.raw.length),this.tokens.links[ae.tag]||(this.tokens.links[ae.tag]={href:ae.href,title:ae.title});continue}if(ae=this.tokenizer.table(ee)){ee=ee.substring(ae.raw.length),re.push(ae);continue}if(ae=this.tokenizer.lheading(ee)){ee=ee.substring(ae.raw.length),re.push(ae);continue}if(ne&&(ae=this.tokenizer.paragraph(ee))){ee=ee.substring(ae.raw.length),re.push(ae);continue}if(ae=this.tokenizer.text(ee,re)){ee=ee.substring(ae.raw.length),ae.type?re.push(ae):(je=re[re.length-1],je.raw+=`
|
|
`+ae.raw,je.text+=`
|
|
`+ae.text);continue}if(ee){var ot="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(ot);break}else throw new Error(ot)}}return re},de.inline=function(ee){var re,ne,ae,ye,we,je,ot=ee.length;for(re=0;re<ot;re++){je=ee[re];switch(je.type){case"paragraph":case"text":case"heading":{je.tokens=[],this.inlineTokens(je.text,je.tokens);break}case"table":{for(je.tokens={header:[],cells:[]},ye=je.header.length,ne=0;ne<ye;ne++)je.tokens.header[ne]=[],this.inlineTokens(je.header[ne],je.tokens.header[ne]);for(ye=je.cells.length,ne=0;ne<ye;ne++)for(we=je.cells[ne],je.tokens.cells[ne]=[],ae=0;ae<we.length;ae++)je.tokens.cells[ne][ae]=[],this.inlineTokens(we[ae],je.tokens.cells[ne][ae]);break}case"blockquote":{this.inline(je.tokens);break}case"list":{for(ye=je.items.length,ne=0;ne<ye;ne++)this.inline(je.items[ne].tokens);break}}}return ee},de.inlineTokens=function(ee,re,ne,ae,ye){re===void 0&&(re=[]),ne===void 0&&(ne=!1),ae===void 0&&(ae=!1),ye===void 0&&(ye="");var we,je=ee,ot;if(this.tokens.links){var xt=Object.keys(this.tokens.links);if(xt.length>0)for(;(ot=this.tokenizer.rules.inline.reflinkSearch.exec(je))!=null;)xt.includes(ot[0].slice(ot[0].lastIndexOf("[")+1,-1))&&(je=je.slice(0,ot.index)+"["+"a".repeat(ot[0].length-2)+"]"+je.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(ot=this.tokenizer.rules.inline.blockSkip.exec(je))!=null;)je=je.slice(0,ot.index)+"["+"a".repeat(ot[0].length-2)+"]"+je.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;ee;){if(we=this.tokenizer.escape(ee)){ee=ee.substring(we.raw.length),re.push(we);continue}if(we=this.tokenizer.tag(ee,ne,ae)){ee=ee.substring(we.raw.length),ne=we.inLink,ae=we.inRawBlock,re.push(we);continue}if(we=this.tokenizer.link(ee)){ee=ee.substring(we.raw.length),we.type==="link"&&(we.tokens=this.inlineTokens(we.text,[],!0,ae)),re.push(we);continue}if(we=this.tokenizer.reflink(ee,this.tokens.links)){ee=ee.substring(we.raw.length),we.type==="link"&&(we.tokens=this.inlineTokens(we.text,[],!0,ae)),re.push(we);continue}if(we=this.tokenizer.strong(ee,je,ye)){ee=ee.substring(we.raw.length),we.tokens=this.inlineTokens(we.text,[],ne,ae),re.push(we);continue}if(we=this.tokenizer.em(ee,je,ye)){ee=ee.substring(we.raw.length),we.tokens=this.inlineTokens(we.text,[],ne,ae),re.push(we);continue}if(we=this.tokenizer.codespan(ee)){ee=ee.substring(we.raw.length),re.push(we);continue}if(we=this.tokenizer.br(ee)){ee=ee.substring(we.raw.length),re.push(we);continue}if(we=this.tokenizer.del(ee)){ee=ee.substring(we.raw.length),we.tokens=this.inlineTokens(we.text,[],ne,ae),re.push(we);continue}if(we=this.tokenizer.autolink(ee,Ae)){ee=ee.substring(we.raw.length),re.push(we);continue}if(!ne&&(we=this.tokenizer.url(ee,Ae))){ee=ee.substring(we.raw.length),re.push(we);continue}if(we=this.tokenizer.inlineText(ee,ae,Ke)){ee=ee.substring(we.raw.length),ye=we.raw.slice(-1),re.push(we);continue}if(ee){var Oe="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(Oe);break}else throw new Error(Oe)}}return re},Y(me,null,[{key:"rules",get:function(){return{block:Xe,inline:Ze}}}]),me}(),He=B.defaults,$e=J.cleanUrl,ze=J.escape,Ie=function(){function me(fe){this.options=fe||He}var de=me.prototype;return de.code=function(ee,re,ne){var ae=(re||"").match(/\S*/)[0];if(this.options.highlight){var ye=this.options.highlight(ee,ae);ye!=null&&ye!==ee&&(ne=!0,ee=ye)}return ae?'<pre><code class="'+this.options.langPrefix+ze(ae,!0)+'">'+(ne?ee:ze(ee,!0))+`</code></pre>
|
|
`:"<pre><code>"+(ne?ee:ze(ee,!0))+`</code></pre>
|
|
`},de.blockquote=function(ee){return`<blockquote>
|
|
`+ee+`</blockquote>
|
|
`},de.html=function(ee){return ee},de.heading=function(ee,re,ne,ae){return this.options.headerIds?"<h"+re+' id="'+this.options.headerPrefix+ae.slug(ne)+'">'+ee+"</h"+re+`>
|
|
`:"<h"+re+">"+ee+"</h"+re+`>
|
|
`},de.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},de.list=function(ee,re,ne){var ae=re?"ol":"ul",ye=re&&ne!==1?' start="'+ne+'"':"";return"<"+ae+ye+`>
|
|
`+ee+"</"+ae+`>
|
|
`},de.listitem=function(ee){return"<li>"+ee+`</li>
|
|
`},de.checkbox=function(ee){return"<input "+(ee?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},de.paragraph=function(ee){return"<p>"+ee+`</p>
|
|
`},de.table=function(ee,re){return re&&(re="<tbody>"+re+"</tbody>"),`<table>
|
|
<thead>
|
|
`+ee+`</thead>
|
|
`+re+`</table>
|
|
`},de.tablerow=function(ee){return`<tr>
|
|
`+ee+`</tr>
|
|
`},de.tablecell=function(ee,re){var ne=re.header?"th":"td",ae=re.align?"<"+ne+' align="'+re.align+'">':"<"+ne+">";return ae+ee+"</"+ne+`>
|
|
`},de.strong=function(ee){return"<strong>"+ee+"</strong>"},de.em=function(ee){return"<em>"+ee+"</em>"},de.codespan=function(ee){return"<code>"+ee+"</code>"},de.br=function(){return this.options.xhtml?"<br/>":"<br>"},de.del=function(ee){return"<del>"+ee+"</del>"},de.link=function(ee,re,ne){if(ee=$e(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ne;var ae='<a href="'+ze(ee)+'"';return re&&(ae+=' title="'+re+'"'),ae+=">"+ne+"</a>",ae},de.image=function(ee,re,ne){if(ee=$e(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ne;var ae='<img src="'+ee+'" alt="'+ne+'"';return re&&(ae+=' title="'+re+'"'),ae+=this.options.xhtml?"/>":">",ae},de.text=function(ee){return ee},me}(),Fe=function(){function me(){}var de=me.prototype;return de.strong=function(ee){return ee},de.em=function(ee){return ee},de.codespan=function(ee){return ee},de.del=function(ee){return ee},de.html=function(ee){return ee},de.text=function(ee){return ee},de.link=function(ee,re,ne){return""+ne},de.image=function(ee,re,ne){return""+ne},de.br=function(){return""},me}(),ht=function(){function me(){this.seen={}}var de=me.prototype;return de.slug=function(ee){var re=ee.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(re)){var ne=re;do this.seen[ne]++,re=ne+"-"+this.seen[ne];while(this.seen.hasOwnProperty(re))}return this.seen[re]=0,re},me}(),at=B.defaults,tt=J.unescape,Ye=function(){function me(fe){this.options=fe||at,this.options.renderer=this.options.renderer||new Ie,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Fe,this.slugger=new ht}me.parse=function(ee,re){var ne=new me(re);return ne.parse(ee)};var de=me.prototype;return de.parse=function(ee,re){re===void 0&&(re=!0);var ne="",ae,ye,we,je,ot,xt,Oe,ct,ft,Ge,_t,Ct,Ut,Ft,Dt,sr,rr,vt,Lr=ee.length;for(ae=0;ae<Lr;ae++){Ge=ee[ae];switch(Ge.type){case"space":continue;case"hr":{ne+=this.renderer.hr();continue}case"heading":{ne+=this.renderer.heading(this.parseInline(Ge.tokens),Ge.depth,tt(this.parseInline(Ge.tokens,this.textRenderer)),this.slugger);continue}case"code":{ne+=this.renderer.code(Ge.text,Ge.lang,Ge.escaped);continue}case"table":{for(ct="",Oe="",je=Ge.header.length,ye=0;ye<je;ye++)Oe+=this.renderer.tablecell(this.parseInline(Ge.tokens.header[ye]),{header:!0,align:Ge.align[ye]});for(ct+=this.renderer.tablerow(Oe),ft="",je=Ge.cells.length,ye=0;ye<je;ye++){for(xt=Ge.tokens.cells[ye],Oe="",ot=xt.length,we=0;we<ot;we++)Oe+=this.renderer.tablecell(this.parseInline(xt[we]),{header:!1,align:Ge.align[we]});ft+=this.renderer.tablerow(Oe)}ne+=this.renderer.table(ct,ft);continue}case"blockquote":{ft=this.parse(Ge.tokens),ne+=this.renderer.blockquote(ft);continue}case"list":{for(_t=Ge.ordered,Ct=Ge.start,Ut=Ge.loose,je=Ge.items.length,ft="",ye=0;ye<je;ye++)Dt=Ge.items[ye],sr=Dt.checked,rr=Dt.task,Ft="",Dt.task&&(vt=this.renderer.checkbox(sr),Ut?Dt.tokens.length>0&&Dt.tokens[0].type==="text"?(Dt.tokens[0].text=vt+" "+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=vt+" "+Dt.tokens[0].tokens[0].text)):Dt.tokens.unshift({type:"text",text:vt}):Ft+=vt),Ft+=this.parse(Dt.tokens,Ut),ft+=this.renderer.listitem(Ft,rr,sr);ne+=this.renderer.list(ft,_t,Ct);continue}case"html":{ne+=this.renderer.html(Ge.text);continue}case"paragraph":{ne+=this.renderer.paragraph(this.parseInline(Ge.tokens));continue}case"text":{for(ft=Ge.tokens?this.parseInline(Ge.tokens):Ge.text;ae+1<Lr&&ee[ae+1].type==="text";)Ge=ee[++ae],ft+=`
|
|
`+(Ge.tokens?this.parseInline(Ge.tokens):Ge.text);ne+=re?this.renderer.paragraph(ft):ft;continue}default:{var fr='Token with "'+Ge.type+'" type was not found.';if(this.options.silent){console.error(fr);return}else throw new Error(fr)}}}return ne},de.parseInline=function(ee,re){re=re||this.renderer;var ne="",ae,ye,we=ee.length;for(ae=0;ae<we;ae++){ye=ee[ae];switch(ye.type){case"escape":{ne+=re.text(ye.text);break}case"html":{ne+=re.html(ye.text);break}case"link":{ne+=re.link(ye.href,ye.title,this.parseInline(ye.tokens,re));break}case"image":{ne+=re.image(ye.href,ye.title,ye.text);break}case"strong":{ne+=re.strong(this.parseInline(ye.tokens,re));break}case"em":{ne+=re.em(this.parseInline(ye.tokens,re));break}case"codespan":{ne+=re.codespan(ye.text);break}case"br":{ne+=re.br();break}case"del":{ne+=re.del(this.parseInline(ye.tokens,re));break}case"text":{ne+=re.text(ye.text);break}default:{var je='Token with "'+ye.type+'" type was not found.';if(this.options.silent){console.error(je);return}else throw new Error(je)}}}return ne},me}(),lt=J.merge,et=J.checkSanitizeDeprecation,Qe=J.escape,Le=B.getDefaults,st=B.changeDefaults,rt=B.defaults;function De(me,de,fe){if(typeof me=="undefined"||me===null)throw new Error("marked(): input parameter is undefined or null");if(typeof me!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(me)+", string expected");if(typeof de=="function"&&(fe=de,de=null),de=lt({},De.defaults,de||{}),et(de),fe){var ee=de.highlight,re;try{re=ke.lex(me,de)}catch(we){return fe(we)}var ne=function(je){var ot;if(!je)try{ot=Ye.parse(re,de)}catch(xt){je=xt}return de.highlight=ee,je?fe(je):fe(null,ot)};if(!ee||ee.length<3)return ne();if(delete de.highlight,!re.length)return ne();var ae=0;De.walkTokens(re,function(we){we.type==="code"&&(ae++,setTimeout(function(){ee(we.text,we.lang,function(je,ot){if(je)return ne(je);ot!=null&&ot!==we.text&&(we.text=ot,we.escaped=!0),ae--,ae===0&&ne()})},0))}),ae===0&&ne();return}try{var ye=ke.lex(me,de);return de.walkTokens&&De.walkTokens(ye,de.walkTokens),Ye.parse(ye,de)}catch(we){if(we.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,de.silent)return"<p>An error occurred:</p><pre>"+Qe(we.message+"",!0)+"</pre>";throw we}}De.options=De.setOptions=function(me){return lt(De.defaults,me),st(De.defaults),De},De.getDefaults=Le,De.defaults=rt,De.use=function(me){var de=lt({},me);if(me.renderer&&function(){var ee=De.defaults.renderer||new Ie,re=function(ye){var we=ee[ye];ee[ye]=function(){for(var je=arguments.length,ot=new Array(je),xt=0;xt<je;xt++)ot[xt]=arguments[xt];var Oe=me.renderer[ye].apply(ee,ot);return Oe===!1&&(Oe=we.apply(ee,ot)),Oe}};for(var ne in me.renderer)re(ne);de.renderer=ee}(),me.tokenizer&&function(){var ee=De.defaults.tokenizer||new be,re=function(ye){var we=ee[ye];ee[ye]=function(){for(var je=arguments.length,ot=new Array(je),xt=0;xt<je;xt++)ot[xt]=arguments[xt];var Oe=me.tokenizer[ye].apply(ee,ot);return Oe===!1&&(Oe=we.apply(ee,ot)),Oe}};for(var ne in me.tokenizer)re(ne);de.tokenizer=ee}(),me.walkTokens){var fe=De.defaults.walkTokens;de.walkTokens=function(ee){me.walkTokens(ee),fe&&fe(ee)}}De.setOptions(de)},De.walkTokens=function(me,de){for(var fe=I(me),ee;!(ee=fe()).done;){var re=ee.value;de(re);switch(re.type){case"table":{for(var ne=I(re.tokens.header),ae;!(ae=ne()).done;){var ye=ae.value;De.walkTokens(ye,de)}for(var we=I(re.tokens.cells),je;!(je=we()).done;)for(var ot=je.value,xt=I(ot),Oe;!(Oe=xt()).done;){var ct=Oe.value;De.walkTokens(ct,de)}break}case"list":{De.walkTokens(re.items,de);break}default:re.tokens&&De.walkTokens(re.tokens,de)}}},De.Parser=Ye,De.parser=Ye.parse,De.Renderer=Ie,De.TextRenderer=Fe,De.Lexer=ke,De.lexer=ke.lex,De.Tokenizer=be,De.Slugger=ht,De.parse=De;var Ne=De;return Ne})},ELLl:function(dt,qe,te){(function(ie){ie(te("VrN/"))})(function(ie){var Y={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},_=ie.Pos;ie.defineOption("autoCloseBrackets",!1,function(g,b,u){u&&u!=ie.Init&&(g.removeKeyMap(I),g.state.closeBrackets=null),b&&(P(V(b,"pairs")),g.state.closeBrackets=b,g.addKeyMap(I))});function V(g,b){return b=="pairs"&&typeof g=="string"?g:typeof g=="object"&&g[b]!=null?g[b]:Y[b]}var I={Backspace:O,Enter:R};function P(g){for(var b=0;b<g.length;b++){var u=g.charAt(b),a="'"+u+"'";I[a]||(I[a]=B(u))}}P(Y.pairs+"`");function B(g){return function(b){return c(b,g)}}function N(g){var b=g.state.closeBrackets;if(!b||b.override)return b;var u=g.getModeAt(g.getCursor());return u.closeBrackets||b}function O(g){var b=N(g);if(!b||g.getOption("disableInput"))return ie.Pass;for(var u=V(b,"pairs"),a=g.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return ie.Pass;var h=k(g,a[l].head);if(!h||u.indexOf(h)%2!=0)return ie.Pass}for(var l=a.length-1;l>=0;l--){var A=a[l].head;g.replaceRange("",_(A.line,A.ch-1),_(A.line,A.ch+1),"+delete")}}function R(g){var b=N(g),u=b&&V(b,"explode");if(!u||g.getOption("disableInput"))return ie.Pass;for(var a=g.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return ie.Pass;var h=k(g,a[l].head);if(!h||u.indexOf(h)%2!=0)return ie.Pass}g.operation(function(){var A=g.lineSeparator()||`
|
|
`;g.replaceSelection(A+A,null),g.execCommand("goCharLeft"),a=g.listSelections();for(var m=0;m<a.length;m++){var E=a[m].head.line;g.indentLine(E,null,!0),g.indentLine(E+1,null,!0)}})}function f(g){var b=ie.cmpPos(g.anchor,g.head)>0;return{anchor:new _(g.anchor.line,g.anchor.ch+(b?-1:1)),head:new _(g.head.line,g.head.ch+(b?1:-1))}}function c(g,b){var u=N(g);if(!u||g.getOption("disableInput"))return ie.Pass;var a=V(u,"pairs"),l=a.indexOf(b);if(l==-1)return ie.Pass;for(var h=V(u,"closeBefore"),A=V(u,"triples"),m=a.charAt(l+1)==b,E=g.listSelections(),D=l%2==0,w,y=0;y<E.length;y++){var p=E[y],d=p.head,o,C=g.getRange(d,_(d.line,d.ch+1));if(D&&!p.empty())o="surround";else if((m||!D)&&C==b)m&&T(g,d)?o="both":A.indexOf(b)>=0&&g.getRange(d,_(d.line,d.ch+3))==b+b+b?o="skipThree":o="skip";else if(m&&d.ch>1&&A.indexOf(b)>=0&&g.getRange(_(d.line,d.ch-2),d)==b+b){if(d.ch>2&&/\bstring/.test(g.getTokenTypeAt(_(d.line,d.ch-2))))return ie.Pass;o="addFour"}else if(m){var S=d.ch==0?" ":g.getRange(_(d.line,d.ch-1),d);if(!ie.isWordChar(C)&&S!=b&&!ie.isWordChar(S))o="both";else return ie.Pass}else if(D&&(C.length===0||/\s/.test(C)||h.indexOf(C)>-1))o="both";else return ie.Pass;if(!w)w=o;else if(w!=o)return ie.Pass}var x=l%2?a.charAt(l-1):b,M=l%2?b:a.charAt(l+1);g.operation(function(){if(w=="skip")g.execCommand("goCharRight");else if(w=="skipThree")for(var F=0;F<3;F++)g.execCommand("goCharRight");else if(w=="surround"){for(var G=g.getSelections(),F=0;F<G.length;F++)G[F]=x+G[F]+M;g.replaceSelections(G,"around"),G=g.listSelections().slice();for(var F=0;F<G.length;F++)G[F]=f(G[F]);g.setSelections(G)}else w=="both"?(g.replaceSelection(x+M,null),g.triggerElectric(x+M),g.execCommand("goCharLeft")):w=="addFour"&&(g.replaceSelection(x+x+x+x,"before"),g.execCommand("goCharRight"))})}function k(g,b){var u=g.getRange(_(b.line,b.ch-1),_(b.line,b.ch+1));return u.length==2?u:null}function T(g,b){var u=g.getTokenAt(_(b.line,b.ch+1));return/\bstring/.test(u.type)&&u.start==b.ch&&(b.ch==0||!/\bstring/.test(g.getTokenTypeAt(b)))}})},H38U:function(dt,qe,te){var ie=te("f4xo"),Y=te("rcnY"),_=te("wU8J"),V=te("Iq15"),I=te("dWSS");function P(N,O){this.typeNumber=N,this.errorCorrectLevel=O,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}var B=P.prototype;B.addData=function(N){var O=new ie(N);this.dataList.push(O),this.dataCache=null},B.isDark=function(N,O){if(N<0||this.moduleCount<=N||O<0||this.moduleCount<=O)throw new Error(N+","+O);return this.modules[N][O]},B.getModuleCount=function(){return this.moduleCount},B.make=function(){if(this.typeNumber<1){var N=1;for(N=1;N<40;N++){for(var O=Y.getRSBlocks(N,this.errorCorrectLevel),R=new _,f=0,c=0;c<O.length;c++)f+=O[c].dataCount;for(var c=0;c<this.dataList.length;c++){var k=this.dataList[c];R.put(k.mode,4),R.put(k.getLength(),V.getLengthInBits(k.mode,N)),k.write(R)}if(R.getLengthInBits()<=f*8)break}this.typeNumber=N}this.makeImpl(!1,this.getBestMaskPattern())},B.makeImpl=function(N,O){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var R=0;R<this.moduleCount;R++){this.modules[R]=new Array(this.moduleCount);for(var f=0;f<this.moduleCount;f++)this.modules[R][f]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(N,O),this.typeNumber>=7&&this.setupTypeNumber(N),this.dataCache==null&&(this.dataCache=P.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,O)},B.setupPositionProbePattern=function(N,O){for(var R=-1;R<=7;R++){if(N+R<=-1||this.moduleCount<=N+R)continue;for(var f=-1;f<=7;f++){if(O+f<=-1||this.moduleCount<=O+f)continue;0<=R&&R<=6&&(f==0||f==6)||0<=f&&f<=6&&(R==0||R==6)||2<=R&&R<=4&&2<=f&&f<=4?this.modules[N+R][O+f]=!0:this.modules[N+R][O+f]=!1}}},B.getBestMaskPattern=function(){for(var N=0,O=0,R=0;R<8;R++){this.makeImpl(!0,R);var f=V.getLostPoint(this);(R==0||N>f)&&(N=f,O=R)}return O},B.createMovieClip=function(N,O,R){var f=N.createEmptyMovieClip(O,R),c=1;this.make();for(var k=0;k<this.modules.length;k++)for(var T=k*c,g=0;g<this.modules[k].length;g++){var b=g*c,u=this.modules[k][g];u&&(f.beginFill(0,100),f.moveTo(b,T),f.lineTo(b+c,T),f.lineTo(b+c,T+c),f.lineTo(b,T+c),f.endFill())}return f},B.setupTimingPattern=function(){for(var N=8;N<this.moduleCount-8;N++){if(this.modules[N][6]!=null)continue;this.modules[N][6]=N%2==0}for(var O=8;O<this.moduleCount-8;O++){if(this.modules[6][O]!=null)continue;this.modules[6][O]=O%2==0}},B.setupPositionAdjustPattern=function(){for(var N=V.getPatternPosition(this.typeNumber),O=0;O<N.length;O++)for(var R=0;R<N.length;R++){var f=N[O],c=N[R];if(this.modules[f][c]!=null)continue;for(var k=-2;k<=2;k++)for(var T=-2;T<=2;T++)k==-2||k==2||T==-2||T==2||k==0&&T==0?this.modules[f+k][c+T]=!0:this.modules[f+k][c+T]=!1}},B.setupTypeNumber=function(N){for(var O=V.getBCHTypeNumber(this.typeNumber),R=0;R<18;R++){var f=!N&&(O>>R&1)==1;this.modules[Math.floor(R/3)][R%3+this.moduleCount-8-3]=f}for(var R=0;R<18;R++){var f=!N&&(O>>R&1)==1;this.modules[R%3+this.moduleCount-8-3][Math.floor(R/3)]=f}},B.setupTypeInfo=function(N,O){for(var R=this.errorCorrectLevel<<3|O,f=V.getBCHTypeInfo(R),c=0;c<15;c++){var k=!N&&(f>>c&1)==1;c<6?this.modules[c][8]=k:c<8?this.modules[c+1][8]=k:this.modules[this.moduleCount-15+c][8]=k}for(var c=0;c<15;c++){var k=!N&&(f>>c&1)==1;c<8?this.modules[8][this.moduleCount-c-1]=k:c<9?this.modules[8][15-c-1+1]=k:this.modules[8][15-c-1]=k}this.modules[this.moduleCount-8][8]=!N},B.mapData=function(N,O){for(var R=-1,f=this.moduleCount-1,c=7,k=0,T=this.moduleCount-1;T>0;T-=2)for(T==6&&T--;;){for(var g=0;g<2;g++)if(this.modules[f][T-g]==null){var b=!1;k<N.length&&(b=(N[k]>>>c&1)==1);var u=V.getMask(O,f,T-g);u&&(b=!b),this.modules[f][T-g]=b,c--,c==-1&&(k++,c=7)}if(f+=R,f<0||this.moduleCount<=f){f-=R,R=-R;break}}},P.PAD0=236,P.PAD1=17,P.createData=function(N,O,R){for(var f=Y.getRSBlocks(N,O),c=new _,k=0;k<R.length;k++){var T=R[k];c.put(T.mode,4),c.put(T.getLength(),V.getLengthInBits(T.mode,N)),T.write(c)}for(var g=0,k=0;k<f.length;k++)g+=f[k].dataCount;if(c.getLengthInBits()>g*8)throw new Error("code length overflow. ("+c.getLengthInBits()+">"+g*8+")");for(c.getLengthInBits()+4<=g*8&&c.put(0,4);c.getLengthInBits()%8!=0;)c.putBit(!1);for(;!(c.getLengthInBits()>=g*8);){if(c.put(P.PAD0,8),c.getLengthInBits()>=g*8)break;c.put(P.PAD1,8)}return P.createBytes(c,f)},P.createBytes=function(N,O){for(var R=0,f=0,c=0,k=new Array(O.length),T=new Array(O.length),g=0;g<O.length;g++){var b=O[g].dataCount,u=O[g].totalCount-b;f=Math.max(f,b),c=Math.max(c,u),k[g]=new Array(b);for(var a=0;a<k[g].length;a++)k[g][a]=255&N.buffer[a+R];R+=b;var l=V.getErrorCorrectPolynomial(u),h=new I(k[g],l.getLength()-1),A=h.mod(l);T[g]=new Array(l.getLength()-1);for(var a=0;a<T[g].length;a++){var m=a+A.getLength()-T[g].length;T[g][a]=m>=0?A.get(m):0}}for(var E=0,a=0;a<O.length;a++)E+=O[a].totalCount;for(var D=new Array(E),w=0,a=0;a<f;a++)for(var g=0;g<O.length;g++)a<k[g].length&&(D[w++]=k[g][a]);for(var a=0;a<c;a++)for(var g=0;g<O.length;g++)a<T[g].length&&(D[w++]=T[g][a]);return D},dt.exports=P},HmJG:function(dt,qe,te){},Iq15:function(dt,qe,te){var ie=te("nVVt"),Y=te("dWSS"),_=te("dQei"),V={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},I={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1<<10|1<<8|1<<5|1<<4|1<<2|1<<1|1<<0,G18:1<<12|1<<11|1<<10|1<<9|1<<8|1<<5|1<<2|1<<0,G15_MASK:1<<14|1<<12|1<<10|1<<4|1<<1,getBCHTypeInfo:function(P){for(var B=P<<10;I.getBCHDigit(B)-I.getBCHDigit(I.G15)>=0;)B^=I.G15<<I.getBCHDigit(B)-I.getBCHDigit(I.G15);return(P<<10|B)^I.G15_MASK},getBCHTypeNumber:function(P){for(var B=P<<12;I.getBCHDigit(B)-I.getBCHDigit(I.G18)>=0;)B^=I.G18<<I.getBCHDigit(B)-I.getBCHDigit(I.G18);return P<<12|B},getBCHDigit:function(P){for(var B=0;P!=0;)B++,P>>>=1;return B},getPatternPosition:function(P){return I.PATTERN_POSITION_TABLE[P-1]},getMask:function(P,B,N){switch(P){case V.PATTERN000:return(B+N)%2==0;case V.PATTERN001:return B%2==0;case V.PATTERN010:return N%3==0;case V.PATTERN011:return(B+N)%3==0;case V.PATTERN100:return(Math.floor(B/2)+Math.floor(N/3))%2==0;case V.PATTERN101:return B*N%2+B*N%3==0;case V.PATTERN110:return(B*N%2+B*N%3)%2==0;case V.PATTERN111:return(B*N%3+(B+N)%2)%2==0;default:throw new Error("bad maskPattern:"+P)}},getErrorCorrectPolynomial:function(P){for(var B=new Y([1],0),N=0;N<P;N++)B=B.multiply(new Y([1,_.gexp(N)],0));return B},getLengthInBits:function(P,B){if(1<=B&&B<10)switch(P){case ie.MODE_NUMBER:return 10;case ie.MODE_ALPHA_NUM:return 9;case ie.MODE_8BIT_BYTE:return 8;case ie.MODE_KANJI:return 8;default:throw new Error("mode:"+P)}else if(B<27)switch(P){case ie.MODE_NUMBER:return 12;case ie.MODE_ALPHA_NUM:return 11;case ie.MODE_8BIT_BYTE:return 16;case ie.MODE_KANJI:return 10;default:throw new Error("mode:"+P)}else if(B<41)switch(P){case ie.MODE_NUMBER:return 14;case ie.MODE_ALPHA_NUM:return 13;case ie.MODE_8BIT_BYTE:return 16;case ie.MODE_KANJI:return 12;default:throw new Error("mode:"+P)}else throw new Error("type:"+B)},getLostPoint:function(P){for(var B=P.getModuleCount(),N=0,O=0;O<B;O++)for(var R=0;R<B;R++){for(var f=0,c=P.isDark(O,R),k=-1;k<=1;k++){if(O+k<0||B<=O+k)continue;for(var T=-1;T<=1;T++){if(R+T<0||B<=R+T)continue;if(k==0&&T==0)continue;c==P.isDark(O+k,R+T)&&f++}}f>5&&(N+=3+f-5)}for(var O=0;O<B-1;O++)for(var R=0;R<B-1;R++){var g=0;P.isDark(O,R)&&g++,P.isDark(O+1,R)&&g++,P.isDark(O,R+1)&&g++,P.isDark(O+1,R+1)&&g++,(g==0||g==4)&&(N+=3)}for(var O=0;O<B;O++)for(var R=0;R<B-6;R++)P.isDark(O,R)&&!P.isDark(O,R+1)&&P.isDark(O,R+2)&&P.isDark(O,R+3)&&P.isDark(O,R+4)&&!P.isDark(O,R+5)&&P.isDark(O,R+6)&&(N+=40);for(var R=0;R<B;R++)for(var O=0;O<B-6;O++)P.isDark(O,R)&&!P.isDark(O+1,R)&&P.isDark(O+2,R)&&P.isDark(O+3,R)&&P.isDark(O+4,R)&&!P.isDark(O+5,R)&&P.isDark(O+6,R)&&(N+=40);for(var b=0,R=0;R<B;R++)for(var O=0;O<B;O++)P.isDark(O,R)&&b++;var u=Math.abs(100*b/B/B-50)/5;return N+=u*10,N}};dt.exports=I},LSTS:function(dt,qe,te){"use strict";Object.defineProperty(qe,"__esModule",{value:!0});var ie=function(){function c(k,T){for(var g=0;g<T.length;g++){var b=T[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(k,b.key,b)}}return function(k,T,g){return T&&c(k.prototype,T),g&&c(k,g),k}}(),Y=te("q1tI"),_=P(Y),V=te("17x9"),I=P(V);function P(c){return c&&c.__esModule?c:{default:c}}function B(c,k){var T={};for(var g in c){if(k.indexOf(g)>=0)continue;if(!Object.prototype.hasOwnProperty.call(c,g))continue;T[g]=c[g]}return T}function N(c,k){if(!(c instanceof k))throw new TypeError("Cannot call a class as a function")}function O(c,k){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return k&&(typeof k=="object"||typeof k=="function")?k:c}function R(c,k){if(typeof k!="function"&&k!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof k);c.prototype=Object.create(k&&k.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),k&&(Object.setPrototypeOf?Object.setPrototypeOf(c,k):c.__proto__=k)}var f=function(c){R(k,c);function k(T){N(this,k);var g=O(this,(k.__proto__||Object.getPrototypeOf(k)).call(this,T));return g.scrollListener=g.scrollListener.bind(g),g.eventListenerOptions=g.eventListenerOptions.bind(g),g.mousewheelListener=g.mousewheelListener.bind(g),g}return ie(k,[{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 g=this.getParentElement(this.scrollComponent);g.scrollTop=g.scrollHeight-this.beforeScrollHeight+this.beforeScrollTop,this.loadMore=!1}this.attachScrollListener()}},{key:"componentWillUnmount",value:function(){this.detachScrollListener(),this.detachMousewheelListener()}},{key:"isPassiveSupported",value:function(){var g=!1,b={get passive(){g=!0}};try{document.addEventListener("test",null,b),document.removeEventListener("test",null,b)}catch(u){}return g}},{key:"eventListenerOptions",value:function(){var g=this.props.useCapture;return this.isPassiveSupported()&&(g={useCapture:this.props.useCapture,passive:!0}),g}},{key:"setDefaultLoader",value:function(g){this.defaultLoader=g}},{key:"detachMousewheelListener",value:function(){var g=window;this.props.useWindow===!1&&(g=this.scrollComponent.parentNode),g.removeEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture)}},{key:"detachScrollListener",value:function(){var g=window;this.props.useWindow===!1&&(g=this.getParentElement(this.scrollComponent)),g.removeEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),g.removeEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture)}},{key:"getParentElement",value:function(g){var b=this.props.getScrollParent&&this.props.getScrollParent();return b!=null?b:g&&g.parentNode}},{key:"filterProps",value:function(g){return g}},{key:"attachScrollListener",value:function(){var g=this.getParentElement(this.scrollComponent);if(!this.props.hasMore||!g)return;var b=window;this.props.useWindow===!1&&(b=g),b.addEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture),b.addEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),b.addEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture),this.props.initialLoad&&this.scrollListener()}},{key:"mousewheelListener",value:function(g){g.deltaY===1&&!this.isPassiveSupported()&&g.preventDefault()}},{key:"scrollListener",value:function(){var g=this.scrollComponent,b=window,u=this.getParentElement(g),a=void 0;if(this.props.useWindow){var l=document.documentElement||document.body.parentNode||document.body,h=b.pageYOffset!==void 0?b.pageYOffset:l.scrollTop;this.props.isReverse?a=h:a=this.calculateOffset(g,h)}else this.props.isReverse?a=u.scrollTop:a=g.scrollHeight-u.scrollTop-u.clientHeight;a<Number(this.props.threshold)&&g&&g.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(g,b){return g?this.calculateTopPosition(g)+(g.offsetHeight-b-window.innerHeight):0}},{key:"calculateTopPosition",value:function(g){return g?g.offsetTop+this.calculateTopPosition(g.offsetParent):0}},{key:"render",value:function(){var g=this,b=this.filterProps(this.props),u=b.children,a=b.element,l=b.hasMore,h=b.initialLoad,A=b.isReverse,m=b.loader,E=b.loadMore,D=b.pageStart,w=b.ref,y=b.threshold,p=b.useCapture,d=b.useWindow,o=b.getScrollParent,C=B(b,["children","element","hasMore","initialLoad","isReverse","loader","loadMore","pageStart","ref","threshold","useCapture","useWindow","getScrollParent"]);C.ref=function(x){g.scrollComponent=x,w&&w(x)};var S=[u];return l&&(m?A?S.unshift(m):S.push(m):this.defaultLoader&&(A?S.unshift(this.defaultLoader):S.push(this.defaultLoader))),_.default.createElement(a,C,S)}}]),k}(Y.Component);f.propTypes={children:I.default.node.isRequired,element:I.default.node,hasMore:I.default.bool,initialLoad:I.default.bool,isReverse:I.default.bool,loader:I.default.node,loadMore:I.default.func.isRequired,pageStart:I.default.number,ref:I.default.func,getScrollParent:I.default.func,threshold:I.default.number,useCapture:I.default.bool,useWindow:I.default.bool},f.defaultProps={element:"div",hasMore:!1,initialLoad:!0,pageStart:0,ref:null,threshold:250,useWindow:!0,isReverse:!1,useCapture:!1,loader:null,getScrollParent:null},qe.default=f,dt.exports=qe.default},LdHM:function(dt,qe,te){"use strict";te.d(qe,"b",function(){return h}),te.d(qe,"a",function(){return m});var ie=te("1OyB"),Y=te("vuIU"),_=te("Ji7U"),V=te("LK+K"),I=te("q1tI"),P=te("rePB"),B=te("Ff2n"),N=te("ODXe"),O=te("4IlW"),R=te("bX4T"),f=te("YrtM"),c=te("TSYQ"),k=te.n(c),T=te("+nKL"),g=te("8OUc"),b=function(q,oe){var ue=q.prefixCls,ge=q.id,_e=q.flattenOptions,be=q.childrenAsData,Se=q.values,Te=q.searchValue,Ce=q.multiple,pe=q.defaultActiveFirstOption,se=q.height,Re=q.itemHeight,Je=q.notFoundContent,Xe=q.open,Ze=q.menuItemSelectedIcon,Ke=q.virtual,Ae=q.onSelect,ke=q.onToggleOpen,He=q.onActiveValue,$e=q.onScroll,ze=q.onMouseEnter,Ie="".concat(ue,"-item"),Fe=Object(f.a)(function(){return _e},[Xe,_e],function(Ne,me){return me[0]&&Ne[1]!==me[1]}),ht=I.useRef(null),at=function(me){me.preventDefault()},tt=function(me){ht.current&&ht.current.scrollTo({index:me})},Ye=function(me){for(var de=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,fe=Fe.length,ee=0;ee<fe;ee+=1){var re=(me+ee*de+fe)%fe,ne=Fe[re],ae=ne.group,ye=ne.data;if(!ae&&!ye.disabled)return re}return-1},lt=I.useState(function(){return Ye(0)}),et=Object(N.a)(lt,2),Qe=et[0],Le=et[1],st=function(me){Le(me);var de=Fe[me];if(!de){He(null,-1);return}He(de.data.value,me)};I.useEffect(function(){st(pe!==!1?Ye(0):-1)},[Fe.length,Te]),I.useEffect(function(){var Ne=setTimeout(function(){if(!Ce&&Xe&&Se.size===1){var me=Array.from(Se)[0],de=Fe.findIndex(function(fe){var ee=fe.data;return ee.value===me});st(de),tt(de)}});return function(){return clearTimeout(Ne)}},[Xe]);var rt=function(me){me!==void 0&&Ae(me,{selected:!Se.has(me)}),Ce||ke(!1)};if(I.useImperativeHandle(oe,function(){return{onKeyDown:function(me){var de=me.which;switch(de){case O.a.UP:case O.a.DOWN:{var fe=0;if(de===O.a.UP?fe=-1:de===O.a.DOWN&&(fe=1),fe!==0){var ee=Ye(Qe+fe,fe);tt(ee),st(ee)}break}case O.a.ENTER:{var re=Fe[Qe];re&&!re.data.disabled?rt(re.data.value):rt(void 0),Xe&&me.preventDefault();break}case O.a.ESC:ke(!1)}},onKeyUp:function(){},scrollTo:function(me){tt(me)}}}),Fe.length===0)return I.createElement("div",{role:"listbox",id:"".concat(ge,"_list"),className:"".concat(Ie,"-empty"),onMouseDown:at},Je);function De(Ne){var me=Fe[Ne];if(!me)return null;var de=me.data||{},fe=de.value,ee=de.label,re=de.children,ne=Object(R.a)(de,!0),ae=be?re:ee;return me?I.createElement("div",Object.assign({"aria-label":typeof ae=="string"?ae:null},ne,{key:Ne,role:"option",id:"".concat(ge,"_list_").concat(Ne),"aria-selected":Se.has(fe)}),fe):null}return I.createElement(I.Fragment,null,I.createElement("div",{role:"listbox",id:"".concat(ge,"_list"),style:{height:0,width:0,overflow:"hidden"}},De(Qe-1),De(Qe),De(Qe+1)),I.createElement(T.a,{itemKey:"key",ref:ht,data:Fe,height:se,itemHeight:Re,fullHeight:!1,onMouseDown:at,onScroll:$e,virtual:Ke,onMouseEnter:ze},function(Ne,me){var de,fe=Ne.group,ee=Ne.groupOption,re=Ne.data,ne=re.label,ae=re.key;if(fe)return I.createElement("div",{className:k()(Ie,"".concat(Ie,"-group"))},ne!==void 0?ne:ae);var ye=re.disabled,we=re.value,je=re.title,ot=re.children,xt=re.style,Oe=re.className,ct=Object(B.a)(re,["disabled","value","title","children","style","className"]),ft=Se.has(we),Ge="".concat(Ie,"-option"),_t=k()(Ie,Ge,Oe,(de={},Object(P.a)(de,"".concat(Ge,"-grouped"),ee),Object(P.a)(de,"".concat(Ge,"-active"),Qe===me&&!ye),Object(P.a)(de,"".concat(Ge,"-disabled"),ye),Object(P.a)(de,"".concat(Ge,"-selected"),ft),de)),Ct=be?ot:ne,Ut=!Ze||typeof Ze=="function"||ft;return I.createElement("div",Object.assign({},ct,{"aria-selected":ft,className:_t,title:je,onMouseMove:function(){if(Qe===me||ye)return;st(me)},onClick:function(){ye||rt(we)},style:xt}),I.createElement("div",{className:"".concat(Ge,"-content")},Ct||we),I.isValidElement(Ze)||ft,Ut&&I.createElement(g.a,{className:"".concat(Ie,"-option-state"),customizeIcon:Ze,customizeIconProps:{isSelected:ft}},ft?"\u2713":null))}))},u=I.forwardRef(b);u.displayName="OptionList";var a=u,l=function(){return null};l.isSelectOption=!0;var h=l,A=function(){return null};A.isSelectOptGroup=!0;var m=A,E=te("VTBJ"),D=te("Zm9Q");function w(j){var q=j.key,oe=j.props,ue=oe.children,ge=oe.value,_e=Object(B.a)(oe,["children","value"]);return Object(E.a)({key:q,value:ge!==void 0?ge:q,children:ue},_e)}function y(j){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(D.a)(j).map(function(oe,ue){if(!I.isValidElement(oe)||!oe.type)return null;var ge=oe.type.isSelectOptGroup,_e=oe.key,be=oe.props,Se=be.children,Te=Object(B.a)(be,["children"]);return q||!ge?w(oe):Object(E.a)(Object(E.a)({key:"__RC_SELECT_GRP__".concat(_e===null?ue:_e,"__"),label:_e},Te),{},{options:y(Se)})}).filter(function(oe){return oe})}var p=te("2Qr1"),d=te("qNPg"),o=te("U8pU"),C=te("Kwbf"),S=te("WKfj");function x(j){var q=j.mode,oe=j.options,ue=j.children,ge=j.backfill,_e=j.allowClear,be=j.placeholder,Se=j.getInputElement,Te=j.showSearch,Ce=j.onSearch,pe=j.defaultOpen,se=j.autoFocus,Re=j.labelInValue,Je=j.value,Xe=j.inputValue,Ze=j.optionLabelProp,Ke=q==="multiple"||q==="tags",Ae=Te!==void 0?Te:Ke||q==="combobox",ke=oe||y(ue);if(Object(C.a)(q!=="tags"||ke.every(function(Ie){return!Ie.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),q==="tags"||q==="combobox"){var He=ke.some(function(Ie){return Ie.options?Ie.options.some(function(Fe){return typeof("value"in Fe?Fe.value:Fe.key)=="number"}):typeof("value"in Ie?Ie.value:Ie.key)=="number"});Object(C.a)(!He,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(C.a)(q!=="combobox"||!Ze,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(C.a)(q==="combobox"||!ge,"`backfill` only works with `combobox` mode."),Object(C.a)(q==="combobox"||!Se,"`getInputElement` only work with `combobox` mode."),Object(C.b)(q!=="combobox"||!Se||!_e||!be,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Ce&&!Ae&&q!=="combobox"&&q!=="tags"&&Object(C.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(C.b)(!pe||se,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Je!=null){var $e=Object(S.d)(Je);Object(C.a)(!Re||$e.every(function(Ie){return Object(o.a)(Ie)==="object"&&("key"in Ie||"value"in Ie)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(C.a)(!Ke||Array.isArray(Je),"`value` should be array when `mode` is `multiple` or `tags`")}if(ue){var ze=null;Object(D.a)(ue).some(function(Ie){if(!I.isValidElement(Ie)||!Ie.type)return!1;var Fe=Ie.type;if(Fe.isSelectOption)return!1;if(Fe.isSelectOptGroup){var ht=Object(D.a)(Ie.props.children).every(function(at){return!I.isValidElement(at)||!Ie.type||at.type.isSelectOption?!0:(ze=at.type,!1)});return!ht}return ze=Fe,!0}),ze&&Object(C.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(ze.displayName||ze.name||ze,"`.")),Object(C.a)(Xe===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var M=x,F=Object(d.a)({prefixCls:"rc-select",components:{optionList:a},convertChildrenToData:y,flattenOptions:p.d,getLabeledValue:p.e,filterOptions:p.b,isValueDisabled:p.g,findValueOption:p.c,warningProps:M,fillOptionsWithMissingValue:p.a}),G=function(j){Object(_.a)(oe,j);var q=Object(V.a)(oe);function oe(){var ue;return Object(ie.a)(this,oe),ue=q.apply(this,arguments),ue.selectRef=I.createRef(),ue.focus=function(){ue.selectRef.current.focus()},ue.blur=function(){ue.selectRef.current.blur()},ue}return Object(Y.a)(oe,[{key:"render",value:function(){return I.createElement(F,Object.assign({ref:this.selectRef},this.props))}}]),oe}(I.Component);G.Option=h,G.OptGroup=m;var J=G,K=qe.c=J},M8RZ:function(dt,qe,te){"use strict";te.d(qe,"a",function(){return O});var ie=te("fWQN"),Y=te("mtLc"),_=te("yKVA"),V=te("879j"),I=te("q1tI"),P=te.n(I),B=te("i8i4"),N=te.n(B),O=function(R){Object(_.a)(c,R);var f=Object(V.a)(c);function c(k){var T;Object(ie.a)(this,c),T=f.call(this,k);var g=window.document;return T.node=g.createElement("div"),g.body.appendChild(T.node),T}return Object(Y.a)(c,[{key:"render",value:function(){var T=this.props.children;return Object(B.createPortal)(T,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),c}(P.a.Component)},Ot1p:function(dt,qe,te){"use strict";var ie=te("2qtc"),Y=te("kLXV"),_=te("rAM+"),V=te("miYZ"),I=te("tsqr"),P=te("9og8"),B=te("tJVT"),N=te("jrin"),O=te("WmNS"),R=te.n(O),f=te("q1tI"),c=te.n(f),k=te("VrN/"),T=te.n(k),g=te("bdgK"),b=te("p77/"),u=te("Bd2K"),a=te("ELLl"),l=te("19Vz"),h=te("lZu9"),A=te("+NIl"),m=te("kSUc"),E=te("9Bee"),D=function(Oe){var ct=Oe.value,ft=ct===void 0?"":ct,Ge=Oe.className,_t=Oe.showTextOnly,Ct=Oe.showLines,Ut=Oe.style,Ft=Ut===void 0?{}:Ut,Dt=Object(f.useMemo)(function(){return""},[ft]);return c.a.createElement(c.a.Fragment,null,c.a.createElement("div",{dangerouslySetInnerHTML:{__html:Dt}}))},w=te("Q9mQ"),y=te("diRs"),p=te("0Owb"),d=te("dejd"),o=te("C+DQ"),C=te("D1Df"),S=te.n(C),x=te("1vsH"),M=te("m3rI"),F=[{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 G(Oe){var ct=Oe.onActionCallback,ft=Oe.title,Ge=Oe.icon,_t=Oe.actionName,Ct=Oe.className,Ut=Ct===void 0?"":Ct,Ft=Oe.children;function Dt(){ct(_t)}return c.a.createElement("a",{title:ft,className:Ut,onClick:Dt},c.a.createElement("i",{className:"md-iconfont ".concat(Ge)}),Ft)}var J=function(Oe){var ct=Oe.watch,ft=Oe.showNullButton,Ge=Oe.onActionCallback,_t=Oe.fullScreen,Ct=Oe.insertTemp,Ut=Oe.hidetoolBar,Ft=Oe.uuid,Dt=Oe.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(x.E)("_educoder_session_login"),"&_educoder_session=").concat(Object(x.E)("_educoder_session"),"&key=").concat(Ft,"&api=").concat(encodeURIComponent(M.a.PROXY_SERVER)));var sr=[].concat(F,[{title:"".concat(ct?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(ct?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return c.a.createElement("ul",{className:"markdown-toolbar-container"},!Ut&&sr.map(function(rr,vt){return c.a.createElement("li",{key:vt},rr.actionName?c.a.createElement(G,Object(p.a)({},rr,{onActionCallback:Ge})):c.a.createElement("span",{className:"v-line"}))}),ft?c.a.createElement("li",null,c.a.createElement(G,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:Ge},c.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,Ct&&c.a.createElement("li",null,c.a.createElement(G,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(Ct),onActionCallback:Ge},c.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),c.a.createElement("li",null,c.a.createElement(y.a,{title:"\u6253\u5F00\u624B\u673A\u626B\u4E00\u626B",content:c.a.createElement("div",null,c.a.createElement(S.a,{size:150,fgColor:"#000",value:"https://test2.educoder.net/upload.html?_educoder_session_login=".concat(Object(x.E)("_educoder_session_login"),"&_educoder_session=").concat(Object(x.E)("_educoder_session"),"&key=").concat(Ft,"&api=").concat(encodeURIComponent(M.a.PROXY_SERVER))}))},c.a.createElement("span",{className:"fill-tip",onMouseOver:function(){return Dt(!0)}},"\u624B\u673A\u4E0A\u4F20\u6587\u4EF6"))),c.a.createElement("li",{className:"btn-full-screen"},c.a.createElement(G,{icon:"".concat(_t?"icon-shrink":"icon-enlarge"),title:_t?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:Ge})))},K=te("M8RZ"),j=te("+L6B"),q=te("2/Rp"),oe=te("y8nQ"),ue=te("Vl3Y"),ge=te("5NDa"),_e=te("5rEg"),be={labelCol:{span:4},wrapperCol:{span:20}},Se=function(Oe){var ct=Oe.callback,ft=Oe.onCancel;function Ge(_t){ct(_t)}return c.a.createElement(ue.a,Object(p.a)({},be,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:Ge}),c.a.createElement(ue.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},c.a.createElement(_e.a,null)),c.a.createElement(ue.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},c.a.createElement(_e.a,null)),c.a.createElement("div",{className:"flex-container flex-end"},c.a.createElement(q.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),c.a.createElement(q.a,{type:"ghost",onClick:ft},"\u53D6\u6D88")))},Te=te("7ahc"),Ce=te("k1fw"),pe=te("HmJG"),se=te("BjJ7"),Re=ue.a.useForm,Je={width:280,marginRight:10},Xe={labelCol:{span:5},wrapperCol:{span:19}},Ze=function(Oe){var ct=Oe.callback,ft=Oe.onCancel,Ge=Re(),_t=Object(B.a)(Ge,1),Ct=_t[0],Ut=Object(f.useRef)();function Ft(rr){ct(Object(Ce.a)(Object(Ce.a)({},rr),{},{name:Ut.current}))}function Dt(rr,vt){Ct.setFieldsValue({src:"/api/attachments/".concat(rr.id,"?type=").concat(rr.content_type),type:vt.type})}function sr(rr){var vt=rr.target.files[0];Ut.current=vt.name,Ae(vt,Dt)}return c.a.createElement(ue.a,Object(p.a)({form:Ct},Xe,{className:"upload-image-panel",onFinish:Ft}),c.a.createElement(ue.a.Item,{label:"\u6587\u4EF6\u5730\u5740",required:!0},c.a.createElement("div",{className:"flex-container"},c.a.createElement(ue.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u6587\u4EF6\u5730\u5740"}]},c.a.createElement(_e.a,{style:Je})),c.a.createElement(Ke,{onFileChange:sr}))),c.a.createElement(ue.a.Item,{label:"\u6587\u4EF6\u63CF\u8FF0",name:"alt"},c.a.createElement(_e.a,{style:{width:264}})),c.a.createElement(ue.a.Item,{style:{textAlign:"right"}},c.a.createElement(q.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),c.a.createElement(q.a,{type:"ghost",onClick:ft},"\u53D6\u6D88")))};function Ke(Oe){var ct=Oe.onFileChange;return c.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",c.a.createElement("input",{type:"file",onChange:ct}))}function Ae(Oe,ct){if(!Oe)throw new String("\u6CA1\u6709\u6587\u4EF6");var ft=new FormData;ft.append("editormd-image-file",Oe),ft.append("file_param_name","editormd-image-file"),ft.append("byxhr","true");var Ge=new window.XMLHttpRequest;Ge.withCredentials=!0,Ge.addEventListener("load",function(_t){ct(JSON.parse(_t.target.responseText),Oe)},!1),Ge.addEventListener("error",function(_t){console.error(_t)},!1),Ge.open("POST","".concat(se.a,"/api/attachments.json")),Ge.send(ft)}var ke=te("giR+"),He=te("fyUT"),$e=te("7Kak"),ze=te("9yH6"),Ie=ze.a.Group,Fe={margin:"0 8px"},ht=function(Oe){var ct=Oe.callback,ft=Oe.onCancel;function Ge(_t){ct(_t)}return c.a.createElement(ue.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:Ge},c.a.createElement("div",{className:"flex-container"},c.a.createElement("span",{style:Fe},"\u5355\u5143\u683C\u6570\uFF1A"),c.a.createElement("span",{style:Fe},"\u884C\u6570"),c.a.createElement(ue.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},c.a.createElement(He.a,null)),c.a.createElement("span",{style:Fe},"\u5217\u6570"),c.a.createElement(ue.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},c.a.createElement(He.a,null))),c.a.createElement("div",{className:"flex-container",style:{marginTop:12}},c.a.createElement("span",{style:Fe},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),c.a.createElement(ue.a.Item,{name:"align"},c.a.createElement(Ie,null,c.a.createElement(ze.a,{value:"default"},c.a.createElement("i",{className:"fa fa-align-justify"})),c.a.createElement(ze.a,{value:"left"},c.a.createElement("i",{className:"fa fa-align-left"})),c.a.createElement(ze.a,{value:"center"},c.a.createElement("i",{className:"fa fa-align-center"})),c.a.createElement(ze.a,{value:"right"},c.a.createElement("i",{className:"fa fa-align-right"}))))),c.a.createElement("div",{className:"flex-container flex-end"},c.a.createElement(q.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),c.a.createElement(q.a,{type:"ghost",onClick:ft},"\u53D6\u6D88")))},at=te("ErOA"),tt=te("7Cbv"),Ye="link",lt="upload-image",et="code-block",Qe="add-table",Le="------------",st={default:Le,left:":".concat(Le),center:":".concat(Le,":"),right:"".concat(Le,":")},rt=te("9VGf"),De,Ne;function me(){}var de=0,fe=1e4,ee="\u2581",re=`
|
|
**\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 ne(Oe){return/^\d+$/.test(Oe)?"".concat(Oe,"px"):Oe}var ae=navigator.platform.toUpperCase().indexOf("MAC")>=0,ye=ae?"Cmd":"Ctrl",we=["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"],je=(De={},Object(N.a)(De,ye+"-B","bold"),Object(N.a)(De,ye+"-I","italic"),De),ot=(Ne={},Object(N.a)(Ne,Ye,"\u6DFB\u52A0\u94FE\u63A5"),Object(N.a)(Ne,et,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(N.a)(Ne,lt,"\u6DFB\u52A0\u6587\u4EF6"),Object(N.a)(Ne,Qe,"\u6DFB\u52A0\u8868\u683C"),Ne),xt=qe.a=function(Oe){var ct=Oe.defaultValue,ft=ct===void 0?"":ct,Ge=Oe.onChange,_t=Oe.width,Ct=_t===void 0?"100%":_t,Ut=Oe.height,Ft=Ut===void 0?400:Ut,Dt=Oe.miniToolbar,sr=Dt===void 0?!1:Dt,rr=Oe.isFocus,vt=rr===void 0?!1:rr,Lr=Oe.watch,fr=Oe.insertTemp,lr=Oe.mode,Mt=lr===void 0?"markdown":lr,er=Oe.id,jt=er===void 0?"markdown-editor-id":er,Lt=Oe.showResizeBar,mt=Lt===void 0?!1:Lt,ur=Oe.noStorage,_r=ur===void 0?!1:ur,Rr=Oe.showNullButton,Pt=Rr===void 0?!1:Rr,Yr=Oe.hidetoolBar,ui=Yr===void 0?!1:Yr,gi=Oe.fullScreen,We=gi===void 0?!1:gi,Tt=Oe.onBlur,ri=Oe.onCMBeforeChange,di=Oe.onFullScreen,hi=Oe.className,Ri=hi===void 0?"":hi,z=Oe.disablePaste,s=z===void 0?!1:z,v=Oe.placeholder,W=v===void 0?"":v,Q=Oe.values,H=Q===void 0?"":Q,ce=Object(f.useState)(null),Pe=Object(B.a)(ce,2),Ee=Pe[0],gt=Pe[1],Be=Object(f.useState)(ft),wt=Object(B.a)(Be,2),Nt=wt[0],Gt=wt[1],zr=Object(f.useState)(Lr),Gr=Object(B.a)(zr,2),pr=Gr[0],$r=Gr[1],Ki=Object(f.useState)(We),kr=Object(B.a)(Ki,2),Or=kr[0],ii=kr[1],vi=Object(f.useState)(""),Jr=Object(B.a)(vi,2),ni=Jr[0],Kr=Jr[1],fn=Object(f.useState)(0),Vi=Object(B.a)(fn,2),Ur=Vi[0],Fr=Vi[1],ki=Object(f.useState)(Ft),Oi=Object(B.a)(ki,2),Mi=Oi[0],ir=Oi[1],Wt=Object(f.useState)(!1),xr=Object(B.a)(Wt,2),Ht=xr[0],Er=xr[1],$t=Object(f.useRef)(Object(tt.a)()),yi=Object(f.useRef)(!1),dr=Object(f.useRef)(),hr=Object(f.useRef)(),ai=Object(f.useRef)(),bi=Object(f.useRef)(),xi=Object(f.useRef)(),Fn=function(){var yt=Object(P.a)(R.a.mark(function At(){var Et,kt;return R.a.wrap(function(Kt){for(;;)switch(Kt.prev=Kt.next){case 0:return Kt.next=2,Object(at.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:$t.current}});case 2:kt=Kt.sent,kt!=null&&(Et=kt.attachments)!==null&&Et!==void 0&&Et.length&&(console.log("cm:",Ee,hr),kt.attachments.map(function(It){It.content_type.indexOf("image")>-1?Ee.replaceSelection(".concat(It.content_type,")")):It.content_type.indexOf("video")>-1?Ee.replaceSelection('<video width="100%" controls src="'.concat(M.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):It.content_type.indexOf("pdf")>-1?Ee.replaceSelection('<a href="'.concat(M.a.API_SERVER,"/api/attachments/").concat(It.id,"?type=").concat(It.content_type,'&disposition=inline" target="_blank">').concat(It.name,"</a>")):Ee.replaceSelection("[".concat(It.name,"](").concat(M.a.API_SERVER,"/api/attachments/").concat(It.id,"?type=").concat(It.content_type,")"))}));case 4:case"end":return Kt.stop()}},At)}));return function(){return yt.apply(this,arguments)}}();Object(f.useEffect)(function(){Gt(H),Ee==null||Ee.setValue(H)},[H]),Object(f.useEffect)(function(){di==null||di(Or)},[Or]),Object(f.useEffect)(function(){if(hr.current){var yt=T.a.fromTextArea(hr.current,{mode:Mt,lineNumbers:!sr,lineWrapping:!0,value:ft,autoCloseTags:!0,autoCloseBrackets:!0});vt&&yt.focus();function At(Et,kt){if(s){kt.preventDefault();return}var Bt=kt.clipboardData;if(Bt){var Kt=Bt.types.toString(),It=Bt.items;if(Kt==="Files"||Bt.types.indexOf("Files")>-1){if(kt.preventDefault(),Mt=="stex")return;try{var Zt,mr=It[1];((Zt=It[0])===null||Zt===void 0?void 0:Zt.kind)==="file"&&(mr=It[0]);var Ot=mr.getAsFile(),Pi=Ot.name.split(".").pop();Ae(Ot,function(Vt){if(Vt.id){var Sr,Yt,Qr;(Ot==null||((Sr=Ot.type)===null||Sr===void 0)?void 0:Sr.indexOf("image"))>-1?yt.replaceSelection(".concat(Vt.content_type,")")):(Ot==null||((Yt=Ot.type)===null||Yt===void 0)?void 0:Yt.indexOf("video"))>-1?yt.replaceSelection('<video width="100%" controls src="'.concat(M.a.API_SERVER,"/api/attachments/").concat(Vt.id,'"></video>')):(Ot==null||((Qr=Ot.type)===null||Qr===void 0)?void 0:Qr.indexOf("pdf"))>-1?yt.replaceSelection('<a href="'.concat(M.a.API_SERVER,"/api/attachments/").concat(Vt.id,"?type=").concat(Ot.type,'&disposition=inline" target="_blank">').concat(Ot.name,"</a>")):we.includes(Pi)?yt.replaceSelection('<a href="'.concat(M.a.API_SERVER,"/api/attachments/").concat(Vt.id,'?type=office&disposition=inline" target="_blank">').concat(Ot.name,"</a>")):yt.replaceSelection("[".concat(Ot.name,"](").concat(M.a.API_SERVER,"/api/attachments/").concat(Vt.id,"?type=").concat(Vt.content_type,")"))}else(Vt==null?void 0:Vt.status)===401&&(document.location.href="/user/login")})}catch(Vt){I.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return yt.on("paste",At),yt.on("dragleave",function(Et,kt){ai.current.classList.remove("mouse-hover-md")}),yt.on("dragover",function(Et,kt){ai.current.classList.add("mouse-hover-md")}),yt.on("drop",function(Et,kt){ai.current.classList.add("mouse-hover-md");var Bt;if(Bt=kt.dataTransfer.files,Bt.length>0){kt.preventDefault(),kt.stopPropagation();for(var Kt=function(mr){var Ot=Bt[mr],Pi=Ot.name.split(".").pop();Ae(Ot,function(Vt){if(Vt.id){var Sr,Yt,Qr;(Ot==null||((Sr=Ot.type)===null||Sr===void 0)?void 0:Sr.indexOf("image"))>-1?yt.replaceSelection(".concat(Vt.content_type,")")):(Ot==null||((Yt=Ot.type)===null||Yt===void 0)?void 0:Yt.indexOf("video"))>-1?yt.replaceSelection('<video width="100%" controls src="'.concat(M.a.API_SERVER,"/api/attachments/").concat(Vt.id,'"></video>')):(Ot==null||((Qr=Ot.type)===null||Qr===void 0)?void 0:Qr.indexOf("pdf"))>-1?yt.replaceSelection('<a href="'.concat(M.a.API_SERVER,"/api/attachments/").concat(Vt.id,"?type=").concat(Ot.type,'&disposition=inline" target="_blank">').concat(Ot.name,"</a>")):we.includes(Pi)?yt.replaceSelection('<a href="'.concat(M.a.API_SERVER,"/api/attachments/").concat(Vt.id,'?type=office&disposition=inline" target="_blank">').concat(Ot.name,"</a>")):yt.replaceSelection("[".concat(Ot.name,"](").concat(M.a.API_SERVER,"/api/attachments/").concat(Vt.id,"?type=").concat(Vt.content_type,")"))}else(Vt==null?void 0:Vt.status)===401&&(document.location.href="/user/login")})},It=0;It<Bt.length;It++)Kt(It)}}),gt(yt),function(){yt.off("paste",At)}}},[]);var Zr=Object(f.useCallback)(function(){if(ai.current)try{}catch(yt){console.log(yt,"---- to set md editor body height")}},[Mi,ai,Or]);Object(f.useEffect)(function(){function yt(){var Et=new g.default(function(kt){var Bt=Object(_.a)(kt),Kt;try{for(Bt.s();!(Kt=Bt.n()).done;){var It=Kt.value;(It.target.offsetHeight>0||It.target.offsetWidth>0)&&(Zr(),Ee.setSize("100%","100%"),Ee.refresh())}}catch(Zt){Bt.e(Zt)}finally{Bt.f()}});return Et.observe(hr.current.parentElement),Et}if(Ee){var At=yt();return function(){At.unobserve(hr.current.parentElement)}}},[Ee,Zr]),Object(f.useEffect)(function(){if(Ee){for(var yt=[],At=function(){var It=kt[Et];Bt=Object(B.a)(It,2);var Zt=Bt[0],mr=Bt[1],Ot=Object(N.a)({},Zt,function(){Xi(mr)});yt.push(Ot),Ee.addKeyMap(Ot)},Et=0,kt=Object.entries(je);Et<kt.length;Et++){var Bt;At()}return dr.current=setInterval(function(){yi.current&&Fn()},4e3),function(){clearInterval(dr.current);var Kt=Object(_.a)(yt),It;try{for(Kt.s();!(It=Kt.n()).done;){var Zt=It.value;Ee.removeKeyMap(Zt)}}catch(mr){Kt.e(mr)}finally{Kt.f()}}}},[Ee]),Object(f.useEffect)(function(){We!==Or&&ii(We)},[We]),Object(rt.a)(function(){if(!_r&&Ur>0){var yt=new Date().getTime(),At=window.sessionStorage.getItem(jt);yt>=Ur+fe&&(!At||At!==Nt)&&(window.sessionStorage.setItem(jt,Nt),Er(!0))}},fe),Object(f.useEffect)(function(){$r(Lr)},[Ee,Lr]),Object(f.useEffect)(function(){Ee&&(vt&&Ee.focus())},[Ee,vt]),Object(f.useEffect)(function(){if(pr&&Ee){var yt=Ee.getScrollerElement();function At(Et){var kt=Et.target;if(xi.current){var Bt=kt.scrollTop/kt.scrollHeight;xi.current.scrollTop=xi.current.scrollHeight*Bt}}return yt.addEventListener("scroll",At),function(){yt.removeEventListener("scroll",At)}}},[Ee,pr]),Object(f.useEffect)(function(){if(Ee&&ri){function yt(At,Et){ri(At,Et)}return Ee.on("beforeChange",yt),function(){Ee.off("beforeChange",yt)}}},[Ee,ri]),Object(f.useEffect)(function(){if(Ee&&Tt){function yt(){Tt(Ee.getValue())}return Ee.on("blur",yt),function(){Ee.off("blur",yt)}}},[Ee,Tt]),Object(f.useEffect)(function(){if(Ee){function yt(At){var Et=At.getValue();Gt(Et),Fr(new Date().getTime()),At.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),Ge&&Ge(Et)}return Ee.on("change",yt),function(){Ee.off("change",yt)}}},[Ee,Ge]),Object(f.useEffect)(function(){Ee&&(ft==null?(Ee.setValue(""),Gt("")):ft!==Ee.getValue()&&(Ee.setValue(ft),Gt(ft),Ee.setCursor(Ee.lineCount(),0)))},[Ee,ft]);var Xi=Object(f.useCallback)(function(yt){var At=Ee.getCursor(),Et=Ee.getSelection(),kt=Et.split(`
|
|
`);switch(yt){case"bold":return Ee.replaceSelection("**"+Et+"**"),Et===""&&Ee.setCursor(At.line,At.ch+2),Ee.focus();case"italic":return Ee.replaceSelection("*"+Et+"*"),Et===""&&Ee.setCursor(At.line,At.ch+1),Ee.focus();case"code":return Ee.replaceSelection("`"+Et+"`"),Et===""&&Ee.setCursor(At.line,At.ch+1),Ee.focus();case"inline-latex":return Ee.replaceSelection("`$$"+Et+"$$`"),Et===""&&Ee.setCursor(At.line,At.ch+3),Ee.focus();case"latex":return Ee.replaceSelection("```latex\n"+Et+"\n```"),Ee.setCursor(At.line+1,Et.length+1),Ee.focus();case"line-break":return Ee.replaceSelection(`<br/>
|
|
`),Ee.focus();case"list-ul":return Et===""?Ee.replaceSelection("- "+Et):Ee.replaceSelection(kt.map(function(Bt){return Bt===""?"":"- ".concat(Bt)}).join(`
|
|
`)),Ee.focus();case"list-ol":return Et===""?Ee.replaceSelection("1. "+Et):Ee.replaceSelection(kt.map(function(Bt,Kt){return Bt===""?"":"".concat(Kt+1,". ").concat(Bt)}).join(`
|
|
`)),Ee.focus();case"add-null-ch":return Et===""&&Ee.setCursor(At.line,At.ch+1),Ee.replaceSelection(ee),Ee.focus();case"inster-template-1":return Et===""&&Ee.setCursor(At.line,At.ch),Ee.replaceSelection(re),Ee.focus();case"eraser":return Ee.setValue(""),Ee.focus();case"trigger-watch":return $r(!pr),Ee.focus();case"trigger-full-screen":return ii(!Or),Ee.focus();case Ye:Kr(Ye);return;case et:Kr(et);return;case lt:Kr(lt);return;case Qe:Kr(Qe);return;default:throw new Error}},[Ee,pr,Or]),jr=Object(f.useCallback)(function(yt){Kr("");switch(ni){case Ye:var At=yt.title,Et=yt.link;return Ee.replaceSelection("[".concat(At,"](").concat(Et,")")),Ee.focus();case et:var kt=yt.language,Bt=yt.content;return Ee.replaceSelection(["```"+kt,Bt,"```"].join(`
|
|
`)),Ee.focus();case lt:var Kt=yt.src,It=yt.alt,Zt=yt.name;return Kt.indexOf("type=image")>-1?Ee.replaceSelection(".concat(Kt,' "').concat(It||"",'" )')):Kt.indexOf("type=application/pdf")>-1?Ee.replaceSelection('<a href="'.concat(Kt,'&disposition=inline" target="_blank">').concat(Zt,"</a>")):Ee.replaceSelection('<a href="'.concat(Kt,'" target="_blank">').concat(Zt,"</a>")),Ee.focus();case Qe:for(var mr=yt.row,Ot=yt.col,Pi=yt.align,Vt=`
|
|
`,Sr=0;Sr<mr;Sr++){for(var Yt=[],Qr=[],pn=0;pn<Ot;pn++)Sr===1&&Qr.push(st[Pi]),Yt.push(" ");Sr===1&&(Vt+="| ".concat(Qr.join(" | "),` |
|
|
`)),Vt+="| ".concat(Yt.join(Ot===1?"":" | "),` |
|
|
`)}return Ee.replaceSelection(Vt+`
|
|
`),Ee.focus();default:throw new Error}},[Ee,ni]),Yi=Object(f.useMemo)(function(){switch(ni){case Ye:return c.a.createElement(Se,{callback:jr,onCancel:ci});case et:return c.a.createElement(Te.b,{callback:jr,onCancel:ci});case lt:return c.a.createElement(Ze,{callback:jr,onCancel:ci});case Qe:return c.a.createElement(ht,{callback:jr,onCancel:ci});default:return null}},[ni]);function ci(){Kr("")}Object(f.useEffect)(function(){if(bi.current){var yt=bi.current,At=!1,Et=0;function kt(It){At=!0,Et=It.pageY}function Bt(){At=!1}function Kt(It){if(At){var Zt=It.pageY-Et;Zt<0&&(Zt=0),Zt>300&&(Zt=300);var mr=Ft+Zt+"px";ir(mr)}}return yt.addEventListener("mousedown",kt),document.addEventListener("mousemove",Kt),document.addEventListener("mouseup",Bt),function(){yt.removeEventListener("mousedown",kt),document.removeEventListener("mousemove",Kt),document.removeEventListener("mouseup",Bt)}}},[Ee,bi]),Object(f.useEffect)(function(){ir(Ft)},[Ft]);var Ei=ne(Ct),ua=ne(Mi),da={width:Ei,height:ua},Qa=Object(f.useMemo)(function(){if(Ur){var yt=new Date(Ur),At=yt.getHours(),Et=yt.getMinutes(),kt=yt.getSeconds();return At=At<10?"0"+At:At,Et=Et<10?"0"+Et:Et,kt=kt<10?"0"+kt:kt,"".concat(At,":").concat(Et,":").concat(kt)}return 0},[Ur]);function Ja(){window.sessionStorage.removeItem(jt),Er(!1),Fr(0)}function ha(){Er(!1),Fr(0),Ee.setValue(window.sessionStorage.getItem(jt))}function jn(yt,At){var Et=Ee.getValue();Et=Et.replace(yt,At),Gt(Et),Ee==null||Ee.setValue(Et)}return c.a.createElement(f.Fragment,null,c.a.createElement("div",{className:"markdown-editor-wrapper",ref:ai},c.a.createElement("div",{className:"markdown-editor-container ".concat(Ri," ").concat(pr?"on-preview":""," ").concat(sr?"mini":""," ").concat(Or?"full-screen":""),style:da},c.a.createElement(J,{insertTemp:fr,watch:pr,fullScreen:Or,showNullButton:Pt,onActionCallback:Xi,hidetoolBar:ui,uuid:$t.current,setOpenPhones:function(){yi.current=!0}}),c.a.createElement("div",{className:"markdown-editor-body"},c.a.createElement("div",{className:"codemirror-container"},c.a.createElement("textarea",{ref:hr,placeholder:W})),pr?c.a.createElement("div",{ref:xi,className:"preview-container"},Mt==="stex"&&c.a.createElement(D,{value:Nt}),Mt!=="stex"&&c.a.createElement(E.a,{edit:!0,value:Nt,replaces:jn})):null))),mt?c.a.createElement("a",{ref:bi,className:"editor-resize"}):null,c.a.createElement(K.a,null,ot[ni]?c.a.createElement(Y.a,{centered:!0,title:ot[ni],visible:!0,onCancel:ci,footer:null},Yi):null))}},RotF:function(dt,qe,te){dt.exports=te("LSTS")},SJMd:function(dt,qe){/**
|
|
* @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 te,ie,Y,_=!1,V,I;window.PR_SHOULD_USE_CONTINUATION=!0;var P,B;(function(){var N=window,O=["break,continue,do,else,for,if,return,while"],R=[O,"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"],f=[R,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],c=[f,"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"],k=[f,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],T=[f,"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"],g="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",b=[f,"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",a=[O,"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=[O,"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=[O,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],A=[c,T,k,b,u,a,l,h],m=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,E="str",D="kwd",w="com",y="typ",p="lit",d="pun",o="pln",C="tag",S="dec",x="src",M="atn",F="atv",G="nocode",J="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function K(Ae){for(var ke=0,He=!1,$e=!1,ze=0,Ie=Ae.length;ze<Ie;++ze){var Fe=Ae[ze];if(Fe.ignoreCase)$e=!0;else if(/[a-z]/i.test(Fe.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){He=!0,$e=!1;break}}var ht={b:8,t:9,n:10,v:11,f:12,r:13};function at(Qe){var Le=Qe.charCodeAt(0);if(Le!==92)return Le;var st=Qe.charAt(1);return Le=ht[st],Le||("0"<=st&&st<="7"?parseInt(Qe.substring(1),8):st==="u"||st==="x"?parseInt(Qe.substring(2),16):Qe.charCodeAt(1))}function tt(Qe){if(Qe<32)return(Qe<16?"\\x0":"\\x")+Qe.toString(16);var Le=String.fromCharCode(Qe);return Le==="\\"||Le==="-"||Le==="]"||Le==="^"?"\\"+Le:Le}function Ye(Qe){var Le=Qe.substring(1,Qe.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")),st=[],rt=Le[0]==="^",De=["["];rt&&De.push("^");for(var Ne=rt?1:0,me=Le.length;Ne<me;++Ne){var de=Le[Ne];if(/\\[bdsw]/i.test(de))De.push(de);else{var fe=at(de),ee;Ne+2<me&&Le[Ne+1]==="-"?(ee=at(Le[Ne+2]),Ne+=2):ee=fe,st.push([fe,ee]),ee<65||fe>122||(ee<65||fe>90||st.push([Math.max(65,fe)|32,Math.min(ee,90)|32]),ee<97||fe>122||st.push([Math.max(97,fe)&~32,Math.min(ee,122)&~32]))}}st.sort(function(ye,we){return ye[0]-we[0]||we[1]-ye[1]});for(var re=[],ne=[],Ne=0;Ne<st.length;++Ne){var ae=st[Ne];ae[0]<=ne[1]+1?ne[1]=Math.max(ne[1],ae[1]):re.push(ne=ae)}for(var Ne=0;Ne<re.length;++Ne){var ae=re[Ne];De.push(tt(ae[0])),ae[1]>ae[0]&&(ae[1]+1>ae[0]&&De.push("-"),De.push(tt(ae[1])))}return De.push("]"),De.join("")}function lt(Qe){for(var Le=Qe.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")),st=Le.length,rt=[],De=0,Ne=0;De<st;++De){var me=Le[De];if(me==="(")++Ne;else if(me.charAt(0)==="\\"){var de=+me.substring(1);de&&(de<=Ne?rt[de]=-1:Le[De]=tt(de))}}for(var De=1;De<rt.length;++De)rt[De]===-1&&(rt[De]=++ke);for(var De=0,Ne=0;De<st;++De){var me=Le[De];if(me==="(")++Ne,rt[Ne]||(Le[De]="(?:");else if(me.charAt(0)==="\\"){var de=+me.substring(1);de&&de<=Ne&&(Le[De]="\\"+rt[de])}}for(var De=0;De<st;++De)Le[De]==="^"&&Le[De+1]!=="^"&&(Le[De]="");if(Qe.ignoreCase&&He)for(var De=0;De<st;++De){var me=Le[De],fe=me.charAt(0);me.length>=2&&fe==="["?Le[De]=Ye(me):fe!=="\\"&&(Le[De]=me.replace(/[a-zA-Z]/g,function(ne){var ae=ne.charCodeAt(0);return"["+String.fromCharCode(ae&~32,ae|32)+"]"}))}return Le.join("")}for(var et=[],ze=0,Ie=Ae.length;ze<Ie;++ze){var Fe=Ae[ze];if(Fe.global||Fe.multiline)throw new Error(""+Fe);et.push("(?:"+lt(Fe)+")")}return new RegExp(et.join("|"),$e?"gi":"g")}function j(Ae,ke){var He=/(?:^|\s)nocode(?:\s|$)/,$e=[],ze=0,Ie=[],Fe=0;function ht(at){var tt=at.nodeType;if(tt==1){if(He.test(at.className))return;for(var Ye=at.firstChild;Ye;Ye=Ye.nextSibling)ht(Ye);var lt=at.nodeName.toLowerCase();(lt==="br"||lt==="li")&&($e[Fe]=`
|
|
`,Ie[Fe<<1]=ze++,Ie[Fe++<<1|1]=at)}else if(tt==3||tt==4){var et=at.nodeValue;et.length&&(ke?et=et.replace(/\r\n?/g,`
|
|
`):et=et.replace(/[ \t\r\n]+/g," "),$e[Fe]=et,Ie[Fe<<1]=ze,ze+=et.length,Ie[Fe++<<1|1]=at)}}return ht(Ae),{sourceCode:$e.join("").replace(/\n$/,""),spans:Ie}}function q(Ae,ke,He,$e,ze){if(!He)return;var Ie={sourceNode:Ae,pre:1,langExtension:null,numberLines:null,sourceCode:He,spans:null,basePos:ke,decorations:null};$e(Ie),ze.push.apply(ze,Ie.decorations)}var oe=/\S/;function ue(Ae){for(var ke=void 0,He=Ae.firstChild;He;He=He.nextSibling){var $e=He.nodeType;ke=$e===1?ke?Ae:He:$e===3&&oe.test(He.nodeValue)?Ae:ke}return ke===Ae?void 0:ke}function ge(Ae,ke){var He={},$e;(function(){for(var Fe=Ae.concat(ke),ht=[],at={},tt=0,Ye=Fe.length;tt<Ye;++tt){var lt=Fe[tt],et=lt[3];if(et)for(var Qe=et.length;--Qe>=0;)He[et.charAt(Qe)]=lt;var Le=lt[1],st=""+Le;at.hasOwnProperty(st)||(ht.push(Le),at[st]=null)}ht.push(/[\0-\uffff]/),$e=K(ht)})();var ze=ke.length,Ie=function(Fe){for(var ht=Fe.sourceCode,at=Fe.basePos,tt=Fe.sourceNode,Ye=[at,o],lt=0,et=ht.match($e)||[],Qe={},Le=0,st=et.length;Le<st;++Le){var rt=et[Le],De=Qe[rt],Ne=void 0,me;if(typeof De=="string")me=!1;else{var de=He[rt.charAt(0)];if(de)Ne=rt.match(de[1]),De=de[0];else{for(var fe=0;fe<ze;++fe)if(de=ke[fe],Ne=rt.match(de[1]),Ne){De=de[0];break}Ne||(De=o)}me=De.length>=5&&De.substring(0,5)==="lang-",me&&!(Ne&&typeof Ne[1]=="string")&&(me=!1,De=x),me||(Qe[rt]=De)}var ee=lt;if(lt+=rt.length,!me)Ye.push(at+ee,De);else{var re=Ne[1],ne=rt.indexOf(re),ae=ne+re.length;Ne[2]&&(ae=rt.length-Ne[2].length,ne=ae-re.length);var ye=De.substring(5);q(tt,at+ee,rt.substring(0,ne),Ie,Ye),q(tt,at+ee+ne,re,se(ye,re),Ye),q(tt,at+ee+ae,rt.substring(ae),Ie,Ye)}}Fe.decorations=Ye};return Ie}function _e(Ae){var ke=[],He=[];Ae.tripleQuotedStrings?ke.push([E,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Ae.multiLineStrings?ke.push([E,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):ke.push([E,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Ae.verbatimStrings&&He.push([E,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var $e=Ae.hashComments;$e&&(Ae.cStyleComments?($e>1?ke.push([w,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):ke.push([w,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),He.push([E,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):ke.push([w,/^#[^\r\n]*/,null,"#"])),Ae.cStyleComments&&(He.push([w,/^\/\/[^\r\n]*/,null]),He.push([w,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var ze=Ae.regexLiterals;if(ze){var Ie=ze>1?"":`
|
|
\r`,Fe=Ie?".":"[\\S\\s]",ht="/(?=[^/*"+Ie+"])(?:[^/\\x5B\\x5C"+Ie+"]|\\x5C"+Fe+"|\\x5B(?:[^\\x5C\\x5D"+Ie+"]|\\x5C"+Fe+")*(?:\\x5D|$))+/";He.push(["lang-regex",RegExp("^"+J+"("+ht+")")])}var at=Ae.types;at&&He.push([y,at]);var tt=(""+Ae.keywords).replace(/^ | $/g,"");tt.length&&He.push([D,new RegExp("^(?:"+tt.replace(/[\s,]+/g,"|")+")\\b"),null]),ke.push([o,/^\s+/,null,` \r
|
|
\xA0`]);var Ye="^.[^\\s\\w.$@'\"`/\\\\]*";return Ae.regexLiterals&&(Ye+="(?!s*/)"),He.push([p,/^@[a-z_$][a-z_$@0-9]*/i,null],[y,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[o,/^[a-z_$][a-z_$@0-9]*/i,null],[p,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[o,/^\\[\s\S]?/,null],[d,new RegExp(Ye),null]),ge(ke,He)}var be=_e({keywords:A,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Se(Ae,ke,He){for(var $e=/(?:^|\s)nocode(?:\s|$)/,ze=/\r\n?|\n/,Ie=Ae.ownerDocument,Fe=Ie.createElement("li");Ae.firstChild;)Fe.appendChild(Ae.firstChild);var ht=[Fe];function at(Le){var st=Le.nodeType;if(st==1&&!$e.test(Le.className))if(Le.nodeName==="br")tt(Le),Le.parentNode&&Le.parentNode.removeChild(Le);else for(var rt=Le.firstChild;rt;rt=rt.nextSibling)at(rt);else if((st==3||st==4)&&He){var De=Le.nodeValue,Ne=De.match(ze);if(Ne){var me=De.substring(0,Ne.index);Le.nodeValue=me;var de=De.substring(Ne.index+Ne[0].length);if(de){var fe=Le.parentNode;fe.insertBefore(Ie.createTextNode(de),Le.nextSibling)}tt(Le),me||Le.parentNode.removeChild(Le)}}}function tt(Le){for(;!Le.nextSibling;)if(Le=Le.parentNode,!Le)return;function st(Ne,me){var de=me?Ne.cloneNode(!1):Ne,fe=Ne.parentNode;if(fe){var ee=st(fe,1),re=Ne.nextSibling;ee.appendChild(de);for(var ne=re;ne;ne=re)re=ne.nextSibling,ee.appendChild(ne)}return de}for(var rt=st(Le.nextSibling,0),De;(De=rt.parentNode)&&De.nodeType===1;)rt=De;ht.push(rt)}for(var Ye=0;Ye<ht.length;++Ye)at(ht[Ye]);ke===(ke|0)&&ht[0].setAttribute("value",ke);var lt=Ie.createElement("ol");lt.className="linenums";for(var et=Math.max(0,ke-1|0)||0,Ye=0,Qe=ht.length;Ye<Qe;++Ye)Fe=ht[Ye],Fe.className="L"+(Ye+et)%10,Fe.firstChild||Fe.appendChild(Ie.createTextNode("\xA0")),lt.appendChild(Fe);Ae.appendChild(lt)}function Te(Ae){var ke=/\bMSIE\s(\d+)/.exec(navigator.userAgent);ke=ke&&+ke[1]<=8;var He=/\n/g,$e=Ae.sourceCode,ze=$e.length,Ie=0,Fe=Ae.spans,ht=Fe.length,at=0,tt=Ae.decorations,Ye=tt.length,lt=0;tt[Ye]=ze;var et,Qe;for(Qe=et=0;Qe<Ye;)tt[Qe]!==tt[Qe+2]?(tt[et++]=tt[Qe++],tt[et++]=tt[Qe++]):Qe+=2;for(Ye=et,Qe=et=0;Qe<Ye;){for(var Le=tt[Qe],st=tt[Qe+1],rt=Qe+2;rt+2<=Ye&&tt[rt+1]===st;)rt+=2;tt[et++]=Le,tt[et++]=st,Qe=rt}Ye=tt.length=et;var De=Ae.sourceNode,Ne="";De&&(Ne=De.style.display,De.style.display="none");try{for(var me=null;at<ht;){var de=Fe[at],fe=Fe[at+2]||ze,ee=tt[lt+2]||ze,rt=Math.min(fe,ee),re=Fe[at+1],ne;if(re.nodeType!==1&&(ne=$e.substring(Ie,rt))){ke&&(ne=ne.replace(He,"\r")),re.nodeValue=ne;var ae=re.ownerDocument,ye=ae.createElement("span");ye.className=tt[lt+1];var we=re.parentNode;we.replaceChild(ye,re),ye.appendChild(re),Ie<fe&&(Fe[at+1]=re=ae.createTextNode($e.substring(rt,fe)),we.insertBefore(re,ye.nextSibling))}Ie=rt,Ie>=fe&&(at+=2),Ie>=ee&&(lt+=2)}}finally{De&&(De.style.display=Ne)}}var Ce={};function pe(Ae,ke){for(var He=ke.length;--He>=0;){var $e=ke[He];Ce.hasOwnProperty($e)?N.console&&console.warn("cannot override language handler %s",$e):Ce[$e]=Ae}}function se(Ae,ke){return Ae&&Ce.hasOwnProperty(Ae)||(Ae=/^\s*</.test(ke)?"default-markup":"default-code"),Ce[Ae]}pe(be,["default-code"]),pe(ge([],[[o,/^[^<?]+/],[S,/^<!\w[^>]*(?:>|$)/],[w,/^<\!--[\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"]),pe(ge([[o,/^[\s]+/,null,` \r
|
|
`],[F,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[C,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[M,/^(?!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"]),pe(ge([],[[F,/^[\s\S]+/]]),["uq.val"]),pe(_e({keywords:c,hashComments:!0,cStyleComments:!0,types:m}),["c","cc","cpp","cxx","cyc","m"]),pe(_e({keywords:"null,true,false"}),["json"]),pe(_e({keywords:T,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:m}),["cs"]),pe(_e({keywords:k,cStyleComments:!0}),["java"]),pe(_e({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),pe(_e({keywords:a,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),pe(_e({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),pe(_e({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),pe(_e({keywords:b,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),pe(_e({keywords:g,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),pe(ge([],[[E,/^[\s\S]+/]]),["regex"]);function Re(Ae){var ke=Ae.langExtension;try{var He=j(Ae.sourceNode,Ae.pre),$e=He.sourceCode;Ae.sourceCode=$e,Ae.spans=He.spans,Ae.basePos=0,se(ke,$e)(Ae),Te(Ae)}catch(ze){N.console&&console.log(ze&&ze.stack||ze)}}function Je(Ae,ke,He){var $e=He||!1,ze=ke||null,Ie=document.createElement("div");Ie.innerHTML="<pre>"+Ae+"</pre>",Ie=Ie.firstChild,$e&&Se(Ie,$e,!0);var Fe={langExtension:ze,numberLines:$e,sourceNode:Ie,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return Re(Fe),Ie.innerHTML}function Xe(Ae,ke){var He=ke||document.body,$e=He.ownerDocument||document;function ze(de){return He.getElementsByTagName(de)}for(var Ie=[ze("pre"),ze("code"),ze("xmp")],Fe=[],ht=0;ht<Ie.length;++ht)for(var at=0,tt=Ie[ht].length;at<tt;++at)Fe.push(Ie[ht][at]);Ie=null;var Ye=Date;Ye.now||(Ye={now:function(){return+new Date}});var lt=0,et=/\blang(?:uage)?-([\w.]+)(?!\S)/,Qe=/\bprettyprint\b/,Le=/\bprettyprinted\b/,st=/pre|xmp/i,rt=/^code$/i,De=/^(?:pre|code|xmp)$/i,Ne={};function me(){for(var de=N.PR_SHOULD_USE_CONTINUATION?Ye.now()+250:Infinity;lt<Fe.length&&Ye.now()<de;lt++){for(var fe=Fe[lt],ee=Ne,re=fe;re=re.previousSibling;){var ne=re.nodeType,ae=(ne===7||ne===8)&&re.nodeValue;if(ae?!/^\??prettify\b/.test(ae):ne!==3||/\S/.test(re.nodeValue))break;if(ae){ee={},ae.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Ft,Dt,sr){ee[Dt]=sr});break}}var ye=fe.className;if((ee!==Ne||Qe.test(ye))&&!Le.test(ye)){for(var we=!1,je=fe.parentNode;je;je=je.parentNode){var ot=je.tagName;if(De.test(ot)&&je.className&&Qe.test(je.className)){we=!0;break}}if(!we){fe.className+=" prettyprinted";var xt=ee.lang;if(!xt){xt=ye.match(et);var Oe;!xt&&(Oe=ue(fe))&&rt.test(Oe.tagName)&&(xt=Oe.className.match(et)),xt&&(xt=xt[1])}var ct;if(st.test(fe.tagName))ct=1;else{var ft=fe.currentStyle,Ge=$e.defaultView,_t=ft?ft.whiteSpace:Ge&&Ge.getComputedStyle?Ge.getComputedStyle(fe,null).getPropertyValue("white-space"):0;ct=_t&&_t.substring(0,3)==="pre"}var Ct=ee.linenums;(Ct=Ct==="true"||+Ct)||(Ct=ye.match(/\blinenums\b(?::(\d+))?/),Ct=Ct?Ct[1]&&Ct[1].length?+Ct[1]:!0:!1),Ct&&Se(fe,Ct,ct);var Ut={langExtension:xt,sourceNode:fe,numberLines:Ct,pre:ct,sourceCode:null,basePos:null,spans:null,decorations:null};Re(Ut)}}}lt<Fe.length?N.setTimeout(me,250):typeof Ae=="function"&&Ae()}me()}var Ze=N.PR={createSimpleLexer:ge,registerLangHandler:pe,sourceDecorator:_e,PR_ATTRIB_NAME:M,PR_ATTRIB_VALUE:F,PR_COMMENT:w,PR_DECLARATION:S,PR_KEYWORD:D,PR_LITERAL:p,PR_NOCODE:G,PR_PLAIN:o,PR_PUNCTUATION:d,PR_SOURCE:x,PR_STRING:E,PR_TAG:C,PR_TYPE:y,prettyPrintOne:_?N.prettyPrintOne=Je:P=Je,prettyPrint:B=_?N.prettyPrint=Xe:B=Xe},Ke=N.define;typeof Ke=="function"&&Ke.amd&&Ke("google-code-prettify",[],function(){return Ze})})()},SbmS:function(dt,qe,te){dt.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(dt,qe,te){},"VrN/":function(dt,qe,te){(function(ie,Y){dt.exports=Y()})(this,function(){"use strict";var ie=navigator.userAgent,Y=navigator.platform,_=/gecko\/\d/i.test(ie),V=/MSIE \d/.test(ie),I=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ie),P=/Edge\/(\d+)/.exec(ie),B=V||I||P,N=B&&(V?document.documentMode||6:+(P||I)[1]),O=!P&&/WebKit\//.test(ie),R=O&&/Qt\/\d+\.\d+/.test(ie),f=!P&&/Chrome\//.test(ie),c=/Opera\//.test(ie),k=/Apple Computer/.test(navigator.vendor),T=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ie),g=/PhantomJS/.test(ie),b=!P&&/AppleWebKit/.test(ie)&&/Mobile\/\w+/.test(ie),u=/Android/.test(ie),a=b||u||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ie),l=b||/Mac/.test(Y),h=/\bCrOS\b/.test(ie),A=/win/i.test(Y),m=c&&ie.match(/Version\/(\d*\.\d*)/);m&&(m=Number(m[1])),m&&m>=15&&(c=!1,O=!0);var E=l&&(R||c&&(m==null||m<12.11)),D=_||B&&N>=9;function w(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var y=function(e,t){var i=e.className,r=w(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 p(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function d(e,t){return p(e).appendChild(t)}function o(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 L=0;L<t.length;++L)n.appendChild(t[L]);return n}function C(e,t,i,r){var n=o(e,t,i,r);return n.setAttribute("role","presentation"),n}var S;document.createRange?S=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:S=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 x(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 M(){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 F(e,t){var i=e.className;w(t).test(i)||(e.className+=(i?" ":"")+t)}function G(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!w(i[r]).test(t)&&(t+=" "+i[r]);return t}var J=function(e){e.select()};b?J=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:B&&(J=function(e){try{e.select()}catch(t){}});function K(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 L=r||0,U=n||0;;){var X=e.indexOf(" ",L);if(X<0||X>=t)return U+(t-L);U+=X-L,U+=i-U%i,L=X+1}}var oe=function(){this.id=null,this.f=null,this.time=0,this.handler=K(this.onTimeout,this)};oe.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},oe.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 ue(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var ge=50,_e={toString:function(){return"CodeMirror.Pass"}},be={scroll:!1},Se={origin:"*mouse"},Te={origin:"+move"};function Ce(e,t,i){for(var r=0,n=0;;){var L=e.indexOf(" ",r);L==-1&&(L=e.length);var U=L-r;if(L==e.length||n+U>=t)return r+Math.min(U,t-n);if(n+=L-r,n+=i-n%i,r=L+1,n>=t)return r}}var pe=[""];function se(e){for(;pe.length<=e;)pe.push(Re(pe)+" ");return pe[e]}function Re(e){return e[e.length-1]}function Je(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function Xe(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function Ze(){}function Ke(e,t){var i;return Object.create?i=Object.create(e):(Ze.prototype=e,i=new Ze),t&&j(t,i),i}var Ae=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function ke(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Ae.test(e))}function He(e,t){return t?t.source.indexOf("\\w")>-1&&ke(e)?!0:t.test(e):ke(e)}function $e(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ze=/[\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 Ie(e){return e.charCodeAt(0)>=768&&ze.test(e)}function Fe(e,t,i){for(;(i<0?t>0:t<e.length)&&Ie(e.charAt(t));)t+=i;return t}function ht(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,L=r<0?Math.ceil(n):Math.floor(n);if(L==t)return e(L)?t:i;e(L)?i=L:t=L+r}}function at(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,L=0;L<e.length;++L){var U=e[L];(U.from<i&&U.to>t||t==i&&U.to==t)&&(r(Math.max(U.from,t),Math.min(U.to,i),U.level==1?"rtl":"ltr",L),n=!0)}n||r(t,i,"ltr")}var tt=null;function Ye(e,t,i){var r;tt=null;for(var n=0;n<e.length;++n){var L=e[n];if(L.from<t&&L.to>t)return n;L.to==t&&(L.from!=L.to&&i=="before"?r=n:tt=n),L.from==t&&(L.from!=L.to&&i!="before"?r=n:tt=n)}return r!=null?r:tt}var lt=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(Z){return Z<=247?e.charAt(Z):1424<=Z&&Z<=1524?"R":1536<=Z&&Z<=1785?t.charAt(Z-1536):1774<=Z&&Z<=2220?"r":8192<=Z&&Z<=8203?"w":Z==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,L=/[LRr]/,U=/[Lb1n]/,X=/[1n]/;function $(Z,le,he){this.level=Z,this.from=le,this.to=he}return function(Z,le){var he=le=="ltr"?"L":"R";if(Z.length==0||le=="ltr"&&!r.test(Z))return!1;for(var xe=Z.length,ve=[],Me=0;Me<xe;++Me)ve.push(i(Z.charCodeAt(Me)));for(var Ue=0,Ve=he;Ue<xe;++Ue){var it=ve[Ue];it=="m"?ve[Ue]=Ve:Ve=it}for(var ut=0,nt=he;ut<xe;++ut){var pt=ve[ut];pt=="1"&&nt=="r"?ve[ut]="n":L.test(pt)&&(nt=pt,pt=="r"&&(ve[ut]="R"))}for(var St=1,bt=ve[0];St<xe-1;++St){var Rt=ve[St];Rt=="+"&&bt=="1"&&ve[St+1]=="1"?ve[St]="1":Rt==","&&bt==ve[St+1]&&(bt=="1"||bt=="n")&&(ve[St]=bt),bt=Rt}for(var Qt=0;Qt<xe;++Qt){var yr=ve[Qt];if(yr==",")ve[Qt]="N";else if(yr=="%"){var qt=void 0;for(qt=Qt+1;qt<xe&&ve[qt]=="%";++qt);for(var Hr=Qt&&ve[Qt-1]=="!"||qt<xe&&ve[qt]=="1"?"1":"N",Ir=Qt;Ir<qt;++Ir)ve[Ir]=Hr;Qt=qt-1}}for(var ar=0,Nr=he;ar<xe;++ar){var Cr=ve[ar];Nr=="L"&&Cr=="1"?ve[ar]="L":L.test(Cr)&&(Nr=Cr)}for(var cr=0;cr<xe;++cr)if(n.test(ve[cr])){var or=void 0;for(or=cr+1;or<xe&&n.test(ve[or]);++or);for(var tr=(cr?ve[cr-1]:he)=="L",Br=(or<xe?ve[or]:he)=="L",hn=tr==Br?tr?"L":"R":he,_i=cr;_i<or;++_i)ve[_i]=hn;cr=or-1}for(var wr=[],li,br=0;br<xe;)if(U.test(ve[br])){var Ya=br;for(++br;br<xe&&U.test(ve[br]);++br);wr.push(new $(0,Ya,br))}else{var mi=br,zi=wr.length,Gi=le=="rtl"?1:0;for(++br;br<xe&&ve[br]!="L";++br);for(var Dr=mi;Dr<br;)if(X.test(ve[Dr])){mi<Dr&&(wr.splice(zi,0,new $(1,mi,Dr)),zi+=Gi);var cn=Dr;for(++Dr;Dr<br&&X.test(ve[Dr]);++Dr);wr.splice(zi,0,new $(2,cn,Dr)),zi+=Gi,mi=Dr}else++Dr;mi<br&&wr.splice(zi,0,new $(1,mi,br))}return le=="ltr"&&(wr[0].level==1&&(li=Z.match(/^\s+/))&&(wr[0].from=li[0].length,wr.unshift(new $(0,0,li[0].length))),Re(wr).level==1&&(li=Z.match(/\s+$/))&&(Re(wr).to-=li[0].length,wr.push(new $(0,xe-li[0].length,xe)))),le=="rtl"?wr.reverse():wr}}();function et(e,t){var i=e.order;return i==null&&(i=e.order=lt(e.text,t)),i}var Qe=[],Le=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]||Qe).concat(i)}};function st(e,t){return e._handlers&&e._handlers[t]||Qe}function rt(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 L=ue(n,i);L>-1&&(r[t]=n.slice(0,L).concat(n.slice(L+1)))}}}function De(e,t){var i=st(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 Ne(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),De(e,i||t.type,e,t),ne(t)||t.codemirrorIgnore}function me(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)ue(i,t[r])==-1&&i.push(t[r])}function de(e,t){return st(e,t).length>0}function fe(e){e.prototype.on=function(t,i){Le(this,t,i)},e.prototype.off=function(t,i){rt(this,t,i)}}function ee(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function re(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ne(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ae(e){ee(e),re(e)}function ye(e){return e.target||e.srcElement}function we(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 je=function(){if(B&&N<9)return!1;var e=o("div");return"draggable"in e||"dragDrop"in e}(),ot;function xt(e){if(ot==null){var t=o("span","\u200B");d(e,o("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(ot=t.offsetWidth<=1&&t.offsetHeight>2&&!(B&&N<8))}var i=ot?o("span","\u200B"):o("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var Oe;function ct(e){if(Oe!=null)return Oe;var t=d(e,document.createTextNode("A\u062EA")),i=S(t,0,1).getBoundingClientRect(),r=S(t,1,2).getBoundingClientRect();return p(e),!i||i.left==i.right?!1:Oe=r.right-i.right<3}var ft=`
|
|
|
|
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 L=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),U=L.indexOf("\r");U!=-1?(i.push(L.slice(0,U)),t+=U+1):(i.push(L),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},Ge=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},_t=function(){var e=o("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Ct=null;function Ut(e){if(Ct!=null)return Ct;var t=d(e,o("span","x")),i=t.getBoundingClientRect(),r=S(t,0,1).getBoundingClientRect();return Ct=Math.abs(i.left-r.left)>1}var Ft={},Dt={};function sr(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Ft[e]=t}function rr(e,t){Dt[e]=t}function vt(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=Ke(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return vt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return vt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Lr(e,t){t=vt(t);var i=Ft[t.name];if(!i)return Lr(e,"text/plain");var r=i(e,t);if(fr.hasOwnProperty(t.name)){var n=fr[t.name];for(var L in n){if(!n.hasOwnProperty(L))continue;r.hasOwnProperty(L)&&(r["_"+L]=r[L]),r[L]=n[L]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var U in t.modeProps)r[U]=t.modeProps[U];return r}var fr={};function lr(e,t){var i=fr.hasOwnProperty(e)?fr[e]:fr[e]={};j(t,i)}function Mt(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 er(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 jt(e,t,i){return e.startState?e.startState(t,i):!0}var Lt=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};Lt.prototype.eol=function(){return this.pos>=this.string.length},Lt.prototype.sol=function(){return this.pos==this.lineStart},Lt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Lt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Lt.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},Lt.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Lt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Lt.prototype.skipToEnd=function(){this.pos=this.string.length},Lt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Lt.prototype.backUp=function(e){this.pos-=e},Lt.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)},Lt.prototype.indentation=function(){return q(this.string,null,this.tabSize)-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},Lt.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(U){return i?U.toLowerCase():U},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var L=this.string.slice(this.pos).match(e);return L&&L.index>0?null:(L&&t!==!1&&(this.pos+=L[0].length),L)}},Lt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Lt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Lt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Lt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function mt(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],L=n.chunkSize();if(t<L){i=n;break}t-=L}return i.lines[t]}function ur(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(L){var U=L.text;n==i.line&&(U=U.slice(0,i.ch)),n==t.line&&(U=U.slice(t.ch)),r.push(U),++n}),r}function _r(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function Rr(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function Pt(e){if(e.parent==null)return null;for(var t=e.parent,i=ue(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 Yr(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],L=n.height;if(t<L){e=n;continue e}t-=L,i+=n.chunkSize()}return i}while(!e.lines);for(var U=0;U<e.lines.length;++U){var X=e.lines[U],$=X.height;if(t<$)break;t-=$}return i+U}function ui(e,t){return t>=e.first&&t<e.first+e.size}function gi(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 Tt(e,t){return e.line-t.line||e.ch-t.ch}function ri(e,t){return e.sticky==t.sticky&&Tt(e,t)==0}function di(e){return We(e.line,e.ch)}function hi(e,t){return Tt(e,t)<0?t:e}function Ri(e,t){return Tt(e,t)<0?e:t}function z(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,mt(e,i).text.length):v(t,mt(e,t.line).text.length)}function v(e,t){var i=e.ch;return i==null||i>t?We(e.line,t):i<0?We(e.line,0):e}function W(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=s(e,t[r]);return i}var Q=function(e,t){this.state=e,this.lookAhead=t},H=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};H.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},H.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}},H.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},H.fromSaved=function(e,t,i){return t instanceof Q?new H(e,Mt(e.mode,t.state),i,t.lookAhead):new H(e,Mt(e.mode,t),i)},H.prototype.save=function(e){var t=e!==!1?Mt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Q(t,this.maxLookAhead):t};function ce(e,t,i,r){var n=[e.state.modeGen],L={};Gr(e,t.text,e.doc.mode,i,function(Z,le){return n.push(Z,le)},L,r);for(var U=i.state,X=function(Z){i.baseTokens=n;var le=e.state.overlays[Z],he=1,xe=0;i.state=!0,Gr(e,t.text,le.mode,i,function(ve,Me){for(var Ue=he;xe<ve;){var Ve=n[he];Ve>ve&&n.splice(he,1,ve,n[he+1],Ve),he+=2,xe=Math.min(ve,Ve)}if(!Me)return;if(le.opaque)n.splice(Ue,he-Ue,ve,"overlay "+Me),he=Ue+2;else for(;Ue<he;Ue+=2){var it=n[Ue+1];n[Ue+1]=(it?it+" ":"")+"overlay "+Me}},L),i.state=U,i.baseTokens=null,i.baseTokenPos=1},$=0;$<e.state.overlays.length;++$)X($);return{styles:n,classes:L.bgClass||L.textClass?L:null}}function Pe(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Ee(e,Pt(t)),n=t.text.length>e.options.maxHighlightLength&&Mt(e.doc.mode,r.state),L=ce(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=L.styles,L.classes?t.styleClasses=L.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 Ee(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new H(r,!0,t);var L=pr(e,t,i),U=L>r.first&&mt(r,L-1).stateAfter,X=U?H.fromSaved(r,U,L):new H(r,jt(r.mode),L);return r.iter(L,t,function($){gt(e,$.text,X);var Z=X.line;$.stateAfter=Z==t-1||Z%5==0||Z>=n.viewFrom&&Z<n.viewTo?X.save():null,X.nextLine()}),i&&(r.modeFrontier=X.line),X}function gt(e,t,i,r){var n=e.doc.mode,L=new Lt(t,e.options.tabSize,i);for(L.start=L.pos=r||0,t==""&&Be(n,i.state);!L.eol();)wt(n,L,i.state),L.start=L.pos}function Be(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=er(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function wt(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=er(e,i).mode);var L=e.token(t,i);if(t.pos>t.start)return L}throw new Error("Mode "+e.name+" failed to advance stream.")}var Nt=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Gt(e,t,i,r){var n=e.doc,L=n.mode,U;t=s(n,t);var X=mt(n,t.line),$=Ee(e,t.line,i),Z=new Lt(X.text,e.options.tabSize,$),le;for(r&&(le=[]);(r||Z.pos<t.ch)&&!Z.eol();)Z.start=Z.pos,U=wt(L,Z,$.state),r&&le.push(new Nt(Z,U,Mt(n.mode,$.state)));return r?le:new Nt(Z,U,$.state)}function zr(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 Gr(e,t,i,r,n,L,U){var X=i.flattenSpans;X==null&&(X=e.options.flattenSpans);var $=0,Z=null,le=new Lt(t,e.options.tabSize,r),he,xe=e.options.addModeClass&&[null];for(t==""&&zr(Be(i,r.state),L);!le.eol();){if(le.pos>e.options.maxHighlightLength?(X=!1,U&>(e,t,r,le.pos),le.pos=t.length,he=null):he=zr(wt(i,le,r.state,xe),L),xe){var ve=xe[0].name;ve&&(he="m-"+(he?ve+" "+he:ve))}if(!X||Z!=he){for(;$<le.start;)$=Math.min(le.start,$+5e3),n($,Z);Z=he}le.start=le.pos}for(;$<le.pos;){var Me=Math.min(le.pos,$+5e3);n(Me,Z),$=Me}}function pr(e,t,i){for(var r,n,L=e.doc,U=i?-1:t-(e.doc.mode.innerMode?1e3:100),X=t;X>U;--X){if(X<=L.first)return L.first;var $=mt(L,X-1),Z=$.stateAfter;if(Z&&(!i||X+(Z instanceof Q?Z.lookAhead:0)<=L.modeFrontier))return X;var le=q($.text,null,e.options.tabSize);(n==null||r>le)&&(n=X-1,r=le)}return n}function $r(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=mt(e,r).stateAfter;if(n&&(!(n instanceof Q)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Ki=!1,kr=!1;function Or(){Ki=!0}function ii(){kr=!0}function vi(e,t,i){this.marker=e,this.from=t,this.to=i}function Jr(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function ni(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function Kr(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function fn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var L=e[n],U=L.marker,X=L.from==null||(U.inclusiveLeft?L.from<=t:L.from<t);if(X||L.from==t&&U.type=="bookmark"&&(!i||!L.marker.insertLeft)){var $=L.to==null||(U.inclusiveRight?L.to>=t:L.to>t);(r||(r=[])).push(new vi(U,L.from,$?null:L.to))}}return r}function Vi(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var L=e[n],U=L.marker,X=L.to==null||(U.inclusiveRight?L.to>=t:L.to>t);if(X||L.from==t&&U.type=="bookmark"&&(!i||L.marker.insertLeft)){var $=L.from==null||(U.inclusiveLeft?L.from<=t:L.from<t);(r||(r=[])).push(new vi(U,$?null:L.from-t,L.to==null?null:L.to-t))}}return r}function Ur(e,t){if(t.full)return null;var i=ui(e,t.from.line)&&mt(e,t.from.line).markedSpans,r=ui(e,t.to.line)&&mt(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,L=t.to.ch,U=Tt(t.from,t.to)==0,X=fn(i,n,U),$=Vi(r,L,U),Z=t.text.length==1,le=Re(t.text).length+(Z?n:0);if(X)for(var he=0;he<X.length;++he){var xe=X[he];if(xe.to==null){var ve=Jr($,xe.marker);ve?Z&&(xe.to=ve.to==null?null:ve.to+le):xe.to=n}}if($)for(var Me=0;Me<$.length;++Me){var Ue=$[Me];if(Ue.to!=null&&(Ue.to+=le),Ue.from==null){var Ve=Jr(X,Ue.marker);Ve||(Ue.from=le,Z&&(X||(X=[])).push(Ue))}else Ue.from+=le,Z&&(X||(X=[])).push(Ue)}X&&(X=Fr(X)),$&&$!=X&&($=Fr($));var it=[X];if(!Z){var ut=t.text.length-2,nt;if(ut>0&&X)for(var pt=0;pt<X.length;++pt)X[pt].to==null&&(nt||(nt=[])).push(new vi(X[pt].marker,null,null));for(var St=0;St<ut;++St)it.push(nt);it.push($)}return it}function Fr(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 ki(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(ve){if(ve.markedSpans)for(var Me=0;Me<ve.markedSpans.length;++Me){var Ue=ve.markedSpans[Me].marker;Ue.readOnly&&(!r||ue(r,Ue)==-1)&&(r||(r=[])).push(Ue)}}),!r)return null;for(var n=[{from:t,to:i}],L=0;L<r.length;++L)for(var U=r[L],X=U.find(0),$=0;$<n.length;++$){var Z=n[$];if(Tt(Z.to,X.from)<0||Tt(Z.from,X.to)>0)continue;var le=[$,1],he=Tt(Z.from,X.from),xe=Tt(Z.to,X.to);(he<0||!U.inclusiveLeft&&!he)&&le.push({from:Z.from,to:X.from}),(xe>0||!U.inclusiveRight&&!xe)&&le.push({from:X.to,to:Z.to}),n.splice.apply(n,le),$+=le.length-3}return n}function Oi(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 Mi(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function ir(e){return e.inclusiveLeft?-1:0}function Wt(e){return e.inclusiveRight?1:0}function xr(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),L=Tt(r.from,n.from)||ir(e)-ir(t);if(L)return-L;var U=Tt(r.to,n.to)||Wt(e)-Wt(t);return U||t.id-e.id}function Ht(e,t){var i=kr&&e.markedSpans,r;if(i)for(var n=void 0,L=0;L<i.length;++L)n=i[L],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||xr(r,n.marker)<0)&&(r=n.marker);return r}function Er(e){return Ht(e,!0)}function $t(e){return Ht(e,!1)}function yi(e,t){var i=kr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var L=i[n];L.marker.collapsed&&(L.from==null||L.from<t)&&(L.to==null||L.to>t)&&(!r||xr(r,L.marker)<0)&&(r=L.marker)}return r}function dr(e,t,i,r,n){var L=mt(e,t),U=kr&&L.markedSpans;if(U)for(var X=0;X<U.length;++X){var $=U[X];if(!$.marker.collapsed)continue;var Z=$.marker.find(0),le=Tt(Z.from,i)||ir($.marker)-ir(n),he=Tt(Z.to,r)||Wt($.marker)-Wt(n);if(le>=0&&he<=0||le<=0&&he>=0)continue;if(le<=0&&($.marker.inclusiveRight&&n.inclusiveLeft?Tt(Z.to,i)>=0:Tt(Z.to,i)>0)||le>=0&&($.marker.inclusiveRight&&n.inclusiveLeft?Tt(Z.from,r)<=0:Tt(Z.from,r)<0))return!0}}function hr(e){for(var t;t=Er(e);)e=t.find(-1,!0).line;return e}function ai(e){for(var t;t=$t(e);)e=t.find(1,!0).line;return e}function bi(e){for(var t,i;t=$t(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function xi(e,t){var i=mt(e,t),r=hr(i);return i==r?t:Pt(r)}function Fn(e,t){if(t>e.lastLine())return t;var i=mt(e,t),r;if(!Zr(e,i))return t;for(;r=$t(i);)i=r.find(1,!0).line;return Pt(i)+1}function Zr(e,t){var i=kr&&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&&Xi(e,t,r))return!0}}function Xi(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return Xi(e,r.line,Jr(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,L=0;L<t.markedSpans.length;++L)if(n=t.markedSpans[L],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&Xi(e,t,n))return!0}function jr(e){e=hr(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 L=i.parent;L;i=L,L=i.parent)for(var U=0;U<L.children.length;++U){var X=L.children[U];if(X==i)break;t+=X.height}return t}function Yi(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=Er(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=$t(r);){var L=i.find(0,!0);t-=r.text.length-L.from.ch,r=L.to.line,t+=r.text.length-L.to.ch}return t}function ci(e){var t=e.display,i=e.doc;t.maxLine=mt(i,i.first),t.maxLineLength=Yi(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=Yi(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Ei=function(e,t,i){this.text=e,Mi(this,t),this.height=i?i(this):1};Ei.prototype.lineNo=function(){return Pt(this)},fe(Ei);function ua(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Oi(e),Mi(e,i);var n=r?r(e):1;n!=e.height&&Rr(e,n)}function da(e){e.parent=null,Oi(e)}var Qa={},Ja={};function ha(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?Ja:Qa;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function jn(e,t){var i=C("span",null,null,O?"padding-right: .1px":null),r={pre:C("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 L=n?t.rest[n-1]:t.line,U=void 0;r.pos=0,r.addToken=At,ct(e.display.measure)&&(U=et(L,e.doc.direction))&&(r.addToken=kt(r.addToken,U)),r.map=[];var X=t!=e.display.externalMeasured&&Pt(L);Kt(L,r,Pe(e,L,X)),L.styleClasses&&(L.styleClasses.bgClass&&(r.bgClass=G(L.styleClasses.bgClass,r.bgClass||"")),L.styleClasses.textClass&&(r.textClass=G(L.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(xt(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(O){var $=r.content.lastChild;(/\bcm-tab\b/.test($.className)||$.querySelector&&$.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return De(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=G(r.pre.className,r.textClass||"")),r}function yt(e){var t=o("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function At(e,t,i,r,n,L,U){if(!t)return;var X=e.splitSpaces?Et(t,e.trailingSpace):t,$=e.cm.state.specialChars,Z=!1,le;if(!$.test(t))e.col+=t.length,le=document.createTextNode(X),e.map.push(e.pos,e.pos+t.length,le),B&&N<9&&(Z=!0),e.pos+=t.length;else{le=document.createDocumentFragment();for(var he=0;;){$.lastIndex=he;var xe=$.exec(t),ve=xe?xe.index-he:t.length-he;if(ve){var Me=document.createTextNode(X.slice(he,he+ve));B&&N<9?le.appendChild(o("span",[Me])):le.appendChild(Me),e.map.push(e.pos,e.pos+ve,Me),e.col+=ve,e.pos+=ve}if(!xe)break;he+=ve+1;var Ue=void 0;if(xe[0]==" "){var Ve=e.cm.options.tabSize,it=Ve-e.col%Ve;Ue=le.appendChild(o("span",se(it),"cm-tab")),Ue.setAttribute("role","presentation"),Ue.setAttribute("cm-text"," "),e.col+=it}else xe[0]=="\r"||xe[0]==`
|
|
`?(Ue=le.appendChild(o("span",xe[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Ue.setAttribute("cm-text",xe[0]),e.col+=1):(Ue=e.cm.options.specialCharPlaceholder(xe[0]),Ue.setAttribute("cm-text",xe[0]),B&&N<9?le.appendChild(o("span",[Ue])):le.appendChild(Ue),e.col+=1);e.map.push(e.pos,e.pos+1,Ue),e.pos++}}if(e.trailingSpace=X.charCodeAt(t.length-1)==32,i||r||n||Z||L||U){var ut=i||"";r&&(ut+=r),n&&(ut+=n);var nt=o("span",[le],ut,L);if(U)for(var pt in U)U.hasOwnProperty(pt)&&pt!="style"&&pt!="class"&&nt.setAttribute(pt,U[pt]);return e.content.appendChild(nt)}e.content.appendChild(le)}function Et(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var L=e.charAt(n);L==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(L="\xA0"),r+=L,i=L==" "}return r}function kt(e,t){return function(i,r,n,L,U,X,$){n=n?n+" cm-force-border":"cm-force-border";for(var Z=i.pos,le=Z+r.length;;){for(var he=void 0,xe=0;xe<t.length&&!(he=t[xe],he.to>Z&&he.from<=Z);xe++);if(he.to>=le)return e(i,r,n,L,U,X,$);e(i,r.slice(0,he.to-Z),n,L,null,X,$),L=null,r=r.slice(he.to-Z),Z=he.to}}}function Bt(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 Kt(e,t,i){var r=e.markedSpans,n=e.text,L=0;if(!r){for(var U=1;U<i.length;U+=2)t.addToken(t,n.slice(L,L=i[U]),ha(i[U+1],t.cm.options));return}for(var X=n.length,$=0,Z=1,le="",he,xe,ve=0,Me,Ue,Ve,it,ut;;){if(ve==$){Me=Ue=Ve=xe="",ut=null,it=null,ve=Infinity;for(var nt=[],pt=void 0,St=0;St<r.length;++St){var bt=r[St],Rt=bt.marker;if(Rt.type=="bookmark"&&bt.from==$&&Rt.widgetNode)nt.push(Rt);else if(bt.from<=$&&(bt.to==null||bt.to>$||Rt.collapsed&&bt.to==$&&bt.from==$)){if(bt.to!=null&&bt.to!=$&&ve>bt.to&&(ve=bt.to,Ue=""),Rt.className&&(Me+=" "+Rt.className),Rt.css&&(xe=(xe?xe+";":"")+Rt.css),Rt.startStyle&&bt.from==$&&(Ve+=" "+Rt.startStyle),Rt.endStyle&&bt.to==ve&&(pt||(pt=[])).push(Rt.endStyle,bt.to),Rt.title&&((ut||(ut={})).title=Rt.title),Rt.attributes)for(var Qt in Rt.attributes)(ut||(ut={}))[Qt]=Rt.attributes[Qt];Rt.collapsed&&(!it||xr(it.marker,Rt)<0)&&(it=bt)}else bt.from>$&&ve>bt.from&&(ve=bt.from)}if(pt)for(var yr=0;yr<pt.length;yr+=2)pt[yr+1]==ve&&(Ue+=" "+pt[yr]);if(!it||it.from==$)for(var qt=0;qt<nt.length;++qt)Bt(t,0,nt[qt]);if(it&&(it.from||0)==$){if(Bt(t,(it.to==null?X+1:it.to)-$,it.marker,it.from==null),it.to==null)return;it.to==$&&(it=!1)}}if($>=X)break;for(var Hr=Math.min(X,ve);;){if(le){var Ir=$+le.length;if(!it){var ar=Ir>Hr?le.slice(0,Hr-$):le;t.addToken(t,ar,he?he+Me:Me,Ve,$+ar.length==ve?Ue:"",xe,ut)}if(Ir>=Hr){le=le.slice(Hr-$),$=Hr;break}$=Ir,Ve=""}le=n.slice(L,L=i[Z++]),he=ha(i[Z++],t.cm.options)}}}function It(e,t,i){this.line=t,this.rest=bi(t),this.size=this.rest?Pt(Re(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Zr(e,t)}function Zt(e,t,i){for(var r=[],n,L=t;L<i;L=n){var U=new It(e.doc,mt(e.doc,L),L);n=L+U.size,r.push(U)}return r}var mr=null;function Ot(e){mr?mr.ops.push(e):e.ownsGroup=mr={ops:[e],delayedCallbacks:[]}}function Pi(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 Vt(e,t){var i=e.ownsGroup;if(!i)return;try{Pi(i)}finally{mr=null,t(i)}}var Sr=null;function Yt(e,t){var i=st(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;mr?n=mr.delayedCallbacks:Sr?n=Sr:(n=Sr=[],setTimeout(Qr,0));for(var L=function(X){n.push(function(){return i[X].apply(null,r)})},U=0;U<i.length;++U)L(U)}function Qr(){var e=Sr;Sr=null;for(var t=0;t<e.length;++t)e[t]()}function pn(e,t,i,r){for(var n=0;n<t.changes.length;n++){var L=t.changes[n];L=="text"?Ps(e,t):L=="gutter"?qa(e,t,i,r):L=="class"?ca(e,t):L=="widget"&&Is(e,t,r)}t.changes=null}function mn(e){return e.node==e.text&&(e.node=o("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),B&&N<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(o("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function Za(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):jn(e,t)}function Ps(e,t){var i=t.text.className,r=Za(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,ca(e,t)):i&&(t.text.className=i)}function ca(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=o("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 L=t.line.gutterMarkers;if(e.options.lineNumbers||L){var U=mn(t),X=t.gutter=o("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(X),U.insertBefore(X,t.text),t.line.gutterClass&&(X.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!L||!L["CodeMirror-linenumbers"])&&(t.lineNumber=X.appendChild(o("div",gi(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),L)for(var $=0;$<e.display.gutterSpecs.length;++$){var Z=e.display.gutterSpecs[$].className,le=L.hasOwnProperty(Z)&&L[Z];le&&X.appendChild(o("div",[le],"CodeMirror-gutter-elt","left: "+r.gutterLeft[Z]+"px; width: "+r.gutterWidth[Z]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=w("CodeMirror-linewidget"),n=t.node.firstChild,L=void 0;n;n=L)L=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);eo(e,t,i)}function Ns(e,t,i,r){var n=Za(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),ca(e,t),qa(e,t,i,r),eo(e,t,r),t.node}function eo(e,t,i){if(to(e,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)to(e,t.rest[r],t,i,!1)}function to(e,t,i,r,n){if(!t.widgets)return;for(var L=mn(i),U=0,X=t.widgets;U<X.length;++U){var $=X[U],Z=o("div",[$.node],"CodeMirror-linewidget"+($.className?" "+$.className:""));$.handleMouseEvents||Z.setAttribute("cm-ignore-events","true"),Bs($,Z,i,r),e.display.input.setUneditable(Z),n&&$.above?L.insertBefore(Z,i.gutter||i.text):L.appendChild(Z),Yt($,"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(!x(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,o("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function fi(e,t){for(var i=ye(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 Wn(e){return e.lineSpace.offsetTop}function fa(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function ro(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=d(e.measure,o("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 ge-e.display.nativeBarWidth}function Ii(e){return e.display.scroller.clientWidth-oi(e)-e.display.barWidth}function pa(e){return e.display.scroller.clientHeight-oi(e)-e.display.barHeight}function Us(e,t,i){var r=e.options.lineWrapping,n=r&&Ii(e);if(!t.measure.heights||r&&t.measure.width!=n){var L=t.measure.heights=[];if(r){t.measure.width=n;for(var U=t.text.firstChild.getClientRects(),X=0;X<U.length-1;X++){var $=U[X],Z=U[X+1];Math.abs($.bottom-Z.bottom)>2&&L.push(($.bottom+Z.top)/2-i.top)}}L.push(i.bottom-i.top)}}function io(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(Pt(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Fs(e,t){t=hr(t);var i=Pt(t),r=e.display.externalMeasured=new It(e.doc,t,i);r.lineN=i;var n=r.built=jn(e,r);return r.text=n.pre,d(e.display.lineMeasure,n.pre),r}function no(e,t,i,r){return si(e,$i(e,t),i,r)}function ma(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Ui(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function $i(e,t){var i=Pt(t),r=ma(e,i);r&&!r.text?r=null:r&&r.changes&&(pn(e,r,i,Ea(e)),e.curOp.forceUpdate=!0),r||(r=Fs(e,t));var n=io(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 L=i+(r||""),U;return t.cache.hasOwnProperty(L)?U=t.cache[L]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Us(e,t.view,t.rect),t.hasHeights=!0),U=Ws(e,t,i,r),U.bogus||(t.cache[L]=U)),{left:U.left,right:U.right,top:n?U.rtop:U.top,bottom:n?U.rbottom:U.bottom}}var ao={left:0,right:0,top:0,bottom:0};function oo(e,t,i){for(var r,n,L,U,X,$,Z=0;Z<e.length;Z+=3)if(X=e[Z],$=e[Z+1],t<X?(n=0,L=1,U="left"):t<$?(n=t-X,L=n+1):(Z==e.length-3||t==$&&e[Z+3]>t)&&(L=$-X,n=L-1,t>=$&&(U="right")),n!=null){if(r=e[Z+2],X==$&&i==(r.insertLeft?"left":"right")&&(U=i),i=="left"&&n==0)for(;Z&&e[Z-2]==e[Z-3]&&e[Z-1].insertLeft;)r=e[(Z-=3)+2],U="left";if(i=="right"&&n==$-X)for(;Z<e.length-3&&e[Z+3]==e[Z+4]&&!e[Z+5].insertLeft;)r=e[(Z+=3)+2],U="right";break}return{node:r,start:n,end:L,collapse:U,coverStart:X,coverEnd:$}}function js(e,t){var i=ao;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=oo(t.map,i,r),L=n.node,U=n.start,X=n.end,$=n.collapse,Z;if(L.nodeType==3){for(var le=0;le<4;le++){for(;U&&Ie(t.line.text.charAt(n.coverStart+U));)--U;for(;n.coverStart+X<n.coverEnd&&Ie(t.line.text.charAt(n.coverStart+X));)++X;if(B&&N<9&&U==0&&X==n.coverEnd-n.coverStart?Z=L.parentNode.getBoundingClientRect():Z=js(S(L,U,X).getClientRects(),r),Z.left||Z.right||U==0)break;X=U,U=U-1,$="right"}B&&N<11&&(Z=Hs(e.display.measure,Z))}else{U>0&&($=r="right");var he;e.options.lineWrapping&&(he=L.getClientRects()).length>1?Z=he[r=="right"?he.length-1:0]:Z=L.getBoundingClientRect()}if(B&&N<9&&!U&&(!Z||!Z.left&&!Z.right)){var xe=L.parentNode.getClientRects()[0];xe?Z={left:xe.left,right:xe.left+Ji(e.display),top:xe.top,bottom:xe.bottom}:Z=ao}for(var ve=Z.top-t.rect.top,Me=Z.bottom-t.rect.top,Ue=(ve+Me)/2,Ve=t.view.measure.heights,it=0;it<Ve.length-1&&!(Ue<Ve[it]);it++);var ut=it?Ve[it-1]:0,nt=Ve[it],pt={left:($=="right"?Z.right:Z.left)-t.rect.left,right:($=="left"?Z.left:Z.right)-t.rect.left,top:ut,bottom:nt};return!Z.left&&!Z.right&&(pt.bogus=!0),e.options.singleCursorHeightPerLine||(pt.rtop=ve,pt.rbottom=Me),pt}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Ut(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 so(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 lo(e){e.display.externalMeasure=null,p(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)so(e.display.view[t])}function vn(e){lo(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function uo(){return f&&u?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function ho(){return f&&u?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function ga(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 Hn(e,t,i,r,n){if(!n){var L=ga(t);i.top+=L,i.bottom+=L}if(r=="line")return i;r||(r="local");var U=jr(t);if(r=="local"?U+=Wn(e.display):U-=e.display.viewOffset,r=="page"||r=="window"){var X=e.display.lineSpace.getBoundingClientRect();U+=X.top+(r=="window"?0:ho());var $=X.left+(r=="window"?0:uo());i.left+=$,i.right+=$}return i.top+=U,i.bottom+=U,i}function co(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=uo(),n-=ho();else if(i=="local"||!i){var L=e.display.sizer.getBoundingClientRect();r+=L.left,n+=L.top}var U=e.display.lineSpace.getBoundingClientRect();return{left:r-U.left,top:n-U.top}}function va(e,t,i,r,n){return r||(r=mt(e.doc,t.line)),Hn(e,r,no(e,r,t.ch,n),i)}function qr(e,t,i,r,n,L){r=r||mt(e.doc,t.line),n||(n=$i(e,r));function U(Me,Ue){var Ve=si(e,n,Me,Ue?"right":"left",L);return Ue?Ve.left=Ve.right:Ve.right=Ve.left,Hn(e,r,Ve,i)}var X=et(r,e.doc.direction),$=t.ch,Z=t.sticky;if($>=r.text.length?($=r.text.length,Z="before"):$<=0&&($=0,Z="after"),!X)return U(Z=="before"?$-1:$,Z=="before");function le(Me,Ue,Ve){var it=X[Ue],ut=it.level==1;return U(Ve?Me-1:Me,ut!=Ve)}var he=Ye(X,$,Z),xe=tt,ve=le($,he,Z=="before");return xe!=null&&(ve.other=le($,xe,Z!="before")),ve}function fo(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=Ji(e.display)*t.ch);var r=mt(e.doc,t.line),n=jr(r)+Wn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ya(e,t,i,r,n){var L=We(e,t,i);return L.xRel=n,r&&(L.outside=r),L}function ba(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return ya(r.first,0,null,-1,-1);var n=Yr(r,i),L=r.first+r.size-1;if(n>L)return ya(r.first+r.size-1,mt(r,L).text.length,null,1,1);t<0&&(t=0);for(var U=mt(r,n);;){var X=zs(e,U,n,t,i),$=yi(U,X.ch+(X.xRel>0||X.outside>0?1:0));if(!$)return X;var Z=$.find(1);if(Z.line==n)return Z;U=mt(r,n=Z.line)}}function po(e,t,i,r){r-=ga(t);var n=t.text.length,L=ht(function(U){return si(e,i,U-1).bottom<=r},n,0);return n=ht(function(U){return si(e,i,U).top>r},L,n),{begin:L,end:n}}function mo(e,t,i,r){i||(i=$i(e,t));var n=Hn(e,t,si(e,i,r),"line").top;return po(e,t,i,n)}function xa(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function zs(e,t,i,r,n){n-=jr(t);var L=$i(e,t),U=ga(t),X=0,$=t.text.length,Z=!0,le=et(t,e.doc.direction);if(le){var he=(e.options.lineWrapping?Ks:Gs)(e,t,i,L,le,r,n);Z=he.level!=1,X=Z?he.from:he.to-1,$=Z?he.to:he.from-1}var xe=null,ve=null,Me=ht(function(St){var bt=si(e,L,St);return bt.top+=U,bt.bottom+=U,xa(bt,r,n,!1)?(bt.top<=n&&bt.left<=r&&(xe=St,ve=bt),!0):!1},X,$),Ue,Ve,it=!1;if(ve){var ut=r-ve.left<ve.right-r,nt=ut==Z;Me=xe+(nt?0:1),Ve=nt?"after":"before",Ue=ut?ve.left:ve.right}else{!Z&&(Me==$||Me==X)&&Me++,Ve=Me==0?"after":Me==t.text.length?"before":si(e,L,Me-(Z?1:0)).bottom+U<=n==Z?"after":"before";var pt=qr(e,We(i,Me,Ve),"line",t,L);Ue=pt.left,it=n<pt.top?-1:n>=pt.bottom?1:0}return Me=Fe(t.text,Me,1),ya(i,Me,Ve,it,r-Ue)}function Gs(e,t,i,r,n,L,U){var X=ht(function(he){var xe=n[he],ve=xe.level!=1;return xa(qr(e,We(i,ve?xe.to:xe.from,ve?"before":"after"),"line",t,r),L,U,!0)},0,n.length-1),$=n[X];if(X>0){var Z=$.level!=1,le=qr(e,We(i,Z?$.from:$.to,Z?"after":"before"),"line",t,r);xa(le,L,U,!0)&&le.top>U&&($=n[X-1])}return $}function Ks(e,t,i,r,n,L,U){var X=po(e,t,r,U),$=X.begin,Z=X.end;/\s/.test(t.text.charAt(Z-1))&&Z--;for(var le=null,he=null,xe=0;xe<n.length;xe++){var ve=n[xe];if(ve.from>=Z||ve.to<=$)continue;var Me=ve.level!=1,Ue=si(e,r,Me?Math.min(Z,ve.to)-1:Math.max($,ve.from)).right,Ve=Ue<L?L-Ue+1e9:Ue-L;(!le||he>Ve)&&(le=ve,he=Ve)}return le||(le=n[n.length-1]),le.from<$&&(le={from:$,to:le.to,level:le.level}),le.to>Z&&(le={from:le.from,to:Z,level:le.level}),le}var Ni;function Qi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Ni==null){Ni=o("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Ni.appendChild(document.createTextNode("x")),Ni.appendChild(o("br"));Ni.appendChild(document.createTextNode("x"))}d(e.measure,Ni);var i=Ni.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),p(e.measure),i||1}function Ji(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=o("span","xxxxxxxxxx"),i=o("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 Ea(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,L=t.gutters.firstChild,U=0;L;L=L.nextSibling,++U){var X=e.display.gutterSpecs[U].className;i[X]=L.offsetLeft+L.clientLeft+n,r[X]=L.clientWidth}return{fixedPos:Sa(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Sa(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function go(e){var t=Qi(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/Ji(e.display)-3);return function(n){if(Zr(e.doc,n))return 0;var L=0;if(n.widgets)for(var U=0;U<n.widgets.length;U++)n.widgets[U].height&&(L+=n.widgets[U].height);return i?L+(Math.ceil(n.text.length/r)||1)*t:L+t}}function Ca(e){var t=e.doc,i=go(e);t.iter(function(r){var n=i(r);n!=r.height&&Rr(r,n)})}function Bi(e,t,i,r){var n=e.display;if(!i&&ye(t).getAttribute("cm-not-content")=="true")return null;var L,U,X=n.lineSpace.getBoundingClientRect();try{L=t.clientX-X.left,U=t.clientY-X.top}catch(he){return null}var $=ba(e,L,U),Z;if(r&&$.xRel>0&&(Z=mt(e.doc,$.line).text).length==$.ch){var le=q(Z,Z.length,e.options.tabSize)-Z.length;$=We($.line,Math.max(0,Math.round((L-ro(e.display).left)/Ji(e.display))-le))}return $}function Ui(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 Mr(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)kr&&xi(e.doc,t)<n.viewTo&&Ci(e);else if(i<=n.viewFrom)kr&&Fn(e.doc,i+r)>n.viewFrom?Ci(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)Ci(e);else if(t<=n.viewFrom){var L=zn(e,i,i+r,1);L?(n.view=n.view.slice(L.index),n.viewFrom=L.lineN,n.viewTo+=r):Ci(e)}else if(i>=n.viewTo){var U=zn(e,t,t,-1);U?(n.view=n.view.slice(0,U.index),n.viewTo=U.lineN):Ci(e)}else{var X=zn(e,t,t,-1),$=zn(e,i,i+r,1);X&&$?(n.view=n.view.slice(0,X.index).concat(Zt(e,X.lineN,$.lineN)).concat(n.view.slice($.index)),n.viewTo+=r):Ci(e)}var Z=n.externalMeasured;Z&&(i<Z.lineN?Z.lineN+=r:t<Z.lineN+Z.size&&(n.externalMeasured=null))}function Si(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 L=r.view[Ui(e,t)];if(L.node==null)return;var U=L.changes||(L.changes=[]);ue(U,i)==-1&&U.push(i)}function Ci(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=Ui(e,t),L,U=e.display.view;if(!kr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var X=e.display.viewFrom,$=0;$<n;$++)X+=U[$].size;if(X!=t){if(r>0){if(n==U.length-1)return null;L=X+U[n].size-t,n++}else L=X-t;t+=L,i+=L}for(;xi(e.doc,i)!=i;){if(n==(r<0?0:U.length-1))return null;i+=r*U[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=Zt(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=Zt(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Ui(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(Zt(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,Ui(e,i)))),r.viewTo=i}function vo(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 yo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),L=r.selection=document.createDocumentFragment(),U=0;U<i.sel.ranges.length;U++){if(!t&&U==i.sel.primIndex)continue;var X=i.sel.ranges[U];if(X.from().line>=e.display.viewTo||X.to().line<e.display.viewFrom)continue;var $=X.empty();($||e.options.showCursorWhenSelecting)&&bo(e,X.head,n),$||Xs(e,X,L)}return r}function bo(e,t,i){var r=qr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(o("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 L=i.appendChild(o("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));L.style.display="",L.style.left=r.other.left+"px",L.style.top=r.other.top+"px",L.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Gn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,L=document.createDocumentFragment(),U=ro(e.display),X=U.left,$=Math.max(r.sizerWidth,Ii(e)-r.sizer.offsetLeft)-U.right,Z=n.direction=="ltr";function le(nt,pt,St,bt){pt<0&&(pt=0),pt=Math.round(pt),bt=Math.round(bt),L.appendChild(o("div",null,"CodeMirror-selected","position: absolute; left: "+nt+`px;
|
|
top: `+pt+"px; width: "+(St==null?$-nt:St)+`px;
|
|
height: `+(bt-pt)+"px"))}function he(nt,pt,St){var bt=mt(n,nt),Rt=bt.text.length,Qt,yr;function qt(ar,Nr){return va(e,We(nt,ar),"div",bt,Nr)}function Hr(ar,Nr,Cr){var cr=mo(e,bt,null,ar),or=Nr=="ltr"==(Cr=="after")?"left":"right",tr=Cr=="after"?cr.begin:cr.end-(/\s/.test(bt.text.charAt(cr.end-1))?2:1);return qt(tr,or)[or]}var Ir=et(bt,n.direction);return at(Ir,pt||0,St==null?Rt:St,function(ar,Nr,Cr,cr){var or=Cr=="ltr",tr=qt(ar,or?"left":"right"),Br=qt(Nr-1,or?"right":"left"),hn=pt==null&&ar==0,_i=St==null&&Nr==Rt,wr=cr==0,li=!Ir||cr==Ir.length-1;if(Br.top-tr.top<=3){var br=(Z?hn:_i)&&wr,Ya=(Z?_i:hn)&&li,mi=br?X:(or?tr:Br).left,zi=Ya?$:(or?Br:tr).right;le(mi,tr.top,zi-mi,tr.bottom)}else{var Gi,Dr,cn,$a;or?(Gi=Z&&hn&&wr?X:tr.left,Dr=Z?$:Hr(ar,Cr,"before"),cn=Z?X:Hr(Nr,Cr,"after"),$a=Z&&_i&&li?$:Br.right):(Gi=Z?Hr(ar,Cr,"before"):X,Dr=!Z&&hn&&wr?$:tr.right,cn=!Z&&_i&&li?X:Br.left,$a=Z?Hr(Nr,Cr,"after"):$),le(Gi,tr.top,Dr-Gi,tr.bottom),tr.bottom<Br.top&&le(X,tr.bottom,null,Br.top),le(cn,Br.top,$a-cn,Br.bottom)}(!Qt||Gn(tr,Qt)<0)&&(Qt=tr),Gn(Br,Qt)<0&&(Qt=Br),(!yr||Gn(tr,yr)<0)&&(yr=tr),Gn(Br,yr)<0&&(yr=Br)}),{start:Qt,end:yr}}var xe=t.from(),ve=t.to();if(xe.line==ve.line)he(xe.line,xe.ch,ve.ch);else{var Me=mt(n,xe.line),Ue=mt(n,ve.line),Ve=hr(Me)==hr(Ue),it=he(xe.line,xe.ch,Ve?Me.text.length+1:null).end,ut=he(ve.line,Ve?0:null,ve.ch).start;Ve&&(it.top<ut.top-2?(le(it.right,it.top,null,it.bottom),le(X,ut.top,ut.left,ut.bottom)):le(it.right,it.top,ut.left-it.right,it.bottom)),it.bottom<ut.top&&le(X,it.bottom,null,ut.top)}i.appendChild(L)}function Ta(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 xo(e){e.state.focused||(e.display.input.focus(),wa(e))}function Eo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Zi(e))},100)}function wa(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(De(e,"focus",e,t),e.state.focused=!0,F(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),O&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Ta(e)}function Zi(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(De(e,"blur",e,t),e.state.focused=!1,y(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Kn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],L=e.options.lineWrapping,U=void 0,X=0;if(n.hidden)continue;if(B&&N<8){var $=n.node.offsetTop+n.node.offsetHeight;U=$-i,i=$}else{var Z=n.node.getBoundingClientRect();U=Z.bottom-Z.top,!L&&n.text.firstChild&&(X=n.text.firstChild.getBoundingClientRect().right-Z.left-1)}var le=n.line.height-U;if((le>.005||le<-.005)&&(Rr(n.line,U),So(n.line),n.rest))for(var he=0;he<n.rest.length;he++)So(n.rest[he]);if(X>e.display.sizerWidth){var xe=Math.ceil(X/Ji(e.display));xe>e.display.maxLineLength&&(e.display.maxLineLength=xe,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function So(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 Vn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Wn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,L=Yr(t,r),U=Yr(t,n);if(i&&i.ensure){var X=i.ensure.from.line,$=i.ensure.to.line;X<L?(L=X,U=Yr(t,jr(mt(t,X))+e.wrapper.clientHeight)):Math.min($,t.lastLine())>=U&&(L=Yr(t,jr(mt(t,$))-e.wrapper.clientHeight),U=$)}return{from:L,to:Math.max(U,L+1)}}function Ys(e,t){if(Ne(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&&!g){var L=o("div","\u200B",null,`position: absolute;
|
|
top: `+(t.top-i.viewOffset-Wn(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(L),L.scrollIntoView(n),e.display.lineSpace.removeChild(L)}}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 L=0;L<5;L++){var U=!1,X=qr(e,t),$=!i||i==t?X:qr(e,i);n={left:Math.min(X.left,$.left),top:Math.min(X.top,$.top)-r,right:Math.max(X.left,$.left),bottom:Math.max(X.bottom,$.bottom)+r};var Z=La(e,n),le=e.doc.scrollTop,he=e.doc.scrollLeft;if(Z.scrollTop!=null&&(xn(e,Z.scrollTop),Math.abs(e.doc.scrollTop-le)>1&&(U=!0)),Z.scrollLeft!=null&&(Fi(e,Z.scrollLeft),Math.abs(e.doc.scrollLeft-he)>1&&(U=!0)),!U)break}return n}function Qs(e,t){var i=La(e,t);i.scrollTop!=null&&xn(e,i.scrollTop),i.scrollLeft!=null&&Fi(e,i.scrollLeft)}function La(e,t){var i=e.display,r=Qi(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,L=pa(e),U={};t.bottom-t.top>L&&(t.bottom=t.top+L);var X=e.doc.height+fa(i),$=t.top<r,Z=t.bottom>X-r;if(t.top<n)U.scrollTop=$?0:t.top;else if(t.bottom>n+L){var le=Math.min(t.top,(Z?X:t.bottom)-L);le!=n&&(U.scrollTop=le)}var he=e.options.fixedGutter?0:i.gutters.offsetWidth,xe=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-he,ve=Ii(e)-i.gutters.offsetWidth,Me=t.right-t.left>ve;return Me&&(t.right=t.left+ve),t.left<10?U.scrollLeft=0:t.left<xe?U.scrollLeft=Math.max(0,t.left+he-(Me?0:10)):t.right>ve+xe-3&&(U.scrollLeft=t.right+(Me?0:10)-ve),U}function Aa(e,t){if(t==null)return;Xn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function qi(e){Xn(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)&&Xn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Xn(e),e.curOp.scrollToPos=t}function Xn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=fo(e,t.from),r=fo(e,t.to);Co(e,i,r,t.margin)}}function Co(e,t,i,r){var n=La(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;_||_a(e,{top:t}),To(e,t,!0),_&&_a(e),Cn(e,100)}function To(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 Fi(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,_o(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+fa(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 ji=function(e,t,i){this.cm=i;var r=this.vert=o("div",[o("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=o("div",[o("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),Le(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Le(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,B&&N<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};ji.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 L=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+L)+"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}},ji.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},ji.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},ji.prototype.zeroWidthHack=function(){var e=l&&!T?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new oe,this.disableVert=new oe},ji.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),L=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);L!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},ji.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 en(e,t){t||(t=En(e));var i=e.display.barWidth,r=e.display.barHeight;wo(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Kn(e),wo(e,En(e)),i=e.display.barWidth,r=e.display.barHeight}function wo(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 Lo={native:ji,null:Sn};function Ao(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&y(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Lo[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Le(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"?Fi(e,t):xn(e,t)},e),e.display.scrollbars.addClass&&F(e.display.wrapper,e.display.scrollbars.addClass)}var Zs=0;function Wi(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:++Zs},Ot(e.curOp)}function Hi(e){var t=e.curOp;t&&Vt(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 L=0;L<t.length;L++)il(t[L]);for(var U=0;U<t.length;U++)nl(t[U])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&ci(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 Yn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&Da(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Kn(t),e.barMeasure=En(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=no(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-Ii(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&&Fi(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var i=e.focus&&e.focus==M();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&en(t,e.barMeasure),e.updatedDisplay&&ka(t,e.barMeasure),e.selectionChanged&&Ta(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&xo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&Do(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&To(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Fi(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 L=e.maybeHiddenMarkers,U=e.maybeUnhiddenMarkers;if(L)for(var X=0;X<L.length;++X)L[X].lines.length||De(L[X],"hide");if(U)for(var $=0;$<U.length;++$)U[$].lines.length&&De(U[$],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&De(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Wr(e,t){if(e.curOp)return t();Wi(e);try{return t()}finally{Hi(e)}}function gr(e,t){return function(){if(e.curOp)return t.apply(e,arguments);Wi(e);try{return t.apply(e,arguments)}finally{Hi(e)}}}function Ar(e){return function(){if(this.curOp)return e.apply(this,arguments);Wi(this);try{return e.apply(this,arguments)}finally{Hi(this)}}}function vr(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);Wi(t);try{return e.apply(this,arguments)}finally{Hi(t)}}}function Cn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,K(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=Ee(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(L){if(r.line>=e.display.viewFrom){var U=L.styles,X=L.text.length>e.options.maxHighlightLength?Mt(t.mode,r.state):null,$=ce(e,L,r,!0);X&&(r.state=X),L.styles=$.styles;var Z=L.styleClasses,le=$.classes;le?L.styleClasses=le:Z&&(L.styleClasses=null);for(var he=!U||U.length!=L.styles.length||Z!=le&&(!Z||!le||Z.bgClass!=le.bgClass||Z.textClass!=le.textClass),xe=0;!he&&xe<U.length;++xe)he=U[xe]!=L.styles[xe];he&&n.push(r.line),L.stateAfter=r.save(),r.nextLine()}else L.text.length<=e.options.maxHighlightLength&>(e,L.text,r),L.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&&Wr(e,function(){for(var L=0;L<n.length;L++)Si(e,n[L],"text")})}var Yn=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Vn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Ii(e),this.force=i,this.dims=Ea(e),this.events=[]};Yn.prototype.signal=function(e,t){de(e,t)&&this.events.push(arguments)},Yn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)De.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=M();if(!t||!x(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&x(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==M())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&x(document.body,e.anchorNode)&&x(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 Da(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return Ci(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&&vo(e)==0)return!1;Ro(e)&&(Ci(e),t.dims=Ea(e));var n=r.first+r.size,L=Math.max(t.visible.from-e.options.viewportMargin,r.first),U=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<L&&L-i.viewFrom<20&&(L=Math.max(r.first,i.viewFrom)),i.viewTo>U&&i.viewTo-U<20&&(U=Math.min(n,i.viewTo)),kr&&(L=xi(e.doc,L),U=Fn(e.doc,U));var X=L!=i.viewFrom||U!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,L,U),i.viewOffset=jr(mt(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var $=vo(e);if(!X&&$==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var Z=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(Z),p(i.cursorDiv),p(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,X&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,Cn(e,400)),i.updateLineNumbers=null,!0}function Do(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Ii(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+fa(e.display)-pa(e),i.top)}),t.visible=Vn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Vn(e.display,e.doc,i));if(!Da(e,t))break;Kn(e);var n=En(e);yn(e),en(e,n),ka(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 _a(e,t){var i=new Yn(e,t);if(Da(e,i)){Kn(e),Do(e,i);var r=En(e);yn(e),en(e,r),ka(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,L=r.lineDiv,U=L.firstChild;function X(Me){var Ue=Me.nextSibling;return O&&l&&e.display.currentWheelTarget==Me?Me.style.display="none":Me.parentNode.removeChild(Me),Ue}for(var $=r.view,Z=r.viewFrom,le=0;le<$.length;le++){var he=$[le];if(!he.hidden)if(!he.node||he.node.parentNode!=L){var xe=Ns(e,he,Z,i);L.insertBefore(xe,U)}else{for(;U!=he.node;)U=X(U);var ve=n&&t!=null&&t<=Z&&he.lineNumber;he.changes&&(ue(he.changes,"gutter")>-1&&(ve=!1),pn(e,he,Z,i)),ve&&(p(he.lineNumber),he.lineNumber.appendChild(document.createTextNode(gi(e.options,Z)))),U=he.node.nextSibling}Z+=he.size}for(;U;)U=X(U)}function Ra(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function ka(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 _o(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=Sa(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,L=r+"px",U=0;U<i.length;U++)if(!i[U].hidden){e.options.fixedGutter&&(i[U].gutter&&(i[U].gutter.style.left=L),i[U].gutterBackground&&(i[U].gutterBackground.style.left=L));var X=i[U].alignable;if(X)for(var $=0;$<X.length;$++)X[$].style.left=L}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Ro(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=gi(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(o("div",[o("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),L=n.firstChild.offsetWidth,U=n.offsetWidth-L;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(L,r.lineGutter.offsetWidth-U)+1,r.lineNumWidth=r.lineNumInnerWidth+U,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",Ra(e.display),!0}return!1}function Oa(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var L=e[n],U=null;if(typeof L!="string"&&(U=L.style,L=L.className),L=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:L,style:U})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function ko(e){var t=e.gutters,i=e.gutterSpecs;p(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],L=n.className,U=n.style,X=t.appendChild(o("div",null,"CodeMirror-gutter "+L));U&&(X.style.cssText=U),L=="CodeMirror-linenumbers"&&(e.lineGutter=X,X.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",Ra(e)}function Tn(e){ko(e.display),Mr(e),_o(e)}function dl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=o("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=o("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=C("div",null,"CodeMirror-code"),n.selectionDiv=o("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=o("div",null,"CodeMirror-cursors"),n.measure=o("div",null,"CodeMirror-measure"),n.lineMeasure=o("div",null,"CodeMirror-measure"),n.lineSpace=C("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var L=C("div",[n.lineSpace],"CodeMirror-lines");n.mover=o("div",[L],null,"position: relative"),n.sizer=o("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=o("div",null,null,"position: absolute; height: "+ge+"px; width: 1px;"),n.gutters=o("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=o("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=o("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),B&&N<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!O&&!(_&&a)&&(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=Oa(r.gutters,r.lineNumbers),ko(n),i.init(n)}var $n=0,Vr=null;B?Vr=-.53:_?Vr=15:f?Vr=-.7:k&&(Vr=-1/3);function Oo(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=Oo(e);return t.x*=Vr,t.y*=Vr,t}function Mo(e,t){var i=Oo(t),r=i.x,n=i.y,L=e.display,U=L.scroller,X=U.scrollWidth>U.clientWidth,$=U.scrollHeight>U.clientHeight;if(!(r&&X||n&&$))return;if(n&&l&&O){e:for(var Z=t.target,le=L.view;Z!=U;Z=Z.parentNode)for(var he=0;he<le.length;he++)if(le[he].node==Z){e.display.currentWheelTarget=Z;break e}}if(r&&!_&&!c&&Vr!=null){n&&$&&xn(e,Math.max(0,U.scrollTop+n*Vr)),Fi(e,Math.max(0,U.scrollLeft+r*Vr)),(!n||n&&$)&&ee(t),L.wheelStartX=null;return}if(n&&Vr!=null){var xe=n*Vr,ve=e.doc.scrollTop,Me=ve+L.wrapper.clientHeight;xe<0?ve=Math.max(0,ve+xe-50):Me=Math.min(e.doc.height,Me+xe+50),_a(e,{top:ve,bottom:Me})}$n<20&&(L.wheelStartX==null?(L.wheelStartX=U.scrollLeft,L.wheelStartY=U.scrollTop,L.wheelDX=r,L.wheelDY=n,setTimeout(function(){if(L.wheelStartX==null)return;var Ue=U.scrollLeft-L.wheelStartX,Ve=U.scrollTop-L.wheelStartY,it=Ve&&L.wheelDY&&Ve/L.wheelDY||Ue&&L.wheelDX&&Ue/L.wheelDX;if(L.wheelStartX=L.wheelStartY=null,!it)return;Vr=(Vr*$n+it)/($n+1),++$n},200)):(L.wheelDX+=r,L.wheelDY+=n))}var Xr=function(e,t){this.ranges=e,this.primIndex=t};Xr.prototype.primary=function(){return this.ranges[this.primIndex]},Xr.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(!ri(i.anchor,r.anchor)||!ri(i.head,r.head))return!1}return!0},Xr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new zt(di(this.ranges[t].anchor),di(this.ranges[t].head));return new Xr(e,this.primIndex)},Xr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Xr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(Tt(t,r.from())>=0&&Tt(e,r.to())<=0)return i}return-1};var zt=function(e,t){this.anchor=e,this.head=t};zt.prototype.from=function(){return Ri(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 ei(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(xe,ve){return Tt(xe.from(),ve.from())}),i=ue(t,n);for(var L=1;L<t.length;L++){var U=t[L],X=t[L-1],$=Tt(X.to(),U.from());if(r&&!U.empty()?$>0:$>=0){var Z=Ri(X.from(),U.from()),le=hi(X.to(),U.to()),he=X.empty()?U.from()==U.head:X.from()==X.head;L<=i&&--i,t.splice(--L,2,new zt(he?le:Z,he?Z:le))}}return new Xr(t,i)}function Ti(e,t){return new Xr([new zt(e,t||e)],0)}function wi(e){return e.text?We(e.from.line+e.text.length-1,Re(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Po(e,t){if(Tt(e,t.from)<0)return e;if(Tt(e,t.to)<=0)return wi(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+=wi(t).ch-t.to.ch),We(i,r)}function Ma(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new zt(Po(n.anchor,t),Po(n.head,t)))}return ei(e.cm,i,e.sel.primIndex)}function Io(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),L=n,U=0;U<t.length;U++){var X=t[U],$=Io(X.from,n,L),Z=Io(wi(X),n,L);if(n=X.to,L=Z,i=="around"){var le=e.sel.ranges[U],he=Tt(le.head,le.anchor)<0;r[U]=new zt(he?Z:$,he?$:Z)}else r[U]=new zt($,$)}return new Xr(r,e.sel.primIndex)}function Pa(e){e.doc.mode=Lr(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&&Mr(e)}function No(e,t){return t.from.ch==0&&t.to.ch==0&&Re(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Ia(e,t,i,r){function n(ut){return i?i[ut]:null}function L(ut,nt,pt){ua(ut,nt,pt,r),Yt(ut,"change",ut,t)}function U(ut,nt){for(var pt=[],St=ut;St<nt;++St)pt.push(new Ei(Z[St],n(St),r));return pt}var X=t.from,$=t.to,Z=t.text,le=mt(e,X.line),he=mt(e,$.line),xe=Re(Z),ve=n(Z.length-1),Me=$.line-X.line;if(t.full)e.insert(0,U(0,Z.length)),e.remove(Z.length,e.size-Z.length);else if(No(e,t)){var Ue=U(0,Z.length-1);L(he,he.text,ve),Me&&e.remove(X.line,Me),Ue.length&&e.insert(X.line,Ue)}else if(le==he)if(Z.length==1)L(le,le.text.slice(0,X.ch)+xe+le.text.slice($.ch),ve);else{var Ve=U(1,Z.length-1);Ve.push(new Ei(xe+le.text.slice($.ch),ve,r)),L(le,le.text.slice(0,X.ch)+Z[0],n(0)),e.insert(X.line+1,Ve)}else if(Z.length==1)L(le,le.text.slice(0,X.ch)+Z[0]+he.text.slice($.ch),n(0)),e.remove(X.line+1,Me);else{L(le,le.text.slice(0,X.ch)+Z[0],n(0)),L(he,xe+he.text.slice($.ch),ve);var it=U(1,Z.length-1);Me>1&&e.remove(X.line+1,Me-1),e.insert(X.line+1,it)}Yt(e,"change",e,t)}function Li(e,t,i){function r(n,L,U){if(n.linked)for(var X=0;X<n.linked.length;++X){var $=n.linked[X];if($.doc==L)continue;var Z=U&&$.sharedHist;if(i&&!Z)continue;t($.doc,Z),r($.doc,n,Z)}}r(e,null,!0)}function Bo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ca(e),Pa(e),Uo(e),e.options.lineWrapping||ci(e),e.options.mode=t.modeOption,Mr(e)}function Uo(e){(e.doc.direction=="rtl"?F:y)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Wr(e,function(){Uo(e),Mr(e)})}function Qn(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 Na(e,t){var i={from:di(t.from),to:wi(t),text:ur(e,t.from,t.to)};return Wo(e,i,t.from.line,t.to.line+1),Li(e,function(r){return Wo(r,i,t.from.line,t.to.line+1)},!0),i}function Fo(e){for(;e.length;){var t=Re(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return Fo(e.done),Re(e.done);if(e.done.length&&!Re(e.done).ranges)return Re(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Re(e.done)}function jo(e,t,i,r){var n=e.history;n.undone.length=0;var L=+new Date,U,X;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>L-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(U=pl(n,n.lastOp==r)))X=Re(U.changes),Tt(t.from,t.to)==0&&Tt(t.from,X.to)==0?X.to=wi(t):U.changes.push(Na(e,t));else{var $=Re(n.done);for((!$||!$.ranges)&&Jn(e.sel,n.done),U={changes:[Na(e,t)],generation:n.generation},n.done.push(U);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=L,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,X||De(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,L=r&&r.origin;i==n.lastSelOp||L&&n.lastSelOrigin==L&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==L||ml(e,L,Re(n.done),t))?n.done[n.done.length-1]=t:Jn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=L,n.lastSelOp=i,r&&r.clearRedo!==!1&&Fo(n.undone)}function Jn(e,t){var i=Re(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Wo(e,t,i,r){var n=t["spans_"+e.id],L=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(U){U.markedSpans&&((n||(n=t["spans_"+e.id]={}))[L]=U.markedSpans),++L})}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 Ho(e,t){var i=yl(e,t),r=Ur(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var L=i[n],U=r[n];if(L&&U){e:for(var X=0;X<U.length;++X){for(var $=U[X],Z=0;Z<L.length;++Z)if(L[Z].marker==$.marker)continue e;L.push($)}}else U&&(i[n]=U)}return i}function tn(e,t,i){for(var r=[],n=0;n<e.length;++n){var L=e[n];if(L.ranges){r.push(i?Xr.prototype.deepCopy.call(L):L);continue}var U=L.changes,X=[];r.push({changes:X});for(var $=0;$<U.length;++$){var Z=U[$],le=void 0;if(X.push({from:Z.from,to:Z.to,text:Z.text}),t)for(var he in Z)(le=he.match(/^spans_(\d+)$/))&&(ue(t,Number(le[1]))>-1&&(Re(X)[he]=Z[he],delete Z[he]))}}return r}function Ba(e,t,i,r){if(r){var n=e.anchor;if(i){var L=Tt(t,n)<0;L!=Tt(i,n)<0?(n=t,t=i):L!=Tt(t,i)<0&&(t=i)}return new zt(n,t)}else return new zt(i||t,t)}function Zn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),Tr(e,new Xr([Ba(e.sel.primary(),t,i,n)],0),r)}function zo(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),L=0;L<e.sel.ranges.length;L++)r[L]=Ba(e.sel.ranges[L],t[L],null,n);var U=ei(e.cm,r,e.sel.primIndex);Tr(e,U,i)}function Ua(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,Tr(e,ei(e.cm,n,e.sel.primIndex),r)}function Go(e,t,i,r){Tr(e,Ti(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var L=0;L<n.length;L++)this.ranges[L]=new zt(s(e,n[L].anchor),s(e,n[L].head))},origin:i&&i.origin};return De(e,"beforeSelectionChange",e,r),e.cm&&De(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?ei(e.cm,r.ranges,r.ranges.length-1):t}function Ko(e,t,i){var r=e.history.done,n=Re(r);n&&n.ranges?(r[r.length-1]=t,qn(e,t,i)):Tr(e,t,i)}function Tr(e,t,i){qn(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function qn(e,t,i){(de(e,"beforeSelectionChange")||e.cm&&de(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(Tt(t.primary().head,e.sel.primary().head)<0?-1:1);Vo(e,Yo(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&qi(e.cm)}function Vo(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,me(e.cm)),Yt(e,"cursorActivity",e)}function Xo(e){Vo(e,Yo(e,e.sel,null,!1))}function Yo(e,t,i,r){for(var n,L=0;L<t.ranges.length;L++){var U=t.ranges[L],X=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[L],$=ea(e,U.anchor,X&&X.anchor,i,r),Z=ea(e,U.head,X&&X.head,i,r);(n||$!=U.anchor||Z!=U.head)&&(n||(n=t.ranges.slice(0,L)),n[L]=new zt($,Z))}return n?ei(e.cm,n,t.primIndex):t}function rn(e,t,i,r,n){var L=mt(e,t.line);if(L.markedSpans)for(var U=0;U<L.markedSpans.length;++U){var X=L.markedSpans[U],$=X.marker,Z="selectLeft"in $?!$.selectLeft:$.inclusiveLeft,le="selectRight"in $?!$.selectRight:$.inclusiveRight;if((X.from==null||(Z?X.from<=t.ch:X.from<t.ch))&&(X.to==null||(le?X.to>=t.ch:X.to>t.ch))){if(n&&(De($,"beforeCursorEnter"),$.explicitlyCleared))if(L.markedSpans){--U;continue}else break;if(!$.atomic)continue;if(i){var he=$.find(r<0?1:-1),xe=void 0;if((r<0?le:Z)&&(he=$o(e,he,-r,he&&he.line==t.line?L:null)),he&&he.line==t.line&&(xe=Tt(he,i))&&(r<0?xe<0:xe>0))return rn(e,he,t,r,n)}var ve=$.find(r<0?-1:1);return(r<0?Z:le)&&(ve=$o(e,ve,r,ve.line==t.line?L:null)),ve?rn(e,ve,t,r,n):null}}return t}function ea(e,t,i,r,n){var L=r||1,U=rn(e,t,i,L,n)||!n&&rn(e,t,i,L,!0)||rn(e,t,i,-L,n)||!n&&rn(e,t,i,-L,!0);return U||(e.cantEdit=!0,We(e.first,0))}function $o(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||mt(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 Qo(e){e.setSelection(We(e.firstLine(),0),We(e.lastLine()),be)}function Jo(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,L,U,X){n&&(r.from=s(e,n)),L&&(r.to=s(e,L)),U&&(r.text=U),X!==void 0&&(r.origin=X)}),De(e,"beforeChange",e,r),e.cm&&De(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 nn(e,t,i){if(e.cm){if(!e.cm.curOp)return gr(e.cm,nn)(e,t,i);if(e.cm.state.suppressEdits)return}if((de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"))&&(t=Jo(e,t,!0),!t))return;var r=Ki&&!i&&ki(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)Zo(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else Zo(e,t)}function Zo(e,t){if(t.text.length==1&&t.text[0]==""&&Tt(t.from,t.to)==0)return;var i=Ma(e,t);jo(e,t,i,e.cm?e.cm.curOp.id:NaN),Ln(e,t,i,Ur(e,t));var r=[];Li(e,function(n,L){!L&&ue(r,n.history)==-1&&(rs(n.history,t),r.push(n.history)),Ln(n,t,null,Ur(n,t))})}function ta(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,L,U=e.sel,X=t=="undo"?n.done:n.undone,$=t=="undo"?n.undone:n.done,Z=0;Z<X.length&&!(L=X[Z],i?L.ranges&&!L.equals(e.sel):!L.ranges);Z++);if(Z==X.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(L=X.pop(),L.ranges){if(Jn(L,$),i&&!L.equals(e.sel)){Tr(e,L,{clearRedo:!1});return}U=L}else if(r){X.push(L);return}else break;var le=[];Jn(U,$),$.push({changes:le,generation:n.generation}),n.generation=L.generation||++n.maxGeneration;for(var he=de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"),xe=function(Ue){var Ve=L.changes[Ue];if(Ve.origin=t,he&&!Jo(e,Ve,!1))return X.length=0,{};le.push(Na(e,Ve));var it=Ue?Ma(e,Ve):Re(X);Ln(e,Ve,it,Ho(e,Ve)),!Ue&&e.cm&&e.cm.scrollIntoView({from:Ve.from,to:wi(Ve)});var ut=[];Li(e,function(nt,pt){!pt&&ue(ut,nt.history)==-1&&(rs(nt.history,Ve),ut.push(nt.history)),Ln(nt,Ve,null,Ho(nt,Ve))})},ve=L.changes.length-1;ve>=0;--ve){var Me=xe(ve);if(Me)return Me.v}}function qo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Xr(Je(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){Mr(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Si(e.cm,r,"gutter")}}function Ln(e,t,i,r){if(e.cm&&!e.cm.curOp)return gr(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:[Re(t.text)],origin:t.origin}}var L=e.lastLine();t.to.line>L&&(t={from:t.from,to:We(L,mt(e,L).text.length),text:[t.text[0]],origin:t.origin}),t.removed=ur(e,t.from,t.to),i||(i=Ma(e,t)),e.cm?xl(e.cm,t,r):Ia(e,t,r),qn(e,i,be),e.cantEdit&&ea(e,We(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,L=t.from,U=t.to,X=!1,$=L.line;e.options.lineWrapping||($=Pt(hr(mt(r,L.line))),r.iter($,U.line+1,function(ve){if(ve==n.maxLine)return X=!0,!0})),r.sel.contains(t.from,t.to)>-1&&me(e),Ia(r,t,i,go(e)),e.options.lineWrapping||(r.iter($,L.line+t.text.length,function(ve){var Me=Yi(ve);Me>n.maxLineLength&&(n.maxLine=ve,n.maxLineLength=Me,n.maxLineChanged=!0,X=!1)}),X&&(e.curOp.updateMaxLine=!0)),$r(r,L.line),Cn(e,400);var Z=t.text.length-(U.line-L.line)-1;t.full?Mr(e):L.line==U.line&&t.text.length==1&&!No(e.doc,t)?Si(e,L.line,"text"):Mr(e,L.line,U.line+1,Z);var le=de(e,"changes"),he=de(e,"change");if(he||le){var xe={from:L,to:U,text:t.text,removed:t.removed,origin:t.origin};he&&Yt(e,"change",e,xe),le&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(xe)}e.display.selForContextMenu=null}function an(e,t,i,r,n){var L;r||(r=i),Tt(r,i)<0&&(L=[r,i],i=L[0],r=L[1]),typeof t=="string"&&(t=e.splitLines(t)),nn(e,{from:i,to:r,text:t,origin:n})}function es(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function ts(e,t,i,r){for(var n=0;n<e.length;++n){var L=e[n],U=!0;if(L.ranges){L.copied||(L=e[n]=L.deepCopy(),L.copied=!0);for(var X=0;X<L.ranges.length;X++)es(L.ranges[X].anchor,t,i,r),es(L.ranges[X].head,t,i,r);continue}for(var $=0;$<L.changes.length;++$){var Z=L.changes[$];if(i<Z.from.line)Z.from=We(Z.from.line+r,Z.from.ch),Z.to=We(Z.to.line+r,Z.to.ch);else if(t<=Z.to.line){U=!1;break}}U||(e.splice(0,n+1),n=0)}}function rs(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;ts(e.done,i,r,n),ts(e.undone,i,r,n)}function An(e,t,i,r){var n=t,L=t;return typeof t=="number"?L=mt(e,z(e,t)):n=Pt(t),n==null?null:(r(L,n)&&e.cm&&Si(e.cm,n,i),L)}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),Yt(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 L=Math.min(t,n-e),U=r.height;if(r.removeInner(e,L),this.height-=U-r.height,n==L&&(this.children.splice(i--,1),r.parent=null),(t-=L)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Dn))){var X=[];this.collapse(X),this.children=[new Dn(X)],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],L=n.chunkSize();if(e<=L){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var U=n.lines.length%25+25,X=U;X<n.lines.length;){var $=new Dn(n.lines.slice(X,X+=25));n.height-=$.height,this.children.splice(++r,0,$),$.parent=this}n.lines=n.lines.slice(0,U),this.maybeSpill()}break}e-=L}},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=ue(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],L=n.chunkSize();if(e<L){var U=Math.min(t,L-e);if(n.iterN(e,U,i))return!0;if((t-=U)==0)break;e=0}else e-=L}}};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=Pt(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 L=gn(this);Rr(i,Math.max(0,i.height-L)),e&&(Wr(e,function(){is(e,i,-L),Si(e,r,"widget")}),Yt(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;Zr(this.doc,r)||Rr(r,r.height+n),i&&Wr(i,function(){i.curOp.forceUpdate=!0,is(i,r,n),Yt(i,"lineWidgetChanged",i,e,Pt(r))})},fe(Rn);function is(e,t,i){jr(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Aa(e,i)}function El(e,t,i,r){var n=new Rn(e,i,r),L=e.cm;return L&&n.noHScroll&&(L.display.alignWidgets=!0),An(e,t,"widget",function(U){var X=U.widgets||(U.widgets=[]);if(n.insertAt==null?X.push(n):X.splice(Math.min(X.length-1,Math.max(0,n.insertAt)),0,n),n.line=U,L&&!Zr(e,U)){var $=jr(U)<e.scrollTop;Rr(U,U.height+gn(n)),$&&Aa(L,n.height),L.curOp.forceUpdate=!0}return!0}),L&&Yt(L,"lineWidgetAdded",L,n,typeof t=="number"?t:Pt(t)),n}var ns=0,Ai=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ns};Ai.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&Wi(e),de(this,"clear")){var i=this.find();i&&Yt(this,"clear",i.from,i.to)}for(var r=null,n=null,L=0;L<this.lines.length;++L){var U=this.lines[L],X=Jr(U.markedSpans,this);e&&!this.collapsed?Si(e,Pt(U),"text"):e&&(X.to!=null&&(n=Pt(U)),X.from!=null&&(r=Pt(U))),U.markedSpans=ni(U.markedSpans,X),X.from==null&&this.collapsed&&!Zr(this.doc,U)&&e&&Rr(U,Qi(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var $=0;$<this.lines.length;++$){var Z=hr(this.lines[$]),le=Yi(Z);le>e.display.maxLineLength&&(e.display.maxLine=Z,e.display.maxLineLength=le,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Mr(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Xo(e.doc)),e&&Yt(e,"markerCleared",e,this,r,n),t&&Hi(e),this.parent&&this.parent.clear()},Ai.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var L=this.lines[n],U=Jr(L.markedSpans,this);if(U.from!=null&&(i=We(t?L:Pt(L),U.from),e==-1))return i;if(U.to!=null&&(r=We(t?L:Pt(L),U.to),e==1))return r}return i&&{from:i,to:r}},Ai.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;Wr(r,function(){var n=t.line,L=Pt(t.line),U=ma(r,L);if(U&&(so(U),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Zr(i.doc,n)&&i.height!=null){var X=i.height;i.height=null;var $=gn(i)-X;$&&Rr(n,n.height+$)}Yt(r,"markerChanged",r,e)})},Ai.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||ue(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Ai.prototype.detachLine=function(e){if(this.lines.splice(ue(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},fe(Ai);function on(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return gr(e.cm,on)(e,t,i,r,n);var L=new Ai(e,n),U=Tt(t,i);if(r&&j(r,L,!1),U>0||U==0&&L.clearWhenEmpty!==!1)return L;if(L.replacedWith&&(L.collapsed=!0,L.widgetNode=C("span",[L.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||L.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(L.widgetNode.insertLeft=!0)),L.collapsed){if(dr(e,t.line,t,i,L)||t.line!=i.line&&dr(e,i.line,t,i,L))throw new Error("Inserting collapsed marker partially overlapping an existing one");ii()}L.addToHistory&&jo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var X=t.line,$=e.cm,Z;if(e.iter(X,i.line+1,function(he){$&&L.collapsed&&!$.options.lineWrapping&&hr(he)==$.display.maxLine&&(Z=!0),L.collapsed&&X!=t.line&&Rr(he,0),Kr(he,new vi(L,X==t.line?t.ch:null,X==i.line?i.ch:null)),++X}),L.collapsed&&e.iter(t.line,i.line+1,function(he){Zr(e,he)&&Rr(he,0)}),L.clearOnEnter&&Le(L,"beforeCursorEnter",function(){return L.clear()}),L.readOnly&&(Or(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),L.collapsed&&(L.id=++ns,L.atomic=!0),$){if(Z&&($.curOp.updateMaxLine=!0),L.collapsed)Mr($,t.line,i.line+1);else if(L.className||L.startStyle||L.endStyle||L.css||L.attributes||L.title)for(var le=t.line;le<=i.line;le++)Si($,le,"text");L.atomic&&Xo($.doc),Yt($,"markerAdded",$,L)}return L}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();Yt(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 L=[on(e,t,i,r,n)],U=L[0],X=r.widgetNode;return Li(e,function($){X&&(r.widgetNode=X.cloneNode(!0)),L.push(on($,s($,t),s($,i),r,n));for(var Z=0;Z<$.linked.length;++Z)if($.linked[Z].isParent)return;U=Re(L)}),new kn(L,U)}function as(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(),L=e.clipPos(n.from),U=e.clipPos(n.to);if(Tt(L,U)){var X=on(e,L,U,r.primary,r.primary.type);r.markers.push(X),X.parent=r}}}function Tl(e){for(var t=function(r){var n=e[r],L=[n.primary.doc];Li(n.primary.doc,function($){return L.push($)});for(var U=0;U<n.markers.length;U++){var X=n.markers[U];ue(L,X.doc)==-1&&(X.parent=null,n.markers.splice(U--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,Pr=function(e,t,i,r,n){if(!(this instanceof Pr))return new Pr(e,t,i,r,n);i==null&&(i=0),_n.call(this,[new Dn([new Ei("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var L=We(i,0);this.sel=Ti(L),this.history=new Qn(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)),Ia(this,{from:L,to:L,text:e}),Tr(this,Ti(L),be)};Pr.prototype=Ke(_n.prototype,{constructor:Pr,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=_r(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:vr(function(e){var t=We(this.first,0),i=this.first+this.size-1;nn(this,{from:t,to:We(i,mt(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&bn(this.cm,0,0),Tr(this,Ti(t),be)}),replaceRange:function(e,t,i,r){t=s(this,t),i=i?s(this,i):t,an(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(ui(this,e))return mt(this,e)},getLineNumber:function(e){return Pt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=mt(this,e)),hr(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:vr(function(e,t,i){Go(this,s(this,typeof e=="number"?We(e,t||0):e),null,i)}),setSelection:vr(function(e,t,i){Go(this,s(this,e),s(this,t||e),i)}),extendSelection:vr(function(e,t,i){Zn(this,s(this,e),t&&s(this,t),i)}),extendSelections:vr(function(e,t){zo(this,W(this,e),t)}),extendSelectionsBy:vr(function(e,t){var i=Je(this.sel.ranges,e);zo(this,W(this,i),t)}),setSelections:vr(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)),Tr(this,ei(this.cm,r,t),i)}),addSelection:vr(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new zt(s(this,e),s(this,t||e))),Tr(this,ei(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:vr(function(e,t,i){for(var r=[],n=this.sel,L=0;L<n.ranges.length;L++){var U=n.ranges[L];r[L]={from:U.from(),to:U.to(),text:this.splitLines(e[L]),origin:i}}for(var X=t&&t!="end"&&cl(this,r,t),$=r.length-1;$>=0;$--)nn(this,r[$]);X?Ko(this,X):this.cm&&qi(this.cm)}),undo:vr(function(){ta(this,"undo")}),redo:vr(function(){ta(this,"redo")}),undoSelection:vr(function(){ta(this,"undo",!0)}),redoSelection:vr(function(){ta(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 Qn(this.history.maxGeneration),Li(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:tn(this.history.done),undone:tn(this.history.undone)}},setHistory:function(e){var t=this.history=new Qn(this.history.maxGeneration);t.done=tn(e.done.slice(0),null,!0),t.undone=tn(e.undone.slice(0),null,!0)},setGutterMarker:vr(function(e,t,i){return An(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&$e(n)&&(r.gutterMarkers=null),!0})}),clearGutter:vr(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&An(t,i,"gutter",function(){return i.gutterMarkers[e]=null,$e(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!ui(this,e))return null;if(t=e,e=mt(this,e),!e)return null}else if(t=Pt(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:vr(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(w(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:vr(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",L=r[n];if(L)if(i==null)r[n]=null;else{var U=L.match(w(i));if(!U)return!1;var X=U.index+U[0].length;r[n]=L.slice(0,U.index)+(!U.index||X==L.length?"":" ")+L.slice(X)||null}else return!1;return!0})}),addLineWidget:vr(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return on(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),on(this,e,e,i,"bookmark")},findMarksAt:function(e){e=s(this,e);var t=[],i=mt(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(L){var U=L.markedSpans;if(U)for(var X=0;X<U.length;X++){var $=U[X];!($.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 L=n.text.length+r;if(L>e)return t=e,!0;e-=L,++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 Pr(_r(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 Pr(_r(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,as(this)),r},unlinkDoc:function(e){if(e instanceof Jt&&(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(as(this));break}if(e.history==this.history){var r=[e.id];Li(e,function(n){return r.push(n.id)},!0),e.history=new Qn(null),e.history.done=tn(this.history.done,r),e.history.undone=tn(this.history.undone,r)}},iterLinkedDocs:function(e){Li(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):ft(e)},lineSeparator:function(){return this.lineSep||`
|
|
`},setDirection:vr(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)})}),Pr.prototype.eachLine=Pr.prototype.iter;var os=0;function Ll(e){var t=this;if(ss(t),Ne(t,e)||fi(t.display,e))return;ee(e),B&&(os=+new Date);var i=Bi(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,L=Array(n),U=0,X=function(){++U==n&&gr(t,function(){i=s(t.doc,i);var ve={from:i,to:i,text:t.doc.splitLines(L.filter(function(Me){return Me!=null}).join(t.doc.lineSeparator())),origin:"paste"};nn(t.doc,ve),Ko(t.doc,Ti(s(t.doc,i),s(t.doc,wi(ve))))})()},$=function(ve,Me){if(t.options.allowDropFileTypes&&ue(t.options.allowDropFileTypes,ve.type)==-1){X();return}var Ue=new FileReader;Ue.onerror=function(){return X()},Ue.onload=function(){var Ve=Ue.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(Ve)){X();return}L[Me]=Ve,X()},Ue.readAsText(ve)},Z=0;Z<r.length;Z++)$(r[Z],Z);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 le=e.dataTransfer.getData("Text");if(le){var he;if(t.state.draggingText&&!t.state.draggingText.copy&&(he=t.listSelections()),qn(t.doc,Ti(i,i)),he)for(var xe=0;xe<he.length;++xe)an(t.doc,"",he[xe].anchor,he[xe].head,"drag");t.replaceSelection(le,"around","paste"),t.display.input.focus()}}catch(ve){}}}function Al(e,t){if(B&&(!e.state.draggingText||+new Date-os<100)){ae(t);return}if(Ne(e,t)||fi(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!k){var i=o("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",c&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),c&&i.parentNode.removeChild(i)}}function Dl(e,t){var i=Bi(e,t);if(!i)return;var r=document.createDocumentFragment();bo(e,i,r),e.display.dragCursor||(e.display.dragCursor=o("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),d(e.display.dragCursor,r)}function ss(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function ls(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 L=0;L<i.length;L++)e(i[L])})}var us=!1;function _l(){if(us)return;Rl(),us=!0}function Rl(){var e;Le(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,ls(kl)},100))}),Le(window,"blur",function(){return ls(Zi)})}function kl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var Di={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++)Di[On+48]=Di[On+96]=String(On);for(var ra=65;ra<=90;ra++)Di[ra]=String.fromCharCode(ra);for(var Mn=1;Mn<=12;Mn++)Di[Mn+111]=Di[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,L,U=0;U<t.length-1;U++){var X=t[U];if(/^(cmd|meta|m)$/i.test(X))L=!0;else if(/^a(lt)?$/i.test(X))i=!0;else if(/^(c|ctrl|control)$/i.test(X))r=!0;else if(/^s(hift)?$/i.test(X))n=!0;else throw new Error("Unrecognized modifier name: "+X)}return i&&(e="Alt-"+e),r&&(e="Ctrl-"+e),L&&(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=Je(i.split(" "),Ol),L=0;L<n.length;L++){var U=void 0,X=void 0;L==n.length-1?(X=n.join(" "),U=r):(X=n.slice(0,L+1).join(" "),U="...");var $=t[X];if(!$)t[X]=U;else if($!=U)throw new Error("Inconsistent bindings for "+X)}delete e[i]}for(var Z in t)e[Z]=t[Z];return e}function sn(e,t,i,r){t=ia(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 sn(e,t.fallthrough,i,r);for(var L=0;L<t.fallthrough.length;L++){var U=sn(e,t.fallthrough[L],i,r);if(U)return U}}}function ds(e){var t=typeof e=="string"?e:Di[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function hs(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(E?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(E?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function cs(e,t){if(c&&e.keyCode==34&&e.char)return!1;var i=Di[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),hs(i,e,t))}function ia(e){return typeof e=="string"?pi[e]:e}function ln(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var L=t(i[n]);r.length&&Tt(L.from,Re(r).to)<=0;){var U=r.pop();if(Tt(U.from,L.from)<0){L.from=U.from;break}}r.push(L)}Wr(e,function(){for(var X=r.length-1;X>=0;X--)an(e.doc,"",r[X].from,r[X].to,"+delete");qi(e)})}function Fa(e,t,i){var r=Fe(e.text,t+i,i);return r<0||r>e.text.length?null:r}function ja(e,t,i){var r=Fa(e,t.ch,i);return r==null?null:new We(t.line,r,i<0?"after":"before")}function Wa(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var L=et(i,t.doc.direction);if(L){var U=n<0?Re(L):L[0],X=n<0==(U.level==1),$=X?"after":"before",Z;if(U.level>0||t.doc.direction=="rtl"){var le=$i(t,i);Z=n<0?i.text.length-1:0;var he=si(t,le,Z).top;Z=ht(function(xe){return si(t,le,xe).top==he},n<0==(U.level==1)?U.from:U.to-1,Z),$=="before"&&(Z=Fa(i,Z,1))}else Z=n<0?U.to:U.from;return new We(r,Z,$)}}return new We(r,n<0?i.text.length:0,n<0?"before":"after")}function Pl(e,t,i,r){var n=et(t,e.doc.direction);if(!n)return ja(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 L=Ye(n,i.ch,i.sticky),U=n[L];if(e.doc.direction=="ltr"&&U.level%2==0&&(r>0?U.to>i.ch:U.from<i.ch))return ja(t,i,r);var X=function(it,ut){return Fa(t,it instanceof We?it.ch:it,ut)},$,Z=function(it){return e.options.lineWrapping?($=$||$i(e,t),mo(e,t,$,it)):{begin:0,end:t.text.length}},le=Z(i.sticky=="before"?X(i,-1):i.ch);if(e.doc.direction=="rtl"||U.level==1){var he=U.level==1==r<0,xe=X(i,he?1:-1);if(xe!=null&&(he?xe<=U.to&&xe<=le.end:xe>=U.from&&xe>=le.begin)){var ve=he?"before":"after";return new We(i.line,xe,ve)}}var Me=function(it,ut,nt){for(var pt=function(Qt,yr){return yr?new We(i.line,X(Qt,1),"before"):new We(i.line,Qt,"after")};it>=0&&it<n.length;it+=ut){var St=n[it],bt=ut>0==(St.level!=1),Rt=bt?nt.begin:X(nt.end,-1);if(St.from<=Rt&&Rt<St.to)return pt(Rt,bt);if(Rt=bt?St.from:X(St.to,-1),nt.begin<=Rt&&Rt<nt.end)return pt(Rt,bt)}},Ue=Me(L+r,r,le);if(Ue)return Ue;var Ve=r>0?le.end:X(le.begin,-1);return Ve!=null&&!(r>0&&Ve==t.text.length)&&(Ue=Me(r>0?0:n.length-1,r,Z(Ve)),Ue)?Ue:null}var Pn={selectAll:Qo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),be)},killLine:function(e){return ln(e,function(t){if(t.empty()){var i=mt(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 ln(e,function(t){return{from:We(t.from().line,0),to:s(e.doc,We(t.to().line+1,0))}})},delLineLeft:function(e){return ln(e,function(t){return{from:We(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return ln(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 ln(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 fs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return ps(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")},Te)},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")},Te)},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/)?ps(e,t.head):r},Te)},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 L=i[n].from(),U=q(e.getLine(L.line),L.ch,r);t.push(se(r-U%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Wr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,L=mt(e.doc,n.line).text;if(L){if(n.ch==L.length&&(n=new We(n.line,n.ch-1)),n.ch>0)n=new We(n.line,n.ch+1),e.replaceRange(L.charAt(n.ch-1)+L.charAt(n.ch-2),We(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var U=mt(e.doc,n.line-1).text;U&&(n=new We(n.line,1),e.replaceRange(L.charAt(0)+e.doc.lineSeparator()+U.charAt(U.length-1),We(n.line-1,U.length-1),n,"+transpose"))}}i.push(new zt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Wr(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);qi(e)})},openLine:function(e){return e.replaceSelection(`
|
|
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function fs(e,t){var i=mt(e.doc,t),r=hr(i);return r!=i&&(t=Pt(r)),Wa(!0,e,r,t,1)}function Il(e,t){var i=mt(e.doc,t),r=ai(i);return r!=i&&(t=Pt(r)),Wa(!0,e,i,t,-1)}function ps(e,t){var i=fs(e,t.line),r=mt(e.doc,i.line),n=et(r,e.doc.direction);if(!n||n[0].level==0){var L=Math.max(i.ch,r.text.search(/\S/)),U=t.line==i.line&&t.ch<=L&&t.ch;return We(i.line,U?0:L,i.sticky)}return i}function na(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)!=_e}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=sn(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&sn(t,e.options.extraKeys,i,e)||sn(t,e.options.keyMap,i,e)}var Bl=new oe;function In(e,t,i,r){var n=e.state.keySeq;if(n){if(ds(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())}),ms(e,n+" "+t,i,r))return!0}return ms(e,t,i,r)}function ms(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&Yt(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(ee(i),Ta(e)),!!n}function gs(e,t){var i=cs(t,!0);return i?t.shiftKey&&!e.state.keySeq?In(e,"Shift-"+i,t,function(r){return na(e,r,!0)})||In(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return na(e,r)}):In(e,i,t,function(r){return na(e,r)}):!1}function Ul(e,t,i){return In(e,"'"+i+"'",t,function(r){return na(e,r,!0)})}var Ha=null;function vs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=M(),Ne(t,e))return;B&&N<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=gs(t,e);c&&(Ha=r?i:null,!r&&i==88&&!_t&&(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;F(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(y(t,"CodeMirror-crosshair"),rt(document,"keyup",i),rt(document,"mouseover",i))}Le(document,"keyup",i),Le(document,"mouseover",i)}function ys(e){e.keyCode==16&&(this.doc.sel.shift=!1),Ne(this,e)}function bs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(fi(t.display,e)||Ne(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(c&&i==Ha){Ha=null,ee(e);return}if(c&&(!e.which||e.which<10)&&gs(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,za=function(e,t,i){this.time=e,this.pos=t,this.button=i};za.prototype.compare=function(e,t,i){return this.time+jl>e&&Tt(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 za(i,e,t),Nn=null,"double"):(Nn=new za(i,e,t),Bn=null,"single")}function xs(e){var t=this,i=t.display;if(Ne(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,fi(i,e)){O||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ga(t,e))return;var r=Bi(t,e),n=we(e),L=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,L,e))return;n==1?r?Gl(t,r,L,e):ye(e)==i.scroller&&ee(e):n==2?(r&&Zn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(D?t.display.input.onContextMenu(e):Eo(t))}function Hl(e,t,i,r,n){var L="Click";return r=="double"?L="Double"+L:r=="triple"&&(L="Triple"+L),L=(t==1?"Left":t==2?"Middle":"Right")+L,In(e,hs(L,n),n,function(U){if(typeof U=="string"&&(U=Pn[U]),!U)return!1;var X=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),X=U(e,i)!=_e}finally{e.state.suppressEdits=!1}return X})}function zl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var L=h?i.shiftKey&&i.metaKey:i.altKey;n.unit=L?"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 Gl(e,t,i,r){B?setTimeout(K(xo,e),0):e.curOp.focus=M();var n=zl(e,i,r),L=e.doc.sel,U;e.options.dragDrop&&je&&!e.isReadOnly()&&i=="single"&&(U=L.contains(t))>-1&&(Tt((U=L.ranges[U]).from(),t)<0||t.xRel>0)&&(Tt(U.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,L=!1,U=gr(e,function(Z){O&&(n.scroller.draggable=!1),e.state.draggingText=!1,rt(n.wrapper.ownerDocument,"mouseup",U),rt(n.wrapper.ownerDocument,"mousemove",X),rt(n.scroller,"dragstart",$),rt(n.scroller,"drop",U),L||(ee(Z),r.addNew||Zn(e.doc,i,null,null,r.extend),O&&!k||B&&N==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),X=function(Z){L=L||Math.abs(t.clientX-Z.clientX)+Math.abs(t.clientY-Z.clientY)>=10},$=function(){return L=!0};O&&(n.scroller.draggable=!0),e.state.draggingText=U,U.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Le(n.wrapper.ownerDocument,"mouseup",U),Le(n.wrapper.ownerDocument,"mousemove",X),Le(n.scroller,"dragstart",$),Le(n.scroller,"drop",U),Eo(e),setTimeout(function(){return n.input.focus()},20)}function Es(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,L=e.doc;ee(t);var U,X,$=L.sel,Z=$.ranges;if(r.addNew&&!r.extend?(X=L.sel.contains(i),X>-1?U=Z[X]:U=new zt(i,i)):(U=L.sel.primary(),X=L.sel.primIndex),r.unit=="rectangle")r.addNew||(U=new zt(i,i)),i=Bi(e,t,!0,!0),X=-1;else{var le=Es(e,i,r.unit);r.extend?U=Ba(U,le.anchor,le.head,r.extend):U=le}r.addNew?X==-1?(X=Z.length,Tr(L,ei(e,Z.concat([U]),X),{scroll:!1,origin:"*mouse"})):Z.length>1&&Z[X].empty()&&r.unit=="char"&&!r.extend?(Tr(L,ei(e,Z.slice(0,X).concat(Z.slice(X+1)),0),{scroll:!1,origin:"*mouse"}),$=L.sel):Ua(L,X,U,Se):(X=0,Tr(L,new Xr([U],0),Se),$=L.sel);var he=i;function xe(nt){if(Tt(he,nt)==0)return;if(he=nt,r.unit=="rectangle"){for(var pt=[],St=e.options.tabSize,bt=q(mt(L,i.line).text,i.ch,St),Rt=q(mt(L,nt.line).text,nt.ch,St),Qt=Math.min(bt,Rt),yr=Math.max(bt,Rt),qt=Math.min(i.line,nt.line),Hr=Math.min(e.lastLine(),Math.max(i.line,nt.line));qt<=Hr;qt++){var Ir=mt(L,qt).text,ar=Ce(Ir,Qt,St);Qt==yr?pt.push(new zt(We(qt,ar),We(qt,ar))):Ir.length>ar&&pt.push(new zt(We(qt,ar),We(qt,Ce(Ir,yr,St))))}pt.length||pt.push(new zt(i,i)),Tr(L,ei(e,$.ranges.slice(0,X).concat(pt),X),{origin:"*mouse",scroll:!1}),e.scrollIntoView(nt)}else{var Nr=U,Cr=Es(e,nt,r.unit),cr=Nr.anchor,or;Tt(Cr.anchor,cr)>0?(or=Cr.head,cr=Ri(Nr.from(),Cr.anchor)):(or=Cr.anchor,cr=hi(Nr.to(),Cr.head));var tr=$.ranges.slice(0);tr[X]=Xl(e,new zt(s(L,cr),or)),Tr(L,ei(e,tr,X),Se)}}var ve=n.wrapper.getBoundingClientRect(),Me=0;function Ue(nt){var pt=++Me,St=Bi(e,nt,!0,r.unit=="rectangle");if(!St)return;if(Tt(St,he)!=0){e.curOp.focus=M(),xe(St);var bt=Vn(n,L);(St.line>=bt.to||St.line<bt.from)&&setTimeout(gr(e,function(){Me==pt&&Ue(nt)}),150)}else{var Rt=nt.clientY<ve.top?-20:nt.clientY>ve.bottom?20:0;Rt&&setTimeout(gr(e,function(){if(Me!=pt)return;n.scroller.scrollTop+=Rt,Ue(nt)}),50)}}function Ve(nt){e.state.selectingText=!1,Me=Infinity,nt&&(ee(nt),n.input.focus()),rt(n.wrapper.ownerDocument,"mousemove",it),rt(n.wrapper.ownerDocument,"mouseup",ut),L.history.lastSelOrigin=null}var it=gr(e,function(nt){nt.buttons===0||!we(nt)?Ve(nt):Ue(nt)}),ut=gr(e,Ve);e.state.selectingText=ut,Le(n.wrapper.ownerDocument,"mousemove",it),Le(n.wrapper.ownerDocument,"mouseup",ut)}function Xl(e,t){var i=t.anchor,r=t.head,n=mt(e.doc,i.line);if(Tt(i,r)==0&&i.sticky==r.sticky)return t;var L=et(n);if(!L)return t;var U=Ye(L,i.ch,i.sticky),X=L[U];if(X.from!=i.ch&&X.to!=i.ch)return t;var $=U+(X.from==i.ch==(X.level!=1)?0:1);if($==0||$==L.length)return t;var Z;if(r.line!=i.line)Z=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var le=Ye(L,r.ch,r.sticky),he=le-U||(r.ch-i.ch)*(X.level==1?-1:1);le==$-1||le==$?Z=he<0:Z=he>0}var xe=L[$+(Z?-1:0)],ve=Z==(xe.level==1),Me=ve?xe.from:xe.to,Ue=ve?"after":"before";return i.ch==Me&&i.sticky==Ue?t:new zt(new We(i.line,Me,Ue),r)}function Ss(e,t,i,r){var n,L;if(t.touches)n=t.touches[0].clientX,L=t.touches[0].clientY;else try{n=t.clientX,L=t.clientY}catch(xe){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ee(t);var U=e.display,X=U.lineDiv.getBoundingClientRect();if(L>X.bottom||!de(e,i))return ne(t);L-=X.top-U.viewOffset;for(var $=0;$<e.display.gutterSpecs.length;++$){var Z=U.gutters.childNodes[$];if(Z&&Z.getBoundingClientRect().right>=n){var le=Yr(e.doc,L),he=e.display.gutterSpecs[$];return De(e,i,e,le,he.className,t),ne(t)}}}function Ga(e,t){return Ss(e,t,"gutterClick",!0)}function Cs(e,t){if(fi(e.display,t)||Yl(e,t))return;if(Ne(e,t,"contextmenu"))return;D||e.display.input.onContextMenu(t)}function Yl(e,t){return de(e,"gutterContextMenu")?Ss(e,t,"gutterContextMenu",!1):!1}function Ts(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 un={toString:function(){return"CodeMirror.Init"}},ws={},aa={};function $l(e){var t=e.optionHandlers;function i(r,n,L,U){e.defaults[r]=n,L&&(t[r]=U?function(X,$,Z){Z!=un&&L(X,$,Z)}:L)}e.defineOption=i,e.Init=un,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,Pa(r)},!0),i("indentUnit",2,Pa,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){wn(r),vn(r),Mr(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var L=[],U=r.doc.first;r.doc.iter(function($){for(var Z=0;;){var le=$.text.indexOf(n,Z);if(le==-1)break;Z=le+n.length,L.push(We(U,le))}U++});for(var X=L.length-1;X>=0;X--)an(r.doc,n,L[X],We(L[X].line,L[X].ch+n.length))}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,n,L){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),L!=un&&r.refresh()}),i("specialCharPlaceholder",yt,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",a?"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",!A),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Ts(r),Tn(r)},!0),i("keyMap","default",function(r,n,L){var U=ia(n),X=L!=un&&ia(L);X&&X.detach&&X.detach(r,U),U.attach&&U.attach(r,X||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Jl,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=Oa(n,r.options.lineNumbers),Tn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?Sa(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return en(r)},!0),i("scrollbarStyle","native",function(r){Ao(r),en(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=Oa(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,Ql),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 Ql(e,t,i){var r=i&&i!=un;if(!t!=!r){var n=e.display.dragFunctions,L=t?Le:rt;L(e.display.scroller,"dragstart",n.start),L(e.display.scroller,"dragenter",n.enter),L(e.display.scroller,"dragover",n.over),L(e.display.scroller,"dragleave",n.leave),L(e.display.scroller,"drop",n.drop)}}function Jl(e){e.options.lineWrapping?(F(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(y(e.display.wrapper,"CodeMirror-wrap"),ci(e)),Ca(e),Mr(e),vn(e),setTimeout(function(){return en(e)},100)}function Jt(e,t){var i=this;if(!(this instanceof Jt))return new Jt(e,t);this.options=t=t?j(t):{},j(ws,t,!1);var r=t.value;typeof r=="string"?r=new Pr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Jt.inputStyles[t.inputStyle](this),L=this.display=new dl(e,r,n,t);L.wrapper.CodeMirror=this,Ts(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Ao(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 oe,keySeq:null,specialChars:null},t.autofocus&&!a&&L.input.focus(),B&&N<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Zl(this),_l(),Wi(this),this.curOp.forceUpdate=!0,Bo(this,r),t.autofocus&&!a||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&wa(i)},20):Zi(this);for(var U in aa)aa.hasOwnProperty(U)&&aa[U](this,t[U],un);Ro(this),t.finishInit&&t.finishInit(this);for(var X=0;X<Ka.length;++X)Ka[X](this);Hi(this),O&&t.lineWrapping&&getComputedStyle(L.lineDiv).textRendering=="optimizelegibility"&&(L.lineDiv.style.textRendering="auto")}Jt.defaults=ws,Jt.optionHandlers=aa;function Zl(e){var t=e.display;Le(t.scroller,"mousedown",gr(e,xs)),B&&N<11?Le(t.scroller,"dblclick",gr(e,function($){if(Ne(e,$))return;var Z=Bi(e,$);if(!Z||Ga(e,$)||fi(e.display,$))return;ee($);var le=e.findWordAt(Z);Zn(e.doc,le.anchor,le.head)})):Le(t.scroller,"dblclick",function($){return Ne(e,$)||ee($)}),Le(t.scroller,"contextmenu",function($){return Cs(e,$)}),Le(t.input.getField(),"contextmenu",function($){t.scroller.contains($.target)||Cs(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 L($){if($.touches.length!=1)return!1;var Z=$.touches[0];return Z.radiusX<=1&&Z.radiusY<=1}function U($,Z){if(Z.left==null)return!0;var le=Z.left-$.left,he=Z.top-$.top;return le*le+he*he>20*20}Le(t.scroller,"touchstart",function($){if(!Ne(e,$)&&!L($)&&!Ga(e,$)){t.input.ensurePolled(),clearTimeout(i);var Z=+new Date;t.activeTouch={start:Z,moved:!1,prev:Z-r.end<=300?r:null},$.touches.length==1&&(t.activeTouch.left=$.touches[0].pageX,t.activeTouch.top=$.touches[0].pageY)}}),Le(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Le(t.scroller,"touchend",function($){var Z=t.activeTouch;if(Z&&!fi(t,$)&&Z.left!=null&&!Z.moved&&new Date-Z.start<300){var le=e.coordsChar(t.activeTouch,"page"),he;!Z.prev||U(Z,Z.prev)?he=new zt(le,le):!Z.prev.prev||U(Z,Z.prev.prev)?he=e.findWordAt(le):he=new zt(We(le.line,0),s(e.doc,We(le.line+1,0))),e.setSelection(he.anchor,he.head),e.focus(),ee($)}n()}),Le(t.scroller,"touchcancel",n),Le(t.scroller,"scroll",function(){t.scroller.clientHeight&&(xn(e,t.scroller.scrollTop),Fi(e,t.scroller.scrollLeft,!0),De(e,"scroll",e))}),Le(t.scroller,"mousewheel",function($){return Mo(e,$)}),Le(t.scroller,"DOMMouseScroll",function($){return Mo(e,$)}),Le(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function($){Ne(e,$)||ae($)},over:function($){Ne(e,$)||(Dl(e,$),ae($))},start:function($){return Al(e,$)},drop:gr(e,Ll),leave:function($){Ne(e,$)||ss(e)}};var X=t.input.getField();Le(X,"keyup",function($){return ys.call(e,$)}),Le(X,"keydown",gr(e,vs)),Le(X,"keypress",gr(e,bs)),Le(X,"focus",function($){return wa(e,$)}),Le(X,"blur",function($){return Zi(e,$)})}var Ka=[];Jt.defineInitHook=function(e){return Ka.push(e)};function Un(e,t,i,r){var n=e.doc,L;i==null&&(i="add"),i=="smart"&&(n.mode.indent?L=Ee(e,t).state:i="prev");var U=e.options.tabSize,X=mt(n,t),$=q(X.text,null,U);X.stateAfter&&(X.stateAfter=null);var Z=X.text.match(/^\s*/)[0],le;if(!r&&!/\S/.test(X.text))le=0,i="not";else if(i=="smart"&&(le=n.mode.indent(L,X.text.slice(Z.length),X.text),le==_e||le>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?le=q(mt(n,t-1).text,null,U):le=0:i=="add"?le=$+e.options.indentUnit:i=="subtract"?le=$-e.options.indentUnit:typeof i=="number"&&(le=$+i),le=Math.max(0,le);var he="",xe=0;if(e.options.indentWithTabs)for(var ve=Math.floor(le/U);ve;--ve)xe+=U,he+=" ";if(xe<le&&(he+=se(le-xe)),he!=Z)return an(n,he,We(t,0),We(t,Z.length),"+input"),X.stateAfter=null,!0;for(var Me=0;Me<n.sel.ranges.length;Me++){var Ue=n.sel.ranges[Me];if(Ue.head.line==t&&Ue.head.ch<Z.length){var Ve=We(t,Z.length);Ua(n,Me,new zt(Ve,Ve));break}}}var ti=null;function oa(e){ti=e}function Va(e,t,i,r,n){var L=e.doc;e.display.shift=!1,r||(r=L.sel);var U=+new Date-200,X=n=="paste"||e.state.pasteIncoming>U,$=ft(t),Z=null;if(X&&r.ranges.length>1)if(ti&&ti.text.join(`
|
|
`)==t){if(r.ranges.length%ti.text.length==0){Z=[];for(var le=0;le<ti.text.length;le++)Z.push(L.splitLines(ti.text[le]))}}else $.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(Z=Je($,function(it){return[it]}));for(var he=e.curOp.updateInput,xe=r.ranges.length-1;xe>=0;xe--){var ve=r.ranges[xe],Me=ve.from(),Ue=ve.to();ve.empty()&&(i&&i>0?Me=We(Me.line,Me.ch-i):e.state.overwrite&&!X?Ue=We(Ue.line,Math.min(mt(L,Ue.line).text.length,Ue.ch+Re($).length)):X&&ti&&ti.lineWise&&ti.text.join(`
|
|
`)==$.join(`
|
|
`)&&(Me=Ue=We(Me.line,0)));var Ve={from:Me,to:Ue,text:Z?Z[xe%Z.length]:$,origin:n||(X?"paste":e.state.cutIncoming>U?"cut":"+input")};nn(e.doc,Ve),Yt(e,"inputRead",e,Ve)}t&&!X&&As(e,t),qi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=he),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ls(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&Wr(t,function(){return Va(t,i,0,null,"paste")}),!0}function As(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 L=e.getModeAt(n.head),U=!1;if(L.electricChars){for(var X=0;X<L.electricChars.length;X++)if(t.indexOf(L.electricChars.charAt(X))>-1){U=Un(e,n.head.line,"smart");break}}else L.electricInput&&(L.electricInput.test(mt(e.doc,n.head.line).text.slice(0,n.head.ch))&&(U=Un(e,n.head.line,"smart")));U&&Yt(e,"electricInput",e,n.head.line)}}function Ds(e){for(var t=[],i=[],r=0;r<e.doc.sel.ranges.length;r++){var n=e.doc.sel.ranges[r].head.line,L={anchor:We(n,0),head:We(n+1,0)};i.push(L),t.push(e.getRange(L.anchor,L.head))}return{text:t,ranges:i}}function _s(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Rs(){var e=o("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=o("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return O?e.style.width="1000px":e.setAttribute("wrap","off"),b&&(e.style.border="1px solid black"),_s(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 L=this.options,U=L[r];if(L[r]==n&&r!="mode")return;L[r]=n,t.hasOwnProperty(r)&&gr(this,t[r])(this,n,U),De(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"](ia(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,L=0;L<n.length;++L)if(n[L]==r||n[L].name==r)return n.splice(L,1),!0},addOverlay:Ar(function(r,n){var L=r.token?r:e.getMode(this.options,r);if(L.startState)throw new Error("Overlays may not be stateful.");Xe(this.state.overlays,{mode:L,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(U){return U.priority}),this.state.modeGen++,Mr(this)}),removeOverlay:Ar(function(r){for(var n=this.state.overlays,L=0;L<n.length;++L){var U=n[L].modeSpec;if(U==r||typeof r=="string"&&U.name==r){n.splice(L,1),this.state.modeGen++,Mr(this);return}}}),indentLine:Ar(function(r,n,L){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),ui(this.doc,r)&&Un(this,r,n,L)}),indentSelection:Ar(function(r){for(var n=this.doc.sel.ranges,L=-1,U=0;U<n.length;U++){var X=n[U];if(X.empty())X.head.line>L&&(Un(this,X.head.line,r,!0),L=X.head.line,U==this.doc.sel.primIndex&&qi(this));else{var $=X.from(),Z=X.to(),le=Math.max(L,$.line);L=Math.min(this.lastLine(),Z.line-(Z.ch?0:1))+1;for(var he=le;he<L;++he)Un(this,he,r);var xe=this.doc.sel.ranges;$.ch==0&&n.length==xe.length&&xe[U].from().ch>0&&Ua(this.doc,U,new zt($,xe[U].to()),be)}}}),getTokenAt:function(r,n){return Gt(this,r,n)},getLineTokens:function(r,n){return Gt(this,We(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=Pe(this,mt(this.doc,r.line)),L=0,U=(n.length-1)/2,X=r.ch,$;if(X==0)$=n[2];else for(;;){var Z=L+U>>1;if((Z?n[Z*2-1]:0)>=X)U=Z;else if(n[Z*2+1]<X)L=Z+1;else{$=n[Z*2+2];break}}var le=$?$.indexOf("overlay "):-1;return le<0?$:le==0?null:$.slice(0,le-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 L=[];if(!i.hasOwnProperty(n))return L;var U=i[n],X=this.getModeAt(r);if(typeof X[n]=="string")U[X[n]]&&L.push(U[X[n]]);else if(X[n])for(var $=0;$<X[n].length;$++){var Z=U[X[n][$]];Z&&L.push(Z)}else X.helperType&&U[X.helperType]?L.push(U[X.helperType]):U[X.name]&&L.push(U[X.name]);for(var le=0;le<U._global.length;le++){var he=U._global[le];he.pred(X,this)&&ue(L,he.val)==-1&&L.push(he.val)}return L},getStateAfter:function(r,n){var L=this.doc;return r=z(L,r==null?L.first+L.size-1:r),Ee(this,r+1,n).state},cursorCoords:function(r,n){var L,U=this.doc.sel.primary();return r==null?L=U.head:typeof r=="object"?L=s(this.doc,r):L=r?U.from():U.to(),qr(this,L,n||"page")},charCoords:function(r,n){return va(this,s(this.doc,r),n||"page")},coordsChar:function(r,n){return r=co(this,r,n||"page"),ba(this,r.left,r.top)},lineAtHeight:function(r,n){return r=co(this,{top:r,left:0},n||"page").top,Yr(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,L){var U=!1,X;if(typeof r=="number"){var $=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>$&&(r=$,U=!0),X=mt(this.doc,r)}else X=r;return Hn(this,X,{top:0,left:0},n||"page",L||U).top+(U?this.doc.height-jr(X):0)},defaultTextHeight:function(){return Qi(this.display)},defaultCharWidth:function(){return Ji(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,L,U,X){var $=this.display;r=qr(this,s(this.doc,r));var Z=r.bottom,le=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),$.sizer.appendChild(n),U=="over")Z=r.top;else if(U=="above"||U=="near"){var he=Math.max($.wrapper.clientHeight,this.doc.height),xe=Math.max($.sizer.clientWidth,$.lineSpace.clientWidth);(U=="above"||r.bottom+n.offsetHeight>he)&&r.top>n.offsetHeight?Z=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=he&&(Z=r.bottom),le+n.offsetWidth>xe&&(le=xe-n.offsetWidth)}n.style.top=Z+"px",n.style.left=n.style.right="",X=="right"?(le=$.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(X=="left"?le=0:X=="middle"&&(le=($.sizer.clientWidth-n.offsetWidth)/2),n.style.left=le+"px"),L&&Qs(this,{left:le,top:Z,right:le+n.offsetWidth,bottom:Z+n.offsetHeight})},triggerOnKeyDown:Ar(vs),triggerOnKeyPress:Ar(bs),triggerOnKeyUp:ys,triggerOnMouseDown:Ar(xs),execCommand:function(r){if(Pn.hasOwnProperty(r))return Pn[r].call(null,this)},triggerElectric:Ar(function(r){As(this,r)}),findPosH:function(r,n,L,U){var X=1;n<0&&(X=-1,n=-n);for(var $=s(this.doc,r),Z=0;Z<n&&!($=Xa(this.doc,$,X,L,U),$.hitSide);++Z);return $},moveH:Ar(function(r,n){var L=this;this.extendSelectionsBy(function(U){return L.display.shift||L.doc.extend||U.empty()?Xa(L.doc,U.head,r,n,L.options.rtlMoveVisually):r<0?U.from():U.to()},Te)}),deleteH:Ar(function(r,n){var L=this.doc.sel,U=this.doc;L.somethingSelected()?U.replaceSelection("",null,"+delete"):ln(this,function(X){var $=Xa(U,X.head,r,n,!1);return r<0?{from:$,to:X.head}:{from:X.head,to:$}})}),findPosV:function(r,n,L,U){var X=1,$=U;n<0&&(X=-1,n=-n);for(var Z=s(this.doc,r),le=0;le<n;++le){var he=qr(this,Z,"div");if($==null?$=he.left:he.left=$,Z=ks(this,he,X,L),Z.hitSide)break}return Z},moveV:Ar(function(r,n){var L=this,U=this.doc,X=[],$=!this.display.shift&&!U.extend&&U.sel.somethingSelected();if(U.extendSelectionsBy(function(le){if($)return r<0?le.from():le.to();var he=qr(L,le.head,"div");le.goalColumn!=null&&(he.left=le.goalColumn),X.push(he.left);var xe=ks(L,he,r,n);return n=="page"&&le==U.sel.primary()&&Aa(L,va(L,xe,"div").top-he.top),xe},Te),X.length)for(var Z=0;Z<U.sel.ranges.length;Z++)U.sel.ranges[Z].goalColumn=X[Z]}),findWordAt:function(r){var n=this.doc,L=mt(n,r.line).text,U=r.ch,X=r.ch;if(L){var $=this.getHelper(r,"wordChars");(r.sticky=="before"||X==L.length)&&U?--U:++X;for(var Z=L.charAt(U),le=He(Z,$)?function(he){return He(he,$)}:/\s/.test(Z)?function(he){return/\s/.test(he)}:function(he){return!/\s/.test(he)&&!He(he)};U>0&&le(L.charAt(U-1));)--U;for(;X<L.length&&le(L.charAt(X));)++X}return new zt(We(r.line,U),We(r.line,X))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?F(this.display.cursorDiv,"CodeMirror-overwrite"):y(this.display.cursorDiv,"CodeMirror-overwrite"),De(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==M()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:Ar(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:pa(this),clientWidth:Ii(this)}},scrollIntoView:Ar(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):Co(this,r.from,r.to,r.margin)}),setSize:Ar(function(r,n){var L=this,U=function($){return typeof $=="number"||/^\d+$/.test(String($))?$+"px":$};r!=null&&(this.display.wrapper.style.width=U(r)),n!=null&&(this.display.wrapper.style.height=U(n)),this.options.lineWrapping&&lo(this);var X=this.display.viewFrom;this.doc.iter(X,this.display.viewTo,function($){if($.widgets){for(var Z=0;Z<$.widgets.length;Z++)if($.widgets[Z].noHScroll){Si(L,X,"widget");break}}++X}),this.curOp.forceUpdate=!0,De(this,"refresh",this)}),operation:function(r){return Wr(this,r)},startOperation:function(){return Wi(this)},endOperation:function(){return Hi(this)},refresh:Ar(function(){var r=this.display.cachedTextHeight;Mr(this),this.curOp.forceUpdate=!0,vn(this),bn(this,this.doc.scrollLeft,this.doc.scrollTop),Ra(this.display),(r==null||Math.abs(r-Qi(this.display))>.5||this.options.lineWrapping)&&Ca(this),De(this,"refresh",this)}),swapDoc:Ar(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Bo(this,r),vn(this),this.display.input.reset(),bn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,Yt(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,L){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=L},e.registerGlobalHelper=function(r,n,L,U){e.registerHelper(r,n,U),i[r]._global.push({pred:L,val:U})}}function Xa(e,t,i,r,n){var L=t,U=i,X=mt(e,t.line),$=n&&e.direction=="rtl"?-i:i;function Z(){var ut=t.line+$;return ut<e.first||ut>=e.first+e.size?!1:(t=new We(ut,t.ch,t.sticky),X=mt(e,ut))}function le(ut){var nt;if(r=="codepoint"){var pt=X.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(pt)?nt=null:nt=new We(t.line,Math.max(0,Math.min(X.text.length,t.ch+i*(pt>=55296&&pt<56320?2:1))),-i)}else n?nt=Pl(e.cm,X,t,i):nt=ja(X,t,i);if(nt==null)if(!ut&&Z())t=Wa(n,e.cm,X,t.line,$);else return!1;else t=nt;return!0}if(r=="char"||r=="codepoint")le();else if(r=="column")le(!0);else if(r=="word"||r=="group")for(var he=null,xe=r=="group",ve=e.cm&&e.cm.getHelper(t,"wordChars"),Me=!0;!(i<0&&!le(!Me));Me=!1){var Ue=X.text.charAt(t.ch)||`
|
|
`,Ve=He(Ue,ve)?"w":xe&&Ue==`
|
|
`?"n":!xe||/\s/.test(Ue)?null:"p";if(xe&&!Me&&!Ve&&(Ve="s"),he&&he!=Ve){i<0&&(i=1,le(),t.sticky="after");break}if(Ve&&(he=Ve),i>0&&!le(!Me))break}var it=ea(e,t,L,U,!0);return ri(L,it)&&(it.hitSide=!0),it}function ks(e,t,i,r){var n=e.doc,L=t.left,U;if(r=="page"){var X=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),$=Math.max(X-.5*Qi(e.display),3);U=(i>0?t.bottom:t.top)+i*$}else r=="line"&&(U=i>0?t.bottom+3:t.top-3);for(var Z;!(Z=ba(e,L,U),!Z.outside);){if(i<0?U<=0:U>=n.height){Z.hitSide=!0;break}U+=i*5}return Z}var Xt=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new oe,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;_s(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function L(X){for(var $=X.target;$;$=$.parentNode){if($==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test($.className))break}return!1}Le(n,"paste",function(X){if(!L(X)||Ne(r,X)||Ls(X,r))return;N<=11&&setTimeout(gr(r,function(){return t.updateFromDOM()}),20)}),Le(n,"compositionstart",function(X){t.composing={data:X.data,done:!1}}),Le(n,"compositionupdate",function(X){t.composing||(t.composing={data:X.data,done:!1})}),Le(n,"compositionend",function(X){t.composing&&(X.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Le(n,"touchstart",function(){return i.forceCompositionEnd()}),Le(n,"input",function(){t.composing||t.readFromDOMSoon()});function U(X){if(!L(X)||Ne(r,X))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()}),X.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var $=Ds(r);oa({lineWise:!0,text:$.text}),X.type=="cut"&&r.operation(function(){r.setSelections($.ranges,0,be),r.replaceSelection("",null,"cut")})}else return;if(X.clipboardData){X.clipboardData.clearData();var Z=ti.text.join(`
|
|
`);if(X.clipboardData.setData("Text",Z),X.clipboardData.getData("Text")==Z){X.preventDefault();return}}var le=Rs(),he=le.firstChild;r.display.lineSpace.insertBefore(le,r.display.lineSpace.firstChild),he.value=ti.text.join(`
|
|
`);var xe=document.activeElement;J(he),setTimeout(function(){r.display.lineSpace.removeChild(le),xe.focus(),xe==n&&i.showPrimarySelection()},50)}Le(n,"copy",U),Le(n,"cut",U)},Xt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Xt.prototype.prepareSelection=function(){var e=yo(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 L=sa(t,e.anchorNode,e.anchorOffset),U=sa(t,e.focusNode,e.focusOffset);if(L&&!L.bad&&U&&!U.bad&&Tt(Ri(L,U),r)==0&&Tt(hi(L,U),n)==0)return;var X=t.display.view,$=r.line>=t.display.viewFrom&&Os(t,r)||{node:X[0].measure.map[2],offset:0},Z=n.line<t.display.viewTo&&Os(t,n);if(!Z){var le=X[X.length-1].measure,he=le.maps?le.maps[le.maps.length-1]:le.map;Z={node:he[he.length-1],offset:he[he.length-2]-he[he.length-3]}}if(!$||!Z){e.removeAllRanges();return}var xe=e.rangeCount&&e.getRangeAt(0),ve;try{ve=S($.node,$.offset,Z.offset,Z.node)}catch(Me){}ve&&(!_&&t.state.focused?(e.collapse($.node,$.offset),ve.collapsed||(e.removeAllRanges(),e.addRange(ve))):(e.removeAllRanges(),e.addRange(ve)),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 x(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():Wr(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&&f&&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=sa(t,e.anchorNode,e.anchorOffset),r=sa(t,e.focusNode,e.focusOffset);i&&r&&Wr(t,function(){Tr(t.doc,Ti(i,r),be),(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,mt(e.doc,r.line-1).length)),n.ch==mt(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 L,U,X;r.line==t.viewFrom||(L=Ui(e,r.line))==0?(U=Pt(t.view[0].line),X=t.view[0].node):(U=Pt(t.view[L].line),X=t.view[L-1].node.nextSibling);var $=Ui(e,n.line),Z,le;if($==t.view.length-1?(Z=t.viewTo-1,le=t.lineDiv.lastChild):(Z=Pt(t.view[$+1].line)-1,le=t.view[$+1].node.previousSibling),!X)return!1;for(var he=e.doc.splitLines(tu(e,X,le,U,Z)),xe=ur(e.doc,We(U,0),We(Z,mt(e.doc,Z).text.length));he.length>1&&xe.length>1;)if(Re(he)==Re(xe))he.pop(),xe.pop(),Z--;else if(he[0]==xe[0])he.shift(),xe.shift(),U++;else break;for(var ve=0,Me=0,Ue=he[0],Ve=xe[0],it=Math.min(Ue.length,Ve.length);ve<it&&Ue.charCodeAt(ve)==Ve.charCodeAt(ve);)++ve;for(var ut=Re(he),nt=Re(xe),pt=Math.min(ut.length-(he.length==1?ve:0),nt.length-(xe.length==1?ve:0));Me<pt&&ut.charCodeAt(ut.length-Me-1)==nt.charCodeAt(nt.length-Me-1);)++Me;if(he.length==1&&xe.length==1&&U==r.line)for(;ve&&ve>r.ch&&ut.charCodeAt(ut.length-Me-1)==nt.charCodeAt(nt.length-Me-1);)ve--,Me++;he[he.length-1]=ut.slice(0,ut.length-Me).replace(/^\u200b+/,""),he[0]=he[0].slice(ve).replace(/\u200b+$/,"");var St=We(U,ve),bt=We(Z,xe.length?Re(xe).length-Me:0);if(he.length>1||he[0]||Tt(St,bt))return an(e.doc,he,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())&&Wr(this.cm,function(){return Mr(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()||gr(this.cm,Va)(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 Os(e,t){var i=ma(e,t.line);if(!i||i.hidden)return null;var r=mt(e.doc,t.line),n=io(i,r,t.line),L=et(r,e.doc.direction),U="left";if(L){var X=Ye(L,t.ch);U=X%2?"right":"left"}var $=oo(n.map,t.ch,U);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 dn(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var L="",U=!1,X=e.doc.lineSeparator(),$=!1;function Z(ve){return function(Me){return Me.id==ve}}function le(){U&&(L+=X,$&&(L+=X),U=$=!1)}function he(ve){ve&&(le(),L+=ve)}function xe(ve){if(ve.nodeType==1){var Me=ve.getAttribute("cm-text");if(Me){he(Me);return}var Ue=ve.getAttribute("cm-marker"),Ve;if(Ue){var it=e.findMarks(We(r,0),We(n+1,0),Z(+Ue));it.length&&(Ve=it[0].find(0))&&he(ur(e.doc,Ve.from,Ve.to).join(X));return}if(ve.getAttribute("contenteditable")=="false")return;var ut=/^(pre|div|p|li|table|br)$/i.test(ve.nodeName);if(!/^br$/i.test(ve.nodeName)&&ve.textContent.length==0)return;ut&&le();for(var nt=0;nt<ve.childNodes.length;nt++)xe(ve.childNodes[nt]);/^(pre|p)$/i.test(ve.nodeName)&&($=!0),ut&&(U=!0)}else ve.nodeType==3&&he(ve.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(xe(t),t==i);)t=t.nextSibling,$=!1;return L}function sa(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return dn(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 L=e.display.view[n];if(L.node==r)return ru(L,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!x(r,t))return dn(We(Pt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var L=e.rest?Re(e.rest):e.line;return dn(We(Pt(L),L.text.length),n)}var U=t.nodeType==3?t:null,X=t;for(!U&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(U=t.firstChild,i&&(i=U.nodeValue.length));X.parentNode!=r;)X=X.parentNode;var $=e.measure,Z=$.maps;function le(Ve,it,ut){for(var nt=-1;nt<(Z?Z.length:0);nt++)for(var pt=nt<0?$.map:Z[nt],St=0;St<pt.length;St+=3){var bt=pt[St+2];if(bt==Ve||bt==it){var Rt=Pt(nt<0?e.line:e.rest[nt]),Qt=pt[St]+ut;return(ut<0||bt!=Ve)&&(Qt=pt[St+(ut?1:0)]),We(Rt,Qt)}}}var he=le(U,X,i);if(he)return dn(he,n);for(var xe=X.nextSibling,ve=U?U.nodeValue.length-i:0;xe;xe=xe.nextSibling){if(he=le(xe,xe.firstChild,0),he)return dn(We(he.line,he.ch-ve),n);ve+=xe.textContent.length}for(var Me=X.previousSibling,Ue=i;Me;Me=Me.previousSibling){if(he=le(Me,Me.firstChild,-1),he)return dn(We(he.line,he.ch+Ue),n);Ue+=Me.textContent.length}}var nr=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new oe,this.hasSelection=!1,this.composing=null};nr.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),b&&(n.style.width="0px"),Le(n,"input",function(){B&&N>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Le(n,"paste",function(U){if(Ne(r,U)||Ls(U,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function L(U){if(Ne(r,U))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var X=Ds(r);oa({lineWise:!0,text:X.text}),U.type=="cut"?r.setSelections(X.ranges,null,be):(i.prevInput="",n.value=X.text.join(`
|
|
`),J(n))}else return;U.type=="cut"&&(r.state.cutIncoming=+new Date)}Le(n,"cut",L),Le(n,"copy",L),Le(e.scroller,"paste",function(U){if(fi(e,U)||Ne(r,U))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var X=new Event("paste");X.clipboardData=U.clipboardData,n.dispatchEvent(X)}),Le(e.lineSpace,"selectstart",function(U){fi(e,U)||ee(U)}),Le(n,"compositionstart",function(){var U=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:U,range:r.markText(U,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Le(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},nr.prototype.createField=function(e){this.wrapper=Rs(),this.textarea=this.wrapper.firstChild},nr.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},nr.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=yo(e);if(e.options.moveInputWithCursor){var n=qr(e,i.sel.primary().head,"div"),L=t.wrapper.getBoundingClientRect(),U=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+U.top-L.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+U.left-L.left))}return r},nr.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")},nr.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&&J(this.textarea),B&&N>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",B&&N>=9&&(this.hasSelection=null))},nr.prototype.getField=function(){return this.textarea},nr.prototype.supportsTouch=function(){return!1},nr.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!a||M()!=this.textarea))try{this.textarea.focus()}catch(e){}},nr.prototype.blur=function(){this.textarea.blur()},nr.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},nr.prototype.receivedFocus=function(){this.slowPoll()},nr.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()})},nr.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)},nr.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||Ge(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(B&&N>=9&&this.hasSelection===n||l&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var L=n.charCodeAt(0);if(L==8203&&!r&&(r="\u200B"),L==8666)return this.reset(),this.cm.execCommand("undo")}for(var U=0,X=Math.min(r.length,n.length);U<X&&r.charCodeAt(U)==n.charCodeAt(U);)++U;return Wr(t,function(){Va(t,n.slice(U),r.length-U,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},nr.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},nr.prototype.onKeyPress=function(){B&&N>=9&&(this.hasSelection=null),this.fastPoll()},nr.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var L=Bi(i,e),U=r.scroller.scrollTop;if(!L||c)return;var X=i.options.resetSelectionOnContextMenu;X&&i.doc.sel.contains(L)==-1&&gr(i,Tr)(i.doc,Ti(L),be);var $=n.style.cssText,Z=t.wrapper.style.cssText,le=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
|
|
top: `+(e.clientY-le.top-5)+"px; left: "+(e.clientX-le.left-5)+`px;
|
|
z-index: 1000; background: `+(B?"rgba(255, 255, 255, .05)":"transparent")+`;
|
|
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var he;O&&(he=window.scrollY),r.input.focus(),O&&window.scrollTo(null,he),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=ve,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function xe(){if(n.selectionStart!=null){var Ue=i.somethingSelected(),Ve="\u200B"+(Ue?n.value:"");n.value="\u21DA",n.value=Ve,t.prevInput=Ue?"":"\u200B",n.selectionStart=1,n.selectionEnd=Ve.length,r.selForContextMenu=i.doc.sel}}function ve(){if(t.contextMenuPending!=ve)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=Z,n.style.cssText=$,B&&N<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=U),n.selectionStart!=null){(!B||B&&N<9)&&xe();var Ue=0,Ve=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?gr(i,Qo)(i):Ue++<10?r.detectingSelectAll=setTimeout(Ve,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(Ve,200)}}if(B&&N>=9&&xe(),D){ae(e);var Me=function(){rt(window,"mouseup",Me),setTimeout(ve,20)};Le(window,"mouseup",Me)}else setTimeout(ve,50)},nr.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},nr.prototype.setUneditable=function(){},nr.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=M();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=X.getValue()}var n;if(e.form&&(Le(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var L=e.form;n=L.submit;try{var U=L.submit=function(){r(),L.submit=n,L.submit(),L.submit=U}}catch($){}}t.finishInit=function($){$.save=r,$.getTextArea=function(){return e},$.toTextArea=function(){$.toTextArea=isNaN,r(),e.parentNode.removeChild($.getWrapperElement()),e.style.display="",e.form&&(rt(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var X=Jt(function($){return e.parentNode.insertBefore($,e.nextSibling)},t);return X}function nu(e){e.off=rt,e.on=Le,e.wheelEventPixels=hl,e.Doc=Pr,e.splitLines=ft,e.countColumn=q,e.findColumn=Ce,e.isWordChar=ke,e.Pass=_e,e.signal=De,e.Line=Ei,e.changeEnd=wi,e.scrollbarModel=Lo,e.Pos=We,e.cmpPos=Tt,e.modes=Ft,e.mimeModes=Dt,e.resolveMode=vt,e.getMode=Lr,e.modeExtensions=fr,e.extendMode=lr,e.copyState=Mt,e.startState=jt,e.innerMode=er,e.commands=Pn,e.keyMap=pi,e.keyName=cs,e.isModifierKey=ds,e.lookupKey=sn,e.normalizeKeyMap=Ml,e.StringStream=Lt,e.SharedTextMarker=kn,e.TextMarker=Ai,e.LineWidget=Rn,e.e_preventDefault=ee,e.e_stopPropagation=re,e.e_stop=ae,e.addClass=F,e.contains=x,e.rmClass=y,e.keyNames=Di}$l(Jt),ql(Jt);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in Pr.prototype)Pr.prototype.hasOwnProperty(la)&&ue(au,la)<0&&(Jt.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(Pr.prototype[la]));return fe(Pr),Jt.inputStyles={textarea:nr,contenteditable:Xt},Jt.defineMode=function(e){!Jt.defaults.mode&&e!="null"&&(Jt.defaults.mode=e),sr.apply(this,arguments)},Jt.defineMIME=rr,Jt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Jt.defineMIME("text/plain","null"),Jt.defineExtension=function(e,t){Jt.prototype[e]=t},Jt.defineDocExtension=function(e,t){Pr.prototype[e]=t},Jt.fromTextArea=iu,nu(Jt),Jt.version="5.58.2",Jt})},Y1PL:function(dt,qe,te){"use strict";te.r(qe),te.d(qe,"ResizableTextArea",function(){return ue});var ie=te("wx14"),Y=te("1OyB"),_=te("vuIU"),V=te("Ji7U"),I=te("LK+K"),P=te("q1tI"),B=te("VTBJ"),N=te("rePB"),O=te("Zm9Q"),R=te("Kwbf"),f=te("c+Xe"),c=te("m+aA"),k=te("bdgK"),T=new Map;function g(be){be.forEach(function(Se){var Te,Ce=Se.target;(Te=T.get(Ce))===null||Te===void 0||Te.forEach(function(pe){return pe(Ce)})})}var b=new k.default(g),u=null,a=null;function l(be,Se){T.has(be)||(T.set(be,new Set),b.observe(be)),T.get(be).add(Se)}function h(be,Se){T.has(be)&&(T.get(be).delete(Se),T.get(be).size||(b.unobserve(be),T.delete(be)))}var A=function(be){Object(V.a)(Te,be);var Se=Object(I.a)(Te);function Te(){return Object(Y.a)(this,Te),Se.apply(this,arguments)}return Object(_.a)(Te,[{key:"render",value:function(){return this.props.children}}]),Te}(P.Component),m=P.createContext(null);function E(be){var Se=be.children,Te=be.onBatchResize,Ce=P.useRef(0),pe=P.useRef([]),se=P.useContext(m),Re=P.useCallback(function(Je,Xe,Ze){Ce.current+=1;var Ke=Ce.current;pe.current.push({size:Je,element:Xe,data:Ze}),Promise.resolve().then(function(){Ke===Ce.current&&(Te==null||Te(pe.current),pe.current=[])}),se==null||se(Je,Xe,Ze)},[Te,se]);return P.createElement(m.Provider,{value:Re},Se)}function D(be){var Se=be.children,Te=be.disabled,Ce=P.useRef(null),pe=P.useRef(null),se=P.useContext(m),Re=P.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Je=P.isValidElement(Se)&&Object(f.c)(Se),Xe=Je?Se.ref:null,Ze=P.useMemo(function(){return Object(f.a)(Xe,Ce)},[Xe,Ce]),Ke=P.useRef(be);Ke.current=be;var Ae=P.useCallback(function(ke){var He=Ke.current,$e=He.onResize,ze=He.data,Ie=ke.getBoundingClientRect(),Fe=Ie.width,ht=Ie.height,at=ke.offsetWidth,tt=ke.offsetHeight,Ye=Math.floor(Fe),lt=Math.floor(ht);if(Re.current.width!==Ye||Re.current.height!==lt||Re.current.offsetWidth!==at||Re.current.offsetHeight!==tt){var et={width:Ye,height:lt,offsetWidth:at,offsetHeight:tt};Re.current=et;var Qe=at===Math.round(Fe)?Fe:at,Le=tt===Math.round(ht)?ht:tt,st=Object(B.a)(Object(B.a)({},et),{},{offsetWidth:Qe,offsetHeight:Le});se==null||se(st,ke,ze),$e&&Promise.resolve().then(function(){$e(st,ke)})}},[]);return P.useEffect(function(){var ke=Object(c.a)(Ce.current)||Object(c.a)(pe.current);return ke&&!Te&&l(ke,Ae),function(){return h(ke,Ae)}},[Ce.current,Te]),P.createElement(A,{ref:pe},Je?P.cloneElement(Se,{ref:Ze}):Se)}var w="rc-observer-key";function y(be){var Se=be.children,Te=Object(O.a)(Se);return Te.map(function(Ce,pe){var se=(Ce==null?void 0:Ce.key)||"".concat(w,"-").concat(pe);return P.createElement(D,Object(ie.a)({},be,{key:se}),Ce)})}y.Collection=E;var p=y,d=te("bT9E"),o=te("TSYQ"),C=te.n(o),S=`
|
|
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
|
|
`,x=["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"],M={},F;function G(be){var Se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=be.getAttribute("id")||be.getAttribute("data-reactid")||be.getAttribute("name");if(Se&&M[Te])return M[Te];var Ce=window.getComputedStyle(be),pe=Ce.getPropertyValue("box-sizing")||Ce.getPropertyValue("-moz-box-sizing")||Ce.getPropertyValue("-webkit-box-sizing"),se=parseFloat(Ce.getPropertyValue("padding-bottom"))+parseFloat(Ce.getPropertyValue("padding-top")),Re=parseFloat(Ce.getPropertyValue("border-bottom-width"))+parseFloat(Ce.getPropertyValue("border-top-width")),Je=x.map(function(Ze){return"".concat(Ze,":").concat(Ce.getPropertyValue(Ze))}).join(";"),Xe={sizingStyle:Je,paddingSize:se,borderSize:Re,boxSizing:pe};return Se&&Te&&(M[Te]=Xe),Xe}function J(be){var Se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Ce=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;F||(F=document.createElement("textarea"),F.setAttribute("tab-index","-1"),F.setAttribute("aria-hidden","true"),document.body.appendChild(F)),be.getAttribute("wrap")?F.setAttribute("wrap",be.getAttribute("wrap")):F.removeAttribute("wrap");var pe=G(be,Se),se=pe.paddingSize,Re=pe.borderSize,Je=pe.boxSizing,Xe=pe.sizingStyle;F.setAttribute("style","".concat(Xe,";").concat(S)),F.value=be.value||be.placeholder||"";var Ze=Number.MIN_SAFE_INTEGER,Ke=Number.MAX_SAFE_INTEGER,Ae=F.scrollHeight,ke;if(Je==="border-box"?Ae+=Re:Je==="content-box"&&(Ae-=se),Te!==null||Ce!==null){F.value=" ";var He=F.scrollHeight-se;Te!==null&&(Ze=He*Te,Je==="border-box"&&(Ze=Ze+se+Re),Ae=Math.max(Ze,Ae)),Ce!==null&&(Ke=He*Ce,Je==="border-box"&&(Ke=Ke+se+Re),ke=Ae>Ke?"":"hidden",Ae=Math.min(Ke,Ae))}return{height:Ae,minHeight:Ze,maxHeight:Ke,overflowY:ke,resize:"none"}}var K=te("Gytx"),j=te.n(K),q;(function(be){be[be.NONE=0]="NONE",be[be.RESIZING=1]="RESIZING",be[be.RESIZED=2]="RESIZED"})(q||(q={}));var oe=function(be){Object(V.a)(Te,be);var Se=Object(I.a)(Te);function Te(Ce){var pe;return Object(Y.a)(this,Te),pe=Se.call(this,Ce),pe.nextFrameActionId=void 0,pe.resizeFrameId=void 0,pe.textArea=void 0,pe.saveTextArea=function(se){pe.textArea=se},pe.handleResize=function(se){var Re=pe.state.resizeStatus,Je=pe.props,Xe=Je.autoSize,Ze=Je.onResize;if(Re!==q.NONE)return;typeof Ze=="function"&&Ze(se),Xe&&pe.resizeOnNextFrame()},pe.resizeOnNextFrame=function(){cancelAnimationFrame(pe.nextFrameActionId),pe.nextFrameActionId=requestAnimationFrame(pe.resizeTextarea)},pe.resizeTextarea=function(){var se=pe.props.autoSize;if(!se||!pe.textArea)return;var Re=se.minRows,Je=se.maxRows,Xe=J(pe.textArea,!1,Re,Je);pe.setState({textareaStyles:Xe,resizeStatus:q.RESIZING},function(){cancelAnimationFrame(pe.resizeFrameId),pe.resizeFrameId=requestAnimationFrame(function(){pe.setState({resizeStatus:q.RESIZED},function(){pe.resizeFrameId=requestAnimationFrame(function(){pe.setState({resizeStatus:q.NONE}),pe.fixFirefoxAutoScroll()})})})})},pe.renderTextArea=function(){var se=pe.props,Re=se.prefixCls,Je=Re===void 0?"rc-textarea":Re,Xe=se.autoSize,Ze=se.onResize,Ke=se.className,Ae=se.disabled,ke=pe.state,He=ke.textareaStyles,$e=ke.resizeStatus,ze=Object(d.a)(pe.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Ie=C()(Je,Ke,Object(N.a)({},"".concat(Je,"-disabled"),Ae));"value"in ze&&(ze.value=ze.value||"");var Fe=Object(B.a)(Object(B.a)(Object(B.a)({},pe.props.style),He),$e===q.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return P.createElement(p,{onResize:pe.handleResize,disabled:!(Xe||Ze)},P.createElement("textarea",Object(ie.a)({},ze,{className:Ie,style:Fe,ref:pe.saveTextArea})))},pe.state={textareaStyles:{},resizeStatus:q.NONE},pe}return Object(_.a)(Te,[{key:"componentDidUpdate",value:function(pe){(pe.value!==this.props.value||!j()(pe.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 pe=this.textArea.selectionStart,se=this.textArea.selectionEnd;this.textArea.setSelectionRange(pe,se)}}catch(Re){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Te}(P.Component),ue=oe,ge=function(be){Object(V.a)(Te,be);var Se=Object(I.a)(Te);function Te(Ce){var pe;Object(Y.a)(this,Te),pe=Se.call(this,Ce),pe.resizableTextArea=void 0,pe.focus=function(){pe.resizableTextArea.textArea.focus()},pe.saveTextArea=function(Re){pe.resizableTextArea=Re},pe.handleChange=function(Re){var Je=pe.props.onChange;pe.setValue(Re.target.value,function(){pe.resizableTextArea.resizeTextarea()}),Je&&Je(Re)},pe.handleKeyDown=function(Re){var Je=pe.props,Xe=Je.onPressEnter,Ze=Je.onKeyDown;Re.keyCode===13&&Xe&&Xe(Re),Ze&&Ze(Re)};var se=typeof Ce.value=="undefined"||Ce.value===null?Ce.defaultValue:Ce.value;return pe.state={value:se},pe}return Object(_.a)(Te,[{key:"setValue",value:function(pe,se){"value"in this.props||this.setState({value:pe},se)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return P.createElement(ue,Object(ie.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(pe){return"value"in pe?{value:pe.value}:null}}]),Te}(P.Component),_e=qe.default=ge},ZW9T:function(dt,qe,te){"use strict";te.d(qe,"a",function(){return A});var ie=te("k1fw"),Y=te("miYZ"),_=te("tsqr"),V=te("rAM+"),I=te("tJVT"),P=te("PpiC"),B=te("q1tI"),N=te.n(B),O=te("bdgK");function R(m,E,D,w,y){var p=E.getWordUntilPosition(D),d={startLineNumber:D.lineNumber,endLineNumber:D.lineNumber,startColumn:p.startColumn,endColumn:p.endColumn},o=w.map(function(C){return{label:C,kind:m.languages.CompletionItemKind.Keyword,insertText:C,insertTextRules:m.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:d}});return y.map(function(C){o.push(Object(ie.a)(Object(ie.a)({},C),{},{range:d}))}),o}var f=function(m){var E={label:"ifelse",kind:m.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {"," $0","} else {"," ","}"].join(`
|
|
`),insertTextRules:m.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"];m.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(d,o){var C=R(m,d,o,D,[E]);return{suggestions:C}}});var w=["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"];m.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(d,o){var C=[{label:"print",kind:m.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join(`
|
|
`),insertTextRules:m.languages.CompletionItemInsertTextRule.InsertAsSnippet}],S=R(m,d,o,w,C);return{suggestions:S}}});var y=["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"];m.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(d,o){var C=[E,{label:"main",kind:m.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {"," $0","}"].join(`
|
|
`),insertTextRules:m.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:m.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join(`
|
|
`),insertTextRules:m.languages.CompletionItemInsertTextRule.InsertAsSnippet}],S=R(m,d,o,y,C);return{suggestions:S}}})},c="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",k=te("LvDl");function T(m){return/^\d+$/.test(m)?"".concat(m,"px"):m}function g(){}var b=!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 a(){var m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],E=m;if(Array.isArray(m)){for(var D=0;D<m.length;D++){var w=u[m[D]];if(w)return w}return E[0]}return u[E]||E}var l=null,h=qe.b=function(m){var E=m.width,D=E===void 0?"100%":E,w=m.height,y=w===void 0?"100%":w,p=m.value,d=m.language,o=d===void 0?"javascript":d,C=m.style,S=C===void 0?{}:C,x=m.options,M=x===void 0?{}:x,F=m.overrideServices,G=F===void 0?{}:F,J=m.theme,K=J===void 0?"vs-dark":J,j=m.onEditBlur,q=m.onSave,oe=m.autoHeight,ue=oe===void 0?!1:oe,ge=m.forbidCopy,_e=ge===void 0?!1:ge,be=m.onChange,Se=be===void 0?g:be,Te=m.editorDidMount,Ce=Te===void 0?g:Te,pe=m.onFocus,se=pe===void 0?g:pe,Re=m.filename,Je=Re===void 0?"educoder.txt":Re,Xe=Object(P.a)(m,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),Ze=Object(B.useRef)(),Ke=Object(B.useRef)({}),Ae=Object(B.useRef)(),ke=Object(B.useRef)(!1),He=Object(B.useRef)(),$e=Object(B.useState)(!1),ze=Object(I.a)($e,2),Ie=ze[0],Fe=ze[1];function ht(){var ne;return Ze.current&&(ne=new O.default(function(ae){var ye=Object(V.a)(ae),we;try{for(ye.s();!(we=ye.n()).done;){var je=we.value;(je.target.offsetHeight>0||je.target.offsetWidth>0)&&Ke.current.instance.layout()}}catch(ot){ye.e(ot)}finally{ye.f()}}),ne.observe(Ze.current)),ne}function at(){_.b.warn(decodeURIComponent(c))}var tt=function(){var ae=Ke.current.instance;if(p!=null&&ae&&Ie){var ye=ae.getModel();ye&&p!==ye.getValue()&&(b=!0,ye.setValue(p),ae.layout(),b=!1)}};Object(B.useEffect)(function(){Ae.current&&clearTimeout(Ae.current),Ae.current=setTimeout(function(){tt()},500)},[p,Ie,Ke.current]);function Ye(){var ne=Ke.current.instance;if(ne){var ae=ne.getSelection(),ye=Ke.current.pastePos||{},we=new l.Range(ye.startLineNumber||ae.endLineNumber,ye.startColumn||ae.endColumn,ye.endLineNumber||ae.endLineNumber,ye.endColumn||ae.endColumn);setTimeout(function(){ne.executeEdits("",[{range:we,text:""}])},300)}}function lt(ne){(window.navigator.platform.match("Mac")?ne.metaKey:ne.ctrlKey)&&ne.keyCode==83&&(ne.preventDefault(),q())}var et=function(){if(ue&&Ke.current.instance){var ae=Ke.current.instance.getContentHeight();ee(ae<y?y:ae)}else ee(y)};function Qe(ne){var ae=document.createEvent("MouseEvents");ae.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),ne.dispatchEvent(ae)}function Le(ne,ae){var ye=window.URL||window.webkitURL||window,we=new Blob([ae]),je=document.createElementNS("http://www.w3.org/1999/xhtml","a");je.href=ye.createObjectURL(we),je.download=ne,Qe(je)}Object(B.useEffect)(function(){et()},[et]),Object(B.useEffect)(function(){Ze.current&&!Ie&&te.e(27).then(te.t.bind(null,"M/lh",7)).then(function(ne){try{l=ne,Ke.current.instance=l.editor.create(Ze.current,{value:p,language:a(o),theme:K,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},G);var ae=Ke.current.instance;if(Ce(ae,l),setTimeout(function(){et(),Ke.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){Le(Je||"educoder.txt",ae.getValue())}})},500),Ke.current.subscription=ae.onDidChangeModelContent(function(we){ke.current?clearTimeout(He.current):(et(),Se(ae.getValue(),we)),He.current=setTimeout(function(){ke.current=!1},500)}),window.Monaco||f(l),_e&&(ae.addCommand(l.KeyMod.CtrlCmd|l.KeyMod.Shift|l.KeyCode.KEY_V,function(){return at(),null}),ae.addCommand(l.KeyMod.CtrlCmd|l.KeyCode.KEY_C,function(){return at(),null})),window.Monaco=l,j&&ae.onDidBlurEditorWidget(function(){j(ae.getValue())}),se&&ae.onDidFocusEditorText(function(){se(ae.getValue())}),_e){ae.addCommand(l.KeyMod.CtrlCmd|l.KeyCode.KEY_V,function(){return at(),null}),ae.onDidPaste(function(we){Ke.current.pastePos=we});try{window.addEventListener("paste",Ye)}catch(we){}}var ye=ht();return Fe(!0),function(){var we=Ke.current.instance;we.dispose();var je=we.getModel();je&&je.dispose(),Ke.current.subscription&&Ke.current.subscription.dispose(),_e&&window.removeEventListener("paste",Ye),ye.unobserve(Ze.current)}}catch(we){}})},[]),Object(B.useEffect)(function(){var ne=Ke.current.instance;if(ne&&Ie)return document.addEventListener("keydown",lt,!1),function(){document.removeEventListener("keydown",lt)}},[q,Ie]),Object(B.useEffect)(function(){var ne=Ke.current.instance;if(ne&&Ie){var ae=a(o);l.editor.setModelLanguage(ne.getModel(),ae),console.log("language:",o,ne.getModel(),ae)}},[o,Ie]),Object(B.useEffect)(function(){var ne=Ke.current.instance;ne&&Ie&&l.editor.setTheme(K)},[K,Ie]),Object(B.useEffect)(function(){var ne=Ke.current.instance;ne&&Ie&&(ne.updateOptions(Object(ie.a)({},M)),setTimeout(function(){ne.getModel().updateOptions(Object(ie.a)({},M))},200))},[JSON.stringify(M),Ie]),Object(B.useEffect)(function(){var ne=Ke.current.instance;ne&&Ie&&ne.layout()},[D,y,Ie]);var st=Object(B.useState)(T(D)),rt=Object(I.a)(st,2),De=rt[0],Ne=rt[1],me=Object(B.useState)(T(y)),de=Object(I.a)(me,2),fe=de[0],ee=de[1],re=Object(ie.a)(Object(ie.a)({},S),{},{width:De,height:fe});return N.a.createElement("div",{className:"my-monaco-editor",ref:Ze,style:re})};function A(m){var E=m.width,D=E===void 0?"100%":E,w=m.height,y=w===void 0?"100%":w,p=m.original,d=m.modified,o=m.language,C=m.options,S=C===void 0?{}:C,x=Object(B.useRef)(),M=Object(B.useState)(null),F=Object(I.a)(M,2),G=F[0],J=F[1];function K(ue){var ge;return x.current&&(ge=new O.default(function(_e){var be=Object(V.a)(_e),Se;try{for(be.s();!(Se=be.n()).done;){var Te=Se.value;(Te.target.offsetHeight>0||Te.target.offsetWidth>0)&&ue.layout()}}catch(Ce){be.e(Ce)}finally{be.f()}}),ge.observe(x.current)),ge}Object(B.useEffect)(function(){x.current&&te.e(27).then(te.t.bind(null,"M/lh",7)).then(function(ue){l=ue;var ge=l.editor.createDiffEditor(x.current,Object(ie.a)(Object(ie.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},S),{},{wordWrap:!0}));J(ge);var _e=K(ge);return function(){ge.dispose();var be=ge.getModel();be&&be.dispose(),_e.unobserve(x.current)}})},[]),Object(B.useEffect)(function(){G&&G.setModel({original:l.editor.createModel(p,o),modified:l.editor.createModel(d,o)})},[p,d,o,G]);var j=T(D),q=T(y),oe={width:j,height:q};return N.a.createElement("div",{className:"my-diff-editor",ref:x,style:oe})}},ZpRC:function(dt,qe,te){"use strict";function ie(f){return typeof f=="object"&&f!=null&&f.nodeType===1}function Y(f,c){return(!c||f!=="hidden")&&f!=="visible"&&f!=="clip"}function _(f,c){if(f.clientHeight<f.scrollHeight||f.clientWidth<f.scrollWidth){var k=getComputedStyle(f,null);return Y(k.overflowY,c)||Y(k.overflowX,c)||function(T){var g=function(b){if(!b.ownerDocument||!b.ownerDocument.defaultView)return null;try{return b.ownerDocument.defaultView.frameElement}catch(u){return null}}(T);return!!g&&(g.clientHeight<T.scrollHeight||g.clientWidth<T.scrollWidth)}(f)}return!1}function V(f,c,k,T,g,b,u,a){return b<f&&u>c||b>f&&u<c?0:b<=f&&a<=k||u>=c&&a>=k?b-f-T:u>c&&a<k||b<f&&a>k?u-c+g:0}var I=function(f,c){var k=window,T=c.scrollMode,g=c.block,b=c.inline,u=c.boundary,a=c.skipOverflowHiddenElements,l=typeof u=="function"?u:function(He){return He!==u};if(!ie(f))throw new TypeError("Invalid target");for(var h=document.scrollingElement||document.documentElement,A=[],m=f;ie(m)&&l(m);){if((m=m.parentElement)===h){A.push(m);break}m!=null&&m===document.body&&_(m)&&!_(document.documentElement)||m!=null&&_(m,a)&&A.push(m)}for(var E=k.visualViewport?k.visualViewport.width:innerWidth,D=k.visualViewport?k.visualViewport.height:innerHeight,w=window.scrollX||pageXOffset,y=window.scrollY||pageYOffset,p=f.getBoundingClientRect(),d=p.height,o=p.width,C=p.top,S=p.right,x=p.bottom,M=p.left,F=g==="start"||g==="nearest"?C:g==="end"?x:C+d/2,G=b==="center"?M+o/2:b==="end"?S:M,J=[],K=0;K<A.length;K++){var j=A[K],q=j.getBoundingClientRect(),oe=q.height,ue=q.width,ge=q.top,_e=q.right,be=q.bottom,Se=q.left;if(T==="if-needed"&&C>=0&&M>=0&&x<=D&&S<=E&&C>=ge&&x<=be&&M>=Se&&S<=_e)return J;var Te=getComputedStyle(j),Ce=parseInt(Te.borderLeftWidth,10),pe=parseInt(Te.borderTopWidth,10),se=parseInt(Te.borderRightWidth,10),Re=parseInt(Te.borderBottomWidth,10),Je=0,Xe=0,Ze="offsetWidth"in j?j.offsetWidth-j.clientWidth-Ce-se:0,Ke="offsetHeight"in j?j.offsetHeight-j.clientHeight-pe-Re:0;if(h===j)Je=g==="start"?F:g==="end"?F-D:g==="nearest"?V(y,y+D,D,pe,Re,y+F,y+F+d,d):F-D/2,Xe=b==="start"?G:b==="center"?G-E/2:b==="end"?G-E:V(w,w+E,E,Ce,se,w+G,w+G+o,o),Je=Math.max(0,Je+y),Xe=Math.max(0,Xe+w);else{Je=g==="start"?F-ge-pe:g==="end"?F-be+Re+Ke:g==="nearest"?V(ge,be,oe,pe,Re+Ke,F,F+d,d):F-(ge+oe/2)+Ke/2,Xe=b==="start"?G-Se-Ce:b==="center"?G-(Se+ue/2)+Ze/2:b==="end"?G-_e+se+Ze:V(Se,_e,ue,Ce,se+Ze,G,G+o,o);var Ae=j.scrollLeft,ke=j.scrollTop;F+=ke-(Je=Math.max(0,Math.min(ke+Je,j.scrollHeight-oe+Ke))),G+=Ae-(Xe=Math.max(0,Math.min(Ae+Xe,j.scrollWidth-ue+Ze)))}J.push({el:j,top:Je,left:Xe})}return J};function P(f){return f===Object(f)&&Object.keys(f).length!==0}function B(f,c){c===void 0&&(c="auto");var k="scrollBehavior"in document.body.style;f.forEach(function(T){var g=T.el,b=T.top,u=T.left;g.scroll&&k?g.scroll({top:b,left:u,behavior:c}):(g.scrollTop=b,g.scrollLeft=u)})}function N(f){return f===!1?{block:"end",inline:"nearest"}:P(f)?f:{block:"start",inline:"nearest"}}function O(f,c){var k=!f.ownerDocument.documentElement.contains(f);if(P(c)&&typeof c.behavior=="function")return c.behavior(k?[]:I(f,c));if(k)return;var T=N(c);return B(I(f,T),T.behavior)}var R=qe.a=O},aRTE:function(dt,qe){dt.exports={L:1,M:0,Q:3,H:2}},bT9E:function(dt,qe,te){"use strict";te.d(qe,"a",function(){return Y});var ie=te("VTBJ");function Y(_,V){var I=Object(ie.a)({},_);return Array.isArray(V)&&V.forEach(function(P){delete I[P]}),I}},c5Ni:function(dt,qe,te){},dQei:function(dt,qe){for(var te={glog:function(Y){if(Y<1)throw new Error("glog("+Y+")");return te.LOG_TABLE[Y]},gexp:function(Y){for(;Y<0;)Y+=255;for(;Y>=256;)Y-=255;return te.EXP_TABLE[Y]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},ie=0;ie<8;ie++)te.EXP_TABLE[ie]=1<<ie;for(var ie=8;ie<256;ie++)te.EXP_TABLE[ie]=te.EXP_TABLE[ie-4]^te.EXP_TABLE[ie-5]^te.EXP_TABLE[ie-6]^te.EXP_TABLE[ie-8];for(var ie=0;ie<255;ie++)te.LOG_TABLE[te.EXP_TABLE[ie]]=ie;dt.exports=te},dWSS:function(dt,qe,te){var ie=te("dQei");function Y(_,V){if(_.length==null)throw new Error(_.length+"/"+V);for(var I=0;I<_.length&&_[I]==0;)I++;this.num=new Array(_.length-I+V);for(var P=0;P<_.length-I;P++)this.num[P]=_[P+I]}Y.prototype={get:function(_){return this.num[_]},getLength:function(){return this.num.length},multiply:function(_){for(var V=new Array(this.getLength()+_.getLength()-1),I=0;I<this.getLength();I++)for(var P=0;P<_.getLength();P++)V[I+P]^=ie.gexp(ie.glog(this.get(I))+ie.glog(_.get(P)));return new Y(V,0)},mod:function(_){if(this.getLength()-_.getLength()<0)return this;for(var V=ie.glog(this.get(0))-ie.glog(_.get(0)),I=new Array(this.getLength()),P=0;P<this.getLength();P++)I[P]=this.get(P);for(var P=0;P<_.getLength();P++)I[P]^=ie.gexp(ie.glog(_.get(P))+V);return new Y(I,0).mod(_)}},dt.exports=Y},dejd:function(dt,qe,te){},dmUQ:function(dt,qe,te){"use strict";var ie=te("Ff2n"),Y=te("rePB"),_=te("1OyB"),V=te("vuIU"),I=te("Ji7U"),P=te("md7G"),B=te("foSv"),N=te("q1tI"),O=te.n(N),R=te("TSYQ"),f=te.n(R),c=te("4IlW");function k(d,o){var C=Object.keys(d);if(Object.getOwnPropertySymbols){var S=Object.getOwnPropertySymbols(d);o&&(S=S.filter(function(x){return Object.getOwnPropertyDescriptor(d,x).enumerable})),C.push.apply(C,S)}return C}function T(d){for(var o=1;o<arguments.length;o++){var C=arguments[o]!=null?arguments[o]:{};o%2?k(Object(C),!0).forEach(function(S){Object(Y.a)(d,S,C[S])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(C)):k(Object(C)).forEach(function(S){Object.defineProperty(d,S,Object.getOwnPropertyDescriptor(C,S))})}return d}function g(d){var o=b();return function(){var S=Object(B.a)(d),x;if(o){var M=Object(B.a)(this).constructor;x=Reflect.construct(S,arguments,M)}else x=S.apply(this,arguments);return Object(P.a)(this,x)}}function b(){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 a(d){d.preventDefault()}var l=function(o){return o.replace(/[^\w.-]+/g,"")},h=200,A=600,m=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,E=function(o){return o!=null},D=function(o,C){return C===o||typeof C=="number"&&typeof o=="number"&&isNaN(C)&&isNaN(o)},w=function(d){Object(I.a)(C,d);var o=g(C);function C(S){var x;Object(_.a)(this,C),x=o.call(this,S),x.onKeyDown=function(G){var J=x.props,K=J.onKeyDown,j=J.onPressEnter;if(G.keyCode===c.a.UP){var q=x.getRatio(G);x.up(G,q,null),x.stop()}else if(G.keyCode===c.a.DOWN){var oe=x.getRatio(G);x.down(G,oe,null),x.stop()}else G.keyCode===c.a.ENTER&&j&&j(G);if(x.recordCursorPosition(),x.lastKeyCode=G.keyCode,K){for(var ue=arguments.length,ge=new Array(ue>1?ue-1:0),_e=1;_e<ue;_e++)ge[_e-1]=arguments[_e];K.apply(void 0,[G].concat(ge))}},x.onKeyUp=function(G){var J=x.props.onKeyUp;if(x.stop(),x.recordCursorPosition(),J){for(var K=arguments.length,j=new Array(K>1?K-1:0),q=1;q<K;q++)j[q-1]=arguments[q];J.apply(void 0,[G].concat(j))}},x.onChange=function(G){var J=x.props.onChange;x.state.focused&&(x.inputting=!0),x.rawInput=x.props.parser(x.getValueFromEvent(G)),x.setState({inputValue:x.rawInput}),J(x.toNumber(x.rawInput))},x.onMouseUp=function(){var G=x.props.onMouseUp;x.recordCursorPosition(),G&&G.apply(void 0,arguments)},x.onFocus=function(){var G;x.setState({focused:!0}),(G=x.props).onFocus.apply(G,arguments)},x.onBlur=function(){var G=x.props.onBlur;x.inputting=!1,x.setState({focused:!1});var J=x.getCurrentValidValue(x.state.inputValue),K=x.setValue(J,u);if(G){var j=x.input.value,q=x.getInputDisplayValue({focus:!1,value:K});x.input.value=q&&Number(q),G.apply(void 0,arguments),x.input.value=j}},x.getRatio=function(G){var J=1;return G.metaKey||G.ctrlKey?J=.1:G.shiftKey&&(J=10),J},x.getFullNum=function(G){return isNaN(G)?G:/e/i.test(String(G))?Number(G).toFixed(18).replace(/\.?0+$/,""):G},x.getPrecision=function(G){if(E(x.props.precision))return x.props.precision;var J=String(G);if(J.indexOf("e-")>=0)return parseInt(J.slice(J.indexOf("e-")+2),10);var K=0;return J.indexOf(".")>=0&&(K=J.length-J.indexOf(".")-1),K},x.getInputDisplayValue=function(G){var J=G||x.state,K=J.focused,j=J.inputValue,q=J.value,oe;K?oe=j:oe=x.toPrecisionAsStep(q),oe==null&&(oe="");var ue=x.formatWrapper(oe);return E(x.props.decimalSeparator)&&(ue=ue.toString().replace(".",x.props.decimalSeparator)),ue},x.recordCursorPosition=function(){try{x.cursorStart=x.input.selectionStart,x.cursorEnd=x.input.selectionEnd,x.currentValue=x.input.value,x.cursorBefore=x.input.value.substring(0,x.cursorStart),x.cursorAfter=x.input.value.substring(x.cursorEnd)}catch(G){}},x.restoreByAfter=function(G){if(G===void 0)return!1;var J=x.input.value,K=J.lastIndexOf(G);if(K===-1)return!1;var j=x.cursorBefore.length;return x.lastKeyCode===c.a.DELETE&&x.cursorBefore.charAt(j-1)===G[0]?(x.fixCaret(j,j),!0):K+G.length===J.length?(x.fixCaret(K,K),!0):!1},x.partRestoreByAfter=function(G){return G===void 0?!1:Array.prototype.some.call(G,function(J,K){var j=G.substring(K);return x.restoreByAfter(j)})},x.isNotCompleteNumber=function(G){return isNaN(G)||G===""||G===null||G&&G.toString().indexOf(".")===G.toString().length-1},x.stop=function(){x.autoStepTimer&&clearTimeout(x.autoStepTimer)},x.down=function(G,J,K){x.pressingUpOrDown=!0,x.step("down",G,J,K)},x.up=function(G,J,K){x.pressingUpOrDown=!0,x.step("up",G,J,K)},x.saveInput=function(G){x.input=G};var M=S.value;M===void 0&&(M=S.defaultValue),x.state={focused:S.autoFocus};var F=x.getValidValue(x.toNumber(M));return x.state=T(T({},x.state),{},{inputValue:x.toPrecisionAsStep(F),value:F}),x}return Object(V.a)(C,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(x){var M=this.props,F=M.value,G=M.onChange,J=M.max,K=M.min,j=this.state.focused;if(x){if(!D(x.value,F)||!D(x.max,J)||!D(x.min,K)){var q=j?F:this.getValidValue(F),oe;this.pressingUpOrDown?oe=q:this.inputting?oe=this.rawInput:oe=this.toPrecisionAsStep(q),this.setState({value:q,inputValue:oe})}var ue="value"in this.props?F:this.state.value;"max"in this.props&&x.max!==J&&typeof ue=="number"&&ue>J&&G&&G(J),"min"in this.props&&x.min!==K&&typeof ue=="number"&&ue<K&&G&&G(K)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var ge=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===c.a.BACKSPACE?ge=this.cursorStart-1:this.lastKeyCode===c.a.DELETE&&(ge=this.cursorStart):ge=this.input.value.length,this.fixCaret(ge,ge)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case c.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case c.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(_e){}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(x){var M=x;return M===""?M="":this.isNotCompleteNumber(parseFloat(M))?M=this.state.value:M=this.getValidValue(M),this.toNumber(M)}},{key:"getValueFromEvent",value:function(x){var M=x.target.value.trim().replace(/。/g,".");return E(this.props.decimalSeparator)&&(M=M.replace(this.props.decimalSeparator,".")),M}},{key:"getValidValue",value:function(x){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,F=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,G=parseFloat(x);return isNaN(G)?x:(G<M&&(G=M),G>F&&(G=F),G)}},{key:"setValue",value:function(x,M){var F=this.props.precision,G=this.isNotCompleteNumber(parseFloat(x))?null:parseFloat(x),J=this.state.value,K=J===void 0?null:J,j=this.state.inputValue,q=j===void 0?null:j,oe=typeof G=="number"?G.toFixed(F):"".concat(G),ue=G!==K||oe!=="".concat(q);return"value"in this.props?(q=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:q},M)):this.setState({value:G,inputValue:this.toPrecisionAsStep(x)},M),ue&&this.props.onChange(G),G}},{key:"getMaxPrecision",value:function(x){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,F=this.props,G=F.precision,J=F.step;if(E(G))return G;var K=this.getPrecision(M),j=this.getPrecision(J),q=this.getPrecision(x);return x?Math.max(q,K+j):K+j}},{key:"getPrecisionFactor",value:function(x){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,F=this.getMaxPrecision(x,M);return Math.pow(10,F)}},{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(x){return this.props.formatter?this.props.formatter(x):x}},{key:"toPrecisionAsStep",value:function(x){if(this.isNotCompleteNumber(x)||x==="")return x;var M=Math.abs(this.getMaxPrecision(x));return isNaN(M)?x.toString():Number(x).toFixed(M)}},{key:"toNumber",value:function(x){var M=this.props.precision,F=this.state.focused,G=x&&x.length>16&&F;return this.isNotCompleteNumber(x)||G?x:E(M)?Math.round(x*Math.pow(10,M))/Math.pow(10,M):Number(x)}},{key:"upStep",value:function(x,M){var F=this.props.step,G=this.getPrecisionFactor(x,M),J=Math.abs(this.getMaxPrecision(x,M)),K=((G*x+G*F*M)/G).toFixed(J);return this.toNumber(K)}},{key:"downStep",value:function(x,M){var F=this.props.step,G=this.getPrecisionFactor(x,M),J=Math.abs(this.getMaxPrecision(x,M)),K=((G*x-G*F*M)/G).toFixed(J);return this.toNumber(K)}},{key:"step",value:function(x,M){var F=this,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,J=arguments.length>3?arguments[3]:void 0;this.stop(),M&&(M.persist(),M.preventDefault());var K=this.props;if(K.disabled)return;var j=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(j))return;var q=this["".concat(x,"Step")](j,G),oe=q>K.max||q<K.min;if(q>K.max?q=K.max:q<K.min&&(q=K.min),this.setValue(q,null),this.setState({focused:!0},function(){F.pressingUpOrDown=!1}),oe)return;this.autoStepTimer=setTimeout(function(){F[x](M,G,!0)},J?h:A)}},{key:"fixCaret",value:function(x,M){if(x===void 0||M===void 0||!this.input||!this.input.value)return;try{var F=this.input.selectionStart,G=this.input.selectionEnd;(x!==F||M!==G)&&this.input.setSelectionRange(x,M)}catch(J){}}},{key:"render",value:function(){var x,M=this.props,F=M.prefixCls,G=M.disabled,J=M.readOnly,K=M.useTouch,j=M.autoComplete,q=M.upHandler,oe=M.downHandler,ue=M.className,ge=M.max,_e=M.min,be=M.style,Se=M.title,Te=M.onMouseEnter,Ce=M.onMouseLeave,pe=M.onMouseOver,se=M.onMouseOut,Re=M.required,Je=M.onClick,Xe=M.tabIndex,Ze=M.type,Ke=M.placeholder,Ae=M.id,ke=M.inputMode,He=M.pattern,$e=M.step,ze=M.maxLength,Ie=M.autoFocus,Fe=M.name,ht=M.onPaste,at=M.onInput,tt=Object(ie.a)(M,["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"]),Ye=this.state,lt=Ye.value,et=Ye.focused,Qe=f()(F,(x={},Object(Y.a)(x,ue,!!ue),Object(Y.a)(x,"".concat(F,"-disabled"),G),Object(Y.a)(x,"".concat(F,"-focused"),et),x)),Le={};Object.keys(tt).forEach(function(ae){(ae.substr(0,5)==="data-"||ae.substr(0,5)==="aria-"||ae==="role")&&(Le[ae]=tt[ae])});var st=!J&&!G,rt=this.getInputDisplayValue(null),De=(lt||lt===0)&&(isNaN(lt)||Number(lt)>=ge),Ne=(lt||lt===0)&&(isNaN(lt)||Number(lt)<=_e),me=De||G||J,de=Ne||G||J,fe=f()("".concat(F,"-handler"),"".concat(F,"-handler-up"),Object(Y.a)({},"".concat(F,"-handler-up-disabled"),me)),ee=f()("".concat(F,"-handler"),"".concat(F,"-handler-down"),Object(Y.a)({},"".concat(F,"-handler-down-disabled"),de)),re=K?{onTouchStart:me?u:this.up,onTouchEnd:this.stop}:{onMouseDown:me?u:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},ne=K?{onTouchStart:de?u:this.down,onTouchEnd:this.stop}:{onMouseDown:de?u:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return O.a.createElement("div",{className:Qe,style:be,title:Se,onMouseEnter:Te,onMouseLeave:Ce,onMouseOver:pe,onMouseOut:se,onFocus:function(){return null},onBlur:function(){return null}},O.a.createElement("div",{className:"".concat(F,"-handler-wrap")},O.a.createElement("span",Object.assign({unselectable:"on"},re,{role:"button","aria-label":"Increase Value","aria-disabled":me,className:fe}),q||O.a.createElement("span",{unselectable:"on",className:"".concat(F,"-handler-up-inner"),onClick:a})),O.a.createElement("span",Object.assign({unselectable:"on"},ne,{role:"button","aria-label":"Decrease Value","aria-disabled":de,className:ee}),oe||O.a.createElement("span",{unselectable:"on",className:"".concat(F,"-handler-down-inner"),onClick:a}))),O.a.createElement("div",{className:"".concat(F,"-input-wrap")},O.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":_e,"aria-valuemax":ge,"aria-valuenow":lt,required:Re,type:Ze,placeholder:Ke,onPaste:ht,onClick:Je,onMouseUp:this.onMouseUp,className:"".concat(F,"-input"),tabIndex:Xe,autoComplete:j,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:st?this.onKeyDown:u,onKeyUp:st?this.onKeyUp:u,autoFocus:Ie,maxLength:ze,readOnly:J,disabled:G,max:ge,min:_e,step:$e,name:Fe,title:Se,id:Ae,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(rt),pattern:He,inputMode:ke,onInput:at},Le))))}}]),C}(O.a.Component);w.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:m,min:-m,step:1,style:{},onChange:u,onKeyDown:u,onPressEnter:u,onFocus:u,onBlur:u,parser:l,required:!1,autoComplete:"off"};var y=w,p=qe.a=y},f4xo:function(dt,qe,te){var ie=te("nVVt");function Y(_){this.mode=ie.MODE_8BIT_BYTE,this.data=_}Y.prototype={getLength:function(_){return this.data.length},write:function(_){for(var V=0;V<this.data.length;V++)_.put(this.data.charCodeAt(V),8)}},dt.exports=Y},fB9n:function(dt,qe,te){"use strict";te.r(qe);var ie=te("14J3"),Y=te("BMrR"),_=te("jCWc"),V=te("kPKH"),I=te("k1fw"),P=te("9og8"),B=te("tJVT"),N=te("PpiC"),O=te("WmNS"),R=te.n(O),f=te("q1tI"),c=te.n(f),k=te("55Ip"),T=te("9kvl"),g=te("T2oS"),b=te("W9HT"),u=te("oBTY"),a=te("B9cy"),l=te("Ol7k"),h=te("lUTK"),A=te("BvKs"),m=te("Ty5D"),E=te("wd/R"),D=te.n(E),w=te("RotF"),y=te.n(w),p=te("m3rI"),d=te("9Bee"),o=te("SbmS"),C=te.n(o),S=A.a.SubMenu,x=l.a.Sider,M=l.a.Content,F=function(ke){var He=ke.messages,$e=ke.globalSetting,ze=ke.loading,Ie=ke.user,Fe=ke.dispatch,ht=Object(N.a)(ke,["messages","globalSetting","loading","user","dispatch"]),at=Object(m.i)(),tt=Object(m.h)(),Ye=Ie.userInfo,lt=Object(f.useState)(!1),et=Object(B.a)(lt,2),Qe=et[0],Le=et[1],st=Object(f.useState)({per_page:20,page:1}),rt=Object(B.a)(st,2),De=rt[0],Ne=rt[1],me=Object(f.useState)({per_page:20,page:1}),de=Object(B.a)(me,2),fe=de[0],ee=de[1],re=Object(f.useState)([]),ne=Object(B.a)(re,2),ae=ne[0],ye=ne[1];Object(f.useEffect)(function(){De.page=1,je()},[at.userId]);var we=function(xt){var Oe,ct;T.d.push("/messages/".concat(Ie==null||((Oe=Ie.userInfo)===null||Oe===void 0)?void 0:Oe.login,"/message_detail?target_ids=").concat(xt==null||((ct=xt.target)===null||ct===void 0)?void 0:ct.id))},je=function(){var ot=Object(P.a)(R.a.mark(function xt(){var Oe,ct;return R.a.wrap(function(Ge){for(;;)switch(Ge.prev=Ge.next){case 0:return Le(!1),Ge.next=3,Fe({type:"messages/getPrivateMessages",payload:Object(I.a)(Object(I.a)({},at),fe)});case 3:Oe=Ge.sent,Oe!=null&&Oe.private_messages&&(ye([].concat(Object(u.a)(ae),Object(u.a)(Oe.private_messages))),((ct=Oe.private_messages)===null||ct===void 0?void 0:ct.length)===20&&Le(!0));case 5:case"end":return Ge.stop()}},xt)}));return function(){return ot.apply(this,arguments)}}();return c.a.createElement("aside",{className:C.a.listRightMessage},c.a.createElement(y.a,{loadMore:function(){fe.page++,je()},hasMore:Qe,useWindow:!1},c.a.createElement(b.a,{spinning:ze["messages/getPrivateMessages"]},c.a.createElement("div",{className:"minH500"},ae==null?void 0:ae.map(function(ot,xt){var Oe,ct;return c.a.createElement("aside",{key:xt},c.a.createElement(Y.a,{onClick:function(){return we(ot)}},c.a.createElement(V.a,{flex:"58px"},c.a.createElement("img",{src:p.a.IMG_SERVER+"/images/"+(ot==null||((Oe=ot.target)===null||Oe===void 0)?void 0:Oe.image_url),alt:""})),c.a.createElement(V.a,{flex:"1"},c.a.createElement(Y.a,null,c.a.createElement(V.a,{span:24},c.a.createElement(Y.a,null,c.a.createElement(V.a,{flex:"1"},c.a.createElement("span",{className:C.a.userName},ot==null||((ct=ot.target)===null||ct===void 0)?void 0:ct.name)),c.a.createElement(V.a,null,c.a.createElement("span",{className:"ml15 c-grey-c"},D()(ot.send_time).fromNow())))),c.a.createElement(V.a,{span:24},c.a.createElement("div",{className:["mt15",C.a.content].join(" ")},c.a.createElement(d.a,{value:ot.content||""})))))))})))))},G=Object(T.a)(function(Ae){var ke=Ae.messages,He=Ae.loading,$e=Ae.user,ze=Ae.globalSetting;return{messages:ke,globalSetting:ze,user:$e,loading:He.effects}})(F),J=te("+L6B"),K=te("2/Rp"),j=te("miYZ"),q=te("tsqr"),oe=te("y8nQ"),ue=te("Vl3Y"),ge=te("kaH+"),_e=te("1vsH"),be=te("5WQS"),Se=te("Ot1p"),Te=te("dhSg"),Ce=A.a.SubMenu,pe=l.a.Sider,se=l.a.Content,Re=function(ke){var He=ke.messages,$e=ke.globalSetting,ze=ke.loading,Ie=ke.user,Fe=ke.dispatch,ht=Object(N.a)(ke,["messages","globalSetting","loading","user","dispatch"]),at=Object(m.i)(),tt=Object(m.h)(),Ye=tt.query,lt=Object(f.useState)({per_page:20,page:1}),et=Object(B.a)(lt,2),Qe=et[0],Le=et[1],st=Object(f.useState)([]),rt=Object(B.a)(st,2),De=rt[0],Ne=rt[1],me=Object(f.useState)(!1),de=Object(B.a)(me,2),fe=de[0],ee=de[1],re=Object(f.useState)(!1),ne=Object(B.a)(re,2),ae=ne[0],ye=ne[1],we=Object(f.useState)(""),je=Object(B.a)(we,2),ot=je[0],xt=je[1],Oe=Object(f.useRef)(),ct=ue.a.useForm(),ft=Object(B.a)(ct,1),Ge=ft[0],_t=Object(f.useState)([]),Ct=Object(B.a)(_t,2),Ut=Ct[0],Ft=Ct[1],Dt=Object(f.useState)(!0),sr=Object(B.a)(Dt,2),rr=sr[0],vt=sr[1];Object(f.useEffect)(function(){Qe.page=1,Lr()},[Ye.target_ids]);var Lr=function(){var Mt=Object(P.a)(R.a.mark(function er(){var jt,Lt;return R.a.wrap(function(ur){for(;;)switch(ur.prev=ur.next){case 0:return ee(!1),ur.next=3,Fe({type:"messages/getPrivateMessageDetails",payload:Object(I.a)(Object(I.a)({},at),{},{target_id:Ye==null?void 0:Ye.target_ids},Qe)});case 3:jt=ur.sent,jt!=null&&jt.messages&&(Ut=jt==null?void 0:jt.messages,((Lt=Ut)===null||Lt===void 0?void 0:Lt.length)===20&&setTimeout(function(){ee(!0),vt(!1)},500),Qe.page===1?Ne(Object(u.a)(jt==null?void 0:jt.messages.reverse())):Ne([].concat(Object(u.a)(De),Object(u.a)(jt==null?void 0:jt.messages.reverse()))));case 5:case"end":return ur.stop()}},er)}));return function(){return Mt.apply(this,arguments)}}();Object(f.useEffect)(function(){console.log("newData.length:",Qe,Ut.length,Ut),Qe.page===1&&rr&&(Oe.current.scrollTop=Oe.current.scrollHeight)},[De]),Object(f.useEffect)(function(){Oe.current.onclick=function(Mt){Mt.target.nodeName==="IMG"&&Mt.target.alt!==""&&Te.a.publish("preview-image",Mt.target.src)}},[]);var fr=function(){var Mt=Object(P.a)(R.a.mark(function er(jt,Lt){var mt;return R.a.wrap(function(_r){for(;;)switch(_r.prev=_r.next){case 0:return _r.next=2,Object(be.a)(Object(I.a)(Object(I.a)({},at),{},{id:jt.id}));case 2:mt=_r.sent,mt.status===0&&(De.splice(Lt,1),Ne(Object(u.a)(De)));case 5:case"end":return _r.stop()}},er)}));return function(jt,Lt){return Mt.apply(this,arguments)}}(),lr=function(){var Mt=Object(P.a)(R.a.mark(function er(){return R.a.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:if(!(ot==="")){Lt.next=3;break}return q.b.error("\u8BF7\u8F93\u5165\u60A8\u7684\u56DE\u590D"),Lt.abrupt("return",!1);case 3:return xt(""),ye(!0),Lt.next=8,Object(be.g)(Object(I.a)(Object(I.a)({},at),{},{content:ot,target_id:Ye==null?void 0:Ye.target_ids}));case 8:ye(!1),Qe.page=1,Ge.resetFields(),Lr();case 12:case"end":return Lt.stop()}},er)}));return function(){return Mt.apply(this,arguments)}}();return c.a.createElement("section",null,c.a.createElement("aside",{className:C.a.listMessage,ref:Oe},c.a.createElement(y.a,{isReverse:!0,loadMore:function(){Qe.page++,Lr()},hasMore:fe,useWindow:!1},!fe&&c.a.createElement("div",{className:"tc mt20 animated fadeIn"},c.a.createElement("span",{className:C.a.msgDate},"\u6CA1\u6709\u4FE1\u606F\u4E86\uFF5E\uFF5E")),c.a.createElement(b.a,{spinning:ze["messages/getPrivateMessageDetails"]},c.a.createElement("aside",{className:"minH500"},De==null?void 0:De.map(function(Mt,er){var jt;return c.a.createElement("aside",{key:er},c.a.createElement(Y.a,{justify:"center"},c.a.createElement(V.a,{flex:"1",className:"tc"},c.a.createElement("span",{className:C.a.msgDate},D()(Mt.send_time).format("YYYY-MM-DD")))),c.a.createElement(Y.a,{onClick:function(){return Object(_e.H)(Mt)}},c.a.createElement(V.a,{flex:"58px"},c.a.createElement("img",{src:p.a.IMG_SERVER+"/images/"+(Mt==null||((jt=Mt.sender)===null||jt===void 0)?void 0:jt.image_url),alt:""})),c.a.createElement(V.a,null,c.a.createElement("div",{className:C.a.msg},c.a.createElement(d.a,{value:Mt.content||""}),c.a.createElement("span",{onClick:function(){return fr(Mt,er)},className:["current",C.a.deleteMsg].join(" ")},"\u5220\u9664"))),c.a.createElement(V.a,null,c.a.createElement("span",{className:"c-grey-c ml10"},D()(Mt.send_time).format("HH:mm")))))}))))),c.a.createElement("aside",{className:"pl30 pr30 mb30 mt30"},c.a.createElement(ue.a,{form:Ge},c.a.createElement(ue.a.Item,{name:"content"},c.a.createElement(Se.a,{placeholder:"\u8BF7\u8F93\u5165\u4F60\u7684\u56DE\u590D",height:150,onChange:function(er){return xt(er)}})),c.a.createElement(Y.a,null,c.a.createElement(V.a,{flex:"1"},c.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")),c.a.createElement(V.a,null,c.a.createElement(K.a,{loading:ae,type:"primary",onClick:function(){return lr()}},"\u56DE\u590D"))))),c.a.createElement(ge.a,null))},Je=Object(T.a)(function(Ae){var ke=Ae.messages,He=Ae.loading,$e=Ae.user,ze=Ae.globalSetting;return{messages:ke,globalSetting:ze,user:$e,loading:He.effects}})(Re),Xe=te("30zm"),Ze=function(ke){var He,$e=ke.messages,ze=ke.globalSetting,Ie=ke.loading,Fe=ke.user,ht=ke.dispatch,at=Object(N.a)(ke,["messages","globalSetting","loading","user","dispatch"]),tt=at.match.params,Ye=at.location.query,lt=Fe.userInfo,et=$e.tidingsList,Qe=$e.privateMessageDetails,Le=Object(f.useState)({per_page:20,page:1}),st=Object(B.a)(Le,2),rt=st[0],De=st[1],Ne=Object(f.useState)({per_page:20,page:1}),me=Object(B.a)(Ne,2),de=me[0],fe=me[1],ee=Object(f.useState)([]),re=Object(B.a)(ee,2),ne=re[0],ae=re[1],ye=Object(f.useState)([]),we=Object(B.a)(ye,2),je=we[0],ot=we[1];Object(f.useEffect)(function(){rt.page=1},[tt.userId]);var xt=function(){var ct=Object(P.a)(R.a.mark(function ft(){var Ge;return R.a.wrap(function(Ct){for(;;)switch(Ct.prev=Ct.next){case 0:return Ct.next=2,ht({type:"messages/getPrivateMessageDetails",payload:Object(I.a)(Object(I.a)({},tt),{},{target_id:Ye==null?void 0:Ye.target_ids})});case 2:Ge=Ct.sent,Ge!=null&&Ge.messages&&ae(Ge.messages);case 4:case"end":return Ct.stop()}},ft)}));return function(){return ct.apply(this,arguments)}}(),Oe=function(){var ct=Object(P.a)(R.a.mark(function ft(){var Ge;return R.a.wrap(function(Ct){for(;;)switch(Ct.prev=Ct.next){case 0:return Ct.next=2,ht({type:"messages/getPrivateMessages",payload:Object(I.a)(Object(I.a)({},tt),de)});case 2:Ge=Ct.sent,Ge!=null&&Ge.private_messages&&ot(Ge.private_messages);case 4:case"end":return Ct.stop()}},ft)}));return function(){return ct.apply(this,arguments)}}();return c.a.createElement("section",{className:C.a.bg},c.a.createElement("section",{className:"edu-container mt20"},c.a.createElement(Y.a,{gutter:[20,20]},c.a.createElement(Xe.a,null),c.a.createElement(V.a,{flex:"1"},c.a.createElement("aside",{className:"bg-white"},c.a.createElement("aside",{className:["font16",C.a.topBar].join(" ")},c.a.createElement(Y.a,null,c.a.createElement(V.a,{flex:"30px",className:"tc"},c.a.createElement(k.a,{to:"/messages/".concat(tt.userId,"/private_messages"),className:"iconfont icon-zuojiantou c-black pl10"})),c.a.createElement(V.a,{flex:"1",className:"tc"},Qe==null||((He=Qe.target)===null||He===void 0)?void 0:He.name,"\u4E0E\u4F60\u7684\u79C1\u4FE1"),c.a.createElement(V.a,{flex:"290px",className:"tl"},c.a.createElement("span",{className:"pl30"},"\u79C1\u4FE1\u5217\u8868")))),c.a.createElement(Y.a,null,c.a.createElement(V.a,{flex:"1"},c.a.createElement(Je,null)),c.a.createElement(V.a,{flex:"290px"},c.a.createElement(G,null))))))))},Ke=qe.default=Object(T.a)(function(Ae){var ke=Ae.messages,He=Ae.loading,$e=Ae.user,ze=Ae.globalSetting;return{messages:ke,globalSetting:ze,user:$e,loading:He.effects}})(Ze)},kSUc:function(dt,qe,te){},"kaH+":function(dt,qe,te){"use strict";var ie=te("+L6B"),Y=te("2/Rp"),_=te("tJVT"),V=te("q1tI"),I=te.n(V),P=te("UZu5"),B=te.n(P),N=te("dhSg"),O=te("rLCj"),R=te("dF/Y"),f=te("4i/N");qe.a=function(){var c=Object(V.useState)(""),k=Object(_.a)(c,2),T=k[0],g=k[1],b=Object(V.useState)(0),u=Object(_.a)(b,2),a=u[0],l=u[1],h=Object(V.useRef)("");Object(V.useEffect)(function(){var D=N.a.subscribe("preview-image",function(w){g(w),document.body.style.overflow="hidden"});return D},[]),Object(V.useEffect)(function(){return document.addEventListener("keydown",A),function(){document.removeEventListener("keydown",A)}},[]),Object(V.useEffect)(function(){h.current=T},[T]);function A(D){D.keyCode==27&&h.current&&m()}function m(){document.body.style.overflow="auto",g("")}function E(){l(a+90)}return I.a.createElement(V.Fragment,null,T?I.a.createElement("div",{className:"image-preview-container"},I.a.createElement("div",{className:"button-group"},I.a.createElement(Y.a,{onClick:E},"\u65CB\u8F6C",I.a.createElement(O.a,null)),I.a.createElement(Y.a,{href:T},"\u4E0B\u8F7D",I.a.createElement(R.a,null)),I.a.createElement(Y.a,{onClick:m},"\u5173\u95ED",I.a.createElement(f.a,null))),I.a.createElement("div",{className:"preview-wrp-group"},I.a.createElement("img",{className:"image-preview",src:T,alt:"\u9884\u89C8\u5927\u56FE",style:{transform:"rotate(".concat(a,"deg)")}}))):null)}},kzJb:function(dt,qe,te){dt.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(dt,qe,te){(function(ie){ie(te("VrN/"),te("1eCo"),te("8EBN"))})(function(ie){"use strict";ie.defineMode("markdown",function(Y,_){var V=ie.getMode(Y,"text/html"),I=V.name=="null";function P(K){if(ie.findModeByName){var j=ie.findModeByName(K);j&&(K=j.mime||j.mimes[0])}var q=ie.getMode(Y,K);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 B={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 N in B)B.hasOwnProperty(N)&&_.tokenTypeOverrides[N]&&(B[N]=_.tokenTypeOverrides[N]);var O=/^([*\-_])(?:\s*\1){2,}\s*$/,R=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,f=/^\[(x| )\](?=\s)/i,c=_.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,k=/^ {0,3}(?:\={1,}|-{2,})\s*$/,T=/^[^#!\[\]*_\\<>` "'(~:]+/,g=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,b=/^\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]/,a=" ";function l(K,j,q){return j.f=j.inline=q,q(K,j)}function h(K,j,q){return j.f=j.block=q,q(K,j)}function A(K){return!K||!/\S/.test(K.string)}function m(K){if(K.linkTitle=!1,K.linkHref=!1,K.linkText=!1,K.em=!1,K.strong=!1,K.strikethrough=!1,K.quote=0,K.indentedCode=!1,K.f==D){var j=I;if(!j){var q=ie.innerMode(V,K.htmlState);j=q.mode.name=="xml"&&q.state.tagStart===null&&!q.state.context&&q.state.tokenize.isInText}j&&(K.f=d,K.block=E,K.htmlState=null)}return K.trailingSpace=0,K.trailingSpaceNewLine=!1,K.prevLine=K.thisLine,K.thisLine={stream:null},null}function E(K,j){var q=K.column()===j.indentation,oe=A(j.prevLine.stream),ue=j.indentedCode,ge=j.prevLine.hr,_e=j.list!==!1,be=(j.listStack[j.listStack.length-1]||0)+3;j.indentedCode=!1;var Se=j.indentation;if(j.indentationDiff===null&&(j.indentationDiff=j.indentation,_e)){for(j.list=null;Se<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=Se-j.listStack[j.listStack.length-1])}var Te=!oe&&!ge&&!j.prevLine.header&&(!_e||!ue)&&!j.prevLine.fencedCodeEnd,Ce=(j.list===!1||ge||oe)&&j.indentation<=be&&K.match(O),pe=null;if(j.indentationDiff>=4&&(ue||j.prevLine.fencedCodeEnd||j.prevLine.header||oe))return K.skipToEnd(),j.indentedCode=!0,B.code;if(K.eatSpace())return null;if(q&&j.indentation<=be&&(pe=K.match(c))&&pe[1].length<=6)return j.quote=0,j.header=pe[1].length,j.thisLine.header=!0,_.highlightFormatting&&(j.formatting="header"),j.f=j.inline,y(j);if(j.indentation<=be&&K.eat(">"))return j.quote=q?1:j.quote+1,_.highlightFormatting&&(j.formatting="quote"),K.eatSpace(),y(j);if(!Ce&&!j.setext&&q&&j.indentation<=be&&(pe=K.match(R))){var se=pe[1]?"ol":"ul";return j.indentation=Se+K.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&&K.match(f,!1)&&(j.taskList=!0),j.f=j.inline,_.highlightFormatting&&(j.formatting=["list","list-"+se]),y(j)}else{if(q&&j.indentation<=be&&(pe=K.match(g,!0)))return j.quote=0,j.fencedEndRE=new RegExp(pe[1]+"+ *$"),j.localMode=_.fencedCodeBlockHighlighting&&P(pe[2]||_.fencedCodeBlockDefaultMode),j.localMode&&(j.localState=ie.startState(j.localMode)),j.f=j.block=w,_.highlightFormatting&&(j.formatting="code-block"),j.code=-1,y(j);if(j.setext||(!Te||!_e)&&!j.quote&&j.list===!1&&!j.code&&!Ce&&!b.test(K.string)&&(pe=K.lookAhead(1))&&(pe=pe.match(k)))return j.setext?(j.header=j.setext,j.setext=0,K.skipToEnd(),_.highlightFormatting&&(j.formatting="header")):(j.header=pe[0].charAt(0)=="="?1:2,j.setext=j.header),j.thisLine.header=!0,j.f=j.inline,y(j);if(Ce)return K.skipToEnd(),j.hr=!0,j.thisLine.hr=!0,B.hr;if(K.peek()==="[")return l(K,j,M)}return l(K,j,j.inline)}function D(K,j){var q=V.token(K,j.htmlState);if(!I){var oe=ie.innerMode(V,j.htmlState);(oe.mode.name=="xml"&&oe.state.tagStart===null&&!oe.state.context&&oe.state.tokenize.isInText||j.md_inside&&K.current().indexOf(">")>-1)&&(j.f=d,j.block=E,j.htmlState=null)}return q}function w(K,j){var q=j.listStack[j.listStack.length-1]||0,oe=j.indentation<q,ue=q+3;if(j.fencedEndRE&&j.indentation<=ue&&(oe||K.match(j.fencedEndRE))){_.highlightFormatting&&(j.formatting="code-block");var ge;return oe||(ge=y(j)),j.localMode=j.localState=null,j.block=E,j.f=d,j.fencedEndRE=null,j.code=0,j.thisLine.fencedCodeEnd=!0,oe?h(K,j,j.block):ge}else return j.localMode?j.localMode.token(K,j.localState):(K.skipToEnd(),B.code)}function y(K){var j=[];if(K.formatting){j.push(B.formatting),typeof K.formatting=="string"&&(K.formatting=[K.formatting]);for(var q=0;q<K.formatting.length;q++)j.push(B.formatting+"-"+K.formatting[q]),K.formatting[q]==="header"&&j.push(B.formatting+"-"+K.formatting[q]+"-"+K.header),K.formatting[q]==="quote"&&(!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=K.quote?j.push(B.formatting+"-"+K.formatting[q]+"-"+K.quote):j.push("error"))}if(K.taskOpen)return j.push("meta"),j.length?j.join(" "):null;if(K.taskClosed)return j.push("property"),j.length?j.join(" "):null;if(K.linkHref?j.push(B.linkHref,"url"):(K.strong&&j.push(B.strong),K.em&&j.push(B.em),K.strikethrough&&j.push(B.strikethrough),K.emoji&&j.push(B.emoji),K.linkText&&j.push(B.linkText),K.code&&j.push(B.code),K.image&&j.push(B.image),K.imageAltText&&j.push(B.imageAltText,"link"),K.imageMarker&&j.push(B.imageMarker)),K.header&&j.push(B.header,B.header+"-"+K.header),K.quote&&(j.push(B.quote),!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=K.quote?j.push(B.quote+"-"+K.quote):j.push(B.quote+"-"+_.maxBlockquoteDepth)),K.list!==!1){var oe=(K.listStack.length-1)%3;oe?oe===1?j.push(B.list2):j.push(B.list3):j.push(B.list1)}return K.trailingSpaceNewLine?j.push("trailing-space-new-line"):K.trailingSpace&&j.push("trailing-space-"+(K.trailingSpace%2?"a":"b")),j.length?j.join(" "):null}function p(K,j){return K.match(T,!0)?y(j):void 0}function d(K,j){var q=j.text(K,j);if(typeof q!="undefined")return q;if(j.list)return j.list=null,y(j);if(j.taskList){var oe=K.match(f,!0)[1]===" ";return oe?j.taskOpen=!0:j.taskClosed=!0,_.highlightFormatting&&(j.formatting="task"),j.taskList=!1,y(j)}if(j.taskOpen=!1,j.taskClosed=!1,j.header&&K.match(/^#+$/,!0))return _.highlightFormatting&&(j.formatting="header"),y(j);var ue=K.next();if(j.linkTitle){j.linkTitle=!1;var ge=ue;ue==="("&&(ge=")"),ge=(ge+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var _e="^\\s*(?:[^"+ge+"\\\\]+|\\\\\\\\|\\\\.)"+ge;if(K.match(new RegExp(_e),!0))return B.linkHref}if(ue==="`"){var be=j.formatting;_.highlightFormatting&&(j.formatting="code"),K.eatWhile("`");var Se=K.current().length;if(j.code==0&&(!j.quote||Se==1))return j.code=Se,y(j);if(Se==j.code){var Te=y(j);return j.code=0,Te}else return j.formatting=be,y(j)}else if(j.code)return y(j);if(ue==="\\"&&(K.next(),_.highlightFormatting)){var Ce=y(j),pe=B.formatting+"-escape";return Ce?Ce+" "+pe:pe}if(ue==="!"&&K.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return j.imageMarker=!0,j.image=!0,_.highlightFormatting&&(j.formatting="image"),y(j);if(ue==="["&&j.imageMarker&&K.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return j.imageMarker=!1,j.imageAltText=!0,_.highlightFormatting&&(j.formatting="image"),y(j);if(ue==="]"&&j.imageAltText){_.highlightFormatting&&(j.formatting="image");var Ce=y(j);return j.imageAltText=!1,j.image=!1,j.inline=j.f=C,Ce}if(ue==="["&&!j.image)return j.linkText&&K.match(/^.*?\]/)||(j.linkText=!0,_.highlightFormatting&&(j.formatting="link")),y(j);if(ue==="]"&&j.linkText){_.highlightFormatting&&(j.formatting="link");var Ce=y(j);return j.linkText=!1,j.inline=j.f=K.match(/\(.*?\)| ?\[.*?\]/,!1)?C:d,Ce}if(ue==="<"&&K.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=o,_.highlightFormatting&&(j.formatting="link");var Ce=y(j);return Ce?Ce+=" ":Ce="",Ce+B.linkInline}if(ue==="<"&&K.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=o,_.highlightFormatting&&(j.formatting="link");var Ce=y(j);return Ce?Ce+=" ":Ce="",Ce+B.linkEmail}if(_.xml&&ue==="<"&&K.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var se=K.string.indexOf(">",K.pos);if(se!=-1){var Re=K.string.substring(K.start,se);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(Re)&&(j.md_inside=!0)}return K.backUp(1),j.htmlState=ie.startState(V),h(K,j,D)}if(_.xml&&ue==="<"&&K.match(/^\/\w*?>/))return j.md_inside=!1,"tag";if(ue==="*"||ue==="_"){for(var Je=1,Xe=K.pos==1?" ":K.string.charAt(K.pos-2);Je<3&&K.eat(ue);)Je++;var Ze=K.peek()||" ",Ke=!/\s/.test(Ze)&&(!u.test(Ze)||/\s/.test(Xe)||u.test(Xe)),Ae=!/\s/.test(Xe)&&(!u.test(Xe)||/\s/.test(Ze)||u.test(Ze)),ke=null,He=null;if(Je%2&&(!j.em&&Ke&&(ue==="*"||!Ae||u.test(Xe))?ke=!0:j.em==ue&&Ae&&(ue==="*"||!Ke||u.test(Ze))&&(ke=!1)),Je>1&&(!j.strong&&Ke&&(ue==="*"||!Ae||u.test(Xe))?He=!0:j.strong==ue&&Ae&&(ue==="*"||!Ke||u.test(Ze))&&(He=!1)),He!=null||ke!=null){_.highlightFormatting&&(j.formatting=ke==null?"strong":He==null?"em":"strong em"),ke===!0&&(j.em=ue),He===!0&&(j.strong=ue);var Te=y(j);return ke===!1&&(j.em=!1),He===!1&&(j.strong=!1),Te}}else if(ue===" "&&(K.eat("*")||K.eat("_"))){if(K.peek()===" ")return y(j);K.backUp(1)}if(_.strikethrough){if(ue==="~"&&K.eatWhile(ue)){if(j.strikethrough){_.highlightFormatting&&(j.formatting="strikethrough");var Te=y(j);return j.strikethrough=!1,Te}else if(K.match(/^[^\s]/,!1))return j.strikethrough=!0,_.highlightFormatting&&(j.formatting="strikethrough"),y(j)}else if(ue===" "&&K.match(/^~~/,!0)){if(K.peek()===" ")return y(j);K.backUp(2)}}if(_.emoji&&ue===":"&&K.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){j.emoji=!0,_.highlightFormatting&&(j.formatting="emoji");var $e=y(j);return j.emoji=!1,$e}return ue===" "&&(K.match(/^ +$/,!1)?j.trailingSpace++:j.trailingSpace&&(j.trailingSpaceNewLine=!0)),y(j)}function o(K,j){var q=K.next();if(q===">"){j.f=j.inline=d,_.highlightFormatting&&(j.formatting="link");var oe=y(j);return oe?oe+=" ":oe="",oe+B.linkInline}return K.match(/^[^>]+/,!0),B.linkInline}function C(K,j){if(K.eatSpace())return null;var q=K.next();return q==="("||q==="["?(j.f=j.inline=x(q==="("?")":"]"),_.highlightFormatting&&(j.formatting="link-string"),j.linkHref=!0,y(j)):"error"}var S={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function x(K){return function(j,q){var oe=j.next();if(oe===K){q.f=q.inline=d,_.highlightFormatting&&(q.formatting="link-string");var ue=y(q);return q.linkHref=!1,ue}return j.match(S[K]),q.linkHref=!0,y(q)}}function M(K,j){return K.match(/^([^\]\\]|\\.)*\]:/,!1)?(j.f=F,K.next(),_.highlightFormatting&&(j.formatting="link"),j.linkText=!0,y(j)):l(K,j,d)}function F(K,j){if(K.match(/^\]:/,!0)){j.f=j.inline=G,_.highlightFormatting&&(j.formatting="link");var q=y(j);return j.linkText=!1,q}return K.match(/^([^\]\\]|\\.)+/,!0),B.linkText}function G(K,j){return K.eatSpace()?null:(K.match(/^[^\s]+/,!0),K.peek()===void 0?j.linkTitle=!0:K.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),j.f=j.inline=d,B.linkHref+" url")}var J={startState:function(){return{f:E,prevLine:{stream:null},thisLine:{stream:null},block:E,htmlState:null,indentation:0,inline:d,text:p,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(K){return{f:K.f,prevLine:K.prevLine,thisLine:K.thisLine,block:K.block,htmlState:K.htmlState&&ie.copyState(V,K.htmlState),indentation:K.indentation,localMode:K.localMode,localState:K.localMode?ie.copyState(K.localMode,K.localState):null,inline:K.inline,text:K.text,formatting:!1,linkText:K.linkText,linkTitle:K.linkTitle,linkHref:K.linkHref,code:K.code,em:K.em,strong:K.strong,strikethrough:K.strikethrough,emoji:K.emoji,header:K.header,setext:K.setext,hr:K.hr,taskList:K.taskList,list:K.list,listStack:K.listStack.slice(0),quote:K.quote,indentedCode:K.indentedCode,trailingSpace:K.trailingSpace,trailingSpaceNewLine:K.trailingSpaceNewLine,md_inside:K.md_inside,fencedEndRE:K.fencedEndRE}},token:function(K,j){if(j.formatting=!1,K!=j.thisLine.stream){if(j.header=0,j.hr=!1,K.match(/^\s*$/,!0))return m(j),null;if(j.prevLine=j.thisLine,j.thisLine={stream:K},j.taskList=!1,j.trailingSpace=0,j.trailingSpaceNewLine=!1,!j.localState&&(j.f=j.block,j.f!=D)){var q=K.match(/^\s*/,!0)[0].replace(/\t/g,a).length;if(j.indentation=q,j.indentationDiff=null,q>0)return null}}return j.f(K,j)},innerMode:function(K){return K.block==D?{state:K.htmlState,mode:V}:K.localState?{state:K.localState,mode:K.localMode}:{state:K,mode:J}},indent:function(K,j,q){return K.block==D&&V.indent?V.indent(K.htmlState,j,q):K.localState&&K.localMode.indent?K.localMode.indent(K.localState,j,q):ie.Pass},blankLine:m,getType:y,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return J},"xml"),ie.defineMIME("text/markdown","markdown"),ie.defineMIME("text/x-markdown","markdown")})},nVVt:function(dt,qe){dt.exports={MODE_NUMBER:1<<0,MODE_ALPHA_NUM:1<<1,MODE_8BIT_BYTE:1<<2,MODE_KANJI:1<<3}},osHv:function(dt,qe,te){(function(ie){ie(te("VrN/"))})(function(ie){"use strict";var Y=ie.Pos;function _(u,a){return u.line-a.line||u.ch-a.ch}var V="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",I=V+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",P=new RegExp("<(/?)(["+V+"]["+I+"]*)","g");function B(u,a,l,h){this.line=a,this.ch=l,this.cm=u,this.text=u.getLine(a),this.min=h?Math.max(h.from,u.firstLine()):u.firstLine(),this.max=h?Math.min(h.to-1,u.lastLine()):u.lastLine()}function N(u,a){var l=u.cm.getTokenTypeAt(Y(u.line,a));return l&&/\btag\b/.test(l)}function O(u){return u.line>=u.max?void 0:(u.ch=0,u.text=u.cm.getLine(++u.line),!0)}function R(u){return u.line<=u.min?void 0:(u.text=u.cm.getLine(--u.line),u.ch=u.text.length,!0)}function f(u){for(;;){var a=u.text.indexOf(">",u.ch);if(a==-1){if(O(u))continue;return}if(!N(u,a+1)){u.ch=a+1;continue}var l=u.text.lastIndexOf("/",a),h=l>-1&&!/\S/.test(u.text.slice(l+1,a));return u.ch=a+1,h?"selfClose":"regular"}}function c(u){for(;;){var a=u.ch?u.text.lastIndexOf("<",u.ch-1):-1;if(a==-1){if(R(u))continue;return}if(!N(u,a+1)){u.ch=a;continue}P.lastIndex=a,u.ch=a;var l=P.exec(u.text);if(l&&l.index==a)return l}}function k(u){for(;;){P.lastIndex=u.ch;var a=P.exec(u.text);if(!a){if(O(u))continue;return}if(!N(u,a.index+1)){u.ch=a.index+1;continue}return u.ch=a.index+a[0].length,a}}function T(u){for(;;){var a=u.ch?u.text.lastIndexOf(">",u.ch-1):-1;if(a==-1){if(R(u))continue;return}if(!N(u,a+1)){u.ch=a;continue}var l=u.text.lastIndexOf("/",a),h=l>-1&&!/\S/.test(u.text.slice(l+1,a));return u.ch=a+1,h?"selfClose":"regular"}}function g(u,a){for(var l=[];;){var h=k(u),A,m=u.line,E=u.ch-(h?h[0].length:0);if(!h||!(A=f(u)))return;if(A=="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&&(!a||a==h[2]))return{tag:h[2],from:Y(m,E),to:Y(u.line,u.ch)}}else l.push(h[2])}}function b(u,a){for(var l=[];;){var h=T(u);if(!h)return;if(h=="selfClose"){c(u);continue}var A=u.line,m=u.ch,E=c(u);if(!E)return;if(E[1])l.push(E[2]);else{for(var D=l.length-1;D>=0;--D)if(l[D]==E[2]){l.length=D;break}if(D<0&&(!a||a==E[2]))return{tag:E[2],from:Y(u.line,u.ch),to:Y(A,m)}}}}ie.registerHelper("fold","xml",function(u,a){for(var l=new B(u,a.line,0);;){var h=k(l);if(!h||l.line!=a.line)return;var A=f(l);if(!A)return;if(!h[1]&&A!="selfClose"){var m=Y(l.line,l.ch),E=g(l,h[2]);return E&&_(E.from,m)>0?{from:m,to:E.from}:null}}}),ie.findMatchingTag=function(u,a,l){var h=new B(u,a.line,a.ch,l);if(h.text.indexOf(">")==-1&&h.text.indexOf("<")==-1)return;var A=f(h),m=A&&Y(h.line,h.ch),E=A&&c(h);if(!A||!E||_(h,a)>0)return;var D={from:Y(h.line,h.ch),to:m,tag:E[2]};return A=="selfClose"?{open:D,close:null,at:"open"}:E[1]?{open:b(h,E[2]),close:D,at:"close"}:(h=new B(u,m.line,m.ch,l),{open:D,close:g(h,E[2]),at:"open"})},ie.findEnclosingTag=function(u,a,l,h){for(var A=new B(u,a.line,a.ch,l);;){var m=b(A,h);if(!m)break;var E=new B(u,a.line,a.ch,l),D=g(E,m.tag);if(D)return{open:m,close:D}}},ie.scanForClosingTag=function(u,a,l,h){var A=new B(u,a.line,a.ch,h?{from:0,to:h}:null);return g(A,l)}})},p5ED:function(dt,qe,te){"use strict";var ie=te("+L6B"),Y=te("2/Rp"),_=te("5Dmo"),V=te("3S7+"),I=te("k1fw"),P=te("tJVT"),B=te("q1tI"),N=te.n(B),O=te("vHTk"),R=te.n(O),f=te("yEEn"),c=te("ZW9T"),k=te("1vsH");qe.a=function(T){var g=T.name,b=T.data,u=T.theme,a=T.type,l=T.filename,h=T.monacoEditor,A=T.className,m=T.style,E=T.close,D=T.onClose,w=T.hasMask,y=Object(B.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),p=Object(P.a)(y,2),d=p[0],o=p[1],C=Object(B.useState)(""),S=Object(P.a)(C,2),x=S[0],M=S[1],F=Object(B.useRef)();l&&(h.filename=l),Object(B.useEffect)(function(){var K,j,q=(K=document.cookie)===null||K===void 0||((j=K.replace(/\s/g,""))===null||j===void 0)?void 0:j.split(";");q==null||q.map(function(oe){var ue=oe.split("=");ue[0]==="_educoder_session"&&M(ue[1])})},[]);var G=function(){if(b.startsWith("http")||b.startsWith("/")){J();return}Object(k.x)(l||"educoder",b,l)},J=function(){Object(k.v)(l||g,b)};return console.log("data:",b,"fileanme:",l," name:",g),N.a.createElement("div",{style:Object(I.a)({},m||{}),className:"".concat(w&&R.a.bgBlack," ").concat(a?R.a.wrp:"hide")},E&&N.a.createElement("div",{className:R.a.close,ref:F},N.a.createElement(V.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return F.current}},N.a.createElement("span",{onClick:J},N.a.createElement("i",{className:"icon-quxiaozhiding"}))),N.a.createElement(V.a,{title:"\u5173\u95ED",getPopupContainer:function(){return F.current}},N.a.createElement("span",{className:"",onClick:D},N.a.createElement("i",{className:"icon-guanbi1"})))),N.a.createElement("div",{className:"".concat(R.a[A]," ").concat(A," ").concat(R.a.monaco," ").concat(a==="txt"?"show":"hide")},a==="txt"&&N.a.createElement(c.b,h)),a==="audio"&&N.a.createElement("audio",{src:"".concat(b!=null&&b.startsWith("/")||(b==null?void 0:b.indexOf("https://"))>-1?b:"data:audio/mp3;base64,").concat(b),autoPlay:!0}),a==="video"&&N.a.createElement(N.a.Fragment,null,b!=null&&b.startsWith("/")?N.a.createElement("video",{controls:!0,src:"".concat(b),autoPlay:!0}):N.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(b),autoPlay:!0})),a==="html"&&N.a.createElement("iframe",{src:b+"&disposition=inline"}),a==="pdf"&&N.a.createElement("embed",{className:R.a.embed,src:b}),a==="image"&&N.a.createElement(N.a.Fragment,null,N.a.createElement("img",{src:"".concat(b!=null&&b.startsWith("/")||(b==null?void 0:b.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(b)})),a==="other"&&N.a.createElement("div",null,N.a.createElement(Y.a,{type:"primary",size:"large",onClick:G},N.a.createElement(f.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(a==="download"||a==="office")&&N.a.createElement(Y.a,{type:"primary",size:"large",onClick:G},N.a.createElement(f.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(dt,qe,te){},"rAM+":function(dt,qe,te){"use strict";te.d(qe,"a",function(){return Y});var ie=te("Qw5x");function Y(_,V){var I;if(typeof Symbol=="undefined"||_[Symbol.iterator]==null){if(Array.isArray(_)||(I=Object(ie.a)(_))||V&&_&&typeof _.length=="number"){I&&(_=I);var P=0,B=function(){};return{s:B,n:function(){return P>=_.length?{done:!0}:{done:!1,value:_[P++]}},e:function(c){throw c},f:B}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var N=!0,O=!1,R;return{s:function(){I=_[Symbol.iterator]()},n:function(){var c=I.next();return N=c.done,c},e:function(c){O=!0,R=c},f:function(){try{!N&&I.return!=null&&I.return()}finally{if(O)throw R}}}}},rUJ1:function(dt,qe){const te=/[&<>"']/,ie=/[&<>"']/g,Y=/[<>"']|&(?!#?\w+;)/,_=/[<>"']|&(?!#?\w+;)/g,V={"&":"&","<":"<",">":">",'"':""","'":"'"},I=w=>V[w];function P(w,y){if(y){if(te.test(w))return w.replace(ie,I)}else if(Y.test(w))return w.replace(_,I);return w}const B=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function N(w){return w.replace(B,(y,p)=>(p=p.toLowerCase(),p==="colon"?":":p.charAt(0)==="#"?p.charAt(1)==="x"?String.fromCharCode(parseInt(p.substring(2),16)):String.fromCharCode(+p.substring(1)):""))}const O=/(^|[^\[])\^/g;function R(w,y){w=w.source||w,y=y||"";const p={replace:(d,o)=>(o=o.source||o,o=o.replace(O,"$1"),w=w.replace(d,o),p),getRegex:()=>new RegExp(w,y)};return p}const f=/[^\w:]/g,c=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(w,y,p){if(w){let d;try{d=decodeURIComponent(N(p)).replace(f,"").toLowerCase()}catch(o){return null}if(d.indexOf("javascript:")===0||d.indexOf("vbscript:")===0||d.indexOf("data:")===0)return null}y&&!c.test(p)&&(p=a(y,p));try{p=encodeURI(p).replace(/%25/g,"%")}catch(d){return null}return p}const T={},g=/^[^:]+:\/*[^/]*$/,b=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(w,y){T[" "+w]||(g.test(w)?T[" "+w]=w+"/":T[" "+w]=m(w,"/",!0)),w=T[" "+w];const p=w.indexOf(":")===-1;return y.substring(0,2)==="//"?p?y:w.replace(b,"$1")+y:y.charAt(0)==="/"?p?y:w.replace(u,"$1")+y:w+y}const l={exec:function(){}};function h(w){let y=1,p,d;for(;y<arguments.length;y++){p=arguments[y];for(d in p)Object.prototype.hasOwnProperty.call(p,d)&&(w[d]=p[d])}return w}function A(w,y){const p=w.replace(/\|/g,(C,S,x)=>{let M=!1,F=S;for(;--F>=0&&x[F]==="\\";)M=!M;return M?"|":" |"}),d=p.split(/ \|/);let o=0;if(d.length>y)d.splice(y);else for(;d.length<y;)d.push("");for(;o<d.length;o++)d[o]=d[o].trim().replace(/\\\|/g,"|");return d}function m(w,y,p){const d=w.length;if(d===0)return"";let o=0;for(;o<d;){const C=w.charAt(d-o-1);if(C===y&&!p)o++;else if(C!==y&&p)o++;else break}return w.substr(0,d-o)}function E(w,y){if(w.indexOf(y[1])===-1)return-1;const p=w.length;let d=0,o=0;for(;o<p;o++)if(w[o]==="\\")o++;else if(w[o]===y[0])d++;else if(w[o]===y[1]&&(d--,d<0))return o;return-1}function D(w){w&&w.sanitize&&!w.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")}dt.exports={escape:P,unescape:N,edit:R,cleanUrl:k,resolveUrl:a,noopTest:l,merge:h,splitCells:A,rtrim:m,findClosingBracket:E,checkSanitizeDeprecation:D}},rcnY:function(dt,qe,te){var ie=te("aRTE");function Y(_,V){this.totalCount=_,this.dataCount=V}Y.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],Y.getRSBlocks=function(_,V){var I=Y.getRsBlockTable(_,V);if(I==null)throw new Error("bad rs block @ typeNumber:"+_+"/errorCorrectLevel:"+V);for(var P=I.length/3,B=new Array,N=0;N<P;N++)for(var O=I[N*3+0],R=I[N*3+1],f=I[N*3+2],c=0;c<O;c++)B.push(new Y(R,f));return B},Y.getRsBlockTable=function(_,V){switch(V){case ie.L:return Y.RS_BLOCK_TABLE[(_-1)*4+0];case ie.M:return Y.RS_BLOCK_TABLE[(_-1)*4+1];case ie.Q:return Y.RS_BLOCK_TABLE[(_-1)*4+2];case ie.H:return Y.RS_BLOCK_TABLE[(_-1)*4+3];default:return}},dt.exports=Y},ulZh:function(dt,qe,te){typeof window!="undefined"&&function(Y,_){dt.exports=_()}(this,function(){return function(ie){var Y={};function _(V){if(Y[V])return Y[V].exports;var I=Y[V]={i:V,l:!1,exports:{}};return ie[V].call(I.exports,I,I.exports,_),I.l=!0,I.exports}return _.m=ie,_.c=Y,_.d=function(V,I,P){_.o(V,I)||Object.defineProperty(V,I,{enumerable:!0,get:P})},_.r=function(V){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(V,"__esModule",{value:!0})},_.t=function(V,I){if(I&1&&(V=_(V)),I&8)return V;if(I&4&&typeof V=="object"&&V&&V.__esModule)return V;var P=Object.create(null);if(_.r(P),Object.defineProperty(P,"default",{enumerable:!0,value:V}),I&2&&typeof V!="string")for(var B in V)_.d(P,B,function(N){return V[N]}.bind(null,B));return P},_.n=function(V){var I=V&&V.__esModule?function(){return V.default}:function(){return V};return _.d(I,"a",I),I},_.o=function(V,I){return Object.prototype.hasOwnProperty.call(V,I)},_.p="/dist/",_(_.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(ie,Y,_){"use strict";var V=Object.prototype.hasOwnProperty,I="~";function P(){}Object.create&&(P.prototype=Object.create(null),new P().__proto__||(I=!1));function B(f,c,k){this.fn=f,this.context=c,this.once=k||!1}function N(f,c,k,T,g){if(typeof k!="function")throw new TypeError("The listener must be a function");var b=new B(k,T||f,g),u=I?I+c:c;return f._events[u]?f._events[u].fn?f._events[u]=[f._events[u],b]:f._events[u].push(b):(f._events[u]=b,f._eventsCount++),f}function O(f,c){--f._eventsCount===0?f._events=new P:delete f._events[c]}function R(){this._events=new P,this._eventsCount=0}R.prototype.eventNames=function(){var c=[],k,T;if(this._eventsCount===0)return c;for(T in k=this._events)V.call(k,T)&&c.push(I?T.slice(1):T);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(k)):c},R.prototype.listeners=function(c){var k=I?I+c:c,T=this._events[k];if(!T)return[];if(T.fn)return[T.fn];for(var g=0,b=T.length,u=new Array(b);g<b;g++)u[g]=T[g].fn;return u},R.prototype.listenerCount=function(c){var k=I?I+c:c,T=this._events[k];return T?T.fn?1:T.length:0},R.prototype.emit=function(c,k,T,g,b,u){var a=I?I+c:c;if(!this._events[a])return!1;var l=this._events[a],h=arguments.length,A,m;if(l.fn){l.once&&this.removeListener(c,l.fn,void 0,!0);switch(h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,k),!0;case 3:return l.fn.call(l.context,k,T),!0;case 4:return l.fn.call(l.context,k,T,g),!0;case 5:return l.fn.call(l.context,k,T,g,b),!0;case 6:return l.fn.call(l.context,k,T,g,b,u),!0}for(m=1,A=new Array(h-1);m<h;m++)A[m-1]=arguments[m];l.fn.apply(l.context,A)}else{var E=l.length,D;for(m=0;m<E;m++){l[m].once&&this.removeListener(c,l[m].fn,void 0,!0);switch(h){case 1:l[m].fn.call(l[m].context);break;case 2:l[m].fn.call(l[m].context,k);break;case 3:l[m].fn.call(l[m].context,k,T);break;case 4:l[m].fn.call(l[m].context,k,T,g);break;default:if(!A)for(D=1,A=new Array(h-1);D<h;D++)A[D-1]=arguments[D];l[m].fn.apply(l[m].context,A)}}}return!0},R.prototype.on=function(c,k,T){return N(this,c,k,T,!1)},R.prototype.once=function(c,k,T){return N(this,c,k,T,!0)},R.prototype.removeListener=function(c,k,T,g){var b=I?I+c:c;if(!this._events[b])return this;if(!k)return O(this,b),this;var u=this._events[b];if(u.fn)u.fn===k&&(!g||u.once)&&(!T||u.context===T)&&O(this,b);else{for(var a=0,l=[],h=u.length;a<h;a++)(u[a].fn!==k||g&&!u[a].once||T&&u[a].context!==T)&&l.push(u[a]);l.length?this._events[b]=l.length===1?l[0]:l:O(this,b)}return this},R.prototype.removeAllListeners=function(c){var k;return c?(k=I?I+c:c,this._events[k]&&O(this,k)):(this._events=new P,this._eventsCount=0),this},R.prototype.off=R.prototype.removeListener,R.prototype.addListener=R.prototype.on,R.prefixed=I,R.EventEmitter=R,ie.exports=R},"./node_modules/url-toolkit/src/url-toolkit.js":function(ie,Y,_){(function(V){var I=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,P=/^([^\/?#]*)([^]*)$/,B=/(?:\/|^)\.(?=\/)/g,N=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(R,f,c){if(c=c||{},R=R.trim(),f=f.trim(),!f){if(!c.alwaysNormalize)return R;var k=O.parseURL(R);if(!k)throw new Error("Error trying to parse base URL.");return k.path=O.normalizePath(k.path),O.buildURLFromParts(k)}var T=O.parseURL(f);if(!T)throw new Error("Error trying to parse relative URL.");if(T.scheme)return c.alwaysNormalize?(T.path=O.normalizePath(T.path),O.buildURLFromParts(T)):f;var g=O.parseURL(R);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var b=P.exec(g.path);g.netLoc=b[1],g.path=b[2]}g.netLoc&&!g.path&&(g.path="/");var u={scheme:g.scheme,netLoc:T.netLoc,path:null,params:T.params,query:T.query,fragment:T.fragment};if(!T.netLoc&&(u.netLoc=g.netLoc,T.path[0]!=="/"))if(!T.path)u.path=g.path,T.params||(u.params=g.params,T.query||(u.query=g.query));else{var a=g.path,l=a.substring(0,a.lastIndexOf("/")+1)+T.path;u.path=O.normalizePath(l)}return u.path===null&&(u.path=c.alwaysNormalize?O.normalizePath(T.path):T.path),O.buildURLFromParts(u)},parseURL:function(R){var f=I.exec(R);return f?{scheme:f[1]||"",netLoc:f[2]||"",path:f[3]||"",params:f[4]||"",query:f[5]||"",fragment:f[6]||""}:null},normalizePath:function(R){for(R=R.split("").reverse().join("").replace(B,"");R.length!==(R=R.replace(N,"")).length;);return R.split("").reverse().join("")},buildURLFromParts:function(R){return R.scheme+R.netLoc+R.path+R.params+R.query+R.fragment}};ie.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(ie,Y,_){function V(c){var k={};function T(b){if(k[b])return k[b].exports;var u=k[b]={i:b,l:!1,exports:{}};return c[b].call(u.exports,u,u.exports,T),u.l=!0,u.exports}T.m=c,T.c=k,T.i=function(b){return b},T.d=function(b,u,a){T.o(b,u)||Object.defineProperty(b,u,{configurable:!1,enumerable:!0,get:a})},T.r=function(b){Object.defineProperty(b,"__esModule",{value:!0})},T.n=function(b){var u=b&&b.__esModule?function(){return b.default}:function(){return b};return T.d(u,"a",u),u},T.o=function(b,u){return Object.prototype.hasOwnProperty.call(b,u)},T.p="/",T.oe=function(b){throw console.error(b),b};var g=T(T.s=ENTRY_MODULE);return g.default||g}var I="[\\.|\\-|\\+|\\w|/|@]+",P="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+I+").*?\\)";function B(c){return(c+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function N(c){return!isNaN(1*c)}function O(c,k,T){var g={};g[T]=[];var b=k.toString(),u=b.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return g;for(var a=u[1],l=new RegExp("(\\\\n|\\W)"+B(a)+P,"g"),h;h=l.exec(b);){if(h[3]==="dll-reference")continue;g[T].push(h[3])}for(l=new RegExp("\\("+B(a)+'\\("(dll-reference\\s('+I+'))"\\)\\)'+P,"g");h=l.exec(b);)c[h[2]]||(g[T].push(h[1]),c[h[2]]=_(h[1]).m),g[h[2]]=g[h[2]]||[],g[h[2]].push(h[4]);for(var A=Object.keys(g),m=0;m<A.length;m++)for(var E=0;E<g[A[m]].length;E++)N(g[A[m]][E])&&(g[A[m]][E]=1*g[A[m]][E]);return g}function R(c){var k=Object.keys(c);return k.reduce(function(T,g){return T||c[g].length>0},!1)}function f(c,k){for(var T={main:[k]},g={main:[]},b={main:{}};R(T);)for(var u=Object.keys(T),a=0;a<u.length;a++){var l=u[a],h=T[l],A=h.pop();if(b[l]=b[l]||{},b[l][A]||!c[l][A])continue;b[l][A]=!0,g[l]=g[l]||[],g[l].push(A);for(var m=O(c,c[l][A],l),E=Object.keys(m),D=0;D<E.length;D++)T[E[D]]=T[E[D]]||[],T[E[D]]=T[E[D]].concat(m[E[D]])}return g}ie.exports=function(c,k){k=k||{};var T={main:_.m},g=k.all?{main:Object.keys(T.main)}:f(T,c),b="";Object.keys(g).filter(function(A){return A!=="main"}).forEach(function(A){for(var m=0;g[A][m];)m++;g[A].push(m),T[A][m]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",b=b+"var "+A+" = ("+V.toString().replace("ENTRY_MODULE",JSON.stringify(m))+")({"+g[A].map(function(E){return""+JSON.stringify(E)+": "+T[A][E].toString()}).join(",")+`});
|
|
`}),b=b+"new (("+V.toString().replace("ENTRY_MODULE",JSON.stringify(c))+")({"+g.main.map(function(A){return""+JSON.stringify(A)+": "+T.main[A].toString()}).join(",")+"}))(self);";var u=new window.Blob([b],{type:"text/javascript"});if(k.bare)return u;var a=window.URL||window.webkitURL||window.mozURL||window.msURL,l=a.createObjectURL(u),h=new window.Worker(l);return h.objectURL=l,h}},"./src/config.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"hlsDefaultConfig",function(){return D}),_.d(Y,"mergeConfig",function(){return y}),_.d(Y,"enableStreamingMode",function(){return p});var V=_("./src/controller/abr-controller.ts"),I=_("./src/controller/audio-stream-controller.ts"),P=_("./src/controller/audio-track-controller.ts"),B=_("./src/controller/subtitle-stream-controller.ts"),N=_("./src/controller/subtitle-track-controller.ts"),O=_("./src/controller/buffer-controller.ts"),R=_("./src/controller/timeline-controller.ts"),f=_("./src/controller/cap-level-controller.ts"),c=_("./src/controller/fps-controller.ts"),k=_("./src/controller/eme-controller.ts"),T=_("./src/controller/cmcd-controller.ts"),g=_("./src/utils/xhr-loader.ts"),b=_("./src/utils/fetch-loader.ts"),u=_("./src/utils/cues.ts"),a=_("./src/utils/mediakeys-helper.ts"),l=_("./src/utils/logger.ts");function h(){return h=Object.assign||function(d){for(var o=1;o<arguments.length;o++){var C=arguments[o];for(var S in C)Object.prototype.hasOwnProperty.call(C,S)&&(d[S]=C[S])}return d},h.apply(this,arguments)}function A(d,o){var C=Object.keys(d);if(Object.getOwnPropertySymbols){var S=Object.getOwnPropertySymbols(d);o&&(S=S.filter(function(x){return Object.getOwnPropertyDescriptor(d,x).enumerable})),C.push.apply(C,S)}return C}function m(d){for(var o=1;o<arguments.length;o++){var C=arguments[o]!=null?arguments[o]:{};o%2?A(Object(C),!0).forEach(function(S){E(d,S,C[S])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(C)):A(Object(C)).forEach(function(S){Object.defineProperty(d,S,Object.getOwnPropertyDescriptor(C,S))})}return d}function E(d,o,C){return o in d?Object.defineProperty(d,o,{value:C,enumerable:!0,configurable:!0,writable:!0}):d[o]=C,d}var D=m(m({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:g.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:V.default,bufferController:O.default,capLevelController:f.default,fpsController:c.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:a.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},w()),{},{subtitleStreamController:B.SubtitleStreamController,subtitleTrackController:N.default,timelineController:R.TimelineController,audioStreamController:I.default,audioTrackController:P.default,emeController:k.default,cmcdController:T.default});function w(){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 y(d,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},d,o)}function p(d){var o=d.loader;if(o!==b.default&&o!==g.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var C=Object(b.fetchSupported)();C&&(d.loader=b.default,d.progressive=!0,d.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/polyfills/number.ts"),I=_("./src/utils/ewma-bandwidth-estimator.ts"),P=_("./src/events.ts"),B=_("./src/utils/buffer-helper.ts"),N=_("./src/errors.ts"),O=_("./src/types/loader.ts"),R=_("./src/utils/logger.ts");function f(T,g){for(var b=0;b<g.length;b++){var u=g[b];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(T,u.key,u)}}function c(T,g,b){return g&&f(T.prototype,g),b&&f(T,b),T}var k=function(){function T(b){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=b;var u=b.config;this.bwEstimator=new I.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var g=T.prototype;return g.registerListeners=function(){var u=this.hls;u.on(P.Events.FRAG_LOADING,this.onFragLoading,this),u.on(P.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(P.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var u=this.hls;u.off(P.Events.FRAG_LOADING,this.onFragLoading,this),u.off(P.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(P.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},g.onFragLoading=function(u,a){var l=a.frag;if(l.type===O.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=l,this.partCurrent=(h=a.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},g.onLevelLoaded=function(u,a){var l=this.hls.config;a.details.live?this.bwEstimator.update(l.abrEwmaSlowLive,l.abrEwmaFastLive):this.bwEstimator.update(l.abrEwmaSlowVoD,l.abrEwmaFastVoD)},g._abandonRulesCheck=function(){var u=this.fragCurrent,a=this.partCurrent,l=this.hls,h=l.autoLevelEnabled,A=l.config,m=l.media;if(!u||!m)return;var E=a?a.stats:u.stats,D=a?a.duration:u.duration;if(E.aborted){R.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!h||m.paused||!m.playbackRate||!m.readyState)return;var w=performance.now()-E.loading.start,y=Math.abs(m.playbackRate);if(w<=500*D/y)return;var p=l.levels,d=l.minAutoLevel,o=p[u.level],C=E.total||Math.max(E.loaded,Math.round(D*o.maxBitrate/8)),S=Math.max(1,E.bwEstimate?E.bwEstimate/8:E.loaded*1e3/w),x=(C-E.loaded)/S,M=m.currentTime,F=(B.BufferHelper.bufferInfo(m,M,A.maxBufferHole).end-M)/y;if(F>=2*D/y||x<=F)return;var G=Number.POSITIVE_INFINITY,J;for(J=u.level-1;J>d;J--){var K=p[J].maxBitrate;if(G=D*K/(8*.8*S),G<F)break}if(G>=x)return;var j=this.bwEstimator.getEstimate();R.logger.warn("Fragment "+u.sn+(a?" part "+a.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+J+`
|
|
Current BW estimate: `+(Object(V.isFiniteNumber)(j)?(j/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+x.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+G.toFixed(3)+` s
|
|
Time to underbuffer: `+F.toFixed(3)+" s"),l.nextLoadLevel=J,this.bwEstimator.sample(w,E.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),l.trigger(P.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:a,stats:E})},g.onFragLoaded=function(u,a){var l=a.frag,h=a.part;if(l.type===O.PlaylistLevelType.MAIN&&Object(V.isFiniteNumber)(l.sn)){var A=h?h.stats:l.stats,m=h?h.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var E=this.hls.levels[l.level],D=(E.loaded?E.loaded.bytes:0)+A.loaded,w=(E.loaded?E.loaded.duration:0)+m;E.loaded={bytes:D,duration:w},E.realBitrate=Math.round(8*D/w)}if(l.bitrateTest){var y={stats:A,frag:l,part:h,id:l.type};this.onFragBuffered(P.Events.FRAG_BUFFERED,y),l.bitrateTest=!1}}},g.onFragBuffered=function(u,a){var l=a.frag,h=a.part,A=h?h.stats:l.stats;if(A.aborted)return;if(l.type!==O.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var m=A.parsing.end-A.loading.start;this.bwEstimator.sample(m,A.loaded),A.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=m/1e3:this.bitrateTestDelay=0},g.onError=function(u,a){switch(a.details){case N.ErrorDetails.FRAG_LOAD_ERROR:case N.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},g.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},g.getNextABRAutoLevel=function(){var u=this.fragCurrent,a=this.partCurrent,l=this.hls,h=l.maxAutoLevel,A=l.config,m=l.minAutoLevel,E=l.media,D=a?a.duration:u?u.duration:0,w=E?E.currentTime:0,y=E&&E.playbackRate!==0?Math.abs(E.playbackRate):1,p=this.bwEstimator?this.bwEstimator.getEstimate():A.abrEwmaDefaultEstimate,d=(B.BufferHelper.bufferInfo(E,w,A.maxBufferHole).end-w)/y,o=this.findBestLevel(p,m,h,d,A.abrBandWidthFactor,A.abrBandWidthUpFactor);if(o>=0)return o;R.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var C=D?Math.min(D,A.maxStarvationDelay):A.maxStarvationDelay,S=A.abrBandWidthFactor,x=A.abrBandWidthUpFactor;if(!d){var M=this.bitrateTestDelay;if(M){var F=D?Math.min(D,A.maxLoadingDelay):A.maxLoadingDelay;C=F-M,R.logger.trace("bitrate test took "+Math.round(1e3*M)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*C)+" ms"),S=x=1}}return o=this.findBestLevel(p,m,h,d+C,S,x),Math.max(o,0)},g.findBestLevel=function(u,a,l,h,A,m){for(var E,D=this.fragCurrent,w=this.partCurrent,y=this.lastLoadedFragLevel,p=this.hls.levels,d=p[y],o=!!(d!=null&&(E=d.details)!==null&&E!==void 0&&E.live),C=d==null?void 0:d.codecSet,S=w?w.duration:D?D.duration:0,x=l;x>=a;x--){var M=p[x];if(!M||C&&M.codecSet!==C)continue;var F=M.details,G=(w?F==null?void 0:F.partTarget:F==null?void 0:F.averagetargetduration)||S,J=void 0;x<=y?J=A*u:J=m*u;var K=p[x].maxBitrate,j=K*G/J;if(R.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+x+"/"+Math.round(J)+"/"+K+"/"+G+"/"+h+"/"+j),J>K&&(!j||o&&!this.bitrateTestDelay||j<h))return x}return-1},c(T,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,a=this.bwEstimator;if(u!==-1&&(!a||!a.canEstimate()))return u;var l=this.getNextABRAutoLevel();return u!==-1&&(l=Math.min(u,l)),l},set:function(u){this._nextAutoLevel=u}}]),T}();Y.default=k},"./src/controller/audio-stream-controller.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/polyfills/number.ts"),I=_("./src/controller/base-stream-controller.ts"),P=_("./src/events.ts"),B=_("./src/utils/buffer-helper.ts"),N=_("./src/controller/fragment-tracker.ts"),O=_("./src/types/level.ts"),R=_("./src/types/loader.ts"),f=_("./src/loader/fragment.ts"),c=_("./src/demux/chunk-cache.ts"),k=_("./src/demux/transmuxer-interface.ts"),T=_("./src/types/transmuxer.ts"),g=_("./src/controller/fragment-finders.ts"),b=_("./src/utils/discontinuities.ts"),u=_("./src/errors.ts"),a=_("./src/utils/logger.ts");function l(){return l=Object.assign||function(D){for(var w=1;w<arguments.length;w++){var y=arguments[w];for(var p in y)Object.prototype.hasOwnProperty.call(y,p)&&(D[p]=y[p])}return D},l.apply(this,arguments)}function h(D,w){D.prototype=Object.create(w.prototype),D.prototype.constructor=D,A(D,w)}function A(D,w){return A=Object.setPrototypeOf||function(p,d){return p.__proto__=d,p},A(D,w)}var m=100,E=function(D){h(w,D);function w(p,d){var o;return o=D.call(this,p,d,"[audio-stream-controller]")||this,o.videoBuffer=null,o.videoTrackCC=-1,o.waitingVideoCC=-1,o.audioSwitch=!1,o.trackId=-1,o.waitingData=null,o.mainDetails=null,o.bufferFlushed=!1,o._registerListeners(),o}var y=w.prototype;return y.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},y._registerListeners=function(){var d=this.hls;d.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(P.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.on(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.on(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(P.Events.ERROR,this.onError,this),d.on(P.Events.BUFFER_RESET,this.onBufferReset,this),d.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this),d.on(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.on(P.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},y._unregisterListeners=function(){var d=this.hls;d.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(P.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.off(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.off(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(P.Events.ERROR,this.onError,this),d.off(P.Events.BUFFER_RESET,this.onBufferReset,this),d.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),d.off(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.off(P.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},y.onInitPtsFound=function(d,o){var C=o.frag,S=o.id,x=o.initPTS;if(S==="main"){var M=C.cc;this.initPTS[C.cc]=x,this.log("InitPTS for cc: "+M+" found from main: "+x),this.videoTrackCC=M,this.state===I.State.WAITING_INIT_PTS&&this.tick()}},y.startLoad=function(d){if(!this.levels){this.startPosition=d,this.state=I.State.STOPPED;return}var o=this.lastCurrentTime;this.stopLoad(),this.setInterval(m),this.fragLoadError=0,o>0&&d===-1?(this.log("Override startPosition with lastCurrentTime @"+o.toFixed(3)),this.state=I.State.IDLE):(this.loadedmetadata=!1,this.state=I.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=d,this.tick()},y.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_TRACK:{var d,o=this.levels,C=this.trackId,S=o==null||((d=o[C])===null||d===void 0)?void 0:d.details;if(S){if(this.waitForCdnTuneIn(S))break;this.state=I.State.WAITING_INIT_PTS}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var x,M=performance.now(),F=this.retryDate;(!F||M>=F||(x=this.media)!==null&&x!==void 0&&x.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=I.State.IDLE);break}case I.State.WAITING_INIT_PTS:{var G=this.waitingData;if(G){var J=G.frag,K=G.part,j=G.cache,q=G.complete;if(this.initPTS[J.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.FRAG_LOADING;var oe=j.flush(),ue={frag:J,part:K,payload:oe,networkDetails:null};this._handleFragmentLoadProgress(ue),q&&D.prototype._handleFragmentLoadComplete.call(this,ue)}else if(this.videoTrackCC!==this.waitingVideoCC)a.logger.log("Waiting fragment cc ("+J.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ge=this.getLoadPosition(),_e=B.BufferHelper.bufferInfo(this.mediaBuffer,ge,this.config.maxBufferHole),be=Object(g.fragmentWithinToleranceTest)(_e.end,this.config.maxFragLookUpTolerance,J);be<0&&(a.logger.log("Waiting fragment cc ("+J.cc+") @ "+J.start+" cancelled because another fragment at "+_e.end+" is needed"),this.clearWaitingFragment())}}else this.state=I.State.IDLE}}this.onTickEnd()},y.clearWaitingFragment=function(){var d=this.waitingData;d&&(this.fragmentTracker.removeFragment(d.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.IDLE)},y.onTickEnd=function(){var d=this.media;if(!d||!d.readyState)return;var o=this.mediaBuffer?this.mediaBuffer:d,C=o.buffered;!this.loadedmetadata&&C.length&&(this.loadedmetadata=!0),this.lastCurrentTime=d.currentTime},y.doTickIdle=function(){var d,o,C=this.hls,S=this.levels,x=this.media,M=this.trackId,F=C.config;if(!S||!S[M])return;if(!x&&(this.startFragRequested||!F.startFragPrefetch))return;var G=S[M],J=G.details;if(!J||J.live&&this.levelLastLoaded!==M||this.waitForCdnTuneIn(J)){this.state=I.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,f.ElementaryStreamTypes.AUDIO,R.PlaylistLevelType.AUDIO));var K=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,R.PlaylistLevelType.AUDIO);if(K===null)return;var j=K.len,q=this.getMaxBufferLength(),oe=this.audioSwitch;if(j>=q&&!oe)return;if(!oe&&this._streamEnded(K,J)){C.trigger(P.Events.BUFFER_EOS,{type:"audio"}),this.state=I.State.ENDED;return}var ue=J.fragments,ge=ue[0].start,_e=K.end;if(oe){var be=this.getLoadPosition();_e=be,J.PTSKnown&&be<ge&&((K.end>ge||K.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),x.currentTime=ge+.05))}var Se=this.getNextFragment(_e,J);if(!Se){this.bufferFlushed=!0;return}((d=Se.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((o=Se.decryptdata)!==null&&o!==void 0&&o.key)?this.loadKey(Se,J):this.loadFragment(Se,J,_e)},y.getMaxBufferLength=function(){var d=D.prototype.getMaxBufferLength.call(this),o=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,R.PlaylistLevelType.MAIN);return o===null?d:Math.max(d,o.len)},y.onMediaDetaching=function(){this.videoBuffer=null,D.prototype.onMediaDetaching.call(this)},y.onAudioTracksUpdated=function(d,o){var C=o.audioTracks;this.resetTransmuxer(),this.levels=C.map(function(S){return new O.Level(S)})},y.onAudioTrackSwitching=function(d,o){var C=!!o.url;this.trackId=o.id;var S=this.fragCurrent;S!=null&&S.loader&&S.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),C?this.setInterval(m):this.resetTransmuxer(),C?(this.audioSwitch=!0,this.state=I.State.IDLE):this.state=I.State.STOPPED,this.tick()},y.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},y.onLevelLoaded=function(d,o){this.mainDetails=o.details},y.onAudioTrackLoaded=function(d,o){var C,S=this.levels,x=o.details,M=o.id;if(!S){this.warn("Audio tracks were reset while loading level "+M);return}this.log("Track "+M+" loaded ["+x.startSN+","+x.endSN+"],duration:"+x.totalduration);var F=S[M],G=0;if(x.live||(C=F.details)!==null&&C!==void 0&&C.live){var J=this.mainDetails;if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed||!J)return;!F.details&&x.hasProgramDateTime&&J.hasProgramDateTime?(Object(b.alignMediaPlaylistByPDT)(x,J),G=x.fragments[0].start):G=this.alignPlaylists(x,F.details)}F.details=x,this.levelLastLoaded=M,!this.startFragRequested&&(this.mainDetails||!x.live)&&this.setStartPosition(F.details,G),this.state===I.State.WAITING_TRACK&&!this.waitForCdnTuneIn(x)&&(this.state=I.State.IDLE),this.tick()},y._handleFragmentLoadProgress=function(d){var o,C=d.frag,S=d.part,x=d.payload,M=this.config,F=this.trackId,G=this.levels;if(!G){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+C.sn+" of level "+C.level+" will not be buffered");return}var J=G[F];console.assert(J,"Audio track is defined on fragment load progress");var K=J.details;console.assert(K,"Audio track details are defined on fragment load progress");var j=M.defaultAudioCodec||J.audioCodec||"mp4a.40.2",q=this.transmuxer;q||(q=this.transmuxer=new k.default(this.hls,R.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var oe=this.initPTS[C.cc],ue=(o=C.initSegment)===null||o===void 0?void 0:o.data;if(oe!==void 0){var ge=!1,_e=S?S.index:-1,be=_e!==-1,Se=new T.ChunkMetadata(C.level,C.sn,C.stats.chunkCount,x.byteLength,_e,be);q.push(x,ue,j,"",C,S,K.totalduration,ge,Se,oe)}else{a.logger.log("Unknown video PTS for cc "+C.cc+", waiting for video PTS before demuxing audio frag "+C.sn+" of ["+K.startSN+" ,"+K.endSN+"],track "+F);var Te=this.waitingData=this.waitingData||{frag:C,part:S,cache:new c.default,complete:!1},Ce=Te.cache;Ce.push(new Uint8Array(x)),this.waitingVideoCC=this.videoTrackCC,this.state=I.State.WAITING_INIT_PTS}},y._handleFragmentLoadComplete=function(d){if(this.waitingData){this.waitingData.complete=!0;return}D.prototype._handleFragmentLoadComplete.call(this,d)},y.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},y.onBufferCreated=function(d,o){var C=o.tracks.audio;C&&(this.mediaBuffer=C.buffer),o.tracks.video&&(this.videoBuffer=o.tracks.video.buffer)},y.onFragBuffered=function(d,o){var C=o.frag,S=o.part;if(C.type!==R.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(C)){this.warn("Fragment "+C.sn+(S?" p: "+S.index:"")+" of level "+C.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}C.sn!=="initSegment"&&(this.fragPrevious=C,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(C,S)},y.onError=function(d,o){switch(o.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(R.PlaylistLevelType.AUDIO,o);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==I.State.ERROR&&this.state!==I.State.STOPPED&&(this.state=o.fatal?I.State.ERROR:I.State.IDLE,this.warn(o.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(o.parent==="audio"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var C=!0,S=this.getFwdBufferInfo(this.mediaBuffer,R.PlaylistLevelType.AUDIO);S&&S.len>.5&&(C=!this.reduceMaxBufferLength(S.len)),C&&(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}},y.onBufferFlushed=function(d,o){var C=o.type;C===f.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},y._handleTransmuxComplete=function(d){var o,C="audio",S=this.hls,x=d.remuxResult,M=d.chunkMeta,F=this.getCurrentContext(M);if(!F){this.warn("The loading context changed while buffering fragment "+M.sn+" of level "+M.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(M.level);return}var G=F.frag,J=F.part,K=x.audio,j=x.text,q=x.id3,oe=x.initSegment;if(this.fragContextChanged(G))return;if(this.state=I.State.PARSING,this.audioSwitch&&K&&this.completeAudioSwitch(),oe!=null&&oe.tracks&&(this._bufferInitSegment(oe.tracks,G,M),S.trigger(P.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:C,tracks:oe.tracks})),K){var ue=K.startPTS,ge=K.endPTS,_e=K.startDTS,be=K.endDTS;J&&(J.elementaryStreams[f.ElementaryStreamTypes.AUDIO]={startPTS:ue,endPTS:ge,startDTS:_e,endDTS:be}),G.setElementaryStreamInfo(f.ElementaryStreamTypes.AUDIO,ue,ge,_e,be),this.bufferFragmentData(K,G,J,M)}if(q!=null&&(o=q.samples)!==null&&o!==void 0&&o.length){var Se=l({frag:G,id:C},q);S.trigger(P.Events.FRAG_PARSING_METADATA,Se)}if(j){var Te=l({frag:G,id:C},j);S.trigger(P.Events.FRAG_PARSING_USERDATA,Te)}},y._bufferInitSegment=function(d,o,C){if(this.state!==I.State.PARSING)return;d.video&&delete d.video;var S=d.audio;if(!S)return;S.levelCodec=S.codec,S.id="audio",this.log("Init audio buffer, container:"+S.container+", codecs[parsed]=["+S.codec+"]"),this.hls.trigger(P.Events.BUFFER_CODECS,d);var x=S.initSegment;if(x!=null&&x.byteLength){var M={type:"audio",frag:o,part:null,chunkMeta:C,parent:o.type,data:x};this.hls.trigger(P.Events.BUFFER_APPENDING,M)}this.tick()},y.loadFragment=function(d,o,C){var S=this.fragmentTracker.getState(d);this.fragCurrent=d,(this.audioSwitch||S===N.FragmentState.NOT_LOADED||S===N.FragmentState.PARTIAL)&&(d.sn==="initSegment"?this._loadInitSegment(d):o.live&&!Object(V.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=I.State.WAITING_INIT_PTS):(this.startFragRequested=!0,D.prototype.loadFragment.call(this,d,o,C)))},y.completeAudioSwitch=function(){var d=this.hls,o=this.media,C=this.trackId;o&&(this.log("Switching audio track : flushing all audio"),D.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,d.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:C})},w}(I.default);Y.default=E},"./src/controller/audio-track-controller.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/events.ts"),I=_("./src/errors.ts"),P=_("./src/controller/base-playlist-controller.ts"),B=_("./src/types/loader.ts");function N(k,T){for(var g=0;g<T.length;g++){var b=T[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(k,b.key,b)}}function O(k,T,g){return T&&N(k.prototype,T),g&&N(k,g),k}function R(k,T){k.prototype=Object.create(T.prototype),k.prototype.constructor=k,f(k,T)}function f(k,T){return f=Object.setPrototypeOf||function(b,u){return b.__proto__=u,b},f(k,T)}var c=function(k){R(T,k);function T(b){var u;return u=k.call(this,b,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var g=T.prototype;return g.registerListeners=function(){var u=this.hls;u.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(V.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var u=this.hls;u.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(V.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,k.prototype.destroy.call(this)},g.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},g.onManifestParsed=function(u,a){this.tracks=a.audioTracks||[]},g.onAudioTrackLoaded=function(u,a){var l=a.id,h=a.details,A=this.tracksInGroup[l];if(!A){this.warn("Invalid audio track id "+l);return}var m=A.details;A.details=a.details,this.log("audioTrack "+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,a,m))},g.onLevelLoading=function(u,a){this.switchLevel(a.level)},g.onLevelSwitching=function(u,a){this.switchLevel(a.level)},g.switchLevel=function(u){var a=this.hls.levels[u];if(!(a!=null&&a.audioGroupIds))return;var l=a.audioGroupIds[a.urlId];if(this.groupId!==l){this.groupId=l;var h=this.tracks.filter(function(m){return!l||m.groupId===l});this.selectDefaultTrack&&!h.some(function(m){return m.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var A={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(V.Events.AUDIO_TRACKS_UPDATED,A),this.selectInitialTrack()}},g.onError=function(u,a){if(k.prototype.onError.call(this,u,a),a.fatal||!a.context)return;a.context.type===B.PlaylistContextType.AUDIO_TRACK&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&this.retryLoadingOrFail(a)},g.setAudioTrack=function(u){var a=this.tracksInGroup;if(u<0||u>=a.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=a[this.trackId];this.log("Now switching to audio-track index "+u);var h=a[u],A=h.id,m=h.groupId,E=m===void 0?"":m,D=h.name,w=h.type,y=h.url;if(this.trackId=u,this.trackName=D,this.selectDefaultTrack=!1,this.hls.trigger(V.Events.AUDIO_TRACK_SWITCHING,{id:A,groupId:E,name:D,type:w,url:y}),h.details&&!h.details.live)return;var p=this.switchParams(h.url,l==null?void 0:l.details);this.loadPlaylist(p)},g.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.length,"Initial audio track should be selected when tracks are known");var a=this.trackName,l=this.findTrackId(a)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},g.findTrackId=function(u){for(var a=this.tracksInGroup,l=0;l<a.length;l++){var h=a[l];if((!this.selectDefaultTrack||h.default)&&(!u||u===h.name))return h.id}return-1},g.loadPlaylist=function(u){var a=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(a)){var l=a.id,h=a.groupId,A=a.url;if(u)try{A=u.addDirectives(A)}catch(m){this.warn("Could not construct new URL with HLS Delivery Directives: "+m)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(V.Events.AUDIO_TRACK_LOADING,{url:A,id:l,groupId:h,deliveryDirectives:u||null})}},O(T,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),T}(P.default);Y.default=c},"./src/controller/base-playlist-controller.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return O});var V=_("./src/polyfills/number.ts"),I=_("./src/types/level.ts"),P=_("./src/controller/level-helper.ts"),B=_("./src/utils/logger.ts"),N=_("./src/errors.ts"),O=function(){function R(c,k){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=B.logger.log.bind(B.logger,k+":"),this.warn=B.logger.warn.bind(B.logger,k+":"),this.hls=c}var f=R.prototype;return f.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},f.onError=function(k,T){T.fatal&&T.type===N.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},f.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},f.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},f.stopLoad=function(){this.canLoad=!1,this.clearTimer()},f.switchParams=function(k,T){var g=T==null?void 0:T.renditionReports;if(g)for(var b=0;b<g.length;b++){var u=g[b],a=""+u.URI;if(a===k.substr(-a.length)){var l=parseInt(u["LAST-MSN"]),h=parseInt(u["LAST-PART"]);if(T&&this.hls.config.lowLatencyMode){var A=Math.min(T.age-T.partTarget,T.targetduration);h!==void 0&&A>T.partTarget&&(h+=1)}if(Object(V.isFiniteNumber)(l))return new I.HlsUrlParameters(l,Object(V.isFiniteNumber)(h)?h:void 0,I.HlsSkip.No)}}},f.loadPlaylist=function(k){},f.shouldLoadTrack=function(k){return this.canLoad&&k&&!!k.url&&(!k.details||k.details.live)},f.playlistLoaded=function(k,T,g){var b=this,u=T.details,a=T.stats,l=a.loading.end?Math.max(0,self.performance.now()-a.loading.end):0;if(u.advancedDateTime=Date.now()-l,u.live||g!=null&&g.live){if(u.reloaded(g),g&&this.log("live playlist "+k+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),g&&u.fragments.length>0&&Object(P.mergeDetails)(g,u),!this.canLoad||!u.live)return;var h,A=void 0,m=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var E=this.hls.config.lowLatencyMode,D=u.lastPartSn,w=u.endSN,y=u.lastPartIndex,p=y!==-1,d=D===w,o=E?0:y;p?(A=d?w+1:D,m=d?o:y+1):A=w+1;var C=u.age,S=C+u.ageHeader,x=Math.min(S-u.partTarget,u.targetduration*1.5);if(x>0){if(g&&x>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+x+" with playlist age: "+u.age),x=0;else{var M=Math.floor(x/u.targetduration);if(A+=M,m!==void 0){var F=Math.round(x%u.targetduration/u.partTarget);m+=F}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+C.toFixed(2)+"s goal: "+x+" skip sn "+M+" to part "+m)}u.tuneInGoal=x}if(h=this.getDeliveryDirectives(u,T.deliveryDirectives,A,m),E||!d){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(u,T.deliveryDirectives,A,m);var G=Object(P.computeReloadInterval)(u,a);A!==void 0&&u.canBlockReload&&(G-=u.partTarget||1),this.log("reload live playlist "+k+" in "+Math.round(G)+" ms"),this.timer=self.setTimeout(function(){return b.loadPlaylist(h)},G)}else this.clearTimer()},f.getDeliveryDirectives=function(k,T,g,b){var u=Object(I.getSkipValue)(k,g);return T!=null&&T.skip&&k.deltaUpdateFailed&&(g=T.msn,b=T.part,u=I.HlsSkip.No),new I.HlsUrlParameters(g,b,u)},f.retryLoadingOrFail=function(k){var T=this,g=this.hls.config,b=this.retryCount<g.levelLoadingMaxRetry;if(b){var u;if(this.retryCount++,k.details.indexOf("LoadTimeOut")>-1&&(u=k.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+k.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*g.levelLoadingRetryDelay,g.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return T.loadPlaylist()},a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+k.details+'"')}}else this.warn('cannot recover from error "'+k.details+'"'),this.clearTimer(),k.fatal=!0;return b},R}()},"./src/controller/base-stream-controller.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"State",function(){return w}),_.d(Y,"default",function(){return y});var V=_("./src/polyfills/number.ts"),I=_("./src/task-loop.ts"),P=_("./src/controller/fragment-tracker.ts"),B=_("./src/utils/buffer-helper.ts"),N=_("./src/utils/logger.ts"),O=_("./src/events.ts"),R=_("./src/errors.ts"),f=_("./src/types/transmuxer.ts"),c=_("./src/utils/mp4-tools.ts"),k=_("./src/utils/discontinuities.ts"),T=_("./src/controller/fragment-finders.ts"),g=_("./src/controller/level-helper.ts"),b=_("./src/loader/fragment-loader.ts"),u=_("./src/crypt/decrypter.ts"),a=_("./src/utils/time-ranges.ts"),l=_("./src/types/loader.ts");function h(p,d){for(var o=0;o<d.length;o++){var C=d[o];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(p,C.key,C)}}function A(p,d,o){return d&&h(p.prototype,d),o&&h(p,o),p}function m(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function E(p,d){p.prototype=Object.create(d.prototype),p.prototype.constructor=p,D(p,d)}function D(p,d){return D=Object.setPrototypeOf||function(C,S){return C.__proto__=S,C},D(p,d)}var w={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"},y=function(p){E(d,p);function d(C,S,x){var M;return M=p.call(this)||this,M.hls=void 0,M.fragPrevious=null,M.fragCurrent=null,M.fragmentTracker=void 0,M.transmuxer=null,M._state=w.STOPPED,M.media=void 0,M.mediaBuffer=void 0,M.config=void 0,M.bitrateTest=!1,M.lastCurrentTime=0,M.nextLoadPosition=0,M.startPosition=0,M.loadedmetadata=!1,M.fragLoadError=0,M.retryDate=0,M.levels=null,M.fragmentLoader=void 0,M.levelLastLoaded=null,M.startFragRequested=!1,M.decrypter=void 0,M.initPTS=[],M.onvseeking=null,M.onvended=null,M.logPrefix="",M.log=void 0,M.warn=void 0,M.logPrefix=x,M.log=N.logger.log.bind(N.logger,x+":"),M.warn=N.logger.warn.bind(N.logger,x+":"),M.hls=C,M.fragmentLoader=new b.default(C.config),M.fragmentTracker=S,M.config=C.config,M.decrypter=new u.default(C,C.config),C.on(O.Events.KEY_LOADED,M.onKeyLoaded,m(M)),M}var o=d.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(S){},o.stopLoad=function(){this.fragmentLoader.abort();var S=this.fragCurrent;S&&this.fragmentTracker.removeFragment(S),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=w.STOPPED},o._streamEnded=function(S,x){var M=this.fragCurrent,F=this.fragmentTracker;if(!x.live&&M&&M.sn===x.endSN&&!S.nextStart){var G=F.getState(M);return G===P.FragmentState.PARTIAL||G===P.FragmentState.OK}return!1},o.onMediaAttached=function(S,x){var M=this.media=this.mediaBuffer=x.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),M.addEventListener("seeking",this.onvseeking),M.addEventListener("ended",this.onvended);var F=this.config;this.levels&&F.autoStartLoad&&this.state===w.STOPPED&&this.startLoad(F.startPosition)},o.onMediaDetaching=function(){var S=this.media;S!=null&&S.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),S&&(S.removeEventListener("seeking",this.onvseeking),S.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var S=this.config,x=this.fragCurrent,M=this.media,F=this.mediaBuffer,G=this.state,J=M?M.currentTime:0,K=B.BufferHelper.bufferInfo(F||M,J,S.maxBufferHole);if(this.log("media seeking to "+(Object(V.isFiniteNumber)(J)?J.toFixed(3):J)+", state: "+G),G===w.ENDED)this.resetLoadingState();else if(x&&!K.len){var j=S.maxFragLookUpTolerance,q=x.start-j,oe=x.start+x.duration+j,ue=J>oe;(J<q||ue)&&(ue&&x.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),x.loader.abort()),this.resetLoadingState())}M&&(this.lastCurrentTime=J),!this.loadedmetadata&&!K.len&&(this.nextLoadPosition=this.startPosition=J),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(S,x){if(this.state!==w.KEY_LOADING||x.frag!==this.fragCurrent||!this.levels)return;this.state=w.IDLE;var M=this.levels[x.frag.level].details;M&&this.loadFragment(x.frag,M,x.frag.start)},o.onHandlerDestroying=function(){this.stopLoad(),p.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=w.STOPPED,this.hls.off(O.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,p.prototype.onHandlerDestroyed.call(this)},o.loadKey=function(S,x){this.log("Loading key for "+S.sn+" of ["+x.startSN+"-"+x.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+S.level),this.state=w.KEY_LOADING,this.fragCurrent=S,this.hls.trigger(O.Events.KEY_LOADING,{frag:S})},o.loadFragment=function(S,x,M){this._loadFragForPlayback(S,x,M)},o._loadFragForPlayback=function(S,x,M){var F=this,G=function(K){if(F.fragContextChanged(S)){F.warn("Fragment "+S.sn+(K.part?" p: "+K.part.index:"")+" of level "+S.level+" was dropped during download."),F.fragmentTracker.removeFragment(S);return}S.stats.chunkCount++,F._handleFragmentLoadProgress(K)};this._doFragLoad(S,x,M,G).then(function(J){if(!J)return;F.fragLoadError=0;var K=F.state;if(F.fragContextChanged(S)){(K===w.FRAG_LOADING||K===w.BACKTRACKING||!F.fragCurrent&&K===w.PARSING)&&(F.fragmentTracker.removeFragment(S),F.state=w.IDLE);return}if("payload"in J&&(F.log("Loaded fragment "+S.sn+" of level "+S.level),F.hls.trigger(O.Events.FRAG_LOADED,J),F.state===w.BACKTRACKING)){F.fragmentTracker.backtrack(S,J),F.resetFragmentLoading(S);return}F._handleFragmentLoadComplete(J)}).catch(function(J){F.warn(J),F.resetFragmentLoading(S)})},o.flushMainBuffer=function(S,x,M){if(M===void 0&&(M=null),!(S-x))return;var F={startOffset:S,endOffset:x,type:M};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,F)},o._loadInitSegment=function(S){var x=this;this._doFragLoad(S).then(function(M){if(!M||x.fragContextChanged(S)||!x.levels)throw new Error("init load aborted");return M}).then(function(M){var F=x.hls,G=M.payload,J=S.decryptdata;if(G&&G.byteLength>0&&J&&J.key&&J.iv&&J.method==="AES-128"){var K=self.performance.now();return x.decrypter.webCryptoDecrypt(new Uint8Array(G),J.key.buffer,J.iv.buffer).then(function(j){var q=self.performance.now();return F.trigger(O.Events.FRAG_DECRYPTED,{frag:S,payload:j,stats:{tstart:K,tdecrypt:q}}),M.payload=j,M})}return M}).then(function(M){var F=x.fragCurrent,G=x.hls,J=x.levels;if(!J)throw new Error("init load aborted, missing levels");var K=J[S.level].details;console.assert(K,"Level details are defined when init segment is loaded");var j=S.stats;x.state=w.IDLE,x.fragLoadError=0,S.data=new Uint8Array(M.payload),j.parsing.start=j.buffering.start=self.performance.now(),j.parsing.end=j.buffering.end=self.performance.now(),M.frag===F&&G.trigger(O.Events.FRAG_BUFFERED,{stats:j,frag:F,part:null,id:S.type}),x.tick()}).catch(function(M){x.warn(M),x.resetFragmentLoading(S)})},o.fragContextChanged=function(S){var x=this.fragCurrent;return!S||!x||S.level!==x.level||S.sn!==x.sn||S.urlId!==x.urlId},o.fragBufferedComplete=function(S,x){var M=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+S.type+" sn: "+S.sn+(x?" part: "+x.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+S.level+" "+a.default.toString(B.BufferHelper.getBuffered(M))),this.state=w.IDLE,this.tick()},o._handleFragmentLoadComplete=function(S){var x=this.transmuxer;if(!x)return;var M=S.frag,F=S.part,G=S.partsLoaded,J=!G||G.length===0||G.some(function(j){return!j}),K=new f.ChunkMetadata(M.level,M.sn,M.stats.chunkCount+1,0,F?F.index:-1,!J);x.flush(K)},o._handleFragmentLoadProgress=function(S){},o._doFragLoad=function(S,x,M,F){var G=this;if(M===void 0&&(M=null),!this.levels)throw new Error("frag load aborted, missing levels");if(M=Math.max(S.start,M||0),this.config.lowLatencyMode&&x){var J=x.partList;if(J&&F){M>S.end&&x.fragmentHint&&(S=x.fragmentHint);var K=this.getNextPart(J,S,M);if(K>-1){var j=J[K];return this.log("Loading part sn: "+S.sn+" p: "+j.index+" cc: "+S.cc+" of playlist ["+x.startSN+"-"+x.endSN+"] parts [0-"+K+"-"+(J.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+S.level+", target: "+parseFloat(M.toFixed(3))),this.nextLoadPosition=j.start+j.duration,this.state=w.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:S,part:J[K],targetBufferTime:M}),this.doFragPartsLoad(S,J,K,F).catch(function(q){return G.handleFragLoadError(q)})}else if(!S.url||this.loadedEndOfParts(J,M))return Promise.resolve(null)}}return this.log("Loading fragment "+S.sn+" cc: "+S.cc+" "+(x?"of ["+x.startSN+"-"+x.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+S.level+", target: "+parseFloat(M.toFixed(3))),Object(V.isFiniteNumber)(S.sn)&&!this.bitrateTest&&(this.nextLoadPosition=S.start+S.duration),this.state=w.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:S,targetBufferTime:M}),this.fragmentLoader.load(S,F).catch(function(q){return G.handleFragLoadError(q)})},o.doFragPartsLoad=function(S,x,M,F){var G=this;return new Promise(function(J,K){var j=[],q=function oe(ue){var ge=x[ue];G.fragmentLoader.loadPart(S,ge,F).then(function(_e){j[ge.index]=_e;var be=_e.part;G.hls.trigger(O.Events.FRAG_LOADED,_e);var Se=x[ue+1];if(Se&&Se.fragment===S)oe(ue+1);else return J({frag:S,part:be,partsLoaded:j})}).catch(K)};q(M)})},o.handleFragLoadError=function(S){var x=S.data;return x&&x.details===R.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(x.frag,x.part):this.hls.trigger(O.Events.ERROR,x),null},o._handleTransmuxerFlush=function(S){var x=this.getCurrentContext(S);if(!x||this.state!==w.PARSING){this.fragCurrent||(this.state=w.IDLE);return}var M=x.frag,F=x.part,G=x.level,J=self.performance.now();M.stats.parsing.end=J,F&&(F.stats.parsing.end=J),this.updateLevelTiming(M,F,G,S.partial)},o.getCurrentContext=function(S){var x=this.levels,M=S.level,F=S.sn,G=S.part;if(!x||!x[M])return this.warn("Levels object was unset while buffering fragment "+F+" of level "+M+". The current chunk will not be buffered."),null;var J=x[M],K=G>-1?Object(g.getPartWith)(J,F,G):null,j=K?K.fragment:Object(g.getFragmentWithSN)(J,F,this.fragCurrent);return j?{frag:j,part:K,level:J}:null},o.bufferFragmentData=function(S,x,M,F){if(!S||this.state!==w.PARSING)return;var G=S.data1,J=S.data2,K=G;if(G&&J&&(K=Object(c.appendUint8Array)(G,J)),!K||!K.length)return;var j={type:S.type,frag:x,part:M,chunkMeta:F,parent:x.type,data:K};this.hls.trigger(O.Events.BUFFER_APPENDING,j),S.dropped&&S.independent&&!M&&this.flushBufferGap(x)},o.flushBufferGap=function(S){var x=this.media;if(!x)return;if(!B.BufferHelper.isBuffered(x,x.currentTime)){this.flushMainBuffer(0,S.start);return}var M=x.currentTime,F=B.BufferHelper.bufferInfo(x,M,0),G=S.duration,J=Math.min(this.config.maxFragLookUpTolerance*2,G*.25),K=Math.max(Math.min(S.start-J,F.end-J),M+J);S.start-K>J&&this.flushMainBuffer(K,S.start)},o.getFwdBufferInfo=function(S,x){var M=this.config,F=this.getLoadPosition();if(!Object(V.isFiniteNumber)(F))return null;var G=B.BufferHelper.bufferInfo(S,F,M.maxBufferHole);if(G.len===0&&G.nextStart!==void 0){var J=this.fragmentTracker.getBufferedFrag(F,x);if(J&&G.nextStart<J.end)return B.BufferHelper.bufferInfo(S,F,Math.max(G.nextStart,M.maxBufferHole))}return G},o.getMaxBufferLength=function(S){var x=this.config,M;return S?M=Math.max(8*x.maxBufferSize/S,x.maxBufferLength):M=x.maxBufferLength,Math.min(M,x.maxMaxBufferLength)},o.reduceMaxBufferLength=function(S){var x=this.config,M=S||x.maxBufferLength;return x.maxMaxBufferLength>=M?(x.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+x.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(S,x){var M,F,G=x.fragments,J=G.length;if(!J)return null;var K=this.config,j=G[0].start,q;if(x.live){var oe=K.initialLiveManifestSize;if(J<oe)return this.warn("Not enough fragments to start playback (have: "+J+", need: "+oe+")"),null;!x.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(q=this.getInitialLiveFragment(x,G),this.startPosition=q?this.hls.liveSyncPosition||q.start:S)}else S<=j&&(q=G[0]);if(!q){var ue=K.lowLatencyMode?x.partEnd:x.fragmentEnd;q=this.getFragmentAtPosition(S,ue,x)}return(M=q)!==null&&M!==void 0&&M.initSegment&&!((F=q)!==null&&F!==void 0&&F.initSegment.data)&&!this.bitrateTest&&(q=q.initSegment),q},o.getNextPart=function(S,x,M){for(var F=-1,G=!1,J=!0,K=0,j=S.length;K<j;K++){var q=S[K];if(J=J&&!q.independent,F>-1&&M<q.start)break;var oe=q.loaded;!oe&&(G||q.independent||J)&&q.fragment===x&&(F=K),G=oe}return F},o.loadedEndOfParts=function(S,x){var M=S[S.length-1];return M&&x>M.start&&M.loaded},o.getInitialLiveFragment=function(S,x){var M=this.fragPrevious,F=null;if(M){if(S.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+M.programDateTime),F=Object(T.findFragmentByPDT)(x,M.endProgramDateTime,this.config.maxFragLookUpTolerance)),!F){var G=M.sn+1;if(G>=S.startSN&&G<=S.endSN){var J=x[G-S.startSN];M.cc===J.cc&&(F=J,this.log("Live playlist, switching playlist, load frag with next SN: "+F.sn))}F||(F=Object(T.findFragWithCC)(x,M.cc),F&&this.log("Live playlist, switching playlist, load frag with same CC: "+F.sn))}}else{var K=this.hls.liveSyncPosition;K!==null&&(F=this.getFragmentAtPosition(K,this.bitrateTest?S.fragmentEnd:S.edge,S))}return F},o.getFragmentAtPosition=function(S,x,M){var F=this.config,G=this.fragPrevious,J=M.fragments,K=M.endSN,j=M.fragmentHint,q=F.maxFragLookUpTolerance,oe=!!(F.lowLatencyMode&&M.partList&&j);oe&&j&&!this.bitrateTest&&(J=J.concat(j),K=j.sn);var ue;if(S<x){var ge=S>x-q?0:q;ue=Object(T.findFragmentByPTS)(G,J,S,ge)}else ue=J[J.length-1];if(ue){var _e=ue.sn-M.startSN,be=G&&ue.level===G.level,Se=J[_e+1],Te=this.fragmentTracker.getState(ue);if(Te===P.FragmentState.BACKTRACKED){ue=null;for(var Ce=_e;J[Ce]&&this.fragmentTracker.getState(J[Ce])===P.FragmentState.BACKTRACKED;)G?ue=J[Ce--]:ue=J[--Ce];ue||(ue=Se)}else G&&ue.sn===G.sn&&!oe&&(be&&(ue.sn<K&&this.fragmentTracker.getState(Se)!==P.FragmentState.OK?(this.log("SN "+ue.sn+" just loaded, load next one: "+Se.sn),ue=Se):ue=null))}return ue},o.synchronizeToLiveEdge=function(S){var x=this.config,M=this.media;if(!M)return;var F=this.hls.liveSyncPosition,G=M.currentTime,J=S.fragments[0].start,K=S.edge,j=G>=J-x.maxFragLookUpTolerance&&G<=K;if(F!==null&&M.duration>F&&(G<F||!j)){var q=x.liveMaxLatencyDuration!==void 0?x.liveMaxLatencyDuration:x.liveMaxLatencyDurationCount*S.targetduration;(!j&&M.readyState<4||G<K-q)&&(this.loadedmetadata||(this.nextLoadPosition=F),M.readyState&&(this.warn("Playback: "+G.toFixed(3)+" is located too far from the end of live sliding playlist: "+K+", reset currentTime to : "+F.toFixed(3)),M.currentTime=F))}},o.alignPlaylists=function(S,x){var M=this.levels,F=this.levelLastLoaded,G=this.fragPrevious,J=F!==null?M[F]:null,K=S.fragments.length;if(!K)return this.warn("No fragments in live playlist"),0;var j=S.fragments[0].start,q=!x,oe=S.alignedSliding&&Object(V.isFiniteNumber)(j);if(q||!oe&&!j){Object(k.alignStream)(G,J,S);var ue=S.fragments[0].start;return this.log("Live playlist sliding: "+ue.toFixed(2)+" start-sn: "+(x?x.startSN:"na")+"->"+S.startSN+" prev-sn: "+(G?G.sn:"na")+" fragments: "+K),ue}return j},o.waitForCdnTuneIn=function(S){var x=3;return S.live&&S.canBlockReload&&S.tuneInGoal>Math.max(S.partHoldBack,S.partTarget*x)},o.setStartPosition=function(S,x){var M=this.startPosition;if(M<x&&(M=-1),M===-1||this.lastCurrentTime===-1){var F=S.startTimeOffset;Object(V.isFiniteNumber)(F)?(M=x+F,F<0&&(M+=S.totalduration),M=Math.min(Math.max(x,M),x+S.totalduration),this.log("Start time offset "+F+" found in playlist, adjust startPosition to "+M),this.startPosition=M):S.live?M=this.hls.liveSyncPosition||x:this.startPosition=M=0,this.lastCurrentTime=M}this.nextLoadPosition=M},o.getLoadPosition=function(){var S=this.media,x=0;return this.loadedmetadata&&S?x=S.currentTime:this.nextLoadPosition&&(x=this.nextLoadPosition),x},o.handleFragLoadAborted=function(S,x){this.transmuxer&&S.sn!=="initSegment"&&S.stats.aborted&&(this.warn("Fragment "+S.sn+(x?" part"+x.index:"")+" of level "+S.level+" was aborted"),this.resetFragmentLoading(S))},o.resetFragmentLoading=function(S){(!this.fragCurrent||!this.fragContextChanged(S))&&(this.state=w.IDLE)},o.onFragmentOrKeyLoadError=function(S,x){if(x.fatal)return;var M=x.frag;if(!M||M.type!==S)return;var F=this.fragCurrent;console.assert(F&&M.sn===F.sn&&M.level===F.level&&M.urlId===F.urlId,"Frag load error must match current frag to retry");var G=this.config;if(this.fragLoadError+1<=G.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(M.level))return;var J=Math.min(Math.pow(2,this.fragLoadError)*G.fragLoadingRetryDelay,G.fragLoadingMaxRetryTimeout);this.warn("Fragment "+M.sn+" of "+S+" "+M.level+" failed to load, retrying in "+J+"ms"),this.retryDate=self.performance.now()+J,this.fragLoadError++,this.state=w.FRAG_LOADING_WAITING_RETRY}else x.levelRetry?(S===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=w.IDLE):(N.logger.error(x.details+" reaches max retry, redispatch as fatal ..."),x.fatal=!0,this.hls.stopLoad(),this.state=w.ERROR)},o.afterBufferFlushed=function(S,x,M){if(!S)return;var F=B.BufferHelper.getBuffered(S);this.fragmentTracker.detectEvictedFragments(x,F,M),this.state===w.ENDED&&this.resetLoadingState()},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=w.IDLE},o.resetLiveStartWhenNotLoaded=function(S){if(!this.loadedmetadata){this.startFragRequested=!1;var x=this.levels?this.levels[S].details:null;if(x!=null&&x.live)return this.startPosition=-1,this.setStartPosition(x,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},o.updateLevelTiming=function(S,x,M,F){var G=this,J=M.details;console.assert(!!J,"level.details must be defined");var K=Object.keys(S.elementaryStreams).reduce(function(j,q){var oe=S.elementaryStreams[q];if(oe){var ue=oe.endPTS-oe.startPTS;if(ue<=0)return G.warn("Could not parse fragment "+S.sn+" "+q+" duration reliably ("+ue+") resetting transmuxer to fallback to playlist timing"),G.resetTransmuxer(),j||!1;var ge=F?0:Object(g.updateFragPTSDTS)(J,S,oe.startPTS,oe.endPTS,oe.startDTS,oe.endDTS);return G.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:J,level:M,drift:ge,type:q,frag:S,start:oe.startPTS,end:oe.endPTS}),!0}return j},!1);K?(this.state=w.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:S,part:x})):this.resetLoadingState()},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},A(d,[{key:"state",get:function(){return this._state},set:function(S){var x=this._state;x!==S&&(this._state=S,this.log(x+"->"+S))}}]),d}(I.default)},"./src/controller/buffer-controller.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return T});var V=_("./src/polyfills/number.ts"),I=_("./src/events.ts"),P=_("./src/utils/logger.ts"),B=_("./src/errors.ts"),N=_("./src/utils/buffer-helper.ts"),O=_("./src/utils/mediasource-helper.ts"),R=_("./src/loader/fragment.ts"),f=_("./src/controller/buffer-operation-queue.ts"),c=Object(O.getMediaSource)(),k=/([ha]vc.)(?:\.[^.,]+)+/,T=function(){function g(u){var a=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=a.hls,h=a.media,A=a.mediaSource;P.logger.log("[buffer-controller]: Media source opened"),h&&(a.updateMediaElementDuration(),l.trigger(I.Events.MEDIA_ATTACHED,{media:h})),A&&A.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){P.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){P.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var b=g.prototype;return b.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},b.destroy=function(){this.unregisterListeners(),this.details=null},b.registerListeners=function(){var a=this.hls;a.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(I.Events.BUFFER_RESET,this.onBufferReset,this),a.on(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.on(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.on(I.Events.BUFFER_EOS,this.onBufferEos,this),a.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.on(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.on(I.Events.FRAG_PARSED,this.onFragParsed,this),a.on(I.Events.FRAG_CHANGED,this.onFragChanged,this)},b.unregisterListeners=function(){var a=this.hls;a.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(I.Events.BUFFER_RESET,this.onBufferReset,this),a.off(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.off(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.off(I.Events.BUFFER_EOS,this.onBufferEos,this),a.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.off(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.off(I.Events.FRAG_PARSED,this.onFragParsed,this),a.off(I.Events.FRAG_CHANGED,this.onFragChanged,this)},b._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new f.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},b.onManifestParsed=function(a,l){var h=2;(l.audio&&!l.video||!l.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,P.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},b.onMediaAttaching=function(a,l){var h=this.media=l.media;if(h&&c){var A=this.mediaSource=new c;A.addEventListener("sourceopen",this._onMediaSourceOpen),A.addEventListener("sourceended",this._onMediaSourceEnded),A.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(A),this._objectUrl=h.src}},b.onMediaDetaching=function(){var a=this.media,l=this.mediaSource,h=this._objectUrl;if(l){if(P.logger.log("[buffer-controller]: media source detaching"),l.readyState==="open")try{l.endOfStream()}catch(A){P.logger.warn("[buffer-controller]: onMediaDetaching: "+A.message+" while calling endOfStream")}this.onBufferReset(),l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),a&&(h&&self.URL.revokeObjectURL(h),a.src===h?(a.removeAttribute("src"),a.load()):P.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(I.Events.MEDIA_DETACHED,void 0)},b.onBufferReset=function(){var a=this;this.getSourceBufferTypes().forEach(function(l){var h=a.sourceBuffer[l];try{h&&(a.removeBufferListeners(l),a.mediaSource&&a.mediaSource.removeSourceBuffer(h),a.sourceBuffer[l]=void 0)}catch(A){P.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",A)}}),this._initSourceBuffer()},b.onBufferCodecs=function(a,l){var h=this,A=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(m){if(A){var E=h.tracks[m];if(E&&typeof E.buffer.changeType=="function"){var D=l[m],w=D.codec,y=D.levelCodec,p=D.container,d=(E.levelCodec||E.codec).replace(k,"$1"),o=(y||w).replace(k,"$1");if(d!==o){var C=p+";codecs="+(y||w);h.appendChangeType(m,C)}}}else h.pendingTracks[m]=l[m]}),A)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},b.appendChangeType=function(a,l){var h=this,A=this.operationQueue,m={execute:function(){var D=h.sourceBuffer[a];D&&(P.logger.log("[buffer-controller]: changing "+a+" sourceBuffer type to "+l),D.changeType(l)),A.shiftAndExecuteNext(a)},onStart:function(){},onComplete:function(){},onError:function(D){P.logger.warn("[buffer-controller]: Failed to change "+a+" SourceBuffer type",D)}};A.append(m,a)},b.onBufferAppending=function(a,l){var h=this,A=this.hls,m=this.operationQueue,E=this.tracks,D=l.data,w=l.type,y=l.frag,p=l.part,d=l.chunkMeta,o=d.buffering[w],C=self.performance.now();o.start=C;var S=y.stats.buffering,x=p?p.stats.buffering:null;S.start===0&&(S.start=C),x&&x.start===0&&(x.start=C);var M=E.audio,F=w==="audio"&&d.id===1&&(M==null?void 0:M.container)==="audio/mpeg",G={execute:function(){if(o.executeStart=self.performance.now(),F){var K=h.sourceBuffer[w];if(K){var j=y.start-K.timestampOffset;Math.abs(j)>=.1&&(P.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+y.start+" (delta: "+j+") sn: "+y.sn+")"),K.timestampOffset=y.start)}}h.appendExecutor(D,w)},onStart:function(){},onComplete:function(){var K=self.performance.now();o.executeEnd=o.end=K,S.first===0&&(S.first=K),x&&x.first===0&&(x.first=K);var j=h.sourceBuffer,q={};for(var oe in j)q[oe]=N.BufferHelper.getBuffered(j[oe]);h.appendError=0,h.hls.trigger(I.Events.BUFFER_APPENDED,{type:w,frag:y,part:p,chunkMeta:d,parent:y.type,timeRanges:q})},onError:function(K){P.logger.error("[buffer-controller]: Error encountered while trying to append to the "+w+" SourceBuffer",K);var j={type:B.ErrorTypes.MEDIA_ERROR,parent:y.type,details:B.ErrorDetails.BUFFER_APPEND_ERROR,err:K,fatal:!1};K.code===DOMException.QUOTA_EXCEEDED_ERR?j.details=B.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,j.details=B.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>A.config.appendErrorMaxRetry&&(P.logger.error("[buffer-controller]: Failed "+A.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),j.fatal=!0)),A.trigger(I.Events.ERROR,j)}};m.append(G,w)},b.onBufferFlushing=function(a,l){var h=this,A=this.operationQueue,m=function(D){return{execute:h.removeExecutor.bind(h,D,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(I.Events.BUFFER_FLUSHED,{type:D})},onError:function(y){P.logger.warn("[buffer-controller]: Failed to remove from "+D+" SourceBuffer",y)}}};l.type?A.append(m(l.type),l.type):this.getSourceBufferTypes().forEach(function(E){A.append(m(E),E)})},b.onFragParsed=function(a,l){var h=this,A=l.frag,m=l.part,E=[],D=m?m.elementaryStreams:A.elementaryStreams;D[R.ElementaryStreamTypes.AUDIOVIDEO]?E.push("audiovideo"):(D[R.ElementaryStreamTypes.AUDIO]&&E.push("audio"),D[R.ElementaryStreamTypes.VIDEO]&&E.push("video"));var w=function(){var p=self.performance.now();A.stats.buffering.end=p,m&&(m.stats.buffering.end=p);var d=m?m.stats:A.stats;h.hls.trigger(I.Events.FRAG_BUFFERED,{frag:A,part:m,stats:d,id:A.type})};E.length===0&&P.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+A.type+" level: "+A.level+" sn: "+A.sn),this.blockBuffers(w,E)},b.onFragChanged=function(a,l){this.flushBackBuffer()},b.onBufferEos=function(a,l){var h=this,A=this.getSourceBufferTypes().reduce(function(m,E){var D=h.sourceBuffer[E];return(!l.type||l.type===E)&&(D&&!D.ended&&(D.ended=!0,P.logger.log("[buffer-controller]: "+E+" sourceBuffer now EOS"))),m&&!!(!D||D.ended)},!0);A&&this.blockBuffers(function(){var m=h.mediaSource;if(!m||m.readyState!=="open")return;m.endOfStream()})},b.onLevelUpdated=function(a,l){var h=l.details;if(!h.fragments.length)return;this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},b.flushBackBuffer=function(){var a=this.hls,l=this.details,h=this.media,A=this.sourceBuffer;if(!h||l===null)return;var m=this.getSourceBufferTypes();if(!m.length)return;var E=l.live&&a.config.liveBackBufferLength!==null?a.config.liveBackBufferLength:a.config.backBufferLength;if(!Object(V.isFiniteNumber)(E)||E<0)return;var D=h.currentTime,w=l.levelTargetDuration,y=Math.max(E,w),p=Math.floor(D/w)*w-y;m.forEach(function(d){var o=A[d];if(o){var C=N.BufferHelper.getBuffered(o);C.length>0&&p>C.start(0)&&(a.trigger(I.Events.BACK_BUFFER_REACHED,{bufferEnd:p}),l.live&&a.trigger(I.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p}),a.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:d}))}})},b.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var a=this.details,l=this.hls,h=this.media,A=this.mediaSource,m=a.fragments[0].start+a.totalduration,E=h.duration,D=Object(V.isFiniteNumber)(A.duration)?A.duration:0;a.live&&l.config.liveDurationInfinity?(P.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),A.duration=Infinity,this.updateSeekableRange(a)):(m>D&&m>E||!Object(V.isFiniteNumber)(E))&&(P.logger.log("[buffer-controller]: Updating Media Source duration to "+m.toFixed(3)),A.duration=m)},b.updateSeekableRange=function(a){var l=this.mediaSource,h=a.fragments,A=h.length;if(A&&a.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var m=Math.max(0,h[0].start),E=Math.max(m,m+a.totalduration);l.setLiveSeekableRange(m,E)}},b.checkPendingTracks=function(){var a=this.bufferCodecEventsExpected,l=this.operationQueue,h=this.pendingTracks,A=Object.keys(h).length;if(A&&!a||A===2){this.createSourceBuffers(h),this.pendingTracks={};var m=this.getSourceBufferTypes();if(m.length===0){this.hls.trigger(I.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}m.forEach(function(E){l.executeNext(E)})}},b.createSourceBuffers=function(a){var l=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var A=0;for(var m in a)if(!l[m]){var E=a[m];if(!E)throw Error("source buffer exists for track "+m+", however track does not");var D=E.levelCodec||E.codec,w=E.container+";codecs="+D;P.logger.log("[buffer-controller]: creating sourceBuffer("+w+")");try{var y=l[m]=h.addSourceBuffer(w),p=m;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[m]={buffer:y,codec:D,container:E.container,levelCodec:E.levelCodec,id:E.id},A++}catch(d){P.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+d.message),this.hls.trigger(I.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:w})}}A&&this.hls.trigger(I.Events.BUFFER_CREATED,{tracks:this.tracks})},b._onSBUpdateStart=function(a){var l=this.operationQueue,h=l.current(a);h.onStart()},b._onSBUpdateEnd=function(a){var l=this.operationQueue,h=l.current(a);h.onComplete(),l.shiftAndExecuteNext(a)},b._onSBUpdateError=function(a,l){P.logger.error("[buffer-controller]: "+a+" SourceBuffer error",l),this.hls.trigger(I.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(a);h&&h.onError(l)},b.removeExecutor=function(a,l,h){var A=this.media,m=this.mediaSource,E=this.operationQueue,D=this.sourceBuffer,w=D[a];if(!A||!m||!w){P.logger.warn("[buffer-controller]: Attempting to remove from the "+a+" SourceBuffer, but it does not exist"),E.shiftAndExecuteNext(a);return}var y=Object(V.isFiniteNumber)(A.duration)?A.duration:Infinity,p=Object(V.isFiniteNumber)(m.duration)?m.duration:Infinity,d=Math.max(0,l),o=Math.min(h,y,p);o>d?(P.logger.log("[buffer-controller]: Removing ["+d+","+o+"] from the "+a+" SourceBuffer"),console.assert(!w.updating,a+" sourceBuffer must not be updating"),w.remove(d,o)):E.shiftAndExecuteNext(a)},b.appendExecutor=function(a,l){var h=this.operationQueue,A=this.sourceBuffer,m=A[l];if(!m){P.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(l);return}m.ended=!1,console.assert(!m.updating,l+" sourceBuffer must not be updating"),m.appendBuffer(a)},b.blockBuffers=function(a,l){var h=this;if(l===void 0&&(l=this.getSourceBufferTypes()),!l.length){P.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(a);return}var A=this.operationQueue,m=l.map(function(E){return A.appendBlocker(E)});Promise.all(m).then(function(){a(),l.forEach(function(E){var D=h.sourceBuffer[E];(!D||!D.updating)&&A.shiftAndExecuteNext(E)})})},b.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},b.addBufferListener=function(a,l,h){var A=this.sourceBuffer[a];if(!A)return;var m=h.bind(this,a);this.listeners[a].push({event:l,listener:m}),A.addEventListener(l,m)},b.removeBufferListeners=function(a){var l=this.sourceBuffer[a];if(!l)return;this.listeners[a].forEach(function(h){l.removeEventListener(h.event,h.listener)})},g}()},"./src/controller/buffer-operation-queue.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return I});var V=_("./src/utils/logger.ts"),I=function(){function P(N){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=N}var B=P.prototype;return B.append=function(O,R){var f=this.queues[R];f.push(O),f.length===1&&this.buffers[R]&&this.executeNext(R)},B.insertAbort=function(O,R){var f=this.queues[R];f.unshift(O),this.executeNext(R)},B.appendBlocker=function(O){var R,f=new Promise(function(k){R=k}),c={execute:R,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(c,O),f},B.executeNext=function(O){var R=this.buffers,f=this.queues,c=R[O],k=f[O];if(k.length){var T=k[0];try{T.execute()}catch(g){V.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),T.onError(g),(!c||!c.updating)&&(k.shift(),this.executeNext(O))}}},B.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},B.current=function(O){return this.queues[O][0]},P}()},"./src/controller/cap-level-controller.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/events.ts");function I(N,O){for(var R=0;R<O.length;R++){var f=O[R];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(N,f.key,f)}}function P(N,O,R){return O&&I(N.prototype,O),R&&I(N,R),N}var B=function(){function N(R){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=R,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=N.prototype;return O.setStreamController=function(f){this.streamController=f},O.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},O.registerListeners=function(){var f=this.hls;f.on(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),f.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),f.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var f=this.hls;f.off(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),f.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),f.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(f,c){N.isLevelAllowed(c.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(c.droppedLevel)},O.onMediaAttaching=function(f,c){this.media=c.media instanceof HTMLVideoElement?c.media:null},O.onManifestParsed=function(f,c){var k=this.hls;this.restrictedLevels=[],this.firstLevel=c.firstLevel,k.config.capLevelToPlayerSize&&c.video&&this.startCapping()},O.onBufferCodecs=function(f,c){var k=this.hls;k.config.capLevelToPlayerSize&&c.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var f=this.hls.levels;if(f.length){var c=this.hls;c.autoLevelCapping=this.getMaxLevel(f.length-1),c.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=c.autoLevelCapping}}},O.getMaxLevel=function(f){var c=this,k=this.hls.levels;if(!k.length)return-1;var T=k.filter(function(g,b){return N.isLevelAllowed(b,c.restrictedLevels)&&b<=f});return this.clientRect=null,N.getMaxLevelByMediaSize(T,this.mediaWidth,this.mediaHeight)},O.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()},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var f=this.media,c={width:0,height:0};if(f){var k=f.getBoundingClientRect();c.width=k.width,c.height=k.height,!c.width&&!c.height&&(c.width=k.right-k.left||f.width||0,c.height=k.bottom-k.top||f.height||0)}return this.clientRect=c,c},N.isLevelAllowed=function(f,c){return c===void 0&&(c=[]),c.indexOf(f)===-1},N.getMaxLevelByMediaSize=function(f,c,k){if(!f||!f.length)return-1;for(var T=function(l,h){return h?l.width!==h.width||l.height!==h.height:!0},g=f.length-1,b=0;b<f.length;b+=1){var u=f[b];if((u.width>=c||u.height>=k)&&T(u,f[b+1])){g=b;break}}return g},P(N,[{key:"mediaWidth",get:function(){return this.getDimensions().width*N.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*N.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var f=1;try{f=self.devicePixelRatio}catch(c){}return f}}]),N}();Y.default=B},"./src/controller/cmcd-controller.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return T});var V=_("./src/events.ts"),I=_("./src/types/cmcd.ts"),P=_("./src/utils/buffer-helper.ts"),B=_("./src/utils/logger.ts");function N(g,b){for(var u=0;u<b.length;u++){var a=b[u];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(g,a.key,a)}}function O(g,b,u){return b&&N(g.prototype,b),u&&N(g,u),g}function R(g,b){var u=typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(u)return(u=u.call(g)).next.bind(u);if(Array.isArray(g)||(u=f(g))||b&&g&&typeof g.length=="number"){u&&(g=u);var a=0;return function(){return a>=g.length?{done:!0}:{done:!1,value:g[a++]}}}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 f(g,b){if(!g)return;if(typeof g=="string")return c(g,b);var u=Object.prototype.toString.call(g).slice(8,-1);if(u==="Object"&&g.constructor&&(u=g.constructor.name),u==="Map"||u==="Set")return Array.from(g);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return c(g,b)}function c(g,b){(b==null||b>g.length)&&(b=g.length);for(var u=0,a=new Array(b);u<b;u++)a[u]=g[u];return a}function k(){return k=Object.assign||function(g){for(var b=1;b<arguments.length;b++){var u=arguments[b];for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(g[a]=u[a])}return g},k.apply(this,arguments)}var T=function(){function g(u){var a=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(){a.initialized&&(a.starved=!0),a.buffering=!0},this.onPlaying=function(){a.initialized||(a.initialized=!0),a.buffering=!1},this.applyPlaylistData=function(A){try{a.apply(A,{ot:I.CMCDObjectType.MANIFEST,su:!a.initialized})}catch(m){B.logger.warn("Could not generate manifest CMCD data.",m)}},this.applyFragmentData=function(A){try{var m=A.frag,E=a.hls.levels[m.level],D=a.getObjectType(m),w={d:m.duration*1e3,ot:D};(D===I.CMCDObjectType.VIDEO||D===I.CMCDObjectType.AUDIO||D==I.CMCDObjectType.MUXED)&&(w.br=E.bitrate/1e3,w.tb=a.getTopBandwidth(D),w.bl=a.getBufferLength(D)),a.apply(A,w)}catch(y){B.logger.warn("Could not generate segment CMCD data.",y)}},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||g.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var b=g.prototype;return b.registerListeners=function(){var a=this.hls;a.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),a.on(V.Events.BUFFER_CREATED,this.onBufferCreated,this)},b.unregisterListeners=function(){var a=this.hls;a.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),a.off(V.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},b.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},b.onMediaAttached=function(a,l){this.media=l.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},b.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},b.onBufferCreated=function(a,l){var h,A;this.audioBuffer=(h=l.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(A=l.tracks.video)===null||A===void 0?void 0:A.buffer},b.createData=function(){var a;return{v:I.CMCDVersion,sf:I.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(a=this.media)===null||a===void 0?void 0:a.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},b.apply=function(a,l){l===void 0&&(l={}),k(l,this.createData());var h=l.ot===I.CMCDObjectType.INIT||l.ot===I.CMCDObjectType.VIDEO||l.ot===I.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 A=g.toHeaders(l);if(!Object.keys(A).length)return;a.headers||(a.headers={}),k(a.headers,A)}else{var m=g.toQuery(l);if(!m)return;a.url=g.appendQueryToUri(a.url,m)}},b.getObjectType=function(a){var l=a.type;return l==="subtitle"?I.CMCDObjectType.TIMED_TEXT:a.sn==="initSegment"?I.CMCDObjectType.INIT:l==="audio"?I.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?I.CMCDObjectType.VIDEO:I.CMCDObjectType.MUXED:void 0},b.getTopBandwidth=function(a){for(var l=0,h=a===I.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,A=R(h),m;!(m=A()).done;){var E=m.value;E.bitrate>l&&(l=E.bitrate)}return l>0?l:NaN},b.getBufferLength=function(a){var l=this.hls.media,h=a===I.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!l)return NaN;var A=P.BufferHelper.bufferInfo(h,l.currentTime,this.config.maxBufferHole);return A.len*1e3},b.createPlaylistLoader=function(){var a=this.config.pLoader,l=this.applyPlaylistData,h=a||this.config.loader;return function(){function A(E){this.loader=void 0,this.loader=new h(E)}var m=A.prototype;return m.destroy=function(){this.loader.destroy()},m.abort=function(){this.loader.abort()},m.load=function(D,w,y){l(D),this.loader.load(D,w,y)},O(A,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),A}()},b.createFragmentLoader=function(){var a=this.config.fLoader,l=this.applyFragmentData,h=a||this.config.loader;return function(){function A(E){this.loader=void 0,this.loader=new h(E)}var m=A.prototype;return m.destroy=function(){this.loader.destroy()},m.abort=function(){this.loader.abort()},m.load=function(D,w,y){l(D),this.loader.load(D,w,y)},O(A,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),A}()},g.uuid=function(){var a=URL.createObjectURL(new Blob),l=a.toString();return URL.revokeObjectURL(a),l.substr(l.lastIndexOf("/")+1)},g.serialize=function(a){for(var l=[],h=function(F){return!Number.isNaN(F)&&F!=null&&F!==""&&F!==!1},A=function(F){return Math.round(F)},m=function(F){return A(F/100)*100},E=function(F){return encodeURIComponent(F)},D={br:A,d:A,bl:m,dl:m,mtp:m,nor:E,rtp:m,tb:A},w=Object.keys(a||{}).sort(),y=R(w),p;!(p=y()).done;){var d=p.value,o=a[d];if(!h(o))continue;if(d==="v"&&o===1)continue;if(d=="pr"&&o===1)continue;var C=D[d];C&&(o=C(o));var S=typeof o,x=void 0;d==="ot"||d==="sf"||d==="st"?x=d+"="+o:S==="boolean"?x=d:S==="number"?x=d+"="+o:x=d+"="+JSON.stringify(o),l.push(x)}return l.join(",")},g.toHeaders=function(a){for(var l=Object.keys(a),h={},A=["Object","Request","Session","Status"],m=[{},{},{},{}],E={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,w=l;D<w.length;D++){var y=w[D],p=E[y]!=null?E[y]:1;m[p][y]=a[y]}for(var d=0;d<m.length;d++){var o=g.serialize(m[d]);o&&(h["CMCD-"+A[d]]=o)}return h},g.toQuery=function(a){return"CMCD="+encodeURIComponent(g.serialize(a))},g.appendQueryToUri=function(a,l){if(!l)return a;var h=a.includes("?")?"&":"?";return""+a+h+l},g}()},"./src/controller/eme-controller.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/events.ts"),I=_("./src/errors.ts"),P=_("./src/utils/logger.ts"),B=_("./src/utils/mediakeys-helper.ts");function N(T,g){for(var b=0;b<g.length;b++){var u=g[b];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(T,u.key,u)}}function O(T,g,b){return g&&N(T.prototype,g),b&&N(T,b),T}var R=3,f=function(g,b,u){var a={audioCapabilities:[],videoCapabilities:[]};return g.forEach(function(l){a.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:u.audioRobustness||""})}),b.forEach(function(l){a.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:u.videoRobustness||""})}),[a]},c=function(g,b,u,a){switch(g){case B.KeySystems.WIDEVINE:return f(b,u,a);default:throw new Error("Unknown key-system: "+g)}},k=function(){function T(b){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=b,this._config=b.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 g=T.prototype;return g.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},g._registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g._unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g.getLicenseServerUrl=function(u){switch(u){case B.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},g._attemptKeySystemAccess=function(u,a,l){var h=this,A=c(u,a,l,this._drmSystemOptions);P.logger.log("Requesting encrypted media key-system access");var m=this.requestMediaKeySystemAccess(u,A);this.mediaKeysPromise=m.then(function(E){return h._onMediaKeySystemAccessObtained(u,E)}),m.catch(function(E){P.logger.error('Failed to obtain key-system "'+u+'" access:',E)})},g._onMediaKeySystemAccessObtained=function(u,a){var l=this;P.logger.log('Access for key-system "'+u+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:a,mediaKeySystemDomain:u};this._mediaKeysList.push(h);var A=Promise.resolve().then(function(){return a.createMediaKeys()}).then(function(m){return h.mediaKeys=m,P.logger.log('Media-keys created for key-system "'+u+'"'),l._onMediaKeysCreated(),m});return A.catch(function(m){P.logger.error("Failed to create media-keys:",m)}),A},g._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(a){a.mediaKeysSession||(a.mediaKeysSession=a.mediaKeys.createSession(),u._onNewMediaKeySession(a.mediaKeysSession))})},g._onNewMediaKeySession=function(u){var a=this;P.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(l){a._onKeySessionMessage(u,l.message)},!1)},g._onKeySessionMessage=function(u,a){P.logger.log("Got EME message event, creating license request"),this._requestLicense(a,function(l){P.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),u.update(l)})},g.onMediaEncrypted=function(u){var a=this;if(P.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){P.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(A){if(!a._media)return;a._attemptSetMediaKeys(A),a._generateRequestWithPreferredKeySession(u.initDataType,u.initData)};this.mediaKeysPromise.then(l).catch(l)},g._attemptSetMediaKeys=function(u){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var a=this._mediaKeysList[0];if(!a||!a.mediaKeys){P.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}P.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(a.mediaKeys),this._hasSetMediaKeys=!0}},g._generateRequestWithPreferredKeySession=function(u,a){var l=this,h=this._mediaKeysList[0];if(!h){P.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){P.logger.warn("Key-Session already initialized but requested again");return}var A=h.mediaKeysSession;if(!A){P.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!a){P.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}P.logger.log('Generating key-session request for "'+u+'" init data type'),h.mediaKeysSessionInitialized=!0,A.generateRequest(u,a).then(function(){P.logger.debug("Key-session generation succeeded")}).catch(function(m){P.logger.error("Error generating key-session request:",m),l.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},g._createLicenseXhr=function(u,a,l){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,u,a,l);var A=this._licenseXhrSetup;if(A)try{A.call(this.hls,h,u),A=void 0}catch(m){P.logger.error(m)}try{h.readyState||h.open("POST",u,!0),A&&A.call(this.hls,h,u)}catch(m){throw new Error("issue setting up KeySystem license XHR "+m)}return h},g._onLicenseRequestReadyStageChange=function(u,a,l,h){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,P.logger.log("License request succeeded");var A=u.response,m=this._licenseResponseCallback;if(m)try{A=m.call(this.hls,u,a)}catch(D){P.logger.error(D)}h(A)}else{if(P.logger.error("License Request XHR failed ("+a+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>R){this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var E=R-this._requestLicenseFailureCount+1;P.logger.warn("Retrying license request, "+E+" attempts left"),this._requestLicense(l,h)}break}},g._generateLicenseRequestChallenge=function(u,a){switch(u.mediaKeySystemDomain){case B.KeySystems.WIDEVINE:return a}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},g._requestLicense=function(u,a){P.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){P.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(l.mediaKeySystemDomain),A=this._createLicenseXhr(h,u,a);P.logger.log("Sending license request to URL: "+h);var m=this._generateLicenseRequestChallenge(l,u);A.send(m)}catch(E){P.logger.error("Failure requesting DRM license: "+E),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},g.onMediaAttached=function(u,a){if(!this._emeEnabled)return;var l=a.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},g.onMediaDetached=function(){var u=this._media,a=this._mediaKeysList;if(!u)return;u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(a.map(function(l){if(l.mediaKeysSession)return l.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){})},g.onManifestParsed=function(u,a){if(!this._emeEnabled)return;var l=a.levels.map(function(A){return A.audioCodec}).filter(function(A){return!!A}),h=a.levels.map(function(A){return A.videoCodec}).filter(function(A){return!!A});this._attemptKeySystemAccess(B.KeySystems.WIDEVINE,l,h)},O(T,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),T}();Y.default=k},"./src/controller/fps-controller.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/events.ts"),I=_("./src/utils/logger.ts"),P=function(){function B(O){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=O,this.registerListeners()}var N=B.prototype;return N.setStreamController=function(R){this.streamController=R},N.registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},N.unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching)},N.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},N.onMediaAttaching=function(R,f){var c=this.hls.config;if(c.capLevelOnFPSDrop){var k=f.media instanceof self.HTMLVideoElement?f.media:null;this.media=k,k&&typeof k.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),c.fpsDroppedMonitoringPeriod)}},N.checkFPS=function(R,f,c){var k=performance.now();if(f){if(this.lastTime){var T=k-this.lastTime,g=c-this.lastDroppedFrames,b=f-this.lastDecodedFrames,u=1e3*g/T,a=this.hls;if(a.trigger(V.Events.FPS_DROP,{currentDropped:g,currentDecoded:b,totalDroppedFrames:c}),u>0&&g>a.config.fpsDroppedMonitoringThreshold*b){var l=a.currentLevel;I.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(a.autoLevelCapping===-1||a.autoLevelCapping>=l)&&(l=l-1,a.trigger(V.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:a.currentLevel}),a.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=k,this.lastDroppedFrames=c,this.lastDecodedFrames=f}},N.checkFPSInterval=function(){var R=this.media;if(R)if(this.isVideoPlaybackQualityAvailable){var f=R.getVideoPlaybackQuality();this.checkFPS(R,f.totalVideoFrames,f.droppedVideoFrames)}else this.checkFPS(R,R.webkitDecodedFrameCount,R.webkitDroppedFrameCount)},B}();Y.default=P},"./src/controller/fragment-finders.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"findFragmentByPDT",function(){return P}),_.d(Y,"findFragmentByPTS",function(){return B}),_.d(Y,"fragmentWithinToleranceTest",function(){return N}),_.d(Y,"pdtWithinToleranceTest",function(){return O}),_.d(Y,"findFragWithCC",function(){return R});var V=_("./src/polyfills/number.ts"),I=_("./src/utils/binary-search.ts");function P(f,c,k){if(c===null||!Array.isArray(f)||!f.length||!Object(V.isFiniteNumber)(c))return null;var T=f[0].programDateTime;if(c<(T||0))return null;var g=f[f.length-1].endProgramDateTime;if(c>=(g||0))return null;k=k||0;for(var b=0;b<f.length;++b){var u=f[b];if(O(c,k,u))return u}return null}function B(f,c,k,T){k===void 0&&(k=0),T===void 0&&(T=0);var g=null;if(f?g=c[f.sn-c[0].sn+1]||null:k===0&&c[0].start===0&&(g=c[0]),g&&N(k,T,g)===0)return g;var b=I.default.search(c,N.bind(null,k,T));return b||g}function N(f,c,k){f===void 0&&(f=0),c===void 0&&(c=0);var T=Math.min(c,k.duration+(k.deltaPTS?k.deltaPTS:0));return k.start+k.duration-T<=f?1:k.start-T>f&&k.start?-1:0}function O(f,c,k){var T=Math.min(c,k.duration+(k.deltaPTS?k.deltaPTS:0))*1e3,g=k.endProgramDateTime||0;return g-T>f}function R(f,c){return I.default.search(f,function(k){return k.cc<c?1:k.cc>c?-1:0})}},"./src/controller/fragment-tracker.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"FragmentState",function(){return P}),_.d(Y,"FragmentTracker",function(){return B});var V=_("./src/events.ts"),I=_("./src/types/loader.ts"),P;(function(R){R.NOT_LOADED="NOT_LOADED",R.BACKTRACKED="BACKTRACKED",R.APPENDING="APPENDING",R.PARTIAL="PARTIAL",R.OK="OK"})(P||(P={}));var B=function(){function R(c){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=c,this._registerListeners()}var f=R.prototype;return f._registerListeners=function(){var k=this.hls;k.on(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.on(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.on(V.Events.FRAG_LOADED,this.onFragLoaded,this)},f._unregisterListeners=function(){var k=this.hls;k.off(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.off(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.off(V.Events.FRAG_LOADED,this.onFragLoaded,this)},f.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},f.getAppendedFrag=function(k,T){if(T===I.PlaylistLevelType.MAIN){var g=this.activeFragment,b=this.activeParts;if(!g)return null;if(b)for(var u=b.length;u--;){var a=b[u],l=a?a.end:g.appendedPTS;if(a.start<=k&&l!==void 0&&k<=l)return u>9&&(this.activeParts=b.slice(u-9)),a}else if(g.start<=k&&g.appendedPTS!==void 0&&k<=g.appendedPTS)return g}return this.getBufferedFrag(k,T)},f.getBufferedFrag=function(k,T){for(var g=this.fragments,b=Object.keys(g),u=b.length;u--;){var a=g[b[u]];if((a==null?void 0:a.body.type)===T&&a.buffered){var l=a.body;if(l.start<=k&&k<=l.end)return l}}return null},f.detectEvictedFragments=function(k,T,g){var b=this;Object.keys(this.fragments).forEach(function(u){var a=b.fragments[u];if(!a)return;if(!a.buffered){a.body.type===g&&b.removeFragment(a.body);return}var l=a.range[k];if(!l)return;l.time.some(function(h){var A=!b.isTimeBuffered(h.startPTS,h.endPTS,T);return A&&b.removeFragment(a.body),A})})},f.detectPartialFragments=function(k){var T=this,g=this.timeRanges,b=k.frag,u=k.part;if(!g||b.sn==="initSegment")return;var a=O(b),l=this.fragments[a];if(!l)return;Object.keys(g).forEach(function(h){var A=b.elementaryStreams[h];if(!A)return;var m=g[h],E=u!==null||A.partial===!0;l.range[h]=T.getBufferedTimes(b,u,E,m)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},f.fragBuffered=function(k){var T=O(k),g=this.fragments[T];g&&(g.backtrack=g.loaded=null,g.buffered=!0)},f.getBufferedTimes=function(k,T,g,b){for(var u={time:[],partial:g},a=T?T.start:k.start,l=T?T.end:k.end,h=k.minEndPTS||l,A=k.maxStartPTS||a,m=0;m<b.length;m++){var E=b.start(m)-this.bufferPadding,D=b.end(m)+this.bufferPadding;if(A>=E&&h<=D){u.time.push({startPTS:Math.max(a,b.start(m)),endPTS:Math.min(l,b.end(m))});break}else if(a<D&&l>E)u.partial=!0,u.time.push({startPTS:Math.max(a,b.start(m)),endPTS:Math.min(l,b.end(m))});else if(l<=E)break}return u},f.getPartialFragment=function(k){var T=null,g,b,u,a=0,l=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(A){var m=h[A];if(!m)return;N(m)&&(b=m.body.start-l,u=m.body.end+l,k>=b&&k<=u&&(g=Math.min(k-b,u-k),a<=g&&(T=m.body,a=g)))}),T},f.getState=function(k){var T=O(k),g=this.fragments[T];return g?g.buffered?N(g)?P.PARTIAL:P.OK:g.backtrack?P.BACKTRACKED:P.APPENDING:P.NOT_LOADED},f.backtrack=function(k,T){var g=O(k),b=this.fragments[g];if(!b||b.backtrack)return null;var u=b.backtrack=T||b.loaded;return b.loaded=null,u},f.getBacktrackData=function(k){var T=O(k),g=this.fragments[T];if(g){var b,u=g.backtrack;if(u!=null&&(b=u.payload)!==null&&b!==void 0&&b.byteLength)return u;this.removeFragment(k)}return null},f.isTimeBuffered=function(k,T,g){for(var b,u,a=0;a<g.length;a++){if(b=g.start(a)-this.bufferPadding,u=g.end(a)+this.bufferPadding,k>=b&&T<=u)return!0;if(T<=b)return!1}return!1},f.onFragLoaded=function(k,T){var g=T.frag,b=T.part;if(g.sn==="initSegment"||g.bitrateTest||b)return;var u=O(g);this.fragments[u]={body:g,loaded:T,backtrack:null,buffered:!1,range:Object.create(null)}},f.onBufferAppended=function(k,T){var g=this,b=T.frag,u=T.part,a=T.timeRanges;if(b.type===I.PlaylistLevelType.MAIN)if(this.activeFragment=b,u){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(u)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(h){var A=a[h];if(g.detectEvictedFragments(h,A),!u)for(var m=0;m<A.length;m++)b.appendedPTS=Math.max(A.end(m),b.appendedPTS||0)})},f.onFragBuffered=function(k,T){this.detectPartialFragments(T)},f.hasFragment=function(k){var T=O(k);return!!this.fragments[T]},f.removeFragmentsInRange=function(k,T,g){var b=this;Object.keys(this.fragments).forEach(function(u){var a=b.fragments[u];if(!a)return;if(a.buffered){var l=a.body;l.type===g&&l.start<T&&l.end>k&&b.removeFragment(l)}})},f.removeFragment=function(k){var T=O(k);k.stats.loaded=0,k.clearElementaryStreamInfo(),delete this.fragments[T]},f.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},R}();function N(R){var f,c;return R.buffered&&(((f=R.range.video)===null||f===void 0?void 0:f.partial)||((c=R.range.audio)===null||c===void 0?void 0:c.partial))}function O(R){return R.type+"_"+R.level+"_"+R.urlId+"_"+R.sn}},"./src/controller/gap-controller.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"STALL_MINIMUM_DURATION_MS",function(){return N}),_.d(Y,"MAX_START_GAP_JUMP",function(){return O}),_.d(Y,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return R}),_.d(Y,"SKIP_BUFFER_RANGE_START",function(){return f}),_.d(Y,"default",function(){return c});var V=_("./src/utils/buffer-helper.ts"),I=_("./src/errors.ts"),P=_("./src/events.ts"),B=_("./src/utils/logger.ts"),N=250,O=2,R=.1,f=.05,c=function(){function k(g,b,u,a){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=g,this.media=b,this.fragmentTracker=u,this.hls=a}var T=k.prototype;return T.destroy=function(){this.hls=this.fragmentTracker=this.media=null},T.poll=function(b){var u=this.config,a=this.media,l=this.stalled,h=a.currentTime,A=a.seeking,m=this.seeking&&!A,E=!this.seeking&&A;if(this.seeking=A,h!==b){if(this.moved=!0,l!==null){if(this.stallReported){var D=self.performance.now()-l;B.logger.warn("playback not stuck anymore @"+h+", after "+Math.round(D)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((E||m)&&(this.stalled=null),a.paused||a.ended||a.playbackRate===0||!V.BufferHelper.getBuffered(a).length)return;var w=V.BufferHelper.bufferInfo(a,h,0),y=w.len>0,p=w.nextStart||0;if(!y&&!p)return;if(A){var d=w.len>O,o=!p||p-h>O&&!this.fragmentTracker.getPartialFragment(h);if(d||o)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var C,S=Math.max(p,w.start||0)-h,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=x==null||((C=x.details)===null||C===void 0)?void 0:C.live,F=M?x.details.targetduration*2:O;if(S>0&&S<=F){this._trySkipBufferHole(null);return}}var G=self.performance.now();if(l===null){this.stalled=G;return}var J=G-l;!A&&J>=N&&this._reportStall(w.len);var K=V.BufferHelper.bufferInfo(a,h,u.maxBufferHole);this._tryFixBufferStall(K,J)},T._tryFixBufferStall=function(b,u){var a=this.config,l=this.fragmentTracker,h=this.media,A=h.currentTime,m=l.getPartialFragment(A);if(m){var E=this._trySkipBufferHole(m);if(E)return}b.len>a.maxBufferHole&&u>a.highBufferWatchdogPeriod*1e3&&(B.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},T._reportStall=function(b){var u=this.hls,a=this.media,l=this.stallReported;l||(this.stallReported=!0,B.logger.warn("Playback stalling at @"+a.currentTime+" due to low buffer (buffer="+b+")"),u.trigger(P.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:b}))},T._trySkipBufferHole=function(b){for(var u=this.config,a=this.hls,l=this.media,h=l.currentTime,A=0,m=V.BufferHelper.getBuffered(l),E=0;E<m.length;E++){var D=m.start(E);if(h+u.maxBufferHole>=A&&h<D){var w=Math.max(D+f,l.currentTime+R);return B.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+w),this.moved=!0,this.stalled=null,l.currentTime=w,b&&a.trigger(P.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+w,frag:b}),w}A=m.end(E)}return 0},T._tryNudgeBuffer=function(){var b=this.config,u=this.hls,a=this.media,l=a.currentTime,h=(this.nudgeRetry||0)+1;if(this.nudgeRetry=h,h<b.nudgeMaxRetry){var A=l+h*b.nudgeOffset;B.logger.warn("Nudging 'currentTime' from "+l+" to "+A),a.currentTime=A,u.trigger(P.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else B.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+b.nudgeMaxRetry+" nudges"),u.trigger(P.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},k}()},"./src/controller/id3-track-controller.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/events.ts"),I=_("./src/utils/texttrack-utils.ts"),P=_("./src/demux/id3.ts"),B=.25,N=function(){function O(f){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=f,this._registerListeners()}var R=O.prototype;return R.destroy=function(){this._unregisterListeners()},R._registerListeners=function(){var c=this.hls;c.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),c.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},R._unregisterListeners=function(){var c=this.hls;c.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),c.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},R.onMediaAttached=function(c,k){this.media=k.media},R.onMediaDetaching=function(){if(!this.id3Track)return;Object(I.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},R.getID3Track=function(c){if(!this.media)return;for(var k=0;k<c.length;k++){var T=c[k];if(T.kind==="metadata"&&T.label==="id3")return Object(I.sendAddTrackEvent)(T,this.media),T}return this.media.addTextTrack("metadata","id3")},R.onFragParsingMetadata=function(c,k){if(!this.media)return;var T=k.frag,g=k.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var b=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<g.length;u++){var a=P.getID3Frames(g[u].data);if(a){var l=g[u].pts,h=u<g.length-1?g[u+1].pts:T.end,A=h-l;A<=0&&(h=l+B);for(var m=0;m<a.length;m++){var E=a[m];if(!P.isTimeStampFrame(E)){var D=new b(l,h,"");D.value=E,this.id3Track.addCue(D)}}}}},R.onBufferFlushing=function(c,k){var T=k.startOffset,g=k.endOffset,b=k.type;if(!b||b==="audio"){var u=this.id3Track;u&&Object(I.removeCuesInRange)(u,T,g)}},O}();Y.default=N},"./src/controller/latency-controller.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return O});var V=_("./src/errors.ts"),I=_("./src/events.ts"),P=_("./src/utils/logger.ts");function B(R,f){for(var c=0;c<f.length;c++){var k=f[c];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(R,k.key,k)}}function N(R,f,c){return f&&B(R.prototype,f),c&&B(R,c),R}var O=function(){function R(c){var k=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 k.timeupdate()},this.hls=c,this.config=c.config,this.registerListeners()}var f=R.prototype;return f.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},f.registerListeners=function(){this.hls.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(I.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){this.hls.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(I.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(I.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(I.Events.ERROR,this.onError)},f.onMediaAttached=function(k,T){this.media=T.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},f.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},f.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},f.onLevelUpdated=function(k,T){var g=T.details;this.levelDetails=g,g.advanced&&this.timeupdate(),!g.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},f.onError=function(k,T){if(T.details!==V.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,P.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},f.timeupdate=function(){var k=this.media,T=this.levelDetails;if(!k||!T)return;this.currentTime=k.currentTime;var g=this.computeLatency();if(g===null)return;this._latency=g;var b=this.config,u=b.lowLatencyMode,a=b.maxLiveSyncPlaybackRate;if(!u||a===1)return;var l=this.targetLatency;if(l===null)return;var h=g-l,A=Math.min(this.maxLatency,l+T.targetduration),m=h<A;if(T.live&&m&&h>.05&&this.forwardBufferLength>1){var E=Math.min(2,Math.max(1,a)),D=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;k.playbackRate=Math.min(E,Math.max(1,D))}else k.playbackRate!==1&&k.playbackRate!==0&&(k.playbackRate=1)},f.estimateLiveEdge=function(){var k=this.levelDetails;return k===null?null:k.edge+k.age},f.computeLatency=function(){var k=this.estimateLiveEdge();return k===null?null:k-this.currentTime},N(R,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var k=this.config,T=this.levelDetails;return k.liveMaxLatencyDuration!==void 0?k.liveMaxLatencyDuration:T?k.liveMaxLatencyDurationCount*T.targetduration:0}},{key:"targetLatency",get:function(){var k=this.levelDetails;if(k===null)return null;var T=k.holdBack,g=k.partHoldBack,b=k.targetduration,u=this.config,a=u.liveSyncDuration,l=u.liveSyncDurationCount,h=u.lowLatencyMode,A=this.hls.userConfig,m=h&&g||T;(A.liveSyncDuration||A.liveSyncDurationCount||m===0)&&(m=a!==void 0?a:l*b);var E=b,D=1;return m+Math.min(this.stallCount*D,E)}},{key:"liveSyncPosition",get:function(){var k=this.estimateLiveEdge(),T=this.targetLatency,g=this.levelDetails;if(k===null||T===null||g===null)return null;var b=g.edge,u=k-T-this.edgeStalled,a=b-g.totalduration,l=b-(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.min(Math.max(a,u),l)}},{key:"drift",get:function(){var k=this.levelDetails;return k===null?1:k.drift}},{key:"edgeStalled",get:function(){var k=this.levelDetails;if(k===null)return 0;var T=(this.config.lowLatencyMode&&k.partTarget||k.targetduration)*3;return Math.max(k.age-T,0)}},{key:"forwardBufferLength",get:function(){var k=this.media,T=this.levelDetails;if(!k||!T)return 0;var g=k.buffered.length;return g?k.buffered.end(g-1):T.edge-this.currentTime}}]),R}()},"./src/controller/level-controller.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return u});var V=_("./src/types/level.ts"),I=_("./src/events.ts"),P=_("./src/errors.ts"),B=_("./src/utils/codecs.ts"),N=_("./src/controller/level-helper.ts"),O=_("./src/controller/base-playlist-controller.ts"),R=_("./src/types/loader.ts");function f(){return f=Object.assign||function(a){for(var l=1;l<arguments.length;l++){var h=arguments[l];for(var A in h)Object.prototype.hasOwnProperty.call(h,A)&&(a[A]=h[A])}return a},f.apply(this,arguments)}function c(a,l){for(var h=0;h<l.length;h++){var A=l[h];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(a,A.key,A)}}function k(a,l,h){return l&&c(a.prototype,l),h&&c(a,h),a}function T(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,g(a,l)}function g(a,l){return g=Object.setPrototypeOf||function(A,m){return A.__proto__=m,A},g(a,l)}var b=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(a){T(l,a);function l(A){var m;return m=a.call(this,A,"[level-controller]")||this,m._levels=[],m._firstLevel=-1,m._startLevel=void 0,m.currentLevelIndex=-1,m.manualLevelIndex=-1,m.onParsedComplete=void 0,m._registerListeners(),m}var h=l.prototype;return h._registerListeners=function(){var m=this.hls;m.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),m.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.on(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),m.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),m.on(I.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var m=this.hls;m.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),m.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.off(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),m.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),m.off(I.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,a.prototype.destroy.call(this)},h.startLoad=function(){var m=this._levels;m.forEach(function(E){E.loadError=0}),a.prototype.startLoad.call(this)},h.onManifestLoaded=function(m,E){var D=[],w=[],y=[],p,d={},o,C=!1,S=!1,x=!1;if(E.levels.forEach(function(J){var K=J.attrs;C=C||!!(J.width&&J.height),S=S||!!J.videoCodec,x=x||!!J.audioCodec,b&&J.audioCodec&&J.audioCodec.indexOf("mp4a.40.34")!==-1&&(J.audioCodec=void 0);var j=J.bitrate+"-"+J.attrs.RESOLUTION+"-"+J.attrs.CODECS;o=d[j],o?o.url.push(J.url):(o=new V.Level(J),d[j]=o,D.push(o)),K&&(K.AUDIO&&Object(N.addGroupId)(o,"audio",K.AUDIO),K.SUBTITLES&&Object(N.addGroupId)(o,"text",K.SUBTITLES))}),(C||S)&&x&&(D=D.filter(function(J){var K=J.videoCodec,j=J.width,q=J.height;return!!K||!!(j&&q)})),D=D.filter(function(J){var K=J.audioCodec,j=J.videoCodec;return(!K||Object(B.isCodecSupportedInMp4)(K,"audio"))&&(!j||Object(B.isCodecSupportedInMp4)(j,"video"))}),E.audioTracks&&(w=E.audioTracks.filter(function(J){return!J.audioCodec||Object(B.isCodecSupportedInMp4)(J.audioCodec,"audio")}),Object(N.assignTrackIdsByGroup)(w)),E.subtitles&&(y=E.subtitles,Object(N.assignTrackIdsByGroup)(y)),D.length>0){p=D[0].bitrate,D.sort(function(J,K){return J.bitrate-K.bitrate}),this._levels=D;for(var M=0;M<D.length;M++)if(D[M].bitrate===p){this._firstLevel=M,this.log("manifest loaded, "+D.length+" level(s) found, first bitrate: "+p);break}var F=x&&!S,G={levels:D,audioTracks:w,subtitleTracks:y,firstLevel:this._firstLevel,stats:E.stats,audio:x,video:S,altAudio:!F&&w.some(function(J){return!!J.url})};this.hls.trigger(I.Events.MANIFEST_PARSED,G),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(I.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:E.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(m,E){if(a.prototype.onError.call(this,m,E),E.fatal)return;var D=E.context,w=this._levels[this.currentLevelIndex];if(D&&(D.type===R.PlaylistContextType.AUDIO_TRACK&&w.audioGroupIds&&D.groupId===w.audioGroupIds[w.urlId]||D.type===R.PlaylistContextType.SUBTITLE_TRACK&&w.textGroupIds&&D.groupId===w.textGroupIds[w.urlId])){this.redundantFailover(this.currentLevelIndex);return}var y=!1,p=!0,d;switch(E.details){case P.ErrorDetails.FRAG_LOAD_ERROR:case P.ErrorDetails.FRAG_LOAD_TIMEOUT:case P.ErrorDetails.KEY_LOAD_ERROR:case P.ErrorDetails.KEY_LOAD_TIMEOUT:if(E.frag){var o=this._levels[E.frag.level];o?(o.fragmentError++,o.fragmentError>this.hls.config.fragLoadingMaxRetry&&(d=E.frag.level)):d=E.frag.level}break;case P.ErrorDetails.LEVEL_LOAD_ERROR:case P.ErrorDetails.LEVEL_LOAD_TIMEOUT:D&&(D.deliveryDirectives&&(p=!1),d=D.level),y=!0;break;case P.ErrorDetails.REMUX_ALLOC_ERROR:d=E.level,y=!0;break}d!==void 0&&this.recoverLevel(E,d,y,p)},h.recoverLevel=function(m,E,D,w){var y=m.details,p=this._levels[E];if(p.loadError++,D){var d=this.retryLoadingOrFail(m);if(d)m.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(w){var o=p.url.length;if(o>1&&p.loadError<o)m.levelRetry=!0,this.redundantFailover(E);else if(this.manualLevelIndex===-1){var C=E===0?this._levels.length-1:E-1;this.currentLevelIndex!==C&&this._levels[C].loadError===0&&(this.warn(y+": switch to "+C),m.levelRetry=!0,this.hls.nextAutoLevel=C)}}},h.redundantFailover=function(m){var E=this._levels[m],D=E.url.length;if(D>1){var w=(E.urlId+1)%D;this.warn("Switching to redundant URL-id "+w),this._levels.forEach(function(y){y.urlId=w}),this.level=m}},h.onFragLoaded=function(m,E){var D=E.frag;if(D!==void 0&&D.type===R.PlaylistLevelType.MAIN){var w=this._levels[D.level];w!==void 0&&(w.fragmentError=0,w.loadError=0)}},h.onLevelLoaded=function(m,E){var D,w=E.level,y=E.details,p=this._levels[w];if(!p){var d;this.warn("Invalid level index "+w),(d=E.deliveryDirectives)!==null&&d!==void 0&&d.skip&&(y.deltaUpdateFailed=!0);return}w===this.currentLevelIndex?(p.fragmentError===0&&(p.loadError=0,this.retryCount=0),this.playlistLoaded(w,E,p.details)):(D=E.deliveryDirectives)!==null&&D!==void 0&&D.skip&&(y.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(m,E){var D=this.hls.levels[this.currentLevelIndex];if(!D)return;if(D.audioGroupIds){for(var w=-1,y=this.hls.audioTracks[E.id].groupId,p=0;p<D.audioGroupIds.length;p++)if(D.audioGroupIds[p]===y){w=p;break}w!==D.urlId&&(D.urlId=w,this.startLoad())}},h.loadPlaylist=function(m){var E=this.currentLevelIndex,D=this._levels[E];if(this.canLoad&&D&&D.url.length>0){var w=D.urlId,y=D.url[w];if(m)try{y=m.addDirectives(y)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Attempt loading level index "+E+(m?" at sn "+m.msn+" part "+m.part:"")+" with URL-id "+w+" "+y),this.clearTimer(),this.hls.trigger(I.Events.LEVEL_LOADING,{url:y,level:E,id:w,deliveryDirectives:m||null})}},h.removeLevel=function(m,E){var D=function(p,d){return d!==E},w=this._levels.filter(function(y,p){return p!==m?!0:y.url.length>1&&E!==void 0?(y.url=y.url.filter(D),y.audioGroupIds&&(y.audioGroupIds=y.audioGroupIds.filter(D)),y.textGroupIds&&(y.textGroupIds=y.textGroupIds.filter(D)),y.urlId=0,!0):!1}).map(function(y,p){var d=y.details;return d!=null&&d.fragments&&d.fragments.forEach(function(o){o.level=p}),y});this._levels=w,this.hls.trigger(I.Events.LEVELS_UPDATED,{levels:w})},k(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(m){var E,D=this._levels;if(D.length===0)return;if(this.currentLevelIndex===m&&(E=D[m])!==null&&E!==void 0&&E.details)return;if(m<0||m>=D.length){var w=m<0;if(this.hls.trigger(I.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.LEVEL_SWITCH_ERROR,level:m,fatal:w,reason:"invalid level idx"}),w)return;m=Math.min(m,D.length-1)}this.clearTimer();var y=this.currentLevelIndex,p=D[y],d=D[m];this.log("switching to level "+m+" from "+y),this.currentLevelIndex=m;var o=f({},d,{level:m,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete o._urlId,this.hls.trigger(I.Events.LEVEL_SWITCHING,o);var C=d.details;if(!C||C.live){var S=this.switchParams(d.uri,p==null?void 0:p.details);this.loadPlaylist(S)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(m){this.manualLevelIndex=m,this._startLevel===void 0&&(this._startLevel=m),m!==-1&&(this.level=m)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(m){this._firstLevel=m}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var m=this.hls.config.startLevel;return m!==void 0?m:this._firstLevel}else return this._startLevel},set:function(m){this._startLevel=m}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(m){this.level=m,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=m)}}]),l}(O.default)},"./src/controller/level-helper.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"addGroupId",function(){return P}),_.d(Y,"assignTrackIdsByGroup",function(){return B}),_.d(Y,"updatePTS",function(){return N}),_.d(Y,"updateFragPTSDTS",function(){return R}),_.d(Y,"mergeDetails",function(){return f}),_.d(Y,"mapPartIntersection",function(){return c}),_.d(Y,"mapFragmentIntersection",function(){return k}),_.d(Y,"adjustSliding",function(){return T}),_.d(Y,"addSliding",function(){return g}),_.d(Y,"computeReloadInterval",function(){return b}),_.d(Y,"getFragmentWithSN",function(){return u}),_.d(Y,"getPartWith",function(){return a});var V=_("./src/polyfills/number.ts"),I=_("./src/utils/logger.ts");function P(l,h,A){switch(h){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(A);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(A);break}}function B(l){var h={};l.forEach(function(A){var m=A.groupId||"";A.id=h[m]=h[m]||0,h[m]++})}function N(l,h,A){var m=l[h],E=l[A];O(m,E)}function O(l,h){var A=h.startPTS;if(Object(V.isFiniteNumber)(A)){var m=0,E;h.sn>l.sn?(m=A-l.start,E=l):(m=l.start-A,E=h),E.duration!==m&&(E.duration=m)}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 R(l,h,A,m,E,D){var w=m-A;w<=0&&(I.logger.warn("Fragment should have a positive duration",h),m=A+h.duration,D=E+h.duration);var y=A,p=m,d=h.startPTS,o=h.endPTS;if(Object(V.isFiniteNumber)(d)){var C=Math.abs(d-A);Object(V.isFiniteNumber)(h.deltaPTS)?h.deltaPTS=Math.max(C,h.deltaPTS):h.deltaPTS=C,y=Math.max(A,d),A=Math.min(A,d),E=Math.min(E,h.startDTS),p=Math.min(m,o),m=Math.max(m,o),D=Math.max(D,h.endDTS)}h.duration=m-A;var S=A-h.start;h.appendedPTS=m,h.start=h.startPTS=A,h.maxStartPTS=y,h.startDTS=E,h.endPTS=m,h.minEndPTS=p,h.endDTS=D;var x=h.sn;if(!l||x<l.startSN||x>l.endSN)return 0;var M,F=x-l.startSN,G=l.fragments;for(G[F]=h,M=F;M>0;M--)O(G[M],G[M-1]);for(M=F;M<G.length-1;M++)O(G[M],G[M+1]);return l.fragmentHint&&O(G[G.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,S}function f(l,h){for(var A=null,m=l.fragments,E=m.length-1;E>=0;E--){var D=m[E].initSegment;if(D){A=D;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var w=0,y;if(k(l,h,function(M,F){M.relurl&&(w=M.cc-F.cc),Object(V.isFiniteNumber)(M.startPTS)&&Object(V.isFiniteNumber)(M.endPTS)&&(F.start=F.startPTS=M.startPTS,F.startDTS=M.startDTS,F.appendedPTS=M.appendedPTS,F.maxStartPTS=M.maxStartPTS,F.endPTS=M.endPTS,F.endDTS=M.endDTS,F.minEndPTS=M.minEndPTS,F.duration=M.endPTS-M.startPTS,F.duration&&(y=F),h.PTSKnown=h.alignedSliding=!0),F.elementaryStreams=M.elementaryStreams,F.loader=M.loader,F.stats=M.stats,F.urlId=M.urlId,M.initSegment&&(F.initSegment=M.initSegment,A=M.initSegment)}),A){var p=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments;p.forEach(function(M){var F;(!M.initSegment||M.initSegment.relurl===((F=A)===null||F===void 0?void 0:F.relurl))&&(M.initSegment=A)})}if(h.skippedSegments&&(h.deltaUpdateFailed=h.fragments.some(function(M){return!M}),h.deltaUpdateFailed)){I.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 o=h.fragments;if(w){I.logger.warn("discontinuity sliding from playlist, take drift into account");for(var C=0;C<o.length;C++)o[C].cc+=w}h.skippedSegments&&(h.startCC=h.fragments[0].cc),c(l.partList,h.partList,function(M,F){F.elementaryStreams=M.elementaryStreams,F.stats=M.stats}),y?R(h,y,y.startPTS,y.endPTS,y.startDTS,y.endDTS):T(l,h),o.length&&(h.totalduration=h.edge-o[0].start),h.driftStartTime=l.driftStartTime,h.driftStart=l.driftStart;var S=h.advancedDateTime;if(h.advanced&&S){var x=h.edge;h.driftStart||(h.driftStartTime=S,h.driftStart=x),h.driftEndTime=S,h.driftEnd=x}else h.driftEndTime=l.driftEndTime,h.driftEnd=l.driftEnd,h.advancedDateTime=l.advancedDateTime}function c(l,h,A){if(l&&h)for(var m=0,E=0,D=l.length;E<=D;E++){var w=l[E],y=h[E+m];w&&y&&w.index===y.index&&w.fragment.sn===y.fragment.sn?A(w,y):m--}}function k(l,h,A){for(var m=h.skippedSegments,E=Math.max(l.startSN,h.startSN)-h.startSN,D=(l.fragmentHint?1:0)+(m?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,w=h.startSN-l.startSN,y=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,p=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,d=E;d<=D;d++){var o=p[w+d],C=y[d];m&&!C&&d<m&&(C=h.fragments[d]=o),o&&C&&A(o,C)}}function T(l,h){var A=h.startSN+h.skippedSegments-l.startSN,m=l.fragments;if(A<0||A>=m.length)return;g(h,m[A].start)}function g(l,h){if(h){for(var A=l.fragments,m=l.skippedSegments;m<A.length;m++)A[m].start+=h;l.fragmentHint&&(l.fragmentHint.start+=h)}}function b(l,h){var A=1e3*l.levelTargetDuration,m=A/2,E=l.age,D=E>0&&E<A*3,w=h.loading.end-h.loading.start,y,p=l.availabilityDelay;if(l.updated===!1)if(D){var d=333*l.misses;y=Math.max(Math.min(m,w*2),d),l.availabilityDelay=(l.availabilityDelay||0)+y}else y=m;else D?(p=Math.min(p||A/2,E),l.availabilityDelay=p,y=p+A-E):y=A-w;return Math.round(y)}function u(l,h,A){if(!l||!l.details)return null;var m=l.details,E=m.fragments[h-m.startSN];return E||(E=m.fragmentHint,E&&E.sn===h?E:h<m.startSN&&A&&A.sn===h?A:null)}function a(l,h,A){if(!l||!l.details)return null;var m=l.details.partList;if(m)for(var E=m.length;E--;){var D=m[E];if(D.index===A&&D.fragment.sn===h)return D}return null}},"./src/controller/stream-controller.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return m});var V=_("./src/polyfills/number.ts"),I=_("./src/controller/base-stream-controller.ts"),P=_("./src/is-supported.ts"),B=_("./src/events.ts"),N=_("./src/utils/buffer-helper.ts"),O=_("./src/controller/fragment-tracker.ts"),R=_("./src/types/loader.ts"),f=_("./src/loader/fragment.ts"),c=_("./src/demux/transmuxer-interface.ts"),k=_("./src/types/transmuxer.ts"),T=_("./src/controller/gap-controller.ts"),g=_("./src/errors.ts"),b=_("./src/utils/logger.ts");function u(E,D){for(var w=0;w<D.length;w++){var y=D[w];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(E,y.key,y)}}function a(E,D,w){return D&&u(E.prototype,D),w&&u(E,w),E}function l(E,D){E.prototype=Object.create(D.prototype),E.prototype.constructor=E,h(E,D)}function h(E,D){return h=Object.setPrototypeOf||function(y,p){return y.__proto__=p,y},h(E,D)}var A=100,m=function(E){l(D,E);function D(y,p){var d;return d=E.call(this,y,p,"[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 w=D.prototype;return w._registerListeners=function(){var p=this.hls;p.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),p.on(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(B.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.on(B.Events.ERROR,this.onError,this),p.on(B.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.on(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.on(B.Events.BUFFER_CREATED,this.onBufferCreated,this),p.on(B.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.on(B.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.on(B.Events.FRAG_BUFFERED,this.onFragBuffered,this)},w._unregisterListeners=function(){var p=this.hls;p.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.off(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(B.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.off(B.Events.ERROR,this.onError,this),p.off(B.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.off(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.off(B.Events.BUFFER_CREATED,this.onBufferCreated,this),p.off(B.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.off(B.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.off(B.Events.FRAG_BUFFERED,this.onFragBuffered,this)},w.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},w.startLoad=function(p){if(this.levels){var d=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(A),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var C=o.startLevel;C===-1&&(o.config.testBandwidth?(C=0,this.bitrateTest=!0):C=o.nextAutoLevel),this.level=o.nextLoadLevel=C,this.loadedmetadata=!1}d>0&&p===-1&&(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),p=d),this.state=I.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=p,this.tick()}else this._forceStartLoad=!0,this.state=I.State.STOPPED},w.stopLoad=function(){this._forceStartLoad=!1,E.prototype.stopLoad.call(this)},w.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_LEVEL:{var p,d=this.levels,o=this.level,C=d==null||((p=d[o])===null||p===void 0)?void 0:p.details;if(C&&(!C.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(C))break;this.state=I.State.IDLE;break}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var S,x=self.performance.now(),M=this.retryDate;(!M||x>=M||(S=this.media)!==null&&S!==void 0&&S.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=I.State.IDLE)}break;default:break}this.onTickEnd()},w.onTickEnd=function(){E.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},w.doTickIdle=function(){var p,d,o=this.hls,C=this.levelLastLoaded,S=this.levels,x=this.media,M=o.config,F=o.nextLoadLevel;if(C===null||!x&&(this.startFragRequested||!M.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!S||!S[F])return;var G=S[F];this.level=o.nextLoadLevel=F;var J=G.details;if(!J||this.state===I.State.WAITING_LEVEL||J.live&&this.levelLastLoaded!==F){this.state=I.State.WAITING_LEVEL;return}var K=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:x,R.PlaylistLevelType.MAIN);if(K===null)return;var j=K.len,q=this.getMaxBufferLength(G.maxBitrate);if(j>=q)return;if(this._streamEnded(K,J)){var oe={};this.altAudio&&(oe.type="video"),this.hls.trigger(B.Events.BUFFER_EOS,oe),this.state=I.State.ENDED;return}var ue=K.end,ge=this.getNextFragment(ue,J);if(this.couldBacktrack&&!this.fragPrevious&&ge&&ge.sn!=="initSegment"){var _e=ge.sn-J.startSN;_e>1&&(ge=J.fragments[_e-1],this.fragmentTracker.removeFragment(ge))}if(ge&&this.fragmentTracker.getState(ge)===O.FragmentState.OK&&this.nextLoadPosition>ue){var be=this.audioOnly&&!this.altAudio?f.ElementaryStreamTypes.AUDIO:f.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(x,be,R.PlaylistLevelType.MAIN),ge=this.getNextFragment(this.nextLoadPosition,J)}if(!ge)return;ge.initSegment&&!ge.initSegment.data&&!this.bitrateTest&&(ge=ge.initSegment),((p=ge.decryptdata)===null||p===void 0?void 0:p.keyFormat)==="identity"&&!((d=ge.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(ge,J):this.loadFragment(ge,J,ue)},w.loadFragment=function(p,d,o){var C,S=this.fragmentTracker.getState(p);if(this.fragCurrent=p,S===O.FragmentState.BACKTRACKED){var x=this.fragmentTracker.getBacktrackData(p);if(x){this._handleFragmentLoadProgress(x),this._handleFragmentLoadComplete(x);return}else S=O.FragmentState.NOT_LOADED}S===O.FragmentState.NOT_LOADED||S===O.FragmentState.PARTIAL?p.sn==="initSegment"?this._loadInitSegment(p):this.bitrateTest?(p.bitrateTest=!0,this.log("Fragment "+p.sn+" of level "+p.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(p)):(this.startFragRequested=!0,E.prototype.loadFragment.call(this,p,d,o)):S===O.FragmentState.APPENDING?this.reduceMaxBufferLength(p.duration)&&this.fragmentTracker.removeFragment(p):((C=this.media)===null||C===void 0?void 0:C.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},w.getAppendedFrag=function(p){var d=this.fragmentTracker.getAppendedFrag(p,R.PlaylistLevelType.MAIN);return d&&"fragment"in d?d.fragment:d},w.getBufferedFrag=function(p){return this.fragmentTracker.getBufferedFrag(p,R.PlaylistLevelType.MAIN)},w.followingBufferedFrag=function(p){return p?this.getBufferedFrag(p.end+.5):null},w.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},w.nextLevelSwitch=function(){var p=this.levels,d=this.media;if(d!=null&&d.readyState){var o,C=this.getAppendedFrag(d.currentTime);if(C&&C.start>1&&this.flushMainBuffer(0,C.start-1),!d.paused&&p){var S=this.hls.nextLoadLevel,x=p[S],M=this.fragLastKbps;M&&this.fragCurrent?o=this.fragCurrent.duration*x.maxBitrate/(1e3*M)+1:o=0}else o=0;var F=this.getBufferedFrag(d.currentTime+o);if(F){var G=this.followingBufferedFrag(F);if(G){this.abortCurrentFrag();var J=G.maxStartPTS?G.maxStartPTS:G.start,K=G.duration,j=Math.max(F.end,J+Math.min(Math.max(K-this.config.maxFragLookUpTolerance,K*.5),K*.75));this.flushMainBuffer(j,Number.POSITIVE_INFINITY)}}}},w.abortCurrentFrag=function(){var p=this.fragCurrent;this.fragCurrent=null,p!=null&&p.loader&&p.loader.abort(),this.state===I.State.KEY_LOADING&&(this.state=I.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},w.flushMainBuffer=function(p,d){E.prototype.flushMainBuffer.call(this,p,d,this.altAudio?"video":null)},w.onMediaAttached=function(p,d){E.prototype.onMediaAttached.call(this,p,d);var o=d.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new T.default(this.config,o,this.fragmentTracker,this.hls)},w.onMediaDetaching=function(){var p=this.media;p&&(p.removeEventListener("playing",this.onvplaying),p.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),E.prototype.onMediaDetaching.call(this)},w.onMediaPlaying=function(){this.tick()},w.onMediaSeeked=function(){var p=this.media,d=p?p.currentTime:null;Object(V.isFiniteNumber)(d)&&this.log("Media seeked to "+d.toFixed(3)),this.tick()},w.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(B.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},w.onManifestParsed=function(p,d){var o=!1,C=!1,S;d.levels.forEach(function(x){S=x.audioCodec,S&&(S.indexOf("mp4a.40.2")!==-1&&(o=!0),S.indexOf("mp4a.40.5")!==-1&&(C=!0))}),this.audioCodecSwitch=o&&C&&!Object(P.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},w.onLevelLoading=function(p,d){var o=this.levels;if(!o||this.state!==I.State.IDLE)return;var C=o[d.level];(!C.details||C.details.live&&this.levelLastLoaded!==d.level||this.waitForCdnTuneIn(C.details))&&(this.state=I.State.WAITING_LEVEL)},w.onLevelLoaded=function(p,d){var o,C=this.levels,S=d.level,x=d.details,M=x.totalduration;if(!C){this.warn("Levels were reset while loading level "+S);return}this.log("Level "+S+" loaded ["+x.startSN+","+x.endSN+"], cc ["+x.startCC+", "+x.endCC+"] duration:"+M);var F=this.fragCurrent;F&&(this.state===I.State.FRAG_LOADING||this.state===I.State.FRAG_LOADING_WAITING_RETRY)&&(F.level!==d.level&&F.loader&&(this.state=I.State.IDLE,F.loader.abort()));var G=C[S],J=0;if(x.live||(o=G.details)!==null&&o!==void 0&&o.live){if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed)return;J=this.alignPlaylists(x,G.details)}if(G.details=x,this.levelLastLoaded=S,this.hls.trigger(B.Events.LEVEL_UPDATED,{details:x,level:S}),this.state===I.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(x))return;this.state=I.State.IDLE}this.startFragRequested?x.live&&this.synchronizeToLiveEdge(x):this.setStartPosition(x,J),this.tick()},w._handleFragmentLoadProgress=function(p){var d,o=p.frag,C=p.part,S=p.payload,x=this.levels;if(!x){this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var M=x[o.level],F=M.details;if(!F){this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset");return}var G=M.videoCodec,J=F.PTSKnown||!F.live,K=(d=o.initSegment)===null||d===void 0?void 0:d.data,j=this._getAudioCodec(M),q=this.transmuxer=this.transmuxer||new c.default(this.hls,R.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),oe=C?C.index:-1,ue=oe!==-1,ge=new k.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,S.byteLength,oe,ue),_e=this.initPTS[o.cc];q.push(S,K,j,G,o,C,F.totalduration,J,ge,_e)},w.onAudioTrackSwitching=function(p,d){var o=this.altAudio,C=!!d.url,S=d.id;if(!C){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var x=this.fragCurrent;x!=null&&x.loader&&(this.log("Switching to main audio track, cancel main fragment load"),x.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var M=this.hls;o&&M.trigger(B.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),M.trigger(B.Events.AUDIO_TRACK_SWITCHED,{id:S})}},w.onAudioTrackSwitched=function(p,d){var o=d.id,C=!!this.hls.audioTracks[o].url;if(C){var S=this.videoBuffer;S&&this.mediaBuffer!==S&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=S)}this.altAudio=C,this.tick()},w.onBufferCreated=function(p,d){var o=d.tracks,C,S,x=!1;for(var M in o){var F=o[M];if(F.id==="main"){if(S=M,C=F,M==="video"){var G=o[M];G&&(this.videoBuffer=G.buffer)}}else x=!0}x&&C?(this.log("Alternate track found, use "+S+".buffered to schedule main fragment loading"),this.mediaBuffer=C.buffer):this.mediaBuffer=this.media},w.onFragBuffered=function(p,d){var o=d.frag,C=d.part;if(o&&o.type!==R.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(C?" p: "+C.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),this.state===I.State.PARSED&&(this.state=I.State.IDLE);return}var S=C?C.stats:o.stats;this.fragLastKbps=Math.round(8*S.total/(S.buffering.end-S.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,C)},w.onError=function(p,d){switch(d.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(R.PlaylistLevelType.MAIN,d);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==I.State.ERROR&&(d.fatal?(this.warn(""+d.details),this.state=I.State.ERROR):!d.levelRetry&&this.state===I.State.WAITING_LEVEL&&(this.state=I.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="main"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var o=!0,C=this.getFwdBufferInfo(this.media,R.PlaylistLevelType.MAIN);C&&C.len>.5&&(o=!this.reduceMaxBufferLength(C.len)),o&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},w.checkBuffer=function(){var p=this.media,d=this.gapController;if(!p||!d||!p.readyState)return;var o=N.BufferHelper.getBuffered(p);!this.loadedmetadata&&o.length?(this.loadedmetadata=!0,this.seekToStartPos()):d.poll(this.lastCurrentTime),this.lastCurrentTime=p.currentTime},w.onFragLoadEmergencyAborted=function(){this.state=I.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},w.onBufferFlushed=function(p,d){var o=d.type;if(o!==f.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var C=(o===f.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(C,o,R.PlaylistLevelType.MAIN)}},w.onLevelsUpdated=function(p,d){this.levels=d.levels},w.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},w.seekToStartPos=function(){var p=this.media,d=p.currentTime,o=this.startPosition;if(o>=0&&d<o){if(p.seeking){b.logger.log("could not seek to "+o+", already seeking at "+d);return}var C=N.BufferHelper.getBuffered(p),S=C.length?C.start(0):0,x=S-o;x>0&&(x<this.config.maxBufferHole||x<this.config.maxFragLookUpTolerance)&&(b.logger.log("adjusting start position by "+x+" to match buffer start"),o+=x,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+d),p.currentTime=o}},w._getAudioCodec=function(p){var d=this.config.defaultAudioCodec||p.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},w._loadBitrateTestFrag=function(p){var d=this;this._doFragLoad(p).then(function(o){var C=d.hls;if(!o||C.nextLoadLevel||d.fragContextChanged(p))return;d.fragLoadError=0,d.state=I.State.IDLE,d.startFragRequested=!1,d.bitrateTest=!1;var S=p.stats;S.parsing.start=S.parsing.end=S.buffering.start=S.buffering.end=self.performance.now(),C.trigger(B.Events.FRAG_LOADED,o)})},w._handleTransmuxComplete=function(p){var d,o="main",C=this.hls,S=p.remuxResult,x=p.chunkMeta,M=this.getCurrentContext(x);if(!M){this.warn("The loading context changed while buffering fragment "+x.sn+" of level "+x.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(x.level);return}var F=M.frag,G=M.part,J=M.level,K=S.video,j=S.text,q=S.id3,oe=S.initSegment,ue=this.altAudio?void 0:S.audio;if(this.fragContextChanged(F))return;if(this.state=I.State.PARSING,oe){oe.tracks&&(this._bufferInitSegment(J,oe.tracks,F,x),C.trigger(B.Events.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:o,tracks:oe.tracks}));var ge=oe.initPTS,_e=oe.timescale;Object(V.isFiniteNumber)(ge)&&(this.initPTS[F.cc]=ge,C.trigger(B.Events.INIT_PTS_FOUND,{frag:F,id:o,initPTS:ge,timescale:_e}))}if(K&&S.independent!==!1){if(J.details){var be=K.startPTS,Se=K.endPTS,Te=K.startDTS,Ce=K.endDTS;if(G)G.elementaryStreams[K.type]={startPTS:be,endPTS:Se,startDTS:Te,endDTS:Ce};else if(K.firstKeyFrame&&K.independent&&(this.couldBacktrack=!0),K.dropped&&K.independent){var pe=this.getLoadPosition()+this.config.maxBufferHole;if(pe<be){this.backtrack(F);return}F.setElementaryStreamInfo(K.type,F.start,Se,F.start,Ce,!0)}F.setElementaryStreamInfo(K.type,be,Se,Te,Ce),this.bufferFragmentData(K,F,G,x)}}else if(S.independent===!1){this.backtrack(F);return}if(ue){var se=ue.startPTS,Re=ue.endPTS,Je=ue.startDTS,Xe=ue.endDTS;G&&(G.elementaryStreams[f.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:Re,startDTS:Je,endDTS:Xe}),F.setElementaryStreamInfo(f.ElementaryStreamTypes.AUDIO,se,Re,Je,Xe),this.bufferFragmentData(ue,F,G,x)}if(q!=null&&(d=q.samples)!==null&&d!==void 0&&d.length){var Ze={frag:F,id:o,samples:q.samples};C.trigger(B.Events.FRAG_PARSING_METADATA,Ze)}if(j){var Ke={frag:F,id:o,samples:j.samples};C.trigger(B.Events.FRAG_PARSING_USERDATA,Ke)}},w._bufferInitSegment=function(p,d,o,C){var S=this;if(this.state!==I.State.PARSING)return;this.audioOnly=!!d.audio&&!d.video,this.altAudio&&!this.audioOnly&&delete d.audio;var x=d.audio,M=d.video,F=d.audiovideo;if(x){var G=p.audioCodec,J=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(G&&(G.indexOf("mp4a.40.5")!==-1?G="mp4a.40.2":G="mp4a.40.5"),x.metadata.channelCount!==1&&J.indexOf("firefox")===-1&&(G="mp4a.40.5")),J.indexOf("android")!==-1&&x.container!=="audio/mpeg"&&(G="mp4a.40.2",this.log("Android: force audio codec to "+G)),p.audioCodec&&p.audioCodec!==G&&this.log('Swapping manifest audio codec "'+p.audioCodec+'" for "'+G+'"'),x.levelCodec=G,x.id="main",this.log("Init audio buffer, container:"+x.container+", codecs[selected/level/parsed]=["+(G||"")+"/"+(p.audioCodec||"")+"/"+x.codec+"]")}M&&(M.levelCodec=p.videoCodec,M.id="main",this.log("Init video buffer, container:"+M.container+", codecs[level/parsed]=["+(p.videoCodec||"")+"/"+M.codec+"]")),F&&this.log("Init audiovideo buffer, container:"+F.container+", codecs[level/parsed]=["+(p.attrs.CODECS||"")+"/"+F.codec+"]"),this.hls.trigger(B.Events.BUFFER_CODECS,d),Object.keys(d).forEach(function(K){var j=d[K],q=j.initSegment;q!=null&&q.byteLength&&S.hls.trigger(B.Events.BUFFER_APPENDING,{type:K,data:q,frag:o,part:null,chunkMeta:C,parent:o.type})}),this.tick()},w.backtrack=function(p){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(p);var d=this.fragmentTracker.backtrack(p);this.fragPrevious=null,this.nextLoadPosition=p.start,d?this.resetFragmentLoading(p):this.state=I.State.BACKTRACKING},w.checkFragmentChanged=function(){var p=this.media,d=null;if(p&&p.readyState>1&&p.seeking===!1){var o=p.currentTime;if(N.BufferHelper.isBuffered(p,o)?d=this.getAppendedFrag(o):N.BufferHelper.isBuffered(p,o+.1)&&(d=this.getAppendedFrag(o+.1)),d){var C=this.fragPlaying,S=d.level;(!C||d.sn!==C.sn||C.level!==S||d.urlId!==C.urlId)&&(this.hls.trigger(B.Events.FRAG_CHANGED,{frag:d}),(!C||C.level!==S)&&this.hls.trigger(B.Events.LEVEL_SWITCHED,{level:S}),this.fragPlaying=d)}}},a(D,[{key:"nextLevel",get:function(){var p=this.nextBufferedFrag;return p?p.level:-1}},{key:"currentLevel",get:function(){var p=this.media;if(p){var d=this.getAppendedFrag(p.currentTime);if(d)return d.level}return-1}},{key:"nextBufferedFrag",get:function(){var p=this.media;if(p){var d=this.getAppendedFrag(p.currentTime);return this.followingBufferedFrag(d)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),D}(I.default)},"./src/controller/subtitle-stream-controller.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"SubtitleStreamController",function(){return l});var V=_("./src/events.ts"),I=_("./src/utils/logger.ts"),P=_("./src/utils/buffer-helper.ts"),B=_("./src/controller/fragment-finders.ts"),N=_("./src/utils/discontinuities.ts"),O=_("./src/controller/level-helper.ts"),R=_("./src/controller/fragment-tracker.ts"),f=_("./src/controller/base-stream-controller.ts"),c=_("./src/types/loader.ts"),k=_("./src/types/level.ts");function T(h,A){for(var m=0;m<A.length;m++){var E=A[m];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(h,E.key,E)}}function g(h,A,m){return A&&T(h.prototype,A),m&&T(h,m),h}function b(h,A){h.prototype=Object.create(A.prototype),h.prototype.constructor=h,u(h,A)}function u(h,A){return u=Object.setPrototypeOf||function(E,D){return E.__proto__=D,E},u(h,A)}var a=500,l=function(h){b(A,h);function A(E,D){var w;return w=h.call(this,E,D,"[subtitle-stream-controller]")||this,w.levels=[],w.currentTrackId=-1,w.tracksBuffered=[],w.mainDetails=null,w._registerListeners(),w}var m=A.prototype;return m.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},m._registerListeners=function(){var D=this.hls;D.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),D.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),D.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),D.on(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),D.on(V.Events.ERROR,this.onError,this),D.on(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),D.on(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),D.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),D.on(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),D.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},m._unregisterListeners=function(){var D=this.hls;D.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),D.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),D.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),D.off(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),D.off(V.Events.ERROR,this.onError,this),D.off(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),D.off(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),D.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),D.off(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),D.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},m.startLoad=function(){this.stopLoad(),this.state=f.State.IDLE,this.setInterval(a),this.tick()},m.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},m.onLevelLoaded=function(D,w){this.mainDetails=w.details},m.onSubtitleFragProcessed=function(D,w){var y=w.frag,p=w.success;if(this.fragPrevious=y,this.state=f.State.IDLE,!p)return;var d=this.tracksBuffered[this.currentTrackId];if(!d)return;for(var o,C=y.start,S=0;S<d.length;S++)if(C>=d[S].start&&C<=d[S].end){o=d[S];break}var x=y.start+y.duration;o?o.end=x:(o={start:C,end:x},d.push(o)),this.fragmentTracker.fragBuffered(y)},m.onBufferFlushing=function(D,w){var y=w.startOffset,p=w.endOffset;if(y===0&&p!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,o=this.levels;if(!o.length||!o[d]||!o[d].details)return;var C=o[d].details,S=C.targetduration,x=p-S;if(x<=0)return;w.endOffsetSubtitles=Math.max(0,x),this.tracksBuffered.forEach(function(M){for(var F=0;F<M.length;){if(M[F].end<=x){M.shift();continue}else if(M[F].start<x)M[F].start=x;else break;F++}}),this.fragmentTracker.removeFragmentsInRange(y,x,c.PlaylistLevelType.SUBTITLE)}},m.onError=function(D,w){var y,p=w.frag;if(!p||p.type!==c.PlaylistLevelType.SUBTITLE)return;(y=this.fragCurrent)!==null&&y!==void 0&&y.loader&&this.fragCurrent.loader.abort(),this.state=f.State.IDLE},m.onSubtitleTracksUpdated=function(D,w){var y=this,p=w.subtitleTracks;this.tracksBuffered=[],this.levels=p.map(function(d){return new k.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){y.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},m.onSubtitleTrackSwitch=function(D,w){if(this.currentTrackId=w.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var y=this.levels[this.currentTrackId];y!=null&&y.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,y&&this.setInterval(a)},m.onSubtitleTrackLoaded=function(D,w){var y,p=w.details,d=w.id,o=this.currentTrackId,C=this.levels;if(!C.length)return;var S=C[o];if(d>=C.length||d!==o||!S)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,p.live||(y=S.details)!==null&&y!==void 0&&y.live){var x=this.mainDetails;if(p.deltaUpdateFailed||!x)return;var M=x.fragments[0];if(!S.details)p.hasProgramDateTime&&x.hasProgramDateTime?Object(N.alignMediaPlaylistByPDT)(p,x):M&&Object(O.addSliding)(p,M.start);else{var F=this.alignPlaylists(p,S.details);F===0&&M&&Object(O.addSliding)(p,M.start)}}if(S.details=p,this.levelLastLoaded=d,this.tick(),p.live&&!this.fragCurrent&&this.media&&this.state===f.State.IDLE){var G=Object(B.findFragmentByPTS)(null,p.fragments,this.media.currentTime,0);G||(this.warn("Subtitle playlist not aligned with playback"),S.details=void 0)}},m._handleFragmentLoadComplete=function(D){var w=D.frag,y=D.payload,p=w.decryptdata,d=this.hls;if(this.fragContextChanged(w))return;if(y&&y.byteLength>0&&p&&p.key&&p.iv&&p.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(y),p.key.buffer,p.iv.buffer).then(function(C){var S=performance.now();d.trigger(V.Events.FRAG_DECRYPTED,{frag:w,payload:C,stats:{tstart:o,tdecrypt:S}})})}},m.doTick=function(){if(!this.media){this.state=f.State.IDLE;return}if(this.state===f.State.IDLE){var D,w=this.currentTrackId,y=this.levels;if(!y.length||!y[w]||!y[w].details)return;var p=y[w].details,d=p.targetduration,o=this.config,C=this.media,S=P.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,C.currentTime-d,o.maxBufferHole),x=S.end,M=S.len,F=this.getMaxBufferLength()+d;if(M>F)return;console.assert(p,"Subtitle track details are defined on idle subtitle stream controller tick");var G=p.fragments,J=G.length,K=p.edge,j,q=this.fragPrevious;if(x<K){var oe=o.maxFragLookUpTolerance;q&&p.hasProgramDateTime&&(j=Object(B.findFragmentByPDT)(G,q.endProgramDateTime,oe)),j||(j=Object(B.findFragmentByPTS)(q,G,x,oe),!j&&q&&q.start<G[0].start&&(j=G[0]))}else j=G[J-1];(D=j)!==null&&D!==void 0&&D.encrypted?(I.logger.log("Loading key for "+j.sn),this.state=f.State.KEY_LOADING,this.hls.trigger(V.Events.KEY_LOADING,{frag:j})):j&&this.fragmentTracker.getState(j)===R.FragmentState.NOT_LOADED&&this.loadFragment(j,p,x)}},m.loadFragment=function(D,w,y){this.fragCurrent=D,h.prototype.loadFragment.call(this,D,w,y)},g(A,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),A}(f.default)},"./src/controller/subtitle-track-controller.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/events.ts"),I=_("./src/utils/texttrack-utils.ts"),P=_("./src/controller/base-playlist-controller.ts"),B=_("./src/types/loader.ts");function N(T,g){for(var b=0;b<g.length;b++){var u=g[b];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(T,u.key,u)}}function O(T,g,b){return g&&N(T.prototype,g),b&&N(T,b),T}function R(T,g){T.prototype=Object.create(g.prototype),T.prototype.constructor=T,f(T,g)}function f(T,g){return f=Object.setPrototypeOf||function(u,a){return u.__proto__=a,u},f(T,g)}var c=function(T){R(g,T);function g(u){var a;return a=T.call(this,u,"[subtitle-track-controller]")||this,a.media=null,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.selectDefaultTrack=!0,a.queuedDefaultTrack=-1,a.trackChangeListener=function(){return a.onTextTracksChanged()},a.asyncPollTrackChange=function(){return a.pollTrackChange(0)},a.useTextTrackPolling=!1,a.subtitlePollingInterval=-1,a.subtitleDisplay=!0,a.registerListeners(),a}var b=g.prototype;return b.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,T.prototype.destroy.call(this)},b.registerListeners=function(){var a=this.hls;a.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),a.on(V.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var a=this.hls;a.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),a.off(V.Events.ERROR,this.onError,this)},b.onMediaAttached=function(a,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)},b.pollTrackChange=function(a){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,a)},b.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 a=k(this.media.textTracks);a.forEach(function(l){Object(I.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},b.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},b.onManifestParsed=function(a,l){this.tracks=l.subtitleTracks},b.onSubtitleTrackLoaded=function(a,l){var h=l.id,A=l.details,m=this.trackId,E=this.tracksInGroup[m];if(!E){this.warn("Invalid subtitle track id "+h);return}var D=E.details;E.details=l.details,this.log("subtitle track "+h+" loaded ["+A.startSN+"-"+A.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,l,D))},b.onLevelLoading=function(a,l){this.switchLevel(l.level)},b.onLevelSwitching=function(a,l){this.switchLevel(l.level)},b.switchLevel=function(a){var l=this.hls.levels[a];if(!(l!=null&&l.textGroupIds))return;var h=l.textGroupIds[l.urlId];if(this.groupId!==h){var A=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,m=this.tracks.filter(function(w){return!h||w.groupId===h});this.tracksInGroup=m;var E=this.findTrackId(A==null?void 0:A.name)||this.findTrackId();this.groupId=h;var D={subtitleTracks:m};this.log("Updating subtitle tracks, "+m.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(V.Events.SUBTITLE_TRACKS_UPDATED,D),E!==-1&&this.setSubtitleTrack(E,A)}},b.findTrackId=function(a){for(var l=this.tracksInGroup,h=0;h<l.length;h++){var A=l[h];if((!this.selectDefaultTrack||A.default)&&(!a||a===A.name))return A.id}return-1},b.onError=function(a,l){if(T.prototype.onError.call(this,a,l),l.fatal||!l.context)return;l.context.type===B.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},b.loadPlaylist=function(a){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var h=l.id,A=l.groupId,m=l.url;if(a)try{m=a.addDirectives(m)}catch(E){this.warn("Could not construct new URL with HLS Delivery Directives: "+E)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(V.Events.SUBTITLE_TRACK_LOADING,{url:m,id:h,groupId:A,deliveryDirectives:a||null})}},b.toggleTrackModes=function(a){var l=this,h=this.media,A=this.subtitleDisplay,m=this.trackId;if(!h)return;var E=k(h.textTracks),D=E.filter(function(p){return p.groupId===l.groupId});if(a===-1)[].slice.call(E).forEach(function(p){p.mode="disabled"});else{var w=D[m];w&&(w.mode="disabled")}var y=D[a];y&&(y.mode=A?"showing":"hidden")},b.setSubtitleTrack=function(a,l){var h,A=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=a;return}if(this.trackId!==a&&this.toggleTrackModes(a),this.trackId===a&&(a===-1||(h=A[a])!==null&&h!==void 0&&h.details)||a<-1||a>=A.length)return;this.clearTimer();var m=A[a];if(this.log("Switching to subtitle track "+a),this.trackId=a,m){var E=m.id,D=m.groupId,w=D===void 0?"":D,y=m.name,p=m.type,d=m.url;this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:E,groupId:w,name:y,type:p,url:d});var o=this.switchParams(m.url,l==null?void 0:l.details);this.loadPlaylist(o)}else this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:a})},b.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var a=-1,l=k(this.media.textTracks),h=0;h<l.length;h++)if(l[h].mode==="hidden")a=h;else if(l[h].mode==="showing"){a=h;break}this.subtitleTrack!==a&&(this.subtitleTrack=a)},O(g,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(a,l)}}]),g}(P.default);function k(T){for(var g=[],b=0;b<T.length;b++){var u=T[b];u.kind==="subtitles"&&u.label&&g.push(T[b])}return g}Y.default=c},"./src/controller/timeline-controller.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"TimelineController",function(){return k});var V=_("./src/polyfills/number.ts"),I=_("./src/events.ts"),P=_("./src/utils/cea-608-parser.ts"),B=_("./src/utils/output-filter.ts"),N=_("./src/utils/webvtt-parser.ts"),O=_("./src/utils/texttrack-utils.ts"),R=_("./src/utils/imsc1-ttml-parser.ts"),f=_("./src/types/loader.ts"),c=_("./src/utils/logger.ts"),k=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=b(),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 B.default(this,"textTrack1"),A=new B.default(this,"textTrack2"),m=new B.default(this,"textTrack3"),E=new B.default(this,"textTrack4");this.cea608Parser1=new P.default(1,h,A),this.cea608Parser2=new P.default(3,m,E)}l.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(I.Events.FRAG_LOADING,this.onFragLoading,this),l.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var a=u.prototype;return a.destroy=function(){var h=this.hls;h.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.off(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(I.Events.FRAG_LOADING,this.onFragLoading,this),h.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.off(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.off(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},a.addCues=function(h,A,m,E,D){for(var w=!1,y=D.length;y--;){var p=D[y],d=g(p[0],p[1],A,m);if(d>=0&&(p[0]=Math.min(p[0],A),p[1]=Math.max(p[1],m),w=!0,d/(m-A)>.5))return}if(w||D.push([A,m]),this.config.renderTextTracksNatively){var o=this.captionsTracks[h];this.Cues.newCue(o,A,m,E)}else{var C=this.Cues.newCue(null,A,m,E);this.hls.trigger(I.Events.CUES_PARSED,{type:"captions",cues:C,track:h})}},a.onInitPtsFound=function(h,A){var m=this,E=A.frag,D=A.id,w=A.initPTS,y=A.timescale,p=this.unparsedVttFrags;D==="main"&&(this.initPTS[E.cc]=w,this.timescale[E.cc]=y),p.length&&(this.unparsedVttFrags=[],p.forEach(function(d){m.onFragLoaded(I.Events.FRAG_LOADED,d)}))},a.getExistingTrack=function(h){var A=this.media;if(A)for(var m=0;m<A.textTracks.length;m++){var E=A.textTracks[m];if(E[h])return E}return null},a.createCaptionsTrack=function(h){this.config.renderTextTracksNatively?this.createNativeTrack(h):this.createNonNativeTrack(h)},a.createNativeTrack=function(h){if(this.captionsTracks[h])return;var A=this.captionsProperties,m=this.captionsTracks,E=this.media,D=A[h],w=D.label,y=D.languageCode,p=this.getExistingTrack(h);if(p)m[h]=p,Object(O.clearCurrentCues)(m[h]),Object(O.sendAddTrackEvent)(m[h],E);else{var d=this.createTextTrack("captions",w,y);d&&(d[h]=!0,m[h]=d)}},a.createNonNativeTrack=function(h){if(this.nonNativeCaptionsTracks[h])return;var A=this.captionsProperties[h];if(!A)return;var m=A.label,E={_id:h,label:m,kind:"captions",default:A.media?!!A.media.default:!1,closedCaptions:A.media};this.nonNativeCaptionsTracks[h]=E,this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[E]})},a.createTextTrack=function(h,A,m){var E=this.media;return E?E.addTextTrack(h,A,m):void 0},a.onMediaAttaching=function(h,A){this.media=A.media,this._cleanTracks()},a.onMediaDetaching=function(){var h=this.captionsTracks;Object.keys(h).forEach(function(A){Object(O.clearCurrentCues)(h[A]),delete h[A]}),this.nonNativeCaptionsTracks={}},a.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=b(),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())},a._cleanTracks=function(){var h=this.media;if(!h)return;var A=h.textTracks;if(A)for(var m=0;m<A.length;m++)Object(O.clearCurrentCues)(A[m])},a.onSubtitleTracksUpdated=function(h,A){var m=this;this.textTracks=[];var E=A.subtitleTracks||[],D=E.some(function(d){return d.textCodec===R.IMSC1_CODEC});if(this.config.enableWebVTT||D&&this.config.enableIMSC1){var w=this.tracks&&E&&this.tracks.length===E.length;if(this.tracks=E||[],this.config.renderTextTracksNatively){var y=this.media?this.media.textTracks:[];this.tracks.forEach(function(d,o){var C;if(o<y.length){for(var S=null,x=0;x<y.length;x++)if(T(y[x],d)){S=y[x];break}S&&(C=S)}C?Object(O.clearCurrentCues)(C):(C=m.createTextTrack("subtitles",d.name,d.lang),C&&(C.mode="disabled")),C&&(C.groupId=d.groupId,m.textTracks.push(C))})}else if(!w&&this.tracks&&this.tracks.length){var p=this.tracks.map(function(d){return{label:d.name,kind:d.type.toLowerCase(),default:d.default,subtitleTrack:d}});this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:p})}}},a.onManifestLoaded=function(h,A){var m=this;this.config.enableCEA708Captions&&A.captions&&A.captions.forEach(function(E){var D=/(?:CC|SERVICE)([1-4])/.exec(E.instreamId);if(!D)return;var w="textTrack"+D[1],y=m.captionsProperties[w];if(!y)return;y.label=E.name,E.lang&&(y.languageCode=E.lang),y.media=E})},a.onFragLoading=function(h,A){var m=this.cea608Parser1,E=this.cea608Parser2,D=this.lastSn,w=this.lastPartIndex;if(!this.enabled||!(m&&E))return;if(A.frag.type===f.PlaylistLevelType.MAIN){var y,p,d=A.frag.sn,o=(y=A==null||((p=A.part)===null||p===void 0)?void 0:p.index)!=null?y:-1;d===D+1||d===D&&o===w+1||(m.reset(),E.reset()),this.lastSn=d,this.lastPartIndex=o}},a.onFragLoaded=function(h,A){var m=A.frag,E=A.payload,D=this.initPTS,w=this.unparsedVttFrags;if(m.type===f.PlaylistLevelType.SUBTITLE)if(E.byteLength){if(!Object(V.isFiniteNumber)(D[m.cc])){w.push(A),D.length&&this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:m,error:new Error("Missing initial subtitle PTS")});return}var y=m.decryptdata;if(y==null||y.key==null||y.method!=="AES-128"){var p=this.tracks[m.level],d=this.vttCCs;d[m.cc]||(d[m.cc]={start:m.start,prevCC:this.prevCC,new:!0},this.prevCC=m.cc),p&&p.textCodec===R.IMSC1_CODEC?this._parseIMSC1(m,E):this._parseVTTs(m,E,d)}}else this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:m,error:new Error("Empty subtitle payload")})},a._parseIMSC1=function(h,A){var m=this,E=this.hls;Object(R.parseIMSC1)(A,this.initPTS[h.cc],this.timescale[h.cc],function(D){m._appendCues(D,h.level),E.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(D){c.logger.log("Failed to parse IMSC1: "+D),E.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:D})})},a._parseVTTs=function(h,A,m){var E=this,D=this.hls;Object(N.parseWebVTT)(A,this.initPTS[h.cc],this.timescale[h.cc],m,h.cc,h.start,function(w){E._appendCues(w,h.level),D.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(w){E._fallbackToIMSC1(h,A),c.logger.log("Failed to parse VTT cue: "+w),D.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:w})})},a._fallbackToIMSC1=function(h,A){var m=this,E=this.tracks[h.level];E.textCodec||Object(R.parseIMSC1)(A,this.initPTS[h.cc],this.timescale[h.cc],function(){E.textCodec=R.IMSC1_CODEC,m._parseIMSC1(h,A)},function(){E.textCodec="wvtt"})},a._appendCues=function(h,A){var m=this.hls;if(this.config.renderTextTracksNatively){var E=this.textTracks[A];if(E.mode==="disabled")return;h.forEach(function(y){return Object(O.addCueToTrack)(E,y)})}else{var D=this.tracks[A],w=D.default?"default":"subtitles"+A;m.trigger(I.Events.CUES_PARSED,{type:"subtitles",cues:h,track:w})}},a.onFragDecrypted=function(h,A){var m=A.frag;if(m.type===f.PlaylistLevelType.SUBTITLE){if(!Object(V.isFiniteNumber)(this.initPTS[m.cc])){this.unparsedVttFrags.push(A);return}this.onFragLoaded(I.Events.FRAG_LOADED,A)}},a.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},a.onFragParsingUserdata=function(h,A){var m=this.cea608Parser1,E=this.cea608Parser2;if(!this.enabled||!(m&&E))return;for(var D=0;D<A.samples.length;D++){var w=A.samples[D].bytes;if(w){var y=this.extractCea608Data(w);m.addData(A.samples[D].pts,y[0]),E.addData(A.samples[D].pts,y[1])}}},a.onBufferFlushing=function(h,A){var m=A.startOffset,E=A.endOffset,D=A.endOffsetSubtitles,w=A.type,y=this.media;if(!y||y.currentTime<E)return;if(!w||w==="video"){var p=this.captionsTracks;Object.keys(p).forEach(function(o){return Object(O.removeCuesInRange)(p[o],m,E)})}if(this.config.renderTextTracksNatively&&(m===0&&D!==void 0)){var d=this.textTracks;Object.keys(d).forEach(function(o){return Object(O.removeCuesInRange)(d[o],m,D)})}},a.extractCea608Data=function(h){for(var A=h[0]&31,m=2,E=[[],[]],D=0;D<A;D++){var w=h[m++],y=127&h[m++],p=127&h[m++],d=(4&w)!==0,o=3&w;if(y===0&&p===0)continue;d&&((o===0||o===1)&&(E[o].push(y),E[o].push(p)))}return E},u}();function T(u,a){return u&&u.label===a.name&&!(u.textTrack1||u.textTrack2)}function g(u,a,l,h){return Math.min(a,h)-Math.max(u,l)}function b(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return V});var V=function(){function I(B,N){this.subtle=void 0,this.aesIV=void 0,this.subtle=B,this.aesIV=N}var P=I.prototype;return P.decrypt=function(N,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,N)},I}()},"./src/crypt/aes-decryptor.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"removePadding",function(){return I}),_.d(Y,"default",function(){return P});var V=_("./src/utils/typed-array.ts");function I(B){var N=B.byteLength,O=N&&new DataView(B.buffer).getUint8(N-1);return O?Object(V.sliceUint8)(B,0,N-O):B}var P=function(){function B(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var N=B.prototype;return N.uint8ArrayToUint32Array_=function(R){for(var f=new DataView(R),c=new Uint32Array(4),k=0;k<4;k++)c[k]=f.getUint32(k*4);return c},N.initTable=function(){var R=this.sBox,f=this.invSBox,c=this.subMix,k=c[0],T=c[1],g=c[2],b=c[3],u=this.invSubMix,a=u[0],l=u[1],h=u[2],A=u[3],m=new Uint32Array(256),E=0,D=0,w=0;for(w=0;w<256;w++)w<128?m[w]=w<<1:m[w]=w<<1^283;for(w=0;w<256;w++){var y=D^D<<1^D<<2^D<<3^D<<4;y=y>>>8^y&255^99,R[E]=y,f[y]=E;var p=m[E],d=m[p],o=m[d],C=m[y]*257^y*16843008;k[E]=C<<24|C>>>8,T[E]=C<<16|C>>>16,g[E]=C<<8|C>>>24,b[E]=C,C=o*16843009^d*65537^p*257^E*16843008,a[y]=C<<24|C>>>8,l[y]=C<<16|C>>>16,h[y]=C<<8|C>>>24,A[y]=C,E?(E=p^m[m[m[o^p]]],D^=m[m[D]]):E=D=1}},N.expandKey=function(R){for(var f=this.uint8ArrayToUint32Array_(R),c=!0,k=0;k<f.length&&c;)c=f[k]===this.key[k],k++;if(c)return;this.key=f;var T=this.keySize=f.length;if(T!==4&&T!==6&&T!==8)throw new Error("Invalid aes key size="+T);var g=this.ksRows=(T+6+1)*4,b,u,a=this.keySchedule=new Uint32Array(g),l=this.invKeySchedule=new Uint32Array(g),h=this.sBox,A=this.rcon,m=this.invSubMix,E=m[0],D=m[1],w=m[2],y=m[3],p,d;for(b=0;b<g;b++){if(b<T){p=a[b]=f[b];continue}d=p,b%T===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^=A[b/T|0]<<24):T>6&&b%T===4&&(d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255]),a[b]=p=(a[b-T]^d)>>>0}for(u=0;u<g;u++)b=g-u,u&3?d=a[b]:d=a[b-4],u<4||b<=4?l[u]=d:l[u]=E[h[d>>>24]]^D[h[d>>>16&255]]^w[h[d>>>8&255]]^y[h[d&255]],l[u]=l[u]>>>0},N.networkToHostOrderSwap=function(R){return R<<24|(R&65280)<<8|(R&16711680)>>8|R>>>24},N.decrypt=function(R,f,c){for(var k=this.keySize+6,T=this.invKeySchedule,g=this.invSBox,b=this.invSubMix,u=b[0],a=b[1],l=b[2],h=b[3],A=this.uint8ArrayToUint32Array_(c),m=A[0],E=A[1],D=A[2],w=A[3],y=new Int32Array(R),p=new Int32Array(y.length),d,o,C,S,x,M,F,G,J,K,j,q,oe,ue,ge=this.networkToHostOrderSwap;f<y.length;){for(J=ge(y[f]),K=ge(y[f+1]),j=ge(y[f+2]),q=ge(y[f+3]),x=J^T[0],M=q^T[1],F=j^T[2],G=K^T[3],oe=4,ue=1;ue<k;ue++)d=u[x>>>24]^a[M>>16&255]^l[F>>8&255]^h[G&255]^T[oe],o=u[M>>>24]^a[F>>16&255]^l[G>>8&255]^h[x&255]^T[oe+1],C=u[F>>>24]^a[G>>16&255]^l[x>>8&255]^h[M&255]^T[oe+2],S=u[G>>>24]^a[x>>16&255]^l[M>>8&255]^h[F&255]^T[oe+3],x=d,M=o,F=C,G=S,oe=oe+4;d=g[x>>>24]<<24^g[M>>16&255]<<16^g[F>>8&255]<<8^g[G&255]^T[oe],o=g[M>>>24]<<24^g[F>>16&255]<<16^g[G>>8&255]<<8^g[x&255]^T[oe+1],C=g[F>>>24]<<24^g[G>>16&255]<<16^g[x>>8&255]<<8^g[M&255]^T[oe+2],S=g[G>>>24]<<24^g[x>>16&255]<<16^g[M>>8&255]<<8^g[F&255]^T[oe+3],p[f]=ge(d^m),p[f+1]=ge(S^E),p[f+2]=ge(C^D),p[f+3]=ge(o^w),m=J,E=K,D=j,w=q,f=f+4}return p.buffer},B}()},"./src/crypt/decrypter.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return f});var V=_("./src/crypt/aes-crypto.ts"),I=_("./src/crypt/fast-aes-key.ts"),P=_("./src/crypt/aes-decryptor.ts"),B=_("./src/utils/logger.ts"),N=_("./src/utils/mp4-tools.ts"),O=_("./src/utils/typed-array.ts"),R=16,f=function(){function c(T,g,b){var u=b===void 0?{}:b,a=u.removePKCS7Padding,l=a===void 0?!0:a;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=T,this.config=g,this.removePKCS7Padding=l,l)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch(A){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var k=c.prototype;return k.destroy=function(){this.observer=null},k.isSync=function(){return this.config.enableSoftwareAES},k.flush=function(){var g=this.currentResult;if(!g){this.reset();return}var b=new Uint8Array(g);return this.reset(),this.removePKCS7Padding?Object(P.removePadding)(b):b},k.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},k.decrypt=function(g,b,u,a){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(g),b,u);var l=this.flush();l&&a(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(g),b,u).then(a)},k.softwareDecrypt=function(g,b,u){var a=this.currentIV,l=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(g=Object(N.appendUint8Array)(h,g),this.remainderData=null);var A=this.getValidChunk(g);if(!A.length)return null;a&&(u=a);var m=this.softwareDecrypter;m||(m=this.softwareDecrypter=new P.default),m.expandKey(b);var E=l;return this.currentResult=m.decrypt(A.buffer,0,u),this.currentIV=Object(O.sliceUint8)(A,-16).buffer,E||null},k.webCryptoDecrypt=function(g,b,u){var a=this,l=this.subtle;return(this.key!==b||!this.fastAesKey)&&(this.key=b,this.fastAesKey=new I.default(l,b)),this.fastAesKey.expandKey().then(function(h){if(!l)return Promise.reject(new Error("web crypto not initialized"));var A=new V.default(l,u);return A.decrypt(g.buffer,h)}).catch(function(h){return a.onWebCryptoError(h,g,b,u)})},k.onWebCryptoError=function(g,b,u,a){return B.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",g),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(b,u,a)},k.getValidChunk=function(g){var b=g,u=g.length-g.length%R;return u!==g.length&&(b=Object(O.sliceUint8)(g,0,u),this.remainderData=Object(O.sliceUint8)(g,u)),b},k.logOnce=function(g){if(!this.logEnabled)return;B.logger.log("[decrypter.ts]: "+g),this.logEnabled=!1},c}()},"./src/crypt/fast-aes-key.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return V});var V=function(){function I(B,N){this.subtle=void 0,this.key=void 0,this.subtle=B,this.key=N}var P=I.prototype;return P.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},I}()},"./src/demux/aacdemuxer.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/demux/base-audio-demuxer.ts"),I=_("./src/demux/adts.ts"),P=_("./src/utils/logger.ts"),B=_("./src/demux/id3.ts");function N(f,c){f.prototype=Object.create(c.prototype),f.prototype.constructor=f,O(f,c)}function O(f,c){return O=Object.setPrototypeOf||function(T,g){return T.__proto__=g,T},O(f,c)}var R=function(f){N(c,f);function c(T,g){var b;return b=f.call(this)||this,b.observer=void 0,b.config=void 0,b.observer=T,b.config=g,b}var k=c.prototype;return k.resetInitSegment=function(g,b,u){f.prototype.resetInitSegment.call(this,g,b,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:g,duration:u,inputTimeScale:9e4,dropped:0}},c.probe=function(g){if(!g)return!1;for(var b=B.getID3Data(g,0)||[],u=b.length,a=g.length;u<a;u++)if(I.probe(g,u))return P.logger.log("ADTS sync word found !"),!0;return!1},k.canParse=function(g,b){return I.canParse(g,b)},k.appendFrame=function(g,b,u){I.initTrackConfig(g,this.observer,b,u,g.manifestCodec);var a=I.appendFrame(g,b,u,this.initPTS,this.frameIndex);if(a&&a.missing===0)return a},c}(V.default);R.minProbeByteLength=9,Y.default=R},"./src/demux/adts.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"getAudioConfig",function(){return B}),_.d(Y,"isHeaderPattern",function(){return N}),_.d(Y,"getHeaderLength",function(){return O}),_.d(Y,"getFullFrameLength",function(){return R}),_.d(Y,"canGetFrameLength",function(){return f}),_.d(Y,"isHeader",function(){return c}),_.d(Y,"canParse",function(){return k}),_.d(Y,"probe",function(){return T}),_.d(Y,"initTrackConfig",function(){return g}),_.d(Y,"getFrameDuration",function(){return b}),_.d(Y,"parseFrameHeader",function(){return u}),_.d(Y,"appendFrame",function(){return a});var V=_("./src/utils/logger.ts"),I=_("./src/errors.ts"),P=_("./src/events.ts");function B(l,h,A,m){var E,D,w,y,p=navigator.userAgent.toLowerCase(),d=m,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];E=((h[A+2]&192)>>>6)+1;var C=(h[A+2]&60)>>>2;if(C>o.length-1){l.trigger(P.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+C});return}return w=(h[A+2]&1)<<2,w|=(h[A+3]&192)>>>6,V.logger.log("manifest codec:"+m+", ADTS type:"+E+", samplingIndex:"+C),/firefox/i.test(p)?C>=6?(E=5,y=new Array(4),D=C-3):(E=2,y=new Array(2),D=C):p.indexOf("android")!==-1?(E=2,y=new Array(2),D=C):(E=5,y=new Array(4),m&&(m.indexOf("mp4a.40.29")!==-1||m.indexOf("mp4a.40.5")!==-1)||!m&&C>=6?D=C-3:((m&&m.indexOf("mp4a.40.2")!==-1&&(C>=6&&w===1||/vivaldi/i.test(p))||!m&&w===1)&&(E=2,y=new Array(2)),D=C)),y[0]=E<<3,y[0]|=(C&14)>>1,y[1]|=(C&1)<<7,y[1]|=w<<3,E===5&&(y[1]|=(D&14)>>1,y[2]=(D&1)<<7,y[2]|=2<<2,y[3]=0),{config:y,samplerate:o[C],channelCount:w,codec:"mp4a.40."+E,manifestCodec:d}}function N(l,h){return l[h]===255&&(l[h+1]&246)===240}function O(l,h){return l[h+1]&1?7:9}function R(l,h){return(l[h+3]&3)<<11|l[h+4]<<3|(l[h+5]&224)>>>5}function f(l,h){return h+5<l.length}function c(l,h){return h+1<l.length&&N(l,h)}function k(l,h){return f(l,h)&&N(l,h)&&R(l,h)<=l.length-h}function T(l,h){if(c(l,h)){var A=O(l,h);if(h+A>=l.length)return!1;var m=R(l,h);if(m<=A)return!1;var E=h+m;return E===l.length||c(l,E)}return!1}function g(l,h,A,m,E){if(!l.samplerate){var D=B(h,A,m,E);if(!D)return;l.config=D.config,l.samplerate=D.samplerate,l.channelCount=D.channelCount,l.codec=D.codec,l.manifestCodec=D.manifestCodec,V.logger.log("parsed codec:"+l.codec+", rate:"+D.samplerate+", channels:"+D.channelCount)}}function b(l){return 1024*9e4/l}function u(l,h,A,m,E){var D=O(l,h),w=R(l,h);if(w-=D,w>0){var y=A+m*E;return{headerLength:D,frameLength:w,stamp:y}}}function a(l,h,A,m,E){var D=b(l.samplerate),w=u(h,A,m,E,D);if(w){var y=w.frameLength,p=w.headerLength,d=w.stamp,o=p+y,C=Math.max(0,A+o-h.length),S;C?(S=new Uint8Array(o-p),S.set(h.subarray(A+p,h.length),0)):S=h.subarray(A+p,A+o);var x={unit:S,pts:d};return C||l.samples.push(x),{sample:x,length:o,missing:C}}}},"./src/demux/base-audio-demuxer.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"initPTSFn",function(){return R});var V=_("./src/polyfills/number.ts"),I=_("./src/demux/id3.ts"),P=_("./src/demux/dummy-demuxed-track.ts"),B=_("./src/utils/mp4-tools.ts"),N=_("./src/utils/typed-array.ts"),O=function(){function f(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var c=f.prototype;return c.resetInitSegment=function(T,g,b){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},c.resetTimeStamp=function(){},c.resetContiguity=function(){},c.canParse=function(T,g){return!1},c.appendFrame=function(T,g,b){},c.demux=function(T,g){this.cachedData&&(T=Object(B.appendUint8Array)(this.cachedData,T),this.cachedData=null);var b=I.getID3Data(T,0),u=b?b.length:0,a,l,h=this._audioTrack,A=this._id3Track,m=b?I.getTimeStamp(b):void 0,E=T.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=R(m,g)),b&&b.length>0&&A.samples.push({pts:this.initPTS,dts:this.initPTS,data:b}),l=this.initPTS;u<E;){if(this.canParse(T,u)){var D=this.appendFrame(h,T,u);D?(this.frameIndex++,l=D.sample.pts,u+=D.length,a=u):u=E}else I.canParse(T,u)?(b=I.getID3Data(T,u),A.samples.push({pts:l,dts:l,data:b}),u+=b.length,a=u):u++;if(u===E&&a!==E){var w=Object(N.sliceUint8)(T,a);this.cachedData?this.cachedData=Object(B.appendUint8Array)(this.cachedData,w):this.cachedData=w}}return{audioTrack:h,avcTrack:Object(P.dummyTrack)(),id3Track:A,textTrack:Object(P.dummyTrack)()}},c.demuxSampleAes=function(T,g,b){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},c.flush=function(T){var g=this.cachedData;return g&&(this.cachedData=null,this.demux(g,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(P.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(P.dummyTrack)()}},c.destroy=function(){},f}(),R=function(c,k){return Object(V.isFiniteNumber)(c)?c*90:k*9e4};Y.default=O},"./src/demux/chunk-cache.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return V});var V=function(){function P(){this.chunks=[],this.dataLength=0}var B=P.prototype;return B.push=function(O){this.chunks.push(O),this.dataLength+=O.length},B.flush=function(){var O=this.chunks,R=this.dataLength,f;if(O.length)O.length===1?f=O[0]:f=I(O,R);else return new Uint8Array(0);return this.reset(),f},B.reset=function(){this.chunks.length=0,this.dataLength=0},P}();function I(P,B){for(var N=new Uint8Array(B),O=0,R=0;R<P.length;R++){var f=P[R];N.set(f,O),O+=f.length}return N}},"./src/demux/dummy-demuxed-track.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"dummyTrack",function(){return V});function V(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/utils/logger.ts"),I=function(){function P(N){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=N,this.bytesAvailable=N.byteLength,this.word=0,this.bitsAvailable=0}var B=P.prototype;return B.loadWord=function(){var O=this.data,R=this.bytesAvailable,f=O.byteLength-R,c=new Uint8Array(4),k=Math.min(4,R);if(k===0)throw new Error("no bytes available");c.set(O.subarray(f,f+k)),this.word=new DataView(c.buffer).getUint32(0),this.bitsAvailable=k*8,this.bytesAvailable-=k},B.skipBits=function(O){var R;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,R=O>>3,O-=R>>3,this.bytesAvailable-=R,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},B.readBits=function(O){var R=Math.min(this.bitsAvailable,O),f=this.word>>>32-R;return O>32&&V.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=R,this.bitsAvailable>0?this.word<<=R:this.bytesAvailable>0&&this.loadWord(),R=O-R,R>0&&this.bitsAvailable?f<<R|this.readBits(R):f},B.skipLZ=function(){var O;for(O=0;O<this.bitsAvailable;++O)if((this.word&2147483648>>>O)!==0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},B.skipUEG=function(){this.skipBits(1+this.skipLZ())},B.skipEG=function(){this.skipBits(1+this.skipLZ())},B.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},B.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},B.readBoolean=function(){return this.readBits(1)===1},B.readUByte=function(){return this.readBits(8)},B.readUShort=function(){return this.readBits(16)},B.readUInt=function(){return this.readBits(32)},B.skipScalingList=function(O){for(var R=8,f=8,c,k=0;k<O;k++)f!==0&&(c=this.readEG(),f=(R+c+256)%256),R=f===0?R:f},B.readSPS=function(){var O=0,R=0,f=0,c=0,k,T,g,b=this.readUByte.bind(this),u=this.readBits.bind(this),a=this.readUEG.bind(this),l=this.readBoolean.bind(this),h=this.skipBits.bind(this),A=this.skipEG.bind(this),m=this.skipUEG.bind(this),E=this.skipScalingList.bind(this);b();var D=b();if(u(5),h(3),b(),m(),D===100||D===110||D===122||D===244||D===44||D===83||D===86||D===118||D===128){var w=a();if(w===3&&h(1),m(),m(),h(1),l())for(T=w!==3?8:12,g=0;g<T;g++)l()&&(g<6?E(16):E(64))}m();var y=a();if(y===0)a();else if(y===1)for(h(1),A(),A(),k=a(),g=0;g<k;g++)A();m(),h(1);var p=a(),d=a(),o=u(1);o===0&&h(1),h(1),l()&&(O=a(),R=a(),f=a(),c=a());var C=[1,1];if(l()&&l()){var S=b();switch(S){case 1:C=[1,1];break;case 2:C=[12,11];break;case 3:C=[10,11];break;case 4:C=[16,11];break;case 5:C=[40,33];break;case 6:C=[24,11];break;case 7:C=[20,11];break;case 8:C=[32,11];break;case 9:C=[80,33];break;case 10:C=[18,11];break;case 11:C=[15,11];break;case 12:C=[64,33];break;case 13:C=[160,99];break;case 14:C=[4,3];break;case 15:C=[3,2];break;case 16:C=[2,1];break;case 255:{C=[b()<<8|b(),b()<<8|b()];break}}}return{width:Math.ceil((p+1)*16-O*2-R*2),height:(2-o)*(d+1)*16-(o?2:4)*(f+c),pixelRatio:C}},B.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},P}();Y.default=I},"./src/demux/id3.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"isHeader",function(){return V}),_.d(Y,"isFooter",function(){return I}),_.d(Y,"getID3Data",function(){return P}),_.d(Y,"canParse",function(){return N}),_.d(Y,"getTimeStamp",function(){return O}),_.d(Y,"isTimeStampFrame",function(){return R}),_.d(Y,"getID3Frames",function(){return c}),_.d(Y,"decodeFrame",function(){return k}),_.d(Y,"utf8ArrayToStr",function(){return a}),_.d(Y,"testables",function(){return l});var V=function(E,D){return D+10<=E.length&&(E[D]===73&&E[D+1]===68&&E[D+2]===51&&(E[D+3]<255&&E[D+4]<255&&(E[D+6]<128&&E[D+7]<128&&E[D+8]<128&&E[D+9]<128)))},I=function(E,D){return D+10<=E.length&&(E[D]===51&&E[D+1]===68&&E[D+2]===73&&(E[D+3]<255&&E[D+4]<255&&(E[D+6]<128&&E[D+7]<128&&E[D+8]<128&&E[D+9]<128)))},P=function(E,D){for(var w=D,y=0;V(E,D);){y+=10;var p=B(E,D+6);y+=p,I(E,D+10)&&(y+=10),D+=y}return y>0?E.subarray(w,w+y):void 0},B=function(E,D){var w=0;return w=(E[D]&127)<<21,w|=(E[D+1]&127)<<14,w|=(E[D+2]&127)<<7,w|=E[D+3]&127,w},N=function(E,D){return V(E,D)&&B(E,D+6)+10<=E.length-D},O=function(E){for(var D=c(E),w=0;w<D.length;w++){var y=D[w];if(R(y))return u(y)}return},R=function(E){return E&&E.key==="PRIV"&&E.info==="com.apple.streaming.transportStreamTimestamp"},f=function(E){var D=String.fromCharCode(E[0],E[1],E[2],E[3]),w=B(E,4),y=10;return{type:D,size:w,data:E.subarray(y,y+w)}},c=function(E){for(var D=0,w=[];V(E,D);){var y=B(E,D+6);D+=10;for(var p=D+y;D+8<p;){var d=f(E.subarray(D)),o=k(d);o&&w.push(o),D+=d.size+10}I(E,D)&&(D+=10)}return w},k=function(E){return E.type==="PRIV"?T(E):E.type[0]==="W"?b(E):g(E)},T=function(E){if(E.size<2)return;var D=a(E.data,!0),w=new Uint8Array(E.data.subarray(D.length+1));return{key:E.type,info:D,data:w.buffer}},g=function(E){if(E.size<2)return;if(E.type==="TXXX"){var D=1,w=a(E.data.subarray(D),!0);D+=w.length+1;var y=a(E.data.subarray(D));return{key:E.type,info:w,data:y}}var p=a(E.data.subarray(1));return{key:E.type,data:p}},b=function(E){if(E.type==="WXXX"){if(E.size<2)return;var D=1,w=a(E.data.subarray(D),!0);D+=w.length+1;var y=a(E.data.subarray(D));return{key:E.type,info:w,data:y}}var p=a(E.data);return{key:E.type,data:p}},u=function(E){if(E.data.byteLength===8){var D=new Uint8Array(E.data),w=D[3]&1,y=(D[4]<<23)+(D[5]<<15)+(D[6]<<7)+D[7];return y/=45,w&&(y+=4772185884e-2),Math.round(y)}return},a=function(E,D){D===void 0&&(D=!1);var w=A();if(w){var y=w.decode(E);if(D){var p=y.indexOf("\0");return p!==-1?y.substring(0,p):y}return y.replace(/\0/g,"")}for(var d=E.length,o,C,S,x="",M=0;M<d;){if(o=E[M++],o===0&&D)return x;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:x+=String.fromCharCode(o);break;case 12:case 13:C=E[M++],x+=String.fromCharCode((o&31)<<6|C&63);break;case 14:C=E[M++],S=E[M++],x+=String.fromCharCode((o&15)<<12|(C&63)<<6|(S&63)<<0);break;default:}}return x},l={decodeTextFrame:g},h;function A(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/demux/base-audio-demuxer.ts"),I=_("./src/demux/id3.ts"),P=_("./src/utils/logger.ts"),B=_("./src/demux/mpegaudio.ts");function N(f,c){f.prototype=Object.create(c.prototype),f.prototype.constructor=f,O(f,c)}function O(f,c){return O=Object.setPrototypeOf||function(T,g){return T.__proto__=g,T},O(f,c)}var R=function(f){N(c,f);function c(){return f.apply(this,arguments)||this}var k=c.prototype;return k.resetInitSegment=function(g,b,u){f.prototype.resetInitSegment.call(this,g,b,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:g,duration:u,inputTimeScale:9e4,dropped:0}},c.probe=function(g){if(!g)return!1;for(var b=I.getID3Data(g,0)||[],u=b.length,a=g.length;u<a;u++)if(B.probe(g,u))return P.logger.log("MPEG Audio sync word found !"),!0;return!1},k.canParse=function(g,b){return B.canParse(g,b)},k.appendFrame=function(g,b,u){return this.initPTS===null?void 0:B.appendFrame(g,b,u,this.initPTS,this.frameIndex)},c}(V.default);R.minProbeByteLength=4,Y.default=R},"./src/demux/mp4demuxer.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/utils/mp4-tools.ts"),I=_("./src/demux/dummy-demuxed-track.ts"),P=function(){function B(O,R){this.remainderData=null,this.config=void 0,this.config=R}var N=B.prototype;return N.resetTimeStamp=function(){},N.resetInitSegment=function(){},N.resetContiguity=function(){},B.probe=function(R){return Object(V.findBox)({data:R,start:0,end:Math.min(R.length,16384)},["moof"]).length>0},N.demux=function(R){var f=R,c=Object(I.dummyTrack)();if(this.config.progressive){this.remainderData&&(f=Object(V.appendUint8Array)(this.remainderData,R));var k=Object(V.segmentValidRange)(f);this.remainderData=k.remainder,c.samples=k.valid||new Uint8Array}else c.samples=f;return{audioTrack:Object(I.dummyTrack)(),avcTrack:c,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},N.flush=function(){var R=Object(I.dummyTrack)();return R.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(I.dummyTrack)(),avcTrack:R,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},N.demuxSampleAes=function(R,f,c){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},N.destroy=function(){},B}();P.minProbeByteLength=1024,Y.default=P},"./src/demux/mpegaudio.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"appendFrame",function(){return O}),_.d(Y,"parseHeader",function(){return R}),_.d(Y,"isHeaderPattern",function(){return f}),_.d(Y,"isHeader",function(){return c}),_.d(Y,"canParse",function(){return k}),_.d(Y,"probe",function(){return T});var V=null,I=[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],P=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],B=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],N=[0,1,1,4];function O(g,b,u,a,l){if(u+24>b.length)return;var h=R(b,u);if(h&&u+h.frameLength<=b.length){var A=h.samplesPerFrame*9e4/h.sampleRate,m=a+l*A,E={unit:b.subarray(u,u+h.frameLength),pts:m,dts:m};return g.config=[],g.channelCount=h.channelCount,g.samplerate=h.sampleRate,g.samples.push(E),{sample:E,length:h.frameLength,missing:0}}}function R(g,b){var u=g[b+1]>>3&3,a=g[b+1]>>1&3,l=g[b+2]>>4&15,h=g[b+2]>>2&3;if(u!==1&&l!==0&&l!==15&&h!==3){var A=g[b+2]>>1&1,m=g[b+3]>>6,E=u===3?3-a:a===3?3:4,D=I[E*14+l-1]*1e3,w=u===3?0:u===2?1:2,y=P[w*3+h],p=m===3?1:2,d=B[u][a],o=N[a],C=d*8*o,S=Math.floor(d*D/y+A)*o;if(V===null){var x=navigator.userAgent||"",M=x.match(/Chrome\/(\d+)/i);V=M?parseInt(M[1]):0}var F=!!V&&V<=87;return F&&a===2&&D>=224e3&&m===0&&(g[b+3]=g[b+3]|128),{sampleRate:y,channelCount:p,frameLength:S,samplesPerFrame:C}}}function f(g,b){return g[b]===255&&(g[b+1]&224)===224&&(g[b+1]&6)!==0}function c(g,b){return b+1<g.length&&f(g,b)}function k(g,b){var u=4;return f(g,b)&&u<=g.length-b}function T(g,b){if(b+1<g.length&&f(g,b)){var u=4,a=R(g,b),l=u;a!=null&&a.frameLength&&(l=a.frameLength);var h=b+l;return h===g.length||c(g,h)}return!1}},"./src/demux/sample-aes.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/crypt/decrypter.ts"),I=_("./src/demux/tsdemuxer.ts"),P=function(){function B(O,R,f){this.keyData=void 0,this.decrypter=void 0,this.keyData=f,this.decrypter=new V.default(O,R,{removePKCS7Padding:!1})}var N=B.prototype;return N.decryptBuffer=function(R,f){this.decrypter.decrypt(R,this.keyData.key.buffer,this.keyData.iv.buffer,f)},N.decryptAacSample=function(R,f,c,k){var T=R[f].unit,g=T.subarray(16,T.length-T.length%16),b=g.buffer.slice(g.byteOffset,g.byteOffset+g.length),u=this;this.decryptBuffer(b,function(a){var l=new Uint8Array(a);T.set(l,16),k||u.decryptAacSamples(R,f+1,c)})},N.decryptAacSamples=function(R,f,c){for(;;f++){if(f>=R.length){c();return}if(R[f].unit.length<32)continue;var k=this.decrypter.isSync();if(this.decryptAacSample(R,f,c,k),!k)return}},N.getAvcEncryptedData=function(R){for(var f=Math.floor((R.length-48)/160)*16+16,c=new Int8Array(f),k=0,T=32;T<=R.length-16;T+=160,k+=16)c.set(R.subarray(T,T+16),k);return c},N.getAvcDecryptedUnit=function(R,f){for(var c=new Uint8Array(f),k=0,T=32;T<=R.length-16;T+=160,k+=16)R.set(c.subarray(k,k+16),T);return R},N.decryptAvcSample=function(R,f,c,k,T,g){var b=Object(I.discardEPB)(T.data),u=this.getAvcEncryptedData(b),a=this;this.decryptBuffer(u.buffer,function(l){T.data=a.getAvcDecryptedUnit(b,l),g||a.decryptAvcSamples(R,f,c+1,k)})},N.decryptAvcSamples=function(R,f,c,k){if(R instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;f++,c=0){if(f>=R.length){k();return}for(var T=R[f].units;!(c>=T.length);c++){var g=T[c];if(g.data.length<=48||g.type!==1&&g.type!==5)continue;var b=this.decrypter.isSync();if(this.decryptAvcSample(R,f,c,k,g,b),!b)return}}},B}();Y.default=P},"./src/demux/transmuxer-interface.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return T});var V=_("./node_modules/webworkify-webpack/index.js"),I=_.n(V),P=_("./src/events.ts"),B=_("./src/demux/transmuxer.ts"),N=_("./src/utils/logger.ts"),O=_("./src/errors.ts"),R=_("./src/utils/mediasource-helper.ts"),f=_("./node_modules/eventemitter3/index.js"),c=_.n(f),k=Object(R.getMediaSource)()||{isTypeSupported:function(){return!1}},T=function(){function g(u,a,l,h){var A=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=a,this.onTransmuxComplete=l,this.onFlush=h;var m=u.config,E=function(d,o){o=o||{},o.frag=A.frag,o.id=A.id,u.trigger(d,o)};this.observer=new f.EventEmitter,this.observer.on(P.Events.FRAG_DECRYPTED,E),this.observer.on(P.Events.ERROR,E);var D={mp4:k.isTypeSupported("video/mp4"),mpeg:k.isTypeSupported("audio/mpeg"),mp3:k.isTypeSupported('audio/mp4; codecs="mp3"')},w=navigator.vendor;if(m.enableWorker&&typeof Worker!="undefined"){N.logger.log("demuxing in webworker");var y;try{y=this.worker=V("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),y.addEventListener("message",this.onwmsg),y.onerror=function(p){u.trigger(P.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(p.message+" ("+p.filename+":"+p.lineno+")")})},y.postMessage({cmd:"init",typeSupported:D,vendor:w,id:a,config:JSON.stringify(m)})}catch(p){N.logger.warn("Error in worker:",p),N.logger.error("Error while initializing DemuxerWorker, fallback to inline"),y&&self.URL.revokeObjectURL(y.objectURL),this.transmuxer=new B.default(this.observer,D,m,w,a),this.worker=null}}else this.transmuxer=new B.default(this.observer,D,m,w,a)}var b=g.prototype;return b.destroy=function(){var a=this.worker;if(a)a.removeEventListener("message",this.onwmsg),a.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},b.push=function(a,l,h,A,m,E,D,w,y,p){var d=this;y.transmuxing.start=self.performance.now();var o=this.transmuxer,C=this.worker,S=E?E.start:m.start,x=m.decryptdata,M=this.frag,F=!(M&&m.cc===M.cc),G=!(M&&y.level===M.level),J=M?y.sn-M.sn:-1,K=this.part?y.part-this.part.index:1,j=!G&&(J===1||J===0&&K===1),q=self.performance.now();(G||J||m.stats.parsing.start===0)&&(m.stats.parsing.start=q),E&&(K||!j)&&(E.stats.parsing.start=q);var oe=new B.TransmuxState(F,j,w,G,S);if(!j||F){N.logger.log("[transmuxer-interface, "+m.type+"]: Starting new transmux session for sn: "+y.sn+" p: "+y.part+" level: "+y.level+" id: "+y.id+`
|
|
discontinuity: `+F+`
|
|
trackSwitch: `+G+`
|
|
contiguous: `+j+`
|
|
accurateTimeOffset: `+w+`
|
|
timeOffset: `+S);var ue=new B.TransmuxConfig(h,A,l,D,p);this.configureTransmuxer(ue)}if(this.frag=m,this.part=E,C)C.postMessage({cmd:"demux",data:a,decryptdata:x,chunkMeta:y,state:oe},a instanceof ArrayBuffer?[a]:[]);else if(o){var ge=o.push(a,x,y,oe);Object(B.isPromise)(ge)?ge.then(function(_e){d.handleTransmuxComplete(_e)}):this.handleTransmuxComplete(ge)}},b.flush=function(a){var l=this;a.transmuxing.start=self.performance.now();var h=this.transmuxer,A=this.worker;if(A)A.postMessage({cmd:"flush",chunkMeta:a});else if(h){var m=h.flush(a);Object(B.isPromise)(m)?m.then(function(E){l.handleFlushResult(E,a)}):this.handleFlushResult(m,a)}},b.handleFlushResult=function(a,l){var h=this;a.forEach(function(A){h.handleTransmuxComplete(A)}),this.onFlush(l)},b.onWorkerMessage=function(a){var l=a.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}}},b.configureTransmuxer=function(a){var l=this.worker,h=this.transmuxer;l?l.postMessage({cmd:"configure",config:a}):h&&h.configure(a)},b.handleTransmuxComplete=function(a){a.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(a)},g}()},"./src/demux/transmuxer-worker.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return O});var V=_("./src/demux/transmuxer.ts"),I=_("./src/events.ts"),P=_("./src/utils/logger.ts"),B=_("./node_modules/eventemitter3/index.js"),N=_.n(B);function O(T){var g=new B.EventEmitter,b=function(a,l){T.postMessage({event:a,data:l})};g.on(I.Events.FRAG_DECRYPTED,b),g.on(I.Events.ERROR,b),T.addEventListener("message",function(u){var a=u.data;switch(a.cmd){case"init":{var l=JSON.parse(a.config);T.transmuxer=new V.default(g,a.typeSupported,l,a.vendor,a.id),Object(P.enableLogs)(l.debug),b("init",null);break}case"configure":{T.transmuxer.configure(a.config);break}case"demux":{var h=T.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Object(V.isPromise)(h)?h.then(function(E){R(T,E)}):R(T,h);break}case"flush":{var A=a.chunkMeta,m=T.transmuxer.flush(A);Object(V.isPromise)(m)?m.then(function(E){c(T,E,A)}):c(T,m,A);break}default:break}})}function R(T,g){if(k(g.remuxResult))return;var b=[],u=g.remuxResult,a=u.audio,l=u.video;a&&f(b,a),l&&f(b,l),T.postMessage({event:"transmuxComplete",data:g},b)}function f(T,g){g.data1&&T.push(g.data1.buffer),g.data2&&T.push(g.data2.buffer)}function c(T,g,b){g.forEach(function(u){R(T,u)}),T.postMessage({event:"flush",data:b})}function k(T){return!T.audio&&!T.video&&!T.text&&!T.id3&&!T.initSegment}},"./src/demux/transmuxer.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return l}),_.d(Y,"isPromise",function(){return m}),_.d(Y,"TransmuxConfig",function(){return E}),_.d(Y,"TransmuxState",function(){return D});var V=_("./src/events.ts"),I=_("./src/errors.ts"),P=_("./src/crypt/decrypter.ts"),B=_("./src/demux/aacdemuxer.ts"),N=_("./src/demux/mp4demuxer.ts"),O=_("./src/demux/tsdemuxer.ts"),R=_("./src/demux/mp3demuxer.ts"),f=_("./src/remux/mp4-remuxer.ts"),c=_("./src/remux/passthrough-remuxer.ts"),k=_("./src/demux/chunk-cache.ts"),T=_("./src/utils/mp4-tools.ts"),g=_("./src/utils/logger.ts"),b;try{b=self.performance.now.bind(self.performance)}catch(w){g.logger.debug("Unable to use Performance API on this environment"),b=self.Date.now}var u=[{demux:O.default,remux:f.default},{demux:N.default,remux:c.default},{demux:B.default,remux:f.default},{demux:R.default,remux:f.default}],a=1024;u.forEach(function(w){var y=w.demux;a=Math.max(a,y.minProbeByteLength)});var l=function(){function w(p,d,o,C,S){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 k.default,this.observer=p,this.typeSupported=d,this.config=o,this.vendor=C,this.id=S}var y=w.prototype;return y.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},y.push=function(d,o,C,S){var x=this,M=C.transmuxing;M.executeStart=b();var F=new Uint8Array(d),G=this.cache,J=this.config,K=this.currentTransmuxState,j=this.transmuxConfig;S&&(this.currentTransmuxState=S);var q=h(F,o);if(q&&q.method==="AES-128"){var oe=this.getDecrypter();if(J.enableSoftwareAES){var ue=oe.softwareDecrypt(F,q.key.buffer,q.iv.buffer);if(!ue)return M.executeEnd=b(),A(C);F=new Uint8Array(ue)}else return this.decryptionPromise=oe.webCryptoDecrypt(F,q.key.buffer,q.iv.buffer).then(function(ke){var He=x.push(ke,null,C);return x.decryptionPromise=null,He}),this.decryptionPromise}var ge=S||K,_e=ge.contiguous,be=ge.discontinuity,Se=ge.trackSwitch,Te=ge.accurateTimeOffset,Ce=ge.timeOffset,pe=j.audioCodec,se=j.videoCodec,Re=j.defaultInitPts,Je=j.duration,Xe=j.initSegmentData;if((be||Se)&&this.resetInitSegment(Xe,pe,se,Je),be&&this.resetInitialTimestamp(Re),_e||this.resetContiguity(),this.needsProbing(F,be,Se)){if(G.dataLength){var Ze=G.flush();F=Object(T.appendUint8Array)(Ze,F)}this.configureTransmuxer(F,j)}var Ke=this.transmux(F,q,Ce,Te,C),Ae=this.currentTransmuxState;return Ae.contiguous=!0,Ae.discontinuity=!1,Ae.trackSwitch=!1,M.executeEnd=b(),Ke},y.flush=function(d){var o=this,C=d.transmuxing;C.executeStart=b();var S=this.decrypter,x=this.cache,M=this.currentTransmuxState,F=this.decryptionPromise;if(F)return F.then(function(){return o.flush(d)});var G=[],J=M.timeOffset;if(S){var K=S.flush();K&&G.push(this.push(K,null,d))}var j=x.dataLength;x.reset();var q=this.demuxer,oe=this.remuxer;if(!q||!oe)return j>=a&&this.observer.emit(V.Events.ERROR,V.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),C.executeEnd=b(),[A(d)];var ue=q.flush(J);return m(ue)?ue.then(function(ge){return o.flushRemux(G,ge,d),G}):(this.flushRemux(G,ue,d),G)},y.flushRemux=function(d,o,C){var S=o.audioTrack,x=o.avcTrack,M=o.id3Track,F=o.textTrack,G=this.currentTransmuxState,J=G.accurateTimeOffset,K=G.timeOffset;g.logger.log("[transmuxer.ts]: Flushed fragment "+C.sn+(C.part>-1?" p: "+C.part:"")+" of level "+C.level);var j=this.remuxer.remux(S,x,M,F,K,J,!0,this.id);d.push({remuxResult:j,chunkMeta:C}),C.transmuxing.executeEnd=b()},y.resetInitialTimestamp=function(d){var o=this.demuxer,C=this.remuxer;if(!o||!C)return;o.resetTimeStamp(d),C.resetTimeStamp(d)},y.resetContiguity=function(){var d=this.demuxer,o=this.remuxer;if(!d||!o)return;d.resetContiguity(),o.resetNextTimestamp()},y.resetInitSegment=function(d,o,C,S){var x=this.demuxer,M=this.remuxer;if(!x||!M)return;x.resetInitSegment(o,C,S),M.resetInitSegment(d,o,C)},y.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},y.transmux=function(d,o,C,S,x){var M;return o&&o.method==="SAMPLE-AES"?M=this.transmuxSampleAes(d,o,C,S,x):M=this.transmuxUnencrypted(d,C,S,x),M},y.transmuxUnencrypted=function(d,o,C,S){var x=this.demuxer.demux(d,o,!1,!this.config.progressive),M=x.audioTrack,F=x.avcTrack,G=x.id3Track,J=x.textTrack,K=this.remuxer.remux(M,F,G,J,o,C,!1,this.id);return{remuxResult:K,chunkMeta:S}},y.transmuxSampleAes=function(d,o,C,S,x){var M=this;return this.demuxer.demuxSampleAes(d,o,C).then(function(F){var G=M.remuxer.remux(F.audioTrack,F.avcTrack,F.id3Track,F.textTrack,C,S,!1,M.id);return{remuxResult:G,chunkMeta:x}})},y.configureTransmuxer=function(d,o){for(var C=this.config,S=this.observer,x=this.typeSupported,M=this.vendor,F=o.audioCodec,G=o.defaultInitPts,J=o.duration,K=o.initSegmentData,j=o.videoCodec,q,oe=0,ue=u.length;oe<ue;oe++)if(u[oe].demux.probe(d)){q=u[oe];break}q||(g.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),q={demux:N.default,remux:c.default});var ge=this.demuxer,_e=this.remuxer,be=q.remux,Se=q.demux;(!_e||!(_e instanceof be))&&(this.remuxer=new be(S,C,x,M)),(!ge||!(ge instanceof Se))&&(this.demuxer=new Se(S,C,x),this.probe=Se.probe),this.resetInitSegment(K,F,j,J),this.resetInitialTimestamp(G)},y.needsProbing=function(d,o,C){return!this.demuxer||!this.remuxer||o||C},y.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new P.default(this.observer,this.config)),d},w}();function h(w,y){var p=null;return w.byteLength>0&&y!=null&&y.key!=null&&y.iv!==null&&y.method!=null&&(p=y),p}var A=function(y){return{remuxResult:{},chunkMeta:y}};function m(w){return"then"in w&&w.then instanceof Function}var E=function(y,p,d,o,C){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=y,this.videoCodec=p,this.initSegmentData=d,this.duration=o,this.defaultInitPts=C},D=function(y,p,d,o,C){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=y,this.contiguous=p,this.accurateTimeOffset=d,this.trackSwitch=o,this.timeOffset=C}},"./src/demux/tsdemuxer.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"discardEPB",function(){return A});var V=_("./src/demux/adts.ts"),I=_("./src/demux/mpegaudio.ts"),P=_("./src/demux/exp-golomb.ts"),B=_("./src/demux/id3.ts"),N=_("./src/demux/sample-aes.ts"),O=_("./src/events.ts"),R=_("./src/utils/mp4-tools.ts"),f=_("./src/utils/logger.ts"),c=_("./src/errors.ts"),k={video:1,audio:2,id3:3,text:4},T=function(){function m(D,w,y){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=w,this.typeSupported=y}m.probe=function(w){var y=m.syncOffset(w);return y<0?!1:(y&&f.logger.warn("MPEG2-TS detected but first sync word found @ offset "+y+", junk ahead ?"),!0)},m.syncOffset=function(w){for(var y=Math.min(1e3,w.length-3*188),p=0;p<y;){if(w[p]===71&&w[p+188]===71&&w[p+2*188]===71)return p;p++}return-1},m.createTrack=function(w,y){return{container:w==="video"||w==="audio"?"video/mp2t":void 0,type:w,id:k[w],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:w==="audio"?y:void 0}};var E=m.prototype;return E.resetInitSegment=function(w,y,p){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=m.createTrack("video",p),this._audioTrack=m.createTrack("audio",p),this._id3Track=m.createTrack("id3",p),this._txtTrack=m.createTrack("text",p),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=w,this.videoCodec=y,this._duration=p},E.resetTimeStamp=function(){},E.resetContiguity=function(){var w=this._audioTrack,y=this._avcTrack,p=this._id3Track;w&&(w.pesData=null),y&&(y.pesData=null),p&&(p.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},E.demux=function(w,y,p,d){p===void 0&&(p=!1),d===void 0&&(d=!1),p||(this.sampleAes=null);var o,C=this._avcTrack,S=this._audioTrack,x=this._id3Track,M=C.pid,F=C.pesData,G=S.pid,J=x.pid,K=S.pesData,j=x.pesData,q=!1,oe=this.pmtParsed,ue=this._pmtId,ge=w.length;if(this.remainderData&&(w=Object(R.appendUint8Array)(this.remainderData,w),ge=w.length,this.remainderData=null),ge<188&&!d)return this.remainderData=w,{audioTrack:S,avcTrack:C,id3Track:x,textTrack:this._txtTrack};var _e=Math.max(0,m.syncOffset(w));ge-=(ge+_e)%188,ge<w.byteLength&&!d&&(this.remainderData=new Uint8Array(w.buffer,ge,w.buffer.byteLength-ge));for(var be=_e;be<ge;be+=188)if(w[be]===71){var Se=!!(w[be+1]&64),Te=((w[be+1]&31)<<8)+w[be+2],Ce=(w[be+3]&48)>>4,pe=void 0;if(Ce>1){if(pe=be+5+w[be+4],pe===be+188)continue}else pe=be+4;switch(Te){case M:Se&&(F&&(o=a(F))&&this.parseAVCPES(o,!1),F={data:[],size:0}),F&&(F.data.push(w.subarray(pe,be+188)),F.size+=be+188-pe);break;case G:Se&&(K&&(o=a(K))&&(S.isAAC?this.parseAACPES(o):this.parseMPEGPES(o)),K={data:[],size:0}),K&&(K.data.push(w.subarray(pe,be+188)),K.size+=be+188-pe);break;case J:Se&&(j&&(o=a(j))&&this.parseID3PES(o),j={data:[],size:0}),j&&(j.data.push(w.subarray(pe,be+188)),j.size+=be+188-pe);break;case 0:Se&&(pe+=w[pe]+1),ue=this._pmtId=b(w,pe);break;case ue:{Se&&(pe+=w[pe]+1);var se=u(w,pe,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,p);M=se.avc,M>0&&(C.pid=M),G=se.audio,G>0&&(S.pid=G,S.isAAC=se.isAAC),J=se.id3,J>0&&(x.pid=J),q&&!oe&&(f.logger.log("reparse from beginning"),q=!1,be=_e-188),oe=this.pmtParsed=!0;break}case 17:case 8191:break;default:q=!0;break}}else this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});C.pesData=F,S.pesData=K,x.pesData=j;var Re={audioTrack:S,avcTrack:C,id3Track:x,textTrack:this._txtTrack};return d&&this.extractRemainingSamples(Re),Re},E.flush=function(){var w=this.remainderData;this.remainderData=null;var y;return w?y=this.demux(w,-1,!1,!0):y={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(y),this.sampleAes?this.decrypt(y,this.sampleAes):y},E.extractRemainingSamples=function(w){var y=w.audioTrack,p=w.avcTrack,d=w.id3Track,o=p.pesData,C=y.pesData,S=d.pesData,x;o&&(x=a(o))?(this.parseAVCPES(x,!0),p.pesData=null):p.pesData=o,C&&(x=a(C))?(y.isAAC?this.parseAACPES(x):this.parseMPEGPES(x),y.pesData=null):(C!=null&&C.size&&f.logger.log("last AAC PES packet truncated,might overlap between fragments"),y.pesData=C),S&&(x=a(S))?(this.parseID3PES(x),d.pesData=null):d.pesData=S},E.demuxSampleAes=function(w,y,p){var d=this.demux(w,p,!0,!this.config.progressive),o=this.sampleAes=new N.default(this.observer,this.config,y);return this.decrypt(d,o)},E.decrypt=function(w,y){return new Promise(function(p){var d=w.audioTrack,o=w.avcTrack;d.samples&&d.isAAC?y.decryptAacSamples(d.samples,0,function(){o.samples?y.decryptAvcSamples(o.samples,0,0,function(){p(w)}):p(w)}):o.samples&&y.decryptAvcSamples(o.samples,0,0,function(){p(w)})})},E.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},E.parseAVCPES=function(w,y){var p=this,d=this._avcTrack,o=this.parseAVCNALu(w.data),C=!1,S=this.avcSample,x,M=!1;w.data=null,S&&o.length&&!d.audFound&&(l(S,d),S=this.avcSample=g(!1,w.pts,w.dts,"")),o.forEach(function(F){switch(F.type){case 1:{x=!0,S||(S=p.avcSample=g(!0,w.pts,w.dts,"")),C&&(S.debug+="NDR "),S.frame=!0;var G=F.data;if(M&&G.length>4){var J=new P.default(G).readSliceType();(J===2||J===4||J===7||J===9)&&(S.key=!0)}break}case 5:x=!0,S||(S=p.avcSample=g(!0,w.pts,w.dts,"")),C&&(S.debug+="IDR "),S.key=!0,S.frame=!0;break;case 6:{x=!0,C&&S&&(S.debug+="SEI ");var K=new P.default(A(F.data));K.readUByte();for(var j=0,q=0,oe=!1,ue=0;!oe&&K.bytesAvailable>1;){j=0;do ue=K.readUByte(),j+=ue;while(ue===255);q=0;do ue=K.readUByte(),q+=ue;while(ue===255);if(j===4&&K.bytesAvailable!==0){oe=!0;var ge=K.readUByte();if(ge===181){var _e=K.readUShort();if(_e===49){var be=K.readUInt();if(be===1195456820){var Se=K.readUByte();if(Se===3){for(var Te=K.readUByte(),Ce=K.readUByte(),pe=31&Te,se=[Te,Ce],Re=0;Re<pe;Re++)se.push(K.readUByte()),se.push(K.readUByte()),se.push(K.readUByte());h(p._txtTrack.samples,{type:3,pts:w.pts,bytes:se})}}}}}else if(j===5&&K.bytesAvailable!==0){if(oe=!0,q>16){for(var Je=[],Xe=0;Xe<16;Xe++)Je.push(K.readUByte().toString(16)),(Xe===3||Xe===5||Xe===7||Xe===9)&&Je.push("-");for(var Ze=q-16,Ke=new Uint8Array(Ze),Ae=0;Ae<Ze;Ae++)Ke[Ae]=K.readUByte();h(p._txtTrack.samples,{pts:w.pts,payloadType:j,uuid:Je.join(""),userData:Object(B.utf8ArrayToStr)(Ke),userDataBytes:Ke})}}else if(q<K.bytesAvailable)for(var ke=0;ke<q;ke++)K.readUByte()}break}case 7:if(x=!0,M=!0,C&&S&&(S.debug+="SPS "),!d.sps){var He=new P.default(F.data),$e=He.readSPS();d.width=$e.width,d.height=$e.height,d.pixelRatio=$e.pixelRatio,d.sps=[F.data],d.duration=p._duration;for(var ze=F.data.subarray(1,4),Ie="avc1.",Fe=0;Fe<3;Fe++){var ht=ze[Fe].toString(16);ht.length<2&&(ht="0"+ht),Ie+=ht}d.codec=Ie}break;case 8:x=!0,C&&S&&(S.debug+="PPS "),d.pps||(d.pps=[F.data]);break;case 9:x=!1,d.audFound=!0,S&&l(S,d),S=p.avcSample=g(!1,w.pts,w.dts,C?"AUD ":"");break;case 12:x=!1;break;default:x=!1,S&&(S.debug+="unknown NAL "+F.type+" ");break}if(S&&x){var at=S.units;at.push(F)}}),y&&S&&(l(S,d),this.avcSample=null)},E.getLastNalUnit=function(){var w,y=this.avcSample,p;if(!y||y.units.length===0){var d=this._avcTrack.samples;y=d[d.length-1]}if((w=y)!==null&&w!==void 0&&w.units){var o=y.units;p=o[o.length-1]}return p},E.parseAVCNALu=function(w){var y=w.byteLength,p=this._avcTrack,d=p.naluState||0,o=d,C=[],S=0,x,M,F,G=-1,J=0;for(d===-1&&(G=0,J=w[0]&31,d=0,S=1);S<y;){if(x=w[S++],!d){d=x?0:1;continue}if(d===1){d=x?0:2;continue}if(!x)d=3;else if(x===1){if(G>=0){var K={data:w.subarray(G,S-d-1),type:J};C.push(K)}else{var j=this.getLastNalUnit();if(j&&(o&&S<=4-o&&(j.state&&(j.data=j.data.subarray(0,j.data.byteLength-o))),M=S-d-1,M>0)){var q=new Uint8Array(j.data.byteLength+M);q.set(j.data,0),q.set(w.subarray(0,M),j.data.byteLength),j.data=q,j.state=0}}S<y?(F=w[S]&31,G=S,J=F,d=0):d=-1}else d=0}if(G>=0&&d>=0){var oe={data:w.subarray(G,y),type:J,state:d};C.push(oe)}if(C.length===0){var ue=this.getLastNalUnit();if(ue){var ge=new Uint8Array(ue.data.byteLength+w.byteLength);ge.set(ue.data,0),ge.set(w,ue.data.byteLength),ue.data=ge}}return p.naluState=d,C},E.parseAACPES=function(w){var y=0,p=this._audioTrack,d=this.aacOverFlow,o=w.data;if(d){this.aacOverFlow=null;var C=d.sample.unit.byteLength,S=Math.min(d.missing,C),x=C-S;d.sample.unit.set(o.subarray(0,S),x),p.samples.push(d.sample),y=d.missing}var M,F;for(M=y,F=o.length;M<F-1&&!V.isHeader(o,M);M++);if(M!==y){var G,J;if(M<F-1?(G="AAC PES did not start with ADTS header,offset:"+M,J=!1):(G="no ADTS header found in AAC PES",J=!0),f.logger.warn("parsing error:"+G),this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:J,reason:G}),J)return}V.initTrackConfig(p,this.observer,o,M,this.audioCodec);var K;if(w.pts!==void 0)K=w.pts;else if(d){var j=V.getFrameDuration(p.samplerate);K=d.sample.pts+j}else{f.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var q=0;M<F;)if(V.isHeader(o,M)){if(M+5<F){var oe=V.appendFrame(p,o,M,K,q);if(oe)if(oe.missing)this.aacOverFlow=oe;else{M+=oe.length,q++;continue}}break}else M++},E.parseMPEGPES=function(w){var y=w.data,p=y.length,d=0,o=0,C=w.pts;if(C===void 0){f.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<p;)if(I.isHeader(y,o)){var S=I.appendFrame(this._audioTrack,y,o,C,d);if(S)o+=S.length,d++;else break}else o++},E.parseID3PES=function(w){if(w.pts===void 0){f.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(w)},m}();T.minProbeByteLength=188;function g(m,E,D,w){return{key:m,frame:!1,pts:E,dts:D,units:[],debug:w,length:0}}function b(m,E){return(m[E+10]&31)<<8|m[E+11]}function u(m,E,D,w){var y={audio:-1,avc:-1,id3:-1,isAAC:!0},p=(m[E+1]&15)<<8|m[E+2],d=E+3+p-4,o=(m[E+10]&15)<<8|m[E+11];for(E+=12+o;E<d;){var C=(m[E+1]&31)<<8|m[E+2];switch(m[E]){case 207:if(!w){f.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:y.audio===-1&&(y.audio=C);break;case 21:y.id3===-1&&(y.id3=C);break;case 219:if(!w){f.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:y.avc===-1&&(y.avc=C);break;case 3:case 4:D?y.audio===-1&&(y.audio=C,y.isAAC=!1):f.logger.log("MPEG audio found, not supported in this browser");break;case 36:f.logger.warn("Unsupported HEVC stream type found");break;default:break}E+=((m[E+3]&15)<<8|m[E+4])+5}return y}function a(m){var E=0,D,w,y,p,d,o=m.data;if(!m||m.size===0)return null;for(;o[0].length<19&&o.length>1;){var C=new Uint8Array(o[0].length+o[1].length);C.set(o[0]),C.set(o[1],o[0].length),o[0]=C,o.splice(1,1)}D=o[0];var S=(D[0]<<16)+(D[1]<<8)+D[2];if(S===1){if(w=(D[4]<<8)+D[5],w&&w>m.size-6)return null;var x=D[7];x&192&&(p=(D[9]&14)*536870912+(D[10]&255)*4194304+(D[11]&254)*16384+(D[12]&255)*128+(D[13]&254)/2,x&64?(d=(D[14]&14)*536870912+(D[15]&255)*4194304+(D[16]&254)*16384+(D[17]&255)*128+(D[18]&254)/2,p-d>60*9e4&&(f.logger.warn(Math.round((p-d)/9e4)+"s delta between PTS and DTS, align them"),p=d)):d=p),y=D[8];var M=y+9;if(m.size<=M)return null;m.size-=M;for(var F=new Uint8Array(m.size),G=0,J=o.length;G<J;G++){D=o[G];var K=D.byteLength;if(M)if(M>K){M-=K;continue}else D=D.subarray(M),K-=M,M=0;F.set(D,E),E+=K}return w&&(w-=y+3),{data:F,pts:p,dts:d,len:w}}return null}function l(m,E){if(m.units.length&&m.frame){if(m.pts===void 0){var D=E.samples,w=D.length;if(w){var y=D[w-1];m.pts=y.pts,m.dts=y.dts}else{E.dropped++;return}}E.samples.push(m)}m.debug.length&&f.logger.log(m.pts+"/"+m.dts+":"+m.debug)}function h(m,E){var D=m.length;if(D>0){if(E.pts>=m[D-1].pts)m.push(E);else for(var w=D-1;w>=0;w--)if(E.pts<m[w].pts){m.splice(w,0,E);break}}else m.push(E)}function A(m){for(var E=m.byteLength,D=[],w=1;w<E-2;)m[w]===0&&m[w+1]===0&&m[w+2]===3?(D.push(w+2),w+=2):w++;if(D.length===0)return m;var y=E-D.length,p=new Uint8Array(y),d=0;for(w=0;w<y;d++,w++)d===D[0]&&(d++,D.shift()),p[w]=m[d];return p}Y.default=T},"./src/errors.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"ErrorTypes",function(){return V}),_.d(Y,"ErrorDetails",function(){return I});var V;(function(P){P.NETWORK_ERROR="networkError",P.MEDIA_ERROR="mediaError",P.KEY_SYSTEM_ERROR="keySystemError",P.MUX_ERROR="muxError",P.OTHER_ERROR="otherError"})(V||(V={}));var I;(function(P){P.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",P.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",P.KEY_SYSTEM_NO_SESSION="keySystemNoSession",P.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",P.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",P.MANIFEST_LOAD_ERROR="manifestLoadError",P.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",P.MANIFEST_PARSING_ERROR="manifestParsingError",P.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",P.LEVEL_EMPTY_ERROR="levelEmptyError",P.LEVEL_LOAD_ERROR="levelLoadError",P.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",P.LEVEL_SWITCH_ERROR="levelSwitchError",P.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",P.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",P.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",P.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",P.FRAG_LOAD_ERROR="fragLoadError",P.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",P.FRAG_DECRYPT_ERROR="fragDecryptError",P.FRAG_PARSING_ERROR="fragParsingError",P.REMUX_ALLOC_ERROR="remuxAllocError",P.KEY_LOAD_ERROR="keyLoadError",P.KEY_LOAD_TIMEOUT="keyLoadTimeOut",P.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",P.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",P.BUFFER_APPEND_ERROR="bufferAppendError",P.BUFFER_APPENDING_ERROR="bufferAppendingError",P.BUFFER_STALLED_ERROR="bufferStalledError",P.BUFFER_FULL_ERROR="bufferFullError",P.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",P.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",P.INTERNAL_EXCEPTION="internalException",P.INTERNAL_ABORTED="aborted",P.UNKNOWN="unknown"})(I||(I={}))},"./src/events.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"Events",function(){return V});var V;(function(I){I.MEDIA_ATTACHING="hlsMediaAttaching",I.MEDIA_ATTACHED="hlsMediaAttached",I.MEDIA_DETACHING="hlsMediaDetaching",I.MEDIA_DETACHED="hlsMediaDetached",I.BUFFER_RESET="hlsBufferReset",I.BUFFER_CODECS="hlsBufferCodecs",I.BUFFER_CREATED="hlsBufferCreated",I.BUFFER_APPENDING="hlsBufferAppending",I.BUFFER_APPENDED="hlsBufferAppended",I.BUFFER_EOS="hlsBufferEos",I.BUFFER_FLUSHING="hlsBufferFlushing",I.BUFFER_FLUSHED="hlsBufferFlushed",I.MANIFEST_LOADING="hlsManifestLoading",I.MANIFEST_LOADED="hlsManifestLoaded",I.MANIFEST_PARSED="hlsManifestParsed",I.LEVEL_SWITCHING="hlsLevelSwitching",I.LEVEL_SWITCHED="hlsLevelSwitched",I.LEVEL_LOADING="hlsLevelLoading",I.LEVEL_LOADED="hlsLevelLoaded",I.LEVEL_UPDATED="hlsLevelUpdated",I.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",I.LEVELS_UPDATED="hlsLevelsUpdated",I.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",I.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",I.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",I.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",I.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",I.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",I.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",I.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",I.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",I.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",I.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",I.CUES_PARSED="hlsCuesParsed",I.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",I.INIT_PTS_FOUND="hlsInitPtsFound",I.FRAG_LOADING="hlsFragLoading",I.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",I.FRAG_LOADED="hlsFragLoaded",I.FRAG_DECRYPTED="hlsFragDecrypted",I.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",I.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",I.FRAG_PARSING_METADATA="hlsFragParsingMetadata",I.FRAG_PARSED="hlsFragParsed",I.FRAG_BUFFERED="hlsFragBuffered",I.FRAG_CHANGED="hlsFragChanged",I.FPS_DROP="hlsFpsDrop",I.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",I.ERROR="hlsError",I.DESTROYING="hlsDestroying",I.KEY_LOADING="hlsKeyLoading",I.KEY_LOADED="hlsKeyLoaded",I.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",I.BACK_BUFFER_REACHED="hlsBackBufferReached"})(V||(V={}))},"./src/hls.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return m});var V=_("./node_modules/url-toolkit/src/url-toolkit.js"),I=_.n(V),P=_("./src/loader/playlist-loader.ts"),B=_("./src/loader/key-loader.ts"),N=_("./src/controller/id3-track-controller.ts"),O=_("./src/controller/latency-controller.ts"),R=_("./src/controller/level-controller.ts"),f=_("./src/controller/fragment-tracker.ts"),c=_("./src/controller/stream-controller.ts"),k=_("./src/is-supported.ts"),T=_("./src/utils/logger.ts"),g=_("./src/config.ts"),b=_("./node_modules/eventemitter3/index.js"),u=_.n(b),a=_("./src/events.ts"),l=_("./src/errors.ts");function h(E,D){for(var w=0;w<D.length;w++){var y=D[w];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(E,y.key,y)}}function A(E,D,w){return D&&h(E.prototype,D),w&&h(E,w),E}var m=function(){E.isSupported=function(){return Object(k.isSupported)()};function E(w){w===void 0&&(w={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new b.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 y=this.config=Object(g.mergeConfig)(E.DefaultConfig,w);this.userConfig=w,Object(T.enableLogs)(y.debug),this._autoLevelCapping=-1,y.progressive&&Object(g.enableStreamingMode)(y);var p=y.abrController,d=y.bufferController,o=y.capLevelController,C=y.fpsController,S=this.abrController=new p(this),x=this.bufferController=new d(this),M=this.capLevelController=new o(this),F=new C(this),G=new P.default(this),J=new B.default(this),K=new N.default(this),j=this.levelController=new R.default(this),q=new f.FragmentTracker(this),oe=this.streamController=new c.default(this,q);M.setStreamController(oe),F.setStreamController(oe);var ue=[j,oe];this.networkControllers=ue;var ge=[G,J,S,x,M,F,K,q];this.audioTrackController=this.createController(y.audioTrackController,null,ue),this.createController(y.audioStreamController,q,ue),this.subtitleTrackController=this.createController(y.subtitleTrackController,null,ue),this.createController(y.subtitleStreamController,q,ue),this.createController(y.timelineController,null,ge),this.emeController=this.createController(y.emeController,null,ge),this.cmcdController=this.createController(y.cmcdController,null,ge),this.latencyController=this.createController(O.default,null,ge),this.coreComponents=ge}var D=E.prototype;return D.createController=function(y,p,d){if(y){var o=p?new y(this,p):new y(this);return d&&d.push(o),o}return null},D.on=function(y,p,d){d===void 0&&(d=this),this._emitter.on(y,p,d)},D.once=function(y,p,d){d===void 0&&(d=this),this._emitter.once(y,p,d)},D.removeAllListeners=function(y){this._emitter.removeAllListeners(y)},D.off=function(y,p,d,o){d===void 0&&(d=this),this._emitter.off(y,p,d,o)},D.listeners=function(y){return this._emitter.listeners(y)},D.emit=function(y,p,d){return this._emitter.emit(y,p,d)},D.trigger=function(y,p){if(this.config.debug)return this.emit(y,y,p);try{return this.emit(y,y,p)}catch(d){T.logger.error("An internal error happened while handling event "+y+'. Error message: "'+d.message+'". Here is a stacktrace:',d),this.trigger(a.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:y,error:d})}return!1},D.listenerCount=function(y){return this._emitter.listenerCount(y)},D.destroy=function(){T.logger.log("destroy"),this.trigger(a.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(y){return y.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(y){return y.destroy()}),this.coreComponents.length=0},D.attachMedia=function(y){T.logger.log("attachMedia"),this._media=y,this.trigger(a.Events.MEDIA_ATTACHING,{media:y})},D.detachMedia=function(){T.logger.log("detachMedia"),this.trigger(a.Events.MEDIA_DETACHING,void 0),this._media=null},D.loadSource=function(y){this.stopLoad();var p=this.media,d=this.url,o=this.url=V.buildAbsoluteURL(self.location.href,y,{alwaysNormalize:!0});T.logger.log("loadSource:"+o),p&&d&&d!==o&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(p)),this.trigger(a.Events.MANIFEST_LOADING,{url:y})},D.startLoad=function(y){y===void 0&&(y=-1),T.logger.log("startLoad("+y+")"),this.networkControllers.forEach(function(p){p.startLoad(y)})},D.stopLoad=function(){T.logger.log("stopLoad"),this.networkControllers.forEach(function(y){y.stopLoad()})},D.swapAudioCodec=function(){T.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},D.recoverMediaError=function(){T.logger.log("recoverMediaError");var y=this._media;this.detachMedia(),y&&this.attachMedia(y)},D.removeLevel=function(y,p){p===void 0&&(p=0),this.levelController.removeLevel(y,p)},A(E,[{key:"levels",get:function(){var y=this.levelController.levels;return y||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(y){T.logger.log("set currentLevel:"+y),this.loadLevel=y,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(y){T.logger.log("set nextLevel:"+y),this.levelController.manualLevel=y,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(y){T.logger.log("set loadLevel:"+y),this.levelController.manualLevel=y}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(y){this.levelController.nextLoadLevel=y}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(y){T.logger.log("set firstLevel:"+y),this.levelController.firstLevel=y}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(y){T.logger.log("set startLevel:"+y),y!==-1&&(y=Math.max(y,this.minAutoLevel)),this.levelController.startLevel=y}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(y){var p=!!y;p!==this.config.capLevelToPlayerSize&&(p?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=p)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(y){this._autoLevelCapping!==y&&(T.logger.log("set autoLevelCapping:"+y),this._autoLevelCapping=y)}},{key:"bandwidthEstimate",get:function(){var y=this.abrController.bwEstimator;return y?y.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var y=this.levels,p=this.config.minAutoBitrate;if(!y)return 0;for(var d=y.length,o=0;o<d;o++)if(y[o].maxBitrate>p)return o;return 0}},{key:"maxAutoLevel",get:function(){var y=this.levels,p=this.autoLevelCapping,d;return p===-1&&y&&y.length?d=y.length-1:d=p,d}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(y){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,y)}},{key:"audioTracks",get:function(){var y=this.audioTrackController;return y?y.audioTracks:[]}},{key:"audioTrack",get:function(){var y=this.audioTrackController;return y?y.audioTrack:-1},set:function(y){var p=this.audioTrackController;p&&(p.audioTrack=y)}},{key:"subtitleTracks",get:function(){var y=this.subtitleTrackController;return y?y.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var y=this.subtitleTrackController;return y?y.subtitleTrack:-1},set:function(y){var p=this.subtitleTrackController;p&&(p.subtitleTrack=y)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var y=this.subtitleTrackController;return y?y.subtitleDisplay:!1},set:function(y){var p=this.subtitleTrackController;p&&(p.subtitleDisplay=y)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(y){this.config.lowLatencyMode=y}},{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 a.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return E.defaultConfig?E.defaultConfig:g.hlsDefaultConfig},set:function(y){E.defaultConfig=y}}]),E}();m.defaultConfig=void 0},"./src/is-supported.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"isSupported",function(){return P}),_.d(Y,"changeTypeSupported",function(){return B});var V=_("./src/utils/mediasource-helper.ts");function I(){return self.SourceBuffer||self.WebKitSourceBuffer}function P(){var N=Object(V.getMediaSource)();if(!N)return!1;var O=I(),R=N&&typeof N.isTypeSupported=="function"&&N.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),f=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!R&&!!f}function B(){var N,O=I();return typeof(O==null||((N=O.prototype)===null||N===void 0)?void 0:N.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return T}),_.d(Y,"LoadError",function(){return b});var V=_("./src/polyfills/number.ts"),I=_("./src/errors.ts");function P(u,a){u.prototype=Object.create(a.prototype),u.prototype.constructor=u,f(u,a)}function B(u){var a=typeof Map=="function"?new Map:void 0;return B=function(h){if(h===null||!R(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(h))return a.get(h);a.set(h,A)}function A(){return N(h,arguments,c(this).constructor)}return A.prototype=Object.create(h.prototype,{constructor:{value:A,enumerable:!1,writable:!0,configurable:!0}}),f(A,h)},B(u)}function N(u,a,l){return O()?N=Reflect.construct:N=function(A,m,E){var D=[null];D.push.apply(D,m);var w=Function.bind.apply(A,D),y=new w;return E&&f(y,E.prototype),y},N.apply(null,arguments)}function O(){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 R(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function f(u,a){return f=Object.setPrototypeOf||function(h,A){return h.__proto__=A,h},f(u,a)}function c(u){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},c(u)}var k=Math.pow(2,17),T=function(){function u(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var a=u.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(h,A){var m=this,E=h.url;if(!E)return Promise.reject(new b({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(E?"part list":"url")));this.abort();var D=this.config,w=D.fLoader,y=D.loader;return new Promise(function(p,d){m.loader&&m.loader.destroy();var o=m.loader=h.loader=w?new w(D):new y(D),C=g(h),S={timeout:D.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:D.fragLoadingMaxRetryTimeout,highWaterMark:k};h.stats=o.stats,o.load(C,S,{onSuccess:function(M,F,G,J){m.resetLoader(h,o),p({frag:h,part:null,payload:M.data,networkDetails:J})},onError:function(M,F,G){m.resetLoader(h,o),d(new b({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:M,networkDetails:G}))},onAbort:function(M,F,G){m.resetLoader(h,o),d(new b({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:G}))},onTimeout:function(M,F,G){m.resetLoader(h,o),d(new b({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:G}))},onProgress:function(M,F,G,J){A&&A({frag:h,part:null,payload:G,networkDetails:J})}})})},a.loadPart=function(h,A,m){var E=this;this.abort();var D=this.config,w=D.fLoader,y=D.loader;return new Promise(function(p,d){E.loader&&E.loader.destroy();var o=E.loader=h.loader=w?new w(D):new y(D),C=g(h,A),S={timeout:D.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:D.fragLoadingMaxRetryTimeout,highWaterMark:k};A.stats=o.stats,o.load(C,S,{onSuccess:function(M,F,G,J){E.resetLoader(h,o),E.updateStatsFromPart(h,A);var K={frag:h,part:A,payload:M.data,networkDetails:J};m(K),p(K)},onError:function(M,F,G){E.resetLoader(h,o),d(new b({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:A,response:M,networkDetails:G}))},onAbort:function(M,F,G){h.stats.aborted=A.stats.aborted,E.resetLoader(h,o),d(new b({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:A,networkDetails:G}))},onTimeout:function(M,F,G){E.resetLoader(h,o),d(new b({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:A,networkDetails:G}))}})})},a.updateStatsFromPart=function(h,A){var m=h.stats,E=A.stats,D=E.total;if(m.loaded+=E.loaded,D){var w=Math.round(h.duration/A.duration),y=Math.min(Math.round(m.loaded/D),w),p=w-y,d=p*Math.round(m.loaded/y);m.total=m.loaded+d}else m.total=Math.max(m.loaded,m.total);var o=m.loading,C=E.loading;o.start?o.first+=C.first-C.start:(o.start=C.start,o.first=C.first),o.end=C.end},a.resetLoader=function(h,A){h.loader=null,this.loader===A&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),A.destroy()},u}();function g(u,a){a===void 0&&(a=null);var l=a||u,h={frag:u,part:a,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},A=l.byteRangeStartOffset,m=l.byteRangeEndOffset;return Object(V.isFiniteNumber)(A)&&Object(V.isFiniteNumber)(m)&&(h.rangeStart=A,h.rangeEnd=m),h}var b=function(u){P(a,u);function a(l){for(var h,A=arguments.length,m=new Array(A>1?A-1:0),E=1;E<A;E++)m[E-1]=arguments[E];return h=u.call.apply(u,[this].concat(m))||this,h.data=void 0,h.data=l,h}return a}(B(Error))},"./src/loader/fragment.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"ElementaryStreamTypes",function(){return T}),_.d(Y,"BaseSegment",function(){return g}),_.d(Y,"Fragment",function(){return b}),_.d(Y,"Part",function(){return u});var V=_("./src/polyfills/number.ts"),I=_("./node_modules/url-toolkit/src/url-toolkit.js"),P=_.n(I),B=_("./src/utils/logger.ts"),N=_("./src/loader/level-key.ts"),O=_("./src/loader/load-stats.ts");function R(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,f(a,l)}function f(a,l){return f=Object.setPrototypeOf||function(A,m){return A.__proto__=m,A},f(a,l)}function c(a,l){for(var h=0;h<l.length;h++){var A=l[h];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(a,A.key,A)}}function k(a,l,h){return l&&c(a.prototype,l),h&&c(a,h),a}var T;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(T||(T={}));var g=function(){function a(h){var A;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(A={},A[T.AUDIO]=null,A[T.VIDEO]=null,A[T.AUDIOVIDEO]=null,A),this.baseurl=h}var l=a.prototype;return l.setByteRange=function(A,m){var E=A.split("@",2),D=[];E.length===1?D[0]=m?m.byteRangeEndOffset:0:D[0]=parseInt(E[1]),D[1]=parseInt(E[0])+D[0],this._byteRange=D},k(a,[{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(I.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(A){this._url=A}}]),a}(),b=function(a){R(l,a);function l(A,m){var E;return E=a.call(this,m)||this,E._decryptdata=null,E.rawProgramDateTime=null,E.programDateTime=null,E.tagList=[],E.duration=0,E.sn=0,E.levelkey=void 0,E.type=void 0,E.loader=null,E.level=-1,E.cc=0,E.startPTS=void 0,E.endPTS=void 0,E.appendedPTS=void 0,E.startDTS=void 0,E.endDTS=void 0,E.start=0,E.deltaPTS=void 0,E.maxStartPTS=void 0,E.minEndPTS=void 0,E.stats=new O.LoadStats,E.urlId=0,E.data=void 0,E.bitrateTest=!1,E.title=null,E.initSegment=null,E.type=A,E}var h=l.prototype;return h.createInitializationVector=function(m){for(var E=new Uint8Array(16),D=12;D<16;D++)E[D]=m>>8*(15-D)&255;return E},h.setDecryptDataFromLevelKey=function(m,E){var D=m;return(m==null?void 0:m.method)==="AES-128"&&m.uri&&!m.iv&&(D=N.LevelKey.fromURI(m.uri),D.method=m.method,D.iv=this.createInitializationVector(E),D.keyFormat="identity"),D},h.setElementaryStreamInfo=function(m,E,D,w,y,p){p===void 0&&(p=!1);var d=this.elementaryStreams,o=d[m];if(!o){d[m]={startPTS:E,endPTS:D,startDTS:w,endDTS:y,partial:p};return}o.startPTS=Math.min(o.startPTS,E),o.endPTS=Math.max(o.endPTS,D),o.startDTS=Math.min(o.startDTS,w),o.endDTS=Math.max(o.endDTS,y)},h.clearElementaryStreamInfo=function(){var m=this.elementaryStreams;m[T.AUDIO]=null,m[T.VIDEO]=null,m[T.AUDIOVIDEO]=null},k(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var m=this.sn;typeof m!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&B.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),m=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,m)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(V.isFiniteNumber)(this.programDateTime))return null;var m=Object(V.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+m*1e3}},{key:"encrypted",get:function(){var m;return!!((m=this.decryptdata)!==null&&m!==void 0&&m.keyFormat&&this.decryptdata.uri)}}]),l}(g),u=function(a){R(l,a);function l(h,A,m,E,D){var w;w=a.call(this,m)||this,w.fragOffset=0,w.duration=0,w.gap=!1,w.independent=!1,w.relurl=void 0,w.fragment=void 0,w.index=void 0,w.stats=new O.LoadStats,w.duration=h.decimalFloatingPoint("DURATION"),w.gap=h.bool("GAP"),w.independent=h.bool("INDEPENDENT"),w.relurl=h.enumeratedString("URI"),w.fragment=A,w.index=E;var y=h.enumeratedString("BYTERANGE");return y&&w.setByteRange(y,D),D&&(w.fragOffset=D.fragOffset+D.duration),w}return k(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 A=this.elementaryStreams;return!!(A.audio||A.video||A.audiovideo)}}]),l}(g)},"./src/loader/key-loader.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return B});var V=_("./src/events.ts"),I=_("./src/errors.ts"),P=_("./src/utils/logger.ts"),B=function(){function N(R){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=R,this._registerListeners()}var O=N.prototype;return O._registerListeners=function(){this.hls.on(V.Events.KEY_LOADING,this.onKeyLoading,this)},O._unregisterListeners=function(){this.hls.off(V.Events.KEY_LOADING,this.onKeyLoading)},O.destroy=function(){this._unregisterListeners();for(var f in this.loaders){var c=this.loaders[f];c&&c.destroy()}this.loaders={}},O.onKeyLoading=function(f,c){var k=c.frag,T=k.type,g=this.loaders[T];if(!k.decryptdata){P.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var b=k.decryptdata.uri;if(b!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(g&&(P.logger.warn("abort previous key loader for type:"+T),g.abort()),!b){P.logger.warn("key uri is falsy");return}var a=u.loader,l=k.loader=this.loaders[T]=new a(u);this.decrypturl=b,this.decryptkey=null;var h={url:b,frag:k,responseType:"arraybuffer"},A={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(h,A,m)}else this.decryptkey&&(k.decryptdata.key=this.decryptkey,this.hls.trigger(V.Events.KEY_LOADED,{frag:k}))},O.loadsuccess=function(f,c,k){var T=k.frag;if(!T.decryptdata){P.logger.error("after key load, decryptdata unset");return}this.decryptkey=T.decryptdata.key=new Uint8Array(f.data),T.loader=null,delete this.loaders[T.type],this.hls.trigger(V.Events.KEY_LOADED,{frag:T})},O.loaderror=function(f,c){var k=c.frag,T=k.loader;T&&T.abort(),delete this.loaders[k.type],this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:k,response:f})},O.loadtimeout=function(f,c){var k=c.frag,T=k.loader;T&&T.abort(),delete this.loaders[k.type],this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:k})},N}()},"./src/loader/level-details.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"LevelDetails",function(){return N});var V=_("./src/polyfills/number.ts");function I(O,R){for(var f=0;f<R.length;f++){var c=R[f];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(O,c.key,c)}}function P(O,R,f){return R&&I(O.prototype,R),f&&I(O,f),O}var B=10,N=function(){function O(f){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=f}var R=O.prototype;return R.reloaded=function(c){if(!c){this.advanced=!0,this.updated=!0;return}var k=this.lastPartSn-c.lastPartSn,T=this.lastPartIndex-c.lastPartIndex;this.updated=this.endSN!==c.endSN||!!T||!!k,this.advanced=this.endSN>c.endSN||k>0||k===0&&T>0,this.updated||this.advanced?this.misses=Math.floor(c.misses*.6):this.misses=c.misses+1,this.availabilityDelay=c.availabilityDelay},P(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(V.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||B}},{key:"drift",get:function(){var c=this.driftEndTime-this.driftStartTime;if(c>0){var k=this.driftEnd-this.driftStart;return k*1e3/c}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var c;return(c=this.partList)!==null&&c!==void 0&&c.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var c;return(c=this.fragments)!==null&&c!==void 0&&c.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 c;return(c=this.partList)!==null&&c!==void 0&&c.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var c;return(c=this.partList)!==null&&c!==void 0&&c.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"LevelKey",function(){return N});var V=_("./node_modules/url-toolkit/src/url-toolkit.js"),I=_.n(V);function P(O,R){for(var f=0;f<R.length;f++){var c=R[f];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(O,c.key,c)}}function B(O,R,f){return R&&P(O.prototype,R),f&&P(O,f),O}var N=function(){O.fromURL=function(f,c){return new O(f,c)},O.fromURI=function(f){return new O(f)};function O(R,f){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,f?this._uri=Object(V.buildAbsoluteURL)(R,f,{alwaysNormalize:!0}):this._uri=R}return B(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"LoadStats",function(){return V});var V=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(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return l});var V=_("./src/polyfills/number.ts"),I=_("./node_modules/url-toolkit/src/url-toolkit.js"),P=_.n(I),B=_("./src/loader/fragment.ts"),N=_("./src/loader/level-details.ts"),O=_("./src/loader/level-key.ts"),R=_("./src/utils/attr-list.ts"),f=_("./src/utils/logger.ts"),c=_("./src/utils/codecs.ts"),k=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,T=/#EXT-X-MEDIA:(.*)/g,g=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),b=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 a(D){var w,y;return u.test((w=(y=I.parseURL(D))===null||y===void 0?void 0:y.path)!=null?w:"")}var l=function(){function D(){}return D.findGroup=function(y,p){for(var d=0;d<y.length;d++){var o=y[d];if(o.id===p)return o}},D.convertAVC1ToAVCOTI=function(y){var p=y.split(".");if(p.length>2){var d=p.shift()+".";return d+=parseInt(p.shift()).toString(16),d+=("000"+parseInt(p.shift()).toString(16)).substr(-4),d}return y},D.resolve=function(y,p){return I.buildAbsoluteURL(p,y,{alwaysNormalize:!0})},D.parseMasterPlaylist=function(y,p){var d=[],o={},C=!1;k.lastIndex=0;for(var S;(S=k.exec(y))!=null;)if(S[1]){var x=new R.AttrList(S[1]),M={attrs:x,bitrate:x.decimalInteger("AVERAGE-BANDWIDTH")||x.decimalInteger("BANDWIDTH"),name:x.NAME,url:D.resolve(S[2],p)},F=x.decimalResolution("RESOLUTION");F&&(M.width=F.width,M.height=F.height),h((x.CODECS||"").split(/[ ,]+/).filter(function(J){return J}),M),M.videoCodec&&M.videoCodec.indexOf("avc1")!==-1&&(M.videoCodec=D.convertAVC1ToAVCOTI(M.videoCodec)),d.push(M)}else if(S[3]){var G=new R.AttrList(S[3]);G["DATA-ID"]&&(C=!0,o[G["DATA-ID"]]=G)}return{levels:d,sessionData:C?o:null}},D.parseMasterPlaylistMedia=function(y,p,d,o){o===void 0&&(o=[]);var C,S=[],x=0;for(T.lastIndex=0;(C=T.exec(y))!==null;){var M=new R.AttrList(C[1]);if(M.TYPE===d){var F={attrs:M,bitrate:0,id:x++,groupId:M["GROUP-ID"],instreamId:M["INSTREAM-ID"],name:M.NAME||M.LANGUAGE||"",type:d,default:M.bool("DEFAULT"),autoselect:M.bool("AUTOSELECT"),forced:M.bool("FORCED"),lang:M.LANGUAGE,url:M.URI?D.resolve(M.URI,p):""};if(o.length){var G=D.findGroup(o,F.groupId)||o[0];A(F,G,"audioCodec"),A(F,G,"textCodec")}S.push(F)}}return S},D.parseLevelPlaylist=function(y,p,d,o,C){var S=new N.LevelDetails(p),x=S.fragments,M=null,F=0,G=0,J=0,K=0,j=null,q=new B.Fragment(o,p),oe,ue,ge,_e=-1,be=!1;for(g.lastIndex=0,S.m3u8=y;(oe=g.exec(y))!==null;){be&&(be=!1,q=new B.Fragment(o,p),q.start=J,q.sn=F,q.cc=K,q.level=d,M&&(q.initSegment=M,q.rawProgramDateTime=M.rawProgramDateTime));var Se=oe[1];if(Se){q.duration=parseFloat(Se);var Te=(" "+oe[2]).slice(1);q.title=Te||null,q.tagList.push(Te?["INF",Se,Te]:["INF",Se])}else if(oe[3])Object(V.isFiniteNumber)(q.duration)&&(q.start=J,ge&&(q.levelkey=ge),q.sn=F,q.level=d,q.cc=K,q.urlId=C,x.push(q),q.relurl=(" "+oe[3]).slice(1),E(q,j),j=q,J+=q.duration,F++,G=0,be=!0);else if(oe[4]){var Ce=(" "+oe[4]).slice(1);j?q.setByteRange(Ce,j):q.setByteRange(Ce)}else if(oe[5])q.rawProgramDateTime=(" "+oe[5]).slice(1),q.tagList.push(["PROGRAM-DATE-TIME",q.rawProgramDateTime]),_e===-1&&(_e=x.length);else{if(oe=oe[0].match(b),!oe){f.logger.warn("No matches on slow regex match for level playlist!");continue}for(ue=1;ue<oe.length&&!(typeof oe[ue]!="undefined");ue++);var pe=(" "+oe[ue]).slice(1),se=(" "+oe[ue+1]).slice(1),Re=oe[ue+2]?(" "+oe[ue+2]).slice(1):"";switch(pe){case"PLAYLIST-TYPE":S.type=se.toUpperCase();break;case"MEDIA-SEQUENCE":F=S.startSN=parseInt(se);break;case"SKIP":{var Je=new R.AttrList(se),Xe=Je.decimalInteger("SKIPPED-SEGMENTS");if(Object(V.isFiniteNumber)(Xe)){S.skippedSegments=Xe;for(var Ze=Xe;Ze--;)x.unshift(null);F+=Xe}var Ke=Je.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ke&&(S.recentlyRemovedDateranges=Ke.split(" "));break}case"TARGETDURATION":S.targetduration=parseFloat(se);break;case"VERSION":S.version=parseInt(se);break;case"EXTM3U":break;case"ENDLIST":S.live=!1;break;case"#":(se||Re)&&q.tagList.push(Re?[se,Re]:[se]);break;case"DIS":K++;case"GAP":q.tagList.push([pe]);break;case"BITRATE":q.tagList.push([pe,se]);break;case"DISCONTINUITY-SEQ":K=parseInt(se);break;case"KEY":{var Ae,ke=new R.AttrList(se),He=ke.enumeratedString("METHOD"),$e=ke.URI,ze=ke.hexadecimalInteger("IV"),Ie=ke.enumeratedString("KEYFORMATVERSIONS"),Fe=ke.enumeratedString("KEYID"),ht=(Ae=ke.enumeratedString("KEYFORMAT"))!=null?Ae:"identity",at=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(at.indexOf(ht)>-1){f.logger.warn("Keyformat "+ht+" is not supported from the manifest");continue}else if(ht!=="identity")continue;He&&(ge=O.LevelKey.fromURL(p,$e),$e&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(He)>=0&&(ge.method=He,ge.keyFormat=ht,Fe&&(ge.keyID=Fe),Ie&&(ge.keyFormatVersions=Ie),ge.iv=ze));break}case"START":{var tt=new R.AttrList(se),Ye=tt.decimalFloatingPoint("TIME-OFFSET");Object(V.isFiniteNumber)(Ye)&&(S.startTimeOffset=Ye);break}case"MAP":{var lt=new R.AttrList(se);q.relurl=lt.URI,lt.BYTERANGE&&q.setByteRange(lt.BYTERANGE),q.level=d,q.sn="initSegment",ge&&(q.levelkey=ge),q.initSegment=null,M=q,be=!0;break}case"SERVER-CONTROL":{var et=new R.AttrList(se);S.canBlockReload=et.bool("CAN-BLOCK-RELOAD"),S.canSkipUntil=et.optionalFloat("CAN-SKIP-UNTIL",0),S.canSkipDateRanges=S.canSkipUntil>0&&et.bool("CAN-SKIP-DATERANGES"),S.partHoldBack=et.optionalFloat("PART-HOLD-BACK",0),S.holdBack=et.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Qe=new R.AttrList(se);S.partTarget=Qe.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Le=S.partList;Le||(Le=S.partList=[]);var st=G>0?Le[Le.length-1]:void 0,rt=G++,De=new B.Part(new R.AttrList(se),q,p,rt,st);Le.push(De),q.duration+=De.duration;break}case"PRELOAD-HINT":{var Ne=new R.AttrList(se);S.preloadHint=Ne;break}case"RENDITION-REPORT":{var me=new R.AttrList(se);S.renditionReports=S.renditionReports||[],S.renditionReports.push(me);break}default:f.logger.warn("line parsed but not handled: "+oe);break}}}j&&!j.relurl?(x.pop(),J-=j.duration,S.partList&&(S.fragmentHint=j)):S.partList&&(E(q,j),q.cc=K,S.fragmentHint=q);var de=x.length,fe=x[0],ee=x[de-1];if(J+=S.skippedSegments*S.targetduration,J>0&&de&&ee){S.averagetargetduration=J/de;var re=ee.sn;S.endSN=re!=="initSegment"?re:0,fe&&(S.startCC=fe.cc,fe.initSegment||S.fragments.every(function(ne){return ne.relurl&&a(ne.relurl)})&&(f.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),q=new B.Fragment(o,p),q.relurl=ee.relurl,q.level=d,q.sn="initSegment",fe.initSegment=q,S.needSidxRanges=!0))}else S.endSN=0,S.startCC=0;return S.fragmentHint&&(J+=S.fragmentHint.duration),S.totalduration=J,S.endCC=K,_e>0&&m(x,_e),S},D}();function h(D,w){["video","audio","text"].forEach(function(y){var p=D.filter(function(o){return Object(c.isCodecType)(o,y)});if(p.length){var d=p.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});w[y+"Codec"]=d.length>0?d[0]:p[0],D=D.filter(function(o){return p.indexOf(o)===-1})}}),w.unknownCodecs=D}function A(D,w,y){var p=w[y];p&&(D[y]=p)}function m(D,w){for(var y=D[w],p=w;p--;){var d=D[p];if(!d)return;d.programDateTime=y.programDateTime-d.duration*1e3,y=d}}function E(D,w){D.rawProgramDateTime?D.programDateTime=Date.parse(D.rawProgramDateTime):w!=null&&w.programDateTime&&(D.programDateTime=w.endProgramDateTime),Object(V.isFiniteNumber)(D.programDateTime)||(D.programDateTime=null,D.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/polyfills/number.ts"),I=_("./src/events.ts"),P=_("./src/errors.ts"),B=_("./src/utils/logger.ts"),N=_("./src/utils/mp4-tools.ts"),O=_("./src/loader/m3u8-parser.ts"),R=_("./src/types/loader.ts"),f=_("./src/utils/attr-list.ts");function c(g){var b=g.type;switch(b){case R.PlaylistContextType.AUDIO_TRACK:return R.PlaylistLevelType.AUDIO;case R.PlaylistContextType.SUBTITLE_TRACK:return R.PlaylistLevelType.SUBTITLE;default:return R.PlaylistLevelType.MAIN}}function k(g,b){var u=g.url;return(u===void 0||u.indexOf("data:")===0)&&(u=b.url),u}var T=function(){function g(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var b=g.prototype;return b.registerListeners=function(){var a=this.hls;a.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.on(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},b.unregisterListeners=function(){var a=this.hls;a.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(I.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.off(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},b.createInternalLoader=function(a){var l=this.hls.config,h=l.pLoader,A=l.loader,m=h||A,E=new m(l);return a.loader=E,this.loaders[a.type]=E,E},b.getInternalLoader=function(a){return this.loaders[a.type]},b.resetInternalLoader=function(a){this.loaders[a]&&delete this.loaders[a]},b.destroyInternalLoaders=function(){for(var a in this.loaders){var l=this.loaders[a];l&&l.destroy(),this.resetInternalLoader(a)}},b.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},b.onManifestLoading=function(a,l){var h=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:R.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},b.onLevelLoading=function(a,l){var h=l.id,A=l.level,m=l.url,E=l.deliveryDirectives;this.load({id:h,groupId:null,level:A,responseType:"text",type:R.PlaylistContextType.LEVEL,url:m,deliveryDirectives:E})},b.onAudioTrackLoading=function(a,l){var h=l.id,A=l.groupId,m=l.url,E=l.deliveryDirectives;this.load({id:h,groupId:A,level:null,responseType:"text",type:R.PlaylistContextType.AUDIO_TRACK,url:m,deliveryDirectives:E})},b.onSubtitleTrackLoading=function(a,l){var h=l.id,A=l.groupId,m=l.url,E=l.deliveryDirectives;this.load({id:h,groupId:A,level:null,responseType:"text",type:R.PlaylistContextType.SUBTITLE_TRACK,url:m,deliveryDirectives:E})},b.load=function(a){var l,h=this.hls.config,A=this.getInternalLoader(a);if(A){var m=A.context;if(m&&m.url===a.url){B.logger.trace("[playlist-loader]: playlist request ongoing");return}B.logger.log("[playlist-loader]: aborting previous loader for type: "+a.type),A.abort()}var E,D,w,y;switch(a.type){case R.PlaylistContextType.MANIFEST:E=h.manifestLoadingMaxRetry,D=h.manifestLoadingTimeOut,w=h.manifestLoadingRetryDelay,y=h.manifestLoadingMaxRetryTimeout;break;case R.PlaylistContextType.LEVEL:case R.PlaylistContextType.AUDIO_TRACK:case R.PlaylistContextType.SUBTITLE_TRACK:E=0,D=h.levelLoadingTimeOut;break;default:E=h.levelLoadingMaxRetry,D=h.levelLoadingTimeOut,w=h.levelLoadingRetryDelay,y=h.levelLoadingMaxRetryTimeout;break}if(A=this.createInternalLoader(a),(l=a.deliveryDirectives)!==null&&l!==void 0&&l.part){var p;if(a.type===R.PlaylistContextType.LEVEL&&a.level!==null?p=this.hls.levels[a.level].details:a.type===R.PlaylistContextType.AUDIO_TRACK&&a.id!==null?p=this.hls.audioTracks[a.id].details:a.type===R.PlaylistContextType.SUBTITLE_TRACK&&a.id!==null&&(p=this.hls.subtitleTracks[a.id].details),p){var d=p.partTarget,o=p.targetduration;d&&o&&(D=Math.min(Math.max(d*3,o*.8)*1e3,D))}}var C={timeout:D,maxRetry:E,retryDelay:w,maxRetryDelay:y,highWaterMark:0},S={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};A.load(a,C,S)},b.loadsuccess=function(a,l,h,A){if(A===void 0&&(A=null),h.isSidxRequest){this.handleSidxRequest(a,h),this.handlePlaylistLoaded(a,l,h,A);return}this.resetInternalLoader(h.type);var m=a.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,h,"no EXTM3U delimiter",A);return}l.parsing.start=performance.now(),m.indexOf("#EXTINF:")>0||m.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,l,h,A):this.handleMasterPlaylist(a,l,h,A)},b.loaderror=function(a,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!1,a)},b.loadtimeout=function(a,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!0)},b.handleMasterPlaylist=function(a,l,h,A){var m=this.hls,E=a.data,D=k(a,h),w=O.default.parseMasterPlaylist(E,D),y=w.levels,p=w.sessionData;if(!y.length){this.handleManifestParsingError(a,h,"no level found in manifest",A);return}var d=y.map(function(F){return{id:F.attrs.AUDIO,audioCodec:F.audioCodec}}),o=y.map(function(F){return{id:F.attrs.SUBTITLES,textCodec:F.textCodec}}),C=O.default.parseMasterPlaylistMedia(E,D,"AUDIO",d),S=O.default.parseMasterPlaylistMedia(E,D,"SUBTITLES",o),x=O.default.parseMasterPlaylistMedia(E,D,"CLOSED-CAPTIONS");if(C.length){var M=C.some(function(F){return!F.url});!M&&y[0].audioCodec&&!y[0].attrs.AUDIO&&(B.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),C.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new f.AttrList({}),bitrate:0,url:""}))}m.trigger(I.Events.MANIFEST_LOADED,{levels:y,audioTracks:C,subtitles:S,captions:x,url:D,stats:l,networkDetails:A,sessionData:p})},b.handleTrackOrLevelPlaylist=function(a,l,h,A){var m=this.hls,E=h.id,D=h.level,w=h.type,y=k(a,h),p=Object(V.isFiniteNumber)(E)?E:0,d=Object(V.isFiniteNumber)(D)?D:p,o=c(h),C=O.default.parseLevelPlaylist(a.data,y,d,o,p);if(!C.fragments.length){m.trigger(I.Events.ERROR,{type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:y,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(w===R.PlaylistContextType.MANIFEST){var S={attrs:new f.AttrList({}),bitrate:0,details:C,name:"",url:y};m.trigger(I.Events.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:y,stats:l,networkDetails:A,sessionData:null})}if(l.parsing.end=performance.now(),C.needSidxRanges){var x,M=(x=C.fragments[0].initSegment)===null||x===void 0?void 0:x.url;this.load({url:M,isSidxRequest:!0,type:w,level:D,levelDetails:C,id:E,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=C,this.handlePlaylistLoaded(a,l,h,A)},b.handleSidxRequest=function(a,l){var h=Object(N.parseSegmentIndex)(new Uint8Array(a.data));if(!h)return;var A=h.references,m=l.levelDetails;A.forEach(function(E,D){var w=E.info,y=m.fragments[D];y.byteRange.length===0&&y.setByteRange(String(1+w.end-w.start)+"@"+String(w.start)),y.initSegment&&y.initSegment.setByteRange(String(h.moovEndOffset)+"@0")})},b.handleManifestParsingError=function(a,l,h,A){this.hls.trigger(I.Events.ERROR,{type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===R.PlaylistContextType.MANIFEST,url:a.url,reason:h,response:a,context:l,networkDetails:A})},b.handleNetworkError=function(a,l,h,A){h===void 0&&(h=!1),B.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+a.type+" level: "+a.level+" id: "+a.id+' group-id: "'+a.groupId+'"');var m=P.ErrorDetails.UNKNOWN,E=!1,D=this.getInternalLoader(a);switch(a.type){case R.PlaylistContextType.MANIFEST:m=h?P.ErrorDetails.MANIFEST_LOAD_TIMEOUT:P.ErrorDetails.MANIFEST_LOAD_ERROR,E=!0;break;case R.PlaylistContextType.LEVEL:m=h?P.ErrorDetails.LEVEL_LOAD_TIMEOUT:P.ErrorDetails.LEVEL_LOAD_ERROR,E=!1;break;case R.PlaylistContextType.AUDIO_TRACK:m=h?P.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:P.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,E=!1;break;case R.PlaylistContextType.SUBTITLE_TRACK:m=h?P.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:P.ErrorDetails.SUBTITLE_LOAD_ERROR,E=!1;break}D&&this.resetInternalLoader(a.type);var w={type:P.ErrorTypes.NETWORK_ERROR,details:m,fatal:E,url:a.url,loader:D,context:a,networkDetails:l};A&&(w.response=A),this.hls.trigger(I.Events.ERROR,w)},b.handlePlaylistLoaded=function(a,l,h,A){var m=h.type,E=h.level,D=h.id,w=h.groupId,y=h.loader,p=h.levelDetails,d=h.deliveryDirectives;if(!(p!=null&&p.targetduration)){this.handleManifestParsingError(a,h,"invalid target duration",A);return}if(!y)return;p.live&&(y.getCacheAge&&(p.ageHeader=y.getCacheAge()||0),(!y.getCacheAge||isNaN(p.ageHeader))&&(p.ageHeader=0));switch(m){case R.PlaylistContextType.MANIFEST:case R.PlaylistContextType.LEVEL:this.hls.trigger(I.Events.LEVEL_LOADED,{details:p,level:E||0,id:D||0,stats:l,networkDetails:A,deliveryDirectives:d});break;case R.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(I.Events.AUDIO_TRACK_LOADED,{details:p,id:D||0,groupId:w||"",stats:l,networkDetails:A,deliveryDirectives:d});break;case R.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(I.Events.SUBTITLE_TRACK_LOADED,{details:p,id:D||0,groupId:w||"",stats:l,networkDetails:A,deliveryDirectives:d});break}},g}();Y.default=T},"./src/polyfills/number.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"isFiniteNumber",function(){return V}),_.d(Y,"MAX_SAFE_INTEGER",function(){return I});var V=Number.isFinite||function(P){return typeof P=="number"&&isFinite(P)},I=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(ie,Y,_){"use strict";_.r(Y);var V=function(){function I(){}return I.getSilentFrame=function(B,N){switch(B){case"mp4a.40.2":if(N===1)return new Uint8Array([0,200,0,128,35,128]);if(N===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(N===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(N===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(N===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(N===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(N===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(N===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(N===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},I}();Y.default=V},"./src/remux/mp4-generator.ts":function(ie,Y,_){"use strict";_.r(Y);var V=Math.pow(2,32)-1,I=function(){function P(){}return P.init=function(){P.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 N;for(N in P.types)P.types.hasOwnProperty(N)&&(P.types[N]=[N.charCodeAt(0),N.charCodeAt(1),N.charCodeAt(2),N.charCodeAt(3)]);var O=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]),R=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]);P.HDLR_TYPES={video:O,audio:R};var f=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),c=new Uint8Array([0,0,0,0,0,0,0,0]);P.STTS=P.STSC=P.STCO=c,P.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),P.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),P.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),P.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var k=new Uint8Array([105,115,111,109]),T=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);P.FTYP=P.box(P.types.ftyp,k,g,k,T),P.DINF=P.box(P.types.dinf,P.box(P.types.dref,f))},P.box=function(N){for(var O=8,R=arguments.length,f=new Array(R>1?R-1:0),c=1;c<R;c++)f[c-1]=arguments[c];for(var k=f.length,T=k;k--;)O+=f[k].byteLength;var g=new Uint8Array(O);for(g[0]=O>>24&255,g[1]=O>>16&255,g[2]=O>>8&255,g[3]=O&255,g.set(N,4),k=0,O=8;k<T;k++)g.set(f[k],O),O+=f[k].byteLength;return g},P.hdlr=function(N){return P.box(P.types.hdlr,P.HDLR_TYPES[N])},P.mdat=function(N){return P.box(P.types.mdat,N)},P.mdhd=function(N,O){O*=N;var R=Math.floor(O/(V+1)),f=Math.floor(O%(V+1));return P.box(P.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,N>>24&255,N>>16&255,N>>8&255,N&255,R>>24,R>>16&255,R>>8&255,R&255,f>>24,f>>16&255,f>>8&255,f&255,85,196,0,0]))},P.mdia=function(N){return P.box(P.types.mdia,P.mdhd(N.timescale,N.duration),P.hdlr(N.type),P.minf(N))},P.mfhd=function(N){return P.box(P.types.mfhd,new Uint8Array([0,0,0,0,N>>24,N>>16&255,N>>8&255,N&255]))},P.minf=function(N){return N.type==="audio"?P.box(P.types.minf,P.box(P.types.smhd,P.SMHD),P.DINF,P.stbl(N)):P.box(P.types.minf,P.box(P.types.vmhd,P.VMHD),P.DINF,P.stbl(N))},P.moof=function(N,O,R){return P.box(P.types.moof,P.mfhd(N),P.traf(R,O))},P.moov=function(N){for(var O=N.length,R=[];O--;)R[O]=P.trak(N[O]);return P.box.apply(null,[P.types.moov,P.mvhd(N[0].timescale,N[0].duration)].concat(R).concat(P.mvex(N)))},P.mvex=function(N){for(var O=N.length,R=[];O--;)R[O]=P.trex(N[O]);return P.box.apply(null,[P.types.mvex].concat(R))},P.mvhd=function(N,O){O*=N;var R=Math.floor(O/(V+1)),f=Math.floor(O%(V+1)),c=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,N>>24&255,N>>16&255,N>>8&255,N&255,R>>24,R>>16&255,R>>8&255,R&255,f>>24,f>>16&255,f>>8&255,f&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 P.box(P.types.mvhd,c)},P.sdtp=function(N){var O=N.samples||[],R=new Uint8Array(4+O.length),f,c;for(f=0;f<O.length;f++)c=O[f].flags,R[f+4]=c.dependsOn<<4|c.isDependedOn<<2|c.hasRedundancy;return P.box(P.types.sdtp,R)},P.stbl=function(N){return P.box(P.types.stbl,P.stsd(N),P.box(P.types.stts,P.STTS),P.box(P.types.stsc,P.STSC),P.box(P.types.stsz,P.STSZ),P.box(P.types.stco,P.STCO))},P.avc1=function(N){var O=[],R=[],f,c,k;for(f=0;f<N.sps.length;f++)c=N.sps[f],k=c.byteLength,O.push(k>>>8&255),O.push(k&255),O=O.concat(Array.prototype.slice.call(c));for(f=0;f<N.pps.length;f++)c=N.pps[f],k=c.byteLength,R.push(k>>>8&255),R.push(k&255),R=R.concat(Array.prototype.slice.call(c));var T=P.box(P.types.avcC,new Uint8Array([1,O[3],O[4],O[5],252|3,224|N.sps.length].concat(O).concat([N.pps.length]).concat(R))),g=N.width,b=N.height,u=N.pixelRatio[0],a=N.pixelRatio[1];return P.box(P.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,g>>8&255,g&255,b>>8&255,b&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]),T,P.box(P.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),P.box(P.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,a>>24,a>>16&255,a>>8&255,a&255])))},P.esds=function(N){var O=N.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(N.config).concat([6,1,2]))},P.mp4a=function(N){var O=N.samplerate;return P.box(P.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,N.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),P.box(P.types.esds,P.esds(N)))},P.mp3=function(N){var O=N.samplerate;return P.box(P.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,N.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},P.stsd=function(N){return N.type==="audio"?!N.isAAC&&N.codec==="mp3"?P.box(P.types.stsd,P.STSD,P.mp3(N)):P.box(P.types.stsd,P.STSD,P.mp4a(N)):P.box(P.types.stsd,P.STSD,P.avc1(N))},P.tkhd=function(N){var O=N.id,R=N.duration*N.timescale,f=N.width,c=N.height,k=Math.floor(R/(V+1)),T=Math.floor(R%(V+1));return P.box(P.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,0,0,0,0,k>>24,k>>16&255,k>>8&255,k&255,T>>24,T>>16&255,T>>8&255,T&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,f>>8&255,f&255,0,0,c>>8&255,c&255,0,0]))},P.traf=function(N,O){var R=P.sdtp(N),f=N.id,c=Math.floor(O/(V+1)),k=Math.floor(O%(V+1));return P.box(P.types.traf,P.box(P.types.tfhd,new Uint8Array([0,0,0,0,f>>24,f>>16&255,f>>8&255,f&255])),P.box(P.types.tfdt,new Uint8Array([1,0,0,0,c>>24,c>>16&255,c>>8&255,c&255,k>>24,k>>16&255,k>>8&255,k&255])),P.trun(N,R.length+16+20+8+16+8+8),R)},P.trak=function(N){return N.duration=N.duration||4294967295,P.box(P.types.trak,P.tkhd(N),P.mdia(N))},P.trex=function(N){var O=N.id;return P.box(P.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},P.trun=function(N,O){var R=N.samples||[],f=R.length,c=12+16*f,k=new Uint8Array(c),T,g,b,u,a,l;for(O+=8+c,k.set([0,0,15,1,f>>>24&255,f>>>16&255,f>>>8&255,f&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),T=0;T<f;T++)g=R[T],b=g.duration,u=g.size,a=g.flags,l=g.cts,k.set([b>>>24&255,b>>>16&255,b>>>8&255,b&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.paddingValue<<1|a.isNonSync,a.degradPrio&240<<8,a.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*T);return P.box(P.types.trun,k)},P.initSegment=function(N){P.types||P.init();var O=P.moov(N),R=new Uint8Array(P.FTYP.byteLength+O.byteLength);return R.set(P.FTYP),R.set(O,P.FTYP.byteLength),R},P}();I.types=void 0,I.HDLR_TYPES=void 0,I.STTS=void 0,I.STSC=void 0,I.STCO=void 0,I.STSZ=void 0,I.VMHD=void 0,I.SMHD=void 0,I.STSD=void 0,I.FTYP=void 0,I.DINF=void 0,Y.default=I},"./src/remux/mp4-remuxer.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return l}),_.d(Y,"normalizePts",function(){return h});var V=_("./src/polyfills/number.ts"),I=_("./src/remux/aac-helper.ts"),P=_("./src/remux/mp4-generator.ts"),B=_("./src/events.ts"),N=_("./src/errors.ts"),O=_("./src/utils/logger.ts"),R=_("./src/types/loader.ts"),f=_("./src/utils/timescale-conversion.ts");function c(){return c=Object.assign||function(D){for(var w=1;w<arguments.length;w++){var y=arguments[w];for(var p in y)Object.prototype.hasOwnProperty.call(y,p)&&(D[p]=y[p])}return D},c.apply(this,arguments)}var k=10*1e3,T=1024,g=1152,b=null,u=null,a=!1,l=function(){function D(y,p,d,o){if(o===void 0&&(o=""),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=y,this.config=p,this.typeSupported=d,this.ISGenerated=!1,b===null){var C=navigator.userAgent||"",S=C.match(/Chrome\/(\d+)/i);b=S?parseInt(S[1]):0}if(u===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);u=x?parseInt(x[1]):0}a=!!b&&b<75||!!u&&u<600}var w=D.prototype;return w.destroy=function(){},w.resetTimeStamp=function(p){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=p},w.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},w.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},w.getVideoStartPts=function(p){var d=!1,o=p.reduce(function(C,S){var x=S.pts-C;return x<-4294967296?(d=!0,h(C,S.pts)):x>0?C:S.pts},p[0].pts);return d&&O.logger.debug("PTS rollover detected"),o},w.remux=function(p,d,o,C,S,x,M,F){var G,J,K,j,q,oe,ue=S,ge=S,_e=p.pid>-1,be=d.pid>-1,Se=d.samples.length,Te=p.samples.length>0,Ce=Se>1,pe=(!_e||Te)&&(!be||Ce)||this.ISGenerated||M;if(pe){this.ISGenerated||(K=this.generateIS(p,d,S));var se=this.isVideoContiguous,Re=-1;if(Ce&&(Re=A(d.samples),!se&&this.config.forceKeyFrameOnDiscontinuity))if(oe=!0,Re>0){O.logger.warn("[mp4-remuxer]: Dropped "+Re+" out of "+Se+" video samples due to a missing keyframe");var Je=this.getVideoStartPts(d.samples);d.samples=d.samples.slice(Re),d.dropped+=Re,ge+=(d.samples[0].pts-Je)/(d.timescale||9e4)}else Re===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+Se+" video samples"),oe=!1);if(this.ISGenerated){if(Te&&Ce){var Xe=this.getVideoStartPts(d.samples),Ze=h(p.samples[0].pts,Xe)-Xe,Ke=Ze/d.inputTimeScale;ue+=Math.max(0,Ke),ge+=Math.max(0,-Ke)}if(Te){if(p.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),K=this.generateIS(p,d,S)),J=this.remuxAudio(p,ue,this.isAudioContiguous,x,be||Ce||F===R.PlaylistLevelType.AUDIO?ge:void 0),Ce){var Ae=J?J.endPTS-J.startPTS:0;d.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),K=this.generateIS(p,d,S)),G=this.remuxVideo(d,ge,se,Ae)}}else Ce&&(G=this.remuxVideo(d,ge,se,0));G&&(G.firstKeyFrame=Re,G.independent=Re!==-1)}}return this.ISGenerated&&(o.samples.length&&(q=this.remuxID3(o,S)),C.samples.length&&(j=this.remuxText(C,S))),{audio:J,video:G,initSegment:K,independent:oe,text:j,id3:q}},w.generateIS=function(p,d,o){var C=p.samples,S=d.samples,x=this.typeSupported,M={},F=!Object(V.isFiniteNumber)(this._initPTS),G="audio/mp4",J,K,j;if(F&&(J=K=Infinity),p.config&&C.length&&(p.timescale=p.samplerate,p.isAAC||(x.mpeg?(G="audio/mpeg",p.codec=""):x.mp3&&(p.codec="mp3")),M.audio={id:"audio",container:G,codec:p.codec,initSegment:!p.isAAC&&x.mpeg?new Uint8Array(0):P.default.initSegment([p]),metadata:{channelCount:p.channelCount}},F&&(j=p.inputTimeScale,J=K=C[0].pts-Math.round(j*o))),d.sps&&d.pps&&S.length&&(d.timescale=d.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:d.codec,initSegment:P.default.initSegment([d]),metadata:{width:d.width,height:d.height}},F)){j=d.inputTimeScale;var q=this.getVideoStartPts(S),oe=Math.round(j*o);K=Math.min(K,h(S[0].dts,q)-oe),J=Math.min(J,q-oe)}if(Object.keys(M).length)return this.ISGenerated=!0,F&&(this._initPTS=J,this._initDTS=K),{tracks:M,initPTS:J,timescale:j}},w.remuxVideo=function(p,d,o,C){var S=p.inputTimeScale,x=p.samples,M=[],F=x.length,G=this._initPTS,J=this.nextAvcDts,K=8,j,q,oe,ue=Number.POSITIVE_INFINITY,ge=Number.NEGATIVE_INFINITY,_e=0,be=!1;if(!o||J===null){var Se=d*S,Te=x[0].pts-h(x[0].dts,x[0].pts);J=Se-Te}for(var Ce=0;Ce<F;Ce++){var pe=x[Ce];if(pe.pts=h(pe.pts-G,J),pe.dts=h(pe.dts-G,J),pe.dts>pe.pts){var se=9e4*.2;_e=Math.max(Math.min(_e,pe.pts-pe.dts),-1*se)}pe.dts<x[Ce>0?Ce-1:Ce].dts&&(be=!0)}be&&x.sort(function(ct,ft){var Ge=ct.dts-ft.dts,_t=ct.pts-ft.pts;return Ge||_t}),q=x[0].dts,oe=x[x.length-1].dts;var Re=Math.round((oe-q)/(F-1));if(_e<0){if(_e<Re*-2){O.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(f.toMsFromMpegTsClock)(-Re,!0)+" ms");for(var Je=_e,Xe=0;Xe<F;Xe++)x[Xe].dts=Je=Math.max(Je,x[Xe].pts-Re),x[Xe].pts=Math.max(Je,x[Xe].pts)}else{O.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(f.toMsFromMpegTsClock)(_e,!0)+" ms to overcome this issue");for(var Ze=0;Ze<F;Ze++)x[Ze].dts=x[Ze].dts+_e}q=x[0].dts}if(o){var Ke=q-J,Ae=Ke>Re,ke=Ke<-1;if(Ae||ke){Ae?O.logger.warn("AVC: "+Object(f.toMsFromMpegTsClock)(Ke,!0)+" ms ("+Ke+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(f.toMsFromMpegTsClock)(-Ke,!0)+" ms ("+Ke+"dts) overlapping between fragments detected"),q=J;var He=x[0].pts-Ke;x[0].dts=q,x[0].pts=He,O.logger.log("Video: First PTS/DTS adjusted: "+Object(f.toMsFromMpegTsClock)(He,!0)+"/"+Object(f.toMsFromMpegTsClock)(q,!0)+", delta: "+Object(f.toMsFromMpegTsClock)(Ke,!0)+" ms")}}a&&(q=Math.max(0,q));for(var $e=0,ze=0,Ie=0;Ie<F;Ie++){for(var Fe=x[Ie],ht=Fe.units,at=ht.length,tt=0,Ye=0;Ye<at;Ye++)tt+=ht[Ye].data.length;ze+=tt,$e+=at,Fe.length=tt,Fe.dts=Math.max(Fe.dts,q),Fe.pts=Math.max(Fe.pts,Fe.dts,0),ue=Math.min(Fe.pts,ue),ge=Math.max(Fe.pts,ge)}oe=x[F-1].dts;var lt=ze+4*$e+8,et;try{et=new Uint8Array(lt)}catch(ct){this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:N.ErrorTypes.MUX_ERROR,details:N.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:lt,reason:"fail allocating video mdat "+lt});return}var Qe=new DataView(et.buffer);Qe.setUint32(0,lt),et.set(P.default.types.mdat,4);for(var Le=0;Le<F;Le++){for(var st=x[Le],rt=st.units,De=0,Ne=0,me=rt.length;Ne<me;Ne++){var de=rt[Ne],fe=de.data,ee=de.data.byteLength;Qe.setUint32(K,ee),K+=4,et.set(fe,K),K+=ee,De+=4+ee}if(Le<F-1)j=x[Le+1].dts-st.dts;else{var re=this.config,ne=st.dts-x[Le>0?Le-1:Le].dts;if(re.stretchShortVideoTrack&&this.nextAudioPts!==null){var ae=Math.floor(re.maxBufferHole*S),ye=(C?ue+C*S:this.nextAudioPts)-st.pts;ye>ae?(j=ye-ne,j<0&&(j=ne),O.logger.log("[mp4-remuxer]: It is approximately "+ye/90+" ms to the next segment; using duration "+j/90+" ms for the last video frame.")):j=ne}else j=ne}var we=Math.round(st.pts-st.dts);M.push(new m(st.key,j,De,we))}if(M.length&&b&&b<70){var je=M[0].flags;je.dependsOn=2,je.isNonSync=0}console.assert(j!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=J=oe+j,this.isVideoContiguous=!0;var ot=P.default.moof(p.sequenceNumber++,q,c({},p,{samples:M})),xt="video",Oe={data1:ot,data2:et,startPTS:ue/S,endPTS:(ge+j)/S,startDTS:q/S,endDTS:J/S,type:xt,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:p.dropped};return p.samples=[],p.dropped=0,console.assert(et.length,"MDAT length must not be zero"),Oe},w.remuxAudio=function(p,d,o,C,S){var x=p.inputTimeScale,M=p.samplerate?p.samplerate:x,F=x/M,G=p.isAAC?T:g,J=G*F,K=this._initPTS,j=!p.isAAC&&this.typeSupported.mpeg,q=[],oe=p.samples,ue=j?0:8,ge=this.nextAudioPts||-1,_e=d*x;if(this.isAudioContiguous=o=o||oe.length&&ge>0&&(C&&Math.abs(_e-ge)<9e3||Math.abs(h(oe[0].pts-K,_e)-ge)<20*J),oe.forEach(function(fe){fe.pts=h(fe.pts-K,_e)}),!o||ge<0){if(oe=oe.filter(function(fe){return fe.pts>=0}),!oe.length)return;S===0?ge=0:C?ge=Math.max(0,_e):ge=oe[0].pts}if(p.isAAC)for(var be=S!==void 0,Se=this.config.maxAudioFramesDrift,Te=0,Ce=ge;Te<oe.length;Te++){var pe=oe[Te],se=pe.pts,Re=se-Ce,Je=Math.abs(1e3*Re/x);if(Re<=-Se*J&&be)Te===0&&(O.logger.warn("Audio frame @ "+(se/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Re/x)+" ms."),this.nextAudioPts=ge=Ce=se);else if(Re>=Se*J&&Je<k&&be){var Xe=Math.round(Re/J);Ce=se-Xe*J,Ce<0&&(Xe--,Ce+=J),Te===0&&(this.nextAudioPts=ge=Ce),O.logger.warn("[mp4-remuxer]: Injecting "+Xe+" audio frame @ "+(Ce/x).toFixed(3)+"s due to "+Math.round(1e3*Re/x)+" ms gap.");for(var Ze=0;Ze<Xe;Ze++){var Ke=Math.max(Ce,0),Ae=I.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);Ae||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ae=pe.unit.subarray()),oe.splice(Te,0,{unit:Ae,pts:Ke}),Ce+=J,Te++}}pe.pts=Ce,Ce+=J}for(var ke=null,He=null,$e,ze=0,Ie=oe.length;Ie--;)ze+=oe[Ie].unit.byteLength;for(var Fe=0,ht=oe.length;Fe<ht;Fe++){var at=oe[Fe],tt=at.unit,Ye=at.pts;if(He!==null){var lt=q[Fe-1];lt.duration=Math.round((Ye-He)/F)}else if(o&&p.isAAC&&(Ye=ge),ke=Ye,ze>0){ze+=ue;try{$e=new Uint8Array(ze)}catch(fe){this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:N.ErrorTypes.MUX_ERROR,details:N.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ze,reason:"fail allocating audio mdat "+ze});return}if(!j){var et=new DataView($e.buffer);et.setUint32(0,ze),$e.set(P.default.types.mdat,4)}}else return;$e.set(tt,ue);var Qe=tt.byteLength;ue+=Qe,q.push(new m(!0,G,Qe,0)),He=Ye}var Le=q.length;if(!Le)return;var st=q[q.length-1];this.nextAudioPts=ge=He+F*st.duration;var rt=j?new Uint8Array(0):P.default.moof(p.sequenceNumber++,ke/F,c({},p,{samples:q}));p.samples=[];var De=ke/x,Ne=ge/x,me="audio",de={data1:rt,data2:$e,startPTS:De,endPTS:Ne,startDTS:De,endDTS:Ne,type:me,hasAudio:!0,hasVideo:!1,nb:Le};return this.isAudioContiguous=!0,console.assert($e.length,"MDAT length must not be zero"),de},w.remuxEmptyAudio=function(p,d,o,C){var S=p.inputTimeScale,x=p.samplerate?p.samplerate:S,M=S/x,F=this.nextAudioPts,G=(F!==null?F:C.startDTS*S)+this._initDTS,J=C.endDTS*S+this._initDTS,K=M*T,j=Math.ceil((J-G)/K),q=I.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!q){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var oe=[],ue=0;ue<j;ue++){var ge=G+ue*K;oe.push({unit:q,pts:ge,dts:ge})}return p.samples=oe,this.remuxAudio(p,d,o,!1)},w.remuxID3=function(p,d){var o=p.samples.length;if(!o)return;for(var C=p.inputTimeScale,S=this._initPTS,x=this._initDTS,M=0;M<o;M++){var F=p.samples[M];F.pts=h(F.pts-S,d*C)/C,F.dts=h(F.dts-x,d*C)/C}var G=p.samples;return p.samples=[],{samples:G}},w.remuxText=function(p,d){var o=p.samples.length;if(!o)return;for(var C=p.inputTimeScale,S=this._initPTS,x=0;x<o;x++){var M=p.samples[x];M.pts=h(M.pts-S,d*C)/C}p.samples.sort(function(G,J){return G.pts-J.pts});var F=p.samples;return p.samples=[],{samples:F}},D}();function h(D,w){var y;if(w===null)return D;for(w<D?y=-8589934592:y=8589934592;Math.abs(D-w)>4294967296;)D+=y;return D}function A(D){for(var w=0;w<D.length;w++)if(D[w].key)return w;return-1}var m=function(w,y,p,d){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=y,this.size=p,this.cts=d,this.flags=new E(w)},E=function(w){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=w?2:1,this.isNonSync=w?0:1}},"./src/remux/passthrough-remuxer.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/polyfills/number.ts"),I=_("./src/utils/mp4-tools.ts"),P=_("./src/loader/fragment.ts"),B=_("./src/utils/logger.ts"),N=function(){function f(){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 c=f.prototype;return c.destroy=function(){},c.resetTimeStamp=function(T){this.initPTS=T,this.lastEndDTS=null},c.resetNextTimestamp=function(){this.lastEndDTS=null},c.resetInitSegment=function(T,g,b){this.audioCodec=g,this.videoCodec=b,this.generateInitSegment(T),this.emitInitSegment=!0},c.generateInitSegment=function(T){var g=this.audioCodec,b=this.videoCodec;if(!T||!T.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(I.parseInitSegment)(T);g||(g=R(u.audio,P.ElementaryStreamTypes.AUDIO)),b||(b=R(u.video,P.ElementaryStreamTypes.VIDEO));var a={};u.audio&&u.video?a.audiovideo={container:"video/mp4",codec:g+","+b,initSegment:T,id:"main"}:u.audio?a.audio={container:"audio/mp4",codec:g,initSegment:T,id:"audio"}:u.video?a.video={container:"video/mp4",codec:b,initSegment:T,id:"main"}:B.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},c.remux=function(T,g,b,u,a){var l=this.initPTS,h=this.lastEndDTS,A={audio:void 0,video:void 0,text:u,id3:b,initSegment:void 0};Object(V.isFiniteNumber)(h)||(h=this.lastEndDTS=a||0);var m=g.samples;if(!m||!m.length)return A;var E={initPTS:void 0,timescale:1},D=this.initData;if((!D||!D.length)&&(this.generateInitSegment(m),D=this.initData),!D||!D.length)return B.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),A;this.emitInitSegment&&(E.tracks=this.initTracks,this.emitInitSegment=!1),Object(V.isFiniteNumber)(l)||(this.initPTS=E.initPTS=l=O(D,m,h));var w=Object(I.getDuration)(m,D),y=h,p=w+y;Object(I.offsetStartDTS)(D,m,l),w>0?this.lastEndDTS=p:(B.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!D.audio,o=!!D.video,C="";d&&(C+="audio"),o&&(C+="video");var S={data1:m,startPTS:y,startDTS:y,endPTS:p,endDTS:p,type:C,hasAudio:d,hasVideo:o,nb:1,dropped:0};return A.audio=S.type==="audio"?S:void 0,A.video=S.type!=="audio"?S:void 0,A.text=u,A.id3=b,A.initSegment=E,A},f}(),O=function(c,k,T){return Object(I.getStartDTS)(c,k)-T};function R(f,c){var k=f==null?void 0:f.codec;return k&&k.length>4?k:k==="hvc1"?"hvc1.1.c.L120.90":k==="av01"?"av01.0.04M.08":k==="avc1"||c===P.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}Y.default=N},"./src/task-loop.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return V});var V=function(){function I(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var P=I.prototype;return P.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},P.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},P.onHandlerDestroyed=function(){},P.hasInterval=function(){return!!this._tickInterval},P.hasNextTick=function(){return!!this._tickTimer},P.setInterval=function(N){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,N),!0)},P.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},P.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},P.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},P.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},P.doTick=function(){},I}()},"./src/types/cmcd.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"CMCDVersion",function(){return V}),_.d(Y,"CMCDObjectType",function(){return I}),_.d(Y,"CMCDStreamingFormat",function(){return P}),_.d(Y,"CMCDStreamType",function(){return B});var V=1,I;(function(N){N.MANIFEST="m",N.AUDIO="a",N.VIDEO="v",N.MUXED="av",N.INIT="i",N.CAPTION="c",N.TIMED_TEXT="tt",N.KEY="k",N.OTHER="o"})(I||(I={}));var P;(function(N){N.DASH="d",N.HLS="h",N.SMOOTH="s",N.OTHER="o"})(P||(P={}));var B;(function(N){N.VOD="v",N.LIVE="l"})(B||(B={}))},"./src/types/level.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"HlsSkip",function(){return P}),_.d(Y,"getSkipValue",function(){return B}),_.d(Y,"HlsUrlParameters",function(){return N}),_.d(Y,"Level",function(){return O});function V(R,f){for(var c=0;c<f.length;c++){var k=f[c];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(R,k.key,k)}}function I(R,f,c){return f&&V(R.prototype,f),c&&V(R,c),R}var P;(function(R){R.No="",R.Yes="YES",R.v2="v2"})(P||(P={}));function B(R,f){var c=R.canSkipUntil,k=R.canSkipDateRanges,T=R.endSN,g=f!==void 0?f-T:0;return c&&g<c?k?P.v2:P.Yes:P.No}var N=function(){function R(c,k,T){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=c,this.part=k,this.skip=T}var f=R.prototype;return f.addDirectives=function(k){var T=new self.URL(k);return this.msn!==void 0&&T.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&T.searchParams.set("_HLS_part",this.part.toString()),this.skip&&T.searchParams.set("_HLS_skip",this.skip),T.toString()},R}(),O=function(){function R(f){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=[f.url],this.attrs=f.attrs,this.bitrate=f.bitrate,f.details&&(this.details=f.details),this.id=f.id||0,this.name=f.name,this.width=f.width||0,this.height=f.height||0,this.audioCodec=f.audioCodec,this.videoCodec=f.videoCodec,this.unknownCodecs=f.unknownCodecs,this.codecSet=[f.videoCodec,f.audioCodec].filter(function(c){return c}).join(",").replace(/\.[^.,]+/g,"")}return I(R,[{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(c){var k=c%this.url.length;this._urlId!==k&&(this.details=void 0,this._urlId=k)}}]),R}()},"./src/types/loader.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"PlaylistContextType",function(){return V}),_.d(Y,"PlaylistLevelType",function(){return I});var V;(function(P){P.MANIFEST="manifest",P.LEVEL="level",P.AUDIO_TRACK="audioTrack",P.SUBTITLE_TRACK="subtitleTrack"})(V||(V={}));var I;(function(P){P.MAIN="main",P.AUDIO="audio",P.SUBTITLE="subtitle"})(I||(I={}))},"./src/types/transmuxer.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"ChunkMetadata",function(){return V});var V=function(B,N,O,R,f,c){R===void 0&&(R=0),f===void 0&&(f=-1),c===void 0&&(c=!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=I(),this.buffering={audio:I(),video:I(),audiovideo:I()},this.level=B,this.sn=N,this.id=O,this.size=R,this.part=f,this.partial=c};function I(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"AttrList",function(){return P});var V=/^(\d+)x(\d+)$/,I=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,P=function(){function B(O){typeof O=="string"&&(O=B.parseAttrList(O));for(var R in O)O.hasOwnProperty(R)&&(this[R]=O[R])}var N=B.prototype;return N.decimalInteger=function(R){var f=parseInt(this[R],10);return f>Number.MAX_SAFE_INTEGER?Infinity:f},N.hexadecimalInteger=function(R){if(this[R]){var f=(this[R]||"0x").slice(2);f=(f.length&1?"0":"")+f;for(var c=new Uint8Array(f.length/2),k=0;k<f.length/2;k++)c[k]=parseInt(f.slice(k*2,k*2+2),16);return c}else return null},N.hexadecimalIntegerAsNumber=function(R){var f=parseInt(this[R],16);return f>Number.MAX_SAFE_INTEGER?Infinity:f},N.decimalFloatingPoint=function(R){return parseFloat(this[R])},N.optionalFloat=function(R,f){var c=this[R];return c?parseFloat(c):f},N.enumeratedString=function(R){return this[R]},N.bool=function(R){return this[R]==="YES"},N.decimalResolution=function(R){var f=V.exec(this[R]);return f===null?void 0:{width:parseInt(f[1],10),height:parseInt(f[2],10)}},B.parseAttrList=function(R){var f,c={},k='"';for(I.lastIndex=0;(f=I.exec(R))!==null;){var T=f[2];T.indexOf(k)===0&&T.lastIndexOf(k)===T.length-1&&(T=T.slice(1,-1)),c[f[1]]=T}return c},B}()},"./src/utils/binary-search.ts":function(ie,Y,_){"use strict";_.r(Y);var V={search:function(P,B){for(var N=0,O=P.length-1,R=null,f=null;N<=O;){R=(N+O)/2|0,f=P[R];var c=B(f);if(c>0)N=R+1;else if(c<0)O=R-1;else return f}return null}};Y.default=V},"./src/utils/buffer-helper.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"BufferHelper",function(){return P});var V=_("./src/utils/logger.ts"),I={length:0,start:function(){return 0},end:function(){return 0}},P=function(){function B(){}return B.isBuffered=function(O,R){try{if(O){for(var f=B.getBuffered(O),c=0;c<f.length;c++)if(R>=f.start(c)&&R<=f.end(c))return!0}}catch(k){}return!1},B.bufferInfo=function(O,R,f){try{if(O){var c=B.getBuffered(O),k=[],T;for(T=0;T<c.length;T++)k.push({start:c.start(T),end:c.end(T)});return this.bufferedInfo(k,R,f)}}catch(g){}return{len:0,start:R,end:R,nextStart:void 0}},B.bufferedInfo=function(O,R,f){R=Math.max(0,R),O.sort(function(E,D){var w=E.start-D.start;return w||D.end-E.end});var c=[];if(f)for(var k=0;k<O.length;k++){var T=c.length;if(T){var g=c[T-1].end;O[k].start-g<f?O[k].end>g&&(c[T-1].end=O[k].end):c.push(O[k])}else c.push(O[k])}else c=O;for(var b=0,u,a=R,l=R,h=0;h<c.length;h++){var A=c[h].start,m=c[h].end;if(R+f>=A&&R<m)a=A,l=m,b=l-R;else if(R+f<A){u=A;break}}return{len:b,start:a||0,end:l||0,nextStart:u}},B.getBuffered=function(O){try{return O.buffered}catch(R){return V.logger.log("failed to get media.buffered",R),I}},B}()},"./src/utils/cea-608-parser.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"Row",function(){return l}),_.d(Y,"CaptionScreen",function(){return h});var V=_("./src/utils/logger.ts"),I={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},P=function(p){var d=p;return I.hasOwnProperty(p)&&(d=I[p]),String.fromCharCode(d)},B=15,N=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},R={17:2,18:4,21:6,22:8,23:10,19:13,20:15},f={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},c={25:2,26:4,29:6,30:8,31:10,27:13,28:15},k=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],T;(function(y){y[y.ERROR=0]="ERROR",y[y.TEXT=1]="TEXT",y[y.WARNING=2]="WARNING",y[y.INFO=2]="INFO",y[y.DEBUG=3]="DEBUG",y[y.DATA=3]="DATA"})(T||(T={}));var g=function(){function y(){this.time=null,this.verboseLevel=T.ERROR}var p=y.prototype;return p.log=function(o,C){this.verboseLevel>=o&&V.logger.log(this.time+" ["+o+"] "+C)},y}(),b=function(p){for(var d=[],o=0;o<p.length;o++)d.push(p[o].toString(16));return d},u=function(){function y(d,o,C,S,x){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=o||!1,this.italics=C||!1,this.background=S||"black",this.flash=x||!1}var p=y.prototype;return p.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},p.setStyles=function(o){for(var C=["foreground","underline","italics","background","flash"],S=0;S<C.length;S++){var x=C[S];o.hasOwnProperty(x)&&(this[x]=o[x])}},p.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},p.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},p.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},p.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},y}(),a=function(){function y(d,o,C,S,x,M){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new u(o,C,S,x,M)}var p=y.prototype;return p.reset=function(){this.uchar=" ",this.penState.reset()},p.setChar=function(o,C){this.uchar=o,this.penState.copy(C)},p.setPenState=function(o){this.penState.copy(o)},p.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},p.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},p.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},y}(),l=function(){function y(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 o=0;o<N;o++)this.chars.push(new a);this.logger=d,this.pos=0,this.currPenState=new u}var p=y.prototype;return p.equals=function(o){for(var C=!0,S=0;S<N;S++)if(!this.chars[S].equals(o.chars[S])){C=!1;break}return C},p.copy=function(o){for(var C=0;C<N;C++)this.chars[C].copy(o.chars[C])},p.isEmpty=function(){for(var o=!0,C=0;C<N;C++)if(!this.chars[C].isEmpty()){o=!1;break}return o},p.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(T.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>N&&(this.logger.log(T.DEBUG,"Too large cursor position "+this.pos),this.pos=N)},p.moveCursor=function(o){var C=this.pos+o;if(o>1)for(var S=this.pos+1;S<C+1;S++)this.chars[S].setPenState(this.currPenState);this.setCursor(C)},p.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},p.insertChar=function(o){o>=144&&this.backSpace();var C=P(o);if(this.pos>=N){this.logger.log(T.ERROR,"Cannot insert "+o.toString(16)+" ("+C+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(C,this.currPenState),this.moveCursor(1)},p.clearFromPos=function(o){var C;for(C=o;C<N;C++)this.chars[C].reset()},p.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},p.clearToEndOfRow=function(){this.clearFromPos(this.pos)},p.getTextString=function(){for(var o=[],C=!0,S=0;S<N;S++){var x=this.chars[S].uchar;x!==" "&&(C=!1),o.push(x)}return C?"":o.join("")},p.setPenStyles=function(o){this.currPenState.setStyles(o);var C=this.chars[this.pos];C.setPenState(this.currPenState)},y}(),h=function(){function y(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 o=0;o<B;o++)this.rows.push(new l(d));this.logger=d,this.currRow=B-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var p=y.prototype;return p.reset=function(){for(var o=0;o<B;o++)this.rows[o].clear();this.currRow=B-1},p.equals=function(o){for(var C=!0,S=0;S<B;S++)if(!this.rows[S].equals(o.rows[S])){C=!1;break}return C},p.copy=function(o){for(var C=0;C<B;C++)this.rows[C].copy(o.rows[C])},p.isEmpty=function(){for(var o=!0,C=0;C<B;C++)if(!this.rows[C].isEmpty()){o=!1;break}return o},p.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},p.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},p.insertChar=function(o){var C=this.rows[this.currRow];C.insertChar(o)},p.setPen=function(o){var C=this.rows[this.currRow];C.setPenStyles(o)},p.moveCursor=function(o){var C=this.rows[this.currRow];C.moveCursor(o)},p.setCursor=function(o){this.logger.log(T.INFO,"setCursor: "+o);var C=this.rows[this.currRow];C.setCursor(o)},p.setPAC=function(o){this.logger.log(T.INFO,"pacData = "+JSON.stringify(o));var C=o.row-1;if(this.nrRollUpRows&&C<this.nrRollUpRows-1&&(C=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==C){for(var S=0;S<B;S++)this.rows[S].clear();var x=this.currRow+1-this.nrRollUpRows,M=this.lastOutputScreen;if(M){var F=M.rows[x].cueStartTime,G=this.logger.time;if(F&&G!==null&&F<G)for(var J=0;J<this.nrRollUpRows;J++)this.rows[C-this.nrRollUpRows+J+1].copy(M.rows[x+J])}}this.currRow=C;var K=this.rows[this.currRow];if(o.indent!==null){var j=o.indent,q=Math.max(j-1,0);K.setCursor(o.indent),o.color=K.chars[q].penState.foreground}var oe={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(oe)},p.setBkgData=function(o){this.logger.log(T.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},p.setRollUpRows=function(o){this.nrRollUpRows=o},p.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(T.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(T.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,C=this.rows.splice(o,1)[0];C.clear(),this.rows.splice(this.currRow,0,C),this.logger.log(T.INFO,"Rolling up")},p.getDisplayText=function(o){o=o||!1;for(var C=[],S="",x=-1,M=0;M<B;M++){var F=this.rows[M].getTextString();F&&(x=M+1,o?C.push("Row "+x+": '"+F+"'"):C.push(F.trim()))}return C.length>0&&(o?S="["+C.join(" | ")+"]":S=C.join(`
|
|
`)),S},p.getTextAndFormat=function(){return this.rows},y}(),A=function(){function y(d,o,C){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=o,this.mode=null,this.verbose=0,this.displayedMemory=new h(C),this.nonDisplayedMemory=new h(C),this.lastOutputScreen=new h(C),this.currRollUpRow=this.displayedMemory.rows[B-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=C}var p=y.prototype;return p.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[B-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},p.getHandler=function(){return this.outputFilter},p.setHandler=function(o){this.outputFilter=o},p.setPAC=function(o){this.writeScreen.setPAC(o)},p.setBkgData=function(o){this.writeScreen.setBkgData(o)},p.setMode=function(o){if(o===this.mode)return;this.mode=o,this.logger.log(T.INFO,"MODE="+o),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=o},p.insertChars=function(o){for(var C=0;C<o.length;C++)this.writeScreen.insertChar(o[C]);var S=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(T.INFO,S+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(T.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},p.ccRCL=function(){this.logger.log(T.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},p.ccBS=function(){if(this.logger.log(T.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},p.ccAOF=function(){},p.ccAON=function(){},p.ccDER=function(){this.logger.log(T.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},p.ccRU=function(o){this.logger.log(T.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},p.ccFON=function(){this.logger.log(T.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},p.ccRDC=function(){this.logger.log(T.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},p.ccTR=function(){this.logger.log(T.INFO,"TR"),this.setMode("MODE_TEXT")},p.ccRTD=function(){this.logger.log(T.INFO,"RTD"),this.setMode("MODE_TEXT")},p.ccEDM=function(){this.logger.log(T.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},p.ccCR=function(){this.logger.log(T.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},p.ccENM=function(){this.logger.log(T.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},p.ccEOC=function(){if(this.logger.log(T.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(T.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},p.ccTO=function(o){this.logger.log(T.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},p.ccMIDROW=function(o){var C={flash:!1};if(C.underline=o%2===1,C.italics=o>=46,C.italics)C.foreground="white";else{var S=Math.floor(o/2)-16,x=["white","green","blue","cyan","red","yellow","magenta"];C.foreground=x[S]}this.logger.log(T.INFO,"MIDROW: "+JSON.stringify(C)),this.writeScreen.setPen(C)},p.outputDataUpdate=function(o){o===void 0&&(o=!1);var C=this.logger.time;if(C===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=C:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,C,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:C),this.lastOutputScreen.copy(this.displayedMemory))},p.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},y}(),m=function(){function y(d,o,C){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var S=new g;this.channels=[null,new A(d,o,S),new A(d+1,C,S)],this.cmdHistory=w(),this.logger=S}var p=y.prototype;return p.getHandler=function(o){return this.channels[o].getHandler()},p.setHandler=function(o,C){this.channels[o].setHandler(C)},p.addData=function(o,C){var S,x,M,F=!1;this.logger.time=o;for(var G=0;G<C.length;G+=2){if(x=C[G]&127,M=C[G+1]&127,x===0&&M===0)continue;if(this.logger.log(T.DATA,"["+b([C[G],C[G+1]])+"] -> ("+b([x,M])+")"),S=this.parseCmd(x,M),S||(S=this.parseMidrow(x,M)),S||(S=this.parsePAC(x,M)),S||(S=this.parseBackgroundAttributes(x,M)),!S&&(F=this.parseChars(x,M),F)){var J=this.currentChannel;if(J&&J>0){var K=this.channels[J];K.insertChars(F)}else this.logger.log(T.WARNING,"No channel found yet. TEXT-MODE?")}!S&&!F&&this.logger.log(T.WARNING,"Couldn't parse cleaned data "+b([x,M])+" orig: "+b([C[G],C[G+1]]))}},p.parseCmd=function(o,C){var S=this.cmdHistory,x=(o===20||o===28||o===21||o===29)&&C>=32&&C<=47,M=(o===23||o===31)&&C>=33&&C<=35;if(!(x||M))return!1;if(D(o,C,S))return E(null,null,S),this.logger.log(T.DEBUG,"Repeated command ("+b([o,C])+") is dropped"),!0;var F=o===20||o===21||o===23?1:2,G=this.channels[F];return o===20||o===21||o===28||o===29?C===32?G.ccRCL():C===33?G.ccBS():C===34?G.ccAOF():C===35?G.ccAON():C===36?G.ccDER():C===37?G.ccRU(2):C===38?G.ccRU(3):C===39?G.ccRU(4):C===40?G.ccFON():C===41?G.ccRDC():C===42?G.ccTR():C===43?G.ccRTD():C===44?G.ccEDM():C===45?G.ccCR():C===46?G.ccENM():C===47&&G.ccEOC():G.ccTO(C-32),E(o,C,S),this.currentChannel=F,!0},p.parseMidrow=function(o,C){var S=0;if((o===17||o===25)&&C>=32&&C<=47){if(o===17?S=1:S=2,S!==this.currentChannel)return this.logger.log(T.ERROR,"Mismatch channel in midrow parsing"),!1;var x=this.channels[S];return x?(x.ccMIDROW(C),this.logger.log(T.DEBUG,"MIDROW ("+b([o,C])+")"),!0):!1}return!1},p.parsePAC=function(o,C){var S,x=this.cmdHistory,M=(o>=17&&o<=23||o>=25&&o<=31)&&C>=64&&C<=127,F=(o===16||o===24)&&C>=64&&C<=95;if(!(M||F))return!1;if(D(o,C,x))return E(null,null,x),!0;var G=o<=23?1:2;C>=64&&C<=95?S=G===1?O[o]:f[o]:S=G===1?R[o]:c[o];var J=this.channels[G];return J?(J.setPAC(this.interpretPAC(S,C)),E(o,C,x),this.currentChannel=G,!0):!1},p.interpretPAC=function(o,C){var S,x={color:null,italics:!1,indent:null,underline:!1,row:o};return C>95?S=C-96:S=C-64,x.underline=(S&1)===1,S<=13?x.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(S/2)]:S<=15?(x.italics=!0,x.color="white"):x.indent=Math.floor((S-16)/2)*4,x},p.parseChars=function(o,C){var S,x=null,M=null;if(o>=25?(S=2,M=o-8):(S=1,M=o),M>=17&&M<=19){var F;M===17?F=C+80:M===18?F=C+112:F=C+144,this.logger.log(T.INFO,"Special char '"+P(F)+"' in channel "+S),x=[F]}else o>=32&&o<=127&&(x=C===0?[o]:[o,C]);if(x){var G=b(x);this.logger.log(T.DEBUG,"Char codes = "+G.join(",")),E(o,C,this.cmdHistory)}return x},p.parseBackgroundAttributes=function(o,C){var S=(o===16||o===24)&&C>=32&&C<=47,x=(o===23||o===31)&&C>=45&&C<=47;if(!(S||x))return!1;var M,F={};o===16||o===24?(M=Math.floor((C-32)/2),F.background=k[M],C%2===1&&(F.background=F.background+"_semi")):C===45?F.background="transparent":(F.foreground="black",C===47&&(F.underline=!0));var G=o<=23?1:2,J=this.channels[G];return J.setBkgData(F),E(o,C,this.cmdHistory),!0},p.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var C=this.channels[o];C&&C.reset()}this.cmdHistory=w()},p.cueSplitAtTime=function(o){for(var C=0;C<this.channels.length;C++){var S=this.channels[C];S&&S.cueSplitAtTime(o)}},y}();function E(y,p,d){d.a=y,d.b=p}function D(y,p,d){return d.a===y&&d.b===p}function w(){return{a:null,b:null}}Y.default=m},"./src/utils/codecs.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"isCodecType",function(){return I}),_.d(Y,"isCodecSupportedInMp4",function(){return P});var V={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 I(B,N){var O=V[N];return!!O&&O[B.slice(0,4)]===!0}function P(B,N){return MediaSource.isTypeSupported((N||"video")+'/mp4;codecs="'+B+'"')}},"./src/utils/cues.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/utils/vttparser.ts"),I=_("./src/utils/webvtt-parser.ts"),P=_("./src/utils/texttrack-utils.ts"),B=/\s/,N={newCue:function(R,f,c,k){for(var T=[],g,b,u,a,l,h=self.VTTCue||self.TextTrackCue,A=0;A<k.rows.length;A++)if(g=k.rows[A],u=!0,a=0,l="",!g.isEmpty()){for(var m=0;m<g.chars.length;m++)B.test(g.chars[m].uchar)&&u?a++:(l+=g.chars[m].uchar,u=!1);g.cueStartTime=f,f===c&&(c+=1e-4),a>=16?a--:a++;var E=Object(V.fixLineBreaks)(l.trim()),D=Object(I.generateCueId)(f,c,E);(!R||!R.cues||!R.cues.getCueById(D))&&(b=new h(f,c,E),b.id=D,b.line=A+1,b.align="left",b.position=10+Math.min(80,Math.floor(a*8/32)*10),T.push(b))}return R&&T.length&&(T.sort(function(w,y){return w.line==="auto"||y.line==="auto"?0:w.line>8&&y.line>8?y.line-w.line:w.line-y.line}),T.forEach(function(w){return Object(P.addCueToTrack)(R,w)})),T}};Y.default=N},"./src/utils/discontinuities.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"findFirstFragWithCC",function(){return B}),_.d(Y,"shouldAlignOnDiscontinuities",function(){return N}),_.d(Y,"findDiscontinuousReferenceFrag",function(){return O}),_.d(Y,"adjustSlidingStart",function(){return f}),_.d(Y,"alignStream",function(){return c}),_.d(Y,"alignPDT",function(){return T}),_.d(Y,"alignFragmentByPDTDelta",function(){return g}),_.d(Y,"alignMediaPlaylistByPDT",function(){return b});var V=_("./src/polyfills/number.ts"),I=_("./src/utils/logger.ts"),P=_("./src/controller/level-helper.ts");function B(u,a){for(var l=null,h=0,A=u.length;h<A;h++){var m=u[h];if(m&&m.cc===a){l=m;break}}return l}function N(u,a,l){return!!(a.details&&(l.endCC>l.startCC||u&&u.cc<l.startCC))}function O(u,a){var l=u.fragments,h=a.fragments;if(!h.length||!l.length){I.logger.log("No fragments to align");return}var A=B(l,h[0].cc);if(!A||A&&!A.startPTS){I.logger.log("No frag in previous level to align on");return}return A}function R(u,a){if(u){var l=u.start+a;u.start=u.startPTS=l,u.endPTS=l+u.duration}}function f(u,a){for(var l=a.fragments,h=0,A=l.length;h<A;h++)R(l[h],u);a.fragmentHint&&R(a.fragmentHint,u),a.alignedSliding=!0}function c(u,a,l){if(!a)return;k(u,l,a),!l.alignedSliding&&a.details&&T(l,a.details),!l.alignedSliding&&a.details&&!l.skippedSegments&&Object(P.adjustSliding)(a.details,l)}function k(u,a,l){if(N(u,l,a)){var h=O(l.details,a);h&&Object(V.isFiniteNumber)(h.start)&&(I.logger.log("Adjusting PTS using last level due to CC increase within current level "+a.url),f(h.start,a))}}function T(u,a){if(!a.fragments.length||!u.hasProgramDateTime||!a.hasProgramDateTime)return;var l=a.fragments[0].programDateTime,h=u.fragments[0].programDateTime,A=(h-l)/1e3+a.fragments[0].start;A&&Object(V.isFiniteNumber)(A)&&(I.logger.log("Adjusting PTS using programDateTime delta "+(h-l)+"ms, sliding:"+A.toFixed(3)+" "+u.url+" "),f(A,u))}function g(u,a){var l=u.programDateTime;if(!l)return;var h=(l-a)/1e3;u.start=u.startPTS=h,u.endPTS=h+u.duration}function b(u,a){if(!a.fragments.length||!u.hasProgramDateTime||!a.hasProgramDateTime)return;var l=a.fragments[0].programDateTime,h=a.fragments[0].start,A=l-h*1e3;u.fragments.forEach(function(m){g(m,A)}),u.fragmentHint&&g(u.fragmentHint,A),u.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/utils/ewma.ts"),I=function(){function P(N,O,R){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=R,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new V.default(N),this.fast_=new V.default(O)}var B=P.prototype;return B.update=function(O,R){var f=this.slow_,c=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new V.default(O,f.getEstimate(),f.getTotalWeight())),this.fast_.halfLife!==R&&(this.fast_=new V.default(R,c.getEstimate(),c.getTotalWeight()))},B.sample=function(O,R){O=Math.max(O,this.minDelayMs_);var f=8*R,c=O/1e3,k=f/c;this.fast_.sample(c,k),this.slow_.sample(c,k)},B.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},B.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},B.destroy=function(){},P}();Y.default=I},"./src/utils/ewma.ts":function(ie,Y,_){"use strict";_.r(Y);var V=function(){function I(B,N,O){N===void 0&&(N=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=B,this.alpha_=B?Math.exp(Math.log(.5)/B):0,this.estimate_=N,this.totalWeight_=O}var P=I.prototype;return P.sample=function(N,O){var R=Math.pow(this.alpha_,N);this.estimate_=O*(1-R)+R*this.estimate_,this.totalWeight_+=N},P.getTotalWeight=function(){return this.totalWeight_},P.getEstimate=function(){if(this.alpha_){var N=1-Math.pow(this.alpha_,this.totalWeight_);if(N)return this.estimate_/N}return this.estimate_},I}();Y.default=V},"./src/utils/fetch-loader.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"fetchSupported",function(){return g});var V=_("./src/polyfills/number.ts"),I=_("./src/loader/load-stats.ts"),P=_("./src/demux/chunk-cache.ts");function B(h,A){h.prototype=Object.create(A.prototype),h.prototype.constructor=h,c(h,A)}function N(h){var A=typeof Map=="function"?new Map:void 0;return N=function(E){if(E===null||!f(E))return E;if(typeof E!="function")throw new TypeError("Super expression must either be null or a function");if(typeof A!="undefined"){if(A.has(E))return A.get(E);A.set(E,D)}function D(){return O(E,arguments,k(this).constructor)}return D.prototype=Object.create(E.prototype,{constructor:{value:D,enumerable:!1,writable:!0,configurable:!0}}),c(D,E)},N(h)}function O(h,A,m){return R()?O=Reflect.construct:O=function(D,w,y){var p=[null];p.push.apply(p,w);var d=Function.bind.apply(D,p),o=new d;return y&&c(o,y.prototype),o},O.apply(null,arguments)}function R(){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 f(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function c(h,A){return c=Object.setPrototypeOf||function(E,D){return E.__proto__=D,E},c(h,A)}function k(h){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(m){return m.__proto__||Object.getPrototypeOf(m)},k(h)}function T(){return T=Object.assign||function(h){for(var A=1;A<arguments.length;A++){var m=arguments[A];for(var E in m)Object.prototype.hasOwnProperty.call(m,E)&&(h[E]=m[E])}return h},T.apply(this,arguments)}function g(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(h){}return!1}var b=function(){function h(m){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=m.fetchSetup||a,this.controller=new self.AbortController,this.stats=new I.LoadStats}var A=h.prototype;return A.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},A.abortInternal=function(){var E=this.response;(!E||!E.ok)&&(this.stats.aborted=!0,this.controller.abort())},A.abort=function(){var E;this.abortInternal(),(E=this.callbacks)!==null&&E!==void 0&&E.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},A.load=function(E,D,w){var y=this,p=this.stats;if(p.loading.start)throw new Error("Loader can only be used once.");p.loading.start=self.performance.now();var d=u(E,this.controller.signal),o=w.onProgress,C=E.responseType==="arraybuffer",S=C?"byteLength":"length";this.context=E,this.config=D,this.callbacks=w,this.request=this.fetchSetup(E,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){y.abortInternal(),w.onTimeout(p,E,y.response)},D.timeout),self.fetch(this.request).then(function(x){if(y.response=y.loader=x,!x.ok){var M=x.status,F=x.statusText;throw new l(F||"fetch, bad network response",M,x)}return p.loading.first=Math.max(self.performance.now(),p.loading.start),p.total=parseInt(x.headers.get("Content-Length")||"0"),o&&Object(V.isFiniteNumber)(D.highWaterMark)?y.loadProgressively(x,p,E,D.highWaterMark,o):C?x.arrayBuffer():x.text()}).then(function(x){var M=y.response;self.clearTimeout(y.requestTimeout),p.loading.end=Math.max(self.performance.now(),p.loading.first),p.loaded=p.total=x[S];var F={url:M.url,data:x};o&&!Object(V.isFiniteNumber)(D.highWaterMark)&&o(p,E,x,M),w.onSuccess(F,p,E,M)}).catch(function(x){if(self.clearTimeout(y.requestTimeout),p.aborted)return;var M=x.code||0;w.onError({code:M,text:x.message},E,x.details)})},A.getCacheAge=function(){var E=null;if(this.response){var D=this.response.headers.get("age");E=D?parseFloat(D):null}return E},A.loadProgressively=function(E,D,w,y,p){y===void 0&&(y=0);var d=new P.default,o=E.body.getReader(),C=function S(){return o.read().then(function(x){if(x.done)return d.dataLength&&p(D,w,d.flush(),E),Promise.resolve(new ArrayBuffer(0));var M=x.value,F=M.length;return D.loaded+=F,F<y||d.dataLength?(d.push(M),d.dataLength>=y&&p(D,w,d.flush(),E)):p(D,w,M,E),S()}).catch(function(){return Promise.reject()})};return C()},h}();function u(h,A){var m={method:"GET",mode:"cors",credentials:"same-origin",signal:A,headers:new self.Headers(T({},h.headers))};return h.rangeEnd&&m.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),m}function a(h,A){return new self.Request(h.url,A)}var l=function(h){B(A,h);function A(m,E,D){var w;return w=h.call(this,m)||this,w.code=void 0,w.details=void 0,w.code=E,w.details=D,w}return A}(N(Error));Y.default=b},"./src/utils/imsc1-ttml-parser.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"IMSC1_CODEC",function(){return f}),_.d(Y,"parseIMSC1",function(){return g});var V=_("./src/utils/mp4-tools.ts"),I=_("./src/utils/vttparser.ts"),P=_("./src/utils/vttcue.ts"),B=_("./src/demux/id3.ts"),N=_("./src/utils/timescale-conversion.ts"),O=_("./src/utils/webvtt-parser.ts");function R(){return R=Object.assign||function(y){for(var p=1;p<arguments.length;p++){var d=arguments[p];for(var o in d)Object.prototype.hasOwnProperty.call(d,o)&&(y[o]=d[o])}return y},R.apply(this,arguments)}var f="stpp.ttml.im1t",c=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,k=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,T={left:"start",center:"center",right:"end",start:"start",end:"end"};function g(y,p,d,o,C){var S=Object(V.findBox)(new Uint8Array(y),["mdat"]);if(S.length===0){C(new Error("Could not parse IMSC1 mdat"));return}var x=S[0],M=Object(B.utf8ArrayToStr)(new Uint8Array(y,x.start,x.end-x.start)),F=Object(N.toTimescaleFromScale)(p,1,d);try{o(b(M,F))}catch(G){C(G)}}function b(y,p){var d=new DOMParser,o=d.parseFromString(y,"text/xml"),C=o.getElementsByTagName("tt")[0];if(!C)throw new Error("Invalid ttml");var S={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},x=Object.keys(S).reduce(function(K,j){return K[j]=C.getAttribute("ttp:"+j)||S[j],K},{}),M=C.getAttribute("xml:space")!=="preserve",F=a(u(C,"styling","style")),G=a(u(C,"layout","region")),J=u(C,"body","[begin]");return[].map.call(J,function(K){var j=l(K,M);if(!j||!K.hasAttribute("begin"))return null;var q=E(K.getAttribute("begin"),x),oe=E(K.getAttribute("dur"),x),ue=E(K.getAttribute("end"),x);if(q===null)throw m(K);if(ue===null){if(oe===null)throw m(K);ue=q+oe}var ge=new P.default(q-p,ue-p,j);ge.id=Object(O.generateCueId)(ge.startTime,ge.endTime,ge.text);var _e=G[K.getAttribute("region")],be=F[K.getAttribute("style")];ge.position=10,ge.size=80;var Se=h(_e,be),Te=Se.textAlign;if(Te){var Ce=T[Te];Ce&&(ge.lineAlign=Ce),ge.align=Te}return R(ge,Se),ge}).filter(function(K){return K!==null})}function u(y,p,d){var o=y.getElementsByTagName(p)[0];return o?[].slice.call(o.querySelectorAll(d)):[]}function a(y){return y.reduce(function(p,d){var o=d.getAttribute("xml:id");return o&&(p[o]=d),p},{})}function l(y,p){return[].slice.call(y.childNodes).reduce(function(d,o,C){var S;return o.nodeName==="br"&&C?d+`
|
|
`:(S=o.childNodes)!==null&&S!==void 0&&S.length?l(o,p):p?d+o.textContent.trim().replace(/\s+/g," "):d+o.textContent},"")}function h(y,p){var d="http://www.w3.org/ns/ttml#styling",o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return o.reduce(function(C,S){var x=A(p,d,S)||A(y,d,S);return x&&(C[S]=x),C},{})}function A(y,p,d){return y.hasAttributeNS(p,d)?y.getAttributeNS(p,d):null}function m(y){return new Error("Could not parse ttml timestamp "+y)}function E(y,p){if(!y)return null;var d=Object(I.parseTimeStamp)(y);return d===null&&(c.test(y)?d=D(y,p):k.test(y)&&(d=w(y,p))),d}function D(y,p){var d=c.exec(y),o=(d[4]|0)+(d[5]|0)/p.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+o/p.frameRate}function w(y,p){var d=k.exec(y),o=Number(d[1]),C=d[2];switch(C){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/p.frameRate;case"t":return o/p.tickRate}return o}},"./src/utils/logger.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"enableLogs",function(){return O}),_.d(Y,"logger",function(){return R});var V=function(){},I={trace:V,debug:V,log:V,warn:V,info:V,error:V},P=I;function B(f){var c=self.console[f];return c?c.bind(self.console,"["+f+"] >"):V}function N(f){for(var c=arguments.length,k=new Array(c>1?c-1:0),T=1;T<c;T++)k[T-1]=arguments[T];k.forEach(function(g){P[g]=f[g]?f[g].bind(f):B(g)})}function O(f){if(self.console&&f===!0||typeof f=="object"){N(f,"debug","log","info","warn","error");try{P.log()}catch(c){P=I}}else P=I}var R=P},"./src/utils/mediakeys-helper.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"KeySystems",function(){return V}),_.d(Y,"requestMediaKeySystemAccess",function(){return I});var V;(function(P){P.WIDEVINE="com.widevine.alpha",P.PLAYREADY="com.microsoft.playready"})(V||(V={}));var I=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"getMediaSource",function(){return V});function V(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"bin2str",function(){return N}),_.d(Y,"readUint16",function(){return O}),_.d(Y,"readUint32",function(){return R}),_.d(Y,"writeUint32",function(){return f}),_.d(Y,"findBox",function(){return c}),_.d(Y,"parseSegmentIndex",function(){return k}),_.d(Y,"parseInitSegment",function(){return T}),_.d(Y,"getStartDTS",function(){return g}),_.d(Y,"getDuration",function(){return b}),_.d(Y,"computeRawDurationFromSamples",function(){return u}),_.d(Y,"offsetStartDTS",function(){return a}),_.d(Y,"segmentValidRange",function(){return l}),_.d(Y,"appendUint8Array",function(){return h});var V=_("./src/utils/typed-array.ts"),I=_("./src/loader/fragment.ts"),P=Math.pow(2,32)-1,B=[].push;function N(A){return String.fromCharCode.apply(null,A)}function O(A,m){"data"in A&&(m+=A.start,A=A.data);var E=A[m]<<8|A[m+1];return E<0?65536+E:E}function R(A,m){"data"in A&&(m+=A.start,A=A.data);var E=A[m]<<24|A[m+1]<<16|A[m+2]<<8|A[m+3];return E<0?4294967296+E:E}function f(A,m,E){"data"in A&&(m+=A.start,A=A.data),A[m]=E>>24,A[m+1]=E>>16&255,A[m+2]=E>>8&255,A[m+3]=E&255}function c(A,m){var E=[];if(!m.length)return E;var D,w,y;"data"in A?(D=A.data,w=A.start,y=A.end):(D=A,w=0,y=D.byteLength);for(var p=w;p<y;){var d=R(D,p),o=N(D.subarray(p+4,p+8)),C=d>1?p+d:y;if(o===m[0])if(m.length===1)E.push({data:D,start:p+8,end:C});else{var S=c({data:D,start:p+8,end:C},m.slice(1));S.length&&B.apply(E,S)}p=C}return E}function k(A){var m=c(A,["moov"]),E=m[0],D=E?E.end:null,w=c(A,["sidx"]);if(!w||!w[0])return null;var y=[],p=w[0],d=p.data[0],o=d===0?8:16,C=R(p,o);o+=4;var S=0,x=0;d===0?o+=8:o+=16,o+=2;var M=p.end+x,F=O(p,o);o+=2;for(var G=0;G<F;G++){var J=o,K=R(p,J);J+=4;var j=K&2147483647,q=(K&2147483648)>>>31;if(q===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var oe=R(p,J);J+=4,y.push({referenceSize:j,subsegmentDuration:oe,info:{duration:oe/C,start:M,end:M+j-1}}),M+=j,J+=4,o=J}return{earliestPresentationTime:S,timescale:C,version:d,referencesCount:F,references:y,moovEndOffset:D}}function T(A){for(var m=[],E=c(A,["moov","trak"]),D=0;D<E.length;D++){var w=E[D],y=c(w,["tkhd"])[0];if(y){var p=y.data[y.start],d=p===0?12:20,o=R(y,d),C=c(w,["mdia","mdhd"])[0];if(C){p=C.data[C.start],d=p===0?12:20;var S=R(C,d),x=c(w,["mdia","hdlr"])[0];if(x){var M=N(x.data.subarray(x.start+8,x.start+12)),F={soun:I.ElementaryStreamTypes.AUDIO,vide:I.ElementaryStreamTypes.VIDEO}[M];if(F){var G=c(w,["mdia","minf","stbl","stsd"])[0],J=void 0;G&&(J=N(G.data.subarray(G.start+12,G.start+16))),m[o]={timescale:S,type:F},m[F]={timescale:S,id:o,codec:J}}}}}}var K=c(A,["moov","mvex","trex"]);return K.forEach(function(j){var q=R(j,4),oe=m[q];oe&&(oe.default={duration:R(j,12),flags:R(j,20)})}),m}function g(A,m){return c(m,["moof","traf"]).reduce(function(E,D){var w=c(D,["tfdt"])[0],y=w.data[w.start],p=c(D,["tfhd"]).reduce(function(d,o){var C=R(o,4),S=A[C];if(S){var x=R(w,4);y===1&&(x*=Math.pow(2,32),x+=R(w,8));var M=S.timescale||9e4,F=x/M;if(isFinite(F)&&(d===null||F<d))return F}return d},null);return p!==null&&isFinite(p)&&(E===null||p<E)?p:E},null)||0}function b(A,m){for(var E=0,D=0,w=0,y=c(A,["moof","traf"]),p=0;p<y.length;p++){var d=y[p],o=c(d,["tfhd"])[0],C=R(o,4),S=m[C];if(!S)continue;var x=S.default,M=R(o,0)|(x==null?void 0:x.flags),F=x==null?void 0:x.duration;M&8&&(M&2?F=R(o,12):F=R(o,8));for(var G=S.timescale||9e4,J=c(d,["trun"]),K=0;K<J.length;K++){if(F){var j=R(J[K],4);E=F*j}else E=u(J[K]);S.type===I.ElementaryStreamTypes.VIDEO?D+=E/G:S.type===I.ElementaryStreamTypes.AUDIO&&(w+=E/G)}}if(D===0&&w===0){var q=k(A);if(q!=null&&q.references)return q.references.reduce(function(oe,ue){return oe+ue.info.duration||0},0)}return D||w}function u(A){var m=R(A,0),E=8;m&1&&(E+=4),m&4&&(E+=4);for(var D=0,w=R(A,4),y=0;y<w;y++){if(m&256){var p=R(A,E);D+=p,E+=4}m&512&&(E+=4),m&1024&&(E+=4),m&2048&&(E+=4)}return D}function a(A,m,E){c(m,["moof","traf"]).forEach(function(D){c(D,["tfhd"]).forEach(function(w){var y=R(w,4),p=A[y];if(!p)return;var d=p.timescale||9e4;c(D,["tfdt"]).forEach(function(o){var C=o.data[o.start],S=R(o,4);if(C===0)f(o,4,S-E*d);else{S*=Math.pow(2,32),S+=R(o,8),S-=E*d,S=Math.max(S,0);var x=Math.floor(S/(P+1)),M=Math.floor(S%(P+1));f(o,4,x),f(o,8,M)}})})})}function l(A){var m={valid:null,remainder:null},E=c(A,["moof"]);if(E){if(E.length<2)return m.remainder=A,m}else return m;var D=E[E.length-1];return m.valid=Object(V.sliceUint8)(A,0,D.start-8),m.remainder=Object(V.sliceUint8)(A,D.start-8),m}function h(A,m){var E=new Uint8Array(A.length+m.length);return E.set(A),E.set(m,A.length),E}},"./src/utils/output-filter.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"default",function(){return V});var V=function(){function I(B,N){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=B,this.trackName=N}var P=I.prototype;return P.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},P.newCue=function(N,O,R){(this.startTime===null||this.startTime>N)&&(this.startTime=N),this.endTime=O,this.screen=R,this.timelineController.createCaptionsTrack(this.trackName)},P.reset=function(){this.cueRanges=[]},I}()},"./src/utils/texttrack-utils.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"sendAddTrackEvent",function(){return I}),_.d(Y,"addCueToTrack",function(){return P}),_.d(Y,"clearCurrentCues",function(){return B}),_.d(Y,"removeCuesInRange",function(){return N}),_.d(Y,"getCuesInRange",function(){return R});var V=_("./src/utils/logger.ts");function I(f,c){var k;try{k=new Event("addtrack")}catch(T){k=document.createEvent("Event"),k.initEvent("addtrack",!1,!1)}k.track=f,c.dispatchEvent(k)}function P(f,c){var k=f.mode;if(k==="disabled"&&(f.mode="hidden"),f.cues&&!f.cues.getCueById(c.id))try{if(f.addCue(c),!f.cues.getCueById(c.id))throw new Error("addCue is failed for: "+c)}catch(g){V.logger.debug("[texttrack-utils]: "+g);var T=new self.TextTrackCue(c.startTime,c.endTime,c.text);T.id=c.id,f.addCue(T)}k==="disabled"&&(f.mode=k)}function B(f){var c=f.mode;if(c==="disabled"&&(f.mode="hidden"),f.cues)for(var k=f.cues.length;k--;)f.removeCue(f.cues[k]);c==="disabled"&&(f.mode=c)}function N(f,c,k){var T=f.mode;if(T==="disabled"&&(f.mode="hidden"),f.cues&&f.cues.length>0)for(var g=R(f.cues,c,k),b=0;b<g.length;b++)f.removeCue(g[b]);T==="disabled"&&(f.mode=T)}function O(f,c){if(c<f[0].startTime)return 0;var k=f.length-1;if(c>f[k].endTime)return-1;for(var T=0,g=k;T<=g;){var b=Math.floor((g+T)/2);if(c<f[b].startTime)g=b-1;else if(c>f[b].startTime&&T<k)T=b+1;else return b}return f[T].startTime-c<c-f[g].startTime?T:g}function R(f,c,k){var T=[],g=O(f,c);if(g>-1)for(var b=g,u=f.length;b<u;b++){var a=f[b];if(a.startTime>=c&&a.endTime<=k)T.push(a);else if(a.startTime>k)return T}return T}},"./src/utils/time-ranges.ts":function(ie,Y,_){"use strict";_.r(Y);var V={toString:function(P){for(var B="",N=P.length,O=0;O<N;O++)B+="["+P.start(O).toFixed(3)+","+P.end(O).toFixed(3)+"]";return B}};Y.default=V},"./src/utils/timescale-conversion.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"toTimescaleFromBase",function(){return I}),_.d(Y,"toTimescaleFromScale",function(){return P}),_.d(Y,"toMsFromMpegTsClock",function(){return B}),_.d(Y,"toMpegTsClockFromTimescale",function(){return N});var V=9e4;function I(O,R,f,c){f===void 0&&(f=1),c===void 0&&(c=!1);var k=O*R*f;return c?Math.round(k):k}function P(O,R,f,c){return f===void 0&&(f=1),c===void 0&&(c=!1),I(O,R,1/f,c)}function B(O,R){return R===void 0&&(R=!1),I(O,1e3,1/V,R)}function N(O,R){return R===void 0&&(R=1),I(O,V,1/R)}},"./src/utils/typed-array.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"sliceUint8",function(){return V});function V(I,P,B){return Uint8Array.prototype.slice?I.slice(P,B):new Uint8Array(Array.prototype.slice.call(I,P,B))}},"./src/utils/vttcue.ts":function(ie,Y,_){"use strict";_.r(Y),Y.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var V=["","lr","rl"],I=["start","middle","end","left","right"];function P(f,c){if(typeof c!="string")return!1;if(!Array.isArray(f))return!1;var k=c.toLowerCase();return~f.indexOf(k)?k:!1}function B(f){return P(V,f)}function N(f){return P(I,f)}function O(f){for(var c=arguments.length,k=new Array(c>1?c-1:0),T=1;T<c;T++)k[T-1]=arguments[T];for(var g=1;g<arguments.length;g++){var b=arguments[g];for(var u in b)f[u]=b[u]}return f}function R(f,c,k){var T=this,g={enumerable:!0};T.hasBeenReset=!1;var b="",u=!1,a=f,l=c,h=k,A=null,m="",E=!0,D="auto",w="start",y=50,p="middle",d=50,o="middle";Object.defineProperty(T,"id",O({},g,{get:function(){return b},set:function(S){b=""+S}})),Object.defineProperty(T,"pauseOnExit",O({},g,{get:function(){return u},set:function(S){u=!!S}})),Object.defineProperty(T,"startTime",O({},g,{get:function(){return a},set:function(S){if(typeof S!="number")throw new TypeError("Start time must be set to a number.");a=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"endTime",O({},g,{get:function(){return l},set:function(S){if(typeof S!="number")throw new TypeError("End time must be set to a number.");l=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"text",O({},g,{get:function(){return h},set:function(S){h=""+S,this.hasBeenReset=!0}})),Object.defineProperty(T,"region",O({},g,{get:function(){return A},set:function(S){A=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"vertical",O({},g,{get:function(){return m},set:function(S){var x=B(S);if(x===!1)throw new SyntaxError("An invalid or illegal string was specified.");m=x,this.hasBeenReset=!0}})),Object.defineProperty(T,"snapToLines",O({},g,{get:function(){return E},set:function(S){E=!!S,this.hasBeenReset=!0}})),Object.defineProperty(T,"line",O({},g,{get:function(){return D},set:function(S){if(typeof S!="number"&&S!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");D=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"lineAlign",O({},g,{get:function(){return w},set:function(S){var x=N(S);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");w=x,this.hasBeenReset=!0}})),Object.defineProperty(T,"position",O({},g,{get:function(){return y},set:function(S){if(S<0||S>100)throw new Error("Position must be between 0 and 100.");y=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"positionAlign",O({},g,{get:function(){return p},set:function(S){var x=N(S);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");p=x,this.hasBeenReset=!0}})),Object.defineProperty(T,"size",O({},g,{get:function(){return d},set:function(S){if(S<0||S>100)throw new Error("Size must be between 0 and 100.");d=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"align",O({},g,{get:function(){return o},set:function(S){var x=N(S);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");o=x,this.hasBeenReset=!0}})),T.displayState=void 0}return R.prototype.getCueAsHTML=function(){var f=self.WebVTT;return f.convertCueToDOMTree(self,this.text)},R}()},"./src/utils/vttparser.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"parseTimeStamp",function(){return P}),_.d(Y,"fixLineBreaks",function(){return c}),_.d(Y,"VTTParser",function(){return k});var V=_("./src/utils/vttcue.ts"),I=function(){function T(){}var g=T.prototype;return g.decode=function(u,a){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},T}();function P(T){function g(u,a,l,h){return(u|0)*3600+(a|0)*60+(l|0)+parseFloat(h||0)}var b=T.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return b?parseFloat(b[2])>59?g(b[2],b[3],0,b[4]):g(b[1],b[2],b[3],b[4]):null}var B=function(){function T(){this.values=Object.create(null)}var g=T.prototype;return g.set=function(u,a){!this.get(u)&&a!==""&&(this.values[u]=a)},g.get=function(u,a,l){return l?this.has(u)?this.values[u]:a[l]:this.has(u)?this.values[u]:a},g.has=function(u){return u in this.values},g.alt=function(u,a,l){for(var h=0;h<l.length;++h)if(a===l[h]){this.set(u,a);break}},g.integer=function(u,a){/^-?\d+$/.test(a)&&this.set(u,parseInt(a,10))},g.percent=function(u,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var l=parseFloat(a);if(l>=0&&l<=100)return this.set(u,l),!0}return!1},T}();function N(T,g,b,u){var a=u?T.split(u):[T];for(var l in a){if(typeof a[l]!="string")continue;var h=a[l].split(b);if(h.length!==2)continue;var A=h[0],m=h[1];g(A,m)}}var O=new V.default(0,0,""),R=O.align==="middle"?"middle":"center";function f(T,g,b){var u=T;function a(){var A=P(T);if(A===null)throw new Error("Malformed timestamp: "+u);return T=T.replace(/^[^\sa-zA-Z-]+/,""),A}function l(A,m){var E=new B;N(A,function(y,p){var d;switch(y){case"region":for(var o=b.length-1;o>=0;o--)if(b[o].id===p){E.set(y,b[o].region);break}break;case"vertical":E.alt(y,p,["rl","lr"]);break;case"line":d=p.split(","),E.integer(y,d[0]),E.percent(y,d[0])&&E.set("snapToLines",!1),E.alt(y,d[0],["auto"]),d.length===2&&E.alt("lineAlign",d[1],["start",R,"end"]);break;case"position":d=p.split(","),E.percent(y,d[0]),d.length===2&&E.alt("positionAlign",d[1],["start",R,"end","line-left","line-right","auto"]);break;case"size":E.percent(y,p);break;case"align":E.alt(y,p,["start",R,"end","left","right"]);break}},/:/,/\s/),m.region=E.get("region",null),m.vertical=E.get("vertical","");var D=E.get("line","auto");D==="auto"&&O.line===-1&&(D=-1),m.line=D,m.lineAlign=E.get("lineAlign","start"),m.snapToLines=E.get("snapToLines",!0),m.size=E.get("size",100),m.align=E.get("align",R);var w=E.get("position","auto");w==="auto"&&O.position===50&&(w=m.align==="start"||m.align==="left"?0:m.align==="end"||m.align==="right"?100:50),m.position=w}function h(){T=T.replace(/^\s+/,"")}if(h(),g.startTime=a(),h(),T.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);T=T.substr(3),h(),g.endTime=a(),h(),l(T,g)}function c(T){return T.replace(/<br(?: \/)?>/gi,`
|
|
`)}var k=function(){function T(){this.state="INITIAL",this.buffer="",this.decoder=new I,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var g=T.prototype;return g.parse=function(u){var a=this;u&&(a.buffer+=a.decoder.decode(u,{stream:!0}));function l(){var w=a.buffer,y=0;for(w=c(w);y<w.length&&w[y]!=="\r"&&w[y]!==`
|
|
`;)++y;var p=w.substr(0,y);return w[y]==="\r"&&++y,w[y]===`
|
|
`&&++y,a.buffer=w.substr(y),p}function h(w){N(w,function(y,p){},/:/)}try{var A="";if(a.state==="INITIAL"){if(!/\r\n|\n/.test(a.buffer))return this;A=l();var m=A.match(/^()?WEBVTT([ \t].*)?$/);if(!m||!m[0])throw new Error("Malformed WebVTT signature.");a.state="HEADER"}for(var E=!1;a.buffer;){if(!/\r\n|\n/.test(a.buffer))return this;E?E=!1:A=l();switch(a.state){case"HEADER":/:/.test(A)?h(A):A||(a.state="ID");continue;case"NOTE":A||(a.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(A)){a.state="NOTE";break}if(!A)continue;if(a.cue=new V.default(0,0,""),a.state="CUE",A.indexOf("-->")===-1){a.cue.id=A;continue}case"CUE":if(!a.cue){a.state="BADCUE";continue}try{f(A,a.cue,a.regionList)}catch(w){a.cue=null,a.state="BADCUE";continue}a.state="CUETEXT";continue;case"CUETEXT":{var D=A.indexOf("-->")!==-1;if(!A||D&&(E=!0)){a.oncue&&a.cue&&a.oncue(a.cue),a.cue=null,a.state="ID";continue}if(a.cue===null)continue;a.cue.text&&(a.cue.text+=`
|
|
`),a.cue.text+=A}continue;case"BADCUE":A||(a.state="ID")}}}catch(w){a.state==="CUETEXT"&&a.cue&&a.oncue&&a.oncue(a.cue),a.cue=null,a.state=a.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},g.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(a){u.onparsingerror&&u.onparsingerror(a)}return u.onflush&&u.onflush(),this},T}()},"./src/utils/webvtt-parser.ts":function(ie,Y,_){"use strict";_.r(Y),_.d(Y,"generateCueId",function(){return k}),_.d(Y,"parseWebVTT",function(){return g});var V=_("./src/polyfills/number.ts"),I=_("./src/utils/vttparser.ts"),P=_("./src/demux/id3.ts"),B=_("./src/utils/timescale-conversion.ts"),N=_("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,R=function(u,a,l){return l===void 0&&(l=0),u.substr(l,a.length)===a},f=function(u){var a=parseInt(u.substr(-3)),l=parseInt(u.substr(-6,2)),h=parseInt(u.substr(-9,2)),A=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object(V.isFiniteNumber)(a)||!Object(V.isFiniteNumber)(l)||!Object(V.isFiniteNumber)(h)||!Object(V.isFiniteNumber)(A))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return a+=1e3*l,a+=60*1e3*h,a+=60*60*1e3*A,a},c=function(u){for(var a=5381,l=u.length;l;)a=a*33^u.charCodeAt(--l);return(a>>>0).toString()};function k(b,u,a){return c(b.toString())+c(u.toString())+c(a)}var T=function(u,a,l){var h=u[a],A=u[h.prevCC];if(!A||!A.new&&h.new){u.ccOffset=u.presentationOffset=h.start,h.new=!1;return}for(;(m=A)!==null&&m!==void 0&&m.new;){var m;u.ccOffset+=h.start-A.start,h.new=!1,h=A,A=u[h.prevCC]}u.presentationOffset=l};function g(b,u,a,l,h,A,m,E){var D=new I.VTTParser,w=Object(P.utf8ArrayToStr)(new Uint8Array(b)).trim().replace(O,`
|
|
`).split(`
|
|
`),y=[],p=Object(B.toMpegTsClockFromTimescale)(u,a),d="00:00.000",o=0,C=0,S,x=!0,M=!1;D.oncue=function(F){var G=l[h],J=l.ccOffset,K=(o-p)/9e4;if(G!=null&&G.new&&(C!==void 0?J=l.ccOffset=G.start:T(l,h,K)),K&&(J=K-l.presentationOffset),M){var j=F.endTime-F.startTime,q=Object(N.normalizePts)((F.startTime+J-C)*9e4,A*9e4)/9e4;F.startTime=q,F.endTime=q+j}var oe=F.text.trim();F.text=decodeURIComponent(encodeURIComponent(oe)),F.id||(F.id=k(F.startTime,F.endTime,oe)),F.endTime>0&&y.push(F)},D.onparsingerror=function(F){S=F},D.onflush=function(){if(S){E(S);return}m(y)},w.forEach(function(F){if(x)if(R(F,"X-TIMESTAMP-MAP=")){x=!1,M=!0,F.substr(16).split(",").forEach(function(G){R(G,"LOCAL:")?d=G.substr(6):R(G,"MPEGTS:")&&(o=parseInt(G.substr(7)))});try{C=f(d)/1e3}catch(G){M=!1,S=G}return}else F===""&&(x=!1);D.parse(F+`
|
|
`)}),D.flush()}},"./src/utils/xhr-loader.ts":function(ie,Y,_){"use strict";_.r(Y);var V=_("./src/utils/logger.ts"),I=_("./src/loader/load-stats.ts"),P=/^age:\s*[\d.]+\s*$/m,B=function(){function N(R){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=R?R.xhrSetup:null,this.stats=new I.LoadStats,this.retryDelay=0}var O=N.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var f=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),f&&(f.onreadystatechange=null,f.onprogress=null,f.readyState!==4&&(this.stats.aborted=!0,f.abort()))},O.abort=function(){var f;this.abortInternal(),(f=this.callbacks)!==null&&f!==void 0&&f.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(f,c,k){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=f,this.config=c,this.callbacks=k,this.retryDelay=c.retryDelay,this.loadInternal()},O.loadInternal=function(){var f=this.config,c=this.context;if(!f)return;var k=this.loader=new self.XMLHttpRequest,T=this.stats;T.loading.first=0,T.loaded=0;var g=this.xhrSetup;try{if(g)try{g(k,c.url)}catch(a){k.open("GET",c.url,!0),g(k,c.url)}k.readyState||k.open("GET",c.url,!0);var b=this.context.headers;if(b)for(var u in b)k.setRequestHeader(u,b[u])}catch(a){this.callbacks.onError({code:k.status,text:a.message},c,k);return}c.rangeEnd&&k.setRequestHeader("Range","bytes="+c.rangeStart+"-"+(c.rangeEnd-1)),k.onreadystatechange=this.readystatechange.bind(this),k.onprogress=this.loadprogress.bind(this),k.responseType=c.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),f.timeout),k.send()},O.readystatechange=function(){var f=this.context,c=this.loader,k=this.stats;if(!f||!c)return;var T=c.readyState,g=this.config;if(k.aborted)return;if(T>=2)if(self.clearTimeout(this.requestTimeout),k.loading.first===0&&(k.loading.first=Math.max(self.performance.now(),k.loading.start)),T===4){c.onreadystatechange=null,c.onprogress=null;var b=c.status;if(b>=200&&b<300){k.loading.end=Math.max(self.performance.now(),k.loading.first);var u,a;if(f.responseType==="arraybuffer"?(u=c.response,a=u.byteLength):(u=c.responseText,a=u.length),k.loaded=k.total=a,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(k,f,u,c),!this.callbacks)return;var h={url:c.responseURL,data:u};this.callbacks.onSuccess(h,k,f,c)}else k.retry>=g.maxRetry||b>=400&&b<499?(V.logger.error(b+" while loading "+f.url),this.callbacks.onError({code:b,text:c.statusText},f,c)):(V.logger.warn(b+" while loading "+f.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,g.maxRetryDelay),k.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout)},O.loadtimeout=function(){V.logger.warn("timeout while loading "+this.context.url);var f=this.callbacks;f&&(this.abortInternal(),f.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(f){var c=this.stats;c.loaded=f.loaded,f.lengthComputable&&(c.total=f.total)},O.getCacheAge=function(){var f=null;if(this.loader&&P.test(this.loader.getAllResponseHeaders())){var c=this.loader.getResponseHeader("age");f=c?parseFloat(c):null}return f},N}();Y.default=B}}).default})},vHTk:function(dt,qe,te){dt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}},wU8J:function(dt,qe){function te(){this.buffer=new Array,this.length=0}te.prototype={get:function(ie){var Y=Math.floor(ie/8);return(this.buffer[Y]>>>7-ie%8&1)==1},put:function(ie,Y){for(var _=0;_<Y;_++)this.putBit((ie>>>Y-_-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(ie){var Y=Math.floor(this.length/8);this.buffer.length<=Y&&this.buffer.push(0),ie&&(this.buffer[Y]|=128>>>this.length%8),this.length++}},dt.exports=te}}]);
|