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.
361 lines
913 KiB
361 lines
913 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[174,7,8],{"+NIl":function(gt,at,ue){(function(fe){fe(ue("VrN/"))})(function(fe){"use strict";fe.defineMode("stex",function(Q,D){"use strict";function V(A,S){A.cmdState.push(S)}function I(A){return A.cmdState.length>0?A.cmdState[A.cmdState.length-1]:null}function y(A){var S=A.cmdState.pop();S&&S.closeBracket()}function j(A){for(var S=A.cmdState,C=S.length-1;C>=0;C--){var d=S[C];if(d.name=="DEFAULT")continue;return d}return{styleIdentifier:function(){return null}}}function B(A,S,C){return function(){this.name=A,this.bracketNo=0,this.style=S,this.styles=C,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var M={};M.importmodule=B("importmodule","tag",["string","builtin"]),M.documentclass=B("documentclass","tag",["","atom"]),M.usepackage=B("usepackage","tag",["atom"]),M.begin=B("begin","tag",["atom"]),M.end=B("end","tag",["atom"]),M.label=B("label","tag",["atom"]),M.ref=B("ref","tag",["atom"]),M.eqref=B("eqref","tag",["atom"]),M.cite=B("cite","tag",["atom"]),M.bibitem=B("bibitem","tag",["atom"]),M.Bibitem=B("Bibitem","tag",["atom"]),M.RBibitem=B("RBibitem","tag",["atom"]),M.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function R(A,S){A.f=S}function b(A,S){var C;if(A.match(/^\\[a-zA-Z@]+/)){var d=A.current().slice(1);return C=M.hasOwnProperty(d)?M[d]:M.DEFAULT,C=new C,V(S,C),R(S,O),C.style}if(A.match(/^\\[$&%#{}_]/))return"tag";if(A.match(/^\\[,;!\/\\]/))return"tag";if(A.match("\\["))return R(S,function(s,u){return w(s,u,"\\]")}),"keyword";if(A.match("\\("))return R(S,function(s,u){return w(s,u,"\\)")}),"keyword";if(A.match("$$"))return R(S,function(s,u){return w(s,u,"$$")}),"keyword";if(A.match("$"))return R(S,function(s,u){return w(s,u,"$")}),"keyword";var o=A.next();if(o=="%")return A.skipToEnd(),"comment";if(o=="}"||o=="]"){if(C=I(S),C)C.closeBracket(o),R(S,O);else return"error";return"bracket"}else return o=="{"||o=="["?(C=M.DEFAULT,C=new C,V(S,C),"bracket"):/\d/.test(o)?(A.eatWhile(/[\w.%]/),"atom"):(A.eatWhile(/[\w\-_]/),C=j(S),C.name=="begin"&&(C.argument=A.current()),C.styleIdentifier())}function w(A,S,C){if(A.eatSpace())return null;if(C&&A.match(C))return R(S,b),"keyword";if(A.match(/^\\[a-zA-Z@]+/))return"tag";if(A.match(/^[a-zA-Z]+/))return"variable-2";if(A.match(/^\\[$&%#{}_]/))return"tag";if(A.match(/^\\[,;!\/]/))return"tag";if(A.match(/^[\^_&]/))return"tag";if(A.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(A.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var d=A.next();return d=="{"||d=="}"||d=="["||d=="]"||d=="("||d==")"?"bracket":d=="%"?(A.skipToEnd(),"comment"):"error"}function O(A,S){var C=A.peek(),d;return C=="{"||C=="["?(d=I(S),d.openBracket(C),A.eat(C),R(S,b),"bracket"):/[ \t\r]/.test(C)?(A.eat(C),null):(R(S,b),y(S),b(A,S))}return{startState:function(){var A=D.inMathMode?function(S,C){return w(S,C)}:b;return{cmdState:[],f:A}},copyState:function(A){return{cmdState:A.cmdState.slice(),f:A.f}},token:function(A,S){return S.f(A,S)},blankLine:function(A){A.f=b,A.cmdState.length=0},lineComment:"%"}}),fe.defineMIME("text/x-stex","stex"),fe.defineMIME("text/x-latex","stex")})},"19Vz":function(gt,at,ue){(function(fe){fe(ue("VrN/"))})(function(fe){fe.defineOption("placeholder","",function(B,M,R){var b=R&&R!=fe.Init;if(M&&!b)B.on("blur",I),B.on("change",y),B.on("swapDoc",y),fe.on(B.getInputField(),"compositionupdate",B.state.placeholderCompose=function(){V(B)}),y(B);else if(!M&&b){B.off("blur",I),B.off("change",y),B.off("swapDoc",y),fe.off(B.getInputField(),"compositionupdate",B.state.placeholderCompose),Q(B);var w=B.getWrapperElement();w.className=w.className.replace(" CodeMirror-empty","")}M&&!B.hasFocus()&&I(B)});function Q(B){B.state.placeholder&&(B.state.placeholder.parentNode.removeChild(B.state.placeholder),B.state.placeholder=null)}function D(B){Q(B);var M=B.state.placeholder=document.createElement("pre");M.style.cssText="height: 0; overflow: visible",M.style.direction=B.getOption("direction"),M.className="CodeMirror-placeholder CodeMirror-line-like";var R=B.getOption("placeholder");typeof R=="string"&&(R=document.createTextNode(R)),M.appendChild(R),B.display.lineSpace.insertBefore(M,B.display.lineSpace.firstChild)}function V(B){setTimeout(function(){var M=!1,R=B.getInputField();R.nodeName=="TEXTAREA"?M=!R.value:B.lineCount()==1&&(M=!/[^\u200b]/.test(R.querySelector(".CodeMirror-line").textContent)),M?D(B):Q(B)},20)}function I(B){j(B)&&D(B)}function y(B){var M=B.getWrapperElement(),R=j(B);M.className=M.className.replace(" CodeMirror-empty","")+(R?" CodeMirror-empty":""),R?D(B):Q(B)}function j(B){return B.lineCount()===1&&B.getLine(0)===""}})},"1eCo":function(gt,at,ue){(function(fe){fe(ue("VrN/"))})(function(fe){"use strict";var Q={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},D={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};fe.defineMode("xml",function(V,I){var y=V.indentUnit,j={},B=I.htmlMode?Q:D;for(var M in B)j[M]=B[M];for(var M in I)j[M]=I[M];var R,b;function w(a,g){function f(G){return g.tokenize=G,G(a,g)}var x=a.next();if(x=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?f(S("atom","]]>")):null:a.match("--")?f(S("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),f(C(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),g.tokenize=S("meta","?>"),"meta"):(R=a.eat("/")?"closeTag":"openTag",g.tokenize=O,"tag bracket");if(x=="&"){var P;return a.eat("#")?a.eat("x")?P=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):P=a.eatWhile(/[\d]/)&&a.eat(";"):P=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),P?"atom":"error"}else return a.eatWhile(/[^&<]/),null}w.isInText=!0;function O(a,g){var f=a.next();if(f==">"||f=="/"&&a.eat(">"))return g.tokenize=w,R=f==">"?"endTag":"selfcloseTag","tag bracket";if(f=="=")return R="equals",null;if(f=="<"){g.tokenize=w,g.state=u,g.tagName=g.tagStart=null;var x=g.tokenize(a,g);return x?x+" tag error":"tag error"}else return/[\'\"]/.test(f)?(g.tokenize=A(f),g.stringStartCol=a.column(),g.tokenize(a,g)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function A(a){var g=function(f,x){for(;!f.eol();)if(f.next()==a){x.tokenize=O;break}return"string"};return g.isInAttribute=!0,g}function S(a,g){return function(f,x){for(;!f.eol();){if(f.match(g)){x.tokenize=w;break}f.next()}return a}}function C(a){return function(g,f){for(var x;(x=g.next())!=null;){if(x=="<")return f.tokenize=C(a+1),f.tokenize(g,f);if(x==">")if(a==1){f.tokenize=w;break}else return f.tokenize=C(a-1),f.tokenize(g,f)}return"meta"}}function d(a,g,f){this.prev=a.context,this.tagName=g,this.indent=a.indented,this.startOfLine=f,(j.doNotIndent.hasOwnProperty(g)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function s(a,g){for(var f;;){if(!a.context)return;if(f=a.context.tagName,!j.contextGrabbers.hasOwnProperty(f)||!j.contextGrabbers[f].hasOwnProperty(g))return;o(a)}}function u(a,g,f){return a=="openTag"?(f.tagStart=g.column(),T):a=="closeTag"?m:u}function T(a,g,f){return a=="word"?(f.tagName=g.current(),b="tag",v):j.allowMissingTagName&&a=="endTag"?(b="tag bracket",v(a,g,f)):(b="error",T)}function m(a,g,f){if(a=="word"){var x=g.current();return f.context&&f.context.tagName!=x&&j.implicitlyClosed.hasOwnProperty(f.context.tagName)&&o(f),f.context&&f.context.tagName==x||j.matchClosing===!1?(b="tag",p):(b="tag error",_)}else return j.allowMissingTagName&&a=="endTag"?(b="tag bracket",p(a,g,f)):(b="error",_)}function p(a,g,f){return a!="endTag"?(b="error",p):(o(f),u)}function _(a,g,f){return b="error",p(a,g,f)}function v(a,g,f){if(a=="word")return b="attribute",c;if(a=="endTag"||a=="selfcloseTag"){var x=f.tagName,P=f.tagStart;return f.tagName=f.tagStart=null,a=="selfcloseTag"||j.autoSelfClosers.hasOwnProperty(x)?s(f,x):(s(f,x),f.context=new d(f,x,P==f.indented)),u}return b="error",v}function c(a,g,f){return a=="equals"?h:(j.allowMissing||(b="error"),v(a,g,f))}function h(a,g,f){return a=="string"?l:a=="word"&&j.allowUnquoted?(b="string",v):(b="error",v(a,g,f))}function l(a,g,f){return a=="string"?l:v(a,g,f)}return{startState:function(a){var g={tokenize:w,state:u,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(g.baseIndent=a),g},token:function(a,g){if(!g.tagName&&a.sol()&&(g.indented=a.indentation()),a.eatSpace())return null;R=null;var f=g.tokenize(a,g);return(f||R)&&f!="comment"&&(b=null,g.state=g.state(R||f,a,g),b&&(f=b=="error"?f+" error":b)),f},indent:function(a,g,f){var x=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+y;if(x&&x.noIndent)return fe.Pass;if(a.tokenize!=O&&a.tokenize!=w)return f?f.match(/^(\s*)/)[0].length:0;if(a.tagName)return j.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+y*(j.multilineTagIndentFactor||1);if(j.alignCDATA&&/<!\[CDATA\[/.test(g))return 0;var P=g&&/^<(\/)?([\w_:\.-]*)/.exec(g);if(P&&P[1])for(;x;)if(x.tagName==P[2]){x=x.prev;break}else if(j.implicitlyClosed.hasOwnProperty(x.tagName))x=x.prev;else break;else if(P)for(;x;){var G=j.contextGrabbers[x.tagName];if(G&&G.hasOwnProperty(P[2]))x=x.prev;else break}for(;x&&x.prev&&!x.startOfLine;)x=x.prev;return x?x.indent+y:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:j.htmlMode?"html":"xml",helperType:j.htmlMode?"html":"xml",skipAttribute:function(a){a.state==h&&(a.state=v)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var g=[],f=a.context;f;f=f.prev)f.tagName&&g.push(f.tagName);return g.reverse()}}}),fe.defineMIME("text/xml","xml"),fe.defineMIME("application/xml","xml"),fe.mimeModes.hasOwnProperty("text/html")||fe.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"55Ip":function(gt,at,ue){"use strict";ue.d(at,"a",function(){return s});var fe=ue("Ty5D"),Q=ue("dI71"),D=ue("q1tI"),V=ue.n(D),I=ue("YS25"),y=ue("17x9"),j=ue.n(y),B=ue("wx14"),M=ue("zLVn"),R=ue("9R94"),b=function(h){Object(Q.a)(l,h);function l(){for(var g,f=arguments.length,x=new Array(f),P=0;P<f;P++)x[P]=arguments[P];return g=h.call.apply(h,[this].concat(x))||this,g.history=Object(I.a)(g.props),g}var a=l.prototype;return a.render=function(){return V.a.createElement(fe.c,{history:this.history,children:this.props.children})},l}(V.a.Component),w=function(h){Object(Q.a)(l,h);function l(){for(var g,f=arguments.length,x=new Array(f),P=0;P<f;P++)x[P]=arguments[P];return g=h.call.apply(h,[this].concat(x))||this,g.history=Object(I.b)(g.props),g}var a=l.prototype;return a.render=function(){return V.a.createElement(fe.c,{history:this.history,children:this.props.children})},l}(V.a.Component),O=function(l,a){return typeof l=="function"?l(a):l},A=function(l,a){return typeof l=="string"?Object(I.c)(l,null,null,a):l},S=function(l){return l},C=V.a.forwardRef;typeof C=="undefined"&&(C=S);function d(h){return!!(h.metaKey||h.altKey||h.ctrlKey||h.shiftKey)}var o=C(function(h,l){var a=h.innerRef,g=h.navigate,f=h.onClick,x=Object(M.a)(h,["innerRef","navigate","onClick"]),P=x.target,G=Object(B.a)({},x,{onClick:function(ie){try{f&&f(ie)}catch(z){throw ie.preventDefault(),z}!ie.defaultPrevented&&ie.button===0&&(!P||P==="_self")&&!d(ie)&&(ie.preventDefault(),g())}});return S!==C?G.ref=l||a:G.ref=a,V.a.createElement("a",G)}),s=C(function(h,l){var a=h.component,g=a===void 0?o:a,f=h.replace,x=h.to,P=h.innerRef,G=Object(M.a)(h,["component","replace","to","innerRef"]);return V.a.createElement(fe.e.Consumer,null,function(X){X||Object(R.a)(!1);var ie=X.history,z=A(O(x,X.location),X.location),F=z?ie.createHref(z):"",ne=Object(B.a)({},G,{href:F,navigate:function(){var ge=O(x,X.location),be=f?ie.replace:ie.push;be(ge)}});return S!==C?ne.ref=l||P:ne.innerRef=P,V.a.createElement(g,ne)})});if(!1)var u,T;var m=function(l){return l},p=V.a.forwardRef;typeof p=="undefined"&&(p=m);function _(){for(var h=arguments.length,l=new Array(h),a=0;a<h;a++)l[a]=arguments[a];return l.filter(function(g){return g}).join(" ")}var v=p(function(h,l){var a=h["aria-current"],g=a===void 0?"page":a,f=h.activeClassName,x=f===void 0?"active":f,P=h.activeStyle,G=h.className,X=h.exact,ie=h.isActive,z=h.location,F=h.sensitive,ne=h.strict,ce=h.style,ge=h.to,be=h.innerRef,Ie=Object(M.a)(h,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return V.a.createElement(fe.e.Consumer,null,function(Te){Te||Object(R.a)(!1);var De=z||Te.location,we=A(O(ge,De),De),Ae=we.pathname,ve=Ae&&Ae.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),W=ve?Object(fe.f)(De.pathname,{path:ve,exact:X,sensitive:F,strict:ne}):null,L=!!(ie?ie(W,De):W),k=L?_(G,x):G,H=L?Object(B.a)({},ce,{},P):ce,ee=Object(B.a)({"aria-current":L&&g||null,className:k,style:H,to:we},Ie);return m!==p?ee.ref=l||be:ee.innerRef=be,V.a.createElement(s,ee)})});if(!1)var c},"7Cbv":function(gt,at,ue){"use strict";var fe=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),Q=new Uint8Array(16);function D(){if(!fe)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return fe(Q)}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(O){return typeof O=="string"&&V.test(O)}for(var y=I,j=[],B=0;B<256;++B)j.push((B+256).toString(16).substr(1));function M(O){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=(j[O[A+0]]+j[O[A+1]]+j[O[A+2]]+j[O[A+3]]+"-"+j[O[A+4]]+j[O[A+5]]+"-"+j[O[A+6]]+j[O[A+7]]+"-"+j[O[A+8]]+j[O[A+9]]+"-"+j[O[A+10]]+j[O[A+11]]+j[O[A+12]]+j[O[A+13]]+j[O[A+14]]+j[O[A+15]]).toLowerCase();if(!y(S))throw TypeError("Stringified UUID is invalid");return S}var R=M;function b(O,A,S){O=O||{};var C=O.random||(O.rng||D)();if(C[6]=C[6]&15|64,C[8]=C[8]&63|128,A){S=S||0;for(var d=0;d<16;++d)A[S+d]=C[d];return A}return R(C)}var w=at.a=b},"7ahc":function(gt,at,ue){"use strict";ue.d(at,"a",function(){return T});var fe=ue("k1fw"),Q=ue("0Owb"),D=ue("+L6B"),V=ue("2/Rp"),I=ue("y8nQ"),y=ue("Vl3Y"),j=ue("tJVT"),B=ue("OaEy"),M=ue("2fM7"),R=ue("q1tI"),b=ue.n(R),w=ue("VrN/"),O=ue.n(w),A=ue("p77/"),S=ue.n(A),C=ue("c5Ni"),d=ue.n(C),o=M.a.Option,s={labelCol:{span:4},wrapperCol:{span:20}},u={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"]};at.b=function(m){var p=m.callback,_=m.onCancel,v=Object(R.useState)("python"),c=Object(j.a)(v,2),h=c[0],l=c[1];function a(f){l(u[f][1])}function g(f){p(f)}return b.a.createElement(y.a,Object(Q.a)({},s,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:g}),b.a.createElement(y.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},b.a.createElement(M.a,{onChange:a},Object.keys(u).map(function(f){return b.a.createElement(o,{key:f,value:f},u[f][0])}))),b.a.createElement(y.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},b.a.createElement(T,{mode:h})),b.a.createElement("div",{className:"flex-container flex-end"},b.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),b.a.createElement(V.a,{type:"ghost",onClick:_},"\u53D6\u6D88")))};function T(m){var p=m.value,_=m.onChange,v=m.mode,c=m.options,h=c===void 0?{}:c,l=Object(R.useRef)(),a=Object(R.useState)(),g=Object(j.a)(a,2),f=g[0],x=g[1];return Object(R.useEffect)(function(){if(f){function P(G){var X=G.getValue();_&&_(X)}return f.on("change",P),function(){f.off("change",P)}}},[f,_]),Object(R.useEffect)(function(){f&&f.setOption("mode",v)},[f,v]),Object(R.useEffect)(function(){f&&((p!==f.getValue()||p==="")&&setTimeout(function(){f.setValue(p||" ")},300))},[f,p]),Object(R.useEffect)(function(){if(l.current&&!f){var P=O.a.fromTextArea(l.current,Object(fe.a)({mode:v,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},h));x(P)}},[l.current,f]),b.a.createElement("div",{className:"my-codemirror-container"},b.a.createElement("textarea",{ref:l}))}},"8EBN":function(gt,at,ue){(function(fe){fe(ue("VrN/"))})(function(fe){"use strict";fe.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 Q=0;Q<fe.modeInfo.length;Q++){var D=fe.modeInfo[Q];D.mimes&&(D.mime=D.mimes[0])}fe.findModeByMIME=function(V){V=V.toLowerCase();for(var I=0;I<fe.modeInfo.length;I++){var y=fe.modeInfo[I];if(y.mime==V)return y;if(y.mimes){for(var j=0;j<y.mimes.length;j++)if(y.mimes[j]==V)return y}}if(/\+xml$/.test(V))return fe.findModeByMIME("application/xml");if(/\+json$/.test(V))return fe.findModeByMIME("application/json")},fe.findModeByExtension=function(V){V=V.toLowerCase();for(var I=0;I<fe.modeInfo.length;I++){var y=fe.modeInfo[I];if(y.ext){for(var j=0;j<y.ext.length;j++)if(y.ext[j]==V)return y}}},fe.findModeByFileName=function(V){for(var I=0;I<fe.modeInfo.length;I++){var y=fe.modeInfo[I];if(y.file&&y.file.test(V))return y}var j=V.lastIndexOf("."),B=j>-1&&V.substring(j+1,V.length);if(B)return fe.findModeByExtension(B)},fe.findModeByName=function(V){V=V.toLowerCase();for(var I=0;I<fe.modeInfo.length;I++){var y=fe.modeInfo[I];if(y.name.toLowerCase()==V)return y;if(y.alias){for(var j=0;j<y.alias.length;j++)if(y.alias[j].toLowerCase()==V)return y}}}})},"8JLL":function(gt,at,ue){gt.exports={flex_box_center:"flex_box_center___15KPT",flex_space_between:"flex_space_between___1QiSE",flex_box_vertical_center:"flex_box_vertical_center___3bNXy",flex_box_center_end:"flex_box_center_end___1hLE4",flex_box_column:"flex_box_column___3CCm3",reply:"reply___eY1t0",replyList:"replyList___3g6Og",comment:"comment___LHpQl",content:"content___XWl90",commentItem:"commentItem___2Y_u_"}},"8hTe":function(gt,at,ue){gt.exports={button:"button___1wy9m"}},"9Bee":function(gt,at,ue){"use strict";var fe=ue("DYRE"),Q=ue("zeV3"),D=ue("+L6B"),V=ue("2/Rp"),I=ue("k1fw"),y=ue("9og8"),j=ue("tJVT"),B=ue("WmNS"),M=ue.n(B),R=ue("q1tI"),b=ue.n(R),w=ue("vg9a"),O=ue("DlQD"),A=ue.n(O),S=ue("rUJ1");function C(ae,J){var $=ae.match(/^(\s+)(?:```)/);if($===null)return J;var re=$[1];return J.split(`
|
|
`).map(function(oe){var q=oe.match(/^\s+/);if(q===null)return oe;var Z=Object(j.a)(q,1),se=Z[0];return se.length>=re.length?oe.slice(re.length):oe}).join(`
|
|
`)}var d=[],o=["<ul>"],s=new A.a.Renderer,u=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function T(){d.length=0,o=["<ul>"]}var m={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function p(ae,J,$,re){if(J>=ae.length||ae[J].level<=$)return J;var oe=ae[J];re.push("<li><a href='#"+oe.anchor+"'>"+oe.text+"</a>"),J++;var q=[];return J=p(ae,J,oe.level,q),q.length>0&&(re.push("<ul>"),q.forEach(function(Z){re.push(Z)}),re.push("</ul>")),re.push("</li>"),J=p(ae,J,$,re),J}function _(){return p(d,0,0,o),o.push("</ul>"),o.join("")}var v={heading:function(J){var $=u.exec(J);if($)return{type:"heading",raw:$[0],depth:$[1].length,text:$[2]}},fences:function(J){var $=this.rules.block.fences.exec(J);if($){var re=$[0],oe=C(re,$[3]||""),q=$[2]?$[2].trim():$[2];if(["latex","katex","math"].indexOf(q)>=0){var Z=l(),se=oe;oe=Z,a[Z]={type:"block",expression:se}}return{type:"code",raw:re,lang:q,text:oe}}}},c=/(?:\${2})([^\n`]+?)(?:\${2})/gi,h=0,l=function(){return"__special_katext_id_".concat(h++,"__")},a={};function g(){return a}function f(){h=0,a={}}function x(ae){return ae=ae.replace(c,function(J,$){var re=l();return a[re]={type:"inline",expression:$},re}),ae}var P=s.listitem;s.listitem=function(ae){return P(x(ae))};var G=s.paragraph;s.paragraph=function(ae){return G(x(ae))};var X=s.tablecell;s.tablecell=function(ae,J){return X(x(ae),J)},s.code=function(ae,J,$){var re=(J||"").match(/\S*/)[0];return re?["latex","katex","math"].indexOf(re)>=0?"<p class='editormd-tex'>".concat(ae,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(J,'">').concat($?ae:Object(S.escape)(ae,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+($?ae:Object(S.escape)(ae,!0))+"</code></pre>"},s.heading=function(ae,J,$){var re=this.options.headerPrefix+$.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return d.push({anchor:re,level:J,text:ae}),"<h"+J+' id="'+re+'">'+ae+"</h"+J+">"},A.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),A.a.use({tokenizer:v,renderer:s});var ie=A.a,z=ue("SJMd"),F=ue("ulZh"),ne=ue.n(F),ce=ue("m3rI"),ge=ue("Oy/b"),be=ue("p5ED"),Ie=ue("ErOA"),Te=ue("STEk");/* **********************************
|
|
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 De=function(ae,J){return(De=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function($,re){$.__proto__=re}||function($,re){for(var oe in re)Object.prototype.hasOwnProperty.call(re,oe)&&($[oe]=re[oe])})(ae,J)};function we(ae,J){if(typeof J!="function"&&J!==null)throw new TypeError("Class extends value "+String(J)+" is not a constructor or null");function $(){this.constructor=ae}De(ae,J),ae.prototype=J===null?Object.create(J):($.prototype=J.prototype,new $)}function Ae(ae,J,$,re){return new($||($=Promise))(function(oe,q){function Z(pe){try{le(re.next(pe))}catch(ye){q(ye)}}function se(pe){try{le(re.throw(pe))}catch(ye){q(ye)}}function le(pe){var ye;pe.done?oe(pe.value):(ye=pe.value,ye instanceof $?ye:new $(function(Le){Le(ye)})).then(Z,se)}le((re=re.apply(ae,J||[])).next())})}function ve(ae,J){var $,re,oe,q,Z={label:0,sent:function(){if(1&oe[0])throw oe[1];return oe[1]},trys:[],ops:[]};return q={next:se(0),throw:se(1),return:se(2)},typeof Symbol=="function"&&(q[Symbol.iterator]=function(){return this}),q;function se(le){return function(pe){return function(ye){if($)throw new TypeError("Generator is already executing.");for(;Z;)try{if($=1,re&&(oe=2&ye[0]?re.return:ye[0]?re.throw||((oe=re.return)&&oe.call(re),0):re.next)&&!(oe=oe.call(re,ye[1])).done)return oe;switch(re=0,oe&&(ye=[2&ye[0],oe.value]),ye[0]){case 0:case 1:oe=ye;break;case 4:return Z.label++,{value:ye[1],done:!1};case 5:Z.label++,re=ye[1],ye=[0];continue;case 7:ye=Z.ops.pop(),Z.trys.pop();continue;default:if(!(oe=Z.trys,(oe=oe.length>0&&oe[oe.length-1])||ye[0]!==6&&ye[0]!==2)){Z=0;continue}if(ye[0]===3&&(!oe||ye[1]>oe[0]&&ye[1]<oe[3])){Z.label=ye[1];break}if(ye[0]===6&&Z.label<oe[1]){Z.label=oe[1],oe=ye;break}if(oe&&Z.label<oe[2]){Z.label=oe[2],Z.ops.push(ye);break}oe[2]&&Z.ops.pop(),Z.trys.pop();continue}ye=J.call(ae,Z)}catch(Le){ye=[6,Le],re=0}finally{$=oe=0}if(5&ye[0])throw ye[1];return{value:ye[0]?ye[1]:void 0,done:!0}}([le,pe])}}}var W=function(){function ae(){}return ae.addKey=function(J){ae.key=J},Object.defineProperty(ae,"isLicensed",{get:function(){return!!ae.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(ae.key)},enumerable:!1,configurable:!0}),ae}(),L=function(){function ae(){}return ae.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},ae.setAttributes=function(J,$){for(var re=0,oe=$;re<oe.length;re++){var q=oe[re],Z=q[0],se=q[1];J.setAttribute(Z,se)}},ae.createRect=function(J,$,re){var oe=document.createElementNS("http://www.w3.org/2000/svg","rect");return oe.setAttribute("width",J.toString()),oe.setAttribute("height",$.toString()),re&&ae.setAttributes(oe,re),oe},ae.createLine=function(J,$,re,oe,q){var Z=document.createElementNS("http://www.w3.org/2000/svg","line");return Z.setAttribute("x1",J.toString()),Z.setAttribute("y1",$.toString()),Z.setAttribute("x2",re.toString()),Z.setAttribute("y2",oe.toString()),q&&ae.setAttributes(Z,q),Z},ae.createPolygon=function(J,$){var re=document.createElementNS("http://www.w3.org/2000/svg","polygon");return re.setAttribute("points",J),$&&ae.setAttributes(re,$),re},ae.createCircle=function(J,$){var re=document.createElementNS("http://www.w3.org/2000/svg","circle");return re.setAttribute("cx",(J/2).toString()),re.setAttribute("cy",(J/2).toString()),re.setAttribute("r",J.toString()),$&&ae.setAttributes(re,$),re},ae.createEllipse=function(J,$,re){var oe=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return oe.setAttribute("cx",(J/2).toString()),oe.setAttribute("cy",($/2).toString()),oe.setAttribute("rx",(J/2).toString()),oe.setAttribute("ry",($/2).toString()),re&&ae.setAttributes(oe,re),oe},ae.createGroup=function(J){var $=document.createElementNS("http://www.w3.org/2000/svg","g");return J&&ae.setAttributes($,J),$},ae.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},ae.createMarker=function(J,$,re,oe,q,Z,se){var le=document.createElementNS("http://www.w3.org/2000/svg","marker");return ae.setAttributes(le,[["id",J],["orient",$],["markerWidth",re.toString()],["markerHeight",oe.toString()],["refX",q.toString()],["refY",Z.toString()]]),le.appendChild(se),le},ae.createText=function(J){var $=document.createElementNS("http://www.w3.org/2000/svg","text");return $.setAttribute("x","0"),$.setAttribute("y","0"),J&&ae.setAttributes($,J),$},ae.createTSpan=function(J,$){var re=document.createElementNS("http://www.w3.org/2000/svg","tspan");return re.textContent=J,$&&ae.setAttributes(re,$),re},ae.createImage=function(J){var $=document.createElementNS("http://www.w3.org/2000/svg","image");return J&&ae.setAttributes($,J),$},ae.createPoint=function(J,$){var re=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return re.x=J,re.y=$,re},ae.createPath=function(J,$){var re=document.createElementNS("http://www.w3.org/2000/svg","path");return re.setAttribute("d",J),$&&ae.setAttributes(re,$),re},ae.createElement=function(J,$){var re=document.createElementNS("http://www.w3.org/2000/svg",J);return $&&ae.setAttributes(re,$),re},ae.getHollowRectanglePath=function(J,$,re,oe,q,Z,se,le){return"M"+J+","+$+"V"+($+oe)+"H"+(J+re)+"V"+$+"H"+q+"V"+Z+"H"+(q+se)+"V"+(Z+le)+"H"+q+"V"+$+"Z"},ae}(),k=function(){function ae(J){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+J+"_"}return Object.defineProperty(ae.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(ae.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(ae.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),ae.prototype.addClass=function(J){return this.styleSheet===void 0&&this.addStyleSheet(),J.name=""+this.classNamePrefix+J.localName,this.classes.push(J),this.styleSheet.sheet.insertRule("."+J.name+" {"+J.style+"}",this.styleSheet.sheet.cssRules.length),J},ae.prototype.addRule=function(J){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(J),this.styleSheet.sheet.insertRule(J.selector+" {"+J.style+"}",this.styleSheet.sheet.cssRules.length)},ae.prototype.addStyleSheet=function(){var J;this.styleSheet=document.createElement("style"),((J=this.styleSheetRoot)!==null&&J!==void 0?J:document.head).appendChild(this.styleSheet),this.addRule(new H("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new H("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new H("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new ee("_fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new ee("_fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},ae.prototype.removeStyleSheet=function(){var J;this.styleSheet&&(((J=this.styleSheetRoot)!==null&&J!==void 0?J:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},ae}(),H=function(ae,J){this.selector=ae,this.style=J},ee=function(ae,J){this.localName=ae,this.style=J},U=function(){function ae(){this.blocks=[],this.display=""}return ae.prototype.addButtonBlock=function(J){J.className=this.blockClassName,J.buttonClassName=this.buttonClassName,J.buttonColorsClassName=this.buttonColorsClassName,J.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(J)},ae.prototype.addElementBlock=function(J){J.className===void 0&&(J.className=this.blockClassName),this.blocks.push(J)},ae.prototype.getUI=function(){var J=document.createElement("div");return J.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,J.style.display=this.display,this.blocks.forEach(function($){return J.appendChild($.getUI())}),J},ae}(),de=function(){function ae(){}return ae.prototype.getUI=function(){var J=document.createElement("div");if(J.className=this.className,this.minWidth!==void 0&&(J.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":J.style.justifyContent="flex-start";break;case"center":J.style.justifyContent="center";break;case"end":J.style.justifyContent="flex-end"}return J.style.whiteSpace="nowrap",J},ae}(),Ee=function(ae){function J(){var $=ae!==null&&ae.apply(this,arguments)||this;return $.buttons=[],$}return we(J,ae),J.prototype.addButton=function($){$.className=this.buttonClassName,$.colorsClassName=this.buttonColorsClassName,$.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push($)},J.prototype.getUI=function(){var $=ae.prototype.getUI.call(this);return this.buttons.forEach(function(re){return $.appendChild(re.getUI())}),$},J}(de),_e=function(){function ae(J,$){this._isActive=!1,this._isHidden=!1,this._icon=J,this.title=$,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(ae.prototype,"icon",{get:function(){return this._icon},set:function(J){this._icon=J,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isActive",{get:function(){return this._isActive},set:function(J){this._isActive=J,this.adjustClassName()},enumerable:!1,configurable:!0}),ae.prototype.getUI=function(){var J=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 J.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},ae.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,"")))},ae.prototype.hide=function(){this._isHidden=!0},ae}(),Ue=function(ae){function J(){var $=ae!==null&&ae.apply(this,arguments)||this;return $.elements=[],$}return we(J,ae),J.prototype.addElement=function($){this.elements.push($)},J.prototype.getUI=function(){var $=ae.prototype.getUI.call(this);return this.elements.forEach(function(re){return $.appendChild(re)}),$},J}(de),ke=function(){function ae(J,$){this.horizontal=J,this.vertical=$}return Object.defineProperty(ae.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),ae.prototype.getVerticalLength=function(J){return J/this.ratio},ae.prototype.getHorizontalLength=function(J){return J*this.ratio},ae}(),Oe=function(){function ae(){}return ae.getIcon=function(J,$){if(J>0&&$>0){var re=new ke(J,$),oe=re.ratio>=1?20:re.getHorizontalLength(20),q=re.ratio<1?20:re.getVerticalLength(20),Z=document.createElementNS("http://www.w3.org/2000/svg","svg");Z.setAttribute("xmlns","http://www.w3.org/2000/svg"),Z.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(Z);var se=L.createDefs();Z.appendChild(se);var le=L.createElement("clipPath",[["id","text-bg-clip"]]);se.appendChild(le);var pe=L.createPath(L.getHollowRectanglePath((24-oe)/2,(24-q)/2,oe,q,(24-oe)/2+2,(24-q)/2+2,oe-4,q-4));Z.appendChild(pe);var ye=L.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);ye.appendChild(L.createTSpan(J+":"+$)),Z.appendChild(ye);var Le=ye.getBBox();L.setAttributes(ye,[["x",((24-Le.width)/2).toString()],["y",((24-Le.height)/2-Le.y).toString()]]);var Me=L.createPath(L.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Le.width))/2,(24-Math.ceil(Le.height))/2,Math.ceil(Le.width),Math.ceil(Le.height)));return le.appendChild(Me),L.setAttributes(pe,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(Z),Z.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>'},ae}(),Pe=function(ae){function J($,re,oe){var q=ae.call(this,$,re)||this;return q.isDropdownOpen=!1,q.onClick=q.dropdownButtonClicked,q.dropdownButtons=oe,q}return we(J,ae),J.prototype.setupDropdown=function(){var $=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(re){re.className=$.className,re.colorsClassName=$.colorsClassName,$.dropdownBlock.appendChild(re.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},J.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},J.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},J.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},J.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},J.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},J}(_e),Xe=function(){function ae(J,$){this.GRIP_SIZE=10,this.color=J,this.fillColor=$,this.visual=L.createGroup(),this.visual.appendChild(L.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(L.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return ae.prototype.ownsTarget=function(J){return J===this.visual||J===this.visual.childNodes[0]||J===this.visual.childNodes[1]},ae.prototype.setCenter=function(J,$){this.visual.childNodes.forEach(function(re){return L.setAttributes(re,[["cx",J.toString()],["cy",$.toString()]])})},ae}(),Fe=function(){function ae(J,$,re,oe){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=J,this.canvasHeight=$,this.margin=re,this.container=oe,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(ae.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(J){this._aspectRatio=J,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(J){this._isGridVisible=J,this.gridContainer&&L.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(J){this._zoomFactor=J,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),ae.prototype.open=function(){var J=this;this.cropShadeElement=L.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=L.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var $=0;$<this.numberOfGridLines;$++)this.horizontalGridLines.push(L.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(L.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(re){return J.gridContainer.appendChild(re)}),this.verticalGridLines.forEach(function(re){return J.gridContainer.appendChild(re)}),this.cropRectElement=L.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Xe(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Xe(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Xe(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Xe(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},ae.prototype.setCropRectangle=function(J){this.cropRect=J;var $=Object.assign({},this.cropRect);this.zoomFactor!==1&&($.width=this.cropRect.width*this.zoomFactor,$.height=this.cropRect.height*this.zoomFactor,$.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-$.width/2,$.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-$.height/2),L.setAttributes(this.cropRectElement,[["x",$.x.toString()],["y",$.y.toString()],["width",$.width.toString()],["height",$.height.toString()]]);var re=$.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(q,Z){var se=$.y+re*(Z+1);L.setAttributes(q,[["x1",""+$.x],["y1",""+se],["x2",""+($.x+$.width)],["y2",""+se]])});var oe=$.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(q,Z){var se=$.x+oe*(Z+1);L.setAttributes(q,[["x1",""+se],["y1",""+$.y],["x2",""+se],["y2",""+($.y+$.height)]])}),L.setAttributes(this.cropShadeElement,[["d",L.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,$.x,$.y,$.width,$.height)]]),this.topLeftGrip.setCenter($.x,$.y),this.topRightGrip.setCenter($.x+$.width,$.y),this.bottomLeftGrip.setCenter($.x,$.y+$.height),this.bottomRightGrip.setCenter($.x+$.width,$.y+$.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},ae.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)},ae.prototype.clientToLocalCoordinates=function(J,$){var re=this.container.getBoundingClientRect();return{x:J-re.left+this.margin,y:$-re.top+this.margin}},ae.prototype.onPointerDown=function(J){this.container.setPointerCapture(J.pointerId),this.previousPoint=this.clientToLocalCoordinates(J.clientX,J.clientY),this.cropRectElement===J.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(J.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(J.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(J.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(J.target)&&(this.activeGrip=this.bottomRightGrip)},ae.prototype.onPointerMove=function(J){if(this.isMoving)this.move(this.clientToLocalCoordinates(J.clientX,J.clientY));else if(this.activeGrip){var $=this.clientToLocalCoordinates(J.clientX,J.clientY);this.resize($)}J.preventDefault()},ae.prototype.onPointerUp=function(J){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(J.pointerId)},ae.prototype.move=function(J){var $=J.x-this.previousPoint.x,re=J.y-this.previousPoint.y;this.zoomFactor!==1&&($=-$/this.zoomFactor,re=-re/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+$),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+re),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=J},ae.prototype.resize=function(J){var $=Object.assign({},this.cropRect),re=J.x-this.previousPoint.x,oe=J.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:$.x+re<this.margin&&(re=this.margin-$.x),$.x+=re,$.width=this.cropRect.x+this.cropRect.width-$.x;break;case this.bottomRightGrip:case this.topRightGrip:$.width+re>this.canvasWidth*this.zoomFactor&&(re=this.canvasWidth*this.zoomFactor-$.width),$.width+=re}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?($.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(re),$.height=this.aspectRatio.getVerticalLength($.width)):($.y+=oe,$.height=this.cropRect.y+this.cropRect.height-$.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?$.height=this.aspectRatio.getVerticalLength($.width):$.height+=oe}$.width<10&&($.x=this.cropRect.x,$.width=10),$.height<10&&($.y=this.cropRect.y,$.height=10),this.previousPoint=J,$.x>=this.margin&&$.y>=this.margin&&$.x-this.margin+$.width<=this.canvasWidth&&$.y-this.margin+$.height<=this.canvasHeight&&(this.cropRect=$,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},ae.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var J=this.cropRect.x+this.cropRect.width/2,$=this.cropRect.y+this.cropRect.height/2,re=this.aspectRatio.getHorizontalLength(this.cropRect.height),oe=this.aspectRatio.getVerticalLength(this.cropRect.width);re/this.canvasWidth<oe/this.canvasHeight?this.cropRect.width=re:this.cropRect.height=oe,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=J-this.cropRect.width/2,this.cropRect.y=$-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)}},ae.prototype.getRescaledRect=function(J,$,re,oe,q,Z){var se=re/J,le=oe/$;return{x:(q.x-Z)*se+Z,y:(q.y-Z)*le+Z,width:q.width*se,height:q.height*le}},ae.prototype.scaleCanvas=function(J,$){var re=this.getRescaledRect(this.canvasWidth,this.canvasHeight,J,$,this.cropRect,this.margin);this.canvasWidth=J,this.canvasHeight=$,this.onCropChange&&this.onCropChange(re),this.setCropRectangle(re)},ae}(),Ne=function(){function ae(J){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=J,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(ae.prototype,"angle",{get:function(){return this._angle},set:function(J){this._angle=J,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),ae.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},ae.prototype.onPointerDown=function(J){this.controlContainer.setPointerCapture(J.pointerId),this.isDragging=!0,this.previousPoint={x:J.clientX,y:J.clientY}},ae.prototype.onPointerMove=function(J){this.isDragging&&(this.onAngleChange&&this.onAngleChange((J.clientX-this.previousPoint.x)/5),this.previousPoint.x=J.clientX)},ae.prototype.onPointerUp=function(J){this.isDragging&&this.onAngleChange&&this.onAngleChange((J.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(J.pointerId)},ae.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var J=this.angleLabelText.getBBox();L.setAttributes(this.angleLabelElement,[["x",((this.width-J.width)/2).toString()],["y",(this.height/2).toString()]])}},ae.prototype.positionScaleShape=function(){if(this.scaleShape){var J=this.scaleShape.transform.baseVal.getItem(0);J.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(J,0)}},ae.prototype.getVisual=function(){var J=document.createElementNS("http://www.w3.org/2000/svg","svg");J.setAttribute("xmlns","http://www.w3.org/2000/svg"),J.setAttribute("width",this.width+"px"),J.setAttribute("height",this.height+"px"),J.setAttribute("viewBox","0 0 "+this.width+" "+this.height),J.style.flexShrink="0",document.body.appendChild(J);for(var $="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,re=1;re<=this.width/5+10;re++){var oe=re%5==0?this.height/3:this.height/6;$+="h4v"+-oe+"h1v"+oe}$+="v1H0Z",this.scaleShape=L.createPath($);var q=L.createTransform();this.scaleShape.transform.baseVal.appendItem(q),J.appendChild(this.scaleShape),this.angleLabelElement=L.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=L.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var Z=L.createTSpan("");return Z.innerHTML="°",this.angleLabelElement.appendChild(Z),J.appendChild(this.angleLabelElement),document.body.removeChild(J),J},ae}(),We=function(){function ae(){this.naturalSize=!1,this.imageType="image/png"}return ae.prototype.rasterize=function(J,$,re,oe,q,Z,se){var le=this;return new Promise(function(pe){var ye=document.createElement("canvas");ye.width=J.width.baseVal.value-2*oe,ye.height=J.height.baseVal.value-2*oe;var Le=1,Me=1;le.naturalSize===!0?(Le=$.naturalWidth/(J.width.baseVal.value-2*oe)/Z,Me=$.naturalHeight/(J.height.baseVal.value-2*oe)/se,ye.width=$.naturalWidth/Z,ye.height=$.naturalHeight/se):le.width!==void 0&&le.height!==void 0&&(Le=le.width/re.width,Me=le.height/re.height,ye.width*=Le,ye.height*=Me);var et=ye.getContext("2d");et.translate(ye.width/2,ye.height/2),et.rotate(q*Math.PI/180),et.scale(Z,se),et.translate(-ye.width/2,-ye.height/2),et.drawImage($,0,0,ye.width,ye.height);var rt=document.createElement("canvas");rt.width=re.width*Le,rt.height=re.height*Me,rt.getContext("2d").putImageData(et.getImageData((re.x-oe)*Le,(re.y-oe)*Me,re.width*Le,re.height*Me),0,0),pe(rt.toDataURL(le.imageType,le.imageQuality))})},ae}(),Ze=function(){function ae(J){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=ae.instanceCounter++,this.styles=new k(this.instanceNo),this.target=J,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(ae.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(J){this._zoomToCropEnabled=J,J?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(J){this._isGridVisible=J,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"gridLines",{get:function(){return this._gridLines},set:function(J){this._gridLines=J,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(J){this._rotationAngle=J,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"aspectRatio",{get:function(){var J;return(J=this._aspectRatio)!==null&&J!==void 0?J:this.aspectRatios[0]},set:function(J){this._aspectRatio=J},enumerable:!1,configurable:!0}),ae.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},ae.prototype.show=function(){this.showUI(),this.open()},ae.prototype.close=function(J){J===void 0&&(J=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),J||this.closeEventListeners.forEach(function($){return $()}),this._isOpen=!1)},ae.prototype.addRenderEventListener=function(J){this.renderEventListeners.push(J)},ae.prototype.removeRenderEventListener=function(J){this.renderEventListeners.indexOf(J)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(J),1)},ae.prototype.addCloseEventListener=function(J){this.closeEventListeners.push(J)},ae.prototype.removeCloseEventListener=function(J){this.closeEventListeners.indexOf(J)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(J),1)},ae.prototype.setupResizeObserver=function(){var J=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){J.resize(J.target.clientWidth,J.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))},ae.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var J=1*this.target.clientWidth/this.target.clientHeight,$=this.contentDiv.clientWidth/J>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*J:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,re=$+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/J;this.resize($,re)}},ae.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},ae.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",L.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},ae.prototype.resize=function(J,$){this.imageWidth=Math.round(J),this.imageHeight=Math.round($),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()},ae.prototype.setEditingTarget=function(){var J=document.createElement("canvas");J.width=this.target.naturalWidth,J.height=this.target.naturalHeight,J.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var $=J.toDataURL();L.setAttributes(this.editingTarget,[["href",$]]),this.setEditingTargetSize()},ae.prototype.setTopLeft=function(){var J=this.target.getBoundingClientRect(),$=this.editorCanvas.getBoundingClientRect();this.left=J.left-$.left-this.CANVAS_MARGIN,this.top=J.top-$.top-this.CANVAS_MARGIN},ae.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=L.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=L.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=L.createGroup(),this.editingTargetRotationScaleContainer=L.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var J=L.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(J);var $=L.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem($),this.editingTargetContainer=L.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)},ae.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},ae.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=L.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Fe(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()},ae.prototype.zoomToCrop=function(){if(this.cropRect){var J=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,$=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=J+"px "+$+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-J+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-$+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},ae.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)},ae.prototype.cropRectChanged=function(J){this.cropRect=J,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},ae.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},ae.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"},ae.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},ae.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 J=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,$=this.target.offsetTop>J+this.CANVAS_MARGIN?this.target.offsetTop-(J+this.CANVAS_MARGIN):0;this.coverDiv.style.top=$+"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},ae.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},ae.prototype.addTopToolbar=function(){var J=this;this.topToolbar=new U,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 $=new Ee;$.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock($);var re=[];this.aspectRatios.forEach(function(Me){var et=new _e(Oe.getIcon(Me.horizontal,Me.vertical),Me.horizontal===0&&Me.vertical===0?"FREE":Me.horizontal+":"+Me.vertical);et.onClick=function(){return J.ratioButtonClicked(Me)},re.push(et)}),this.aspectRatioButton=new Pe(Oe.getIcon(0,0),"Aspect ratio",re),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,$.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var oe=new _e('<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");oe.isActive=this.isGridVisible,oe.onClick=function(){J.isGridVisible=!J.isGridVisible,oe.isActive=J.isGridVisible},$.addButton(oe);var q=new _e('<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(q.isActive=this.zoomToCropEnabled,q.onClick=function(){J.zoomToCropEnabled=!J.zoomToCropEnabled,q.isActive=J.zoomToCropEnabled},$.addButton(q),!W.isLicensed){var Z=new Ue;this.topToolbar.addElementBlock(Z);var se=document.createElement("div");se.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var le=document.createElement("a");le.style.color="currentColor",le.href="https://markerjs.com/products/cropro",le.target="_blank",le.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>',se.appendChild(le),Z.addElement(se)}var pe=new Ee;pe.minWidth=3*this.toolbarHeight+"px",pe.contentAlign="end",this.topToolbar.addButtonBlock(pe);var ye=new _e('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");ye.onClick=this.startRenderAndClose,pe.addButton(ye),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(ye.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Le=new _e('<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");Le.onClick=this.close,pe.addButton(Le),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Le.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},ae.prototype.addBottomToolbar=function(){var J=this;this.bottomToolbar=new U,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 $=new Ee;$.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock($);var re=new _e('<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");re.onClick=this.rotateLeftButtonClicked,$.addButton(re);var oe=new _e('<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");oe.onClick=this.rotateRightButtonClicked,$.addButton(oe);var q=new Ue;q.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(q),this.straightener=new Ne("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(pe){J.rotateBy(pe),J.straightener.angle=J.rotationAngle},q.addElement(this.straightener.getUI());var Z=new Ee;Z.minWidth=2*this.toolbarHeight+"px",Z.contentAlign="end",this.bottomToolbar.addButtonBlock(Z);var se=new _e('<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");se.onClick=this.flipHorizontallyButtonClicked,Z.addButton(se);var le=new _e('<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");le.onClick=this.flipVerticallyButtonClicked,Z.addButton(le)},ae.prototype.ratioButtonClicked=function(J){this.aspectRatio=J,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},ae.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=Oe.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},ae.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new ke(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},ae.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},ae.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},ae.prototype.restoreState=function(J){if(J){var $=this.cropLayer.getRescaledRect(J.width,J.height,this.imageWidth,this.imageHeight,J.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle($),this.cropRectChanged($),this.flippedHorizontally=J.flippedHorizontally,this.flippedVertically=J.flippedVertically,this.applyFlip(),this.rotationAngle=J.rotationAngle,this.applyRotation()}},ae.prototype.clientToLocalCoordinates=function(J,$){var re=this.cropImage.getBoundingClientRect();return{x:J-re.left,y:$-re.top}},ae.prototype.onWindowResize=function(){this.positionUI()},ae.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var J=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=J+"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()},ae.prototype.rotateLeftButtonClicked=function(){var J=this.rotationAngle-90;this.rotationAngle%90!=0&&(J+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(J)},ae.prototype.rotateRightButtonClicked=function(){var J=this.rotationAngle+90;this.rotationAngle%90!=0&&(J-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(J)},ae.prototype.rotateTo=function(J){J=(J=J>180?J-360:J)<=-180?J+360:J,this.rotationAngle=J,this.applyRotation()},ae.prototype.rotateBy=function(J){this.rotateTo((this.rotationAngle+J)%360)},ae.prototype.applyRotation=function(){var J=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var $=this.editingTargetRotationContainer.transform.baseVal.getItem(0);$.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem($,0);var re=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/re.width,this.imageHeight/re.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=J},ae.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},ae.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},ae.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},ae.prototype.startRenderAndClose=function(){return Ae(this,void 0,void 0,function(){var J,$;return ve(this,function(re){switch(re.label){case 0:return[4,this.render()];case 1:return J=re.sent(),$=this.getState(),this.renderEventListeners.forEach(function(oe){return oe(J,$)}),this.close(!0),[2]}})})},ae.prototype.render=function(){return Ae(this,void 0,void 0,function(){var J;return ve(this,function($){switch($.label){case 0:return(J=new We).naturalSize=this.renderAtNaturalSize,J.imageType=this.renderImageType,J.imageQuality=this.renderImageQuality,J.width=this.renderWidth,J.height=this.renderHeight,this.unzoomFromCrop(),L.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,J.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 $.sent(),[4,J.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,$.sent()]}})})},ae.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new ee("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 ee("toolbar_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new ee("toolbar-block",`
|
|
display: flex;
|
|
align-items: center;
|
|
box-sizing: content-box;
|
|
`));var J=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new ee("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.toolbarHeight-2*J)+`px;
|
|
height: `+(this.toolbarHeight-2*J)+`px;
|
|
padding: `+J+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new ee("toolbar_button_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new ee("toolbar_active_button",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
|
|
`)),this.styles.addRule(new H("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new H("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
|
|
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new ee("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 ee("toolbar_dropdown_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new ee("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 ee("toolbar_straightener",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
height: `+(this.toolbarHeight-2*J)+`px;
|
|
padding: `+J+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new ee("toolbar_straightener_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`))},ae.instanceCounter=0,ae}(),He=ue("8hTe"),Ye=ue.n(He),Ce=/<pre[^>]*>/g;function $e(ae){var J=document.createElement("div");return J.innerHTML=ae,J.childNodes.length===0?"":J.childNodes[0].nodeValue}var qe=at.a=function(ae){var J=ae.value,$=J===void 0?"":J,re=ae.edit,oe=re===void 0?!1:re,q=ae.className,Z=ae.showTextOnly,se=ae.showLines,le=ae.replaces,pe=ae.zoomImg,ye=ae.hasMask,Le=ae.style,Me=Le===void 0?{}:Le,et=ae.stylesPrev,rt=et===void 0?{}:et,Tt=String($),ot=Object(R.useRef)(),Ve=Object(R.useRef)(),vt=Object(R.useState)(""),st=Object(j.a)(vt,2),Lt=st[0],St=st[1],yt=Object(R.useState)("office"),rr=Object(j.a)(yt,2),Wt=rr[0],Ht=rr[1],Ut=function(){var xt=new Ze(Ve.current);xt.displayMode="popup",xt.addRenderEventListener(function(){var Ct=Object(y.a)(M.a.mark(function nt(ft){var pt;return M.a.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:return ot.current.style.display="none",Gt.next=3,Object(Ie.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:ft}});case 3:pt=Gt.sent,pt!=null&&pt.id&&le(Ve.current.getAttribute("src").replace(ce.a.API_SERVER,""),"/api/attachments/".concat(pt==null?void 0:pt.id,"?type=").concat(pt.content_type));case 5:case"end":return Gt.stop()}},nt)}));return function(nt){return Ct.apply(this,arguments)}}()),xt.show()},or=function(){var xt=new Te.a(Ve.current);xt.settings.displayMode="popup",xt.addEventListener("render",function(){var Ct=Object(y.a)(M.a.mark(function nt(ft){var pt;return M.a.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:if(ot.current.style.display="none",!Ve.current){Gt.next=6;break}return Gt.next=4,Object(Ie.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:ft.dataUrl}});case 4:pt=Gt.sent,pt!=null&&pt.id&&le(Ve.current.getAttribute("src").replace(ce.a.API_SERVER,""),"/api/attachments/".concat(pt==null?void 0:pt.id,"?type=").concat(pt.content_type));case 6:case"end":return Gt.stop()}},nt)}));return function(nt){return Ct.apply(this,arguments)}}()),xt.show(),window.markerArea=xt},wr=Object(R.useMemo)(function(){ot.current&&(ot.current.style.zIndex=-1);try{var Ke=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,xt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,Ct=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;Tt=Tt.replace(Ke,"("+ce.a.API_SERVER+"/api/attachments/").replace(xt,'"'+ce.a.API_SERVER+"/api/attachments/").replace(Ct,'"'+ce.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,`
|
|
`)}catch($t){}var nt=ie(Tt),ft=g();if(Tt.match(/\[TOC\]/)&&(nt=nt.replace("<p>[TOC]</p>",_()),T()),nt=nt.replace(/(__special_katext_id_\d+__)/g,function($t,Gt){var je=ft[Gt],mt=je.type,ri=je.expression;return Object(ge.renderToString)($e(ri)||"",{displayMode:mt==="block",throwOnError:!1,output:"html"})}),nt=nt.replace(/▁/g,"\u2581\u2581\u2581"),f(),Z){var pt=document.createElement("div");return pt.innerHTML=nt,pt.innerText}return setTimeout(function(){return Br()},500),nt},[Tt]),Vt=Object(R.useRef)();m.WebkitLineClamp=se,se&&(Me=Object(I.a)(Object(I.a)({},Me),m));function Sr(Ke){var xt=Ke.target;if(xt.tagName.toUpperCase()==="IMG"){if(pe){var Ct=xt.getAttribute("src");St(Ct),Ht("image")}}else if(xt.tagName.toUpperCase()==="A"){var nt=xt.getAttribute("href");if(nt.indexOf("office")>-1)Ke.preventDefault(),St(nt),Ht("office");else if(nt.indexOf("application/pdf")>-1)Ke.preventDefault(),St(nt),Ht("pdf");else if(nt.indexOf("text/html")>-1)Ke.preventDefault(),St(nt),Ht("html");else if(nt.startsWith("#")){Ke.preventDefault();var ft=document.getElementById(nt.replace("#",""));ft&&ft.scrollIntoView(!0)}}}var Br=function(){var xt,Ct=(xt=Vt.current)===null||xt===void 0?void 0:xt.querySelectorAll("video");Ct==null||Ct.forEach(function(nt){if(nt.oncontextmenu=function(){return!1},nt.src.indexOf(".m3u8")>-1&&!nt.canPlayType("application/vnd.apple.mpegurl")){if(ne.a.isSupported()){var ft=new ne.a;ft.loadSource(nt.src),ft.attachMedia(nt)}}})};Object(R.useEffect)(function(){if(Vt.current&&wr&&(wr.match(Ce)&&window.PR.prettyPrint()),Vt.current)return Vt.current.addEventListener("click",Sr),function(){Vt.current.removeEventListener("click",Sr),f(),T()}},[wr,Vt.current,Sr]);var ut=function(xt){if(!oe)return;xt.target.nodeName==="IMG"?(ot.current.style.zIndex=1,ot.current.style.display="flex",ot.current.style.width=xt.target.clientWidth+"px",ot.current.style.height=xt.target.clientHeight+"px",ot.current.style.top=xt.target.offsetTop+"px",ot.current.style.left=xt.target.offsetLeft+"px",Ve.current.src=xt.target.getAttribute("src")):ot.current.style.display="none"};return b.a.createElement("div",{style:{position:"relative"}},b.a.createElement("div",{ref:Vt,style:Object(I.a)({},Me),className:"".concat(q||""," markdown-body ").concat(Ye.a.mdBody),onMouseOver:ut,dangerouslySetInnerHTML:{__html:wr}}),b.a.createElement("div",{ref:ot,className:Ye.a.button},b.a.createElement(Q.a,null,b.a.createElement(V.a,{onClick:function(){return Ut()}},"\u88C1\u526A"),b.a.createElement(V.a,{onClick:function(){return or()}},"\u7F16\u8F91"))),b.a.createElement("img",{ref:Ve,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),b.a.createElement(be.a,{close:!0,data:Lt,type:Lt!=null&&Lt.length?Wt:"",style:Object(I.a)({},rt),onClose:function(){return St("")}}))}},"9VGf":function(gt,at,ue){"use strict";ue.d(at,"a",function(){return D});var fe=ue("q1tI"),Q=ue.n(fe);function D(V,I){var y=Object(fe.useRef)();Object(fe.useEffect)(function(){y.current=V}),Object(fe.useEffect)(function(){function j(){y.current()}if(I!==null){var B=setInterval(j,I);return function(){return clearInterval(B)}}},[I])}},Bd2K:function(gt,at,ue){(function(fe){fe(ue("VrN/"),ue("osHv"))})(function(fe){fe.defineOption("autoCloseTags",!1,function(M,R,b){if(b!=fe.Init&&b&&M.removeKeyMap("autoCloseTags"),!R)return;var w={name:"autoCloseTags"};(typeof R!="object"||R.whenClosing!==!1)&&(w["'/'"]=function(O){return y(O)}),(typeof R!="object"||R.whenOpening!==!1)&&(w["'>'"]=function(O){return V(O)}),M.addKeyMap(w)});var Q=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],D=["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(M){if(M.getOption("disableInput"))return fe.Pass;for(var R=M.listSelections(),b=[],w=M.getOption("autoCloseTags"),O=0;O<R.length;O++){if(!R[O].empty())return fe.Pass;var A=R[O].head,S=M.getTokenAt(A),C=fe.innerMode(M.getMode(),S.state),d=C.state,o=C.mode.xmlCurrentTag&&C.mode.xmlCurrentTag(d),s=o&&o.name;if(!s)return fe.Pass;var u=C.mode.configuration=="html",T=typeof w=="object"&&w.dontCloseTags||u&&Q,m=typeof w=="object"&&w.indentTags||u&&D;S.end>A.ch&&(s=s.slice(0,s.length-S.end+A.ch));var p=s.toLowerCase();if(!s||S.type=="string"&&(S.end!=A.ch||!/[\"\']/.test(S.string.charAt(S.string.length-1))||S.string.length==1)||S.type=="tag"&&o.close||S.string.indexOf("/")==A.ch-S.start-1||T&&j(T,p)>-1||B(M,C.mode.xmlCurrentContext&&C.mode.xmlCurrentContext(d)||[],s,A,!0))return fe.Pass;var _=typeof w=="object"&&w.emptyTags;if(_&&j(_,s)>-1){b[O]={text:"/>",newPos:fe.Pos(A.line,A.ch+2)};continue}var v=m&&j(m,p)>-1;b[O]={indent:v,text:">"+(v?`
|
|
|
|
`:"")+"</"+s+">",newPos:v?fe.Pos(A.line+1,0):fe.Pos(A.line,A.ch+1)}}for(var c=typeof w=="object"&&w.dontIndentOnAutoClose,O=R.length-1;O>=0;O--){var h=b[O];M.replaceRange(h.text,R[O].head,R[O].anchor,"+insert");var l=M.listSelections().slice(0);l[O]={head:h.newPos,anchor:h.newPos},M.setSelections(l),!c&&h.indent&&(M.indentLine(h.newPos.line,null,!0),M.indentLine(h.newPos.line+1,null,!0))}}function I(M,R){for(var b=M.listSelections(),w=[],O=R?"/":"</",A=M.getOption("autoCloseTags"),S=typeof A=="object"&&A.dontIndentOnSlash,C=0;C<b.length;C++){if(!b[C].empty())return fe.Pass;var d=b[C].head,o=M.getTokenAt(d),s=fe.innerMode(M.getMode(),o.state),u=s.state;if(R&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=d.ch-1))return fe.Pass;var T,m=s.mode.name!="xml"&&M.getMode().name=="htmlmixed";if(m&&s.mode.name=="javascript")T=O+"script";else if(m&&s.mode.name=="css")T=O+"style";else{var p=s.mode.xmlCurrentContext&&s.mode.xmlCurrentContext(u);if(!p||p.length&&B(M,p,p[p.length-1],d))return fe.Pass;T=O+p[p.length-1]}M.getLine(d.line).charAt(o.end)!=">"&&(T+=">"),w[C]=T}if(M.replaceSelections(w),b=M.listSelections(),!S)for(var C=0;C<b.length;C++)(C==b.length-1||b[C].head.line<b[C+1].head.line)&&M.indentLine(b[C].head.line)}function y(M){return M.getOption("disableInput")?fe.Pass:I(M,!0)}fe.commands.closeTag=function(M){return I(M)};function j(M,R){if(M.indexOf)return M.indexOf(R);for(var b=0,w=M.length;b<w;++b)if(M[b]==R)return b;return-1}function B(M,R,b,w,O){if(!fe.scanForClosingTag)return!1;var A=Math.min(M.lastLine()+1,w.line+500),S=fe.scanForClosingTag(M,w,null,A);if(!S||S.tag!=b)return!1;for(var C=O?1:0,d=R.length-1;d>=0&&R[d]==b;d--)++C;w=S.to;for(var d=1;d<C;d++){var o=fe.scanForClosingTag(M,w,null,A);if(!o||o.tag!=b)return!1;w=o.to}return!0}})},BjJ7:function(gt,at,ue){"use strict";ue.d(at,"d",function(){return Q}),ue.d(at,"c",function(){return D}),ue.d(at,"e",function(){return V}),ue.d(at,"b",function(){return I}),ue.d(at,"a",function(){return j});var fe=ue("m3rI");function Q(B){var M=!0;if(B.length>0){for(var R=0;R<B.length;R++)if(B[R].compile_success==0||!B[R].compile_success){M=!1;break}}else M=!1;return M}function D(B){for(var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",R=[],b=0;b<B.length;b++){var w=B[b],O=M?"".concat(M,"/").concat(w.name):"".concat(w.name);R.push({title:w.name,isLeaf:!(w.type==="tree"),key:O})}return R}function V(B,M,R){for(var b=0;b<B.length;b++){var w=B[b];if(w.key===M){w.children=R;break}w.children&&V(w.children,M,R)}return B}function I(B,M,R){var b;return function(){var w=this,O=arguments,A=function(){b=null,R||B.apply(w,O)},S=R&&!b;clearTimeout(b),b=setTimeout(A,M),S&&B.apply(w,O)}}var y=!0,j=fe.a.API_SERVER},"C+DQ":function(gt,at,ue){},DlQD:function(gt,at,ue){(function(fe,Q){gt.exports=Q()})(this,function(){"use strict";function fe($,re){for(var oe=0;oe<re.length;oe++){var q=re[oe];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty($,q.key,q)}}function Q($,re,oe){return re&&fe($.prototype,re),oe&&fe($,oe),$}function D($,re){if(!$)return;if(typeof $=="string")return V($,re);var oe=Object.prototype.toString.call($).slice(8,-1);if(oe==="Object"&&$.constructor&&(oe=$.constructor.name),oe==="Map"||oe==="Set")return Array.from($);if(oe==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(oe))return V($,re)}function V($,re){(re==null||re>$.length)&&(re=$.length);for(var oe=0,q=new Array(re);oe<re;oe++)q[oe]=$[oe];return q}function I($,re){var oe;if(typeof Symbol=="undefined"||$[Symbol.iterator]==null){if(Array.isArray($)||(oe=D($))||re&&$&&typeof $.length=="number"){oe&&($=oe);var q=0;return function(){return q>=$.length?{done:!0}:{done:!1,value:$[q++]}}}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 oe=$[Symbol.iterator](),oe.next.bind(oe)}function y($,re){return re={exports:{}},$(re,re.exports),re.exports}var j=y(function($){function re(){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 oe(q){$.exports.defaults=q}$.exports={defaults:re(),getDefaults:re,changeDefaults:oe}}),B=j.defaults,M=j.getDefaults,R=j.changeDefaults,b=/[&<>"']/,w=/[&<>"']/g,O=/[<>"']|&(?!#?\w+;)/,A=/[<>"']|&(?!#?\w+;)/g,S={"&":"&","<":"<",">":">",'"':""","'":"'"},C=function(re){return S[re]};function d($,re){if(re){if(b.test($))return $.replace(w,C)}else if(O.test($))return $.replace(A,C);return $}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function s($){return $.replace(o,function(re,oe){return oe=oe.toLowerCase(),oe==="colon"?":":oe.charAt(0)==="#"?oe.charAt(1)==="x"?String.fromCharCode(parseInt(oe.substring(2),16)):String.fromCharCode(+oe.substring(1)):""})}var u=/(^|[^\[])\^/g;function T($,re){$=$.source||$,re=re||"";var oe={replace:function(Z,se){return se=se.source||se,se=se.replace(u,"$1"),$=$.replace(Z,se),oe},getRegex:function(){return new RegExp($,re)}};return oe}var m=/[^\w:]/g,p=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function _($,re,oe){if($){var q;try{q=decodeURIComponent(s(oe)).replace(m,"").toLowerCase()}catch(Z){return null}if(q.indexOf("javascript:")===0||q.indexOf("vbscript:")===0||q.indexOf("data:")===0)return null}re&&!p.test(oe)&&(oe=a(re,oe));try{oe=encodeURI(oe).replace(/%25/g,"%")}catch(Z){return null}return oe}var v={},c=/^[^:]+:\/*[^/]*$/,h=/^([^:]+:)[\s\S]*$/,l=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a($,re){v[" "+$]||(c.test($)?v[" "+$]=$+"/":v[" "+$]=P($,"/",!0)),$=v[" "+$];var oe=$.indexOf(":")===-1;return re.substring(0,2)==="//"?oe?re:$.replace(h,"$1")+re:re.charAt(0)==="/"?oe?re:$.replace(l,"$1")+re:$+re}var g={exec:function(){}};function f($){for(var re=1,oe,q;re<arguments.length;re++){oe=arguments[re];for(q in oe)Object.prototype.hasOwnProperty.call(oe,q)&&($[q]=oe[q])}return $}function x($,re){var oe=$.replace(/\|/g,function(se,le,pe){for(var ye=!1,Le=le;--Le>=0&&pe[Le]==="\\";)ye=!ye;return ye?"|":" |"}),q=oe.split(/ \|/),Z=0;if(q.length>re)q.splice(re);else for(;q.length<re;)q.push("");for(;Z<q.length;Z++)q[Z]=q[Z].trim().replace(/\\\|/g,"|");return q}function P($,re,oe){var q=$.length;if(q===0)return"";for(var Z=0;Z<q;){var se=$.charAt(q-Z-1);if(se===re&&!oe)Z++;else if(se!==re&&oe)Z++;else break}return $.substr(0,q-Z)}function G($,re){if($.indexOf(re[1])===-1)return-1;for(var oe=$.length,q=0,Z=0;Z<oe;Z++)if($[Z]==="\\")Z++;else if($[Z]===re[0])q++;else if($[Z]===re[1]&&(q--,q<0))return Z;return-1}function X($){$&&$.sanitize&&!$.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 ie={escape:d,unescape:s,edit:T,cleanUrl:_,resolveUrl:a,noopTest:g,merge:f,splitCells:x,rtrim:P,findClosingBracket:G,checkSanitizeDeprecation:X},z=j.defaults,F=ie.rtrim,ne=ie.splitCells,ce=ie.escape,ge=ie.findClosingBracket;function be($,re,oe){var q=re.href,Z=re.title?ce(re.title):null,se=$[1].replace(/\\([\[\]])/g,"$1");return $[0].charAt(0)!=="!"?{type:"link",raw:oe,href:q,title:Z,text:se}:{type:"image",raw:oe,href:q,title:Z,text:ce(se)}}function Ie($,re){var oe=$.match(/^(\s+)(?:```)/);if(oe===null)return re;var q=oe[1];return re.split(`
|
|
`).map(function(Z){var se=Z.match(/^\s+/);if(se===null)return Z;var le=se[0];return le.length>=q.length?Z.slice(q.length):Z}).join(`
|
|
`)}var Te=function(){function $(oe){this.options=oe||z}var re=$.prototype;return re.space=function(q){var Z=this.rules.block.newline.exec(q);if(Z)return Z[0].length>1?{type:"space",raw:Z[0]}:{raw:`
|
|
`}},re.code=function(q,Z){var se=this.rules.block.code.exec(q);if(se){var le=Z[Z.length-1];if(le&&le.type==="paragraph")return{raw:se[0],text:se[0].trimRight()};var pe=se[0].replace(/^ {4}/gm,"");return{type:"code",raw:se[0],codeBlockStyle:"indented",text:this.options.pedantic?pe:F(pe,`
|
|
`)}}},re.fences=function(q){var Z=this.rules.block.fences.exec(q);if(Z){var se=Z[0],le=Ie(se,Z[3]||"");return{type:"code",raw:se,lang:Z[2]?Z[2].trim():Z[2],text:le}}},re.heading=function(q){var Z=this.rules.block.heading.exec(q);if(Z)return{type:"heading",raw:Z[0],depth:Z[1].length,text:Z[2]}},re.nptable=function(q){var Z=this.rules.block.nptable.exec(q);if(Z){var se={type:"table",header:ne(Z[1].replace(/^ *| *\| *$/g,"")),align:Z[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:Z[3]?Z[3].replace(/\n$/,"").split(`
|
|
`):[],raw:Z[0]};if(se.header.length===se.align.length){var le=se.align.length,pe;for(pe=0;pe<le;pe++)/^ *-+: *$/.test(se.align[pe])?se.align[pe]="right":/^ *:-+: *$/.test(se.align[pe])?se.align[pe]="center":/^ *:-+ *$/.test(se.align[pe])?se.align[pe]="left":se.align[pe]=null;for(le=se.cells.length,pe=0;pe<le;pe++)se.cells[pe]=ne(se.cells[pe],se.header.length);return se}}},re.hr=function(q){var Z=this.rules.block.hr.exec(q);if(Z)return{type:"hr",raw:Z[0]}},re.blockquote=function(q){var Z=this.rules.block.blockquote.exec(q);if(Z){var se=Z[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:Z[0],text:se}}},re.list=function(q){var Z=this.rules.block.list.exec(q);if(Z){for(var se=Z[0],le=Z[2],pe=le.length>1,ye=le[le.length-1]===")",Le={type:"list",raw:se,ordered:pe,start:pe?+le.slice(0,-1):"",loose:!1,items:[]},Me=Z[0].match(this.rules.block.item),et=!1,rt,Tt,ot,Ve,vt,st,Lt,St=Me.length,yt=0;yt<St;yt++)rt=Me[yt],se=rt,Tt=rt.length,rt=rt.replace(/^ *([*+-]|\d+[.)]) */,""),~rt.indexOf(`
|
|
`)&&(Tt-=rt.length,rt=this.options.pedantic?rt.replace(/^ {1,4}/gm,""):rt.replace(new RegExp("^ {1,"+Tt+"}","gm"),"")),yt!==St-1&&(ot=this.rules.block.bullet.exec(Me[yt+1])[0],(pe?ot.length===1||!ye&&ot[ot.length-1]===")":ot.length>1||this.options.smartLists&&ot!==le)&&(Ve=Me.slice(yt+1).join(`
|
|
`),Le.raw=Le.raw.substring(0,Le.raw.length-Ve.length),yt=St-1)),vt=et||/\n\n(?!\s*$)/.test(rt),yt!==St-1&&(et=rt.charAt(rt.length-1)===`
|
|
`,vt||(vt=et)),vt&&(Le.loose=!0),st=/^\[[ xX]\] /.test(rt),Lt=void 0,st&&(Lt=rt[1]!==" ",rt=rt.replace(/^\[[ xX]\] +/,"")),Le.items.push({type:"list_item",raw:se,task:st,checked:Lt,loose:vt,text:rt});return Le}},re.html=function(q){var Z=this.rules.block.html.exec(q);if(Z)return{type:this.options.sanitize?"paragraph":"html",raw:Z[0],pre:!this.options.sanitizer&&(Z[1]==="pre"||Z[1]==="script"||Z[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(Z[0]):ce(Z[0]):Z[0]}},re.def=function(q){var Z=this.rules.block.def.exec(q);if(Z){Z[3]&&(Z[3]=Z[3].substring(1,Z[3].length-1));var se=Z[1].toLowerCase().replace(/\s+/g," ");return{tag:se,raw:Z[0],href:Z[2],title:Z[3]}}},re.table=function(q){var Z=this.rules.block.table.exec(q);if(Z){var se={type:"table",header:ne(Z[1].replace(/^ *| *\| *$/g,"")),align:Z[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:Z[3]?Z[3].replace(/\n$/,"").split(`
|
|
`):[]};if(se.header.length===se.align.length){se.raw=Z[0];var le=se.align.length,pe;for(pe=0;pe<le;pe++)/^ *-+: *$/.test(se.align[pe])?se.align[pe]="right":/^ *:-+: *$/.test(se.align[pe])?se.align[pe]="center":/^ *:-+ *$/.test(se.align[pe])?se.align[pe]="left":se.align[pe]=null;for(le=se.cells.length,pe=0;pe<le;pe++)se.cells[pe]=ne(se.cells[pe].replace(/^ *\| *| *\| *$/g,""),se.header.length);return se}}},re.lheading=function(q){var Z=this.rules.block.lheading.exec(q);if(Z)return{type:"heading",raw:Z[0],depth:Z[2].charAt(0)==="="?1:2,text:Z[1]}},re.paragraph=function(q){var Z=this.rules.block.paragraph.exec(q);if(Z)return{type:"paragraph",raw:Z[0],text:Z[1].charAt(Z[1].length-1)===`
|
|
`?Z[1].slice(0,-1):Z[1]}},re.text=function(q,Z){var se=this.rules.block.text.exec(q);if(se){var le=Z[Z.length-1];return le&&le.type==="text"?{raw:se[0],text:se[0]}:{type:"text",raw:se[0],text:se[0]}}},re.escape=function(q){var Z=this.rules.inline.escape.exec(q);if(Z)return{type:"escape",raw:Z[0],text:ce(Z[1])}},re.tag=function(q,Z,se){var le=this.rules.inline.tag.exec(q);if(le)return!Z&&/^<a /i.test(le[0])?Z=!0:Z&&/^<\/a>/i.test(le[0])&&(Z=!1),!se&&/^<(pre|code|kbd|script)(\s|>)/i.test(le[0])?se=!0:se&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(le[0])&&(se=!1),{type:this.options.sanitize?"text":"html",raw:le[0],inLink:Z,inRawBlock:se,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(le[0]):ce(le[0]):le[0]}},re.link=function(q){var Z=this.rules.inline.link.exec(q);if(Z){var se=ge(Z[2],"()");if(se>-1){var le=Z[0].indexOf("!")===0?5:4,pe=le+Z[1].length+se;Z[2]=Z[2].substring(0,se),Z[0]=Z[0].substring(0,pe).trim(),Z[3]=""}var ye=Z[2],Le="";if(this.options.pedantic){var Me=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(ye);Me?(ye=Me[1],Le=Me[3]):Le=""}else Le=Z[3]?Z[3].slice(1,-1):"";ye=ye.trim().replace(/^<([\s\S]*)>$/,"$1");var et=be(Z,{href:ye&&ye.replace(this.rules.inline._escapes,"$1"),title:Le&&Le.replace(this.rules.inline._escapes,"$1")},Z[0]);return et}},re.reflink=function(q,Z){var se;if((se=this.rules.inline.reflink.exec(q))||(se=this.rules.inline.nolink.exec(q))){var le=(se[2]||se[1]).replace(/\s+/g," ");if(le=Z[le.toLowerCase()],!le||!le.href){var pe=se[0].charAt(0);return{type:"text",raw:pe,text:pe}}var ye=be(se,le,se[0]);return ye}},re.strong=function(q,Z,se){se===void 0&&(se="");var le=this.rules.inline.strong.start.exec(q);if(le&&(!le[1]||le[1]&&(se===""||this.rules.inline.punctuation.exec(se)))){Z=Z.slice(-1*q.length);var pe=le[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;pe.lastIndex=0;for(var ye;(le=pe.exec(Z))!=null;)if(ye=this.rules.inline.strong.middle.exec(Z.slice(0,le.index+3)),ye)return{type:"strong",raw:q.slice(0,ye[0].length),text:q.slice(2,ye[0].length-2)}}},re.em=function(q,Z,se){se===void 0&&(se="");var le=this.rules.inline.em.start.exec(q);if(le&&(!le[1]||le[1]&&(se===""||this.rules.inline.punctuation.exec(se)))){Z=Z.slice(-1*q.length);var pe=le[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;pe.lastIndex=0;for(var ye;(le=pe.exec(Z))!=null;)if(ye=this.rules.inline.em.middle.exec(Z.slice(0,le.index+2)),ye)return{type:"em",raw:q.slice(0,ye[0].length),text:q.slice(1,ye[0].length-1)}}},re.codespan=function(q){var Z=this.rules.inline.code.exec(q);if(Z){var se=Z[2].replace(/\n/g," "),le=/[^ ]/.test(se),pe=se.startsWith(" ")&&se.endsWith(" ");return le&&pe&&(se=se.substring(1,se.length-1)),se=ce(se,!0),{type:"codespan",raw:Z[0],text:se}}},re.br=function(q){var Z=this.rules.inline.br.exec(q);if(Z)return{type:"br",raw:Z[0]}},re.del=function(q){var Z=this.rules.inline.del.exec(q);if(Z)return{type:"del",raw:Z[0],text:Z[1]}},re.autolink=function(q,Z){var se=this.rules.inline.autolink.exec(q);if(se){var le,pe;return se[2]==="@"?(le=ce(this.options.mangle?Z(se[1]):se[1]),pe="mailto:"+le):(le=ce(se[1]),pe=le),{type:"link",raw:se[0],text:le,href:pe,tokens:[{type:"text",raw:le,text:le}]}}},re.url=function(q,Z){var se;if(se=this.rules.inline.url.exec(q)){var le,pe;if(se[2]==="@")le=ce(this.options.mangle?Z(se[0]):se[0]),pe="mailto:"+le;else{var ye;do ye=se[0],se[0]=this.rules.inline._backpedal.exec(se[0])[0];while(ye!==se[0]);le=ce(se[0]),se[1]==="www."?pe="http://"+le:pe=le}return{type:"link",raw:se[0],text:le,href:pe,tokens:[{type:"text",raw:le,text:le}]}}},re.inlineText=function(q,Z,se){var le=this.rules.inline.text.exec(q);if(le){var pe;return Z?pe=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(le[0]):ce(le[0]):le[0]:pe=ce(this.options.smartypants?se(le[0]):le[0]),{type:"text",raw:le[0],text:pe}}},$}(),De=ie.noopTest,we=ie.edit,Ae=ie.merge,ve={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:De,table:De,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=we(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,ve.item=we(ve.item,"gm").replace(/bull/g,ve.bullet).getRegex(),ve.list=we(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._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",ve._comment=/<!--(?!-?>)[\s\S]*?-->/,ve.html=we(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=we(ve._paragraph).replace("hr",ve.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",ve._tag).getRegex(),ve.blockquote=we(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal=Ae({},ve),ve.gfm=Ae({},ve.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*|$)"}),ve.gfm.nptable=we(ve.gfm.nptable).replace("hr",ve.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",ve._tag).getRegex(),ve.gfm.table=we(ve.gfm.table).replace("hr",ve.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",ve._tag).getRegex(),ve.pedantic=Ae({},ve.normal,{html:we(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._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:De,paragraph:we(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var W={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:De,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:De,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};W._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",W.punctuation=we(W.punctuation).replace(/punctuation/g,W._punctuation).getRegex(),W._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",W._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",W.em.start=we(W.em.start).replace(/punctuation/g,W._punctuation).getRegex(),W.em.middle=we(W.em.middle).replace(/punctuation/g,W._punctuation).replace(/overlapSkip/g,W._overlapSkip).getRegex(),W.em.endAst=we(W.em.endAst,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.em.endUnd=we(W.em.endUnd,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.strong.start=we(W.strong.start).replace(/punctuation/g,W._punctuation).getRegex(),W.strong.middle=we(W.strong.middle).replace(/punctuation/g,W._punctuation).replace(/blockSkip/g,W._blockSkip).getRegex(),W.strong.endAst=we(W.strong.endAst,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.strong.endUnd=we(W.strong.endUnd,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.blockSkip=we(W._blockSkip,"g").getRegex(),W.overlapSkip=we(W._overlapSkip,"g").getRegex(),W._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,W._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,W._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])?)+(?![-_])/,W.autolink=we(W.autolink).replace("scheme",W._scheme).replace("email",W._email).getRegex(),W._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,W.tag=we(W.tag).replace("comment",ve._comment).replace("attribute",W._attribute).getRegex(),W._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,W._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,W._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,W.link=we(W.link).replace("label",W._label).replace("href",W._href).replace("title",W._title).getRegex(),W.reflink=we(W.reflink).replace("label",W._label).getRegex(),W.reflinkSearch=we(W.reflinkSearch,"g").replace("reflink",W.reflink).replace("nolink",W.nolink).getRegex(),W.normal=Ae({},W),W.pedantic=Ae({},W.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:we(/^!?\[(label)\]\((.*?)\)/).replace("label",W._label).getRegex(),reflink:we(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",W._label).getRegex()}),W.gfm=Ae({},W.normal,{escape:we(W.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),W.gfm.url=we(W.gfm.url,"i").replace("email",W.gfm._extended_email).getRegex(),W.breaks=Ae({},W.gfm,{br:we(W.br).replace("{2,}","*").getRegex(),text:we(W.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var L={block:ve,inline:W},k=j.defaults,H=L.block,ee=L.inline;function U($){return $.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 de($){var re="",oe,q,Z=$.length;for(oe=0;oe<Z;oe++)q=$.charCodeAt(oe),Math.random()>.5&&(q="x"+q.toString(16)),re+="&#"+q+";";return re}var Ee=function(){function $(oe){this.tokens=[],this.tokens.links=Object.create(null),this.options=oe||k,this.options.tokenizer=this.options.tokenizer||new Te,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var q={block:H.normal,inline:ee.normal};this.options.pedantic?(q.block=H.pedantic,q.inline=ee.pedantic):this.options.gfm&&(q.block=H.gfm,this.options.breaks?q.inline=ee.breaks:q.inline=ee.gfm),this.tokenizer.rules=q}$.lex=function(q,Z){var se=new $(Z);return se.lex(q)};var re=$.prototype;return re.lex=function(q){return q=q.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," "),this.blockTokens(q,this.tokens,!0),this.inline(this.tokens),this.tokens},re.blockTokens=function(q,Z,se){Z===void 0&&(Z=[]),se===void 0&&(se=!0),q=q.replace(/^ +$/gm,"");for(var le,pe,ye,Le;q;){if(le=this.tokenizer.space(q)){q=q.substring(le.raw.length),le.type&&Z.push(le);continue}if(le=this.tokenizer.code(q,Z)){q=q.substring(le.raw.length),le.type?Z.push(le):(Le=Z[Z.length-1],Le.raw+=`
|
|
`+le.raw,Le.text+=`
|
|
`+le.text);continue}if(le=this.tokenizer.fences(q)){q=q.substring(le.raw.length),Z.push(le);continue}if(le=this.tokenizer.heading(q)){q=q.substring(le.raw.length),Z.push(le);continue}if(le=this.tokenizer.nptable(q)){q=q.substring(le.raw.length),Z.push(le);continue}if(le=this.tokenizer.hr(q)){q=q.substring(le.raw.length),Z.push(le);continue}if(le=this.tokenizer.blockquote(q)){q=q.substring(le.raw.length),le.tokens=this.blockTokens(le.text,[],se),Z.push(le);continue}if(le=this.tokenizer.list(q)){for(q=q.substring(le.raw.length),ye=le.items.length,pe=0;pe<ye;pe++)le.items[pe].tokens=this.blockTokens(le.items[pe].text,[],!1);Z.push(le);continue}if(le=this.tokenizer.html(q)){q=q.substring(le.raw.length),Z.push(le);continue}if(se&&(le=this.tokenizer.def(q))){q=q.substring(le.raw.length),this.tokens.links[le.tag]||(this.tokens.links[le.tag]={href:le.href,title:le.title});continue}if(le=this.tokenizer.table(q)){q=q.substring(le.raw.length),Z.push(le);continue}if(le=this.tokenizer.lheading(q)){q=q.substring(le.raw.length),Z.push(le);continue}if(se&&(le=this.tokenizer.paragraph(q))){q=q.substring(le.raw.length),Z.push(le);continue}if(le=this.tokenizer.text(q,Z)){q=q.substring(le.raw.length),le.type?Z.push(le):(Le=Z[Z.length-1],Le.raw+=`
|
|
`+le.raw,Le.text+=`
|
|
`+le.text);continue}if(q){var Me="Infinite loop on byte: "+q.charCodeAt(0);if(this.options.silent){console.error(Me);break}else throw new Error(Me)}}return Z},re.inline=function(q){var Z,se,le,pe,ye,Le,Me=q.length;for(Z=0;Z<Me;Z++){Le=q[Z];switch(Le.type){case"paragraph":case"text":case"heading":{Le.tokens=[],this.inlineTokens(Le.text,Le.tokens);break}case"table":{for(Le.tokens={header:[],cells:[]},pe=Le.header.length,se=0;se<pe;se++)Le.tokens.header[se]=[],this.inlineTokens(Le.header[se],Le.tokens.header[se]);for(pe=Le.cells.length,se=0;se<pe;se++)for(ye=Le.cells[se],Le.tokens.cells[se]=[],le=0;le<ye.length;le++)Le.tokens.cells[se][le]=[],this.inlineTokens(ye[le],Le.tokens.cells[se][le]);break}case"blockquote":{this.inline(Le.tokens);break}case"list":{for(pe=Le.items.length,se=0;se<pe;se++)this.inline(Le.items[se].tokens);break}}}return q},re.inlineTokens=function(q,Z,se,le,pe){Z===void 0&&(Z=[]),se===void 0&&(se=!1),le===void 0&&(le=!1),pe===void 0&&(pe="");var ye,Le=q,Me;if(this.tokens.links){var et=Object.keys(this.tokens.links);if(et.length>0)for(;(Me=this.tokenizer.rules.inline.reflinkSearch.exec(Le))!=null;)et.includes(Me[0].slice(Me[0].lastIndexOf("[")+1,-1))&&(Le=Le.slice(0,Me.index)+"["+"a".repeat(Me[0].length-2)+"]"+Le.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(Me=this.tokenizer.rules.inline.blockSkip.exec(Le))!=null;)Le=Le.slice(0,Me.index)+"["+"a".repeat(Me[0].length-2)+"]"+Le.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;q;){if(ye=this.tokenizer.escape(q)){q=q.substring(ye.raw.length),Z.push(ye);continue}if(ye=this.tokenizer.tag(q,se,le)){q=q.substring(ye.raw.length),se=ye.inLink,le=ye.inRawBlock,Z.push(ye);continue}if(ye=this.tokenizer.link(q)){q=q.substring(ye.raw.length),ye.type==="link"&&(ye.tokens=this.inlineTokens(ye.text,[],!0,le)),Z.push(ye);continue}if(ye=this.tokenizer.reflink(q,this.tokens.links)){q=q.substring(ye.raw.length),ye.type==="link"&&(ye.tokens=this.inlineTokens(ye.text,[],!0,le)),Z.push(ye);continue}if(ye=this.tokenizer.strong(q,Le,pe)){q=q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,le),Z.push(ye);continue}if(ye=this.tokenizer.em(q,Le,pe)){q=q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,le),Z.push(ye);continue}if(ye=this.tokenizer.codespan(q)){q=q.substring(ye.raw.length),Z.push(ye);continue}if(ye=this.tokenizer.br(q)){q=q.substring(ye.raw.length),Z.push(ye);continue}if(ye=this.tokenizer.del(q)){q=q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,le),Z.push(ye);continue}if(ye=this.tokenizer.autolink(q,de)){q=q.substring(ye.raw.length),Z.push(ye);continue}if(!se&&(ye=this.tokenizer.url(q,de))){q=q.substring(ye.raw.length),Z.push(ye);continue}if(ye=this.tokenizer.inlineText(q,le,U)){q=q.substring(ye.raw.length),pe=ye.raw.slice(-1),Z.push(ye);continue}if(q){var rt="Infinite loop on byte: "+q.charCodeAt(0);if(this.options.silent){console.error(rt);break}else throw new Error(rt)}}return Z},Q($,null,[{key:"rules",get:function(){return{block:H,inline:ee}}}]),$}(),_e=j.defaults,Ue=ie.cleanUrl,ke=ie.escape,Oe=function(){function $(oe){this.options=oe||_e}var re=$.prototype;return re.code=function(q,Z,se){var le=(Z||"").match(/\S*/)[0];if(this.options.highlight){var pe=this.options.highlight(q,le);pe!=null&&pe!==q&&(se=!0,q=pe)}return le?'<pre><code class="'+this.options.langPrefix+ke(le,!0)+'">'+(se?q:ke(q,!0))+`</code></pre>
|
|
`:"<pre><code>"+(se?q:ke(q,!0))+`</code></pre>
|
|
`},re.blockquote=function(q){return`<blockquote>
|
|
`+q+`</blockquote>
|
|
`},re.html=function(q){return q},re.heading=function(q,Z,se,le){return this.options.headerIds?"<h"+Z+' id="'+this.options.headerPrefix+le.slug(se)+'">'+q+"</h"+Z+`>
|
|
`:"<h"+Z+">"+q+"</h"+Z+`>
|
|
`},re.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},re.list=function(q,Z,se){var le=Z?"ol":"ul",pe=Z&&se!==1?' start="'+se+'"':"";return"<"+le+pe+`>
|
|
`+q+"</"+le+`>
|
|
`},re.listitem=function(q){return"<li>"+q+`</li>
|
|
`},re.checkbox=function(q){return"<input "+(q?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},re.paragraph=function(q){return"<p>"+q+`</p>
|
|
`},re.table=function(q,Z){return Z&&(Z="<tbody>"+Z+"</tbody>"),`<table>
|
|
<thead>
|
|
`+q+`</thead>
|
|
`+Z+`</table>
|
|
`},re.tablerow=function(q){return`<tr>
|
|
`+q+`</tr>
|
|
`},re.tablecell=function(q,Z){var se=Z.header?"th":"td",le=Z.align?"<"+se+' align="'+Z.align+'">':"<"+se+">";return le+q+"</"+se+`>
|
|
`},re.strong=function(q){return"<strong>"+q+"</strong>"},re.em=function(q){return"<em>"+q+"</em>"},re.codespan=function(q){return"<code>"+q+"</code>"},re.br=function(){return this.options.xhtml?"<br/>":"<br>"},re.del=function(q){return"<del>"+q+"</del>"},re.link=function(q,Z,se){if(q=Ue(this.options.sanitize,this.options.baseUrl,q),q===null)return se;var le='<a href="'+ke(q)+'"';return Z&&(le+=' title="'+Z+'"'),le+=">"+se+"</a>",le},re.image=function(q,Z,se){if(q=Ue(this.options.sanitize,this.options.baseUrl,q),q===null)return se;var le='<img src="'+q+'" alt="'+se+'"';return Z&&(le+=' title="'+Z+'"'),le+=this.options.xhtml?"/>":">",le},re.text=function(q){return q},$}(),Pe=function(){function $(){}var re=$.prototype;return re.strong=function(q){return q},re.em=function(q){return q},re.codespan=function(q){return q},re.del=function(q){return q},re.html=function(q){return q},re.text=function(q){return q},re.link=function(q,Z,se){return""+se},re.image=function(q,Z,se){return""+se},re.br=function(){return""},$}(),Xe=function(){function $(){this.seen={}}var re=$.prototype;return re.slug=function(q){var Z=q.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(Z)){var se=Z;do this.seen[se]++,Z=se+"-"+this.seen[se];while(this.seen.hasOwnProperty(Z))}return this.seen[Z]=0,Z},$}(),Fe=j.defaults,Ne=ie.unescape,We=function(){function $(oe){this.options=oe||Fe,this.options.renderer=this.options.renderer||new Oe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Pe,this.slugger=new Xe}$.parse=function(q,Z){var se=new $(Z);return se.parse(q)};var re=$.prototype;return re.parse=function(q,Z){Z===void 0&&(Z=!0);var se="",le,pe,ye,Le,Me,et,rt,Tt,ot,Ve,vt,st,Lt,St,yt,rr,Wt,Ht,Ut=q.length;for(le=0;le<Ut;le++){Ve=q[le];switch(Ve.type){case"space":continue;case"hr":{se+=this.renderer.hr();continue}case"heading":{se+=this.renderer.heading(this.parseInline(Ve.tokens),Ve.depth,Ne(this.parseInline(Ve.tokens,this.textRenderer)),this.slugger);continue}case"code":{se+=this.renderer.code(Ve.text,Ve.lang,Ve.escaped);continue}case"table":{for(Tt="",rt="",Le=Ve.header.length,pe=0;pe<Le;pe++)rt+=this.renderer.tablecell(this.parseInline(Ve.tokens.header[pe]),{header:!0,align:Ve.align[pe]});for(Tt+=this.renderer.tablerow(rt),ot="",Le=Ve.cells.length,pe=0;pe<Le;pe++){for(et=Ve.tokens.cells[pe],rt="",Me=et.length,ye=0;ye<Me;ye++)rt+=this.renderer.tablecell(this.parseInline(et[ye]),{header:!1,align:Ve.align[ye]});ot+=this.renderer.tablerow(rt)}se+=this.renderer.table(Tt,ot);continue}case"blockquote":{ot=this.parse(Ve.tokens),se+=this.renderer.blockquote(ot);continue}case"list":{for(vt=Ve.ordered,st=Ve.start,Lt=Ve.loose,Le=Ve.items.length,ot="",pe=0;pe<Le;pe++)yt=Ve.items[pe],rr=yt.checked,Wt=yt.task,St="",yt.task&&(Ht=this.renderer.checkbox(rr),Lt?yt.tokens.length>0&&yt.tokens[0].type==="text"?(yt.tokens[0].text=Ht+" "+yt.tokens[0].text,yt.tokens[0].tokens&&yt.tokens[0].tokens.length>0&&yt.tokens[0].tokens[0].type==="text"&&(yt.tokens[0].tokens[0].text=Ht+" "+yt.tokens[0].tokens[0].text)):yt.tokens.unshift({type:"text",text:Ht}):St+=Ht),St+=this.parse(yt.tokens,Lt),ot+=this.renderer.listitem(St,Wt,rr);se+=this.renderer.list(ot,vt,st);continue}case"html":{se+=this.renderer.html(Ve.text);continue}case"paragraph":{se+=this.renderer.paragraph(this.parseInline(Ve.tokens));continue}case"text":{for(ot=Ve.tokens?this.parseInline(Ve.tokens):Ve.text;le+1<Ut&&q[le+1].type==="text";)Ve=q[++le],ot+=`
|
|
`+(Ve.tokens?this.parseInline(Ve.tokens):Ve.text);se+=Z?this.renderer.paragraph(ot):ot;continue}default:{var or='Token with "'+Ve.type+'" type was not found.';if(this.options.silent){console.error(or);return}else throw new Error(or)}}}return se},re.parseInline=function(q,Z){Z=Z||this.renderer;var se="",le,pe,ye=q.length;for(le=0;le<ye;le++){pe=q[le];switch(pe.type){case"escape":{se+=Z.text(pe.text);break}case"html":{se+=Z.html(pe.text);break}case"link":{se+=Z.link(pe.href,pe.title,this.parseInline(pe.tokens,Z));break}case"image":{se+=Z.image(pe.href,pe.title,pe.text);break}case"strong":{se+=Z.strong(this.parseInline(pe.tokens,Z));break}case"em":{se+=Z.em(this.parseInline(pe.tokens,Z));break}case"codespan":{se+=Z.codespan(pe.text);break}case"br":{se+=Z.br();break}case"del":{se+=Z.del(this.parseInline(pe.tokens,Z));break}case"text":{se+=Z.text(pe.text);break}default:{var Le='Token with "'+pe.type+'" type was not found.';if(this.options.silent){console.error(Le);return}else throw new Error(Le)}}}return se},$}(),Ze=ie.merge,He=ie.checkSanitizeDeprecation,Ye=ie.escape,Ce=j.getDefaults,$e=j.changeDefaults,qe=j.defaults;function ae($,re,oe){if(typeof $=="undefined"||$===null)throw new Error("marked(): input parameter is undefined or null");if(typeof $!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call($)+", string expected");if(typeof re=="function"&&(oe=re,re=null),re=Ze({},ae.defaults,re||{}),He(re),oe){var q=re.highlight,Z;try{Z=Ee.lex($,re)}catch(ye){return oe(ye)}var se=function(Le){var Me;if(!Le)try{Me=We.parse(Z,re)}catch(et){Le=et}return re.highlight=q,Le?oe(Le):oe(null,Me)};if(!q||q.length<3)return se();if(delete re.highlight,!Z.length)return se();var le=0;ae.walkTokens(Z,function(ye){ye.type==="code"&&(le++,setTimeout(function(){q(ye.text,ye.lang,function(Le,Me){if(Le)return se(Le);Me!=null&&Me!==ye.text&&(ye.text=Me,ye.escaped=!0),le--,le===0&&se()})},0))}),le===0&&se();return}try{var pe=Ee.lex($,re);return re.walkTokens&&ae.walkTokens(pe,re.walkTokens),We.parse(pe,re)}catch(ye){if(ye.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,re.silent)return"<p>An error occurred:</p><pre>"+Ye(ye.message+"",!0)+"</pre>";throw ye}}ae.options=ae.setOptions=function($){return Ze(ae.defaults,$),$e(ae.defaults),ae},ae.getDefaults=Ce,ae.defaults=qe,ae.use=function($){var re=Ze({},$);if($.renderer&&function(){var q=ae.defaults.renderer||new Oe,Z=function(pe){var ye=q[pe];q[pe]=function(){for(var Le=arguments.length,Me=new Array(Le),et=0;et<Le;et++)Me[et]=arguments[et];var rt=$.renderer[pe].apply(q,Me);return rt===!1&&(rt=ye.apply(q,Me)),rt}};for(var se in $.renderer)Z(se);re.renderer=q}(),$.tokenizer&&function(){var q=ae.defaults.tokenizer||new Te,Z=function(pe){var ye=q[pe];q[pe]=function(){for(var Le=arguments.length,Me=new Array(Le),et=0;et<Le;et++)Me[et]=arguments[et];var rt=$.tokenizer[pe].apply(q,Me);return rt===!1&&(rt=ye.apply(q,Me)),rt}};for(var se in $.tokenizer)Z(se);re.tokenizer=q}(),$.walkTokens){var oe=ae.defaults.walkTokens;re.walkTokens=function(q){$.walkTokens(q),oe&&oe(q)}}ae.setOptions(re)},ae.walkTokens=function($,re){for(var oe=I($),q;!(q=oe()).done;){var Z=q.value;re(Z);switch(Z.type){case"table":{for(var se=I(Z.tokens.header),le;!(le=se()).done;){var pe=le.value;ae.walkTokens(pe,re)}for(var ye=I(Z.tokens.cells),Le;!(Le=ye()).done;)for(var Me=Le.value,et=I(Me),rt;!(rt=et()).done;){var Tt=rt.value;ae.walkTokens(Tt,re)}break}case"list":{ae.walkTokens(Z.items,re);break}default:Z.tokens&&ae.walkTokens(Z.tokens,re)}}},ae.Parser=We,ae.parser=We.parse,ae.Renderer=Oe,ae.TextRenderer=Pe,ae.Lexer=Ee,ae.lexer=Ee.lex,ae.Tokenizer=Te,ae.Slugger=Xe,ae.parse=ae;var J=ae;return J})},ELLl:function(gt,at,ue){(function(fe){fe(ue("VrN/"))})(function(fe){var Q={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},D=fe.Pos;fe.defineOption("autoCloseBrackets",!1,function(S,C,d){d&&d!=fe.Init&&(S.removeKeyMap(I),S.state.closeBrackets=null),C&&(y(V(C,"pairs")),S.state.closeBrackets=C,S.addKeyMap(I))});function V(S,C){return C=="pairs"&&typeof S=="string"?S:typeof S=="object"&&S[C]!=null?S[C]:Q[C]}var I={Backspace:M,Enter:R};function y(S){for(var C=0;C<S.length;C++){var d=S.charAt(C),o="'"+d+"'";I[o]||(I[o]=j(d))}}y(Q.pairs+"`");function j(S){return function(C){return w(C,S)}}function B(S){var C=S.state.closeBrackets;if(!C||C.override)return C;var d=S.getModeAt(S.getCursor());return d.closeBrackets||C}function M(S){var C=B(S);if(!C||S.getOption("disableInput"))return fe.Pass;for(var d=V(C,"pairs"),o=S.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return fe.Pass;var u=O(S,o[s].head);if(!u||d.indexOf(u)%2!=0)return fe.Pass}for(var s=o.length-1;s>=0;s--){var T=o[s].head;S.replaceRange("",D(T.line,T.ch-1),D(T.line,T.ch+1),"+delete")}}function R(S){var C=B(S),d=C&&V(C,"explode");if(!d||S.getOption("disableInput"))return fe.Pass;for(var o=S.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return fe.Pass;var u=O(S,o[s].head);if(!u||d.indexOf(u)%2!=0)return fe.Pass}S.operation(function(){var T=S.lineSeparator()||`
|
|
`;S.replaceSelection(T+T,null),S.execCommand("goCharLeft"),o=S.listSelections();for(var m=0;m<o.length;m++){var p=o[m].head.line;S.indentLine(p,null,!0),S.indentLine(p+1,null,!0)}})}function b(S){var C=fe.cmpPos(S.anchor,S.head)>0;return{anchor:new D(S.anchor.line,S.anchor.ch+(C?-1:1)),head:new D(S.head.line,S.head.ch+(C?1:-1))}}function w(S,C){var d=B(S);if(!d||S.getOption("disableInput"))return fe.Pass;var o=V(d,"pairs"),s=o.indexOf(C);if(s==-1)return fe.Pass;for(var u=V(d,"closeBefore"),T=V(d,"triples"),m=o.charAt(s+1)==C,p=S.listSelections(),_=s%2==0,v,c=0;c<p.length;c++){var h=p[c],l=h.head,a,g=S.getRange(l,D(l.line,l.ch+1));if(_&&!h.empty())a="surround";else if((m||!_)&&g==C)m&&A(S,l)?a="both":T.indexOf(C)>=0&&S.getRange(l,D(l.line,l.ch+3))==C+C+C?a="skipThree":a="skip";else if(m&&l.ch>1&&T.indexOf(C)>=0&&S.getRange(D(l.line,l.ch-2),l)==C+C){if(l.ch>2&&/\bstring/.test(S.getTokenTypeAt(D(l.line,l.ch-2))))return fe.Pass;a="addFour"}else if(m){var f=l.ch==0?" ":S.getRange(D(l.line,l.ch-1),l);if(!fe.isWordChar(g)&&f!=C&&!fe.isWordChar(f))a="both";else return fe.Pass}else if(_&&(g.length===0||/\s/.test(g)||u.indexOf(g)>-1))a="both";else return fe.Pass;if(!v)v=a;else if(v!=a)return fe.Pass}var x=s%2?o.charAt(s-1):C,P=s%2?C:o.charAt(s+1);S.operation(function(){if(v=="skip")S.execCommand("goCharRight");else if(v=="skipThree")for(var G=0;G<3;G++)S.execCommand("goCharRight");else if(v=="surround"){for(var X=S.getSelections(),G=0;G<X.length;G++)X[G]=x+X[G]+P;S.replaceSelections(X,"around"),X=S.listSelections().slice();for(var G=0;G<X.length;G++)X[G]=b(X[G]);S.setSelections(X)}else v=="both"?(S.replaceSelection(x+P,null),S.triggerElectric(x+P),S.execCommand("goCharLeft")):v=="addFour"&&(S.replaceSelection(x+x+x+x,"before"),S.execCommand("goCharRight"))})}function O(S,C){var d=S.getRange(D(C.line,C.ch-1),D(C.line,C.ch+1));return d.length==2?d:null}function A(S,C){var d=S.getTokenAt(D(C.line,C.ch+1));return/\bstring/.test(d.type)&&d.start==C.ch&&(C.ch==0||!/\bstring/.test(S.getTokenTypeAt(C)))}})},G8my:function(gt,at,ue){gt.exports={flex:"flex___1FMOA"}},HmJG:function(gt,at,ue){},JkjM:function(gt,at,ue){"use strict";ue.r(at);var fe=ue("9og8"),Q=ue("PpiC"),D=ue("WmNS"),V=ue.n(D),I=ue("q1tI"),y=ue.n(I),j=ue("Ty5D"),B=ue("9kvl"),M=ue("14J3"),R=ue("BMrR"),b=ue("jCWc"),w=ue("kPKH"),O=ue("+L6B"),A=ue("2/Rp"),S=ue("k1fw"),C=ue("m3rI"),d=ue("LO5M"),o=ue.n(d),s=ue("h+Ho"),u=function(Ne){var We,Ze,He,Ye,Ce=Ne.user,$e=Ne.forumsDetail,qe=Ne.globalSetting,ae=Ne.loading,J=Ne.dispatch,$=Object(Q.a)(Ne,["user","forumsDetail","globalSetting","loading","dispatch"]),re=$e.forumsDetailData||{},oe=re.author_info,q=re.memo,Z=re.recommend_shixuns,se=function(){var le=Object(fe.a)(V.a.mark(function pe(){var ye;return V.a.wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:if(!(oe!=null&&oe.watched)){Me.next=6;break}return Me.next=3,Object(s.a)({user_id:oe.user_id});case 3:Me.t0=Me.sent,Me.next=9;break;case 6:return Me.next=8,Object(s.o)({user_id:oe.user_id});case 8:Me.t0=Me.sent;case 9:ye=Me.t0,ye&&J({type:"forumsDetail/setForumsDetailData",payload:Object(S.a)(Object(S.a)({},$e.forumsDetailData),{},{author_info:Object(S.a)(Object(S.a)({},oe),{},{watched:!(oe!=null&&oe.watched)})})});case 11:case"end":return Me.stop()}},pe)}));return function(){return le.apply(this,arguments)}}();return y.a.createElement("section",{className:o.a.wrap},y.a.createElement("aside",{className:"ml20"},y.a.createElement("div",{className:"bg-white pt40 pb40 pl20 pr20 ".concat(o.a.head)},y.a.createElement("a",{href:"/users/".concat(oe==null?void 0:oe.login),target:"_blank"},(oe==null?void 0:oe.image_url)&&y.a.createElement("img",{src:"".concat(C.a.API_SERVER,"/images/").concat(oe==null?void 0:oe.image_url)})),y.a.createElement("div",{className:"tc font20"},oe==null?void 0:oe.username),y.a.createElement("div",{className:"tc c-grey-999"},oe==null?void 0:oe.identity),((We=Ce.userInfo)===null||We===void 0?void 0:We.user_id)!==(oe==null?void 0:oe.user_id)&&y.a.createElement(R.a,{justify:"center",className:"mt30 ".concat(o.a.buttonWrap)},y.a.createElement(w.a,null,y.a.createElement(A.a,{type:"primary",className:"mr10",onClick:se},oe!=null&&oe.watched?"\u53D6\u6D88\u5173\u6CE8":"\u5173\u6CE8")),y.a.createElement(w.a,null,y.a.createElement(A.a,{ghost:!0,className:o.a.privateMessage,href:"/messages/".concat((Ze=Ce.userInfo)===null||Ze===void 0?void 0:Ze.login,"/message_detail?target_ids=").concat(oe==null?void 0:oe.user_id),target:"_blank"},"\u79C1\u4FE1")))),!!(q!=null&&(He=q.tag)!==null&&He!==void 0&&He.length)&&y.a.createElement("div",{className:"bg-white mt10 pt40 pb40 pl20 pr20"},y.a.createElement("div",{className:"font16"},"\u8BDD\u9898\u6807\u7B7E"),y.a.createElement("div",{className:"mt30 ".concat(o.a.tag)},q==null||((Ye=q.tag)===null||Ye===void 0)?void 0:Ye.map(function(le){return y.a.createElement("a",null,le==null?void 0:le.name)}))),y.a.createElement("div",{className:"pt10 pb10 pl10 pr10"},y.a.createElement("div",{className:"font16 mb20"},"\u63A8\u8350\u5B9E\u8BAD"),y.a.createElement("div",{className:o.a.recommend},Z==null?void 0:Z.map(function(le){return y.a.createElement("div",{className:o.a.recommendItem},y.a.createElement("a",{href:"/shixuns/".concat(le.identifier,"/challenges"),target:"_blank"},y.a.createElement("img",{alt:le.id,src:"".concat(C.a.API_SERVER,"/").concat(le.image_url)})),y.a.createElement("div",{className:"".concat(o.a.flex1," ml10")},y.a.createElement("a",{href:"/shixuns/".concat(le.identifier,"/challenges"),target:"_blank",title:le.name,className:"".concat(o.a.mWidth147," multi-llipsis1e c-grey-666 mb10")},le.name),y.a.createElement("div",{className:"c-grey-999"},le.myshixuns_count," \u4EBA\u5B66\u4E60")))})))))},T=Object(B.a)(function(Fe){var Ne=Fe.user,We=Fe.forumsDetail,Ze=Fe.loading,He=Fe.globalSetting;return{user:Ne,forumsDetail:We,globalSetting:He,loading:Ze.models.forumsDetail}})(u),m=ue("qVdP"),p=ue("jsC+"),_=ue("5Dmo"),v=ue("3S7+"),c=ue("sPJy"),h=ue("bE4q"),l=ue("lUTK"),a=ue("BvKs"),g=ue("5NDa"),f=ue("5rEg"),x=ue("2qtc"),P=ue("kLXV"),G=ue("miYZ"),X=ue("tsqr"),ie=ue("55Ip"),z=ue("wd/R"),F=ue.n(z),ne=ue("9Bee"),ce=ue("oBTY"),ge=ue("tJVT"),be=ue("Ot1p"),Ie=ue("/MfK"),Te=ue("8JLL"),De=ue.n(Te);F.a.lang("ZH-cn");function we(Fe){var Ne=Fe.user,We=Fe.vlist,Ze=We===void 0?[]:We,He=Fe.dispatch,Ye=Fe.params,Ce=Fe.id,$e=Fe.memo_replies,qe=Fe.forumsDetail;return y.a.createElement("aside",{className:De.a.comment},Ze.map(function(ae,J){var $,re;return y.a.createElement(R.a,{key:J,className:De.a.commentItem},y.a.createElement(w.a,{span:24},y.a.createElement(R.a,null,y.a.createElement(w.a,{flex:"1"},y.a.createElement("a",{href:"/users/".concat(ae.user_login),target:"_blank",className:"c-light-black"},ae==null?void 0:ae.username),y.a.createElement("span",{className:"c-light-black ml10"},ae.time)),(ae.can_delete||ae.user_id===(($=Ne.userInfo)===null||$===void 0?void 0:$.user_id)||ae.user_login===((re=Ne.userInfo)===null||re===void 0?void 0:re.login))&&y.a.createElement(w.a,{className:"forums-comment-delete",style:{display:"none"}},y.a.createElement(v.a,{title:"\u5220\u9664"},y.a.createElement(Ie.a,{className:"current",onClick:function(){P.a.confirm({centered:!0,width:530,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u63D0\u793A",content:y.a.createElement("div",{className:"font16 tc"},"\u786E\u5B9A\u8981\u5220\u9664\u8BE5\u6761\u56DE\u590D\u5417\uFF1F"),onOk:function(){var q=Object(fe.a)(V.a.mark(function se(){var le,pe;return V.a.wrap(function(Le){for(;;)switch(Le.prev=Le.next){case 0:return Le.next=2,Object(s.b)({id:ae.id});case 2:le=Le.sent,pe=$e.find(function(Me){return Me.id===Ce}).children.filter(function(Me){return Me.id!==ae.id}),$e.find(function(Me){return Me.id===Ce}).children=pe,He({type:"forumsDetail/setForumsDetailData",payload:Object(S.a)(Object(S.a)({},qe.forumsDetailData),{},{memo_replies:Object(ce.a)($e)})});case 6:case"end":return Le.stop()}},se)}));function Z(){return q.apply(this,arguments)}return Z}()})}}))))),y.a.createElement(w.a,null,y.a.createElement(ne.a,{value:ae.content})))}))}var Ae=we,ve=ue("1vsH");F.a.lang("ZH-cn");var W=function(Ne,We){var Ze=Ne.user,He=Ne.forumsDetail,Ye=Ne.globalSetting,Ce=Ne.loading,$e=Ne.dispatch,qe=Ne.handleClick,ae=Object(Q.a)(Ne,["user","forumsDetail","globalSetting","loading","dispatch","handleClick"]),J=He.forumsDetailData||{},$=J.memo,re=J.memo_replies,oe=Object(j.i)(),q=Object(I.useState)(""),Z=Object(ge.a)(q,2),se=Z[0],le=Z[1],pe=Object(I.useState)(""),ye=Object(ge.a)(pe,2),Le=ye[0],Me=ye[1],et=Object(I.useState)(-1),rt=Object(ge.a)(et,2),Tt=rt[0],ot=rt[1],Ve=Object(I.useState)(!1),vt=Object(ge.a)(Ve,2),st=vt[0],Lt=vt[1],St=Object(I.useState)(1),yt=Object(ge.a)(St,2),rr=yt[0],Wt=yt[1],Ht=Object(I.useState)(!1),Ut=Object(ge.a)(Ht,2),or=Ut[0],wr=Ut[1];Object(I.useImperativeHandle)(We,function(){return{onMdFouch:Br}}),Object(I.useEffect)(function(){Lt(($==null?void 0:$.replies_count)>10)},[$==null?void 0:$.replies_count]);var Vt=function(){var ut=Object(fe.a)(V.a.mark(function Ke(){var xt,Ct,nt;return V.a.wrap(function(pt){for(;;)switch(pt.prev=pt.next){case 0:return xt=rr+1,Wt(xt),pt.next=4,Object(s.h)({id:oe.memoId,page:xt});case 4:Ct=pt.sent,Ct!=null&&Ct.memo_replies&&($e({type:"forumsDetail/setForumsDetailData",payload:Object(S.a)(Object(S.a)({},He.forumsDetailData),{},{memo_replies:[].concat(Object(ce.a)(re),Object(ce.a)(Ct.memo_replies))})}),Lt(((nt=Ct.memo_replies)===null||nt===void 0?void 0:nt.length)===10));case 6:case"end":return pt.stop()}},Ke)}));return function(){return ut.apply(this,arguments)}}(),Sr=function(Ke){var xt,Ct,nt,ft;return Object(S.a)(Object(S.a)({},Ke),{},{image_url:(xt=Ze.userInfo)===null||xt===void 0?void 0:xt.image_url,children:[],user_id:(Ct=Ze.userInfo)===null||Ct===void 0?void 0:Ct.user_id,user_login:(nt=Ze.userInfo)===null||nt===void 0?void 0:nt.login,username:(ft=Ze.userInfo)===null||ft===void 0?void 0:ft.username,time:"".concat(Object(ve.cb)((new Date().getTime()-new Date(Ke.created_at).getTime())/1e3),"\u524D")})},Br=function(){wr(!0)};return y.a.createElement("section",{className:De.a.wrap},!!(re!=null&&re.length)&&y.a.createElement("aside",{className:De.a.content},y.a.createElement("div",{style:{padding:"10px 15px 5px 15px",justifyContent:"space-between",display:"flex"}},y.a.createElement("span",null,"\u5168\u90E8\u56DE\u590D\uFF08",$.replies_count,"\uFF09")),y.a.createElement("aside",{className:De.a.replyList},re==null?void 0:re.map(function(ut,Ke){var xt;return y.a.createElement(R.a,{gutter:[12,12],key:Ke},y.a.createElement(w.a,{flex:"40px"},y.a.createElement("a",{href:"/users/".concat(ut.user_login),target:"_blank"},y.a.createElement("img",{alt:"\u7528\u6237\u5934\u50CF",width:"50",height:"50",src:"".concat(C.a.IMG_SERVER,"/images/").concat(ut==null?void 0:ut.image_url)}))),y.a.createElement(w.a,{flex:"1"},y.a.createElement(R.a,{align:"middle"},y.a.createElement(w.a,{span:24},y.a.createElement("a",{href:"/users/".concat(ut.user_login),target:"_blank"},y.a.createElement("span",{className:"c-light-black"},ut==null?void 0:ut.username)),y.a.createElement("span",{className:"c-light-black ml10"},ut.time)),y.a.createElement(w.a,{span:24},y.a.createElement("div",{onClick:qe},y.a.createElement(ne.a,{value:ut.content}))),!!(ut!=null&&(xt=ut.children)!==null&&xt!==void 0&&xt.length)&&y.a.createElement(Ae,{user:Ze,id:ut==null?void 0:ut.id,vlist:ut==null?void 0:ut.children,dispatch:$e,params:oe,memo_replies:re,forumsDetail:He}),y.a.createElement(w.a,{span:24,className:"mt5 c-light-black"},Tt===Ke?y.a.createElement("aside",null,y.a.createElement(be.a,{onChange:function(nt){Me(nt)},height:150,isFocus:!0,placeholder:"\u6211\u8981\u56DE\u590D..."}),y.a.createElement(R.a,null,y.a.createElement(w.a,{span:24,className:"tr"},y.a.createElement(A.a,{type:"primary",size:"large",onClick:Object(fe.a)(V.a.mark(function Ct(){var nt;return V.a.wrap(function(pt){for(;;)switch(pt.prev=pt.next){case 0:if(!(Le==="")){pt.next=4;break}X.b.error("\u8BF7\u8F93\u5165\u5185\u5BB9"),pt.next=9;break;case 4:return pt.next=6,Object(s.k)({parent_id:ut.id,content:Le});case 6:nt=pt.sent,Me(null),nt&&(ot(-1),re.find(function($t){return $t.id===nt.parent_id}).children.push(Sr(nt)),$e({type:"forumsDetail/setForumsDetailData",payload:Object(S.a)(Object(S.a)({},He.forumsDetailData),{},{memo:Object(S.a)(Object(S.a)({},$),{},{replies_count:$.replies_count+1}),memo_replies:Object(ce.a)(re)})}));case 9:case"end":return pt.stop()}},Ct)}))},"\u53D1\u9001")))):y.a.createElement("div",{className:"tr"},y.a.createElement("span",{className:"iconfont icon-huifu1 mr15 ml30 current",onClick:function(){return ot(Ke)}}),y.a.createElement(v.a,{title:ut.user_praise?"\u53D6\u6D88\u70B9\u8D5E":"\u70B9\u8D5E"},y.a.createElement("span",{className:ut.user_praise?"c-orange":"c-gery-888"},y.a.createElement("i",{className:"iconfont icon-dianzan mr3 current",onClick:Object(fe.a)(V.a.mark(function Ct(){var nt;return V.a.wrap(function(pt){for(;;)switch(pt.prev=pt.next){case 0:return pt.next=2,Object(s.i)({id:ut.id,container_type:"Memo",type:ut.user_praise?0:1});case 2:nt=pt.sent,(nt==null?void 0:nt.praise_count)>=0&&(re.find(function($t){return $t.id===ut.id}).user_praise=!ut.user_praise,re.find(function($t){return $t.id===ut.id}).praise_count=nt==null?void 0:nt.praise_count,$e({type:"forumsDetail/setForumsDetailData",payload:Object(S.a)(Object(S.a)({},He.forumsDetailData),{},{memo_replies:Object(ce.a)(re)})}));case 4:case"end":return pt.stop()}},Ct)}))}),ut.praise_count>0?ut.praise_count:"")))))))}))),st&&y.a.createElement("aside",{className:"bg-white pb20",style:{display:"flex",justifyContent:"center"}},y.a.createElement(R.a,{justify:"space-between"},y.a.createElement(w.a,null),y.a.createElement(w.a,null,st&&y.a.createElement("a",{className:"c-black",onClick:Vt},"\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA")))),y.a.createElement("aside",{className:De.a.reply},y.a.createElement(be.a,{onBlur:function(){return wr(!1)},isFocus:or,defaultValue:se,id:"writeForumsReviewId",onChange:function(Ke){le(Ke)},placeholder:"\u6211\u8981\u56DE\u590D...",height:240}),y.a.createElement(R.a,null,y.a.createElement(w.a,{flex:"1"}),y.a.createElement(w.a,null,y.a.createElement(A.a,{type:"primary",size:"large",onClick:Object(fe.a)(V.a.mark(function ut(){var Ke;return V.a.wrap(function(Ct){for(;;)switch(Ct.prev=Ct.next){case 0:if(!(se==="")){Ct.next=4;break}X.b.error("\u8BF7\u8F93\u5165\u5185\u5BB9"),Ct.next=9;break;case 4:return Ct.next=6,Object(s.k)({parent_id:$.id,content:se});case 6:Ke=Ct.sent,le(null),Ke&&$e({type:"forumsDetail/setForumsDetailData",payload:Object(S.a)(Object(S.a)({},He.forumsDetailData),{},{memo:Object(S.a)(Object(S.a)({},$),{},{replies_count:$.replies_count+1}),memo_replies:[Sr(Ke)].concat(Object(ce.a)(re))})});case 9:case"end":return Ct.stop()}},ut)}))},"\u53D1\u9001")))))},L=Object(B.a)(function(Fe){var Ne=Fe.user,We=Fe.forumsDetail,Ze=Fe.loading,He=Fe.globalSetting;return{user:Ne,forumsDetail:We,globalSetting:He,loading:Ze.models.forumsDetail}},null,null,{forwardRef:!0})(Object(I.forwardRef)(W)),k=ue("smFo"),H=ue.n(k),ee=ue("RCxd"),U=ue("kaH+"),de=ue("dhSg"),Ee={5:"\u6280\u672F\u5206\u4EAB",3:"\u64CD\u4F5C\u6307\u5357",16:"\u901A\u77E5\u516C\u544A"},_e=function(Ne){var We,Ze,He,Ye,Ce,$e=Ne.user,qe=Ne.forumsDetail,ae=Ne.globalSetting,J=Ne.loading,$=Ne.dispatch,re=Object(Q.a)(Ne,["user","forumsDetail","globalSetting","loading","dispatch"]),oe=qe.forumsDetailData||{},q=oe.author_info,Z=oe.memo,se=oe.attachments_list,le=Object(I.useRef)(),pe=Object(I.useRef)(),ye=function(){var Ve=Object(fe.a)(V.a.mark(function vt(){var st,Lt;return V.a.wrap(function(yt){for(;;)switch(yt.prev=yt.next){case 0:return st={id:Z.id,sticky:Z.sticky?0:1},yt.next=3,Object(s.m)(st);case 3:Lt=yt.sent,(Lt==null?void 0:Lt.status)===0&&$({type:"forumsDetail/setForumsDetailData",payload:Object(S.a)(Object(S.a)({},qe.forumsDetailData),{},{memo:Object(S.a)(Object(S.a)({},Z),{},{sticky:!(Z!=null&&Z.sticky)})})});case 5:case"end":return yt.stop()}},vt)}));return function(){return Ve.apply(this,arguments)}}(),Le=function(){var Ve=Object(fe.a)(V.a.mark(function vt(){var st;return V.a.wrap(function(St){for(;;)switch(St.prev=St.next){case 0:return St.next=2,Object(s.b)({id:Z==null?void 0:Z.id});case 2:st=St.sent,(st==null?void 0:st.status)===0&&(X.b.success("\u5220\u9664\u6210\u529F"),B.d.push("/forums")),(st==null?void 0:st.status)===-1&&B.d.push("/forums");case 5:case"end":return St.stop()}},vt)}));return function(){return Ve.apply(this,arguments)}}(),Me=function(){var Ve=Object(fe.a)(V.a.mark(function vt(){return V.a.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:P.a.confirm({centered:!0,width:530,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u5956\u52B1\u8BBE\u7F6E",content:y.a.createElement("div",{className:"font14 tc"},y.a.createElement(f.a,{defaultValue:le.current,onChange:function(yt){return le.current=yt.target.value}})),onOk:function(){var St=Object(fe.a)(V.a.mark(function rr(){var Wt;return V.a.wrap(function(Ut){for(;;)switch(Ut.prev=Ut.next){case 0:return Ut.next=2,Object(s.l)({id:Z==null?void 0:Z.id,container_type:"Memo",score:le.current?Number(le.current):0,user_id:q==null?void 0:q.user_id});case 2:if(Wt=Ut.sent,le.current=null,!((Wt==null?void 0:Wt.code)>0)){Ut.next=8;break}return $({type:"forumsDetail/setForumsDetailData",payload:Object(S.a)(Object(S.a)({},qe.forumsDetailData),{},{memo:Object(S.a)(Object(S.a)({},Z),{},{reward:Wt==null?void 0:Wt.code})})}),X.b.success("\u5956\u52B1\u6210\u529F"),Ut.abrupt("return");case 8:X.b.success("\u5956\u52B1\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\uFF01");case 9:case"end":return Ut.stop()}},rr)}));function yt(){return St.apply(this,arguments)}return yt}()});case 1:case"end":return Lt.stop()}},vt)}));return function(){return Ve.apply(this,arguments)}}(),et=function(){pe.current.onMdFouch&&pe.current.onMdFouch()},rt=function(){var Ve=Object(fe.a)(V.a.mark(function vt(){var st;return V.a.wrap(function(St){for(;;)switch(St.prev=St.next){case 0:return St.next=2,Object(s.i)({id:Z.id,container_type:"Memo",type:1});case 2:st=St.sent,(st==null?void 0:st.praise_count)>=0&&$({type:"forumsDetail/setForumsDetailData",payload:Object(S.a)(Object(S.a)({},qe.forumsDetailData),{},{memo:Object(S.a)(Object(S.a)({},Z),{},{user_praise:!(Z!=null&&Z.user_praise),memo_praise_count:st==null?void 0:st.praise_count})})});case 4:case"end":return St.stop()}},vt)}));return function(){return Ve.apply(this,arguments)}}(),Tt=y.a.createElement(a.a,{className:H.a.menu},((We=$e.userInfo)===null||We===void 0?void 0:We.admin)&&(Z==null?void 0:Z.sticky)&&y.a.createElement(a.a.Item,null,y.a.createElement("a",{onClick:function(){return ye()}},"\u53D6\u6D88\u7F6E\u9876")),((Ze=$e.userInfo)===null||Ze===void 0?void 0:Ze.admin)&&!(Z!=null&&Z.sticky)&&y.a.createElement(a.a.Item,null,y.a.createElement("a",{onClick:function(){return ye()}},"\u7F6E\xA0\xA0\u9876")),y.a.createElement(a.a.Item,null,y.a.createElement(ie.a,{to:"/forums/".concat(Z==null?void 0:Z.id,"/edit")},"\u7F16\xA0\xA0\u8F91")),y.a.createElement(a.a.Item,null,y.a.createElement("a",{onClick:function(){P.a.confirm({title:"\u63D0\u793A",icon:y.a.createElement(ee.a,null),content:"\u5E16\u5B50\u5C06\u88AB\u5220\u9664\uFF0C\u65E0\u6CD5\u6062\u590D\u3002\u662F\u5426\u786E\u8BA4\u5220\u9664\uFF1F",okText:"\u786E\u8BA4",onOk:function(){Le()},cancelText:"\u53D6\u6D88"})}},"\u5220\xA0\xA0\u9664"))),ot=function(vt){var st=vt.target,Lt=st.nodeName,St=st.src;Lt==="IMG"&&(de.a.publish("preview-image",St),console.log("src:",St))};return Object(I.useEffect)(function(){},[]),y.a.createElement("section",{className:H.a.wrap},y.a.createElement(h.a,{separator:"/",className:"mb5"},y.a.createElement(h.a.Item,null,y.a.createElement(ie.a,{to:"/forums/categories/".concat(Z==null?void 0:Z.forum_id)},Ee[Z==null?void 0:Z.forum_id])),y.a.createElement(h.a.Item,null,"\u8BE6\u60C5")),y.a.createElement("header",{className:"bg-white pt40 pb40 pl30 pr30 ".concat(H.a.header)},y.a.createElement(R.a,{align:"middle"},y.a.createElement(w.a,{flex:1,className:"font24 mb5"},y.a.createElement("span",{className:H.a.title},Z==null?void 0:Z.subject),(Z==null?void 0:Z.sticky)&&y.a.createElement("span",{className:H.a.top},"\u7F6E\u9876"),!!(Z!=null&&Z.reward)&&y.a.createElement(v.a,{placement:"bottom",title:"\u83B7\u5F97\u5E73\u53F0\u5956\u52B1\u91D1\u5E01\uFF1A".concat(Z==null?void 0:Z.reward)},y.a.createElement("span",{className:"ml10 c-orange-ff7"},y.a.createElement("i",{className:"iconfont icon-gift font16 mr5"}),y.a.createElement("span",{className:"font14"},Z==null?void 0:Z.reward)))),y.a.createElement(w.a,null,(((He=$e.userInfo)===null||He===void 0?void 0:He.admin)||((Ye=$e.userInfo)===null||Ye===void 0?void 0:Ye.user_id)===(q==null?void 0:q.user_id))&&y.a.createElement(p.a,{overlay:Tt},y.a.createElement("i",{className:"fa fa-bars font-16 current c-grey-bcb"})))),y.a.createElement(R.a,{align:"middle",className:"font14"},y.a.createElement(w.a,{flex:1,className:"c-grey-999"},y.a.createElement("span",null,F()(Z==null?void 0:Z.time).fromNow()," \u53D1\u5E03")),y.a.createElement(w.a,{className:"c-grey-999"},((Ce=$e.userInfo)===null||Ce===void 0?void 0:Ce.admin)&&y.a.createElement(v.a,{placement:"bottom",title:"\u5E16\u5B50\u5956\u52B1"},y.a.createElement("span",{className:"current pr10 ".concat(H.a.line),onClick:Me},y.a.createElement("i",{className:"iconfont icon-jiangli font18 mr5"}))),y.a.createElement("span",{className:"pr10 pl10 ".concat(Z!=null&&Z.replies_count?H.a.line:"")},y.a.createElement("i",{className:"iconfont icon-liulanyan font18 mr5"}),Z==null?void 0:Z.viewed_count),!!(Z!=null&&Z.replies_count)&&y.a.createElement(v.a,{placement:"bottom",title:"\u5199\u8BC4\u8BBA"},y.a.createElement("span",{className:"current pl10",onClick:et},y.a.createElement("i",{className:"iconfont icon-huifu1 font18 mr5"}),Z==null?void 0:Z.replies_count))))),y.a.createElement("main",{className:"bg-white pt40 pb40 pl40 pr40"},y.a.createElement("div",{onClick:ot},y.a.createElement(ne.a,{value:Z==null?void 0:Z.content})),y.a.createElement("div",{className:"bg-white pl40 pr40 mt40"},y.a.createElement("div",{className:"mt10 mb20 ".concat(H.a.flexCenter)},y.a.createElement("div",{className:"".concat(H.a.like," ").concat(Z!=null&&Z.user_praise?"":H.a.canLike),onClick:rt},y.a.createElement("i",{className:"iconfont icon-dianzan font18"}),y.a.createElement("br",null),y.a.createElement("span",null,Z==null?void 0:Z.memo_praise_count)))),!!(se!=null&&se.length)&&y.a.createElement("div",{className:"mt40"},se==null?void 0:se.map(function(Ve){return y.a.createElement("div",{className:"c-grey-888 ".concat(H.a.flexCenter)},y.a.createElement("i",{className:"iconfont icon-fujian mr10 font14 c-green-29b"}),y.a.createElement("a",{href:Ve==null?void 0:Ve.url,title:Ve==null?void 0:Ve.title,className:"".concat(H.a.attachmentName," mr10")},Ve==null?void 0:Ve.title),y.a.createElement("span",{className:"font12 c-grey-666 mt3"},Ve==null?void 0:Ve.filesize))}))),y.a.createElement(L,{ref:pe,handleClick:ot}),y.a.createElement(U.a,null))},Ue=Object(B.a)(function(Fe){var Ne=Fe.user,We=Fe.forumsDetail,Ze=Fe.loading,He=Fe.globalSetting;return{user:Ne,forumsDetail:We,globalSetting:He,loading:Ze.effects}})(_e),ke=ue("G8my"),Oe=ue.n(ke),Pe=function(Ne){var We=Ne.forumsDetail,Ze=Ne.globalSetting,He=Ne.loading,Ye=Ne.dispatch,Ce=Object(Q.a)(Ne,["forumsDetail","globalSetting","loading","dispatch"]),$e=Object(j.i)();Object(I.useEffect)(function(){qe()},[$e.memoId]);var qe=function(){var ae=Object(fe.a)(V.a.mark(function J(){return V.a.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:Ye({type:"forumsDetail/getForumsDetailData",payload:{id:$e.memoId}});case 1:case"end":return re.stop()}},J)}));return function(){return ae.apply(this,arguments)}}();return y.a.createElement("section",{className:"edu-container mb20 mt30 ".concat(Oe.a.flex)},y.a.createElement(Ue,null),y.a.createElement(T,null))},Xe=at.default=Object(B.a)(function(Fe){var Ne=Fe.forumsDetail,We=Fe.loading,Ze=Fe.globalSetting;return{forumsDetail:Ne,globalSetting:Ze,loading:We.models.forumsDetail}})(Pe)},LO5M:function(gt,at,ue){gt.exports={wrap:"wrap___1d4rP",head:"head___1_Uzf",recommendItem:"recommendItem___IStR9",buttonWrap:"buttonWrap___3dpFm",privateMessage:"privateMessage___24GfS",flex1:"flex1___3wIqQ",mWidth147:"mWidth147___3ODny"}},LdHM:function(gt,at,ue){"use strict";ue.d(at,"b",function(){return u}),ue.d(at,"a",function(){return m});var fe=ue("1OyB"),Q=ue("vuIU"),D=ue("Ji7U"),V=ue("LK+K"),I=ue("q1tI"),y=ue("rePB"),j=ue("Ff2n"),B=ue("ODXe"),M=ue("4IlW"),R=ue("bX4T"),b=ue("YrtM"),w=ue("TSYQ"),O=ue.n(w),A=ue("+nKL"),S=ue("8OUc"),C=function(ne,ce){var ge=ne.prefixCls,be=ne.id,Ie=ne.flattenOptions,Te=ne.childrenAsData,De=ne.values,we=ne.searchValue,Ae=ne.multiple,ve=ne.defaultActiveFirstOption,W=ne.height,L=ne.itemHeight,k=ne.notFoundContent,H=ne.open,ee=ne.menuItemSelectedIcon,U=ne.virtual,de=ne.onSelect,Ee=ne.onToggleOpen,_e=ne.onActiveValue,Ue=ne.onScroll,ke=ne.onMouseEnter,Oe="".concat(ge,"-item"),Pe=Object(b.a)(function(){return Ie},[H,Ie],function(J,$){return $[0]&&J[1]!==$[1]}),Xe=I.useRef(null),Fe=function($){$.preventDefault()},Ne=function($){Xe.current&&Xe.current.scrollTo({index:$})},We=function($){for(var re=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,oe=Pe.length,q=0;q<oe;q+=1){var Z=($+q*re+oe)%oe,se=Pe[Z],le=se.group,pe=se.data;if(!le&&!pe.disabled)return Z}return-1},Ze=I.useState(function(){return We(0)}),He=Object(B.a)(Ze,2),Ye=He[0],Ce=He[1],$e=function($){Ce($);var re=Pe[$];if(!re){_e(null,-1);return}_e(re.data.value,$)};I.useEffect(function(){$e(ve!==!1?We(0):-1)},[Pe.length,we]),I.useEffect(function(){var J=setTimeout(function(){if(!Ae&&H&&De.size===1){var $=Array.from(De)[0],re=Pe.findIndex(function(oe){var q=oe.data;return q.value===$});$e(re),Ne(re)}});return function(){return clearTimeout(J)}},[H]);var qe=function($){$!==void 0&&de($,{selected:!De.has($)}),Ae||Ee(!1)};if(I.useImperativeHandle(ce,function(){return{onKeyDown:function($){var re=$.which;switch(re){case M.a.UP:case M.a.DOWN:{var oe=0;if(re===M.a.UP?oe=-1:re===M.a.DOWN&&(oe=1),oe!==0){var q=We(Ye+oe,oe);Ne(q),$e(q)}break}case M.a.ENTER:{var Z=Pe[Ye];Z&&!Z.data.disabled?qe(Z.data.value):qe(void 0),H&&$.preventDefault();break}case M.a.ESC:Ee(!1)}},onKeyUp:function(){},scrollTo:function($){Ne($)}}}),Pe.length===0)return I.createElement("div",{role:"listbox",id:"".concat(be,"_list"),className:"".concat(Oe,"-empty"),onMouseDown:Fe},k);function ae(J){var $=Pe[J];if(!$)return null;var re=$.data||{},oe=re.value,q=re.label,Z=re.children,se=Object(R.a)(re,!0),le=Te?Z:q;return $?I.createElement("div",Object.assign({"aria-label":typeof le=="string"?le:null},se,{key:J,role:"option",id:"".concat(be,"_list_").concat(J),"aria-selected":De.has(oe)}),oe):null}return I.createElement(I.Fragment,null,I.createElement("div",{role:"listbox",id:"".concat(be,"_list"),style:{height:0,width:0,overflow:"hidden"}},ae(Ye-1),ae(Ye),ae(Ye+1)),I.createElement(A.a,{itemKey:"key",ref:Xe,data:Pe,height:W,itemHeight:L,fullHeight:!1,onMouseDown:Fe,onScroll:Ue,virtual:U,onMouseEnter:ke},function(J,$){var re,oe=J.group,q=J.groupOption,Z=J.data,se=Z.label,le=Z.key;if(oe)return I.createElement("div",{className:O()(Oe,"".concat(Oe,"-group"))},se!==void 0?se:le);var pe=Z.disabled,ye=Z.value,Le=Z.title,Me=Z.children,et=Z.style,rt=Z.className,Tt=Object(j.a)(Z,["disabled","value","title","children","style","className"]),ot=De.has(ye),Ve="".concat(Oe,"-option"),vt=O()(Oe,Ve,rt,(re={},Object(y.a)(re,"".concat(Ve,"-grouped"),q),Object(y.a)(re,"".concat(Ve,"-active"),Ye===$&&!pe),Object(y.a)(re,"".concat(Ve,"-disabled"),pe),Object(y.a)(re,"".concat(Ve,"-selected"),ot),re)),st=Te?Me:se,Lt=!ee||typeof ee=="function"||ot;return I.createElement("div",Object.assign({},Tt,{"aria-selected":ot,className:vt,title:Le,onMouseMove:function(){if(Ye===$||pe)return;$e($)},onClick:function(){pe||qe(ye)},style:et}),I.createElement("div",{className:"".concat(Ve,"-content")},st||ye),I.isValidElement(ee)||ot,Lt&&I.createElement(S.a,{className:"".concat(Oe,"-option-state"),customizeIcon:ee,customizeIconProps:{isSelected:ot}},ot?"\u2713":null))}))},d=I.forwardRef(C);d.displayName="OptionList";var o=d,s=function(){return null};s.isSelectOption=!0;var u=s,T=function(){return null};T.isSelectOptGroup=!0;var m=T,p=ue("VTBJ"),_=ue("Zm9Q");function v(F){var ne=F.key,ce=F.props,ge=ce.children,be=ce.value,Ie=Object(j.a)(ce,["children","value"]);return Object(p.a)({key:ne,value:be!==void 0?be:ne,children:ge},Ie)}function c(F){var ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(_.a)(F).map(function(ce,ge){if(!I.isValidElement(ce)||!ce.type)return null;var be=ce.type.isSelectOptGroup,Ie=ce.key,Te=ce.props,De=Te.children,we=Object(j.a)(Te,["children"]);return ne||!be?v(ce):Object(p.a)(Object(p.a)({key:"__RC_SELECT_GRP__".concat(Ie===null?ge:Ie,"__"),label:Ie},we),{},{options:c(De)})}).filter(function(ce){return ce})}var h=ue("2Qr1"),l=ue("qNPg"),a=ue("U8pU"),g=ue("Kwbf"),f=ue("WKfj");function x(F){var ne=F.mode,ce=F.options,ge=F.children,be=F.backfill,Ie=F.allowClear,Te=F.placeholder,De=F.getInputElement,we=F.showSearch,Ae=F.onSearch,ve=F.defaultOpen,W=F.autoFocus,L=F.labelInValue,k=F.value,H=F.inputValue,ee=F.optionLabelProp,U=ne==="multiple"||ne==="tags",de=we!==void 0?we:U||ne==="combobox",Ee=ce||c(ge);if(Object(g.a)(ne!=="tags"||Ee.every(function(Oe){return!Oe.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),ne==="tags"||ne==="combobox"){var _e=Ee.some(function(Oe){return Oe.options?Oe.options.some(function(Pe){return typeof("value"in Pe?Pe.value:Pe.key)=="number"}):typeof("value"in Oe?Oe.value:Oe.key)=="number"});Object(g.a)(!_e,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(g.a)(ne!=="combobox"||!ee,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(g.a)(ne==="combobox"||!be,"`backfill` only works with `combobox` mode."),Object(g.a)(ne==="combobox"||!De,"`getInputElement` only work with `combobox` mode."),Object(g.b)(ne!=="combobox"||!De||!Ie||!Te,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Ae&&!de&&ne!=="combobox"&&ne!=="tags"&&Object(g.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(g.b)(!ve||W,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),k!=null){var Ue=Object(f.d)(k);Object(g.a)(!L||Ue.every(function(Oe){return Object(a.a)(Oe)==="object"&&("key"in Oe||"value"in Oe)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(g.a)(!U||Array.isArray(k),"`value` should be array when `mode` is `multiple` or `tags`")}if(ge){var ke=null;Object(_.a)(ge).some(function(Oe){if(!I.isValidElement(Oe)||!Oe.type)return!1;var Pe=Oe.type;if(Pe.isSelectOption)return!1;if(Pe.isSelectOptGroup){var Xe=Object(_.a)(Oe.props.children).every(function(Fe){return!I.isValidElement(Fe)||!Oe.type||Fe.type.isSelectOption?!0:(ke=Fe.type,!1)});return!Xe}return ke=Pe,!0}),ke&&Object(g.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(ke.displayName||ke.name||ke,"`.")),Object(g.a)(H===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var P=x,G=Object(l.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:c,flattenOptions:h.d,getLabeledValue:h.e,filterOptions:h.b,isValueDisabled:h.g,findValueOption:h.c,warningProps:P,fillOptionsWithMissingValue:h.a}),X=function(F){Object(D.a)(ce,F);var ne=Object(V.a)(ce);function ce(){var ge;return Object(fe.a)(this,ce),ge=ne.apply(this,arguments),ge.selectRef=I.createRef(),ge.focus=function(){ge.selectRef.current.focus()},ge.blur=function(){ge.selectRef.current.blur()},ge}return Object(Q.a)(ce,[{key:"render",value:function(){return I.createElement(G,Object.assign({ref:this.selectRef},this.props))}}]),ce}(I.Component);X.Option=u,X.OptGroup=m;var ie=X,z=at.c=ie},M8RZ:function(gt,at,ue){"use strict";ue.d(at,"a",function(){return M});var fe=ue("fWQN"),Q=ue("mtLc"),D=ue("yKVA"),V=ue("879j"),I=ue("q1tI"),y=ue.n(I),j=ue("i8i4"),B=ue.n(j),M=function(R){Object(D.a)(w,R);var b=Object(V.a)(w);function w(O){var A;Object(fe.a)(this,w),A=b.call(this,O);var S=window.document;return A.node=S.createElement("div"),S.body.appendChild(A.node),A}return Object(Q.a)(w,[{key:"render",value:function(){var A=this.props.children;return Object(j.createPortal)(A,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),w}(y.a.Component)},Ot1p:function(gt,at,ue){"use strict";var fe=ue("2qtc"),Q=ue("kLXV"),D=ue("rAM+"),V=ue("miYZ"),I=ue("tsqr"),y=ue("9og8"),j=ue("tJVT"),B=ue("jrin"),M=ue("WmNS"),R=ue.n(M),b=ue("q1tI"),w=ue.n(b),O=ue("VrN/"),A=ue.n(O),S=ue("bdgK"),C=ue("p77/"),d=ue("Bd2K"),o=ue("ELLl"),s=ue("19Vz"),u=ue("lZu9"),T=ue("+NIl"),m=ue("kSUc"),p=ue("9Bee"),_=function(pe){var ye=pe.value,Le=ye===void 0?"":ye,Me=pe.className,et=pe.showTextOnly,rt=pe.showLines,Tt=pe.style,ot=Tt===void 0?{}:Tt,Ve=Object(b.useMemo)(function(){return""},[Le]);return w.a.createElement(w.a.Fragment,null,w.a.createElement("div",{dangerouslySetInnerHTML:{__html:Ve}}))},v=ue("0Owb"),c=ue("dejd"),h=ue("C+DQ"),l=ue("1vsH"),a=ue("m3rI"),g=[{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 f(pe){var ye=pe.onActionCallback,Le=pe.title,Me=pe.icon,et=pe.actionName,rt=pe.className,Tt=rt===void 0?"":rt,ot=pe.children;function Ve(){ye(et)}return w.a.createElement("a",{title:Le,className:Tt,onClick:Ve},w.a.createElement("i",{className:"md-iconfont ".concat(Me)}),ot)}var x=function(pe){var ye=pe.watch,Le=pe.showNullButton,Me=pe.onActionCallback,et=pe.fullScreen,rt=pe.insertTemp,Tt=pe.hidetoolBar,ot=pe.uuid,Ve=pe.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(l.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(l.F)("_educoder_session"),"&key=").concat(ot,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var vt=[].concat(g,[{title:"".concat(ye?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(ye?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return w.a.createElement("ul",{className:"markdown-toolbar-container"},!Tt&&vt.map(function(st,Lt){return w.a.createElement("li",{key:Lt},st.actionName?w.a.createElement(f,Object(v.a)({},st,{onActionCallback:Me})):w.a.createElement("span",{className:"v-line"}))}),Le?w.a.createElement("li",null,w.a.createElement(f,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:Me},w.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,rt&&w.a.createElement("li",null,w.a.createElement(f,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(rt),onActionCallback:Me},w.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),w.a.createElement("li",{className:"btn-full-screen"},w.a.createElement(f,{icon:"".concat(et?"icon-shrink":"icon-enlarge"),title:et?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:Me})))},P=ue("M8RZ"),G=ue("+L6B"),X=ue("2/Rp"),ie=ue("y8nQ"),z=ue("Vl3Y"),F=ue("5NDa"),ne=ue("5rEg"),ce={labelCol:{span:4},wrapperCol:{span:20}},ge=function(pe){var ye=pe.callback,Le=pe.onCancel;function Me(et){ye(et)}return w.a.createElement(z.a,Object(v.a)({},ce,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:Me}),w.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},w.a.createElement(ne.a,null)),w.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},w.a.createElement(ne.a,null)),w.a.createElement("div",{className:"flex-container flex-end"},w.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),w.a.createElement(X.a,{type:"ghost",onClick:Le},"\u53D6\u6D88")))},be=ue("7ahc"),Ie=ue("HmJG"),Te=ue("BjJ7"),De=z.a.useForm,we={width:280,marginRight:10},Ae={labelCol:{span:5},wrapperCol:{span:19}},ve=function(pe){var ye=pe.callback,Le=pe.onCancel,Me=De(),et=Object(j.a)(Me,1),rt=et[0];function Tt(vt){ye(vt)}function ot(vt,st){if(vt.status===-1){I.b.error(vt.message);return}rt.setFieldsValue({src:"/api/attachments/".concat(vt.id),type:st.type})}function Ve(vt){var st=vt.target.files[0];L(st,ot)}return w.a.createElement(z.a,Object(v.a)({form:rt},Ae,{className:"upload-image-panel",onFinish:Tt}),w.a.createElement(z.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},w.a.createElement("div",{className:"flex-container"},w.a.createElement(z.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},w.a.createElement(ne.a,{style:we})),w.a.createElement(W,{onFileChange:Ve}))),w.a.createElement(z.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},w.a.createElement(ne.a,{style:{width:264}})),w.a.createElement(z.a.Item,{style:{textAlign:"right"}},w.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),w.a.createElement(X.a,{type:"ghost",onClick:Le},"\u53D6\u6D88")))};function W(pe){var ye=pe.onFileChange;return w.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",w.a.createElement("input",{type:"file",onChange:ye}))}function L(pe,ye){if(!pe)throw new String("\u6CA1\u6709\u6587\u4EF6");var Le=new FormData;Le.append("editormd-image-file",pe),Le.append("file_param_name","editormd-image-file"),Le.append("byxhr","true");var Me=new window.XMLHttpRequest;Me.withCredentials=!0,Me.addEventListener("load",function(et){ye(JSON.parse(et.target.responseText),pe)},!1),Me.addEventListener("error",function(et){console.error(et)},!1),Me.open("POST","".concat(Te.a,"/api/attachments.json")),Me.send(Le)}var k=ue("giR+"),H=ue("fyUT"),ee=ue("7Kak"),U=ue("9yH6"),de=U.a.Group,Ee={margin:"0 8px"},_e=function(pe){var ye=pe.callback,Le=pe.onCancel;function Me(et){ye(et)}return w.a.createElement(z.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:Me},w.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},w.a.createElement("span",{style:Ee},"\u5355\u5143\u683C\u6570\uFF1A"),w.a.createElement("span",{style:Ee},"\u884C\u6570"),w.a.createElement(z.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},w.a.createElement(H.a,null)),w.a.createElement("span",{style:Ee},"\u5217\u6570"),w.a.createElement(z.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},w.a.createElement(H.a,null))),w.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},w.a.createElement("span",{style:Ee},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),w.a.createElement(z.a.Item,{name:"align"},w.a.createElement(de,null,w.a.createElement(U.a,{value:"default"},w.a.createElement("i",{className:"fa fa-align-justify"})),w.a.createElement(U.a,{value:"left"},w.a.createElement("i",{className:"fa fa-align-left"})),w.a.createElement(U.a,{value:"center"},w.a.createElement("i",{className:"fa fa-align-center"})),w.a.createElement(U.a,{value:"right"},w.a.createElement("i",{className:"fa fa-align-right"}))))),w.a.createElement("div",{className:"flex-container flex-end"},w.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),w.a.createElement(X.a,{type:"ghost",onClick:Le},"\u53D6\u6D88")))},Ue=ue("ErOA"),ke=ue("7Cbv"),Oe="link",Pe="upload-image",Xe="code-block",Fe="add-table",Ne="------------",We={default:Ne,left:":".concat(Ne),center:":".concat(Ne,":"),right:"".concat(Ne,":")},Ze=ue("9VGf"),He,Ye;function Ce(){}var $e=0,qe=1e4,ae="\u2581",J=`
|
|
**\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 $(pe){return/^\d+$/.test(pe)?"".concat(pe,"px"):pe}var re=navigator.platform.toUpperCase().indexOf("MAC")>=0,oe=re?"Cmd":"Ctrl",q=["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"],Z=(He={},Object(B.a)(He,oe+"-B","bold"),Object(B.a)(He,oe+"-I","italic"),He),se=(Ye={},Object(B.a)(Ye,Oe,"\u6DFB\u52A0\u94FE\u63A5"),Object(B.a)(Ye,Xe,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(B.a)(Ye,Pe,"\u6DFB\u52A0\u6587\u4EF6"),Object(B.a)(Ye,Fe,"\u6DFB\u52A0\u8868\u683C"),Ye),le=at.a=function(pe){var ye=pe.defaultValue,Le=ye===void 0?"":ye,Me=pe.onChange,et=pe.width,rt=et===void 0?"100%":et,Tt=pe.height,ot=Tt===void 0?400:Tt,Ve=pe.miniToolbar,vt=Ve===void 0?!1:Ve,st=pe.isFocus,Lt=st===void 0?!1:st,St=pe.watch,yt=pe.insertTemp,rr=pe.mode,Wt=rr===void 0?"markdown":rr,Ht=pe.id,Ut=Ht===void 0?"markdown-editor-id":Ht,or=pe.showResizeBar,wr=or===void 0?!1:or,Vt=pe.noStorage,Sr=Vt===void 0?!1:Vt,Br=pe.showNullButton,ut=Br===void 0?!1:Br,Ke=pe.hidetoolBar,xt=Ke===void 0?!1:Ke,Ct=pe.fullScreen,nt=Ct===void 0?!1:Ct,ft=pe.onBlur,pt=pe.onCMBeforeChange,$t=pe.onFullScreen,Gt=pe.className,je=Gt===void 0?"":Gt,mt=pe.disablePaste,ri=mt===void 0?!1:mt,bi=pe.placeholder,xi=bi===void 0?"":bi,ii=pe.values,Ei=ii===void 0?"":ii,Et=Object(b.useState)(null),An=Object(j.a)(Et,2),Ge=An[0],Si=An[1],Tr=Object(b.useState)(Le),Ki=Object(j.a)(Tr,2),ni=Ki[0],Lr=Ki[1],Vi=Object(b.useState)(St),Xi=Object(j.a)(Vi,2),Ar=Xi[0],Yi=Xi[1],_n=Object(b.useState)(nt),$i=Object(j.a)(_n,2),_r=$i[0],kn=$i[1],aa=Object(b.useState)(""),Zi=Object(j.a)(aa,2),sr=Zi[0],Vr=Zi[1],oa=Object(b.useState)(0),ai=Object(j.a)(oa,2),kr=ai[0],Ji=ai[1],sa=Object(b.useState)(ot),Dn=Object(j.a)(sa,2),Rn=Dn[0],Ti=Dn[1],On=Object(b.useState)(!1),Pn=Object(j.a)(On,2),la=Pn[0],Ci=Pn[1],oi=Object(b.useRef)(Object(ke.a)()),si=Object(b.useRef)(!1),wi=Object(b.useRef)(),Fr=Object(b.useRef)(),jr=Object(b.useRef)(),Wr=Object(b.useRef)(),Li=Object(b.useRef)(),Mn=function(){var lt=Object(y.a)(R.a.mark(function bt(){var ht,At;return R.a.wrap(function(Mt){for(;;)switch(Mt.prev=Mt.next){case 0:return Mt.next=2,Object(Ue.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:oi.current}});case 2:At=Mt.sent,At!=null&&(ht=At.attachments)!==null&&ht!==void 0&&ht.length&&(console.log("cm:",Ge,Fr),At.attachments.map(function(kt){kt.content_type.indexOf("image")>-1?Ge.replaceSelection(".concat(kt.content_type,")")):kt.content_type.indexOf("video")>-1?Ge.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):kt.content_type.indexOf("pdf")>-1?Ge.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(kt.id,"?type=").concat(kt.content_type,'&disposition=inline" target="_blank">').concat(kt.name,"</a>")):Ge.replaceSelection("[".concat(kt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(kt.id,"?type=").concat(kt.content_type,")"))}));case 4:case"end":return Mt.stop()}},bt)}));return function(){return lt.apply(this,arguments)}}();Object(b.useEffect)(function(){Lr(Ei),Ge==null||Ge.setValue(Ei)},[Ei]),Object(b.useEffect)(function(){$t==null||$t(_r)},[_r]),Object(b.useEffect)(function(){if(Fr.current){var lt=A.a.fromTextArea(Fr.current,{mode:Wt,lineNumbers:!vt,lineWrapping:!0,value:Le,autoCloseTags:!0,autoCloseBrackets:!0});Lt&<.focus();function bt(ht,At){if(ri){At.preventDefault();return}var Dt=At.clipboardData;if(Dt){var Mt=Dt.types.toString(),kt=Dt.items;if(Mt==="Files"||Dt.types.indexOf("Files")>-1){if(At.preventDefault(),Wt=="stex")return;try{var Xt,dr=kt[1];((Xt=kt[0])===null||Xt===void 0?void 0:Xt.kind)==="file"&&(dr=kt[0]);var _t=dr.getAsFile(),Hr=_t.name.split(".").pop();L(_t,function(Rt){if(Rt.id){var hr,ir,Cr;(_t==null||((hr=_t.type)===null||hr===void 0)?void 0:hr.indexOf("image"))>-1?lt.replaceSelection(".concat(Rt.content_type,")")):(_t==null||((ir=_t.type)===null||ir===void 0)?void 0:ir.indexOf("video"))>-1?lt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Rt.id,'"></video>')):(_t==null||((Cr=_t.type)===null||Cr===void 0)?void 0:Cr.indexOf("pdf"))>-1?lt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Rt.id,"?type=").concat(_t.type,'&disposition=inline" target="_blank">').concat(_t.name,"</a>")):q.includes(Hr)?lt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Rt.id,'?type=office&disposition=inline" target="_blank">').concat(_t.name,"</a>")):lt.replaceSelection("[".concat(_t.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Rt.id,"?type=").concat(Rt.content_type,")"))}else(Rt==null?void 0:Rt.status)===401&&(document.location.href="/user/login")})}catch(Rt){I.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return lt.on("paste",bt),lt.on("dragleave",function(ht,At){jr.current.classList.remove("mouse-hover-md")}),lt.on("dragover",function(ht,At){jr.current.classList.add("mouse-hover-md")}),lt.on("drop",function(ht,At){jr.current.classList.add("mouse-hover-md");var Dt;if(Dt=At.dataTransfer.files,Dt.length>0){At.preventDefault(),At.stopPropagation();for(var Mt=function(dr){var _t=Dt[dr],Hr=_t.name.split(".").pop();L(_t,function(Rt){if(Rt.id){var hr,ir,Cr;(_t==null||((hr=_t.type)===null||hr===void 0)?void 0:hr.indexOf("image"))>-1?lt.replaceSelection(".concat(Rt.content_type,")")):(_t==null||((ir=_t.type)===null||ir===void 0)?void 0:ir.indexOf("video"))>-1?lt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Rt.id,'"></video>')):(_t==null||((Cr=_t.type)===null||Cr===void 0)?void 0:Cr.indexOf("pdf"))>-1?lt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Rt.id,"?type=").concat(_t.type,'&disposition=inline" target="_blank">').concat(_t.name,"</a>")):q.includes(Hr)?lt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Rt.id,'?type=office&disposition=inline" target="_blank">').concat(_t.name,"</a>")):lt.replaceSelection("[".concat(_t.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Rt.id,"?type=").concat(Rt.content_type,")"))}else(Rt==null?void 0:Rt.status)===401&&(document.location.href="/user/login")})},kt=0;kt<Dt.length;kt++)Mt(kt)}}),Si(lt),function(){lt.off("paste",bt)}}},[]);var br=Object(b.useCallback)(function(){if(jr.current)try{}catch(lt){console.log(lt,"---- to set md editor body height")}},[Rn,jr,_r]);Object(b.useEffect)(function(){function lt(){var ht=new S.default(function(At){var Dt=Object(D.a)(At),Mt;try{for(Dt.s();!(Mt=Dt.n()).done;){var kt=Mt.value;(kt.target.offsetHeight>0||kt.target.offsetWidth>0)&&(br(),Ge.setSize("100%","100%"),Ge.refresh())}}catch(Xt){Dt.e(Xt)}finally{Dt.f()}});return ht.observe(Fr.current.parentElement),ht}if(Ge){var bt=lt();return function(){bt.unobserve(Fr.current.parentElement)}}},[Ge,br]),Object(b.useEffect)(function(){if(Ge){for(var lt=[],bt=function(){var kt=At[ht];Dt=Object(j.a)(kt,2);var Xt=Dt[0],dr=Dt[1],_t=Object(B.a)({},Xt,function(){In(dr)});lt.push(_t),Ge.addKeyMap(_t)},ht=0,At=Object.entries(Z);ht<At.length;ht++){var Dt;bt()}return wi.current=setInterval(function(){si.current&&Mn()},4e3),function(){clearInterval(wi.current);var Mt=Object(D.a)(lt),kt;try{for(Mt.s();!(kt=Mt.n()).done;){var Xt=kt.value;Ge.removeKeyMap(Xt)}}catch(dr){Mt.e(dr)}finally{Mt.f()}}}},[Ge]),Object(b.useEffect)(function(){nt!==_r&&kn(nt)},[nt]),Object(Ze.a)(function(){if(!Sr&&kr>0){var lt=new Date().getTime(),bt=window.sessionStorage.getItem(Ut);lt>=kr+qe&&(!bt||bt!==ni)&&(window.sessionStorage.setItem(Ut,ni),Ci(!0))}},qe),Object(b.useEffect)(function(){Yi(St)},[Ge,St]),Object(b.useEffect)(function(){Ge&&(Lt&&Ge.focus())},[Ge,Lt]),Object(b.useEffect)(function(){if(Ar&&Ge){var lt=Ge.getScrollerElement();function bt(ht){var At=ht.target;if(Li.current){var Dt=At.scrollTop/At.scrollHeight;Li.current.scrollTop=Li.current.scrollHeight*Dt}}return lt.addEventListener("scroll",bt),function(){lt.removeEventListener("scroll",bt)}}},[Ge,Ar]),Object(b.useEffect)(function(){if(Ge&&pt){function lt(bt,ht){pt(bt,ht)}return Ge.on("beforeChange",lt),function(){Ge.off("beforeChange",lt)}}},[Ge,pt]),Object(b.useEffect)(function(){if(Ge&&ft){function lt(){ft(Ge.getValue())}return Ge.on("blur",lt),function(){Ge.off("blur",lt)}}},[Ge,ft]),Object(b.useEffect)(function(){if(Ge){function lt(bt){var ht=bt.getValue();Lr(ht),Ji(new Date().getTime()),bt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),Me&&Me(ht)}return Ge.on("change",lt),function(){Ge.off("change",lt)}}},[Ge,Me]),Object(b.useEffect)(function(){Ge&&(Le==null?(Ge.setValue(""),Lr("")):Le!==Ge.getValue()&&(Ge.setValue(Le),Lr(Le),Ge.setCursor(Ge.lineCount(),0)))},[Ge,Le]);var In=Object(b.useCallback)(function(lt){var bt=Ge.getCursor(),ht=Ge.getSelection(),At=ht.split(`
|
|
`);switch(lt){case"bold":return Ge.replaceSelection("**"+ht+"**"),ht===""&&Ge.setCursor(bt.line,bt.ch+2),Ge.focus();case"italic":return Ge.replaceSelection("*"+ht+"*"),ht===""&&Ge.setCursor(bt.line,bt.ch+1),Ge.focus();case"code":return Ge.replaceSelection("`"+ht+"`"),ht===""&&Ge.setCursor(bt.line,bt.ch+1),Ge.focus();case"inline-latex":return Ge.replaceSelection("`$$"+ht+"$$`"),ht===""&&Ge.setCursor(bt.line,bt.ch+3),Ge.focus();case"latex":return Ge.replaceSelection("```latex\n"+ht+"\n```"),Ge.setCursor(bt.line+1,ht.length+1),Ge.focus();case"line-break":return Ge.replaceSelection(`<br/>
|
|
`),Ge.focus();case"list-ul":return ht===""?Ge.replaceSelection("- "+ht):Ge.replaceSelection(At.map(function(Dt){return Dt===""?"":"- ".concat(Dt)}).join(`
|
|
`)),Ge.focus();case"list-ol":return ht===""?Ge.replaceSelection("1. "+ht):Ge.replaceSelection(At.map(function(Dt,Mt){return Dt===""?"":"".concat(Mt+1,". ").concat(Dt)}).join(`
|
|
`)),Ge.focus();case"add-null-ch":return ht===""&&Ge.setCursor(bt.line,bt.ch+1),Ge.replaceSelection(ae),Ge.focus();case"inster-template-1":return ht===""&&Ge.setCursor(bt.line,bt.ch),Ge.replaceSelection(J),Ge.focus();case"eraser":return Ge.setValue(""),Ge.focus();case"trigger-watch":return Yi(!Ar),Ge.focus();case"trigger-full-screen":return kn(!_r),Ge.focus();case Oe:Vr(Oe);return;case Xe:Vr(Xe);return;case Pe:Vr(Pe);return;case Fe:Vr(Fe);return;default:throw new Error}},[Ge,Ar,_r]),Ai=Object(b.useCallback)(function(lt){Vr("");switch(sr){case Oe:var bt=lt.title,ht=lt.link;return Ge.replaceSelection("[".concat(bt,"](").concat(ht,")")),Ge.focus();case Xe:var At=lt.language,Dt=lt.content;return Ge.replaceSelection(["```"+At,Dt,"```"].join(`
|
|
`)),Ge.focus();case Pe:var Mt=lt.src,kt=lt.alt;return kt?Ge.replaceSelection(".concat(Mt,' "').concat(kt,'" )')):Ge.replaceSelection("")),Ge.focus();case Fe:for(var Xt=lt.row,dr=lt.col,_t=lt.align,Hr=`
|
|
`,Rt=0;Rt<Xt;Rt++){for(var hr=[],ir=[],Cr=0;Cr<dr;Cr++)Rt===1&&ir.push(We[_t]),hr.push(" ");Rt===1&&(Hr+="| ".concat(ir.join(" | "),` |
|
|
`)),Hr+="| ".concat(hr.join(dr===1?"":" | "),` |
|
|
`)}return Ge.replaceSelection(Hr+`
|
|
`),Ge.focus();default:throw new Error}},[Ge,sr]),Qi=Object(b.useMemo)(function(){switch(sr){case Oe:return w.a.createElement(ge,{callback:Ai,onCancel:Xr});case Xe:return w.a.createElement(be.b,{callback:Ai,onCancel:Xr});case Pe:return w.a.createElement(ve,{callback:Ai,onCancel:Xr});case Fe:return w.a.createElement(_e,{callback:Ai,onCancel:Xr});default:return null}},[sr]);function Xr(){Vr("")}Object(b.useEffect)(function(){if(Wr.current){var lt=Wr.current,bt=!1,ht=0;function At(kt){bt=!0,ht=kt.pageY}function Dt(){bt=!1}function Mt(kt){if(bt){var Xt=kt.pageY-ht;Xt<0&&(Xt=0),Xt>300&&(Xt=300);var dr=ot+Xt+"px";Ti(dr)}}return lt.addEventListener("mousedown",At),document.addEventListener("mousemove",Mt),document.addEventListener("mouseup",Dt),function(){lt.removeEventListener("mousedown",At),document.removeEventListener("mousemove",Mt),document.removeEventListener("mouseup",Dt)}}},[Ge,Wr]),Object(b.useEffect)(function(){Ti(ot)},[ot]);var Mr=$(rt),qi=$(Rn),Dr={width:Mr,height:qi},en=Object(b.useMemo)(function(){if(kr){var lt=new Date(kr),bt=lt.getHours(),ht=lt.getMinutes(),At=lt.getSeconds();return bt=bt<10?"0"+bt:bt,ht=ht<10?"0"+ht:ht,At=At<10?"0"+At:At,"".concat(bt,":").concat(ht,":").concat(At)}return 0},[kr]);function Nn(){window.sessionStorage.removeItem(Ut),Ci(!1),Ji(0)}function li(){Ci(!1),Ji(0),Ge.setValue(window.sessionStorage.getItem(Ut))}function ua(lt,bt){var ht=Ge.getValue();ht=ht.replace(lt,bt),Lr(ht),Ge==null||Ge.setValue(ht)}return w.a.createElement(b.Fragment,null,w.a.createElement("div",{className:"markdown-editor-wrapper",ref:jr},w.a.createElement("div",{className:"markdown-editor-container ".concat(je," ").concat(Ar?"on-preview":""," ").concat(vt?"mini":""," ").concat(_r?"full-screen":""),style:Dr},w.a.createElement(x,{insertTemp:yt,watch:Ar,fullScreen:_r,showNullButton:ut,onActionCallback:In,hidetoolBar:xt,uuid:oi.current,setOpenPhones:function(){si.current=!0}}),w.a.createElement("div",{className:"markdown-editor-body"},w.a.createElement("div",{className:"codemirror-container"},w.a.createElement("textarea",{ref:Fr,placeholder:xi})),Ar?w.a.createElement("div",{ref:Li,className:"preview-container"},Wt==="stex"&&w.a.createElement(_,{value:ni}),Wt!=="stex"&&w.a.createElement(p.a,{edit:!0,value:ni,replaces:ua})):null))),wr?w.a.createElement("a",{ref:Wr,className:"editor-resize"}):null,w.a.createElement(P.a,null,se[sr]?w.a.createElement(Q.a,{centered:!0,title:se[sr],visible:!0,onCancel:Xr,footer:null,className:"markdown-popup-form"},Qi):null))}},SJMd:function(gt,at){/**
|
|
* @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 ue,fe,Q,D=!1,V,I;window.PR_SHOULD_USE_CONTINUATION=!0;var y,j;(function(){var B=window,M=["break,continue,do,else,for,if,return,while"],R=[M,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],b=[R,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],w=[b,"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"],O=[b,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],A=[b,"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"],S="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",C=[b,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],d="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",o=[M,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],s=[M,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],u=[M,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],T=[w,A,O,C,d,o,s,u],m=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,p="str",_="kwd",v="com",c="typ",h="lit",l="pun",a="pln",g="tag",f="dec",x="src",P="atn",G="atv",X="nocode",ie="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(de){for(var Ee=0,_e=!1,Ue=!1,ke=0,Oe=de.length;ke<Oe;++ke){var Pe=de[ke];if(Pe.ignoreCase)Ue=!0;else if(/[a-z]/i.test(Pe.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){_e=!0,Ue=!1;break}}var Xe={b:8,t:9,n:10,v:11,f:12,r:13};function Fe(Ye){var Ce=Ye.charCodeAt(0);if(Ce!==92)return Ce;var $e=Ye.charAt(1);return Ce=Xe[$e],Ce||("0"<=$e&&$e<="7"?parseInt(Ye.substring(1),8):$e==="u"||$e==="x"?parseInt(Ye.substring(2),16):Ye.charCodeAt(1))}function Ne(Ye){if(Ye<32)return(Ye<16?"\\x0":"\\x")+Ye.toString(16);var Ce=String.fromCharCode(Ye);return Ce==="\\"||Ce==="-"||Ce==="]"||Ce==="^"?"\\"+Ce:Ce}function We(Ye){var Ce=Ye.substring(1,Ye.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")),$e=[],qe=Ce[0]==="^",ae=["["];qe&&ae.push("^");for(var J=qe?1:0,$=Ce.length;J<$;++J){var re=Ce[J];if(/\\[bdsw]/i.test(re))ae.push(re);else{var oe=Fe(re),q;J+2<$&&Ce[J+1]==="-"?(q=Fe(Ce[J+2]),J+=2):q=oe,$e.push([oe,q]),q<65||oe>122||(q<65||oe>90||$e.push([Math.max(65,oe)|32,Math.min(q,90)|32]),q<97||oe>122||$e.push([Math.max(97,oe)&~32,Math.min(q,122)&~32]))}}$e.sort(function(pe,ye){return pe[0]-ye[0]||ye[1]-pe[1]});for(var Z=[],se=[],J=0;J<$e.length;++J){var le=$e[J];le[0]<=se[1]+1?se[1]=Math.max(se[1],le[1]):Z.push(se=le)}for(var J=0;J<Z.length;++J){var le=Z[J];ae.push(Ne(le[0])),le[1]>le[0]&&(le[1]+1>le[0]&&ae.push("-"),ae.push(Ne(le[1])))}return ae.push("]"),ae.join("")}function Ze(Ye){for(var Ce=Ye.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")),$e=Ce.length,qe=[],ae=0,J=0;ae<$e;++ae){var $=Ce[ae];if($==="(")++J;else if($.charAt(0)==="\\"){var re=+$.substring(1);re&&(re<=J?qe[re]=-1:Ce[ae]=Ne(re))}}for(var ae=1;ae<qe.length;++ae)qe[ae]===-1&&(qe[ae]=++Ee);for(var ae=0,J=0;ae<$e;++ae){var $=Ce[ae];if($==="(")++J,qe[J]||(Ce[ae]="(?:");else if($.charAt(0)==="\\"){var re=+$.substring(1);re&&re<=J&&(Ce[ae]="\\"+qe[re])}}for(var ae=0;ae<$e;++ae)Ce[ae]==="^"&&Ce[ae+1]!=="^"&&(Ce[ae]="");if(Ye.ignoreCase&&_e)for(var ae=0;ae<$e;++ae){var $=Ce[ae],oe=$.charAt(0);$.length>=2&&oe==="["?Ce[ae]=We($):oe!=="\\"&&(Ce[ae]=$.replace(/[a-zA-Z]/g,function(se){var le=se.charCodeAt(0);return"["+String.fromCharCode(le&~32,le|32)+"]"}))}return Ce.join("")}for(var He=[],ke=0,Oe=de.length;ke<Oe;++ke){var Pe=de[ke];if(Pe.global||Pe.multiline)throw new Error(""+Pe);He.push("(?:"+Ze(Pe)+")")}return new RegExp(He.join("|"),Ue?"gi":"g")}function F(de,Ee){var _e=/(?:^|\s)nocode(?:\s|$)/,Ue=[],ke=0,Oe=[],Pe=0;function Xe(Fe){var Ne=Fe.nodeType;if(Ne==1){if(_e.test(Fe.className))return;for(var We=Fe.firstChild;We;We=We.nextSibling)Xe(We);var Ze=Fe.nodeName.toLowerCase();(Ze==="br"||Ze==="li")&&(Ue[Pe]=`
|
|
`,Oe[Pe<<1]=ke++,Oe[Pe++<<1|1]=Fe)}else if(Ne==3||Ne==4){var He=Fe.nodeValue;He.length&&(Ee?He=He.replace(/\r\n?/g,`
|
|
`):He=He.replace(/[ \t\r\n]+/g," "),Ue[Pe]=He,Oe[Pe<<1]=ke,ke+=He.length,Oe[Pe++<<1|1]=Fe)}}return Xe(de),{sourceCode:Ue.join("").replace(/\n$/,""),spans:Oe}}function ne(de,Ee,_e,Ue,ke){if(!_e)return;var Oe={sourceNode:de,pre:1,langExtension:null,numberLines:null,sourceCode:_e,spans:null,basePos:Ee,decorations:null};Ue(Oe),ke.push.apply(ke,Oe.decorations)}var ce=/\S/;function ge(de){for(var Ee=void 0,_e=de.firstChild;_e;_e=_e.nextSibling){var Ue=_e.nodeType;Ee=Ue===1?Ee?de:_e:Ue===3&&ce.test(_e.nodeValue)?de:Ee}return Ee===de?void 0:Ee}function be(de,Ee){var _e={},Ue;(function(){for(var Pe=de.concat(Ee),Xe=[],Fe={},Ne=0,We=Pe.length;Ne<We;++Ne){var Ze=Pe[Ne],He=Ze[3];if(He)for(var Ye=He.length;--Ye>=0;)_e[He.charAt(Ye)]=Ze;var Ce=Ze[1],$e=""+Ce;Fe.hasOwnProperty($e)||(Xe.push(Ce),Fe[$e]=null)}Xe.push(/[\0-\uffff]/),Ue=z(Xe)})();var ke=Ee.length,Oe=function(Pe){for(var Xe=Pe.sourceCode,Fe=Pe.basePos,Ne=Pe.sourceNode,We=[Fe,a],Ze=0,He=Xe.match(Ue)||[],Ye={},Ce=0,$e=He.length;Ce<$e;++Ce){var qe=He[Ce],ae=Ye[qe],J=void 0,$;if(typeof ae=="string")$=!1;else{var re=_e[qe.charAt(0)];if(re)J=qe.match(re[1]),ae=re[0];else{for(var oe=0;oe<ke;++oe)if(re=Ee[oe],J=qe.match(re[1]),J){ae=re[0];break}J||(ae=a)}$=ae.length>=5&&ae.substring(0,5)==="lang-",$&&!(J&&typeof J[1]=="string")&&($=!1,ae=x),$||(Ye[qe]=ae)}var q=Ze;if(Ze+=qe.length,!$)We.push(Fe+q,ae);else{var Z=J[1],se=qe.indexOf(Z),le=se+Z.length;J[2]&&(le=qe.length-J[2].length,se=le-Z.length);var pe=ae.substring(5);ne(Ne,Fe+q,qe.substring(0,se),Oe,We),ne(Ne,Fe+q+se,Z,W(pe,Z),We),ne(Ne,Fe+q+le,qe.substring(le),Oe,We)}}Pe.decorations=We};return Oe}function Ie(de){var Ee=[],_e=[];de.tripleQuotedStrings?Ee.push([p,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):de.multiLineStrings?Ee.push([p,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Ee.push([p,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),de.verbatimStrings&&_e.push([p,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Ue=de.hashComments;Ue&&(de.cStyleComments?(Ue>1?Ee.push([v,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Ee.push([v,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),_e.push([p,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Ee.push([v,/^#[^\r\n]*/,null,"#"])),de.cStyleComments&&(_e.push([v,/^\/\/[^\r\n]*/,null]),_e.push([v,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var ke=de.regexLiterals;if(ke){var Oe=ke>1?"":`
|
|
\r`,Pe=Oe?".":"[\\S\\s]",Xe="/(?=[^/*"+Oe+"])(?:[^/\\x5B\\x5C"+Oe+"]|\\x5C"+Pe+"|\\x5B(?:[^\\x5C\\x5D"+Oe+"]|\\x5C"+Pe+")*(?:\\x5D|$))+/";_e.push(["lang-regex",RegExp("^"+ie+"("+Xe+")")])}var Fe=de.types;Fe&&_e.push([c,Fe]);var Ne=(""+de.keywords).replace(/^ | $/g,"");Ne.length&&_e.push([_,new RegExp("^(?:"+Ne.replace(/[\s,]+/g,"|")+")\\b"),null]),Ee.push([a,/^\s+/,null,` \r
|
|
\xA0`]);var We="^.[^\\s\\w.$@'\"`/\\\\]*";return de.regexLiterals&&(We+="(?!s*/)"),_e.push([h,/^@[a-z_$][a-z_$@0-9]*/i,null],[c,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[h,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[l,new RegExp(We),null]),be(Ee,_e)}var Te=Ie({keywords:T,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function De(de,Ee,_e){for(var Ue=/(?:^|\s)nocode(?:\s|$)/,ke=/\r\n?|\n/,Oe=de.ownerDocument,Pe=Oe.createElement("li");de.firstChild;)Pe.appendChild(de.firstChild);var Xe=[Pe];function Fe(Ce){var $e=Ce.nodeType;if($e==1&&!Ue.test(Ce.className))if(Ce.nodeName==="br")Ne(Ce),Ce.parentNode&&Ce.parentNode.removeChild(Ce);else for(var qe=Ce.firstChild;qe;qe=qe.nextSibling)Fe(qe);else if(($e==3||$e==4)&&_e){var ae=Ce.nodeValue,J=ae.match(ke);if(J){var $=ae.substring(0,J.index);Ce.nodeValue=$;var re=ae.substring(J.index+J[0].length);if(re){var oe=Ce.parentNode;oe.insertBefore(Oe.createTextNode(re),Ce.nextSibling)}Ne(Ce),$||Ce.parentNode.removeChild(Ce)}}}function Ne(Ce){for(;!Ce.nextSibling;)if(Ce=Ce.parentNode,!Ce)return;function $e(J,$){var re=$?J.cloneNode(!1):J,oe=J.parentNode;if(oe){var q=$e(oe,1),Z=J.nextSibling;q.appendChild(re);for(var se=Z;se;se=Z)Z=se.nextSibling,q.appendChild(se)}return re}for(var qe=$e(Ce.nextSibling,0),ae;(ae=qe.parentNode)&&ae.nodeType===1;)qe=ae;Xe.push(qe)}for(var We=0;We<Xe.length;++We)Fe(Xe[We]);Ee===(Ee|0)&&Xe[0].setAttribute("value",Ee);var Ze=Oe.createElement("ol");Ze.className="linenums";for(var He=Math.max(0,Ee-1|0)||0,We=0,Ye=Xe.length;We<Ye;++We)Pe=Xe[We],Pe.className="L"+(We+He)%10,Pe.firstChild||Pe.appendChild(Oe.createTextNode("\xA0")),Ze.appendChild(Pe);de.appendChild(Ze)}function we(de){var Ee=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Ee=Ee&&+Ee[1]<=8;var _e=/\n/g,Ue=de.sourceCode,ke=Ue.length,Oe=0,Pe=de.spans,Xe=Pe.length,Fe=0,Ne=de.decorations,We=Ne.length,Ze=0;Ne[We]=ke;var He,Ye;for(Ye=He=0;Ye<We;)Ne[Ye]!==Ne[Ye+2]?(Ne[He++]=Ne[Ye++],Ne[He++]=Ne[Ye++]):Ye+=2;for(We=He,Ye=He=0;Ye<We;){for(var Ce=Ne[Ye],$e=Ne[Ye+1],qe=Ye+2;qe+2<=We&&Ne[qe+1]===$e;)qe+=2;Ne[He++]=Ce,Ne[He++]=$e,Ye=qe}We=Ne.length=He;var ae=de.sourceNode,J="";ae&&(J=ae.style.display,ae.style.display="none");try{for(var $=null;Fe<Xe;){var re=Pe[Fe],oe=Pe[Fe+2]||ke,q=Ne[Ze+2]||ke,qe=Math.min(oe,q),Z=Pe[Fe+1],se;if(Z.nodeType!==1&&(se=Ue.substring(Oe,qe))){Ee&&(se=se.replace(_e,"\r")),Z.nodeValue=se;var le=Z.ownerDocument,pe=le.createElement("span");pe.className=Ne[Ze+1];var ye=Z.parentNode;ye.replaceChild(pe,Z),pe.appendChild(Z),Oe<oe&&(Pe[Fe+1]=Z=le.createTextNode(Ue.substring(qe,oe)),ye.insertBefore(Z,pe.nextSibling))}Oe=qe,Oe>=oe&&(Fe+=2),Oe>=q&&(Ze+=2)}}finally{ae&&(ae.style.display=J)}}var Ae={};function ve(de,Ee){for(var _e=Ee.length;--_e>=0;){var Ue=Ee[_e];Ae.hasOwnProperty(Ue)?B.console&&console.warn("cannot override language handler %s",Ue):Ae[Ue]=de}}function W(de,Ee){return de&&Ae.hasOwnProperty(de)||(de=/^\s*</.test(Ee)?"default-markup":"default-code"),Ae[de]}ve(Te,["default-code"]),ve(be([],[[a,/^[^<?]+/],[f,/^<!\w[^>]*(?:>|$)/],[v,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[l,/^(?:<[%?]|[%?]>)/],["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"]),ve(be([[a,/^[\s]+/,null,` \r
|
|
`],[G,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[g,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[l,/^[=<>\/]+/],["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"]),ve(be([],[[G,/^[\s\S]+/]]),["uq.val"]),ve(Ie({keywords:w,hashComments:!0,cStyleComments:!0,types:m}),["c","cc","cpp","cxx","cyc","m"]),ve(Ie({keywords:"null,true,false"}),["json"]),ve(Ie({keywords:A,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:m}),["cs"]),ve(Ie({keywords:O,cStyleComments:!0}),["java"]),ve(Ie({keywords:u,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),ve(Ie({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),ve(Ie({keywords:d,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),ve(Ie({keywords:s,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),ve(Ie({keywords:C,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),ve(Ie({keywords:S,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),ve(be([],[[p,/^[\s\S]+/]]),["regex"]);function L(de){var Ee=de.langExtension;try{var _e=F(de.sourceNode,de.pre),Ue=_e.sourceCode;de.sourceCode=Ue,de.spans=_e.spans,de.basePos=0,W(Ee,Ue)(de),we(de)}catch(ke){B.console&&console.log(ke&&ke.stack||ke)}}function k(de,Ee,_e){var Ue=_e||!1,ke=Ee||null,Oe=document.createElement("div");Oe.innerHTML="<pre>"+de+"</pre>",Oe=Oe.firstChild,Ue&&De(Oe,Ue,!0);var Pe={langExtension:ke,numberLines:Ue,sourceNode:Oe,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return L(Pe),Oe.innerHTML}function H(de,Ee){var _e=Ee||document.body,Ue=_e.ownerDocument||document;function ke(re){return _e.getElementsByTagName(re)}for(var Oe=[ke("pre"),ke("code"),ke("xmp")],Pe=[],Xe=0;Xe<Oe.length;++Xe)for(var Fe=0,Ne=Oe[Xe].length;Fe<Ne;++Fe)Pe.push(Oe[Xe][Fe]);Oe=null;var We=Date;We.now||(We={now:function(){return+new Date}});var Ze=0,He=/\blang(?:uage)?-([\w.]+)(?!\S)/,Ye=/\bprettyprint\b/,Ce=/\bprettyprinted\b/,$e=/pre|xmp/i,qe=/^code$/i,ae=/^(?:pre|code|xmp)$/i,J={};function $(){for(var re=B.PR_SHOULD_USE_CONTINUATION?We.now()+250:Infinity;Ze<Pe.length&&We.now()<re;Ze++){for(var oe=Pe[Ze],q=J,Z=oe;Z=Z.previousSibling;){var se=Z.nodeType,le=(se===7||se===8)&&Z.nodeValue;if(le?!/^\??prettify\b/.test(le):se!==3||/\S/.test(Z.nodeValue))break;if(le){q={},le.replace(/\b(\w+)=([\w:.%+-]+)/g,function(St,yt,rr){q[yt]=rr});break}}var pe=oe.className;if((q!==J||Ye.test(pe))&&!Ce.test(pe)){for(var ye=!1,Le=oe.parentNode;Le;Le=Le.parentNode){var Me=Le.tagName;if(ae.test(Me)&&Le.className&&Ye.test(Le.className)){ye=!0;break}}if(!ye){oe.className+=" prettyprinted";var et=q.lang;if(!et){et=pe.match(He);var rt;!et&&(rt=ge(oe))&&qe.test(rt.tagName)&&(et=rt.className.match(He)),et&&(et=et[1])}var Tt;if($e.test(oe.tagName))Tt=1;else{var ot=oe.currentStyle,Ve=Ue.defaultView,vt=ot?ot.whiteSpace:Ve&&Ve.getComputedStyle?Ve.getComputedStyle(oe,null).getPropertyValue("white-space"):0;Tt=vt&&vt.substring(0,3)==="pre"}var st=q.linenums;(st=st==="true"||+st)||(st=pe.match(/\blinenums\b(?::(\d+))?/),st=st?st[1]&&st[1].length?+st[1]:!0:!1),st&&De(oe,st,Tt);var Lt={langExtension:et,sourceNode:oe,numberLines:st,pre:Tt,sourceCode:null,basePos:null,spans:null,decorations:null};L(Lt)}}}Ze<Pe.length?B.setTimeout($,250):typeof de=="function"&&de()}$()}var ee=B.PR={createSimpleLexer:be,registerLangHandler:ve,sourceDecorator:Ie,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:G,PR_COMMENT:v,PR_DECLARATION:f,PR_KEYWORD:_,PR_LITERAL:h,PR_NOCODE:X,PR_PLAIN:a,PR_PUNCTUATION:l,PR_SOURCE:x,PR_STRING:p,PR_TAG:g,PR_TYPE:c,prettyPrintOne:D?B.prettyPrintOne=k:y=k,prettyPrint:j=D?B.prettyPrint=H:j=H},U=B.define;typeof U=="function"&&U.amd&&U("google-code-prettify",[],function(){return ee})})()},STEk:function(gt,at,ue){"use strict";ue.d(at,"a",function(){return ve});/*! *****************************************************************************
|
|
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 fe=function(W,L){return(fe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(k,H){k.__proto__=H}||function(k,H){for(var ee in H)Object.prototype.hasOwnProperty.call(H,ee)&&(k[ee]=H[ee])})(W,L)};function Q(W,L){function k(){this.constructor=W}fe(W,L),W.prototype=L===null?Object.create(L):(k.prototype=L.prototype,new k)}function D(W,L,k,H){return new(k||(k=Promise))(function(ee,U){function de(Ue){try{_e(H.next(Ue))}catch(ke){U(ke)}}function Ee(Ue){try{_e(H.throw(Ue))}catch(ke){U(ke)}}function _e(Ue){var ke;Ue.done?ee(Ue.value):(ke=Ue.value,ke instanceof k?ke:new k(function(Oe){Oe(ke)})).then(de,Ee)}_e((H=H.apply(W,L||[])).next())})}function V(W,L){var k,H,ee,U,de={label:0,sent:function(){if(1&ee[0])throw ee[1];return ee[1]},trys:[],ops:[]};return U={next:Ee(0),throw:Ee(1),return:Ee(2)},typeof Symbol=="function"&&(U[Symbol.iterator]=function(){return this}),U;function Ee(_e){return function(Ue){return function(ke){if(k)throw new TypeError("Generator is already executing.");for(;de;)try{if(k=1,H&&(ee=2&ke[0]?H.return:ke[0]?H.throw||((ee=H.return)&&ee.call(H),0):H.next)&&!(ee=ee.call(H,ke[1])).done)return ee;switch(H=0,ee&&(ke=[2&ke[0],ee.value]),ke[0]){case 0:case 1:ee=ke;break;case 4:return de.label++,{value:ke[1],done:!1};case 5:de.label++,H=ke[1],ke=[0];continue;case 7:ke=de.ops.pop(),de.trys.pop();continue;default:if(!(ee=de.trys,(ee=ee.length>0&&ee[ee.length-1])||ke[0]!==6&&ke[0]!==2)){de=0;continue}if(ke[0]===3&&(!ee||ke[1]>ee[0]&&ke[1]<ee[3])){de.label=ke[1];break}if(ke[0]===6&&de.label<ee[1]){de.label=ee[1],ee=ke;break}if(ee&&de.label<ee[2]){de.label=ee[2],de.ops.push(ke);break}ee[2]&&de.ops.pop(),de.trys.pop();continue}ke=L.call(W,de)}catch(Oe){ke=[6,Oe],H=0}finally{k=ee=0}if(5&ke[0])throw ke[1];return{value:ke[0]?ke[1]:void 0,done:!0}}([_e,Ue])}}}function I(){for(var W=0,L=0,k=arguments.length;L<k;L++)W+=arguments[L].length;var H=Array(W),ee=0;for(L=0;L<k;L++)for(var U=arguments[L],de=0,Ee=U.length;de<Ee;de++,ee++)H[ee]=U[de];return H}var y=function(){function W(){}return W.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},W.setAttributes=function(L,k){for(var H=0,ee=k;H<ee.length;H++){var U=ee[H],de=U[0],Ee=U[1];L.setAttribute(de,Ee)}},W.createRect=function(L,k,H){var ee=document.createElementNS("http://www.w3.org/2000/svg","rect");return ee.setAttribute("width",L.toString()),ee.setAttribute("height",k.toString()),H&&W.setAttributes(ee,H),ee},W.createLine=function(L,k,H,ee,U){var de=document.createElementNS("http://www.w3.org/2000/svg","line");return de.setAttribute("x1",L.toString()),de.setAttribute("y1",k.toString()),de.setAttribute("x2",H.toString()),de.setAttribute("y2",ee.toString()),U&&W.setAttributes(de,U),de},W.createPolygon=function(L,k){var H=document.createElementNS("http://www.w3.org/2000/svg","polygon");return H.setAttribute("points",L),k&&W.setAttributes(H,k),H},W.createCircle=function(L,k){var H=document.createElementNS("http://www.w3.org/2000/svg","circle");return H.setAttribute("cx",(L/2).toString()),H.setAttribute("cy",(L/2).toString()),H.setAttribute("r",L.toString()),k&&W.setAttributes(H,k),H},W.createEllipse=function(L,k,H){var ee=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return ee.setAttribute("cx",(L/2).toString()),ee.setAttribute("cy",(k/2).toString()),ee.setAttribute("rx",(L/2).toString()),ee.setAttribute("ry",(k/2).toString()),H&&W.setAttributes(ee,H),ee},W.createGroup=function(L){var k=document.createElementNS("http://www.w3.org/2000/svg","g");return L&&W.setAttributes(k,L),k},W.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},W.createMarker=function(L,k,H,ee,U,de,Ee){var _e=document.createElementNS("http://www.w3.org/2000/svg","marker");return W.setAttributes(_e,[["id",L],["orient",k],["markerWidth",H.toString()],["markerHeight",ee.toString()],["refX",U.toString()],["refY",de.toString()]]),_e.appendChild(Ee),_e},W.createText=function(L){var k=document.createElementNS("http://www.w3.org/2000/svg","text");return k.setAttribute("x","0"),k.setAttribute("y","0"),L&&W.setAttributes(k,L),k},W.createTSpan=function(L,k){var H=document.createElementNS("http://www.w3.org/2000/svg","tspan");return H.textContent=L,k&&W.setAttributes(H,k),H},W.createImage=function(L){var k=document.createElementNS("http://www.w3.org/2000/svg","image");return L&&W.setAttributes(k,L),k},W.createPoint=function(L,k){var H=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return H.x=L,H.y=k,H},W.createPath=function(L,k){var H=document.createElementNS("http://www.w3.org/2000/svg","path");return H.setAttribute("d",L),k&&W.setAttributes(H,k),H},W}(),j=function(){function W(){}return W.addKey=function(L){W.key=L},Object.defineProperty(W,"isLicensed",{get:function(){return!!W.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(W.key)},enumerable:!1,configurable:!0}),W}(),B=function(){function W(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return W.prototype.rasterize=function(L,k,H){var ee=this;return new Promise(function(U){var de=H!==void 0?H:document.createElement("canvas");L===null&&(ee.markersOnly=!0,ee.naturalSize=!1);var Ee=document.createElementNS("http://www.w3.org/2000/svg","svg");Ee.setAttribute("xmlns","http://www.w3.org/2000/svg"),Ee.setAttribute("width",k.width.baseVal.valueAsString),Ee.setAttribute("height",k.height.baseVal.valueAsString),Ee.setAttribute("viewBox","0 0 "+k.viewBox.baseVal.width.toString()+" "+k.viewBox.baseVal.height.toString()),Ee.innerHTML=k.innerHTML,ee.naturalSize===!0?(Ee.width.baseVal.value=L.naturalWidth,Ee.height.baseVal.value=L.naturalHeight):ee.width!==void 0&&ee.height!==void 0&&(Ee.width.baseVal.value=ee.width,Ee.height.baseVal.value=ee.height),de.width=Ee.width.baseVal.value,de.height=Ee.height.baseVal.value;var _e=Ee.outerHTML,Ue=de.getContext("2d");ee.markersOnly!==!0&&Ue.drawImage(L,0,0,de.width,de.height);var ke=window.URL,Oe=new Image(de.width,de.height);Oe.setAttribute("crossOrigin","anonymous");var Pe=new Blob([_e],{type:"image/svg+xml"}),Xe=ke.createObjectURL(Pe);Oe.onload=function(){Ue.drawImage(Oe,0,0),ke.revokeObjectURL(Xe);var Fe=de.toDataURL(ee.imageType,ee.imageQuality);U(Fe)},Oe.src=Xe})},W}(),M=function(){},R=function(){function W(L){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+L+"_"}return Object.defineProperty(W.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(W.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(W.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),W.prototype.addClass=function(L){return this.styleSheet===void 0&&this.addStyleSheet(),L.name=""+this.classNamePrefix+L.localName,this.classes.push(L),this.styleSheet.sheet.insertRule("."+L.name+" {"+L.style+"}",this.styleSheet.sheet.cssRules.length),L},W.prototype.addRule=function(L){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(L),this.styleSheet.sheet.insertRule(L.selector+" {"+L.style+"}",this.styleSheet.sheet.cssRules.length)},W.prototype.addStyleSheet=function(){var L;this.styleSheet=document.createElement("style"),((L=this.styleSheetRoot)!==null&&L!==void 0?L:document.head).appendChild(this.styleSheet),this.addRule(new b("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new b("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new b("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new w("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new w("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},W.prototype.removeStyleSheet=function(){var L;this.styleSheet&&(((L=this.styleSheetRoot)!==null&&L!==void 0?L:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},W}(),b=function(W,L){this.selector=W,this.style=L},w=function(W,L){this.localName=W,this.style=L},O=function(){function W(L,k,H,ee,U){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=L,this.displayMode=k,this.markerItems=H,this.uiStyleSettings=ee,this.styles=U,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return W.prototype.show=function(L){var k=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=L,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var H=document.createElement("div");H.className=this.toolbarBlockStyleClass.name,H.style.whiteSpace="nowrap",this.uiContainer.appendChild(H),this.addActionButton(H,'<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(H,'<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(H,'<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(H,'<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(H,'<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(H,'<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(H,'<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(H,'<svg viewBox="0 0 24 24"><path d="M18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 002 2h6v-1.87l.13-.13H5V5h7v7h6.13M14 4.5l5.5 5.5H14V4.5m5.13 9.33l2.04 2.04L15.04 22H13v-2.04l6.13-6.13m3.72.36l-.98.98-2.04-2.04.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72z"/></svg>',"notes"),this.markerButtonBlock=document.createElement("div"),this.markerButtonBlock.className=this.toolbarBlockStyleClass.name,this.markerButtonBlock.style.flexGrow="2",this.markerButtonBlock.style.textAlign="center",this.uiContainer.appendChild(this.markerButtonBlock),this.markerButtonOverflowBlock=document.createElement("div"),this.markerButtonOverflowBlock.className=this.toolbarOverflowBlockStyleClass.name+" "+(this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName?this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName:this.toolbarOverflowBlockStyleColorsClass.name),this.markerButtonOverflowBlock.style.display="none",this.uiContainer.appendChild(this.markerButtonOverflowBlock),this.markerItems&&(this.markerItems.forEach(function(U){var de=document.createElement("div");de.className=""+k.toolbarButtonStyleClass.name,de.setAttribute("data-type-name",U.typeName),de.innerHTML=U.icon,de.addEventListener("click",function(){k.markerToolbarButtonClicked(de,U)}),k.buttons.push(de),k.markerButtons.push(de)}),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 ee=document.createElement("div");ee.className=this.toolbarBlockStyleClass.name,ee.style.whiteSpace="nowrap",ee.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(ee),this.addActionButton(ee,'<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(ee,'<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()},W.prototype.addButtonClickListener=function(L){this.buttonClickListeners.push(L)},W.prototype.removeButtonClickListener=function(L){this.buttonClickListeners.indexOf(L)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(L),1)},W.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},W.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var L=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var k=0;k<this.markerButtons.length;k++)k<L||k===L&&this.markerButtons.length-1===L?this.markerButtonBlock.appendChild(this.markerButtons[k]):(k===L&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[k]))}},W.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")},W.prototype.resetButtonStyles=function(){var L=this;this.buttons.forEach(function(k){k.className=k.className.replace(L.uiStyleSettings.toolbarButtonStyleColorsClassName?L.uiStyleSettings.toolbarButtonStyleColorsClassName:L.toolbarButtonStyleColorsClass.name,"").trim(),k.className=k.className.replace(L.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?L.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:L.toolbarActiveButtonStyleColorsClass.name,"").trim(),k.className+=" "+(L.uiStyleSettings.toolbarButtonStyleColorsClassName?L.uiStyleSettings.toolbarButtonStyleColorsClassName:L.toolbarButtonStyleColorsClass.name)})},W.prototype.addActionButton=function(L,k,H){var ee=this,U=document.createElement("div");switch(U.className=""+this.toolbarButtonStyleClass.name,U.innerHTML=k,U.setAttribute("data-action",H),U.addEventListener("click",function(){ee.actionToolbarButtonClicked(U,H)}),H){case"select":U.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":U.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":U.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":U.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":U.style.fill=this.uiStyleSettings.closeButtonColor}L.appendChild(U),this.buttons.push(U)},W.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new w("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 w("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new w("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new w("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 w("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var L=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new w("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*L)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*L)+`px;
|
|
padding: `+L+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new w("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new w("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new b("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new b("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},W.prototype.markerToolbarButtonClicked=function(L,k){this.setActiveButton(L),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(H){return H("marker",k)}),this.markerButtonOverflowBlock.style.display="none"},W.prototype.actionToolbarButtonClicked=function(L,k){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(H){return H("action",k)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},W.prototype.setActiveButton=function(L){this.resetButtonStyles(),L.className=L.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),L.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},W.prototype.setActiveMarkerButton=function(L){var k=this.markerButtons.find(function(H){return H.getAttribute("data-type-name")===L});k&&this.setActiveButton(k)},W.prototype.setCurrentMarker=function(L){var k=this;this.currentMarker=L,this.buttons.filter(function(H){return/delete|notes/.test(H.getAttribute("data-action"))}).forEach(function(H){k.currentMarker===void 0?(H.style.fillOpacity="0.4",H.style.pointerEvents="none"):(H.style.fillOpacity="1",H.style.pointerEvents="all")})},W}(),A=function(){function W(L,k,H,ee){this.panels=[],this.panelButtons=[],this.markerjsContainer=L,this.displayMode=k,this.uiStyleSettings=H,this.styles=ee,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return W.prototype.addStyles=function(){var L;this.toolboxStyleClass=this.styles.addClass(new w("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 w("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var k=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new w("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new w("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new w("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 w("toolbox-panel-row_colors",`
|
|
background-color: `+((L=this.uiStyleSettings.toolboxBackgroundColor)!==null&&L!==void 0?L:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new w("toolbox_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*k)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*k)+`px;
|
|
padding: `+k+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new w("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new w("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new b("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new b("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},W.prototype.show=function(L){var k;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=L,this.uiContainer.className=this.toolboxStyleClass.name+" "+((k=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&k!==void 0?k:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},W.prototype.setPanelButtons=function(L){var k,H,ee=this;this.panels=L,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((k=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&k!==void 0?k:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((H=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&H!==void 0?H:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(U){var de;U.uiStyleSettings=ee.uiStyleSettings;var Ee=document.createElement("div");Ee.className=ee.toolboxButtonStyleClass.name+" "+((de=ee.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&de!==void 0?de:ee.toolboxButtonStyleColorsClass.name),Ee.innerHTML=U.icon,Ee.title=U.title,Ee.addEventListener("click",function(){ee.panelButtonClick(U)}),ee.panelButtons.push(Ee),ee.buttonRow.appendChild(Ee)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},W.prototype.panelButtonClick=function(L){var k=this,H=-1;if(L!==this.activePanel){H=this.panels.indexOf(L),this.panelRow.innerHTML="";var ee=L.getUi();ee.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(ee),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=L}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){k.displayMode==="inline"?k.panelRow.style.display="none":k.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(U,de){var Ee,_e;U.className=k.toolboxButtonStyleClass.name+" "+(de===H?""+((Ee=k.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Ee!==void 0?Ee:k.toolboxActiveButtonStyleColorsClass.name):""+((_e=k.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&_e!==void 0?_e:k.toolboxButtonStyleColorsClass.name))})},W}(),S=function(W,L){this.title=W,this.icon=L},C=function(W){function L(k,H,ee,U){var de=W.call(this,k,U||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return de.colors=[],de.addTransparent=!1,de.colorBoxes=[],de.colors=H,de.currentColor=ee,de.setCurrentColor=de.setCurrentColor.bind(de),de.getColorBox=de.getColorBox.bind(de),de}return Q(L,W),L.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.overflow="hidden",H.style.whiteSpace="nowrap",this.colors.forEach(function(ee){var U=k.getColorBox(ee);H.appendChild(U),k.colorBoxes.push(U)}),H},L.prototype.getColorBox=function(k){var H=this,ee=this.uiStyleSettings.toolbarHeight/4,U=this.uiStyleSettings.toolbarHeight-ee,de=document.createElement("div");de.style.display="inline-block",de.style.boxSizing="content-box",de.style.width=U-2+"px",de.style.height=U-2+"px",de.style.padding="1px",de.style.marginRight="2px",de.style.marginBottom="2px",de.style.borderWidth="2px",de.style.borderStyle="solid",de.style.borderRadius=(U+2)/2+"px",de.style.borderColor=k===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",de.addEventListener("click",function(){H.setCurrentColor(k,de)});var Ee=document.createElement("div");return Ee.style.display="inline-block",Ee.style.width=U-2+"px",Ee.style.height=U-2+"px",Ee.style.backgroundColor=k,Ee.style.borderRadius=U/2+"px",k==="transparent"&&(Ee.style.fill=this.uiStyleSettings.toolboxAccentColor,Ee.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>`),de.appendChild(Ee),de},L.prototype.setCurrentColor=function(k,H){var ee=this;this.currentColor=k,this.colorBoxes.forEach(function(U){U.style.borderColor=U===H?ee.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(k)},L}(S),d=function(){function W(L,k,H){this._state="new",this._isSelected=!1,this._container=L,this._overlayContainer=k,this.globalSettings=H,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(W.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),W.prototype.ownsTarget=function(L){return!1},Object.defineProperty(W.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),W.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},W.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},W.prototype.pointerDown=function(L,k){},W.prototype.dblClick=function(L,k){},W.prototype.manipulate=function(L){},W.prototype.pointerUp=function(L){this.stateChanged()},W.prototype.dispose=function(){},W.prototype.addMarkerVisualToContainer=function(L){this.container.childNodes.length>0?this.container.insertBefore(L,this.container.childNodes[0]):this.container.appendChild(L)},W.prototype.getState=function(){return{typeName:W.typeName,state:this.state,notes:this.notes}},W.prototype.restoreState=function(L){this._state=L.state,this.notes=L.notes},W.prototype.scale=function(L,k){},W.prototype.colorChanged=function(L){this.onColorChanged&&this.onColorChanged(L),this.stateChanged()},W.prototype.fillColorChanged=function(L){this.onFillColorChanged&&this.onFillColorChanged(L),this.stateChanged()},W.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var L=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),L.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(L)&&this.onStateChanged(this)}},W.typeName="MarkerBase",W}(),o=function(){function W(){this.findGripByVisual=this.findGripByVisual.bind(this)}return W.prototype.findGripByVisual=function(L){return this.topLeft.ownsTarget(L)?this.topLeft:this.topCenter.ownsTarget(L)?this.topCenter:this.topRight.ownsTarget(L)?this.topRight:this.centerLeft.ownsTarget(L)?this.centerLeft:this.centerRight.ownsTarget(L)?this.centerRight:this.bottomLeft.ownsTarget(L)?this.bottomLeft:this.bottomCenter.ownsTarget(L)?this.bottomCenter:this.bottomRight.ownsTarget(L)?this.bottomRight:void 0},W}(),s=function(){function W(){this.GRIP_SIZE=10,this.visual=y.createGroup(),this.visual.appendChild(y.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(y.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return W.prototype.ownsTarget=function(L){return L===this.visual||L===this.visual.childNodes[0]||L===this.visual.childNodes[1]},W}(),u=function(){function W(){}return W.toITransformMatrix=function(L){return{a:L.a,b:L.b,c:L.c,d:L.d,e:L.e,f:L.f}},W.toSVGMatrix=function(L,k){return L.a=k.a,L.b=k.b,L.c=k.c,L.d=k.d,L.e=k.e,L.f=k.f,L},W}(),T=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.left=0,U.top=0,U.width=0,U.height=0,U.defaultSize={x:50,y:20},U.offsetX=0,U.offsetY=0,U.rotationAngle=0,U.CB_DISTANCE=10,U._suppressMarkerCreateEvent=!1,U.container.transform.baseVal.appendItem(y.createTransform()),U.setupControlBox(),U}return Q(L,W),Object.defineProperty(L.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"visual",{get:function(){return this._visual},set:function(k){this._visual=k;var H=y.createTransform();this._visual.transform.baseVal.appendItem(H)},enumerable:!1,configurable:!0}),L.prototype.ownsTarget=function(k){return!!W.prototype.ownsTarget.call(this,k)||!!(this.controlGrips.findGripByVisual(k)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(k))},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.left=k.x,this.top=k.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var ee=this.unrotatePoint(k);if(this.manipulationStartX=ee.x,this.manipulationStartY=ee.y,this.offsetX=ee.x-this.left,this.offsetY=ee.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(H),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(H)){this.activeGrip=this.rotatorGrip;var U=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=U.x-this.width/2,this.top=U.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var de=this.container.transform.baseVal.getItem(0);de.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(de,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},L.prototype.pointerUp=function(k){var H=this.state;W.prototype.pointerUp.call(this,k),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(k),this._state="select",H==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},L.prototype.moveVisual=function(k){this.visual.style.transform="translate("+k.x+"px, "+k.y+"px)"},L.prototype.manipulate=function(k){var H=this.unrotatePoint(k);this.state==="creating"?this.resize(k):this.state==="move"?(this.left=this.manipulationStartLeft+(H.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(H.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(H):this.state==="rotate"&&this.rotate(k)},L.prototype.resize=function(k){var H=this.manipulationStartLeft,ee=this.manipulationStartWidth,U=this.manipulationStartTop,de=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:H=this.manipulationStartLeft+k.x-this.manipulationStartX,ee=this.manipulationStartWidth+this.manipulationStartLeft-H;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:ee=this.manipulationStartWidth+k.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:U=this.manipulationStartTop+k.y-this.manipulationStartY,de=this.manipulationStartHeight+this.manipulationStartTop-U;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:de=this.manipulationStartHeight+k.y-this.manipulationStartY}ee>=0?(this.left=H,this.width=ee):(this.left=H+ee,this.width=-ee),de>=0?(this.top=U,this.height=de):(this.top=U+de,this.height=-de),this.setSize()},L.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},L.prototype.rotate=function(k){if(Math.abs(k.x-this.centerX)>.1){var H=Math.sign(k.x-this.centerX);this.rotationAngle=180*Math.atan((k.y-this.centerY)/(k.x-this.centerX))/Math.PI+90*H,this.applyRotation()}},L.prototype.applyRotation=function(){var k=this.container.transform.baseVal.getItem(0);k.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(k,0)},L.prototype.rotatePoint=function(k){if(this.rotationAngle===0)return k;var H=this.container.getCTM(),ee=y.createPoint(k.x,k.y);return{x:(ee=ee.matrixTransform(H)).x,y:ee.y}},L.prototype.unrotatePoint=function(k){if(this.rotationAngle===0)return k;var H=this.container.getCTM();H=H.inverse();var ee=y.createPoint(k.x,k.y);return{x:(ee=ee.matrixTransform(H)).x,y:ee.y}},L.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},L.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},L.prototype.setupControlBox=function(){this.controlBox=y.createGroup();var k=y.createTransform();k.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(k),this.container.appendChild(this.controlBox),this.controlRect=y.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=y.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 o,this.addControlGrips(),this.controlBox.style.display="none"},L.prototype.adjustControlBox=function(){var k=this.controlBox.transform.baseVal.getItem(0);k.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(k,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()},L.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()},L.prototype.createGrip=function(){var k=new s;return k.visual.transform.baseVal.appendItem(y.createTransform()),this.controlBox.appendChild(k.visual),k},L.prototype.positionGrips=function(){var k=this.controlGrips.topLeft.GRIP_SIZE,H=-k/2,ee=H,U=(this.width+this.CB_DISTANCE)/2-k/2,de=(this.height+this.CB_DISTANCE)/2-k/2,Ee=this.height+this.CB_DISTANCE-k/2,_e=this.width+this.CB_DISTANCE-k/2;this.positionGrip(this.controlGrips.topLeft.visual,H,ee),this.positionGrip(this.controlGrips.topCenter.visual,U,ee),this.positionGrip(this.controlGrips.topRight.visual,_e,ee),this.positionGrip(this.controlGrips.centerLeft.visual,H,de),this.positionGrip(this.controlGrips.centerRight.visual,_e,de),this.positionGrip(this.controlGrips.bottomLeft.visual,H,Ee),this.positionGrip(this.controlGrips.bottomCenter.visual,U,Ee),this.positionGrip(this.controlGrips.bottomRight.visual,_e,Ee),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,U,ee-3*this.CB_DISTANCE)},L.prototype.positionGrip=function(k,H,ee){var U=k.transform.baseVal.getItem(0);U.setTranslate(H,ee),k.transform.baseVal.replaceItem(U,0)},L.prototype.hideControlBox=function(){this.controlBox.style.display="none"},L.prototype.showControlBox=function(){this.controlBox.style.display=""},L.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:u.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:u.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},W.prototype.getState.call(this))},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.left=H.left,this.top=H.top,this.width=H.width,this.height=H.height,this.rotationAngle=H.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(u.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,H.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(u.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,H.containerTransformMatrix))},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H);var ee=this.rotatePoint({x:this.left,y:this.top}),U=this.unrotatePoint({x:ee.x*k,y:ee.y*H});this.left=U.x,this.top=U.y,this.width=this.width*k,this.height=this.height*H,this.adjustControlBox()},L}(d),m=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.fillColor="transparent",U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.opacity=1,U.setStrokeColor=U.setStrokeColor.bind(U),U.setFillColor=U.setFillColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.createVisual=U.createVisual.bind(U),U}return Q(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual)},L.prototype.createVisual=function(){this.visual=y.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)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.createVisual(),this.moveVisual(k),this._state="creating")},L.prototype.manipulate=function(k){W.prototype.manipulate.call(this,k)},L.prototype.resize=function(k){W.prototype.resize.call(this,k),this.setSize()},L.prototype.setSize=function(){W.prototype.setSize.call(this),y.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},L.prototype.pointerUp=function(k){W.prototype.pointerUp.call(this,k),this.setSize()},L.prototype.setStrokeColor=function(k){this.strokeColor=k,this.visual&&y.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(k),this.stateChanged()},L.prototype.setFillColor=function(k){this.fillColor=k,this.visual&&y.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},L.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.visual&&y.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},L.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.visual&&y.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},L.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},W.prototype.getState.call(this))},L.prototype.restoreState=function(k){var H=k;this.fillColor=H.fillColor,this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.opacity=H.opacity,this.createVisual(),W.prototype.restoreState.call(this,k),this.setSize()},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setSize()},L.title="Rectangle marker",L}(T),p=function(W){function L(k,H,ee,U){var de=W.call(this,k,U||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return de.widths=[],de.widthBoxes=[],de.widths=H,de.currentWidth=ee,de.setCurrentWidth=de.setCurrentWidth.bind(de),de}return Q(L,W),L.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2",this.widths.forEach(function(ee){var U=document.createElement("div");U.style.display="flex",U.style.flexGrow="2",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.borderColor=ee===k.currentWidth?k.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){k.setCurrentWidth(ee,U)}),H.appendChild(U);var de=document.createElement("div");de.innerText=ee.toString(),de.style.marginRight="5px",U.appendChild(de);var Ee=document.createElement("div");Ee.style.minHeight="20px",Ee.style.flexGrow="2",Ee.style.display="flex",Ee.style.alignItems="center";var _e=document.createElement("hr");_e.style.minWidth="20px",_e.style.border="0px",_e.style.borderTop=ee+"px solid "+k.uiStyleSettings.toolboxColor,_e.style.flexGrow="2",Ee.appendChild(_e),U.appendChild(Ee),k.widthBoxes.push(U)}),H},L.prototype.setCurrentWidth=function(k,H){var ee=this;this.currentWidth=k,this.widthBoxes.forEach(function(U){U.style.borderColor=U===H?ee.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},L}(S),_=function(W){function L(k,H,ee,U){var de=W.call(this,k,U||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return de.styles=[],de.styleBoxes=[],de.styles=H,de.currentStyle=ee,de.setCurrentStyle=de.setCurrentStyle.bind(de),de}return Q(L,W),L.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2",this.styles.forEach(function(ee){var U=document.createElement("div");U.style.display="flex",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.overflow="hidden",U.style.maxWidth=100/k.styles.length-5+"%",U.style.borderColor=ee===k.currentStyle?k.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){k.setCurrentStyle(ee,U)}),H.appendChild(U);var de=document.createElement("div");de.style.minHeight="20px",de.style.flexGrow="2",de.style.overflow="hidden";var Ee=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+k.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(ee!==""?'stroke-dasharray="'+ee+'"':"")+` />
|
|
</svg>`;de.innerHTML=Ee,U.appendChild(de),k.styleBoxes.push(U)}),H},L.prototype.setCurrentStyle=function(k,H){var ee=this;this.currentStyle=k,this.styleBoxes.forEach(function(U){U.style.borderColor=U===H?ee.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},L}(S),v=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.strokeColor=ee.defaultColor,U.strokeWidth=ee.defaultStrokeWidth,U.strokeDasharray=ee.defaultStrokeDasharray,U.strokePanel=new C("Line color",ee.defaultColorSet,ee.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new p("Line width",ee.defaultStrokeWidths,ee.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new _("Line style",ee.defaultStrokeDasharrays,ee.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Q(L,W),Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=L.typeName,k},L.typeName="FrameMarker",L.title="Frame marker",L.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',L}(m),c=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},h=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.x1=0,U.y1=0,U.x2=0,U.y2=0,U.defaultLength=50,U.manipulationStartX=0,U.manipulationStartY=0,U.manipulationStartX1=0,U.manipulationStartY1=0,U.manipulationStartX2=0,U.manipulationStartY2=0,U.setupControlBox(),U}return Q(L,W),L.prototype.ownsTarget=function(k){return!!W.prototype.ownsTarget.call(this,k)||!(!this.grip1.ownsTarget(k)&&!this.grip2.ownsTarget(k))},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.manipulationStartX=k.x,this.manipulationStartY=k.y,this.state==="new"&&(this.x1=k.x,this.y1=k.y,this.x2=k.x,this.y2=k.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(H)?this.activeGrip=this.grip1:this.grip2.ownsTarget(H)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},L.prototype.pointerUp=function(k){var H=this.state;W.prototype.pointerUp.call(this,k),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(k),this._state="select",H==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},L.prototype.adjustVisual=function(){},L.prototype.manipulate=function(k){this.state==="creating"?this.resize(k):this.state==="move"?(this.x1=this.manipulationStartX1+k.x-this.manipulationStartX,this.y1=this.manipulationStartY1+k.y-this.manipulationStartY,this.x2=this.manipulationStartX2+k.x-this.manipulationStartX,this.y2=this.manipulationStartY2+k.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(k)},L.prototype.resize=function(k){switch(this.activeGrip){case this.grip1:this.x1=k.x,this.y1=k.y;break;case this.grip2:case void 0:this.x2=k.x,this.y2=k.y}this.adjustVisual(),this.adjustControlBox()},L.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},L.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},L.prototype.setupControlBox=function(){this.controlBox=y.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},L.prototype.adjustControlBox=function(){this.positionGrips()},L.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},L.prototype.createGrip=function(){var k=new s;return k.visual.transform.baseVal.appendItem(y.createTransform()),this.controlBox.appendChild(k.visual),k},L.prototype.positionGrips=function(){var k=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-k/2,this.y1-k/2),this.positionGrip(this.grip2.visual,this.x2-k/2,this.y2-k/2)},L.prototype.positionGrip=function(k,H,ee){var U=k.transform.baseVal.getItem(0);U.setTranslate(H,ee),k.transform.baseVal.replaceItem(U,0)},L.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},W.prototype.getState.call(this))},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.x1=H.x1,this.y1=H.y1,this.x2=H.x2,this.y2=H.y2},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.x1=this.x1*k,this.y1=this.y1*H,this.x2=this.x2*k,this.y2=this.y2*H,this.adjustVisual(),this.adjustControlBox()},L}(d),l=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.setStrokeColor=U.setStrokeColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.strokeColor=ee.defaultColor,U.strokeWidth=ee.defaultStrokeWidth,U.strokeDasharray=ee.defaultStrokeDasharray,U.strokePanel=new C("Line color",ee.defaultColorSet,ee.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new p("Line width",ee.defaultStrokeWidths,ee.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new _("Line style",ee.defaultStrokeDasharrays,ee.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Q(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual&&k!==this.selectorLine&&k!==this.visibleLine)},L.prototype.createVisual=function(){this.visual=y.createGroup(),this.selectorLine=y.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=y.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)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},L.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()),y.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),y.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),y.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},L.prototype.setStrokeColor=function(k){this.strokeColor=k,this.adjustVisual(),this.colorChanged(k)},L.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.adjustVisual()},L.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.adjustVisual(),this.stateChanged()},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.createVisual(),this.adjustVisual()},L.typeName="LineMarker",L.title="Line marker",L.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',L}(h),a=function(W){function L(k,H,ee,U){var de=W.call(this,k,U||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return de.fonts=[],de.fontBoxes=[],de.fonts=H,de.currentFont=ee,de.setCurrentFont=de.setCurrentFont.bind(de),de}return Q(L,W),L.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.overflow="hidden",H.style.flexGrow="2",this.fonts.forEach(function(ee){var U=document.createElement("div");U.style.display="inline-block",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.overflow="hidden",U.style.maxWidth=100/k.fonts.length-5+"%",U.style.borderColor=ee===k.currentFont?k.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){k.setCurrentFont(ee,U)}),H.appendChild(U);var de=document.createElement("div");de.style.display="flex",de.style.minHeight="20px",de.style.flexGrow="2",de.style.fontFamily=ee,de.style.overflow="hidden";var Ee=document.createElement("div");Ee.style.whiteSpace="nowrap",Ee.style.overflow="hidden",Ee.style.textOverflow="ellipsis",Ee.innerHTML="The quick brown fox jumps over the lazy dog",de.appendChild(Ee),U.appendChild(de),k.fontBoxes.push(U)}),H},L.prototype.setCurrentFont=function(k,H){var ee=this;this.currentFont=k,this.fontBoxes.forEach(function(U){U.style.borderColor=U===H?ee.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},L}(S),g=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.color="transparent",U.padding=5,U.DEFAULT_TEXT="your text here",U.text=U.DEFAULT_TEXT,U.isMoved=!1,U.color=ee.defaultColor,U.fontFamily=ee.defaultFontFamily,U.defaultSize={x:100,y:30},U.setColor=U.setColor.bind(U),U.setFont=U.setFont.bind(U),U.renderText=U.renderText.bind(U),U.sizeText=U.sizeText.bind(U),U.textEditDivClicked=U.textEditDivClicked.bind(U),U.showTextEditor=U.showTextEditor.bind(U),U.setSize=U.setSize.bind(U),U.positionTextEditor=U.positionTextEditor.bind(U),U.colorPanel=new C("Color",ee.defaultColorSet,ee.defaultColor),U.colorPanel.onColorChanged=U.setColor,U.fontFamilyPanel=new a("Font",ee.defaultFontFamilies,ee.defaultFontFamily),U.fontFamilyPanel.onFontChanged=U.setFont,U}return Q(L,W),L.prototype.ownsTarget=function(k){if(W.prototype.ownsTarget.call(this,k)||k===this.visual||k===this.textElement||k===this.bgRectangle)return!0;var H=!1;return this.textElement.childNodes.forEach(function(ee){ee===k&&(H=!0)}),H},L.prototype.createVisual=function(){this.visual=y.createGroup(),this.bgRectangle=y.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=y.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(y.createTransform()),this.textElement.transform.baseVal.appendItem(y.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.isMoved=!1,this.pointerDownPoint=k,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(k),this._state="creating")},L.prototype.renderText=function(){var k=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(H){k.textElement.appendChild(y.createTSpan(H.trim()===""?" ":H.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},L.prototype.getTextScale=function(){var k=this.textElement.getBBox(),H=1;if(k.width>0&&k.height>0){var ee=(1*this.width-this.width*this.padding*2/100)/k.width,U=(1*this.height-this.height*this.padding*2/100)/k.height;H=Math.min(ee,U)}return H},L.prototype.getTextPosition=function(k){var H=this.textElement.getBBox(),ee=0,U=0;return H.width>0&&H.height>0&&(ee=(this.width-H.width*k)/2,U=this.height/2-H.height*k/2),{x:ee,y:U}},L.prototype.sizeText=function(){var k=this.textElement.getBBox(),H=this.getTextScale(),ee=this.getTextPosition(H);ee.y-=k.y*H,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+ee.x+"px, "+ee.y+"px) scale("+H+", "+H+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(ee.x,ee.y),this.textElement.transform.baseVal.getItem(1).setScale(H,H))},L.prototype.manipulate=function(k){W.prototype.manipulate.call(this,k),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(k.x-this.pointerDownPoint.x)>5||Math.abs(k.y-this.pointerDownPoint.y)>5)},L.prototype.resize=function(k){W.prototype.resize.call(this,k),this.isMoved=!0,this.setSize(),this.sizeText()},L.prototype.setSize=function(){W.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(y.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),y.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},L.prototype.pointerUp=function(k){var H=this.state;H==="creating"&&(this._suppressMarkerCreateEvent=!0),W.prototype.pointerUp.call(this,k),this.setSize(),(H==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},L.prototype.showTextEditor=function(){var k=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(H){H.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var H=Number.parseFloat(k.textEditor.style.fontSize);k.textEditor.clientWidth>=Number.parseInt(k.textEditor.style.maxWidth)&&H>.9;)H-=.1,k.textEditor.style.fontSize=Math.max(H,.9)+"em"}),this.textEditor.addEventListener("keyup",function(H){H.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(H){if(H.clipboardData){var ee=H.clipboardData.getData("text"),U=window.getSelection();if(!U.rangeCount)return!1;U.deleteFromDocument(),U.getRangeAt(0).insertNode(document.createTextNode(ee)),H.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){k.textEditDivClicked(k.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},L.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var k=this.getTextScale(),H=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),ee=this.textElement.getBBox(),U={x:ee.width*k,y:ee.height*k};H.x-=U.x/2,H.y-=U.y/2,this.textEditor.style.top=H.y+"px",this.textEditor.style.left=H.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-H.x+"px",this.textEditor.style.fontSize=Math.max(16*k,12)+"px",this.textElement.style.display="none"}},L.prototype.textEditDivClicked=function(k){this.text=k.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},L.prototype.select=function(){W.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},L.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),W.prototype.deselect.call(this)},L.prototype.dblClick=function(k,H){W.prototype.dblClick.call(this,k,H),this.showTextEditor()},L.prototype.setColor=function(k){this.textElement&&y.setAttributes(this.textElement,[["fill",k]]),this.color=k,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(k)},L.prototype.setFont=function(k){this.textElement&&y.setAttributes(this.textElement,[["font-family",k]]),this.fontFamily=k,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},L.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},L.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){var H=k;this.color=H.color,this.fontFamily=H.fontFamily,this.padding=H.padding,this.text=H.text,this.createVisual(),W.prototype.restoreState.call(this,k),this.setSize()},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setSize(),this.sizeText(),this.positionTextEditor()},L.typeName="TextMarker",L.title="Text marker",L.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>',L}(T),f=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.color="transparent",U.lineWidth=3,U.drawing=!1,U.pixelRatio=1,U.color=ee.defaultColor,U.lineWidth=ee.defaultStrokeWidth,U.pixelRatio=ee.freehandPixelRatio,U.setColor=U.setColor.bind(U),U.addCanvas=U.addCanvas.bind(U),U.finishCreation=U.finishCreation.bind(U),U.setLineWidth=U.setLineWidth.bind(U),U.colorPanel=new C("Color",ee.defaultColorSet,ee.defaultColor),U.colorPanel.onColorChanged=U.setColor,U.lineWidthPanel=new p("Line width",ee.defaultStrokeWidths,ee.defaultStrokeWidth),U.lineWidthPanel.onWidthChanged=U.setLineWidth,U}return Q(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual&&k!==this.drawingImage)},L.prototype.createVisual=function(){this.visual=y.createGroup(),this.drawingImage=y.createImage(),this.visual.appendChild(this.drawingImage);var k=y.createTransform();this.visual.transform.baseVal.appendItem(k),this.addMarkerVisualToContainer(this.visual)},L.prototype.pointerDown=function(k,H){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(k.x,k.y),this.drawing=!0):W.prototype.pointerDown.call(this,k,H)},L.prototype.manipulate=function(k){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(k.x,k.y),this.canvasContext.stroke()):W.prototype.manipulate.call(this,k)},L.prototype.resize=function(k){W.prototype.resize.call(this,k),y.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),y.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},L.prototype.pointerUp=function(k){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):W.prototype.pointerUp.call(this,k)},L.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)},L.prototype.select=function(){this.state==="creating"&&this.finishCreation(),W.prototype.select.call(this)},L.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),W.prototype.deselect.call(this)},L.prototype.finishCreation=function(){for(var k=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),H=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],ee=H[0],U=H[1],de=H[2],Ee=H[3],_e=!1,Ue=0;Ue<this.canvasElement.height;Ue++)for(var ke=0;ke<this.canvasElement.width;ke++)k.data[Ue*this.canvasElement.width*4+4*ke+3]>0&&(_e=!0,Ue<U&&(U=Ue),ke<ee&&(ee=ke),Ue>Ee&&(Ee=Ue),ke>de&&(de=ke));if(_e){this.left=ee/this.pixelRatio,this.top=U/this.pixelRatio,this.width=(de-ee)/this.pixelRatio,this.height=(Ee-U)/this.pixelRatio;var Oe=document.createElement("canvas");Oe.width=de-ee,Oe.height=Ee-U,Oe.getContext("2d").putImageData(this.canvasContext.getImageData(ee,U,de-ee,Ee-U),0,0),this.drawingImgUrl=Oe.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},L.prototype.setDrawingImage=function(){y.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),y.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},L.prototype.setColor=function(k){this.color=k,this.colorChanged(k)},L.prototype.setLineWidth=function(k){this.lineWidth=k},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({drawingImgUrl:this.drawingImgUrl},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){this.createVisual(),W.prototype.restoreState.call(this,k),this.drawingImgUrl=k.drawingImgUrl,this.setDrawingImage()},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setDrawingImage()},L.typeName="FreehandMarker",L.title="Freehand marker",L.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>',L}(T),x=function(W){function L(k,H,ee){var U=W.call(this,k,ee||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return U.typeBoxes=[],U.currentType=H,U.setCurrentType=U.setCurrentType.bind(U),U}return Q(L,W),L.prototype.getUi=function(){var k=this,H=document.createElement("div");H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2";for(var ee=function(Ee){var _e="both";switch(Ee){case 0:_e="both";break;case 1:_e="start";break;case 2:_e="end";break;case 3:_e="none"}var Ue=document.createElement("div");if(Ue.style.display="flex",Ue.style.flexGrow="2",Ue.style.alignItems="center",Ue.style.justifyContent="space-between",Ue.style.padding="5px",Ue.style.borderWidth="2px",Ue.style.borderStyle="solid",Ue.style.borderColor=_e===U.currentType?U.uiStyleSettings.toolboxAccentColor:"transparent",Ue.addEventListener("click",function(){k.setCurrentType(_e,Ue)}),H.appendChild(Ue),_e==="both"||_e==="start"){var ke=document.createElement("div");ke.style.display="flex",ke.style.alignItems="center",ke.style.minHeight="20px",ke.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,5 10,0 10,10" fill="`+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,ke.style.marginLeft="5px",Ue.appendChild(ke)}var Oe=document.createElement("div");Oe.style.display="flex",Oe.style.alignItems="center",Oe.style.minHeight="20px",Oe.style.flexGrow="2";var Pe=document.createElement("hr");if(Pe.style.minWidth="20px",Pe.style.border="0px",Pe.style.borderTop="3px solid "+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee"),Pe.style.flexGrow="2",Oe.appendChild(Pe),Ue.appendChild(Oe),_e==="both"||_e==="end"){var Xe=document.createElement("div");Xe.style.display="flex",Xe.style.alignItems="center",Xe.style.minHeight="20px",Xe.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,0 10,5 0,10" fill="`+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Xe.style.marginRight="5px",Ue.appendChild(Xe)}U.typeBoxes.push(Ue)},U=this,de=0;de<4;de++)ee(de);return H},L.prototype.setCurrentType=function(k,H){var ee=this;this.currentType=k,this.typeBoxes.forEach(function(U){U.style.borderColor=U===H?ee.uiStyleSettings!==void 0?ee.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},L}(S),P=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.arrowType="end",U.arrowBaseHeight=10,U.arrowBaseWidth=10,U.getArrowPoints=U.getArrowPoints.bind(U),U.setArrowType=U.setArrowType.bind(U),U.arrowTypePanel=new x("Arrow type","end"),U.arrowTypePanel.onArrowTypeChanged=U.setArrowType,U}return Q(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.arrow1&&k!==this.arrow2)},L.prototype.getArrowPoints=function(k,H){var ee=this.arrowBaseWidth+2*this.strokeWidth,U=this.arrowBaseHeight+2*this.strokeWidth;return k-ee/2+","+(H+U/2)+" "+k+","+(H-U/2)+" "+(k+ee/2)+","+(H+U/2)},L.prototype.createTips=function(){this.arrow1=y.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(y.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=y.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(y.createTransform()),this.visual.appendChild(this.arrow2)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="creating"&&this.createTips()},L.prototype.adjustVisual=function(){if(W.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",y.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),y.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var k=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),H=this.arrow1.transform.baseVal.getItem(0);H.setRotate(k,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(H,0);var ee=this.arrow2.transform.baseVal.getItem(0);ee.setRotate(k+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(ee,0)}},L.prototype.setArrowType=function(k){this.arrowType=k,this.adjustVisual(),this.stateChanged()},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({arrowType:this.arrowType},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.arrowType=H.arrowType,this.createTips(),this.adjustVisual()},L.typeName="ArrowMarker",L.title="Arrow marker",L.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',L}(l),G=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.fillColor=ee.defaultFillColor,U.strokeWidth=0,U.fillPanel=new C("Color",ee.defaultColorSet,ee.defaultFillColor),U.fillPanel.onColorChanged=U.setFillColor,U}return Q(L,W),Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=L.typeName,k},L.typeName="CoverMarker",L.title="Cover marker",L.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',L}(m),X=function(W){function L(k,H,ee,U){var de=W.call(this,k,U||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return de.opacities=[],de.opacityBoxes=[],de.opacities=H,de.currentOpacity=ee,de.setCurrentOpacity=de.setCurrentOpacity.bind(de),de}return Q(L,W),L.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2",H.style.justifyContent="space-between",this.opacities.forEach(function(ee){var U=document.createElement("div");U.style.display="flex",U.style.alignItems="center",U.style.justifyContent="center",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.borderColor=ee===k.currentOpacity?k.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){k.setCurrentOpacity(ee,U)}),H.appendChild(U);var de=document.createElement("div");de.innerText=100*ee+"%",U.appendChild(de),k.opacityBoxes.push(U)}),H},L.prototype.setCurrentOpacity=function(k,H){var ee=this;this.currentOpacity=k,this.opacityBoxes.forEach(function(U){U.style.borderColor=U===H?ee.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},L}(S),ie=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.setOpacity=U.setOpacity.bind(U),U.fillColor=ee.defaultHighlightColor,U.strokeWidth=0,U.opacity=ee.defaultHighlightOpacity,U.fillPanel=new C("Color",ee.defaultColorSet,U.fillColor),U.fillPanel.onColorChanged=U.setFillColor,U.opacityPanel=new X("Opacity",ee.defaultOpacitySteps,U.opacity),U.opacityPanel.onOpacityChanged=U.setOpacity,U}return Q(L,W),L.prototype.setOpacity=function(k){this.opacity=k,this.visual&&y.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=L.typeName,k},L.typeName="HighlightMarker",L.title="Highlight marker",L.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>',L}(G),z='<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>',F=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.bgColor="transparent",U.tipPosition={x:0,y:0},U.tipBase1Position={x:0,y:0},U.tipBase2Position={x:0,y:0},U.tipMoving=!1,U.color=ee.defaultStrokeColor,U.bgColor=ee.defaultFillColor,U.fontFamily=ee.defaultFontFamily,U.defaultSize={x:100,y:30},U.setBgColor=U.setBgColor.bind(U),U.getTipPoints=U.getTipPoints.bind(U),U.positionTip=U.positionTip.bind(U),U.setTipPoints=U.setTipPoints.bind(U),U.colorPanel=new C("Text color",ee.defaultColorSet,U.color,'<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>'),U.colorPanel.onColorChanged=U.setColor,U.bgColorPanel=new C("Fill color",ee.defaultColorSet,U.bgColor,z),U.bgColorPanel.onColorChanged=U.setBgColor,U.fontFamilyPanel=new a("Font",ee.defaultFontFamilies,ee.defaultFontFamily),U.fontFamilyPanel.onFontChanged=U.setFont,U.tipGrip=new s,U.tipGrip.visual.transform.baseVal.appendItem(y.createTransform()),U.controlBox.appendChild(U.tipGrip.visual),U}return Q(L,W),L.prototype.ownsTarget=function(k){return W.prototype.ownsTarget.call(this,k)||this.tipGrip.ownsTarget(k)||this.tip===k},L.prototype.createTip=function(){y.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=y.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},L.prototype.pointerDown=function(k,H){this.state==="new"&&W.prototype.pointerDown.call(this,k,H),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(H)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):W.prototype.pointerDown.call(this,k,H)},L.prototype.pointerUp=function(k){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,W.prototype.pointerUp.call(this,k);else{var H=this.state==="creating";W.prototype.pointerUp.call(this,k),this.setTipPoints(H),this.positionTip()}},L.prototype.manipulate=function(k){if(this.tipMoving){var H=this.unrotatePoint(k);this.tipPosition={x:H.x-this.manipulationStartLeft,y:H.y-this.manipulationStartTop},this.positionTip()}else W.prototype.manipulate.call(this,k)},L.prototype.setBgColor=function(k){this.bgRectangle&&this.tip&&(y.setAttributes(this.bgRectangle,[["fill",k]]),y.setAttributes(this.tip,[["fill",k]])),this.bgColor=k,this.fillColorChanged(k)},L.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},L.prototype.setTipPoints=function(k){k===void 0&&(k=!1);var H=Math.min(this.height/2,15),ee=this.height/5;k&&(this.tipPosition={x:H+ee/2,y:this.height+20});var U=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?U<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(ee=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:H,y:0},this.tipBase2Position={x:H+ee,y:0}):(this.tipBase1Position={x:0,y:H},this.tipBase2Position={x:0,y:H+ee}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?U<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(ee=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-H-ee,y:0},this.tipBase2Position={x:this.width-H,y:0}):(this.tipBase1Position={x:this.width,y:H},this.tipBase2Position={x:this.width,y:H+ee}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?U<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(ee=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-H-ee,y:this.height},this.tipBase2Position={x:this.width-H,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-H-ee},this.tipBase2Position={x:this.width,y:this.height-H}):U<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(ee=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:H,y:this.height},this.tipBase2Position={x:H+ee,y:this.height}):(this.tipBase1Position={x:0,y:this.height-H},this.tipBase2Position={x:0,y:this.height-H-ee})},L.prototype.resize=function(k){W.prototype.resize.call(this,k),this.positionTip()},L.prototype.positionTip=function(){y.setAttributes(this.tip,[["points",this.getTipPoints()]]);var k=this.tipGrip.visual.transform.baseVal.getItem(0);k.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(k,0)},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),L.prototype.select=function(){this.positionTip(),W.prototype.select.call(this)},L.prototype.getState=function(){var k=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){var H=k;this.bgColor=H.bgColor,this.tipPosition=H.tipPosition,W.prototype.restoreState.call(this,k),this.createTip(),this.setTipPoints()},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.tipPosition={x:this.tipPosition.x*k,y:this.tipPosition.y*H},this.positionTip()},L.typeName="CalloutMarker",L.title="Callout marker",L.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>',L}(g),ne=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.fillColor="transparent",U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.opacity=1,U.strokeColor=ee.defaultColor,U.strokeWidth=ee.defaultStrokeWidth,U.strokeDasharray=ee.defaultStrokeDasharray,U.fillColor=ee.defaultFillColor,U.setStrokeColor=U.setStrokeColor.bind(U),U.setFillColor=U.setFillColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.setOpacity=U.setOpacity.bind(U),U.createVisual=U.createVisual.bind(U),U.strokePanel=new C("Line color",I(ee.defaultColorSet,["transparent"]),ee.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.fillPanel=new C("Fill color",I(ee.defaultColorSet,["transparent"]),U.fillColor,z),U.fillPanel.onColorChanged=U.setFillColor,U.strokeWidthPanel=new p("Line width",ee.defaultStrokeWidths,ee.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new _("Line style",ee.defaultStrokeDasharrays,ee.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U.opacityPanel=new X("Opacity",ee.defaultOpacitySteps,U.opacity),U.opacityPanel.onOpacityChanged=U.setOpacity,U}return Q(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual)},L.prototype.createVisual=function(){this.visual=y.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)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.createVisual(),this.moveVisual(k),this._state="creating")},L.prototype.manipulate=function(k){W.prototype.manipulate.call(this,k)},L.prototype.resize=function(k){W.prototype.resize.call(this,k),this.setSize()},L.prototype.setSize=function(){W.prototype.setSize.call(this),y.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},L.prototype.pointerUp=function(k){W.prototype.pointerUp.call(this,k),this.setSize()},L.prototype.setStrokeColor=function(k){this.strokeColor=k,this.visual&&y.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(k),this.stateChanged()},L.prototype.setFillColor=function(k){this.fillColor=k,this.visual&&y.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(k),this.stateChanged()},L.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.visual&&y.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},L.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.visual&&y.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},L.prototype.setOpacity=function(k){this.opacity=k,this.visual&&y.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){var H=k;this.fillColor=H.fillColor,this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.opacity=H.opacity,this.createVisual(),W.prototype.restoreState.call(this,k),this.setSize()},L.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setSize()},L.typeName="EllipseMarker",L.title="Ellipse marker",L.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>',L}(T),ce=function(W){function L(k,H,ee){return W.call(this,k,H,ee)||this}return Q(L,W),Object.defineProperty(L.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.tip1&&k!==this.tip2)},L.prototype.createTips=function(){this.tip1=y.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(y.createTransform()),this.visual.appendChild(this.tip1),this.tip2=y.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(y.createTransform()),this.visual.appendChild(this.tip2)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="creating"&&this.createTips()},L.prototype.adjustVisual=function(){if(W.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(y.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()]]),y.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 k=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),H=this.tip1.transform.baseVal.getItem(0);H.setRotate(k,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(H,0);var ee=this.tip2.transform.baseVal.getItem(0);ee.setRotate(k+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(ee,0)}},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k),this.createTips(),this.adjustVisual()},L.typeName="MeasurementMarker",L.title="Measurement marker",L.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>',L}(l),ge=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.strokePanel.colors=ee.defaultColorSet,U.fillColor="transparent",U}return Q(L,W),Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=L.typeName,k},L.typeName="EllipseFrameMarker",L.title="Ellipse frame marker",L.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>',L}(ne),be=function(){function W(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(W.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),W.prototype.addUndoStep=function(L){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(L)||(this.undoStack.push(L),JSON.stringify(this.lastRedoStep)!==JSON.stringify(L)&&this.redoStack.splice(0,this.redoStack.length))},W.prototype.replaceLastUndoStep=function(L){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=L)},W.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},W.prototype.undo=function(){if(this.undoStack.length>1){var L=this.undoStack.pop();return L!==void 0&&this.redoStack.push(L),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},W.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},W}(),Ie=function(W){function L(k,H,ee){var U=W.call(this,k,H,ee)||this;return U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.curveX=0,U.curveY=0,U.manipulationStartCurveX=0,U.manipulationStartCurveY=0,U.setStrokeColor=U.setStrokeColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.positionGrips=U.positionGrips.bind(U),U.addControlGrips=U.addControlGrips.bind(U),U.adjustVisual=U.adjustVisual.bind(U),U.setupControlBox=U.setupControlBox.bind(U),U.resize=U.resize.bind(U),U.strokeColor=ee.defaultColor,U.strokeWidth=ee.defaultStrokeWidth,U.strokeDasharray=ee.defaultStrokeDasharray,U.strokePanel=new C("Line color",ee.defaultColorSet,ee.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new p("Line width",ee.defaultStrokeWidths,ee.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new _("Line style",ee.defaultStrokeDasharrays,ee.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Q(L,W),L.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual&&k!==this.selectorCurve&&k!==this.visibleCurve&&!this.curveGrip.ownsTarget(k))},L.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},L.prototype.createVisual=function(){this.visual=y.createGroup(),this.selectorCurve=y.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=y.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)},L.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=k.x,this.curveY=k.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(H)&&(this.activeGrip=this.curveGrip,this._state="resize")},L.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),y.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),y.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),y.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},L.prototype.setupControlBox=function(){W.prototype.setupControlBox.call(this),this.curveControlLine1=y.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=y.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)},L.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,W.prototype.addControlGrips.call(this)},L.prototype.positionGrips=function(){W.prototype.positionGrips.call(this);var k=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-k/2,this.curveY-k/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()))},L.prototype.manipulate=function(k){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+k.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+k.y-this.manipulationStartY),W.prototype.manipulate.call(this,k)},L.prototype.resize=function(k){this.activeGrip===this.curveGrip&&(this.curveX=k.x,this.curveY=k.y),W.prototype.resize.call(this,k),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},L.prototype.setStrokeColor=function(k){this.strokeColor=k,this.adjustVisual(),this.colorChanged(k)},L.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.adjustVisual()},L.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.adjustVisual()},L.prototype.scale=function(k,H){this.curveX=this.curveX*k,this.curveY=this.curveY*H,W.prototype.scale.call(this,k,H)},Object.defineProperty(L.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),L.prototype.getState=function(){var k=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},W.prototype.getState.call(this));return k.typeName=L.typeName,k},L.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.curveX=H.curveX,this.curveY=H.curveY,this.createVisual(),this.adjustVisual()},L.typeName="CurveMarker",L.title="Curve marker",L.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>',L}(h),Te=function(){function W(L,k){k===void 0&&(k=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=L,this.cancelable=k}return Object.defineProperty(W.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),W.prototype.preventDefault=function(){this._defaultPrevented=!0},W}(),De=function(W){function L(k,H,ee){var U=W.call(this,k,!1)||this;return U.dataUrl=H,U.state=ee,U}return Q(L,W),L}(Te),we=function(W){function L(k,H,ee){ee===void 0&&(ee=!1);var U=W.call(this,k,ee)||this;return U.marker=H,U}return Q(L,W),L}(Te),Ae=function(){function W(){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 W.prototype.addEventListener=function(L,k){this[L].push(k)},W.prototype.removeEventListener=function(L,k){var H=this[L].indexOf(k);H>-1&&this[L].splice(H,1)},W}(),ve=function(){function W(L){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new c,this._isOpen=!1,this.undoRedoManager=new be,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 Ae,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=W.instanceCounter++,this.styles=new R(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=L,this.targetRoot=document.body,this.width=L.clientWidth,this.height=L.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(W.prototype,"ALL_MARKER_TYPES",{get:function(){return[v,f,P,g,ge,ne,ie,F,ce,G,l,Ie]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[v,f,P,g,ne,ie,F]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"BASIC_MARKER_TYPES",{get:function(){return[v,f,P,g,ie]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(L){var k=this;this._availableMarkerTypes.splice(0),L.forEach(function(H){if(typeof H=="string"){var ee=k.ALL_MARKER_TYPES.find(function(U){return U.typeName===H});ee!==void 0&&k._availableMarkerTypes.push(ee)}else k._availableMarkerTypes.push(H)})},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(L){this._zoomLevel=L,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(W.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),W.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),j.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},W.prototype.show=function(){var L=this;this.styles.styleSheetRoot===void 0&&M.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=M.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(k){return k(new Te(L))})},W.prototype.render=function(){return D(this,void 0,void 0,function(){var L;return V(this,function(k){switch(k.label){case 0:return this.setCurrentMarker(),(L=new B).naturalSize=this.renderAtNaturalSize,L.imageType=this.renderImageType,L.imageQuality=this.renderImageQuality,L.markersOnly=this.renderMarkersOnly,L.width=this.renderWidth,L.height=this.renderHeight,[4,L.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return k.sent(),[4,L.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,k.sent()]}})})},W.prototype.close=function(L){var k=this;if(L===void 0&&(L=!1),this.isOpen){var H=!1;L||this.eventListeners.beforeclose.forEach(function(ee){var U=new Te(k,!0);ee(U),U.defaultPrevented&&(H=!0)}),H||(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(ee){return ee(new Te(k))}),this.detachEvents(),this._isOpen=!1)}},W.prototype.addMarkersToToolbar=function(){for(var L,k=[],H=0;H<arguments.length;H++)k[H]=arguments[H];(L=this._availableMarkerTypes).push.apply(L,k)},W.prototype.addRenderEventListener=function(L){this.addEventListener("render",function(k){L(k.dataUrl,k.state)})},W.prototype.removeRenderEventListener=function(L){},W.prototype.addCloseEventListener=function(L){this.addEventListener("close",function(){L()})},W.prototype.removeCloseEventListener=function(L){},W.prototype.setupResizeObserver=function(){var L=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){L.resize(L.target.clientWidth,L.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return L.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},W.prototype.onPopupTargetResize=function(){var L=1*this.target.clientWidth/this.target.clientHeight,k=this.editorCanvas.clientWidth/L>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*L:this.editorCanvas.clientWidth,H=k<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/L;this.resize(k,H)},W.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},W.prototype.resize=function(L,k){this._isResizing=!0;var H=L/this.imageWidth,ee=k/this.imageHeight;this.imageWidth=Math.round(L),this.imageHeight=Math.round(k),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(H,ee),this._isResizing=!1},W.prototype.scaleMarkers=function(L,k){var H,ee=this;this._currentMarker&&this._currentMarker instanceof g?this._currentMarker.scale(L,k):(H=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(U){U!==ee._currentMarker&&U.scale(L,k)}),H!==void 0&&this.setCurrentMarker(H)},W.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"},W.prototype.setTopLeft=function(){var L=this.editingTarget.getBoundingClientRect(),k=this.editorCanvas.getBoundingClientRect();this.left=L.left-k.left,this.top=L.top-k.top},W.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)},W.prototype.addDefs=function(){for(var L,k=[],H=0;H<arguments.length;H++)k[H]=arguments[H];this.defs=y.createDefs(),this.addDefsToImage(),(L=this.defs).append.apply(L,k)},W.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},W.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)},W.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},W.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},W.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)},W.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},W.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)},W.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 L=document.createElement("a");L.href="https://markerjs.com/",L.target="_blank",L.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>',L.title="Powered by marker.js",L.style.display="grid",L.style.alignItems="center",L.style.justifyItems="center",L.style.padding="3px",L.style.width="20px",L.style.height="20px",this.logoUI.appendChild(L),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},W.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")},W.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"},W.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},W.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 L=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=L+"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 O(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 A(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},W.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},W.prototype.removeMarker=function(L){this.markerImage.removeChild(L.container),this.markers.indexOf(L)>-1&&this.markers.splice(this.markers.indexOf(L),1),L.dispose()},W.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())},W.prototype.toolbarButtonClicked=function(L,k){if(L==="marker"&&k!==void 0)this.createNewMarker(k);else if(L==="action")switch(k){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()}},W.prototype.deleteSelectedMarker=function(){var L=this;if(this._currentMarker!==void 0){var k=!1;if(this.eventListeners.markerbeforedelete.forEach(function(ee){var U=new we(L,L._currentMarker,!0);ee(U),U.defaultPrevented&&(k=!0)}),!k){var H=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(ee){return ee(new we(L,H))})}}},W.prototype.clear=function(){var L=this,k=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(de){var Ee=new we(L,void 0,!0);de(Ee),Ee.defaultPrevented&&(k=!0)}),!k)){this.setCurrentMarker();for(var H=function(de){var Ee=ee.markers[de];ee.setCurrentMarker(ee.markers[de]),ee._currentMarker.dispose(),ee.markerImage.removeChild(ee._currentMarker.container),ee.markers.splice(ee.markers.indexOf(ee._currentMarker),1),ee.eventListeners.markerdelete.forEach(function(_e){return _e(new we(L,Ee))})},ee=this,U=this.markers.length-1;U>=0;U--)H(U);this.addUndoStep()}},Object.defineProperty(W.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),W.prototype.showNotesEditor=function(){var L;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=(L=this._currentMarker.notes)!==null&&L!==void 0?L:"",this.overlayContainer.appendChild(this.notesArea))},W.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)},W.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},W.prototype.addUndoStep=function(){var L=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var k=this.getState(),H=this.undoRedoManager.getLastUndoStep();if(!H||H.width===k.width&&H.height===k.height){var ee=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(k),ee<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(U){return U(new Te(L))})}else this.undoRedoManager.replaceLastUndoStep(k),this.eventListeners.statechange.forEach(function(U){return U(new Te(L))})}},W.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},W.prototype.undoStep=function(){var L=this,k=this.undoRedoManager.undo();k!==void 0&&(this.restoreState(k),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(H){return H(new Te(L))}))},W.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},W.prototype.redoStep=function(){var L=this,k=this.undoRedoManager.redo();k!==void 0&&(this.restoreState(k),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(H){return H(new Te(L))}))},W.prototype.stepZoom=function(){var L=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=L<this.zoomSteps.length-1?this.zoomSteps[L+1]:this.zoomSteps[0]},W.prototype.panTo=function(L){this.contentDiv.scrollBy({left:this.prevPanPoint.x-L.x,top:this.prevPanPoint.y-L.y}),this.prevPanPoint=L},W.prototype.startRenderAndClose=function(){return D(this,void 0,void 0,function(){var L,k,H=this;return V(this,function(ee){switch(ee.label){case 0:return[4,this.render()];case 1:return L=ee.sent(),k=this.getState(),this.eventListeners.render.forEach(function(U){return U(new De(H,L,k))}),this.close(!0),[2]}})})},W.prototype.getState=function(L){L===!0&&this.setCurrentMarker();var k={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(H){return k.markers.push(H.getState())}),k},W.prototype.restoreState=function(L){var k=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);L.markers.forEach(function(H){var ee=k._availableMarkerTypes.find(function(de){return de.typeName===H.typeName});if(ee!==void 0){var U=k.addNewMarker(ee);U.restoreState(H),k.markers.push(U)}}),L.width&&L.height&&(L.width!==this.imageWidth||L.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/L.width,this.imageHeight/L.height),this.eventListeners.restorestate.forEach(function(H){return H(new Te(k))})},W.prototype.addNewMarker=function(L){var k=y.createGroup();return this.markerImage.appendChild(k),new L(k,this.overlayContainer,this.settings)},W.prototype.createNewMarker=function(L){var k,H=this;(k=typeof L=="string"?this._availableMarkerTypes.find(function(ee){return ee.typeName===L}):L)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(k),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(k.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(ee){return ee(new we(H,H._currentMarker))}))},W.prototype.markerCreated=function(L){var k=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(L),this.setCurrentMarker(L),L instanceof f&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(f):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(H){return H(new we(k,k._currentMarker))})},W.prototype.colorChanged=function(L){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=L,this.settings.defaultStrokeColor=L)},W.prototype.fillColorChanged=function(L){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=L)},W.prototype.markerStateChanged=function(L){var k=this;this.eventListeners.markerchange.forEach(function(H){return H(new we(k,L))})},W.prototype.setCurrentMarker=function(L){var k=this;this._currentMarker!==L&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(H){return H(new we(k,k._currentMarker))})),this._currentMarker=L,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(H){return H(new we(k,k._currentMarker))}))},W.prototype.onPointerDown=function(L){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||L.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var k=this.markers.find(function(H){return H.ownsTarget(L.target)});k!==void 0?(this.setCurrentMarker(k),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(L.clientX,L.clientY),L.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:L.clientX,y:L.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(L.clientX,L.clientY))},W.prototype.onDblClick=function(L){if(this._isFocused||this.focus(),this.mode==="select"){var k=this.markers.find(function(H){return H.ownsTarget(L.target)});k!==void 0&&k!==this._currentMarker&&this.setCurrentMarker(k),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(L.clientX,L.clientY),L.target):this.setCurrentMarker()}},W.prototype.onPointerMove=function(L){this.touchPoints!==1&&L.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||L.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(L.clientX,L.clientY)):this.zoomLevel>1&&this.panTo({x:L.clientX,y:L.clientY}))},W.prototype.onPointerUp=function(L){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(L.clientX,L.clientY)),this.isDragging=!1,this.addUndoStep()},W.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},W.prototype.onKeyUp=function(L){this._currentMarker===void 0||this.notesArea!==void 0||L.key!=="Delete"&&L.key!=="Backspace"||this.deleteSelectedMarker()},W.prototype.clientToLocalCoordinates=function(L,k){var H=this.markerImage.getBoundingClientRect();return{x:(L-H.left)/this.zoomLevel,y:(k-H.top)/this.zoomLevel}},W.prototype.onWindowResize=function(){this.positionUI()},W.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var L=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=L+"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()},W.prototype.addLicenseKey=function(L){j.addKey(L)},W.prototype.addEventListener=function(L,k){this.eventListeners.addEventListener(L,k)},W.prototype.removeEventListener=function(L,k){this.eventListeners.removeEventListener(L,k)},W.prototype.renderState=function(L){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(L),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(W.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),W.prototype.focus=function(){var L=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(k){return k(new Te(L))}))},W.prototype.blur=function(){var L=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(k){return k(new Te(L))}))},W.instanceCounter=0,W}()},UZu5:function(gt,at,ue){},"VrN/":function(gt,at,ue){(function(fe,Q){gt.exports=Q()})(this,function(){"use strict";var fe=navigator.userAgent,Q=navigator.platform,D=/gecko\/\d/i.test(fe),V=/MSIE \d/.test(fe),I=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(fe),y=/Edge\/(\d+)/.exec(fe),j=V||I||y,B=j&&(V?document.documentMode||6:+(y||I)[1]),M=!y&&/WebKit\//.test(fe),R=M&&/Qt\/\d+\.\d+/.test(fe),b=!y&&/Chrome\//.test(fe),w=/Opera\//.test(fe),O=/Apple Computer/.test(navigator.vendor),A=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(fe),S=/PhantomJS/.test(fe),C=!y&&/AppleWebKit/.test(fe)&&/Mobile\/\w+/.test(fe),d=/Android/.test(fe),o=C||d||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(fe),s=C||/Mac/.test(Q),u=/\bCrOS\b/.test(fe),T=/win/i.test(Q),m=w&&fe.match(/Version\/(\d*\.\d*)/);m&&(m=Number(m[1])),m&&m>=15&&(w=!1,M=!0);var p=s&&(R||w&&(m==null||m<12.11)),_=D||j&&B>=9;function v(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var c=function(e,t){var i=e.className,r=v(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 h(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function l(e,t){return h(e).appendChild(t)}function a(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var E=0;E<t.length;++E)n.appendChild(t[E]);return n}function g(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var f;document.createRange?f=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:f=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 P(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function G(e,t){var i=e.className;v(t).test(i)||(e.className+=(i?" ":"")+t)}function X(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!v(i[r]).test(t)&&(t+=" "+i[r]);return t}var ie=function(e){e.select()};C?ie=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:j&&(ie=function(e){try{e.select()}catch(t){}});function z(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function F(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 ne(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var E=r||0,N=n||0;;){var K=e.indexOf(" ",E);if(K<0||K>=t)return N+(t-E);N+=K-E,N+=i-N%i,E=K+1}}var ce=function(){this.id=null,this.f=null,this.time=0,this.handler=z(this.onTimeout,this)};ce.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},ce.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 ge(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var be=50,Ie={toString:function(){return"CodeMirror.Pass"}},Te={scroll:!1},De={origin:"*mouse"},we={origin:"+move"};function Ae(e,t,i){for(var r=0,n=0;;){var E=e.indexOf(" ",r);E==-1&&(E=e.length);var N=E-r;if(E==e.length||n+N>=t)return r+Math.min(N,t-n);if(n+=E-r,n+=i-n%i,r=E+1,n>=t)return r}}var ve=[""];function W(e){for(;ve.length<=e;)ve.push(L(ve)+" ");return ve[e]}function L(e){return e[e.length-1]}function k(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function H(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function ee(){}function U(e,t){var i;return Object.create?i=Object.create(e):(ee.prototype=e,i=new ee),t&&F(t,i),i}var de=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Ee(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||de.test(e))}function _e(e,t){return t?t.source.indexOf("\\w")>-1&&Ee(e)?!0:t.test(e):Ee(e)}function Ue(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ke=/[\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 Oe(e){return e.charCodeAt(0)>=768&&ke.test(e)}function Pe(e,t,i){for(;(i<0?t>0:t<e.length)&&Oe(e.charAt(t));)t+=i;return t}function Xe(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,E=r<0?Math.ceil(n):Math.floor(n);if(E==t)return e(E)?t:i;e(E)?i=E:t=E+r}}function Fe(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,E=0;E<e.length;++E){var N=e[E];(N.from<i&&N.to>t||t==i&&N.to==t)&&(r(Math.max(N.from,t),Math.min(N.to,i),N.level==1?"rtl":"ltr",E),n=!0)}n||r(t,i,"ltr")}var Ne=null;function We(e,t,i){var r;Ne=null;for(var n=0;n<e.length;++n){var E=e[n];if(E.from<t&&E.to>t)return n;E.to==t&&(E.from!=E.to&&i=="before"?r=n:Ne=n),E.from==t&&(E.from!=E.to&&i!="before"?r=n:Ne=n)}return r!=null?r:Ne}var Ze=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(te){return te<=247?e.charAt(te):1424<=te&&te<=1524?"R":1536<=te&&te<=1785?t.charAt(te-1536):1774<=te&&te<=2220?"r":8192<=te&&te<=8203?"w":te==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,E=/[LRr]/,N=/[Lb1n]/,K=/[1n]/;function Y(te,he,me){this.level=te,this.from=he,this.to=me}return function(te,he){var me=he=="ltr"?"L":"R";if(te.length==0||he=="ltr"&&!r.test(te))return!1;for(var Se=te.length,xe=[],Re=0;Re<Se;++Re)xe.push(i(te.charCodeAt(Re)));for(var Be=0,ze=me;Be<Se;++Be){var Je=xe[Be];Je=="m"?xe[Be]=ze:ze=Je}for(var tt=0,Qe=me;tt<Se;++tt){var it=xe[tt];it=="1"&&Qe=="r"?xe[tt]="n":E.test(it)&&(Qe=it,it=="r"&&(xe[tt]="R"))}for(var ct=1,dt=xe[0];ct<Se-1;++ct){var wt=xe[ct];wt=="+"&&dt=="1"&&xe[ct+1]=="1"?xe[ct]="1":wt==","&&dt==xe[ct+1]&&(dt=="1"||dt=="n")&&(xe[ct]=dt),dt=wt}for(var It=0;It<Se;++It){var Qt=xe[It];if(Qt==",")xe[It]="N";else if(Qt=="%"){var Bt=void 0;for(Bt=It+1;Bt<Se&&xe[Bt]=="%";++Bt);for(var yr=It&&xe[It-1]=="!"||Bt<Se&&xe[Bt]=="1"?"1":"N",pr=It;pr<Bt;++pr)xe[pr]=yr;It=Bt-1}}for(var zt=0,mr=me;zt<Se;++zt){var tr=xe[zt];mr=="L"&&tr=="1"?xe[zt]="L":E.test(tr)&&(mr=tr)}for(var Yt=0;Yt<Se;++Yt)if(n.test(xe[Yt])){var Kt=void 0;for(Kt=Yt+1;Kt<Se&&n.test(xe[Kt]);++Kt);for(var Ft=(Yt?xe[Yt-1]:me)=="L",gr=(Kt<Se?xe[Kt]:me)=="L",Gi=Ft==gr?Ft?"L":"R":me,ti=Yt;ti<Kt;++ti)xe[ti]=Gi;Yt=Kt-1}for(var ar=[],Ur,qt=0;qt<Se;)if(N.test(xe[qt])){var Va=qt;for(++qt;qt<Se&&N.test(xe[qt]);++qt);ar.push(new Y(0,Va,qt))}else{var Kr=qt,vi=ar.length,yi=he=="rtl"?1:0;for(++qt;qt<Se&&xe[qt]!="L";++qt);for(var ur=Kr;ur<qt;)if(K.test(xe[ur])){Kr<ur&&(ar.splice(vi,0,new Y(1,Kr,ur)),vi+=yi);var zi=ur;for(++ur;ur<qt&&K.test(xe[ur]);++ur);ar.splice(vi,0,new Y(2,zi,ur)),vi+=yi,Kr=ur}else++ur;Kr<qt&&ar.splice(vi,0,new Y(1,Kr,qt))}return he=="ltr"&&(ar[0].level==1&&(Ur=te.match(/^\s+/))&&(ar[0].from=Ur[0].length,ar.unshift(new Y(0,0,Ur[0].length))),L(ar).level==1&&(Ur=te.match(/\s+$/))&&(L(ar).to-=Ur[0].length,ar.push(new Y(0,Se-Ur[0].length,Se)))),he=="rtl"?ar.reverse():ar}}();function He(e,t){var i=e.order;return i==null&&(i=e.order=Ze(e.text,t)),i}var Ye=[],Ce=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]||Ye).concat(i)}};function $e(e,t){return e._handlers&&e._handlers[t]||Ye}function qe(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 E=ge(n,i);E>-1&&(r[t]=n.slice(0,E).concat(n.slice(E+1)))}}}function ae(e,t){var i=$e(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 J(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),ae(e,i||t.type,e,t),se(t)||t.codemirrorIgnore}function $(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)ge(i,t[r])==-1&&i.push(t[r])}function re(e,t){return $e(e,t).length>0}function oe(e){e.prototype.on=function(t,i){Ce(this,t,i)},e.prototype.off=function(t,i){qe(this,t,i)}}function q(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Z(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function se(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function le(e){q(e),Z(e)}function pe(e){return e.target||e.srcElement}function ye(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),s&&e.ctrlKey&&t==1&&(t=3),t}var Le=function(){if(j&&B<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),Me;function et(e){if(Me==null){var t=a("span","\u200B");l(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(Me=t.offsetWidth<=1&&t.offsetHeight>2&&!(j&&B<8))}var i=Me?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var rt;function Tt(e){if(rt!=null)return rt;var t=l(e,document.createTextNode("A\u062EA")),i=f(t,0,1).getBoundingClientRect(),r=f(t,1,2).getBoundingClientRect();return h(e),!i||i.left==i.right?!1:rt=r.right-i.right<3}var ot=`
|
|
|
|
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 E=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),N=E.indexOf("\r");N!=-1?(i.push(E.slice(0,N)),t+=N+1):(i.push(E),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},Ve=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},vt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),st=null;function Lt(e){if(st!=null)return st;var t=l(e,a("span","x")),i=t.getBoundingClientRect(),r=f(t,0,1).getBoundingClientRect();return st=Math.abs(i.left-r.left)>1}var St={},yt={};function rr(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),St[e]=t}function Wt(e,t){yt[e]=t}function Ht(e){if(typeof e=="string"&&yt.hasOwnProperty(e))e=yt[e];else if(e&&typeof e.name=="string"&&yt.hasOwnProperty(e.name)){var t=yt[e.name];typeof t=="string"&&(t={name:t}),e=U(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ht("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ht("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Ut(e,t){t=Ht(t);var i=St[t.name];if(!i)return Ut(e,"text/plain");var r=i(e,t);if(or.hasOwnProperty(t.name)){var n=or[t.name];for(var E in n){if(!n.hasOwnProperty(E))continue;r.hasOwnProperty(E)&&(r["_"+E]=r[E]),r[E]=n[E]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var N in t.modeProps)r[N]=t.modeProps[N];return r}var or={};function wr(e,t){var i=or.hasOwnProperty(e)?or[e]:or[e]={};F(t,i)}function Vt(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 Sr(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 Br(e,t,i){return e.startState?e.startState(t,i):!0}var ut=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};ut.prototype.eol=function(){return this.pos>=this.string.length},ut.prototype.sol=function(){return this.pos==this.lineStart},ut.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},ut.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},ut.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},ut.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},ut.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},ut.prototype.skipToEnd=function(){this.pos=this.string.length},ut.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},ut.prototype.backUp=function(e){this.pos-=e},ut.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ne(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?ne(this.string,this.lineStart,this.tabSize):0)},ut.prototype.indentation=function(){return ne(this.string,null,this.tabSize)-(this.lineStart?ne(this.string,this.lineStart,this.tabSize):0)},ut.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(N){return i?N.toLowerCase():N},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var E=this.string.slice(this.pos).match(e);return E&&E.index>0?null:(E&&t!==!1&&(this.pos+=E[0].length),E)}},ut.prototype.current=function(){return this.string.slice(this.start,this.pos)},ut.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},ut.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},ut.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function Ke(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],E=n.chunkSize();if(t<E){i=n;break}t-=E}return i.lines[t]}function xt(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(E){var N=E.text;n==i.line&&(N=N.slice(0,i.ch)),n==t.line&&(N=N.slice(t.ch)),r.push(N),++n}),r}function Ct(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function nt(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function ft(e){if(e.parent==null)return null;for(var t=e.parent,i=ge(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 pt(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],E=n.height;if(t<E){e=n;continue e}t-=E,i+=n.chunkSize()}return i}while(!e.lines);for(var N=0;N<e.lines.length;++N){var K=e.lines[N],Y=K.height;if(t<Y)break;t-=Y}return i+N}function $t(e,t){return t>=e.first&&t<e.first+e.size}function Gt(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function je(e,t,i){if(i===void 0&&(i=null),!(this instanceof je))return new je(e,t,i);this.line=e,this.ch=t,this.sticky=i}function mt(e,t){return e.line-t.line||e.ch-t.ch}function ri(e,t){return e.sticky==t.sticky&&mt(e,t)==0}function bi(e){return je(e.line,e.ch)}function xi(e,t){return mt(e,t)<0?t:e}function ii(e,t){return mt(e,t)<0?e:t}function Ei(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function Et(e,t){if(t.line<e.first)return je(e.first,0);var i=e.first+e.size-1;return t.line>i?je(i,Ke(e,i).text.length):An(t,Ke(e,t.line).text.length)}function An(e,t){var i=e.ch;return i==null||i>t?je(e.line,t):i<0?je(e.line,0):e}function Ge(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=Et(e,t[r]);return i}var Si=function(e,t){this.state=e,this.lookAhead=t},Tr=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};Tr.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Tr.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}},Tr.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Tr.fromSaved=function(e,t,i){return t instanceof Si?new Tr(e,Vt(e.mode,t.state),i,t.lookAhead):new Tr(e,Vt(e.mode,t),i)},Tr.prototype.save=function(e){var t=e!==!1?Vt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Si(t,this.maxLookAhead):t};function Ki(e,t,i,r){var n=[e.state.modeGen],E={};_r(e,t.text,e.doc.mode,i,function(te,he){return n.push(te,he)},E,r);for(var N=i.state,K=function(te){i.baseTokens=n;var he=e.state.overlays[te],me=1,Se=0;i.state=!0,_r(e,t.text,he.mode,i,function(xe,Re){for(var Be=me;Se<xe;){var ze=n[me];ze>xe&&n.splice(me,1,xe,n[me+1],ze),me+=2,Se=Math.min(xe,ze)}if(!Re)return;if(he.opaque)n.splice(Be,me-Be,xe,"overlay "+Re),me=Be+2;else for(;Be<me;Be+=2){var Je=n[Be+1];n[Be+1]=(Je?Je+" ":"")+"overlay "+Re}},E),i.state=N,i.baseTokens=null,i.baseTokenPos=1},Y=0;Y<e.state.overlays.length;++Y)K(Y);return{styles:n,classes:E.bgClass||E.textClass?E:null}}function ni(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Lr(e,ft(t)),n=t.text.length>e.options.maxHighlightLength&&Vt(e.doc.mode,r.state),E=Ki(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=E.styles,E.classes?t.styleClasses=E.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 Lr(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new Tr(r,!0,t);var E=kn(e,t,i),N=E>r.first&&Ke(r,E-1).stateAfter,K=N?Tr.fromSaved(r,N,E):new Tr(r,Br(r.mode),E);return r.iter(E,t,function(Y){Vi(e,Y.text,K);var te=K.line;Y.stateAfter=te==t-1||te%5==0||te>=n.viewFrom&&te<n.viewTo?K.save():null,K.nextLine()}),i&&(r.modeFrontier=K.line),K}function Vi(e,t,i,r){var n=e.doc.mode,E=new ut(t,e.options.tabSize,i);for(E.start=E.pos=r||0,t==""&&Xi(n,i.state);!E.eol();)Ar(n,E,i.state),E.start=E.pos}function Xi(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=Sr(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function Ar(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=Sr(e,i).mode);var E=e.token(t,i);if(t.pos>t.start)return E}throw new Error("Mode "+e.name+" failed to advance stream.")}var Yi=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function _n(e,t,i,r){var n=e.doc,E=n.mode,N;t=Et(n,t);var K=Ke(n,t.line),Y=Lr(e,t.line,i),te=new ut(K.text,e.options.tabSize,Y),he;for(r&&(he=[]);(r||te.pos<t.ch)&&!te.eol();)te.start=te.pos,N=Ar(E,te,Y.state),r&&he.push(new Yi(te,N,Vt(n.mode,Y.state)));return r?he:new Yi(te,N,Y.state)}function $i(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 _r(e,t,i,r,n,E,N){var K=i.flattenSpans;K==null&&(K=e.options.flattenSpans);var Y=0,te=null,he=new ut(t,e.options.tabSize,r),me,Se=e.options.addModeClass&&[null];for(t==""&&$i(Xi(i,r.state),E);!he.eol();){if(he.pos>e.options.maxHighlightLength?(K=!1,N&&Vi(e,t,r,he.pos),he.pos=t.length,me=null):me=$i(Ar(i,he,r.state,Se),E),Se){var xe=Se[0].name;xe&&(me="m-"+(me?xe+" "+me:xe))}if(!K||te!=me){for(;Y<he.start;)Y=Math.min(he.start,Y+5e3),n(Y,te);te=me}he.start=he.pos}for(;Y<he.pos;){var Re=Math.min(he.pos,Y+5e3);n(Re,te),Y=Re}}function kn(e,t,i){for(var r,n,E=e.doc,N=i?-1:t-(e.doc.mode.innerMode?1e3:100),K=t;K>N;--K){if(K<=E.first)return E.first;var Y=Ke(E,K-1),te=Y.stateAfter;if(te&&(!i||K+(te instanceof Si?te.lookAhead:0)<=E.modeFrontier))return K;var he=ne(Y.text,null,e.options.tabSize);(n==null||r>he)&&(n=K-1,r=he)}return n}function aa(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=Ke(e,r).stateAfter;if(n&&(!(n instanceof Si)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Zi=!1,sr=!1;function Vr(){Zi=!0}function oa(){sr=!0}function ai(e,t,i){this.marker=e,this.from=t,this.to=i}function kr(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function Ji(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function sa(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Dn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var E=e[n],N=E.marker,K=E.from==null||(N.inclusiveLeft?E.from<=t:E.from<t);if(K||E.from==t&&N.type=="bookmark"&&(!i||!E.marker.insertLeft)){var Y=E.to==null||(N.inclusiveRight?E.to>=t:E.to>t);(r||(r=[])).push(new ai(N,E.from,Y?null:E.to))}}return r}function Rn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var E=e[n],N=E.marker,K=E.to==null||(N.inclusiveRight?E.to>=t:E.to>t);if(K||E.from==t&&N.type=="bookmark"&&(!i||E.marker.insertLeft)){var Y=E.from==null||(N.inclusiveLeft?E.from<=t:E.from<t);(r||(r=[])).push(new ai(N,Y?null:E.from-t,E.to==null?null:E.to-t))}}return r}function Ti(e,t){if(t.full)return null;var i=$t(e,t.from.line)&&Ke(e,t.from.line).markedSpans,r=$t(e,t.to.line)&&Ke(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,E=t.to.ch,N=mt(t.from,t.to)==0,K=Dn(i,n,N),Y=Rn(r,E,N),te=t.text.length==1,he=L(t.text).length+(te?n:0);if(K)for(var me=0;me<K.length;++me){var Se=K[me];if(Se.to==null){var xe=kr(Y,Se.marker);xe?te&&(Se.to=xe.to==null?null:xe.to+he):Se.to=n}}if(Y)for(var Re=0;Re<Y.length;++Re){var Be=Y[Re];if(Be.to!=null&&(Be.to+=he),Be.from==null){var ze=kr(K,Be.marker);ze||(Be.from=he,te&&(K||(K=[])).push(Be))}else Be.from+=he,te&&(K||(K=[])).push(Be)}K&&(K=On(K)),Y&&Y!=K&&(Y=On(Y));var Je=[K];if(!te){var tt=t.text.length-2,Qe;if(tt>0&&K)for(var it=0;it<K.length;++it)K[it].to==null&&(Qe||(Qe=[])).push(new ai(K[it].marker,null,null));for(var ct=0;ct<tt;++ct)Je.push(Qe);Je.push(Y)}return Je}function On(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 Pn(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(xe){if(xe.markedSpans)for(var Re=0;Re<xe.markedSpans.length;++Re){var Be=xe.markedSpans[Re].marker;Be.readOnly&&(!r||ge(r,Be)==-1)&&(r||(r=[])).push(Be)}}),!r)return null;for(var n=[{from:t,to:i}],E=0;E<r.length;++E)for(var N=r[E],K=N.find(0),Y=0;Y<n.length;++Y){var te=n[Y];if(mt(te.to,K.from)<0||mt(te.from,K.to)>0)continue;var he=[Y,1],me=mt(te.from,K.from),Se=mt(te.to,K.to);(me<0||!N.inclusiveLeft&&!me)&&he.push({from:te.from,to:K.from}),(Se>0||!N.inclusiveRight&&!Se)&&he.push({from:K.to,to:te.to}),n.splice.apply(n,he),Y+=he.length-3}return n}function la(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 Ci(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function oi(e){return e.inclusiveLeft?-1:0}function si(e){return e.inclusiveRight?1:0}function wi(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),E=mt(r.from,n.from)||oi(e)-oi(t);if(E)return-E;var N=mt(r.to,n.to)||si(e)-si(t);return N||t.id-e.id}function Fr(e,t){var i=sr&&e.markedSpans,r;if(i)for(var n=void 0,E=0;E<i.length;++E)n=i[E],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||wi(r,n.marker)<0)&&(r=n.marker);return r}function jr(e){return Fr(e,!0)}function Wr(e){return Fr(e,!1)}function Li(e,t){var i=sr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var E=i[n];E.marker.collapsed&&(E.from==null||E.from<t)&&(E.to==null||E.to>t)&&(!r||wi(r,E.marker)<0)&&(r=E.marker)}return r}function Mn(e,t,i,r,n){var E=Ke(e,t),N=sr&&E.markedSpans;if(N)for(var K=0;K<N.length;++K){var Y=N[K];if(!Y.marker.collapsed)continue;var te=Y.marker.find(0),he=mt(te.from,i)||oi(Y.marker)-oi(n),me=mt(te.to,r)||si(Y.marker)-si(n);if(he>=0&&me<=0||he<=0&&me>=0)continue;if(he<=0&&(Y.marker.inclusiveRight&&n.inclusiveLeft?mt(te.to,i)>=0:mt(te.to,i)>0)||he>=0&&(Y.marker.inclusiveRight&&n.inclusiveLeft?mt(te.from,r)<=0:mt(te.from,r)<0))return!0}}function br(e){for(var t;t=jr(e);)e=t.find(-1,!0).line;return e}function In(e){for(var t;t=Wr(e);)e=t.find(1,!0).line;return e}function Ai(e){for(var t,i;t=Wr(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function Qi(e,t){var i=Ke(e,t),r=br(i);return i==r?t:ft(r)}function Xr(e,t){if(t>e.lastLine())return t;var i=Ke(e,t),r;if(!Mr(e,i))return t;for(;r=Wr(i);)i=r.find(1,!0).line;return ft(i)+1}function Mr(e,t){var i=sr&&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&&qi(e,t,r))return!0}}function qi(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return qi(e,r.line,kr(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,E=0;E<t.markedSpans.length;++E)if(n=t.markedSpans[E],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&qi(e,t,n))return!0}function Dr(e){e=br(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 E=i.parent;E;i=E,E=i.parent)for(var N=0;N<E.children.length;++N){var K=E.children[N];if(K==i)break;t+=K.height}return t}function en(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=jr(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Wr(r);){var E=i.find(0,!0);t-=r.text.length-E.from.ch,r=E.to.line,t+=r.text.length-E.to.ch}return t}function Nn(e){var t=e.display,i=e.doc;t.maxLine=Ke(i,i.first),t.maxLineLength=en(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=en(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var li=function(e,t,i){this.text=e,Ci(this,t),this.height=i?i(this):1};li.prototype.lineNo=function(){return ft(this)},oe(li);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),la(e),Ci(e,i);var n=r?r(e):1;n!=e.height&&nt(e,n)}function lt(e){e.parent=null,la(e)}var bt={},ht={};function At(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?ht:bt;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Dt(e,t){var i=g("span",null,null,M?"padding-right: .1px":null),r={pre:g("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 E=n?t.rest[n-1]:t.line,N=void 0;r.pos=0,r.addToken=kt,Tt(e.display.measure)&&(N=He(E,e.doc.direction))&&(r.addToken=dr(r.addToken,N)),r.map=[];var K=t!=e.display.externalMeasured&&ft(E);Hr(E,r,ni(e,E,K)),E.styleClasses&&(E.styleClasses.bgClass&&(r.bgClass=X(E.styleClasses.bgClass,r.bgClass||"")),E.styleClasses.textClass&&(r.textClass=X(E.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(et(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(M){var Y=r.content.lastChild;(/\bcm-tab\b/.test(Y.className)||Y.querySelector&&Y.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return ae(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=X(r.pre.className,r.textClass||"")),r}function Mt(e){var t=a("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function kt(e,t,i,r,n,E,N){if(!t)return;var K=e.splitSpaces?Xt(t,e.trailingSpace):t,Y=e.cm.state.specialChars,te=!1,he;if(!Y.test(t))e.col+=t.length,he=document.createTextNode(K),e.map.push(e.pos,e.pos+t.length,he),j&&B<9&&(te=!0),e.pos+=t.length;else{he=document.createDocumentFragment();for(var me=0;;){Y.lastIndex=me;var Se=Y.exec(t),xe=Se?Se.index-me:t.length-me;if(xe){var Re=document.createTextNode(K.slice(me,me+xe));j&&B<9?he.appendChild(a("span",[Re])):he.appendChild(Re),e.map.push(e.pos,e.pos+xe,Re),e.col+=xe,e.pos+=xe}if(!Se)break;me+=xe+1;var Be=void 0;if(Se[0]==" "){var ze=e.cm.options.tabSize,Je=ze-e.col%ze;Be=he.appendChild(a("span",W(Je),"cm-tab")),Be.setAttribute("role","presentation"),Be.setAttribute("cm-text"," "),e.col+=Je}else Se[0]=="\r"||Se[0]==`
|
|
`?(Be=he.appendChild(a("span",Se[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Be.setAttribute("cm-text",Se[0]),e.col+=1):(Be=e.cm.options.specialCharPlaceholder(Se[0]),Be.setAttribute("cm-text",Se[0]),j&&B<9?he.appendChild(a("span",[Be])):he.appendChild(Be),e.col+=1);e.map.push(e.pos,e.pos+1,Be),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,i||r||n||te||E||N){var tt=i||"";r&&(tt+=r),n&&(tt+=n);var Qe=a("span",[he],tt,E);if(N)for(var it in N)N.hasOwnProperty(it)&&it!="style"&&it!="class"&&Qe.setAttribute(it,N[it]);return e.content.appendChild(Qe)}e.content.appendChild(he)}function Xt(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var E=e.charAt(n);E==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(E="\xA0"),r+=E,i=E==" "}return r}function dr(e,t){return function(i,r,n,E,N,K,Y){n=n?n+" cm-force-border":"cm-force-border";for(var te=i.pos,he=te+r.length;;){for(var me=void 0,Se=0;Se<t.length&&!(me=t[Se],me.to>te&&me.from<=te);Se++);if(me.to>=he)return e(i,r,n,E,N,K,Y);e(i,r.slice(0,me.to-te),n,E,null,K,Y),E=null,r=r.slice(me.to-te),te=me.to}}}function _t(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 Hr(e,t,i){var r=e.markedSpans,n=e.text,E=0;if(!r){for(var N=1;N<i.length;N+=2)t.addToken(t,n.slice(E,E=i[N]),At(i[N+1],t.cm.options));return}for(var K=n.length,Y=0,te=1,he="",me,Se,xe=0,Re,Be,ze,Je,tt;;){if(xe==Y){Re=Be=ze=Se="",tt=null,Je=null,xe=Infinity;for(var Qe=[],it=void 0,ct=0;ct<r.length;++ct){var dt=r[ct],wt=dt.marker;if(wt.type=="bookmark"&&dt.from==Y&&wt.widgetNode)Qe.push(wt);else if(dt.from<=Y&&(dt.to==null||dt.to>Y||wt.collapsed&&dt.to==Y&&dt.from==Y)){if(dt.to!=null&&dt.to!=Y&&xe>dt.to&&(xe=dt.to,Be=""),wt.className&&(Re+=" "+wt.className),wt.css&&(Se=(Se?Se+";":"")+wt.css),wt.startStyle&&dt.from==Y&&(ze+=" "+wt.startStyle),wt.endStyle&&dt.to==xe&&(it||(it=[])).push(wt.endStyle,dt.to),wt.title&&((tt||(tt={})).title=wt.title),wt.attributes)for(var It in wt.attributes)(tt||(tt={}))[It]=wt.attributes[It];wt.collapsed&&(!Je||wi(Je.marker,wt)<0)&&(Je=dt)}else dt.from>Y&&xe>dt.from&&(xe=dt.from)}if(it)for(var Qt=0;Qt<it.length;Qt+=2)it[Qt+1]==xe&&(Be+=" "+it[Qt]);if(!Je||Je.from==Y)for(var Bt=0;Bt<Qe.length;++Bt)_t(t,0,Qe[Bt]);if(Je&&(Je.from||0)==Y){if(_t(t,(Je.to==null?K+1:Je.to)-Y,Je.marker,Je.from==null),Je.to==null)return;Je.to==Y&&(Je=!1)}}if(Y>=K)break;for(var yr=Math.min(K,xe);;){if(he){var pr=Y+he.length;if(!Je){var zt=pr>yr?he.slice(0,yr-Y):he;t.addToken(t,zt,me?me+Re:Re,ze,Y+zt.length==xe?Be:"",Se,tt)}if(pr>=yr){he=he.slice(yr-Y),Y=yr;break}Y=pr,ze=""}he=n.slice(E,E=i[te++]),me=At(i[te++],t.cm.options)}}}function Rt(e,t,i){this.line=t,this.rest=Ai(t),this.size=this.rest?ft(L(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Mr(e,t)}function hr(e,t,i){for(var r=[],n,E=t;E<i;E=n){var N=new Rt(e.doc,Ke(e.doc,E),E);n=E+N.size,r.push(N)}return r}var ir=null;function Cr(e){ir?ir.ops.push(e):e.ownsGroup=ir={ops:[e],delayedCallbacks:[]}}function Ds(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 Rs(e,t){var i=e.ownsGroup;if(!i)return;try{Ds(i)}finally{ir=null,t(i)}}var tn=null;function er(e,t){var i=$e(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;ir?n=ir.delayedCallbacks:tn?n=tn:(n=tn=[],setTimeout(Os,0));for(var E=function(K){n.push(function(){return i[K].apply(null,r)})},N=0;N<i.length;++N)E(N)}function Os(){var e=tn;tn=null;for(var t=0;t<e.length;++t)e[t]()}function Ya(e,t,i,r){for(var n=0;n<t.changes.length;n++){var E=t.changes[n];E=="text"?Ms(e,t):E=="gutter"?Za(e,t,i,r):E=="class"?da(e,t):E=="widget"&&Is(e,t,r)}t.changes=null}function rn(e){return e.node==e.text&&(e.node=a("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),j&&B<8&&(e.node.style.zIndex=2)),e.node}function Ps(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=rn(t);t.background=r.insertBefore(a("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):Dt(e,t)}function Ms(e,t){var i=t.text.className,r=$a(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,da(e,t)):i&&(t.text.className=i)}function da(e,t){Ps(e,t),t.line.wrapClass?rn(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 Za(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=rn(t);t.gutterBackground=a("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}var E=t.line.gutterMarkers;if(e.options.lineNumbers||E){var N=rn(t),K=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(K),N.insertBefore(K,t.text),t.line.gutterClass&&(K.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!E||!E["CodeMirror-linenumbers"])&&(t.lineNumber=K.appendChild(a("div",Gt(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),E)for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var te=e.display.gutterSpecs[Y].className,he=E.hasOwnProperty(te)&&E[te];he&&K.appendChild(a("div",[he],"CodeMirror-gutter-elt","left: "+r.gutterLeft[te]+"px; width: "+r.gutterWidth[te]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=v("CodeMirror-linewidget"),n=t.node.firstChild,E=void 0;n;n=E)E=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);Ja(e,t,i)}function Ns(e,t,i,r){var n=$a(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),da(e,t),Za(e,t,i,r),Ja(e,t,r),t.node}function Ja(e,t,i){if(Qa(e,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)Qa(e,t.rest[r],t,i,!1)}function Qa(e,t,i,r,n){if(!t.widgets)return;for(var E=rn(i),N=0,K=t.widgets;N<K.length;++N){var Y=K[N],te=a("div",[Y.node],"CodeMirror-linewidget"+(Y.className?" "+Y.className:""));Y.handleMouseEvents||te.setAttribute("cm-ignore-events","true"),Us(Y,te,i,r),e.display.input.setUneditable(te),n&&Y.above?E.insertBefore(te,i.gutter||i.text):E.appendChild(te),er(Y,"redraw")}}function Us(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 nn(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;"),l(t.display.measure,a("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function Gr(e,t){for(var i=pe(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 Un(e){return e.lineSpace.offsetTop}function ha(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function qa(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=l(e.measure,a("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function Ir(e){return be-e.display.nativeBarWidth}function ui(e){return e.display.scroller.clientWidth-Ir(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-Ir(e)-e.display.barHeight}function Bs(e,t,i){var r=e.options.lineWrapping,n=r&&ui(e);if(!t.measure.heights||r&&t.measure.width!=n){var E=t.measure.heights=[];if(r){t.measure.width=n;for(var N=t.text.firstChild.getClientRects(),K=0;K<N.length-1;K++){var Y=N[K],te=N[K+1];Math.abs(Y.bottom-te.bottom)>2&&E.push((Y.bottom+te.top)/2-i.top)}}E.push(i.bottom-i.top)}}function eo(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(ft(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Fs(e,t){t=br(t);var i=ft(t),r=e.display.externalMeasured=new Rt(e.doc,t,i);r.lineN=i;var n=r.built=Dt(e,r);return r.text=n.pre,l(e.display.lineMeasure,n.pre),r}function to(e,t,i,r){return Nr(e,_i(e,t),i,r)}function fa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[ci(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=ft(t),r=fa(e,i);r&&!r.text?r=null:r&&r.changes&&(Ya(e,r,i,ba(e)),e.curOp.forceUpdate=!0),r||(r=Fs(e,t));var n=eo(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function Nr(e,t,i,r,n){t.before&&(i=-1);var E=i+(r||""),N;return t.cache.hasOwnProperty(E)?N=t.cache[E]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Bs(e,t.view,t.rect),t.hasHeights=!0),N=Ws(e,t,i,r),N.bogus||(t.cache[E]=N)),{left:N.left,right:N.right,top:n?N.rtop:N.top,bottom:n?N.rbottom:N.bottom}}var ro={left:0,right:0,top:0,bottom:0};function io(e,t,i){for(var r,n,E,N,K,Y,te=0;te<e.length;te+=3)if(K=e[te],Y=e[te+1],t<K?(n=0,E=1,N="left"):t<Y?(n=t-K,E=n+1):(te==e.length-3||t==Y&&e[te+3]>t)&&(E=Y-K,n=E-1,t>=Y&&(N="right")),n!=null){if(r=e[te+2],K==Y&&i==(r.insertLeft?"left":"right")&&(N=i),i=="left"&&n==0)for(;te&&e[te-2]==e[te-3]&&e[te-1].insertLeft;)r=e[(te-=3)+2],N="left";if(i=="right"&&n==Y-K)for(;te<e.length-3&&e[te+3]==e[te+4]&&!e[te+5].insertLeft;)r=e[(te+=3)+2],N="right";break}return{node:r,start:n,end:E,collapse:N,coverStart:K,coverEnd:Y}}function js(e,t){var i=ro;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=io(t.map,i,r),E=n.node,N=n.start,K=n.end,Y=n.collapse,te;if(E.nodeType==3){for(var he=0;he<4;he++){for(;N&&Oe(t.line.text.charAt(n.coverStart+N));)--N;for(;n.coverStart+K<n.coverEnd&&Oe(t.line.text.charAt(n.coverStart+K));)++K;if(j&&B<9&&N==0&&K==n.coverEnd-n.coverStart?te=E.parentNode.getBoundingClientRect():te=js(f(E,N,K).getClientRects(),r),te.left||te.right||N==0)break;K=N,N=N-1,Y="right"}j&&B<11&&(te=Hs(e.display.measure,te))}else{N>0&&(Y=r="right");var me;e.options.lineWrapping&&(me=E.getClientRects()).length>1?te=me[r=="right"?me.length-1:0]:te=E.getBoundingClientRect()}if(j&&B<9&&!N&&(!te||!te.left&&!te.right)){var Se=E.parentNode.getClientRects()[0];Se?te={left:Se.left,right:Se.left+Di(e.display),top:Se.top,bottom:Se.bottom}:te=ro}for(var xe=te.top-t.rect.top,Re=te.bottom-t.rect.top,Be=(xe+Re)/2,ze=t.view.measure.heights,Je=0;Je<ze.length-1&&!(Be<ze[Je]);Je++);var tt=Je?ze[Je-1]:0,Qe=ze[Je],it={left:(Y=="right"?te.right:te.left)-t.rect.left,right:(Y=="left"?te.left:te.right)-t.rect.left,top:tt,bottom:Qe};return!te.left&&!te.right&&(it.bogus=!0),e.options.singleCursorHeightPerLine||(it.rtop=xe,it.rbottom=Re),it}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Lt(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 no(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 ao(e){e.display.externalMeasure=null,h(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)no(e.display.view[t])}function an(e){ao(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function oo(){return b&&d?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return b&&d?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function pa(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=nn(e.widgets[i]));return t}function Bn(e,t,i,r,n){if(!n){var E=pa(t);i.top+=E,i.bottom+=E}if(r=="line")return i;r||(r="local");var N=Dr(t);if(r=="local"?N+=Un(e.display):N-=e.display.viewOffset,r=="page"||r=="window"){var K=e.display.lineSpace.getBoundingClientRect();N+=K.top+(r=="window"?0:so());var Y=K.left+(r=="window"?0:oo());i.left+=Y,i.right+=Y}return i.top+=N,i.bottom+=N,i}function lo(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=oo(),n-=so();else if(i=="local"||!i){var E=e.display.sizer.getBoundingClientRect();r+=E.left,n+=E.top}var N=e.display.lineSpace.getBoundingClientRect();return{left:r-N.left,top:n-N.top}}function ma(e,t,i,r,n){return r||(r=Ke(e.doc,t.line)),Bn(e,r,to(e,r,t.ch,n),i)}function Rr(e,t,i,r,n,E){r=r||Ke(e.doc,t.line),n||(n=_i(e,r));function N(Re,Be){var ze=Nr(e,n,Re,Be?"right":"left",E);return Be?ze.left=ze.right:ze.right=ze.left,Bn(e,r,ze,i)}var K=He(r,e.doc.direction),Y=t.ch,te=t.sticky;if(Y>=r.text.length?(Y=r.text.length,te="before"):Y<=0&&(Y=0,te="after"),!K)return N(te=="before"?Y-1:Y,te=="before");function he(Re,Be,ze){var Je=K[Be],tt=Je.level==1;return N(ze?Re-1:Re,tt!=ze)}var me=We(K,Y,te),Se=Ne,xe=he(Y,me,te=="before");return Se!=null&&(xe.other=he(Y,Se,te!="before")),xe}function uo(e,t){var i=0;t=Et(e.doc,t),e.options.lineWrapping||(i=Di(e.display)*t.ch);var r=Ke(e.doc,t.line),n=Dr(r)+Un(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ga(e,t,i,r,n){var E=je(e,t,i);return E.xRel=n,r&&(E.outside=r),E}function va(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return ga(r.first,0,null,-1,-1);var n=pt(r,i),E=r.first+r.size-1;if(n>E)return ga(r.first+r.size-1,Ke(r,E).text.length,null,1,1);t<0&&(t=0);for(var N=Ke(r,n);;){var K=Gs(e,N,n,t,i),Y=Li(N,K.ch+(K.xRel>0||K.outside>0?1:0));if(!Y)return K;var te=Y.find(1);if(te.line==n)return te;N=Ke(r,n=te.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,E=Xe(function(N){return Nr(e,i,N-1).bottom<=r},n,0);return n=Xe(function(N){return Nr(e,i,N).top>r},E,n),{begin:E,end:n}}function co(e,t,i,r){i||(i=_i(e,t));var n=Bn(e,t,Nr(e,i,r),"line").top;return ho(e,t,i,n)}function ya(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Gs(e,t,i,r,n){n-=Dr(t);var E=_i(e,t),N=pa(t),K=0,Y=t.text.length,te=!0,he=He(t,e.doc.direction);if(he){var me=(e.options.lineWrapping?Ks:zs)(e,t,i,E,he,r,n);te=me.level!=1,K=te?me.from:me.to-1,Y=te?me.to:me.from-1}var Se=null,xe=null,Re=Xe(function(ct){var dt=Nr(e,E,ct);return dt.top+=N,dt.bottom+=N,ya(dt,r,n,!1)?(dt.top<=n&&dt.left<=r&&(Se=ct,xe=dt),!0):!1},K,Y),Be,ze,Je=!1;if(xe){var tt=r-xe.left<xe.right-r,Qe=tt==te;Re=Se+(Qe?0:1),ze=Qe?"after":"before",Be=tt?xe.left:xe.right}else{!te&&(Re==Y||Re==K)&&Re++,ze=Re==0?"after":Re==t.text.length?"before":Nr(e,E,Re-(te?1:0)).bottom+N<=n==te?"after":"before";var it=Rr(e,je(i,Re,ze),"line",t,E);Be=it.left,Je=n<it.top?-1:n>=it.bottom?1:0}return Re=Pe(t.text,Re,1),ga(i,Re,ze,Je,r-Be)}function zs(e,t,i,r,n,E,N){var K=Xe(function(me){var Se=n[me],xe=Se.level!=1;return ya(Rr(e,je(i,xe?Se.to:Se.from,xe?"before":"after"),"line",t,r),E,N,!0)},0,n.length-1),Y=n[K];if(K>0){var te=Y.level!=1,he=Rr(e,je(i,te?Y.from:Y.to,te?"after":"before"),"line",t,r);ya(he,E,N,!0)&&he.top>N&&(Y=n[K-1])}return Y}function Ks(e,t,i,r,n,E,N){var K=ho(e,t,r,N),Y=K.begin,te=K.end;/\s/.test(t.text.charAt(te-1))&&te--;for(var he=null,me=null,Se=0;Se<n.length;Se++){var xe=n[Se];if(xe.from>=te||xe.to<=Y)continue;var Re=xe.level!=1,Be=Nr(e,r,Re?Math.min(te,xe.to)-1:Math.max(Y,xe.from)).right,ze=Be<E?E-Be+1e9:Be-E;(!he||me>ze)&&(he=xe,me=ze)}return he||(he=n[n.length-1]),he.from<Y&&(he={from:Y,to:he.to,level:he.level}),he.to>te&&(he={from:he.from,to:te,level:he.level}),he}var di;function ki(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(di==null){di=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)di.appendChild(document.createTextNode("x")),di.appendChild(a("br"));di.appendChild(document.createTextNode("x"))}l(e.measure,di);var i=di.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),h(e.measure),i||1}function Di(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),i=a("pre",[t],"CodeMirror-line-like");l(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function ba(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,E=t.gutters.firstChild,N=0;E;E=E.nextSibling,++N){var K=e.display.gutterSpecs[N].className;i[K]=E.offsetLeft+E.clientLeft+n,r[K]=E.clientWidth}return{fixedPos:xa(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function xa(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function fo(e){var t=ki(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/Di(e.display)-3);return function(n){if(Mr(e.doc,n))return 0;var E=0;if(n.widgets)for(var N=0;N<n.widgets.length;N++)n.widgets[N].height&&(E+=n.widgets[N].height);return i?E+(Math.ceil(n.text.length/r)||1)*t:E+t}}function Ea(e){var t=e.doc,i=fo(e);t.iter(function(r){var n=i(r);n!=r.height&&nt(r,n)})}function hi(e,t,i,r){var n=e.display;if(!i&&pe(t).getAttribute("cm-not-content")=="true")return null;var E,N,K=n.lineSpace.getBoundingClientRect();try{E=t.clientX-K.left,N=t.clientY-K.top}catch(me){return null}var Y=va(e,E,N),te;if(r&&Y.xRel>0&&(te=Ke(e.doc,Y.line).text).length==Y.ch){var he=ne(te,te.length,e.options.tabSize)-te.length;Y=je(Y.line,Math.max(0,Math.round((E-qa(e.display).left)/Di(e.display))-he))}return Y}function ci(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 cr(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)sr&&Qi(e.doc,t)<n.viewTo&&$r(e);else if(i<=n.viewFrom)sr&&Xr(e.doc,i+r)>n.viewFrom?$r(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)$r(e);else if(t<=n.viewFrom){var E=Fn(e,i,i+r,1);E?(n.view=n.view.slice(E.index),n.viewFrom=E.lineN,n.viewTo+=r):$r(e)}else if(i>=n.viewTo){var N=Fn(e,t,t,-1);N?(n.view=n.view.slice(0,N.index),n.viewTo=N.lineN):$r(e)}else{var K=Fn(e,t,t,-1),Y=Fn(e,i,i+r,1);K&&Y?(n.view=n.view.slice(0,K.index).concat(hr(e,K.lineN,Y.lineN)).concat(n.view.slice(Y.index)),n.viewTo+=r):$r(e)}var te=n.externalMeasured;te&&(i<te.lineN?te.lineN+=r:t<te.lineN+te.size&&(n.externalMeasured=null))}function Yr(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 E=r.view[ci(e,t)];if(E.node==null)return;var N=E.changes||(E.changes=[]);ge(N,i)==-1&&N.push(i)}function $r(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Fn(e,t,i,r){var n=ci(e,t),E,N=e.display.view;if(!sr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var K=e.display.viewFrom,Y=0;Y<n;Y++)K+=N[Y].size;if(K!=t){if(r>0){if(n==N.length-1)return null;E=K+N[n].size-t,n++}else E=K-t;t+=E,i+=E}for(;Qi(e.doc,i)!=i;){if(n==(r<0?0:N.length-1))return null;i+=r*N[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function Vs(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=hr(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=hr(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(ci(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(hr(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,ci(e,i)))),r.viewTo=i}function po(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 on(e){e.display.input.showSelection(e.display.input.prepareSelection())}function mo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),E=r.selection=document.createDocumentFragment(),N=0;N<i.sel.ranges.length;N++){if(!t&&N==i.sel.primIndex)continue;var K=i.sel.ranges[N];if(K.from().line>=e.display.viewTo||K.to().line<e.display.viewFrom)continue;var Y=K.empty();(Y||e.options.showCursorWhenSelecting)&&go(e,K.head,n),Y||Xs(e,K,E)}return r}function go(e,t,i){var r=Rr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(a("div","\xA0","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var E=i.appendChild(a("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));E.style.display="",E.style.left=r.other.left+"px",E.style.top=r.other.top+"px",E.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function jn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,E=document.createDocumentFragment(),N=qa(e.display),K=N.left,Y=Math.max(r.sizerWidth,ui(e)-r.sizer.offsetLeft)-N.right,te=n.direction=="ltr";function he(Qe,it,ct,dt){it<0&&(it=0),it=Math.round(it),dt=Math.round(dt),E.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+Qe+`px;
|
|
top: `+it+"px; width: "+(ct==null?Y-Qe:ct)+`px;
|
|
height: `+(dt-it)+"px"))}function me(Qe,it,ct){var dt=Ke(n,Qe),wt=dt.text.length,It,Qt;function Bt(zt,mr){return ma(e,je(Qe,zt),"div",dt,mr)}function yr(zt,mr,tr){var Yt=co(e,dt,null,zt),Kt=mr=="ltr"==(tr=="after")?"left":"right",Ft=tr=="after"?Yt.begin:Yt.end-(/\s/.test(dt.text.charAt(Yt.end-1))?2:1);return Bt(Ft,Kt)[Kt]}var pr=He(dt,n.direction);return Fe(pr,it||0,ct==null?wt:ct,function(zt,mr,tr,Yt){var Kt=tr=="ltr",Ft=Bt(zt,Kt?"left":"right"),gr=Bt(mr-1,Kt?"right":"left"),Gi=it==null&&zt==0,ti=ct==null&&mr==wt,ar=Yt==0,Ur=!pr||Yt==pr.length-1;if(gr.top-Ft.top<=3){var qt=(te?Gi:ti)&&ar,Va=(te?ti:Gi)&&Ur,Kr=qt?K:(Kt?Ft:gr).left,vi=Va?Y:(Kt?gr:Ft).right;he(Kr,Ft.top,vi-Kr,Ft.bottom)}else{var yi,ur,zi,Xa;Kt?(yi=te&&Gi&&ar?K:Ft.left,ur=te?Y:yr(zt,tr,"before"),zi=te?K:yr(mr,tr,"after"),Xa=te&&ti&&Ur?Y:gr.right):(yi=te?yr(zt,tr,"before"):K,ur=!te&&Gi&&ar?Y:Ft.right,zi=!te&&ti&&Ur?K:gr.left,Xa=te?yr(mr,tr,"after"):Y),he(yi,Ft.top,ur-yi,Ft.bottom),Ft.bottom<gr.top&&he(K,Ft.bottom,null,gr.top),he(zi,gr.top,Xa-zi,gr.bottom)}(!It||jn(Ft,It)<0)&&(It=Ft),jn(gr,It)<0&&(It=gr),(!Qt||jn(Ft,Qt)<0)&&(Qt=Ft),jn(gr,Qt)<0&&(Qt=gr)}),{start:It,end:Qt}}var Se=t.from(),xe=t.to();if(Se.line==xe.line)me(Se.line,Se.ch,xe.ch);else{var Re=Ke(n,Se.line),Be=Ke(n,xe.line),ze=br(Re)==br(Be),Je=me(Se.line,Se.ch,ze?Re.text.length+1:null).end,tt=me(xe.line,ze?0:null,xe.ch).start;ze&&(Je.top<tt.top-2?(he(Je.right,Je.top,null,Je.bottom),he(K,tt.top,tt.left,tt.bottom)):he(Je.right,Je.top,tt.left-Je.right,Je.bottom)),Je.bottom<tt.top&&he(K,Je.bottom,null,tt.top)}i.appendChild(E)}function Sa(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()||Ri(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function vo(e){e.state.focused||(e.display.input.focus(),Ta(e))}function yo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Ri(e))},100)}function Ta(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(ae(e,"focus",e,t),e.state.focused=!0,G(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),M&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Sa(e)}function Ri(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(ae(e,"blur",e,t),e.state.focused=!1,c(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Wn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],E=e.options.lineWrapping,N=void 0,K=0;if(n.hidden)continue;if(j&&B<8){var Y=n.node.offsetTop+n.node.offsetHeight;N=Y-i,i=Y}else{var te=n.node.getBoundingClientRect();N=te.bottom-te.top,!E&&n.text.firstChild&&(K=n.text.firstChild.getBoundingClientRect().right-te.left-1)}var he=n.line.height-N;if((he>.005||he<-.005)&&(nt(n.line,N),bo(n.line),n.rest))for(var me=0;me<n.rest.length;me++)bo(n.rest[me]);if(K>e.display.sizerWidth){var Se=Math.ceil(K/Di(e.display));Se>e.display.maxLineLength&&(e.display.maxLineLength=Se,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function bo(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 Hn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Un(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,E=pt(t,r),N=pt(t,n);if(i&&i.ensure){var K=i.ensure.from.line,Y=i.ensure.to.line;K<E?(E=K,N=pt(t,Dr(Ke(t,K))+e.wrapper.clientHeight)):Math.min(Y,t.lastLine())>=N&&(E=pt(t,Dr(Ke(t,Y))-e.wrapper.clientHeight),N=Y)}return{from:E,to:Math.max(N,E+1)}}function Ys(e,t){if(J(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&&!S){var E=a("div","\u200B",null,`position: absolute;
|
|
top: `+(t.top-i.viewOffset-Un(e.display))+`px;
|
|
height: `+(t.bottom-t.top+Ir(e)+i.barHeight)+`px;
|
|
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(E),E.scrollIntoView(n),e.display.lineSpace.removeChild(E)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?je(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?je(t.line,t.ch+1,"before"):t);for(var E=0;E<5;E++){var N=!1,K=Rr(e,t),Y=!i||i==t?K:Rr(e,i);n={left:Math.min(K.left,Y.left),top:Math.min(K.top,Y.top)-r,right:Math.max(K.left,Y.left),bottom:Math.max(K.bottom,Y.bottom)+r};var te=Ca(e,n),he=e.doc.scrollTop,me=e.doc.scrollLeft;if(te.scrollTop!=null&&(ln(e,te.scrollTop),Math.abs(e.doc.scrollTop-he)>1&&(N=!0)),te.scrollLeft!=null&&(fi(e,te.scrollLeft),Math.abs(e.doc.scrollLeft-me)>1&&(N=!0)),!N)break}return n}function Zs(e,t){var i=Ca(e,t);i.scrollTop!=null&&ln(e,i.scrollTop),i.scrollLeft!=null&&fi(e,i.scrollLeft)}function Ca(e,t){var i=e.display,r=ki(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,E=ca(e),N={};t.bottom-t.top>E&&(t.bottom=t.top+E);var K=e.doc.height+ha(i),Y=t.top<r,te=t.bottom>K-r;if(t.top<n)N.scrollTop=Y?0:t.top;else if(t.bottom>n+E){var he=Math.min(t.top,(te?K:t.bottom)-E);he!=n&&(N.scrollTop=he)}var me=e.options.fixedGutter?0:i.gutters.offsetWidth,Se=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-me,xe=ui(e)-i.gutters.offsetWidth,Re=t.right-t.left>xe;return Re&&(t.right=t.left+xe),t.left<10?N.scrollLeft=0:t.left<Se?N.scrollLeft=Math.max(0,t.left+me-(Re?0:10)):t.right>xe+Se-3&&(N.scrollLeft=t.right+(Re?0:10)-xe),N}function wa(e,t){if(t==null)return;Gn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Oi(e){Gn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function sn(e,t,i){(t!=null||i!=null)&&Gn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Gn(e),e.curOp.scrollToPos=t}function Gn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=uo(e,t.from),r=uo(e,t.to);xo(e,i,r,t.margin)}}function xo(e,t,i,r){var n=Ca(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});sn(e,n.scrollLeft,n.scrollTop)}function ln(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;D||Aa(e,{top:t}),Eo(e,t,!0),D&&Aa(e),hn(e,100)}function Eo(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,Lo(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function un(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+ha(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+Ir(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var pi=function(e,t,i){this.cm=i;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),Ce(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Ce(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,j&&B<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};pi.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 E=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+E)+"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}},pi.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},pi.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},pi.prototype.zeroWidthHack=function(){var e=s&&!A?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new ce,this.disableVert=new ce},pi.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),E=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);E!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},pi.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var dn=function(){};dn.prototype.update=function(){return{bottom:0,right:0}},dn.prototype.setScrollLeft=function(){},dn.prototype.setScrollTop=function(){},dn.prototype.clear=function(){};function Pi(e,t){t||(t=un(e));var i=e.display.barWidth,r=e.display.barHeight;So(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Wn(e),So(e,un(e)),i=e.display.barWidth,r=e.display.barHeight}function So(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 To={native:pi,null:dn};function Co(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&c(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new To[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Ce(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):ln(e,t)},e),e.display.scrollbars.addClass&&G(e.display.wrapper,e.display.scrollbars.addClass)}var Qs=0;function mi(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Qs},Cr(e.curOp)}function gi(e){var t=e.curOp;t&&Rs(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 E=0;E<t.length;E++)il(t[E]);for(var N=0;N<t.length;N++)nl(t[N])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&Nn(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 zn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&La(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Wn(t),e.barMeasure=un(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(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+Ir(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-ui(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==P();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Pi(t,e.barMeasure),e.updatedDisplay&&ka(t,e.barMeasure),e.selectionChanged&&Sa(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&vo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&wo(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&Eo(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&fi(t,e.scrollLeft,!0,!0),e.scrollToPos){var n=$s(t,Et(r,e.scrollToPos.from),Et(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var E=e.maybeHiddenMarkers,N=e.maybeUnhiddenMarkers;if(E)for(var K=0;K<E.length;++K)E[K].lines.length||ae(E[K],"hide");if(N)for(var Y=0;Y<N.length;++Y)N[Y].lines.length&&ae(N[Y],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&ae(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function vr(e,t){if(e.curOp)return t();mi(e);try{return t()}finally{gi(e)}}function Zt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);mi(e);try{return t.apply(e,arguments)}finally{gi(e)}}}function lr(e){return function(){if(this.curOp)return e.apply(this,arguments);mi(this);try{return e.apply(this,arguments)}finally{gi(this)}}}function Jt(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);mi(t);try{return e.apply(this,arguments)}finally{gi(t)}}}function hn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,z(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=Lr(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(E){if(r.line>=e.display.viewFrom){var N=E.styles,K=E.text.length>e.options.maxHighlightLength?Vt(t.mode,r.state):null,Y=Ki(e,E,r,!0);K&&(r.state=K),E.styles=Y.styles;var te=E.styleClasses,he=Y.classes;he?E.styleClasses=he:te&&(E.styleClasses=null);for(var me=!N||N.length!=E.styles.length||te!=he&&(!te||!he||te.bgClass!=he.bgClass||te.textClass!=he.textClass),Se=0;!me&&Se<N.length;++Se)me=N[Se]!=E.styles[Se];me&&n.push(r.line),E.stateAfter=r.save(),r.nextLine()}else E.text.length<=e.options.maxHighlightLength&&Vi(e,E.text,r),E.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return hn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&vr(e,function(){for(var E=0;E<n.length;E++)Yr(e,n[E],"text")})}var zn=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Hn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=ui(e),this.force=i,this.dims=ba(e),this.events=[]};zn.prototype.signal=function(e,t){re(e,t)&&this.events.push(arguments)},zn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)ae.apply(null,this.events[e])};function ol(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Ir(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Ir(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=P();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==P())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 La(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return $r(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&&po(e)==0)return!1;Ao(e)&&($r(e),t.dims=ba(e));var n=r.first+r.size,E=Math.max(t.visible.from-e.options.viewportMargin,r.first),N=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<E&&E-i.viewFrom<20&&(E=Math.max(r.first,i.viewFrom)),i.viewTo>N&&i.viewTo-N<20&&(N=Math.min(n,i.viewTo)),sr&&(E=Qi(e.doc,E),N=Xr(e.doc,N));var K=E!=i.viewFrom||N!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,E,N),i.viewOffset=Dr(Ke(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var Y=po(e);if(!K&&Y==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var te=sl(e);return Y>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),Y>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(te),h(i.cursorDiv),h(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,K&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,hn(e,400)),i.updateLineNumbers=null,!0}function wo(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==ui(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+ha(e.display)-ca(e),i.top)}),t.visible=Hn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Hn(e.display,e.doc,i));if(!La(e,t))break;Wn(e);var n=un(e);on(e),Pi(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 Aa(e,t){var i=new zn(e,t);if(La(e,i)){Wn(e),wo(e,i);var r=un(e);on(e),Pi(e,r),ka(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,E=r.lineDiv,N=E.firstChild;function K(Re){var Be=Re.nextSibling;return M&&s&&e.display.currentWheelTarget==Re?Re.style.display="none":Re.parentNode.removeChild(Re),Be}for(var Y=r.view,te=r.viewFrom,he=0;he<Y.length;he++){var me=Y[he];if(!me.hidden)if(!me.node||me.node.parentNode!=E){var Se=Ns(e,me,te,i);E.insertBefore(Se,N)}else{for(;N!=me.node;)N=K(N);var xe=n&&t!=null&&t<=te&&me.lineNumber;me.changes&&(ge(me.changes,"gutter")>-1&&(xe=!1),Ya(e,me,te,i)),xe&&(h(me.lineNumber),me.lineNumber.appendChild(document.createTextNode(Gt(e.options,te)))),N=me.node.nextSibling}te+=me.size}for(;N;)N=K(N)}function _a(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+Ir(e)+"px"}function Lo(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=xa(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,E=r+"px",N=0;N<i.length;N++)if(!i[N].hidden){e.options.fixedGutter&&(i[N].gutter&&(i[N].gutter.style.left=E),i[N].gutterBackground&&(i[N].gutterBackground.style.left=E));var K=i[N].alignable;if(K)for(var Y=0;Y<K.length;Y++)K[Y].style.left=E}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Ao(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=Gt(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(a("div",[a("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),E=n.firstChild.offsetWidth,N=n.offsetWidth-E;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(E,r.lineGutter.offsetWidth-N)+1,r.lineNumWidth=r.lineNumInnerWidth+N,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",_a(e.display),!0}return!1}function Da(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var E=e[n],N=null;if(typeof E!="string"&&(N=E.style,E=E.className),E=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:E,style:N})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function _o(e){var t=e.gutters,i=e.gutterSpecs;h(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],E=n.className,N=n.style,K=t.appendChild(a("div",null,"CodeMirror-gutter "+E));N&&(K.style.cssText=N),E=="CodeMirror-linenumbers"&&(e.lineGutter=K,K.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",_a(e)}function cn(e){_o(e.display),cr(e),Lo(e)}function dl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=a("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=a("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=g("div",null,"CodeMirror-code"),n.selectionDiv=a("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=a("div",null,"CodeMirror-cursors"),n.measure=a("div",null,"CodeMirror-measure"),n.lineMeasure=a("div",null,"CodeMirror-measure"),n.lineSpace=g("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var E=g("div",[n.lineSpace],"CodeMirror-lines");n.mover=a("div",[E],null,"position: relative"),n.sizer=a("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=a("div",null,null,"position: absolute; height: "+be+"px; width: 1px;"),n.gutters=a("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=a("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=a("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),j&&B<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!M&&!(D&&o)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=Da(r.gutters,r.lineNumbers),_o(n),i.init(n)}var Kn=0,xr=null;j?xr=-.53:D?xr=15:b?xr=-.7:O&&(xr=-1/3);function ko(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function hl(e){var t=ko(e);return t.x*=xr,t.y*=xr,t}function Do(e,t){var i=ko(t),r=i.x,n=i.y,E=e.display,N=E.scroller,K=N.scrollWidth>N.clientWidth,Y=N.scrollHeight>N.clientHeight;if(!(r&&K||n&&Y))return;if(n&&s&&M){e:for(var te=t.target,he=E.view;te!=N;te=te.parentNode)for(var me=0;me<he.length;me++)if(he[me].node==te){e.display.currentWheelTarget=te;break e}}if(r&&!D&&!w&&xr!=null){n&&Y&&ln(e,Math.max(0,N.scrollTop+n*xr)),fi(e,Math.max(0,N.scrollLeft+r*xr)),(!n||n&&Y)&&q(t),E.wheelStartX=null;return}if(n&&xr!=null){var Se=n*xr,xe=e.doc.scrollTop,Re=xe+E.wrapper.clientHeight;Se<0?xe=Math.max(0,xe+Se-50):Re=Math.min(e.doc.height,Re+Se+50),Aa(e,{top:xe,bottom:Re})}Kn<20&&(E.wheelStartX==null?(E.wheelStartX=N.scrollLeft,E.wheelStartY=N.scrollTop,E.wheelDX=r,E.wheelDY=n,setTimeout(function(){if(E.wheelStartX==null)return;var Be=N.scrollLeft-E.wheelStartX,ze=N.scrollTop-E.wheelStartY,Je=ze&&E.wheelDY&&ze/E.wheelDY||Be&&E.wheelDX&&Be/E.wheelDX;if(E.wheelStartX=E.wheelStartY=null,!Je)return;xr=(xr*Kn+Je)/(Kn+1),++Kn},200)):(E.wheelDX+=r,E.wheelDY+=n))}var Er=function(e,t){this.ranges=e,this.primIndex=t};Er.prototype.primary=function(){return this.ranges[this.primIndex]},Er.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},Er.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new Ot(bi(this.ranges[t].anchor),bi(this.ranges[t].head));return new Er(e,this.primIndex)},Er.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Er.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(mt(t,r.from())>=0&&mt(e,r.to())<=0)return i}return-1};var Ot=function(e,t){this.anchor=e,this.head=t};Ot.prototype.from=function(){return ii(this.anchor,this.head)},Ot.prototype.to=function(){return xi(this.anchor,this.head)},Ot.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Or(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(Se,xe){return mt(Se.from(),xe.from())}),i=ge(t,n);for(var E=1;E<t.length;E++){var N=t[E],K=t[E-1],Y=mt(K.to(),N.from());if(r&&!N.empty()?Y>0:Y>=0){var te=ii(K.from(),N.from()),he=xi(K.to(),N.to()),me=K.empty()?N.from()==N.head:K.from()==K.head;E<=i&&--i,t.splice(--E,2,new Ot(me?he:te,me?te:he))}}return new Er(t,i)}function Zr(e,t){return new Er([new Ot(e,t||e)],0)}function Jr(e){return e.text?je(e.from.line+e.text.length-1,L(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Ro(e,t){if(mt(e,t.from)<0)return e;if(mt(e,t.to)<=0)return Jr(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+=Jr(t).ch-t.to.ch),je(i,r)}function Ra(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new Ot(Ro(n.anchor,t),Ro(n.head,t)))}return Or(e.cm,i,e.sel.primIndex)}function Oo(e,t,i){return e.line==t.line?je(i.line,e.ch-t.ch+i.ch):je(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=je(e.first,0),E=n,N=0;N<t.length;N++){var K=t[N],Y=Oo(K.from,n,E),te=Oo(Jr(K),n,E);if(n=K.to,E=te,i=="around"){var he=e.sel.ranges[N],me=mt(he.head,he.anchor)<0;r[N]=new Ot(me?te:Y,me?Y:te)}else r[N]=new Ot(Y,Y)}return new Er(r,e.sel.primIndex)}function Oa(e){e.doc.mode=Ut(e.options,e.doc.modeOption),fn(e)}function fn(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,hn(e,100),e.state.modeGen++,e.curOp&&cr(e)}function Po(e,t){return t.from.ch==0&&t.to.ch==0&&L(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(tt){return i?i[tt]:null}function E(tt,Qe,it){ua(tt,Qe,it,r),er(tt,"change",tt,t)}function N(tt,Qe){for(var it=[],ct=tt;ct<Qe;++ct)it.push(new li(te[ct],n(ct),r));return it}var K=t.from,Y=t.to,te=t.text,he=Ke(e,K.line),me=Ke(e,Y.line),Se=L(te),xe=n(te.length-1),Re=Y.line-K.line;if(t.full)e.insert(0,N(0,te.length)),e.remove(te.length,e.size-te.length);else if(Po(e,t)){var Be=N(0,te.length-1);E(me,me.text,xe),Re&&e.remove(K.line,Re),Be.length&&e.insert(K.line,Be)}else if(he==me)if(te.length==1)E(he,he.text.slice(0,K.ch)+Se+he.text.slice(Y.ch),xe);else{var ze=N(1,te.length-1);ze.push(new li(Se+he.text.slice(Y.ch),xe,r)),E(he,he.text.slice(0,K.ch)+te[0],n(0)),e.insert(K.line+1,ze)}else if(te.length==1)E(he,he.text.slice(0,K.ch)+te[0]+me.text.slice(Y.ch),n(0)),e.remove(K.line+1,Re);else{E(he,he.text.slice(0,K.ch)+te[0],n(0)),E(me,Se+me.text.slice(Y.ch),xe);var Je=N(1,te.length-1);Re>1&&e.remove(K.line+1,Re-1),e.insert(K.line+1,Je)}er(e,"change",e,t)}function Qr(e,t,i){function r(n,E,N){if(n.linked)for(var K=0;K<n.linked.length;++K){var Y=n.linked[K];if(Y.doc==E)continue;var te=N&&Y.sharedHist;if(i&&!te)continue;t(Y.doc,te),r(Y.doc,n,te)}}r(e,null,!0)}function Mo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ea(e),Oa(e),Io(e),e.options.lineWrapping||Nn(e),e.options.mode=t.modeOption,cr(e)}function Io(e){(e.doc.direction=="rtl"?G:c)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){vr(e,function(){Io(e),cr(e)})}function Vn(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 Ma(e,t){var i={from:bi(t.from),to:Jr(t),text:xt(e,t.from,t.to)};return Bo(e,i,t.from.line,t.to.line+1),Qr(e,function(r){return Bo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=L(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),L(e.done);if(e.done.length&&!L(e.done).ranges)return L(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),L(e.done)}function Uo(e,t,i,r){var n=e.history;n.undone.length=0;var E=+new Date,N,K;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>E-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(N=pl(n,n.lastOp==r)))K=L(N.changes),mt(t.from,t.to)==0&&mt(t.from,K.to)==0?K.to=Jr(t):N.changes.push(Ma(e,t));else{var Y=L(n.done);for((!Y||!Y.ranges)&&Xn(e.sel,n.done),N={changes:[Ma(e,t)],generation:n.generation},n.done.push(N);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=E,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,K||ae(e,"historyAdded")}function ml(e,t,i,r){var n=t.charAt(0);return n=="*"||n=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function gl(e,t,i,r){var n=e.history,E=r&&r.origin;i==n.lastSelOp||E&&n.lastSelOrigin==E&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==E||ml(e,E,L(n.done),t))?n.done[n.done.length-1]=t:Xn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=E,n.lastSelOp=i,r&&r.clearRedo!==!1&&No(n.undone)}function Xn(e,t){var i=L(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Bo(e,t,i,r){var n=t["spans_"+e.id],E=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(N){N.markedSpans&&((n||(n=t["spans_"+e.id]={}))[E]=N.markedSpans),++E})}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 Fo(e,t){var i=yl(e,t),r=Ti(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var E=i[n],N=r[n];if(E&&N){e:for(var K=0;K<N.length;++K){for(var Y=N[K],te=0;te<E.length;++te)if(E[te].marker==Y.marker)continue e;E.push(Y)}}else N&&(i[n]=N)}return i}function Mi(e,t,i){for(var r=[],n=0;n<e.length;++n){var E=e[n];if(E.ranges){r.push(i?Er.prototype.deepCopy.call(E):E);continue}var N=E.changes,K=[];r.push({changes:K});for(var Y=0;Y<N.length;++Y){var te=N[Y],he=void 0;if(K.push({from:te.from,to:te.to,text:te.text}),t)for(var me in te)(he=me.match(/^spans_(\d+)$/))&&(ge(t,Number(he[1]))>-1&&(L(K)[me]=te[me],delete te[me]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var E=mt(t,n)<0;E!=mt(i,n)<0?(n=t,t=i):E!=mt(t,i)<0&&(t=i)}return new Ot(n,t)}else return new Ot(i||t,t)}function Yn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),nr(e,new Er([Ia(e.sel.primary(),t,i,n)],0),r)}function jo(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),E=0;E<e.sel.ranges.length;E++)r[E]=Ia(e.sel.ranges[E],t[E],null,n);var N=Or(e.cm,r,e.sel.primIndex);nr(e,N,i)}function Na(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,nr(e,Or(e.cm,n,e.sel.primIndex),r)}function Wo(e,t,i,r){nr(e,Zr(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var E=0;E<n.length;E++)this.ranges[E]=new Ot(Et(e,n[E].anchor),Et(e,n[E].head))},origin:i&&i.origin};return ae(e,"beforeSelectionChange",e,r),e.cm&&ae(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Or(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,i){var r=e.history.done,n=L(r);n&&n.ranges?(r[r.length-1]=t,$n(e,t,i)):nr(e,t,i)}function nr(e,t,i){$n(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function $n(e,t,i){(re(e,"beforeSelectionChange")||e.cm&&re(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(mt(t.primary().head,e.sel.primary().head)<0?-1:1);Go(e,Ko(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Oi(e.cm)}function Go(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,$(e.cm)),er(e,"cursorActivity",e)}function zo(e){Go(e,Ko(e,e.sel,null,!1))}function Ko(e,t,i,r){for(var n,E=0;E<t.ranges.length;E++){var N=t.ranges[E],K=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[E],Y=Zn(e,N.anchor,K&&K.anchor,i,r),te=Zn(e,N.head,K&&K.head,i,r);(n||Y!=N.anchor||te!=N.head)&&(n||(n=t.ranges.slice(0,E)),n[E]=new Ot(Y,te))}return n?Or(e.cm,n,t.primIndex):t}function Ii(e,t,i,r,n){var E=Ke(e,t.line);if(E.markedSpans)for(var N=0;N<E.markedSpans.length;++N){var K=E.markedSpans[N],Y=K.marker,te="selectLeft"in Y?!Y.selectLeft:Y.inclusiveLeft,he="selectRight"in Y?!Y.selectRight:Y.inclusiveRight;if((K.from==null||(te?K.from<=t.ch:K.from<t.ch))&&(K.to==null||(he?K.to>=t.ch:K.to>t.ch))){if(n&&(ae(Y,"beforeCursorEnter"),Y.explicitlyCleared))if(E.markedSpans){--N;continue}else break;if(!Y.atomic)continue;if(i){var me=Y.find(r<0?1:-1),Se=void 0;if((r<0?he:te)&&(me=Vo(e,me,-r,me&&me.line==t.line?E:null)),me&&me.line==t.line&&(Se=mt(me,i))&&(r<0?Se<0:Se>0))return Ii(e,me,t,r,n)}var xe=Y.find(r<0?-1:1);return(r<0?te:he)&&(xe=Vo(e,xe,r,xe.line==t.line?E:null)),xe?Ii(e,xe,t,r,n):null}}return t}function Zn(e,t,i,r,n){var E=r||1,N=Ii(e,t,i,E,n)||!n&&Ii(e,t,i,E,!0)||Ii(e,t,i,-E,n)||!n&&Ii(e,t,i,-E,!0);return N||(e.cantEdit=!0,je(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?Et(e,je(t.line-1)):null:i>0&&t.ch==(r||Ke(e,t.line)).text.length?t.line<e.first+e.size-1?je(t.line+1,0):null:new je(t.line,t.ch+i)}function Xo(e){e.setSelection(je(e.firstLine(),0),je(e.lastLine()),Te)}function Yo(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,E,N,K){n&&(r.from=Et(e,n)),E&&(r.to=Et(e,E)),N&&(r.text=N),K!==void 0&&(r.origin=K)}),ae(e,"beforeChange",e,r),e.cm&&ae(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function Ni(e,t,i){if(e.cm){if(!e.cm.curOp)return Zt(e.cm,Ni)(e,t,i);if(e.cm.state.suppressEdits)return}if((re(e,"beforeChange")||e.cm&&re(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=Zi&&!i&&Pn(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)$o(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else $o(e,t)}function $o(e,t){if(t.text.length==1&&t.text[0]==""&&mt(t.from,t.to)==0)return;var i=Ra(e,t);Uo(e,t,i,e.cm?e.cm.curOp.id:NaN),pn(e,t,i,Ti(e,t));var r=[];Qr(e,function(n,E){!E&&ge(r,n.history)==-1&&(qo(n.history,t),r.push(n.history)),pn(n,t,null,Ti(n,t))})}function Jn(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,E,N=e.sel,K=t=="undo"?n.done:n.undone,Y=t=="undo"?n.undone:n.done,te=0;te<K.length&&!(E=K[te],i?E.ranges&&!E.equals(e.sel):!E.ranges);te++);if(te==K.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(E=K.pop(),E.ranges){if(Xn(E,Y),i&&!E.equals(e.sel)){nr(e,E,{clearRedo:!1});return}N=E}else if(r){K.push(E);return}else break;var he=[];Xn(N,Y),Y.push({changes:he,generation:n.generation}),n.generation=E.generation||++n.maxGeneration;for(var me=re(e,"beforeChange")||e.cm&&re(e.cm,"beforeChange"),Se=function(Be){var ze=E.changes[Be];if(ze.origin=t,me&&!Yo(e,ze,!1))return K.length=0,{};he.push(Ma(e,ze));var Je=Be?Ra(e,ze):L(K);pn(e,ze,Je,Fo(e,ze)),!Be&&e.cm&&e.cm.scrollIntoView({from:ze.from,to:Jr(ze)});var tt=[];Qr(e,function(Qe,it){!it&&ge(tt,Qe.history)==-1&&(qo(Qe.history,ze),tt.push(Qe.history)),pn(Qe,ze,null,Fo(Qe,ze))})},xe=E.changes.length-1;xe>=0;--xe){var Re=Se(xe);if(Re)return Re.v}}function Zo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Er(k(e.sel.ranges,function(n){return new Ot(je(n.anchor.line+t,n.anchor.ch),je(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){cr(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Yr(e.cm,r,"gutter")}}function pn(e,t,i,r){if(e.cm&&!e.cm.curOp)return Zt(e.cm,pn)(e,t,i,r);if(t.to.line<e.first){Zo(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);Zo(e,n),t={from:je(e.first,0),to:je(t.to.line+n,t.to.ch),text:[L(t.text)],origin:t.origin}}var E=e.lastLine();t.to.line>E&&(t={from:t.from,to:je(E,Ke(e,E).text.length),text:[t.text[0]],origin:t.origin}),t.removed=xt(e,t.from,t.to),i||(i=Ra(e,t)),e.cm?xl(e.cm,t,r):Pa(e,t,r),$n(e,i,Te),e.cantEdit&&Zn(e,je(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,E=t.from,N=t.to,K=!1,Y=E.line;e.options.lineWrapping||(Y=ft(br(Ke(r,E.line))),r.iter(Y,N.line+1,function(xe){if(xe==n.maxLine)return K=!0,!0})),r.sel.contains(t.from,t.to)>-1&&$(e),Pa(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(Y,E.line+t.text.length,function(xe){var Re=en(xe);Re>n.maxLineLength&&(n.maxLine=xe,n.maxLineLength=Re,n.maxLineChanged=!0,K=!1)}),K&&(e.curOp.updateMaxLine=!0)),aa(r,E.line),hn(e,400);var te=t.text.length-(N.line-E.line)-1;t.full?cr(e):E.line==N.line&&t.text.length==1&&!Po(e.doc,t)?Yr(e,E.line,"text"):cr(e,E.line,N.line+1,te);var he=re(e,"changes"),me=re(e,"change");if(me||he){var Se={from:E,to:N,text:t.text,removed:t.removed,origin:t.origin};me&&er(e,"change",e,Se),he&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(Se)}e.display.selForContextMenu=null}function Ui(e,t,i,r,n){var E;r||(r=i),mt(r,i)<0&&(E=[r,i],i=E[0],r=E[1]),typeof t=="string"&&(t=e.splitLines(t)),Ni(e,{from:i,to:r,text:t,origin:n})}function Jo(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function Qo(e,t,i,r){for(var n=0;n<e.length;++n){var E=e[n],N=!0;if(E.ranges){E.copied||(E=e[n]=E.deepCopy(),E.copied=!0);for(var K=0;K<E.ranges.length;K++)Jo(E.ranges[K].anchor,t,i,r),Jo(E.ranges[K].head,t,i,r);continue}for(var Y=0;Y<E.changes.length;++Y){var te=E.changes[Y];if(i<te.from.line)te.from=je(te.from.line+r,te.from.ch),te.to=je(te.to.line+r,te.to.ch);else if(t<=te.to.line){N=!1;break}}N||(e.splice(0,n+1),n=0)}}function qo(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;Qo(e.done,i,r,n),Qo(e.undone,i,r,n)}function mn(e,t,i,r){var n=t,E=t;return typeof t=="number"?E=Ke(e,Ei(e,t)):n=ft(t),n==null?null:(r(E,n)&&e.cm&&Yr(e.cm,n,i),E)}function gn(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}gn.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,lt(n),er(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 vn(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}vn.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 E=Math.min(t,n-e),N=r.height;if(r.removeInner(e,E),this.height-=N-r.height,n==E&&(this.children.splice(i--,1),r.parent=null),(t-=E)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof gn))){var K=[];this.collapse(K),this.children=[new gn(K)],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],E=n.chunkSize();if(e<=E){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var N=n.lines.length%25+25,K=N;K<n.lines.length;){var Y=new gn(n.lines.slice(K,K+=25));n.height-=Y.height,this.children.splice(++r,0,Y),Y.parent=this}n.lines=n.lines.slice(0,N),this.maybeSpill()}break}e-=E}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new vn(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=ge(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new vn(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],E=n.chunkSize();if(e<E){var N=Math.min(t,E-e);if(n.iterN(e,N,i))return!0;if((t-=N)==0)break;e=0}else e-=E}}};var yn=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};yn.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=ft(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 E=nn(this);nt(i,Math.max(0,i.height-E)),e&&(vr(e,function(){es(e,i,-E),Yr(e,r,"widget")}),er(e,"lineWidgetCleared",e,this,r))},yn.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=nn(this)-t;if(!n)return;Mr(this.doc,r)||nt(r,r.height+n),i&&vr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),er(i,"lineWidgetChanged",i,e,ft(r))})},oe(yn);function es(e,t,i){Dr(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&wa(e,i)}function El(e,t,i,r){var n=new yn(e,i,r),E=e.cm;return E&&n.noHScroll&&(E.display.alignWidgets=!0),mn(e,t,"widget",function(N){var K=N.widgets||(N.widgets=[]);if(n.insertAt==null?K.push(n):K.splice(Math.min(K.length-1,Math.max(0,n.insertAt)),0,n),n.line=N,E&&!Mr(e,N)){var Y=Dr(N)<e.scrollTop;nt(N,N.height+nn(n)),Y&&wa(E,n.height),E.curOp.forceUpdate=!0}return!0}),E&&er(E,"lineWidgetAdded",E,n,typeof t=="number"?t:ft(t)),n}var ts=0,qr=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ts};qr.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&mi(e),re(this,"clear")){var i=this.find();i&&er(this,"clear",i.from,i.to)}for(var r=null,n=null,E=0;E<this.lines.length;++E){var N=this.lines[E],K=kr(N.markedSpans,this);e&&!this.collapsed?Yr(e,ft(N),"text"):e&&(K.to!=null&&(n=ft(N)),K.from!=null&&(r=ft(N))),N.markedSpans=Ji(N.markedSpans,K),K.from==null&&this.collapsed&&!Mr(this.doc,N)&&e&&nt(N,ki(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var Y=0;Y<this.lines.length;++Y){var te=br(this.lines[Y]),he=en(te);he>e.display.maxLineLength&&(e.display.maxLine=te,e.display.maxLineLength=he,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&cr(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&zo(e.doc)),e&&er(e,"markerCleared",e,this,r,n),t&&gi(e),this.parent&&this.parent.clear()},qr.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var E=this.lines[n],N=kr(E.markedSpans,this);if(N.from!=null&&(i=je(t?E:ft(E),N.from),e==-1))return i;if(N.to!=null&&(r=je(t?E:ft(E),N.to),e==1))return r}return i&&{from:i,to:r}},qr.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;vr(r,function(){var n=t.line,E=ft(t.line),N=fa(r,E);if(N&&(no(N),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Mr(i.doc,n)&&i.height!=null){var K=i.height;i.height=null;var Y=nn(i)-K;Y&&nt(n,n.height+Y)}er(r,"markerChanged",r,e)})},qr.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||ge(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},qr.prototype.detachLine=function(e){if(this.lines.splice(ge(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},oe(qr);function Bi(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return Zt(e.cm,Bi)(e,t,i,r,n);var E=new qr(e,n),N=mt(t,i);if(r&&F(r,E,!1),N>0||N==0&&E.clearWhenEmpty!==!1)return E;if(E.replacedWith&&(E.collapsed=!0,E.widgetNode=g("span",[E.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||E.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(E.widgetNode.insertLeft=!0)),E.collapsed){if(Mn(e,t.line,t,i,E)||t.line!=i.line&&Mn(e,i.line,t,i,E))throw new Error("Inserting collapsed marker partially overlapping an existing one");oa()}E.addToHistory&&Uo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var K=t.line,Y=e.cm,te;if(e.iter(K,i.line+1,function(me){Y&&E.collapsed&&!Y.options.lineWrapping&&br(me)==Y.display.maxLine&&(te=!0),E.collapsed&&K!=t.line&&nt(me,0),sa(me,new ai(E,K==t.line?t.ch:null,K==i.line?i.ch:null)),++K}),E.collapsed&&e.iter(t.line,i.line+1,function(me){Mr(e,me)&&nt(me,0)}),E.clearOnEnter&&Ce(E,"beforeCursorEnter",function(){return E.clear()}),E.readOnly&&(Vr(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),E.collapsed&&(E.id=++ts,E.atomic=!0),Y){if(te&&(Y.curOp.updateMaxLine=!0),E.collapsed)cr(Y,t.line,i.line+1);else if(E.className||E.startStyle||E.endStyle||E.css||E.attributes||E.title)for(var he=t.line;he<=i.line;he++)Yr(Y,he,"text");E.atomic&&zo(Y.doc),er(Y,"markerAdded",Y,E)}return E}var bn=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};bn.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();er(this,"clear")},bn.prototype.find=function(e,t){return this.primary.find(e,t)},oe(bn);function Sl(e,t,i,r,n){r=F(r),r.shared=!1;var E=[Bi(e,t,i,r,n)],N=E[0],K=r.widgetNode;return Qr(e,function(Y){K&&(r.widgetNode=K.cloneNode(!0)),E.push(Bi(Y,Et(Y,t),Et(Y,i),r,n));for(var te=0;te<Y.linked.length;++te)if(Y.linked[te].isParent)return;N=L(E)}),new bn(E,N)}function rs(e){return e.findMarks(je(e.first,0),e.clipPos(je(e.lastLine())),function(t){return t.parent})}function Tl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),E=e.clipPos(n.from),N=e.clipPos(n.to);if(mt(E,N)){var K=Bi(e,E,N,r.primary,r.primary.type);r.markers.push(K),K.parent=r}}}function Cl(e){for(var t=function(r){var n=e[r],E=[n.primary.doc];Qr(n.primary.doc,function(Y){return E.push(Y)});for(var N=0;N<n.markers.length;N++){var K=n.markers[N];ge(E,K.doc)==-1&&(K.parent=null,n.markers.splice(N--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,fr=function(e,t,i,r,n){if(!(this instanceof fr))return new fr(e,t,i,r,n);i==null&&(i=0),vn.call(this,[new gn([new li("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var E=je(i,0);this.sel=Zr(E),this.history=new Vn(null),this.id=++wl,this.modeOption=t,this.lineSep=r,this.direction=n=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),Pa(this,{from:E,to:E,text:e}),nr(this,Zr(E),Te)};fr.prototype=U(vn.prototype,{constructor:fr,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=Ct(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:Jt(function(e){var t=je(this.first,0),i=this.first+this.size-1;Ni(this,{from:t,to:je(i,Ke(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&sn(this.cm,0,0),nr(this,Zr(t),Te)}),replaceRange:function(e,t,i,r){t=Et(this,t),i=i?Et(this,i):t,Ui(this,e,t,i,r)},getRange:function(e,t,i){var r=xt(this,Et(this,e),Et(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($t(this,e))return Ke(this,e)},getLineNumber:function(e){return ft(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=Ke(this,e)),br(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return Et(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:Jt(function(e,t,i){Wo(this,Et(this,typeof e=="number"?je(e,t||0):e),null,i)}),setSelection:Jt(function(e,t,i){Wo(this,Et(this,e),Et(this,t||e),i)}),extendSelection:Jt(function(e,t,i){Yn(this,Et(this,e),t&&Et(this,t),i)}),extendSelections:Jt(function(e,t){jo(this,Ge(this,e),t)}),extendSelectionsBy:Jt(function(e,t){var i=k(this.sel.ranges,e);jo(this,Ge(this,i),t)}),setSelections:Jt(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new Ot(Et(this,e[n].anchor),Et(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),nr(this,Or(this.cm,r,t),i)}),addSelection:Jt(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new Ot(Et(this,e),Et(this,t||e))),nr(this,Or(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=xt(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=xt(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:Jt(function(e,t,i){for(var r=[],n=this.sel,E=0;E<n.ranges.length;E++){var N=n.ranges[E];r[E]={from:N.from(),to:N.to(),text:this.splitLines(e[E]),origin:i}}for(var K=t&&t!="end"&&cl(this,r,t),Y=r.length-1;Y>=0;Y--)Ni(this,r[Y]);K?Ho(this,K):this.cm&&Oi(this.cm)}),undo:Jt(function(){Jn(this,"undo")}),redo:Jt(function(){Jn(this,"redo")}),undoSelection:Jt(function(){Jn(this,"undo",!0)}),redoSelection:Jt(function(){Jn(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 Vn(this.history.maxGeneration),Qr(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:Mi(this.history.done),undone:Mi(this.history.undone)}},setHistory:function(e){var t=this.history=new Vn(this.history.maxGeneration);t.done=Mi(e.done.slice(0),null,!0),t.undone=Mi(e.undone.slice(0),null,!0)},setGutterMarker:Jt(function(e,t,i){return mn(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&Ue(n)&&(r.gutterMarkers=null),!0})}),clearGutter:Jt(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&mn(t,i,"gutter",function(){return i.gutterMarkers[e]=null,Ue(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!$t(this,e))return null;if(t=e,e=Ke(this,e),!e)return null}else if(t=ft(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:Jt(function(e,t,i){return mn(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(v(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:Jt(function(e,t,i){return mn(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",E=r[n];if(E)if(i==null)r[n]=null;else{var N=E.match(v(i));if(!N)return!1;var K=N.index+N[0].length;r[n]=E.slice(0,N.index)+(!N.index||K==E.length?"":" ")+E.slice(K)||null}else return!1;return!0})}),addLineWidget:Jt(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return Bi(this,Et(this,e),Et(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=Et(this,e),Bi(this,e,e,i,"bookmark")},findMarksAt:function(e){e=Et(this,e);var t=[],i=Ke(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=Et(this,e),t=Et(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(E){var N=E.markedSpans;if(N)for(var K=0;K<N.length;K++){var Y=N[K];!(Y.to!=null&&n==e.line&&e.ch>=Y.to||Y.from==null&&n!=e.line||Y.from!=null&&n==t.line&&Y.from>=t.ch)&&(!i||i(Y.marker))&&r.push(Y.marker.parent||Y.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 E=n.text.length+r;if(E>e)return t=e,!0;e-=E,++i}),Et(this,je(i,t))},indexFromPos:function(e){e=Et(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 fr(Ct(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 fr(Ct(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}],Tl(r,rs(this)),r},unlinkDoc:function(e){if(e instanceof Nt&&(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),Cl(rs(this));break}if(e.history==this.history){var r=[e.id];Qr(e,function(n){return r.push(n.id)},!0),e.history=new Vn(null),e.history.done=Mi(this.history.done,r),e.history.undone=Mi(this.history.undone,r)}},iterLinkedDocs:function(e){Qr(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):ot(e)},lineSeparator:function(){return this.lineSep||`
|
|
`},setDirection:Jt(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)})}),fr.prototype.eachLine=fr.prototype.iter;var is=0;function Ll(e){var t=this;if(ns(t),J(t,e)||Gr(t.display,e))return;q(e),j&&(is=+new Date);var i=hi(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,E=Array(n),N=0,K=function(){++N==n&&Zt(t,function(){i=Et(t.doc,i);var xe={from:i,to:i,text:t.doc.splitLines(E.filter(function(Re){return Re!=null}).join(t.doc.lineSeparator())),origin:"paste"};Ni(t.doc,xe),Ho(t.doc,Zr(Et(t.doc,i),Et(t.doc,Jr(xe))))})()},Y=function(xe,Re){if(t.options.allowDropFileTypes&&ge(t.options.allowDropFileTypes,xe.type)==-1){K();return}var Be=new FileReader;Be.onerror=function(){return K()},Be.onload=function(){var ze=Be.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(ze)){K();return}E[Re]=ze,K()},Be.readAsText(xe)},te=0;te<r.length;te++)Y(r[te],te);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 he=e.dataTransfer.getData("Text");if(he){var me;if(t.state.draggingText&&!t.state.draggingText.copy&&(me=t.listSelections()),$n(t.doc,Zr(i,i)),me)for(var Se=0;Se<me.length;++Se)Ui(t.doc,"",me[Se].anchor,me[Se].head,"drag");t.replaceSelection(he,"around","paste"),t.display.input.focus()}}catch(xe){}}}function Al(e,t){if(j&&(!e.state.draggingText||+new Date-is<100)){le(t);return}if(J(e,t)||Gr(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!O){var i=a("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",w&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),w&&i.parentNode.removeChild(i)}}function _l(e,t){var i=hi(e,t);if(!i)return;var r=document.createDocumentFragment();go(e,i,r),e.display.dragCursor||(e.display.dragCursor=a("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),l(e.display.dragCursor,r)}function ns(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function as(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 E=0;E<i.length;E++)e(i[E])})}var os=!1;function kl(){if(os)return;Dl(),os=!0}function Dl(){var e;Ce(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Rl)},100))}),Ce(window,"blur",function(){return as(Ri)})}function Rl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var ei={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"},xn=0;xn<10;xn++)ei[xn+48]=ei[xn+96]=String(xn);for(var Qn=65;Qn<=90;Qn++)ei[Qn]=String.fromCharCode(Qn);for(var En=1;En<=12;En++)ei[En+111]=ei[En+63235]="F"+En;var zr={};zr.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"},zr.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"},zr.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"},zr.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"]},zr.default=s?zr.macDefault:zr.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,E,N=0;N<t.length-1;N++){var K=t[N];if(/^(cmd|meta|m)$/i.test(K))E=!0;else if(/^a(lt)?$/i.test(K))i=!0;else if(/^(c|ctrl|control)$/i.test(K))r=!0;else if(/^s(hift)?$/i.test(K))n=!0;else throw new Error("Unrecognized modifier name: "+K)}return i&&(e="Alt-"+e),r&&(e="Ctrl-"+e),E&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Pl(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=k(i.split(" "),Ol),E=0;E<n.length;E++){var N=void 0,K=void 0;E==n.length-1?(K=n.join(" "),N=r):(K=n.slice(0,E+1).join(" "),N="...");var Y=t[K];if(!Y)t[K]=N;else if(Y!=N)throw new Error("Inconsistent bindings for "+K)}delete e[i]}for(var te in t)e[te]=t[te];return e}function Fi(e,t,i,r){t=qn(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 Fi(e,t.fallthrough,i,r);for(var E=0;E<t.fallthrough.length;E++){var N=Fi(e,t.fallthrough[E],i,r);if(N)return N}}}function ss(e){var t=typeof e=="string"?e:ei[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ls(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(p?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(p?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(w&&e.keyCode==34&&e.char)return!1;var i=ei[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),ls(i,e,t))}function qn(e){return typeof e=="string"?zr[e]:e}function ji(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var E=t(i[n]);r.length&&mt(E.from,L(r).to)<=0;){var N=r.pop();if(mt(N.from,E.from)<0){E.from=N.from;break}}r.push(E)}vr(e,function(){for(var K=r.length-1;K>=0;K--)Ui(e.doc,"",r[K].from,r[K].to,"+delete");Oi(e)})}function Ua(e,t,i){var r=Pe(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Ba(e,t,i){var r=Ua(e,t.ch,i);return r==null?null:new je(t.line,r,i<0?"after":"before")}function Fa(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var E=He(i,t.doc.direction);if(E){var N=n<0?L(E):E[0],K=n<0==(N.level==1),Y=K?"after":"before",te;if(N.level>0||t.doc.direction=="rtl"){var he=_i(t,i);te=n<0?i.text.length-1:0;var me=Nr(t,he,te).top;te=Xe(function(Se){return Nr(t,he,Se).top==me},n<0==(N.level==1)?N.from:N.to-1,te),Y=="before"&&(te=Ua(i,te,1))}else te=n<0?N.to:N.from;return new je(r,te,Y)}}return new je(r,n<0?i.text.length:0,n<0?"before":"after")}function Ml(e,t,i,r){var n=He(t,e.doc.direction);if(!n)return Ba(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 E=We(n,i.ch,i.sticky),N=n[E];if(e.doc.direction=="ltr"&&N.level%2==0&&(r>0?N.to>i.ch:N.from<i.ch))return Ba(t,i,r);var K=function(Je,tt){return Ua(t,Je instanceof je?Je.ch:Je,tt)},Y,te=function(Je){return e.options.lineWrapping?(Y=Y||_i(e,t),co(e,t,Y,Je)):{begin:0,end:t.text.length}},he=te(i.sticky=="before"?K(i,-1):i.ch);if(e.doc.direction=="rtl"||N.level==1){var me=N.level==1==r<0,Se=K(i,me?1:-1);if(Se!=null&&(me?Se<=N.to&&Se<=he.end:Se>=N.from&&Se>=he.begin)){var xe=me?"before":"after";return new je(i.line,Se,xe)}}var Re=function(Je,tt,Qe){for(var it=function(It,Qt){return Qt?new je(i.line,K(It,1),"before"):new je(i.line,It,"after")};Je>=0&&Je<n.length;Je+=tt){var ct=n[Je],dt=tt>0==(ct.level!=1),wt=dt?Qe.begin:K(Qe.end,-1);if(ct.from<=wt&&wt<ct.to)return it(wt,dt);if(wt=dt?ct.from:K(ct.to,-1),Qe.begin<=wt&&wt<Qe.end)return it(wt,dt)}},Be=Re(E+r,r,he);if(Be)return Be;var ze=r>0?he.end:K(he.begin,-1);return ze!=null&&!(r>0&&ze==t.text.length)&&(Be=Re(r>0?0:n.length-1,r,te(ze)),Be)?Be:null}var Sn={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Te)},killLine:function(e){return ji(e,function(t){if(t.empty()){var i=Ke(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:je(t.head.line+1,0)}:{from:t.head,to:je(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return ji(e,function(t){return{from:je(t.from().line,0),to:Et(e.doc,je(t.to().line+1,0))}})},delLineLeft:function(e){return ji(e,function(t){return{from:je(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return ji(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 ji(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(je(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(je(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return ds(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return hs(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")},we)},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")},we)},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/)?hs(e,t.head):r},we)},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 E=i[n].from(),N=ne(e.getLine(E.line),E.ch,r);t.push(W(r-N%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return vr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,E=Ke(e.doc,n.line).text;if(E){if(n.ch==E.length&&(n=new je(n.line,n.ch-1)),n.ch>0)n=new je(n.line,n.ch+1),e.replaceRange(E.charAt(n.ch-1)+E.charAt(n.ch-2),je(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var N=Ke(e.doc,n.line-1).text;N&&(n=new je(n.line,1),e.replaceRange(E.charAt(0)+e.doc.lineSeparator()+N.charAt(N.length-1),je(n.line-1,N.length-1),n,"+transpose"))}}i.push(new Ot(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return vr(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);Oi(e)})},openLine:function(e){return e.replaceSelection(`
|
|
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function ds(e,t){var i=Ke(e.doc,t),r=br(i);return r!=i&&(t=ft(r)),Fa(!0,e,r,t,1)}function Il(e,t){var i=Ke(e.doc,t),r=In(i);return r!=i&&(t=ft(r)),Fa(!0,e,i,t,-1)}function hs(e,t){var i=ds(e,t.line),r=Ke(e.doc,i.line),n=He(r,e.doc.direction);if(!n||n[0].level==0){var E=Math.max(i.ch,r.text.search(/\S/)),N=t.line==i.line&&t.ch<=E&&t.ch;return je(i.line,N?0:E,i.sticky)}return i}function ea(e,t,i){if(typeof t=="string"&&(t=Sn[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)!=Ie}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=Fi(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&Fi(t,e.options.extraKeys,i,e)||Fi(t,e.options.keyMap,i,e)}var Ul=new ce;function Tn(e,t,i,r){var n=e.state.keySeq;if(n){if(ss(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Ul.set(50,function(){e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())}),cs(e,n+" "+t,i,r))return!0}return cs(e,t,i,r)}function cs(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&er(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(q(i),Sa(e)),!!n}function fs(e,t){var i=us(t,!0);return i?t.shiftKey&&!e.state.keySeq?Tn(e,"Shift-"+i,t,function(r){return ea(e,r,!0)})||Tn(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return ea(e,r)}):Tn(e,i,t,function(r){return ea(e,r)}):!1}function Bl(e,t,i){return Tn(e,"'"+i+"'",t,function(r){return ea(e,r,!0)})}var ja=null;function ps(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=P(),J(t,e))return;j&&B<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=fs(t,e);w&&(ja=r?i:null,!r&&i==88&&!vt&&(s?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),D&&!s&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Fl(t)}function Fl(e){var t=e.display.lineDiv;G(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(c(t,"CodeMirror-crosshair"),qe(document,"keyup",i),qe(document,"mouseover",i))}Ce(document,"keyup",i),Ce(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),J(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(Gr(t.display,e)||J(t,e)||e.ctrlKey&&!e.altKey||s&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(w&&i==ja){ja=null,q(e);return}if(w&&(!e.which||e.which<10)&&fs(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Bl(t,e,n))return;t.display.input.onKeyPress(e)}var jl=400,Wa=function(e,t,i){this.time=e,this.pos=t,this.button=i};Wa.prototype.compare=function(e,t,i){return this.time+jl>e&&mt(t,this.pos)==0&&i==this.button};var Cn,wn;function Wl(e,t){var i=+new Date;return wn&&wn.compare(i,e,t)?(Cn=wn=null,"triple"):Cn&&Cn.compare(i,e,t)?(wn=new Wa(i,e,t),Cn=null,"double"):(Cn=new Wa(i,e,t),wn=null,"single")}function vs(e){var t=this,i=t.display;if(J(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,Gr(i,e)){M||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=hi(t,e),n=ye(e),E=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,E,e))return;n==1?r?zl(t,r,E,e):pe(e)==i.scroller&&q(e):n==2?(r&&Yn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(_?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,i,r,n){var E="Click";return r=="double"?E="Double"+E:r=="triple"&&(E="Triple"+E),E=(t==1?"Left":t==2?"Middle":"Right")+E,Tn(e,ls(E,n),n,function(N){if(typeof N=="string"&&(N=Sn[N]),!N)return!1;var K=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),K=N(e,i)!=Ie}finally{e.state.suppressEdits=!1}return K})}function Gl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var E=u?i.shiftKey&&i.metaKey:i.altKey;n.unit=E?"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=s?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(s?i.altKey:i.ctrlKey)),n}function zl(e,t,i,r){j?setTimeout(z(vo,e),0):e.curOp.focus=P();var n=Gl(e,i,r),E=e.doc.sel,N;e.options.dragDrop&&Le&&!e.isReadOnly()&&i=="single"&&(N=E.contains(t))>-1&&(mt((N=E.ranges[N]).from(),t)<0||t.xRel>0)&&(mt(N.to(),t)>0||t.xRel<0)?Kl(e,r,t,n):Vl(e,r,t,n)}function Kl(e,t,i,r){var n=e.display,E=!1,N=Zt(e,function(te){M&&(n.scroller.draggable=!1),e.state.draggingText=!1,qe(n.wrapper.ownerDocument,"mouseup",N),qe(n.wrapper.ownerDocument,"mousemove",K),qe(n.scroller,"dragstart",Y),qe(n.scroller,"drop",N),E||(q(te),r.addNew||Yn(e.doc,i,null,null,r.extend),M&&!O||j&&B==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),K=function(te){E=E||Math.abs(t.clientX-te.clientX)+Math.abs(t.clientY-te.clientY)>=10},Y=function(){return E=!0};M&&(n.scroller.draggable=!0),e.state.draggingText=N,N.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Ce(n.wrapper.ownerDocument,"mouseup",N),Ce(n.wrapper.ownerDocument,"mousemove",K),Ce(n.scroller,"dragstart",Y),Ce(n.scroller,"drop",N),yo(e),setTimeout(function(){return n.input.focus()},20)}function ys(e,t,i){if(i=="char")return new Ot(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new Ot(je(t.line,0),Et(e.doc,je(t.line+1,0)));var r=i(e,t);return new Ot(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,E=e.doc;q(t);var N,K,Y=E.sel,te=Y.ranges;if(r.addNew&&!r.extend?(K=E.sel.contains(i),K>-1?N=te[K]:N=new Ot(i,i)):(N=E.sel.primary(),K=E.sel.primIndex),r.unit=="rectangle")r.addNew||(N=new Ot(i,i)),i=hi(e,t,!0,!0),K=-1;else{var he=ys(e,i,r.unit);r.extend?N=Ia(N,he.anchor,he.head,r.extend):N=he}r.addNew?K==-1?(K=te.length,nr(E,Or(e,te.concat([N]),K),{scroll:!1,origin:"*mouse"})):te.length>1&&te[K].empty()&&r.unit=="char"&&!r.extend?(nr(E,Or(e,te.slice(0,K).concat(te.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),Y=E.sel):Na(E,K,N,De):(K=0,nr(E,new Er([N],0),De),Y=E.sel);var me=i;function Se(Qe){if(mt(me,Qe)==0)return;if(me=Qe,r.unit=="rectangle"){for(var it=[],ct=e.options.tabSize,dt=ne(Ke(E,i.line).text,i.ch,ct),wt=ne(Ke(E,Qe.line).text,Qe.ch,ct),It=Math.min(dt,wt),Qt=Math.max(dt,wt),Bt=Math.min(i.line,Qe.line),yr=Math.min(e.lastLine(),Math.max(i.line,Qe.line));Bt<=yr;Bt++){var pr=Ke(E,Bt).text,zt=Ae(pr,It,ct);It==Qt?it.push(new Ot(je(Bt,zt),je(Bt,zt))):pr.length>zt&&it.push(new Ot(je(Bt,zt),je(Bt,Ae(pr,Qt,ct))))}it.length||it.push(new Ot(i,i)),nr(E,Or(e,Y.ranges.slice(0,K).concat(it),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(Qe)}else{var mr=N,tr=ys(e,Qe,r.unit),Yt=mr.anchor,Kt;mt(tr.anchor,Yt)>0?(Kt=tr.head,Yt=ii(mr.from(),tr.anchor)):(Kt=tr.anchor,Yt=xi(mr.to(),tr.head));var Ft=Y.ranges.slice(0);Ft[K]=Xl(e,new Ot(Et(E,Yt),Kt)),nr(E,Or(e,Ft,K),De)}}var xe=n.wrapper.getBoundingClientRect(),Re=0;function Be(Qe){var it=++Re,ct=hi(e,Qe,!0,r.unit=="rectangle");if(!ct)return;if(mt(ct,me)!=0){e.curOp.focus=P(),Se(ct);var dt=Hn(n,E);(ct.line>=dt.to||ct.line<dt.from)&&setTimeout(Zt(e,function(){Re==it&&Be(Qe)}),150)}else{var wt=Qe.clientY<xe.top?-20:Qe.clientY>xe.bottom?20:0;wt&&setTimeout(Zt(e,function(){if(Re!=it)return;n.scroller.scrollTop+=wt,Be(Qe)}),50)}}function ze(Qe){e.state.selectingText=!1,Re=Infinity,Qe&&(q(Qe),n.input.focus()),qe(n.wrapper.ownerDocument,"mousemove",Je),qe(n.wrapper.ownerDocument,"mouseup",tt),E.history.lastSelOrigin=null}var Je=Zt(e,function(Qe){Qe.buttons===0||!ye(Qe)?ze(Qe):Be(Qe)}),tt=Zt(e,ze);e.state.selectingText=tt,Ce(n.wrapper.ownerDocument,"mousemove",Je),Ce(n.wrapper.ownerDocument,"mouseup",tt)}function Xl(e,t){var i=t.anchor,r=t.head,n=Ke(e.doc,i.line);if(mt(i,r)==0&&i.sticky==r.sticky)return t;var E=He(n);if(!E)return t;var N=We(E,i.ch,i.sticky),K=E[N];if(K.from!=i.ch&&K.to!=i.ch)return t;var Y=N+(K.from==i.ch==(K.level!=1)?0:1);if(Y==0||Y==E.length)return t;var te;if(r.line!=i.line)te=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var he=We(E,r.ch,r.sticky),me=he-N||(r.ch-i.ch)*(K.level==1?-1:1);he==Y-1||he==Y?te=me<0:te=me>0}var Se=E[Y+(te?-1:0)],xe=te==(Se.level==1),Re=xe?Se.from:Se.to,Be=xe?"after":"before";return i.ch==Re&&i.sticky==Be?t:new Ot(new je(i.line,Re,Be),r)}function bs(e,t,i,r){var n,E;if(t.touches)n=t.touches[0].clientX,E=t.touches[0].clientY;else try{n=t.clientX,E=t.clientY}catch(Se){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&q(t);var N=e.display,K=N.lineDiv.getBoundingClientRect();if(E>K.bottom||!re(e,i))return se(t);E-=K.top-N.viewOffset;for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var te=N.gutters.childNodes[Y];if(te&&te.getBoundingClientRect().right>=n){var he=pt(e.doc,E),me=e.display.gutterSpecs[Y];return ae(e,i,e,he,me.className,t),se(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function xs(e,t){if(Gr(e.display,t)||Yl(e,t))return;if(J(e,t,"contextmenu"))return;_||e.display.input.onContextMenu(t)}function Yl(e,t){return re(e,"gutterContextMenu")?bs(e,t,"gutterContextMenu",!1):!1}function Es(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),an(e)}var Wi={toString:function(){return"CodeMirror.Init"}},Ss={},ta={};function $l(e){var t=e.optionHandlers;function i(r,n,E,N){e.defaults[r]=n,E&&(t[r]=N?function(K,Y,te){te!=Wi&&E(K,Y,te)}:E)}e.defineOption=i,e.Init=Wi,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,Oa(r)},!0),i("indentUnit",2,Oa,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){fn(r),an(r),cr(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var E=[],N=r.doc.first;r.doc.iter(function(Y){for(var te=0;;){var he=Y.text.indexOf(n,te);if(he==-1)break;te=he+n.length,E.push(je(N,he))}N++});for(var K=E.length-1;K>=0;K--)Ui(r.doc,n,E[K],je(E[K].line,E[K].ch+n.length))}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,n,E){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),E!=Wi&&r.refresh()}),i("specialCharPlaceholder",Mt,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",o?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!T),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),cn(r)},!0),i("keyMap","default",function(r,n,E){var N=qn(n),K=E!=Wi&&qn(E);K&&K.detach&&K.detach(r,N),N.attach&&N.attach(r,K||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Jl,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=Da(n,r.options.lineNumbers),cn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?xa(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Pi(r)},!0),i("scrollbarStyle","native",function(r){Co(r),Pi(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=Da(r.options.gutters,n),cn(r)},!0),i("firstLineNumber",1,cn,!0),i("lineNumberFormatter",function(r){return r},cn,!0),i("showCursorWhenSelecting",!1,on,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Ri(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,Zl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,on,!0),i("singleCursorHeightPerLine",!0,on,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,fn,!0),i("addModeClass",!1,fn,!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,fn,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function Zl(e,t,i){var r=i&&i!=Wi;if(!t!=!r){var n=e.display.dragFunctions,E=t?Ce:qe;E(e.display.scroller,"dragstart",n.start),E(e.display.scroller,"dragenter",n.enter),E(e.display.scroller,"dragover",n.over),E(e.display.scroller,"dragleave",n.leave),E(e.display.scroller,"drop",n.drop)}}function Jl(e){e.options.lineWrapping?(G(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(c(e.display.wrapper,"CodeMirror-wrap"),Nn(e)),Ea(e),cr(e),an(e),setTimeout(function(){return Pi(e)},100)}function Nt(e,t){var i=this;if(!(this instanceof Nt))return new Nt(e,t);this.options=t=t?F(t):{},F(Ss,t,!1);var r=t.value;typeof r=="string"?r=new fr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Nt.inputStyles[t.inputStyle](this),E=this.display=new dl(e,r,n,t);E.wrapper.CodeMirror=this,Es(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Co(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 ce,keySeq:null,specialChars:null},t.autofocus&&!o&&E.input.focus(),j&&B<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),kl(),mi(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Ri(this);for(var N in ta)ta.hasOwnProperty(N)&&ta[N](this,t[N],Wi);Ao(this),t.finishInit&&t.finishInit(this);for(var K=0;K<Ga.length;++K)Ga[K](this);gi(this),M&&t.lineWrapping&&getComputedStyle(E.lineDiv).textRendering=="optimizelegibility"&&(E.lineDiv.style.textRendering="auto")}Nt.defaults=Ss,Nt.optionHandlers=ta;function Ql(e){var t=e.display;Ce(t.scroller,"mousedown",Zt(e,vs)),j&&B<11?Ce(t.scroller,"dblclick",Zt(e,function(Y){if(J(e,Y))return;var te=hi(e,Y);if(!te||Ha(e,Y)||Gr(e.display,Y))return;q(Y);var he=e.findWordAt(te);Yn(e.doc,he.anchor,he.head)})):Ce(t.scroller,"dblclick",function(Y){return J(e,Y)||q(Y)}),Ce(t.scroller,"contextmenu",function(Y){return xs(e,Y)}),Ce(t.input.getField(),"contextmenu",function(Y){t.scroller.contains(Y.target)||xs(e,Y)});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 E(Y){if(Y.touches.length!=1)return!1;var te=Y.touches[0];return te.radiusX<=1&&te.radiusY<=1}function N(Y,te){if(te.left==null)return!0;var he=te.left-Y.left,me=te.top-Y.top;return he*he+me*me>20*20}Ce(t.scroller,"touchstart",function(Y){if(!J(e,Y)&&!E(Y)&&!Ha(e,Y)){t.input.ensurePolled(),clearTimeout(i);var te=+new Date;t.activeTouch={start:te,moved:!1,prev:te-r.end<=300?r:null},Y.touches.length==1&&(t.activeTouch.left=Y.touches[0].pageX,t.activeTouch.top=Y.touches[0].pageY)}}),Ce(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Ce(t.scroller,"touchend",function(Y){var te=t.activeTouch;if(te&&!Gr(t,Y)&&te.left!=null&&!te.moved&&new Date-te.start<300){var he=e.coordsChar(t.activeTouch,"page"),me;!te.prev||N(te,te.prev)?me=new Ot(he,he):!te.prev.prev||N(te,te.prev.prev)?me=e.findWordAt(he):me=new Ot(je(he.line,0),Et(e.doc,je(he.line+1,0))),e.setSelection(me.anchor,me.head),e.focus(),q(Y)}n()}),Ce(t.scroller,"touchcancel",n),Ce(t.scroller,"scroll",function(){t.scroller.clientHeight&&(ln(e,t.scroller.scrollTop),fi(e,t.scroller.scrollLeft,!0),ae(e,"scroll",e))}),Ce(t.scroller,"mousewheel",function(Y){return Do(e,Y)}),Ce(t.scroller,"DOMMouseScroll",function(Y){return Do(e,Y)}),Ce(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(Y){J(e,Y)||le(Y)},over:function(Y){J(e,Y)||(_l(e,Y),le(Y))},start:function(Y){return Al(e,Y)},drop:Zt(e,Ll),leave:function(Y){J(e,Y)||ns(e)}};var K=t.input.getField();Ce(K,"keyup",function(Y){return ms.call(e,Y)}),Ce(K,"keydown",Zt(e,ps)),Ce(K,"keypress",Zt(e,gs)),Ce(K,"focus",function(Y){return Ta(e,Y)}),Ce(K,"blur",function(Y){return Ri(e,Y)})}var Ga=[];Nt.defineInitHook=function(e){return Ga.push(e)};function Ln(e,t,i,r){var n=e.doc,E;i==null&&(i="add"),i=="smart"&&(n.mode.indent?E=Lr(e,t).state:i="prev");var N=e.options.tabSize,K=Ke(n,t),Y=ne(K.text,null,N);K.stateAfter&&(K.stateAfter=null);var te=K.text.match(/^\s*/)[0],he;if(!r&&!/\S/.test(K.text))he=0,i="not";else if(i=="smart"&&(he=n.mode.indent(E,K.text.slice(te.length),K.text),he==Ie||he>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?he=ne(Ke(n,t-1).text,null,N):he=0:i=="add"?he=Y+e.options.indentUnit:i=="subtract"?he=Y-e.options.indentUnit:typeof i=="number"&&(he=Y+i),he=Math.max(0,he);var me="",Se=0;if(e.options.indentWithTabs)for(var xe=Math.floor(he/N);xe;--xe)Se+=N,me+=" ";if(Se<he&&(me+=W(he-Se)),me!=te)return Ui(n,me,je(t,0),je(t,te.length),"+input"),K.stateAfter=null,!0;for(var Re=0;Re<n.sel.ranges.length;Re++){var Be=n.sel.ranges[Re];if(Be.head.line==t&&Be.head.ch<te.length){var ze=je(t,te.length);Na(n,Re,new Ot(ze,ze));break}}}var Pr=null;function ra(e){Pr=e}function za(e,t,i,r,n){var E=e.doc;e.display.shift=!1,r||(r=E.sel);var N=+new Date-200,K=n=="paste"||e.state.pasteIncoming>N,Y=ot(t),te=null;if(K&&r.ranges.length>1)if(Pr&&Pr.text.join(`
|
|
`)==t){if(r.ranges.length%Pr.text.length==0){te=[];for(var he=0;he<Pr.text.length;he++)te.push(E.splitLines(Pr.text[he]))}}else Y.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(te=k(Y,function(Je){return[Je]}));for(var me=e.curOp.updateInput,Se=r.ranges.length-1;Se>=0;Se--){var xe=r.ranges[Se],Re=xe.from(),Be=xe.to();xe.empty()&&(i&&i>0?Re=je(Re.line,Re.ch-i):e.state.overwrite&&!K?Be=je(Be.line,Math.min(Ke(E,Be.line).text.length,Be.ch+L(Y).length)):K&&Pr&&Pr.lineWise&&Pr.text.join(`
|
|
`)==Y.join(`
|
|
`)&&(Re=Be=je(Re.line,0)));var ze={from:Re,to:Be,text:te?te[Se%te.length]:Y,origin:n||(K?"paste":e.state.cutIncoming>N?"cut":"+input")};Ni(e.doc,ze),er(e,"inputRead",e,ze)}t&&!K&&Cs(e,t),Oi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=me),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ts(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&vr(t,function(){return za(t,i,0,null,"paste")}),!0}function Cs(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 E=e.getModeAt(n.head),N=!1;if(E.electricChars){for(var K=0;K<E.electricChars.length;K++)if(t.indexOf(E.electricChars.charAt(K))>-1){N=Ln(e,n.head.line,"smart");break}}else E.electricInput&&(E.electricInput.test(Ke(e.doc,n.head.line).text.slice(0,n.head.ch))&&(N=Ln(e,n.head.line,"smart")));N&&er(e,"electricInput",e,n.head.line)}}function ws(e){for(var t=[],i=[],r=0;r<e.doc.sel.ranges.length;r++){var n=e.doc.sel.ranges[r].head.line,E={anchor:je(n,0),head:je(n+1,0)};i.push(E),t.push(e.getRange(E.anchor,E.head))}return{text:t,ranges:i}}function Ls(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function As(){var e=a("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=a("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return M?e.style.width="1000px":e.setAttribute("wrap","off"),C&&(e.style.border="1px solid black"),Ls(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 E=this.options,N=E[r];if(E[r]==n&&r!="mode")return;E[r]=n,t.hasOwnProperty(r)&&Zt(this,t[r])(this,n,N),ae(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,n){this.state.keyMaps[n?"push":"unshift"](qn(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,E=0;E<n.length;++E)if(n[E]==r||n[E].name==r)return n.splice(E,1),!0},addOverlay:lr(function(r,n){var E=r.token?r:e.getMode(this.options,r);if(E.startState)throw new Error("Overlays may not be stateful.");H(this.state.overlays,{mode:E,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(N){return N.priority}),this.state.modeGen++,cr(this)}),removeOverlay:lr(function(r){for(var n=this.state.overlays,E=0;E<n.length;++E){var N=n[E].modeSpec;if(N==r||typeof r=="string"&&N.name==r){n.splice(E,1),this.state.modeGen++,cr(this);return}}}),indentLine:lr(function(r,n,E){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),$t(this.doc,r)&&Ln(this,r,n,E)}),indentSelection:lr(function(r){for(var n=this.doc.sel.ranges,E=-1,N=0;N<n.length;N++){var K=n[N];if(K.empty())K.head.line>E&&(Ln(this,K.head.line,r,!0),E=K.head.line,N==this.doc.sel.primIndex&&Oi(this));else{var Y=K.from(),te=K.to(),he=Math.max(E,Y.line);E=Math.min(this.lastLine(),te.line-(te.ch?0:1))+1;for(var me=he;me<E;++me)Ln(this,me,r);var Se=this.doc.sel.ranges;Y.ch==0&&n.length==Se.length&&Se[N].from().ch>0&&Na(this.doc,N,new Ot(Y,Se[N].to()),Te)}}}),getTokenAt:function(r,n){return _n(this,r,n)},getLineTokens:function(r,n){return _n(this,je(r),n,!0)},getTokenTypeAt:function(r){r=Et(this.doc,r);var n=ni(this,Ke(this.doc,r.line)),E=0,N=(n.length-1)/2,K=r.ch,Y;if(K==0)Y=n[2];else for(;;){var te=E+N>>1;if((te?n[te*2-1]:0)>=K)N=te;else if(n[te*2+1]<K)E=te+1;else{Y=n[te*2+2];break}}var he=Y?Y.indexOf("overlay "):-1;return he<0?Y:he==0?null:Y.slice(0,he-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 E=[];if(!i.hasOwnProperty(n))return E;var N=i[n],K=this.getModeAt(r);if(typeof K[n]=="string")N[K[n]]&&E.push(N[K[n]]);else if(K[n])for(var Y=0;Y<K[n].length;Y++){var te=N[K[n][Y]];te&&E.push(te)}else K.helperType&&N[K.helperType]?E.push(N[K.helperType]):N[K.name]&&E.push(N[K.name]);for(var he=0;he<N._global.length;he++){var me=N._global[he];me.pred(K,this)&&ge(E,me.val)==-1&&E.push(me.val)}return E},getStateAfter:function(r,n){var E=this.doc;return r=Ei(E,r==null?E.first+E.size-1:r),Lr(this,r+1,n).state},cursorCoords:function(r,n){var E,N=this.doc.sel.primary();return r==null?E=N.head:typeof r=="object"?E=Et(this.doc,r):E=r?N.from():N.to(),Rr(this,E,n||"page")},charCoords:function(r,n){return ma(this,Et(this.doc,r),n||"page")},coordsChar:function(r,n){return r=lo(this,r,n||"page"),va(this,r.left,r.top)},lineAtHeight:function(r,n){return r=lo(this,{top:r,left:0},n||"page").top,pt(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,E){var N=!1,K;if(typeof r=="number"){var Y=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>Y&&(r=Y,N=!0),K=Ke(this.doc,r)}else K=r;return Bn(this,K,{top:0,left:0},n||"page",E||N).top+(N?this.doc.height-Dr(K):0)},defaultTextHeight:function(){return ki(this.display)},defaultCharWidth:function(){return Di(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,E,N,K){var Y=this.display;r=Rr(this,Et(this.doc,r));var te=r.bottom,he=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),Y.sizer.appendChild(n),N=="over")te=r.top;else if(N=="above"||N=="near"){var me=Math.max(Y.wrapper.clientHeight,this.doc.height),Se=Math.max(Y.sizer.clientWidth,Y.lineSpace.clientWidth);(N=="above"||r.bottom+n.offsetHeight>me)&&r.top>n.offsetHeight?te=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=me&&(te=r.bottom),he+n.offsetWidth>Se&&(he=Se-n.offsetWidth)}n.style.top=te+"px",n.style.left=n.style.right="",K=="right"?(he=Y.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(K=="left"?he=0:K=="middle"&&(he=(Y.sizer.clientWidth-n.offsetWidth)/2),n.style.left=he+"px"),E&&Zs(this,{left:he,top:te,right:he+n.offsetWidth,bottom:te+n.offsetHeight})},triggerOnKeyDown:lr(ps),triggerOnKeyPress:lr(gs),triggerOnKeyUp:ms,triggerOnMouseDown:lr(vs),execCommand:function(r){if(Sn.hasOwnProperty(r))return Sn[r].call(null,this)},triggerElectric:lr(function(r){Cs(this,r)}),findPosH:function(r,n,E,N){var K=1;n<0&&(K=-1,n=-n);for(var Y=Et(this.doc,r),te=0;te<n&&!(Y=Ka(this.doc,Y,K,E,N),Y.hitSide);++te);return Y},moveH:lr(function(r,n){var E=this;this.extendSelectionsBy(function(N){return E.display.shift||E.doc.extend||N.empty()?Ka(E.doc,N.head,r,n,E.options.rtlMoveVisually):r<0?N.from():N.to()},we)}),deleteH:lr(function(r,n){var E=this.doc.sel,N=this.doc;E.somethingSelected()?N.replaceSelection("",null,"+delete"):ji(this,function(K){var Y=Ka(N,K.head,r,n,!1);return r<0?{from:Y,to:K.head}:{from:K.head,to:Y}})}),findPosV:function(r,n,E,N){var K=1,Y=N;n<0&&(K=-1,n=-n);for(var te=Et(this.doc,r),he=0;he<n;++he){var me=Rr(this,te,"div");if(Y==null?Y=me.left:me.left=Y,te=_s(this,me,K,E),te.hitSide)break}return te},moveV:lr(function(r,n){var E=this,N=this.doc,K=[],Y=!this.display.shift&&!N.extend&&N.sel.somethingSelected();if(N.extendSelectionsBy(function(he){if(Y)return r<0?he.from():he.to();var me=Rr(E,he.head,"div");he.goalColumn!=null&&(me.left=he.goalColumn),K.push(me.left);var Se=_s(E,me,r,n);return n=="page"&&he==N.sel.primary()&&wa(E,ma(E,Se,"div").top-me.top),Se},we),K.length)for(var te=0;te<N.sel.ranges.length;te++)N.sel.ranges[te].goalColumn=K[te]}),findWordAt:function(r){var n=this.doc,E=Ke(n,r.line).text,N=r.ch,K=r.ch;if(E){var Y=this.getHelper(r,"wordChars");(r.sticky=="before"||K==E.length)&&N?--N:++K;for(var te=E.charAt(N),he=_e(te,Y)?function(me){return _e(me,Y)}:/\s/.test(te)?function(me){return/\s/.test(me)}:function(me){return!/\s/.test(me)&&!_e(me)};N>0&&he(E.charAt(N-1));)--N;for(;K<E.length&&he(E.charAt(K));)++K}return new Ot(je(r.line,N),je(r.line,K))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?G(this.display.cursorDiv,"CodeMirror-overwrite"):c(this.display.cursorDiv,"CodeMirror-overwrite"),ae(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==P()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:lr(function(r,n){sn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-Ir(this)-this.display.barHeight,width:r.scrollWidth-Ir(this)-this.display.barWidth,clientHeight:ca(this),clientWidth:ui(this)}},scrollIntoView:lr(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:je(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):xo(this,r.from,r.to,r.margin)}),setSize:lr(function(r,n){var E=this,N=function(Y){return typeof Y=="number"||/^\d+$/.test(String(Y))?Y+"px":Y};r!=null&&(this.display.wrapper.style.width=N(r)),n!=null&&(this.display.wrapper.style.height=N(n)),this.options.lineWrapping&&ao(this);var K=this.display.viewFrom;this.doc.iter(K,this.display.viewTo,function(Y){if(Y.widgets){for(var te=0;te<Y.widgets.length;te++)if(Y.widgets[te].noHScroll){Yr(E,K,"widget");break}}++K}),this.curOp.forceUpdate=!0,ae(this,"refresh",this)}),operation:function(r){return vr(this,r)},startOperation:function(){return mi(this)},endOperation:function(){return gi(this)},refresh:lr(function(){var r=this.display.cachedTextHeight;cr(this),this.curOp.forceUpdate=!0,an(this),sn(this,this.doc.scrollLeft,this.doc.scrollTop),_a(this.display),(r==null||Math.abs(r-ki(this.display))>.5||this.options.lineWrapping)&&Ea(this),ae(this,"refresh",this)}),swapDoc:lr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(this,r),an(this),this.display.input.reset(),sn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,er(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}},oe(e),e.registerHelper=function(r,n,E){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=E},e.registerGlobalHelper=function(r,n,E,N){e.registerHelper(r,n,N),i[r]._global.push({pred:E,val:N})}}function Ka(e,t,i,r,n){var E=t,N=i,K=Ke(e,t.line),Y=n&&e.direction=="rtl"?-i:i;function te(){var tt=t.line+Y;return tt<e.first||tt>=e.first+e.size?!1:(t=new je(tt,t.ch,t.sticky),K=Ke(e,tt))}function he(tt){var Qe;if(r=="codepoint"){var it=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(it)?Qe=null:Qe=new je(t.line,Math.max(0,Math.min(K.text.length,t.ch+i*(it>=55296&&it<56320?2:1))),-i)}else n?Qe=Ml(e.cm,K,t,i):Qe=Ba(K,t,i);if(Qe==null)if(!tt&&te())t=Fa(n,e.cm,K,t.line,Y);else return!1;else t=Qe;return!0}if(r=="char"||r=="codepoint")he();else if(r=="column")he(!0);else if(r=="word"||r=="group")for(var me=null,Se=r=="group",xe=e.cm&&e.cm.getHelper(t,"wordChars"),Re=!0;!(i<0&&!he(!Re));Re=!1){var Be=K.text.charAt(t.ch)||`
|
|
`,ze=_e(Be,xe)?"w":Se&&Be==`
|
|
`?"n":!Se||/\s/.test(Be)?null:"p";if(Se&&!Re&&!ze&&(ze="s"),me&&me!=ze){i<0&&(i=1,he(),t.sticky="after");break}if(ze&&(me=ze),i>0&&!he(!Re))break}var Je=Zn(e,t,E,N,!0);return ri(E,Je)&&(Je.hitSide=!0),Je}function _s(e,t,i,r){var n=e.doc,E=t.left,N;if(r=="page"){var K=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),Y=Math.max(K-.5*ki(e.display),3);N=(i>0?t.bottom:t.top)+i*Y}else r=="line"&&(N=i>0?t.bottom+3:t.top-3);for(var te;!(te=va(e,E,N),!te.outside);){if(i<0?N<=0:N>=n.height){te.hitSide=!0;break}N+=i*5}return te}var Pt=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new ce,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Pt.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;Ls(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function E(K){for(var Y=K.target;Y;Y=Y.parentNode){if(Y==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(Y.className))break}return!1}Ce(n,"paste",function(K){if(!E(K)||J(r,K)||Ts(K,r))return;B<=11&&setTimeout(Zt(r,function(){return t.updateFromDOM()}),20)}),Ce(n,"compositionstart",function(K){t.composing={data:K.data,done:!1}}),Ce(n,"compositionupdate",function(K){t.composing||(t.composing={data:K.data,done:!1})}),Ce(n,"compositionend",function(K){t.composing&&(K.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Ce(n,"touchstart",function(){return i.forceCompositionEnd()}),Ce(n,"input",function(){t.composing||t.readFromDOMSoon()});function N(K){if(!E(K)||J(r,K))return;if(r.somethingSelected())ra({lineWise:!1,text:r.getSelections()}),K.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var Y=ws(r);ra({lineWise:!0,text:Y.text}),K.type=="cut"&&r.operation(function(){r.setSelections(Y.ranges,0,Te),r.replaceSelection("",null,"cut")})}else return;if(K.clipboardData){K.clipboardData.clearData();var te=Pr.text.join(`
|
|
`);if(K.clipboardData.setData("Text",te),K.clipboardData.getData("Text")==te){K.preventDefault();return}}var he=As(),me=he.firstChild;r.display.lineSpace.insertBefore(he,r.display.lineSpace.firstChild),me.value=Pr.text.join(`
|
|
`);var Se=document.activeElement;ie(me),setTimeout(function(){r.display.lineSpace.removeChild(he),Se.focus(),Se==n&&i.showPrimarySelection()},50)}Ce(n,"copy",N),Ce(n,"cut",N)},Pt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Pt.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},Pt.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Pt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Pt.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 E=ia(t,e.anchorNode,e.anchorOffset),N=ia(t,e.focusNode,e.focusOffset);if(E&&!E.bad&&N&&!N.bad&&mt(ii(E,N),r)==0&&mt(xi(E,N),n)==0)return;var K=t.display.view,Y=r.line>=t.display.viewFrom&&ks(t,r)||{node:K[0].measure.map[2],offset:0},te=n.line<t.display.viewTo&&ks(t,n);if(!te){var he=K[K.length-1].measure,me=he.maps?he.maps[he.maps.length-1]:he.map;te={node:me[me.length-1],offset:me[me.length-2]-me[me.length-3]}}if(!Y||!te){e.removeAllRanges();return}var Se=e.rangeCount&&e.getRangeAt(0),xe;try{xe=f(Y.node,Y.offset,te.offset,te.node)}catch(Re){}xe&&(!D&&t.state.focused?(e.collapse(Y.node,Y.offset),xe.collapsed||(e.removeAllRanges(),e.addRange(xe))):(e.removeAllRanges(),e.addRange(xe)),Se&&e.anchorNode==null?e.addRange(Se):D&&this.startGracePeriod()),this.rememberSelection()},Pt.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)},Pt.prototype.showMultipleSelections=function(e){l(this.cm.display.cursorDiv,e.cursors),l(this.cm.display.selectionDiv,e.selection)},Pt.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Pt.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return x(this.div,t)},Pt.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Pt.prototype.blur=function(){this.div.blur()},Pt.prototype.getField=function(){return this.div},Pt.prototype.supportsTouch=function(){return!0},Pt.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():vr(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)},Pt.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Pt.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(d&&b&&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=ia(t,e.anchorNode,e.anchorOffset),r=ia(t,e.focusNode,e.focusOffset);i&&r&&vr(t,function(){nr(t.doc,Zr(i,r),Te),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},Pt.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=je(r.line-1,Ke(e.doc,r.line-1).length)),n.ch==Ke(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=je(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var E,N,K;r.line==t.viewFrom||(E=ci(e,r.line))==0?(N=ft(t.view[0].line),K=t.view[0].node):(N=ft(t.view[E].line),K=t.view[E-1].node.nextSibling);var Y=ci(e,n.line),te,he;if(Y==t.view.length-1?(te=t.viewTo-1,he=t.lineDiv.lastChild):(te=ft(t.view[Y+1].line)-1,he=t.view[Y+1].node.previousSibling),!K)return!1;for(var me=e.doc.splitLines(tu(e,K,he,N,te)),Se=xt(e.doc,je(N,0),je(te,Ke(e.doc,te).text.length));me.length>1&&Se.length>1;)if(L(me)==L(Se))me.pop(),Se.pop(),te--;else if(me[0]==Se[0])me.shift(),Se.shift(),N++;else break;for(var xe=0,Re=0,Be=me[0],ze=Se[0],Je=Math.min(Be.length,ze.length);xe<Je&&Be.charCodeAt(xe)==ze.charCodeAt(xe);)++xe;for(var tt=L(me),Qe=L(Se),it=Math.min(tt.length-(me.length==1?xe:0),Qe.length-(Se.length==1?xe:0));Re<it&&tt.charCodeAt(tt.length-Re-1)==Qe.charCodeAt(Qe.length-Re-1);)++Re;if(me.length==1&&Se.length==1&&N==r.line)for(;xe&&xe>r.ch&&tt.charCodeAt(tt.length-Re-1)==Qe.charCodeAt(Qe.length-Re-1);)xe--,Re++;me[me.length-1]=tt.slice(0,tt.length-Re).replace(/^\u200b+/,""),me[0]=me[0].slice(xe).replace(/\u200b+$/,"");var ct=je(N,xe),dt=je(te,Se.length?L(Se).length-Re:0);if(me.length>1||me[0]||mt(ct,dt))return Ui(e.doc,me,ct,dt,"+input"),!0},Pt.prototype.ensurePolled=function(){this.forceCompositionEnd()},Pt.prototype.reset=function(){this.forceCompositionEnd()},Pt.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Pt.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)},Pt.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&vr(this.cm,function(){return cr(e.cm)})},Pt.prototype.setUneditable=function(e){e.contentEditable="false"},Pt.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||Zt(this.cm,za)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Pt.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Pt.prototype.onContextMenu=function(){},Pt.prototype.resetPosition=function(){},Pt.prototype.needsContentAttribute=!0;function ks(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=Ke(e.doc,t.line),n=eo(i,r,t.line),E=He(r,e.doc.direction),N="left";if(E){var K=We(E,t.ch);N=K%2?"right":"left"}var Y=io(n.map,t.ch,N);return Y.offset=Y.collapse=="right"?Y.end:Y.start,Y}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function Hi(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var E="",N=!1,K=e.doc.lineSeparator(),Y=!1;function te(xe){return function(Re){return Re.id==xe}}function he(){N&&(E+=K,Y&&(E+=K),N=Y=!1)}function me(xe){xe&&(he(),E+=xe)}function Se(xe){if(xe.nodeType==1){var Re=xe.getAttribute("cm-text");if(Re){me(Re);return}var Be=xe.getAttribute("cm-marker"),ze;if(Be){var Je=e.findMarks(je(r,0),je(n+1,0),te(+Be));Je.length&&(ze=Je[0].find(0))&&me(xt(e.doc,ze.from,ze.to).join(K));return}if(xe.getAttribute("contenteditable")=="false")return;var tt=/^(pre|div|p|li|table|br)$/i.test(xe.nodeName);if(!/^br$/i.test(xe.nodeName)&&xe.textContent.length==0)return;tt&&he();for(var Qe=0;Qe<xe.childNodes.length;Qe++)Se(xe.childNodes[Qe]);/^(pre|p)$/i.test(xe.nodeName)&&(Y=!0),tt&&(N=!0)}else xe.nodeType==3&&me(xe.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(Se(t),t==i);)t=t.nextSibling,Y=!1;return E}function ia(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return Hi(e.clipPos(je(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 E=e.display.view[n];if(E.node==r)return ru(E,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!x(r,t))return Hi(je(ft(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var E=e.rest?L(e.rest):e.line;return Hi(je(ft(E),E.text.length),n)}var N=t.nodeType==3?t:null,K=t;for(!N&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(N=t.firstChild,i&&(i=N.nodeValue.length));K.parentNode!=r;)K=K.parentNode;var Y=e.measure,te=Y.maps;function he(ze,Je,tt){for(var Qe=-1;Qe<(te?te.length:0);Qe++)for(var it=Qe<0?Y.map:te[Qe],ct=0;ct<it.length;ct+=3){var dt=it[ct+2];if(dt==ze||dt==Je){var wt=ft(Qe<0?e.line:e.rest[Qe]),It=it[ct]+tt;return(tt<0||dt!=ze)&&(It=it[ct+(tt?1:0)]),je(wt,It)}}}var me=he(N,K,i);if(me)return Hi(me,n);for(var Se=K.nextSibling,xe=N?N.nodeValue.length-i:0;Se;Se=Se.nextSibling){if(me=he(Se,Se.firstChild,0),me)return Hi(je(me.line,me.ch-xe),n);xe+=Se.textContent.length}for(var Re=K.previousSibling,Be=i;Re;Re=Re.previousSibling){if(me=he(Re,Re.firstChild,-1),me)return Hi(je(me.line,me.ch+Be),n);Be+=Re.textContent.length}}var jt=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new ce,this.hasSelection=!1,this.composing=null};jt.prototype.init=function(e){var t=this,i=this,r=this.cm;this.createField(e);var n=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),C&&(n.style.width="0px"),Ce(n,"input",function(){j&&B>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Ce(n,"paste",function(N){if(J(r,N)||Ts(N,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function E(N){if(J(r,N))return;if(r.somethingSelected())ra({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var K=ws(r);ra({lineWise:!0,text:K.text}),N.type=="cut"?r.setSelections(K.ranges,null,Te):(i.prevInput="",n.value=K.text.join(`
|
|
`),ie(n))}else return;N.type=="cut"&&(r.state.cutIncoming=+new Date)}Ce(n,"cut",E),Ce(n,"copy",E),Ce(e.scroller,"paste",function(N){if(Gr(e,N)||J(r,N))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var K=new Event("paste");K.clipboardData=N.clipboardData,n.dispatchEvent(K)}),Ce(e.lineSpace,"selectstart",function(N){Gr(e,N)||q(N)}),Ce(n,"compositionstart",function(){var N=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:N,range:r.markText(N,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Ce(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},jt.prototype.createField=function(e){this.wrapper=As(),this.textarea=this.wrapper.firstChild},jt.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},jt.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var n=Rr(e,i.sel.primary().head,"div"),E=t.wrapper.getBoundingClientRect(),N=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+N.top-E.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+N.left-E.left))}return r},jt.prototype.showSelection=function(e){var t=this.cm,i=t.display;l(i.cursorDiv,e.cursors),l(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},jt.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&&ie(this.textarea),j&&B>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",j&&B>=9&&(this.hasSelection=null))},jt.prototype.getField=function(){return this.textarea},jt.prototype.supportsTouch=function(){return!1},jt.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||P()!=this.textarea))try{this.textarea.focus()}catch(e){}},jt.prototype.blur=function(){this.textarea.blur()},jt.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},jt.prototype.receivedFocus=function(){this.slowPoll()},jt.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()})},jt.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)},jt.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||Ve(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(j&&B>=9&&this.hasSelection===n||s&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var E=n.charCodeAt(0);if(E==8203&&!r&&(r="\u200B"),E==8666)return this.reset(),this.cm.execCommand("undo")}for(var N=0,K=Math.min(r.length,n.length);N<K&&r.charCodeAt(N)==n.charCodeAt(N);)++N;return vr(t,function(){za(t,n.slice(N),r.length-N,null,e.composing?"*compose":null),n.length>1e3||n.indexOf(`
|
|
`)>-1?i.value=e.prevInput="":e.prevInput=n,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},jt.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},jt.prototype.onKeyPress=function(){j&&B>=9&&(this.hasSelection=null),this.fastPoll()},jt.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var E=hi(i,e),N=r.scroller.scrollTop;if(!E||w)return;var K=i.options.resetSelectionOnContextMenu;K&&i.doc.sel.contains(E)==-1&&Zt(i,nr)(i.doc,Zr(E),Te);var Y=n.style.cssText,te=t.wrapper.style.cssText,he=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
|
|
top: `+(e.clientY-he.top-5)+"px; left: "+(e.clientX-he.left-5)+`px;
|
|
z-index: 1000; background: `+(j?"rgba(255, 255, 255, .05)":"transparent")+`;
|
|
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var me;M&&(me=window.scrollY),r.input.focus(),M&&window.scrollTo(null,me),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=xe,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function Se(){if(n.selectionStart!=null){var Be=i.somethingSelected(),ze="\u200B"+(Be?n.value:"");n.value="\u21DA",n.value=ze,t.prevInput=Be?"":"\u200B",n.selectionStart=1,n.selectionEnd=ze.length,r.selForContextMenu=i.doc.sel}}function xe(){if(t.contextMenuPending!=xe)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=te,n.style.cssText=Y,j&&B<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=N),n.selectionStart!=null){(!j||j&&B<9)&&Se();var Be=0,ze=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?Zt(i,Xo)(i):Be++<10?r.detectingSelectAll=setTimeout(ze,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(ze,200)}}if(j&&B>=9&&Se(),_){le(e);var Re=function(){qe(window,"mouseup",Re),setTimeout(xe,20)};Ce(window,"mouseup",Re)}else setTimeout(xe,50)},jt.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},jt.prototype.setUneditable=function(){},jt.prototype.needsContentAttribute=!1;function iu(e,t){if(t=t?F(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=P();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=K.getValue()}var n;if(e.form&&(Ce(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var E=e.form;n=E.submit;try{var N=E.submit=function(){r(),E.submit=n,E.submit(),E.submit=N}}catch(Y){}}t.finishInit=function(Y){Y.save=r,Y.getTextArea=function(){return e},Y.toTextArea=function(){Y.toTextArea=isNaN,r(),e.parentNode.removeChild(Y.getWrapperElement()),e.style.display="",e.form&&(qe(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var K=Nt(function(Y){return e.parentNode.insertBefore(Y,e.nextSibling)},t);return K}function nu(e){e.off=qe,e.on=Ce,e.wheelEventPixels=hl,e.Doc=fr,e.splitLines=ot,e.countColumn=ne,e.findColumn=Ae,e.isWordChar=Ee,e.Pass=Ie,e.signal=ae,e.Line=li,e.changeEnd=Jr,e.scrollbarModel=To,e.Pos=je,e.cmpPos=mt,e.modes=St,e.mimeModes=yt,e.resolveMode=Ht,e.getMode=Ut,e.modeExtensions=or,e.extendMode=wr,e.copyState=Vt,e.startState=Br,e.innerMode=Sr,e.commands=Sn,e.keyMap=zr,e.keyName=us,e.isModifierKey=ss,e.lookupKey=Fi,e.normalizeKeyMap=Pl,e.StringStream=ut,e.SharedTextMarker=bn,e.TextMarker=qr,e.LineWidget=yn,e.e_preventDefault=q,e.e_stopPropagation=Z,e.e_stop=le,e.addClass=G,e.contains=x,e.rmClass=c,e.keyNames=ei}$l(Nt),ql(Nt);var au="iter insert remove copy getEditor constructor".split(" ");for(var na in fr.prototype)fr.prototype.hasOwnProperty(na)&&ge(au,na)<0&&(Nt.prototype[na]=function(e){return function(){return e.apply(this.doc,arguments)}}(fr.prototype[na]));return oe(fr),Nt.inputStyles={textarea:jt,contenteditable:Pt},Nt.defineMode=function(e){!Nt.defaults.mode&&e!="null"&&(Nt.defaults.mode=e),rr.apply(this,arguments)},Nt.defineMIME=Wt,Nt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Nt.defineMIME("text/plain","null"),Nt.defineExtension=function(e,t){Nt.prototype[e]=t},Nt.defineDocExtension=function(e,t){fr.prototype[e]=t},Nt.fromTextArea=iu,nu(Nt),Nt.version="5.58.2",Nt})},Y1PL:function(gt,at,ue){"use strict";ue.r(at),ue.d(at,"ResizableTextArea",function(){return ge});var fe=ue("wx14"),Q=ue("1OyB"),D=ue("vuIU"),V=ue("Ji7U"),I=ue("LK+K"),y=ue("q1tI"),j=ue("VTBJ"),B=ue("rePB"),M=ue("Zm9Q"),R=ue("Kwbf"),b=ue("c+Xe"),w=ue("m+aA"),O=ue("bdgK"),A=new Map;function S(Te){Te.forEach(function(De){var we,Ae=De.target;(we=A.get(Ae))===null||we===void 0||we.forEach(function(ve){return ve(Ae)})})}var C=new O.default(S),d=null,o=null;function s(Te,De){A.has(Te)||(A.set(Te,new Set),C.observe(Te)),A.get(Te).add(De)}function u(Te,De){A.has(Te)&&(A.get(Te).delete(De),A.get(Te).size||(C.unobserve(Te),A.delete(Te)))}var T=function(Te){Object(V.a)(we,Te);var De=Object(I.a)(we);function we(){return Object(Q.a)(this,we),De.apply(this,arguments)}return Object(D.a)(we,[{key:"render",value:function(){return this.props.children}}]),we}(y.Component),m=y.createContext(null);function p(Te){var De=Te.children,we=Te.onBatchResize,Ae=y.useRef(0),ve=y.useRef([]),W=y.useContext(m),L=y.useCallback(function(k,H,ee){Ae.current+=1;var U=Ae.current;ve.current.push({size:k,element:H,data:ee}),Promise.resolve().then(function(){U===Ae.current&&(we==null||we(ve.current),ve.current=[])}),W==null||W(k,H,ee)},[we,W]);return y.createElement(m.Provider,{value:L},De)}function _(Te){var De=Te.children,we=Te.disabled,Ae=y.useRef(null),ve=y.useRef(null),W=y.useContext(m),L=y.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),k=y.isValidElement(De)&&Object(b.c)(De),H=k?De.ref:null,ee=y.useMemo(function(){return Object(b.a)(H,Ae)},[H,Ae]),U=y.useRef(Te);U.current=Te;var de=y.useCallback(function(Ee){var _e=U.current,Ue=_e.onResize,ke=_e.data,Oe=Ee.getBoundingClientRect(),Pe=Oe.width,Xe=Oe.height,Fe=Ee.offsetWidth,Ne=Ee.offsetHeight,We=Math.floor(Pe),Ze=Math.floor(Xe);if(L.current.width!==We||L.current.height!==Ze||L.current.offsetWidth!==Fe||L.current.offsetHeight!==Ne){var He={width:We,height:Ze,offsetWidth:Fe,offsetHeight:Ne};L.current=He;var Ye=Fe===Math.round(Pe)?Pe:Fe,Ce=Ne===Math.round(Xe)?Xe:Ne,$e=Object(j.a)(Object(j.a)({},He),{},{offsetWidth:Ye,offsetHeight:Ce});W==null||W($e,Ee,ke),Ue&&Promise.resolve().then(function(){Ue($e,Ee)})}},[]);return y.useEffect(function(){var Ee=Object(w.a)(Ae.current)||Object(w.a)(ve.current);return Ee&&!we&&s(Ee,de),function(){return u(Ee,de)}},[Ae.current,we]),y.createElement(T,{ref:ve},k?y.cloneElement(De,{ref:ee}):De)}var v="rc-observer-key";function c(Te){var De=Te.children,we=Object(M.a)(De);return we.map(function(Ae,ve){var W=(Ae==null?void 0:Ae.key)||"".concat(v,"-").concat(ve);return y.createElement(_,Object(fe.a)({},Te,{key:W}),Ae)})}c.Collection=p;var h=c,l=ue("bT9E"),a=ue("TSYQ"),g=ue.n(a),f=`
|
|
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"],P={},G;function X(Te){var De=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,we=Te.getAttribute("id")||Te.getAttribute("data-reactid")||Te.getAttribute("name");if(De&&P[we])return P[we];var Ae=window.getComputedStyle(Te),ve=Ae.getPropertyValue("box-sizing")||Ae.getPropertyValue("-moz-box-sizing")||Ae.getPropertyValue("-webkit-box-sizing"),W=parseFloat(Ae.getPropertyValue("padding-bottom"))+parseFloat(Ae.getPropertyValue("padding-top")),L=parseFloat(Ae.getPropertyValue("border-bottom-width"))+parseFloat(Ae.getPropertyValue("border-top-width")),k=x.map(function(ee){return"".concat(ee,":").concat(Ae.getPropertyValue(ee))}).join(";"),H={sizingStyle:k,paddingSize:W,borderSize:L,boxSizing:ve};return De&&we&&(P[we]=H),H}function ie(Te){var De=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,we=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Ae=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;G||(G=document.createElement("textarea"),G.setAttribute("tab-index","-1"),G.setAttribute("aria-hidden","true"),document.body.appendChild(G)),Te.getAttribute("wrap")?G.setAttribute("wrap",Te.getAttribute("wrap")):G.removeAttribute("wrap");var ve=X(Te,De),W=ve.paddingSize,L=ve.borderSize,k=ve.boxSizing,H=ve.sizingStyle;G.setAttribute("style","".concat(H,";").concat(f)),G.value=Te.value||Te.placeholder||"";var ee=Number.MIN_SAFE_INTEGER,U=Number.MAX_SAFE_INTEGER,de=G.scrollHeight,Ee;if(k==="border-box"?de+=L:k==="content-box"&&(de-=W),we!==null||Ae!==null){G.value=" ";var _e=G.scrollHeight-W;we!==null&&(ee=_e*we,k==="border-box"&&(ee=ee+W+L),de=Math.max(ee,de)),Ae!==null&&(U=_e*Ae,k==="border-box"&&(U=U+W+L),Ee=de>U?"":"hidden",de=Math.min(U,de))}return{height:de,minHeight:ee,maxHeight:U,overflowY:Ee,resize:"none"}}var z=ue("Gytx"),F=ue.n(z),ne;(function(Te){Te[Te.NONE=0]="NONE",Te[Te.RESIZING=1]="RESIZING",Te[Te.RESIZED=2]="RESIZED"})(ne||(ne={}));var ce=function(Te){Object(V.a)(we,Te);var De=Object(I.a)(we);function we(Ae){var ve;return Object(Q.a)(this,we),ve=De.call(this,Ae),ve.nextFrameActionId=void 0,ve.resizeFrameId=void 0,ve.textArea=void 0,ve.saveTextArea=function(W){ve.textArea=W},ve.handleResize=function(W){var L=ve.state.resizeStatus,k=ve.props,H=k.autoSize,ee=k.onResize;if(L!==ne.NONE)return;typeof ee=="function"&&ee(W),H&&ve.resizeOnNextFrame()},ve.resizeOnNextFrame=function(){cancelAnimationFrame(ve.nextFrameActionId),ve.nextFrameActionId=requestAnimationFrame(ve.resizeTextarea)},ve.resizeTextarea=function(){var W=ve.props.autoSize;if(!W||!ve.textArea)return;var L=W.minRows,k=W.maxRows,H=ie(ve.textArea,!1,L,k);ve.setState({textareaStyles:H,resizeStatus:ne.RESIZING},function(){cancelAnimationFrame(ve.resizeFrameId),ve.resizeFrameId=requestAnimationFrame(function(){ve.setState({resizeStatus:ne.RESIZED},function(){ve.resizeFrameId=requestAnimationFrame(function(){ve.setState({resizeStatus:ne.NONE}),ve.fixFirefoxAutoScroll()})})})})},ve.renderTextArea=function(){var W=ve.props,L=W.prefixCls,k=L===void 0?"rc-textarea":L,H=W.autoSize,ee=W.onResize,U=W.className,de=W.disabled,Ee=ve.state,_e=Ee.textareaStyles,Ue=Ee.resizeStatus,ke=Object(l.a)(ve.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Oe=g()(k,U,Object(B.a)({},"".concat(k,"-disabled"),de));"value"in ke&&(ke.value=ke.value||"");var Pe=Object(j.a)(Object(j.a)(Object(j.a)({},ve.props.style),_e),Ue===ne.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return y.createElement(h,{onResize:ve.handleResize,disabled:!(H||ee)},y.createElement("textarea",Object(fe.a)({},ke,{className:Oe,style:Pe,ref:ve.saveTextArea})))},ve.state={textareaStyles:{},resizeStatus:ne.NONE},ve}return Object(D.a)(we,[{key:"componentDidUpdate",value:function(ve){(ve.value!==this.props.value||!F()(ve.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 ve=this.textArea.selectionStart,W=this.textArea.selectionEnd;this.textArea.setSelectionRange(ve,W)}}catch(L){}}},{key:"render",value:function(){return this.renderTextArea()}}]),we}(y.Component),ge=ce,be=function(Te){Object(V.a)(we,Te);var De=Object(I.a)(we);function we(Ae){var ve;Object(Q.a)(this,we),ve=De.call(this,Ae),ve.resizableTextArea=void 0,ve.focus=function(){ve.resizableTextArea.textArea.focus()},ve.saveTextArea=function(L){ve.resizableTextArea=L},ve.handleChange=function(L){var k=ve.props.onChange;ve.setValue(L.target.value,function(){ve.resizableTextArea.resizeTextarea()}),k&&k(L)},ve.handleKeyDown=function(L){var k=ve.props,H=k.onPressEnter,ee=k.onKeyDown;L.keyCode===13&&H&&H(L),ee&&ee(L)};var W=typeof Ae.value=="undefined"||Ae.value===null?Ae.defaultValue:Ae.value;return ve.state={value:W},ve}return Object(D.a)(we,[{key:"setValue",value:function(ve,W){"value"in this.props||this.setState({value:ve},W)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return y.createElement(ge,Object(fe.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(ve){return"value"in ve?{value:ve.value}:null}}]),we}(y.Component),Ie=at.default=be},bT9E:function(gt,at,ue){"use strict";ue.d(at,"a",function(){return Q});var fe=ue("VTBJ");function Q(D,V){var I=Object(fe.a)({},D);return Array.isArray(V)&&V.forEach(function(y){delete I[y]}),I}},c5Ni:function(gt,at,ue){},dejd:function(gt,at,ue){},dmUQ:function(gt,at,ue){"use strict";var fe=ue("Ff2n"),Q=ue("rePB"),D=ue("1OyB"),V=ue("vuIU"),I=ue("Ji7U"),y=ue("md7G"),j=ue("foSv"),B=ue("q1tI"),M=ue.n(B),R=ue("TSYQ"),b=ue.n(R),w=ue("4IlW");function O(l,a){var g=Object.keys(l);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(l);a&&(f=f.filter(function(x){return Object.getOwnPropertyDescriptor(l,x).enumerable})),g.push.apply(g,f)}return g}function A(l){for(var a=1;a<arguments.length;a++){var g=arguments[a]!=null?arguments[a]:{};a%2?O(Object(g),!0).forEach(function(f){Object(Q.a)(l,f,g[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(g)):O(Object(g)).forEach(function(f){Object.defineProperty(l,f,Object.getOwnPropertyDescriptor(g,f))})}return l}function S(l){var a=C();return function(){var f=Object(j.a)(l),x;if(a){var P=Object(j.a)(this).constructor;x=Reflect.construct(f,arguments,P)}else x=f.apply(this,arguments);return Object(y.a)(this,x)}}function C(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(l){return!1}}function d(){}function o(l){l.preventDefault()}var s=function(a){return a.replace(/[^\w.-]+/g,"")},u=200,T=600,m=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,p=function(a){return a!=null},_=function(a,g){return g===a||typeof g=="number"&&typeof a=="number"&&isNaN(g)&&isNaN(a)},v=function(l){Object(I.a)(g,l);var a=S(g);function g(f){var x;Object(D.a)(this,g),x=a.call(this,f),x.onKeyDown=function(X){var ie=x.props,z=ie.onKeyDown,F=ie.onPressEnter;if(X.keyCode===w.a.UP){var ne=x.getRatio(X);x.up(X,ne,null),x.stop()}else if(X.keyCode===w.a.DOWN){var ce=x.getRatio(X);x.down(X,ce,null),x.stop()}else X.keyCode===w.a.ENTER&&F&&F(X);if(x.recordCursorPosition(),x.lastKeyCode=X.keyCode,z){for(var ge=arguments.length,be=new Array(ge>1?ge-1:0),Ie=1;Ie<ge;Ie++)be[Ie-1]=arguments[Ie];z.apply(void 0,[X].concat(be))}},x.onKeyUp=function(X){var ie=x.props.onKeyUp;if(x.stop(),x.recordCursorPosition(),ie){for(var z=arguments.length,F=new Array(z>1?z-1:0),ne=1;ne<z;ne++)F[ne-1]=arguments[ne];ie.apply(void 0,[X].concat(F))}},x.onChange=function(X){var ie=x.props.onChange;x.state.focused&&(x.inputting=!0),x.rawInput=x.props.parser(x.getValueFromEvent(X)),x.setState({inputValue:x.rawInput}),ie(x.toNumber(x.rawInput))},x.onMouseUp=function(){var X=x.props.onMouseUp;x.recordCursorPosition(),X&&X.apply(void 0,arguments)},x.onFocus=function(){var X;x.setState({focused:!0}),(X=x.props).onFocus.apply(X,arguments)},x.onBlur=function(){var X=x.props.onBlur;x.inputting=!1,x.setState({focused:!1});var ie=x.getCurrentValidValue(x.state.inputValue),z=x.setValue(ie,d);if(X){var F=x.input.value,ne=x.getInputDisplayValue({focus:!1,value:z});x.input.value=ne&&Number(ne),X.apply(void 0,arguments),x.input.value=F}},x.getRatio=function(X){var ie=1;return X.metaKey||X.ctrlKey?ie=.1:X.shiftKey&&(ie=10),ie},x.getFullNum=function(X){return isNaN(X)?X:/e/i.test(String(X))?Number(X).toFixed(18).replace(/\.?0+$/,""):X},x.getPrecision=function(X){if(p(x.props.precision))return x.props.precision;var ie=String(X);if(ie.indexOf("e-")>=0)return parseInt(ie.slice(ie.indexOf("e-")+2),10);var z=0;return ie.indexOf(".")>=0&&(z=ie.length-ie.indexOf(".")-1),z},x.getInputDisplayValue=function(X){var ie=X||x.state,z=ie.focused,F=ie.inputValue,ne=ie.value,ce;z?ce=F:ce=x.toPrecisionAsStep(ne),ce==null&&(ce="");var ge=x.formatWrapper(ce);return p(x.props.decimalSeparator)&&(ge=ge.toString().replace(".",x.props.decimalSeparator)),ge},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(X){}},x.restoreByAfter=function(X){if(X===void 0)return!1;var ie=x.input.value,z=ie.lastIndexOf(X);if(z===-1)return!1;var F=x.cursorBefore.length;return x.lastKeyCode===w.a.DELETE&&x.cursorBefore.charAt(F-1)===X[0]?(x.fixCaret(F,F),!0):z+X.length===ie.length?(x.fixCaret(z,z),!0):!1},x.partRestoreByAfter=function(X){return X===void 0?!1:Array.prototype.some.call(X,function(ie,z){var F=X.substring(z);return x.restoreByAfter(F)})},x.isNotCompleteNumber=function(X){return isNaN(X)||X===""||X===null||X&&X.toString().indexOf(".")===X.toString().length-1},x.stop=function(){x.autoStepTimer&&clearTimeout(x.autoStepTimer)},x.down=function(X,ie,z){x.pressingUpOrDown=!0,x.step("down",X,ie,z)},x.up=function(X,ie,z){x.pressingUpOrDown=!0,x.step("up",X,ie,z)},x.saveInput=function(X){x.input=X};var P=f.value;P===void 0&&(P=f.defaultValue),x.state={focused:f.autoFocus};var G=x.getValidValue(x.toNumber(P));return x.state=A(A({},x.state),{},{inputValue:x.toPrecisionAsStep(G),value:G}),x}return Object(V.a)(g,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(x){var P=this.props,G=P.value,X=P.onChange,ie=P.max,z=P.min,F=this.state.focused;if(x){if(!_(x.value,G)||!_(x.max,ie)||!_(x.min,z)){var ne=F?G:this.getValidValue(G),ce;this.pressingUpOrDown?ce=ne:this.inputting?ce=this.rawInput:ce=this.toPrecisionAsStep(ne),this.setState({value:ne,inputValue:ce})}var ge="value"in this.props?G:this.state.value;"max"in this.props&&x.max!==ie&&typeof ge=="number"&&ge>ie&&X&&X(ie),"min"in this.props&&x.min!==z&&typeof ge=="number"&&ge<z&&X&&X(z)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var be=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===w.a.BACKSPACE?be=this.cursorStart-1:this.lastKeyCode===w.a.DELETE&&(be=this.cursorStart):be=this.input.value.length,this.fixCaret(be,be)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case w.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case w.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(Ie){}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 P=x;return P===""?P="":this.isNotCompleteNumber(parseFloat(P))?P=this.state.value:P=this.getValidValue(P),this.toNumber(P)}},{key:"getValueFromEvent",value:function(x){var P=x.target.value.trim().replace(/。/g,".");return p(this.props.decimalSeparator)&&(P=P.replace(this.props.decimalSeparator,".")),P}},{key:"getValidValue",value:function(x){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,X=parseFloat(x);return isNaN(X)?x:(X<P&&(X=P),X>G&&(X=G),X)}},{key:"setValue",value:function(x,P){var G=this.props.precision,X=this.isNotCompleteNumber(parseFloat(x))?null:parseFloat(x),ie=this.state.value,z=ie===void 0?null:ie,F=this.state.inputValue,ne=F===void 0?null:F,ce=typeof X=="number"?X.toFixed(G):"".concat(X),ge=X!==z||ce!=="".concat(ne);return"value"in this.props?(ne=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:ne},P)):this.setState({value:X,inputValue:this.toPrecisionAsStep(x)},P),ge&&this.props.onChange(X),X}},{key:"getMaxPrecision",value:function(x){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.props,X=G.precision,ie=G.step;if(p(X))return X;var z=this.getPrecision(P),F=this.getPrecision(ie),ne=this.getPrecision(x);return x?Math.max(ne,z+F):z+F}},{key:"getPrecisionFactor",value:function(x){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.getMaxPrecision(x,P);return Math.pow(10,G)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(x){return this.props.formatter?this.props.formatter(x):x}},{key:"toPrecisionAsStep",value:function(x){if(this.isNotCompleteNumber(x)||x==="")return x;var P=Math.abs(this.getMaxPrecision(x));return isNaN(P)?x.toString():Number(x).toFixed(P)}},{key:"toNumber",value:function(x){var P=this.props.precision,G=this.state.focused,X=x&&x.length>16&&G;return this.isNotCompleteNumber(x)||X?x:p(P)?Math.round(x*Math.pow(10,P))/Math.pow(10,P):Number(x)}},{key:"upStep",value:function(x,P){var G=this.props.step,X=this.getPrecisionFactor(x,P),ie=Math.abs(this.getMaxPrecision(x,P)),z=((X*x+X*G*P)/X).toFixed(ie);return this.toNumber(z)}},{key:"downStep",value:function(x,P){var G=this.props.step,X=this.getPrecisionFactor(x,P),ie=Math.abs(this.getMaxPrecision(x,P)),z=((X*x-X*G*P)/X).toFixed(ie);return this.toNumber(z)}},{key:"step",value:function(x,P){var G=this,X=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,ie=arguments.length>3?arguments[3]:void 0;this.stop(),P&&(P.persist(),P.preventDefault());var z=this.props;if(z.disabled)return;var F=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(F))return;var ne=this["".concat(x,"Step")](F,X),ce=ne>z.max||ne<z.min;if(ne>z.max?ne=z.max:ne<z.min&&(ne=z.min),this.setValue(ne,null),this.setState({focused:!0},function(){G.pressingUpOrDown=!1}),ce)return;this.autoStepTimer=setTimeout(function(){G[x](P,X,!0)},ie?u:T)}},{key:"fixCaret",value:function(x,P){if(x===void 0||P===void 0||!this.input||!this.input.value)return;try{var G=this.input.selectionStart,X=this.input.selectionEnd;(x!==G||P!==X)&&this.input.setSelectionRange(x,P)}catch(ie){}}},{key:"render",value:function(){var x,P=this.props,G=P.prefixCls,X=P.disabled,ie=P.readOnly,z=P.useTouch,F=P.autoComplete,ne=P.upHandler,ce=P.downHandler,ge=P.className,be=P.max,Ie=P.min,Te=P.style,De=P.title,we=P.onMouseEnter,Ae=P.onMouseLeave,ve=P.onMouseOver,W=P.onMouseOut,L=P.required,k=P.onClick,H=P.tabIndex,ee=P.type,U=P.placeholder,de=P.id,Ee=P.inputMode,_e=P.pattern,Ue=P.step,ke=P.maxLength,Oe=P.autoFocus,Pe=P.name,Xe=P.onPaste,Fe=P.onInput,Ne=Object(fe.a)(P,["prefixCls","disabled","readOnly","useTouch","autoComplete","upHandler","downHandler","className","max","min","style","title","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","required","onClick","tabIndex","type","placeholder","id","inputMode","pattern","step","maxLength","autoFocus","name","onPaste","onInput"]),We=this.state,Ze=We.value,He=We.focused,Ye=b()(G,(x={},Object(Q.a)(x,ge,!!ge),Object(Q.a)(x,"".concat(G,"-disabled"),X),Object(Q.a)(x,"".concat(G,"-focused"),He),x)),Ce={};Object.keys(Ne).forEach(function(le){(le.substr(0,5)==="data-"||le.substr(0,5)==="aria-"||le==="role")&&(Ce[le]=Ne[le])});var $e=!ie&&!X,qe=this.getInputDisplayValue(null),ae=(Ze||Ze===0)&&(isNaN(Ze)||Number(Ze)>=be),J=(Ze||Ze===0)&&(isNaN(Ze)||Number(Ze)<=Ie),$=ae||X||ie,re=J||X||ie,oe=b()("".concat(G,"-handler"),"".concat(G,"-handler-up"),Object(Q.a)({},"".concat(G,"-handler-up-disabled"),$)),q=b()("".concat(G,"-handler"),"".concat(G,"-handler-down"),Object(Q.a)({},"".concat(G,"-handler-down-disabled"),re)),Z=z?{onTouchStart:$?d:this.up,onTouchEnd:this.stop}:{onMouseDown:$?d:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},se=z?{onTouchStart:re?d:this.down,onTouchEnd:this.stop}:{onMouseDown:re?d:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return M.a.createElement("div",{className:Ye,style:Te,title:De,onMouseEnter:we,onMouseLeave:Ae,onMouseOver:ve,onMouseOut:W,onFocus:function(){return null},onBlur:function(){return null}},M.a.createElement("div",{className:"".concat(G,"-handler-wrap")},M.a.createElement("span",Object.assign({unselectable:"on"},Z,{role:"button","aria-label":"Increase Value","aria-disabled":$,className:oe}),ne||M.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-up-inner"),onClick:o})),M.a.createElement("span",Object.assign({unselectable:"on"},se,{role:"button","aria-label":"Decrease Value","aria-disabled":re,className:q}),ce||M.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-down-inner"),onClick:o}))),M.a.createElement("div",{className:"".concat(G,"-input-wrap")},M.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":Ie,"aria-valuemax":be,"aria-valuenow":Ze,required:L,type:ee,placeholder:U,onPaste:Xe,onClick:k,onMouseUp:this.onMouseUp,className:"".concat(G,"-input"),tabIndex:H,autoComplete:F,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:$e?this.onKeyDown:d,onKeyUp:$e?this.onKeyUp:d,autoFocus:Oe,maxLength:ke,readOnly:ie,disabled:X,max:be,min:Ie,step:Ue,name:Pe,title:De,id:de,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(qe),pattern:_e,inputMode:Ee,onInput:Fe},Ce))))}}]),g}(M.a.Component);v.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:m,min:-m,step:1,style:{},onChange:d,onKeyDown:d,onPressEnter:d,onFocus:d,onBlur:d,parser:s,required:!1,autoComplete:"off"};var c=v,h=at.a=c},kSUc:function(gt,at,ue){},"kaH+":function(gt,at,ue){"use strict";var fe=ue("+L6B"),Q=ue("2/Rp"),D=ue("tJVT"),V=ue("q1tI"),I=ue.n(V),y=ue("UZu5"),j=ue.n(y),B=ue("dhSg"),M=ue("rLCj"),R=ue("dF/Y"),b=ue("4i/N");at.a=function(){var w=Object(V.useState)(""),O=Object(D.a)(w,2),A=O[0],S=O[1],C=Object(V.useState)(0),d=Object(D.a)(C,2),o=d[0],s=d[1],u=Object(V.useRef)("");Object(V.useEffect)(function(){var h=B.a.subscribe("preview-image",function(l){S(l),document.body.style.overflow="hidden"});return h},[]),Object(V.useEffect)(function(){return document.addEventListener("keydown",T),function(){document.removeEventListener("keydown",T)}},[]),Object(V.useEffect)(function(){u.current=A},[A]);function T(h){h.keyCode==27&&u.current&&m()}function m(){document.body.style.overflow="auto",S("")}function p(){s(o+90)}var _=Object(V.useRef)(),v=Object(V.useRef)(),c=function(l){(l.nativeEvent.target===_.current||l.nativeEvent.target===v.current)&&m()};return I.a.createElement(V.Fragment,null,A?I.a.createElement("div",{className:"image-preview-container",ref:_,onClick:c},I.a.createElement("div",{className:"button-group"},I.a.createElement(Q.a,{onClick:p},"\u65CB\u8F6C",I.a.createElement(M.a,null)),I.a.createElement(Q.a,{href:A},"\u4E0B\u8F7D",I.a.createElement(R.a,null)),I.a.createElement(Q.a,{onClick:m},"\u5173\u95ED",I.a.createElement(b.a,null))),I.a.createElement("div",{className:"preview-wrp-group",ref:v},I.a.createElement("img",{className:"image-preview",src:A,alt:"\u9884\u89C8\u5927\u56FE",style:{transform:"rotate(".concat(o,"deg)")}}))):null)}},lZu9:function(gt,at,ue){(function(fe){fe(ue("VrN/"),ue("1eCo"),ue("8EBN"))})(function(fe){"use strict";fe.defineMode("markdown",function(Q,D){var V=fe.getMode(Q,"text/html"),I=V.name=="null";function y(z){if(fe.findModeByName){var F=fe.findModeByName(z);F&&(z=F.mime||F.mimes[0])}var ne=fe.getMode(Q,z);return ne.name=="null"?null:ne}D.highlightFormatting===void 0&&(D.highlightFormatting=!1),D.maxBlockquoteDepth===void 0&&(D.maxBlockquoteDepth=0),D.taskLists===void 0&&(D.taskLists=!1),D.strikethrough===void 0&&(D.strikethrough=!1),D.emoji===void 0&&(D.emoji=!1),D.fencedCodeBlockHighlighting===void 0&&(D.fencedCodeBlockHighlighting=!0),D.fencedCodeBlockDefaultMode===void 0&&(D.fencedCodeBlockDefaultMode="text/plain"),D.xml===void 0&&(D.xml=!0),D.tokenTypeOverrides===void 0&&(D.tokenTypeOverrides={});var j={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 B in j)j.hasOwnProperty(B)&&D.tokenTypeOverrides[B]&&(j[B]=D.tokenTypeOverrides[B]);var M=/^([*\-_])(?:\s*\1){2,}\s*$/,R=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,b=/^\[(x| )\](?=\s)/i,w=D.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,O=/^ {0,3}(?:\={1,}|-{2,})\s*$/,A=/^[^#!\[\]*_\\<>` "'(~:]+/,S=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,C=/^\s*\[[^\]]+?\]:.*$/,d=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function s(z,F,ne){return F.f=F.inline=ne,ne(z,F)}function u(z,F,ne){return F.f=F.block=ne,ne(z,F)}function T(z){return!z||!/\S/.test(z.string)}function m(z){if(z.linkTitle=!1,z.linkHref=!1,z.linkText=!1,z.em=!1,z.strong=!1,z.strikethrough=!1,z.quote=0,z.indentedCode=!1,z.f==_){var F=I;if(!F){var ne=fe.innerMode(V,z.htmlState);F=ne.mode.name=="xml"&&ne.state.tagStart===null&&!ne.state.context&&ne.state.tokenize.isInText}F&&(z.f=l,z.block=p,z.htmlState=null)}return z.trailingSpace=0,z.trailingSpaceNewLine=!1,z.prevLine=z.thisLine,z.thisLine={stream:null},null}function p(z,F){var ne=z.column()===F.indentation,ce=T(F.prevLine.stream),ge=F.indentedCode,be=F.prevLine.hr,Ie=F.list!==!1,Te=(F.listStack[F.listStack.length-1]||0)+3;F.indentedCode=!1;var De=F.indentation;if(F.indentationDiff===null&&(F.indentationDiff=F.indentation,Ie)){for(F.list=null;De<F.listStack[F.listStack.length-1];)F.listStack.pop(),F.listStack.length?F.indentation=F.listStack[F.listStack.length-1]:F.list=!1;F.list!==!1&&(F.indentationDiff=De-F.listStack[F.listStack.length-1])}var we=!ce&&!be&&!F.prevLine.header&&(!Ie||!ge)&&!F.prevLine.fencedCodeEnd,Ae=(F.list===!1||be||ce)&&F.indentation<=Te&&z.match(M),ve=null;if(F.indentationDiff>=4&&(ge||F.prevLine.fencedCodeEnd||F.prevLine.header||ce))return z.skipToEnd(),F.indentedCode=!0,j.code;if(z.eatSpace())return null;if(ne&&F.indentation<=Te&&(ve=z.match(w))&&ve[1].length<=6)return F.quote=0,F.header=ve[1].length,F.thisLine.header=!0,D.highlightFormatting&&(F.formatting="header"),F.f=F.inline,c(F);if(F.indentation<=Te&&z.eat(">"))return F.quote=ne?1:F.quote+1,D.highlightFormatting&&(F.formatting="quote"),z.eatSpace(),c(F);if(!Ae&&!F.setext&&ne&&F.indentation<=Te&&(ve=z.match(R))){var W=ve[1]?"ol":"ul";return F.indentation=De+z.current().length,F.list=!0,F.quote=0,F.listStack.push(F.indentation),F.em=!1,F.strong=!1,F.code=!1,F.strikethrough=!1,D.taskLists&&z.match(b,!1)&&(F.taskList=!0),F.f=F.inline,D.highlightFormatting&&(F.formatting=["list","list-"+W]),c(F)}else{if(ne&&F.indentation<=Te&&(ve=z.match(S,!0)))return F.quote=0,F.fencedEndRE=new RegExp(ve[1]+"+ *$"),F.localMode=D.fencedCodeBlockHighlighting&&y(ve[2]||D.fencedCodeBlockDefaultMode),F.localMode&&(F.localState=fe.startState(F.localMode)),F.f=F.block=v,D.highlightFormatting&&(F.formatting="code-block"),F.code=-1,c(F);if(F.setext||(!we||!Ie)&&!F.quote&&F.list===!1&&!F.code&&!Ae&&!C.test(z.string)&&(ve=z.lookAhead(1))&&(ve=ve.match(O)))return F.setext?(F.header=F.setext,F.setext=0,z.skipToEnd(),D.highlightFormatting&&(F.formatting="header")):(F.header=ve[0].charAt(0)=="="?1:2,F.setext=F.header),F.thisLine.header=!0,F.f=F.inline,c(F);if(Ae)return z.skipToEnd(),F.hr=!0,F.thisLine.hr=!0,j.hr;if(z.peek()==="[")return s(z,F,P)}return s(z,F,F.inline)}function _(z,F){var ne=V.token(z,F.htmlState);if(!I){var ce=fe.innerMode(V,F.htmlState);(ce.mode.name=="xml"&&ce.state.tagStart===null&&!ce.state.context&&ce.state.tokenize.isInText||F.md_inside&&z.current().indexOf(">")>-1)&&(F.f=l,F.block=p,F.htmlState=null)}return ne}function v(z,F){var ne=F.listStack[F.listStack.length-1]||0,ce=F.indentation<ne,ge=ne+3;if(F.fencedEndRE&&F.indentation<=ge&&(ce||z.match(F.fencedEndRE))){D.highlightFormatting&&(F.formatting="code-block");var be;return ce||(be=c(F)),F.localMode=F.localState=null,F.block=p,F.f=l,F.fencedEndRE=null,F.code=0,F.thisLine.fencedCodeEnd=!0,ce?u(z,F,F.block):be}else return F.localMode?F.localMode.token(z,F.localState):(z.skipToEnd(),j.code)}function c(z){var F=[];if(z.formatting){F.push(j.formatting),typeof z.formatting=="string"&&(z.formatting=[z.formatting]);for(var ne=0;ne<z.formatting.length;ne++)F.push(j.formatting+"-"+z.formatting[ne]),z.formatting[ne]==="header"&&F.push(j.formatting+"-"+z.formatting[ne]+"-"+z.header),z.formatting[ne]==="quote"&&(!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=z.quote?F.push(j.formatting+"-"+z.formatting[ne]+"-"+z.quote):F.push("error"))}if(z.taskOpen)return F.push("meta"),F.length?F.join(" "):null;if(z.taskClosed)return F.push("property"),F.length?F.join(" "):null;if(z.linkHref?F.push(j.linkHref,"url"):(z.strong&&F.push(j.strong),z.em&&F.push(j.em),z.strikethrough&&F.push(j.strikethrough),z.emoji&&F.push(j.emoji),z.linkText&&F.push(j.linkText),z.code&&F.push(j.code),z.image&&F.push(j.image),z.imageAltText&&F.push(j.imageAltText,"link"),z.imageMarker&&F.push(j.imageMarker)),z.header&&F.push(j.header,j.header+"-"+z.header),z.quote&&(F.push(j.quote),!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=z.quote?F.push(j.quote+"-"+z.quote):F.push(j.quote+"-"+D.maxBlockquoteDepth)),z.list!==!1){var ce=(z.listStack.length-1)%3;ce?ce===1?F.push(j.list2):F.push(j.list3):F.push(j.list1)}return z.trailingSpaceNewLine?F.push("trailing-space-new-line"):z.trailingSpace&&F.push("trailing-space-"+(z.trailingSpace%2?"a":"b")),F.length?F.join(" "):null}function h(z,F){return z.match(A,!0)?c(F):void 0}function l(z,F){var ne=F.text(z,F);if(typeof ne!="undefined")return ne;if(F.list)return F.list=null,c(F);if(F.taskList){var ce=z.match(b,!0)[1]===" ";return ce?F.taskOpen=!0:F.taskClosed=!0,D.highlightFormatting&&(F.formatting="task"),F.taskList=!1,c(F)}if(F.taskOpen=!1,F.taskClosed=!1,F.header&&z.match(/^#+$/,!0))return D.highlightFormatting&&(F.formatting="header"),c(F);var ge=z.next();if(F.linkTitle){F.linkTitle=!1;var be=ge;ge==="("&&(be=")"),be=(be+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var Ie="^\\s*(?:[^"+be+"\\\\]+|\\\\\\\\|\\\\.)"+be;if(z.match(new RegExp(Ie),!0))return j.linkHref}if(ge==="`"){var Te=F.formatting;D.highlightFormatting&&(F.formatting="code"),z.eatWhile("`");var De=z.current().length;if(F.code==0&&(!F.quote||De==1))return F.code=De,c(F);if(De==F.code){var we=c(F);return F.code=0,we}else return F.formatting=Te,c(F)}else if(F.code)return c(F);if(ge==="\\"&&(z.next(),D.highlightFormatting)){var Ae=c(F),ve=j.formatting+"-escape";return Ae?Ae+" "+ve:ve}if(ge==="!"&&z.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return F.imageMarker=!0,F.image=!0,D.highlightFormatting&&(F.formatting="image"),c(F);if(ge==="["&&F.imageMarker&&z.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return F.imageMarker=!1,F.imageAltText=!0,D.highlightFormatting&&(F.formatting="image"),c(F);if(ge==="]"&&F.imageAltText){D.highlightFormatting&&(F.formatting="image");var Ae=c(F);return F.imageAltText=!1,F.image=!1,F.inline=F.f=g,Ae}if(ge==="["&&!F.image)return F.linkText&&z.match(/^.*?\]/)||(F.linkText=!0,D.highlightFormatting&&(F.formatting="link")),c(F);if(ge==="]"&&F.linkText){D.highlightFormatting&&(F.formatting="link");var Ae=c(F);return F.linkText=!1,F.inline=F.f=z.match(/\(.*?\)| ?\[.*?\]/,!1)?g:l,Ae}if(ge==="<"&&z.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){F.f=F.inline=a,D.highlightFormatting&&(F.formatting="link");var Ae=c(F);return Ae?Ae+=" ":Ae="",Ae+j.linkInline}if(ge==="<"&&z.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){F.f=F.inline=a,D.highlightFormatting&&(F.formatting="link");var Ae=c(F);return Ae?Ae+=" ":Ae="",Ae+j.linkEmail}if(D.xml&&ge==="<"&&z.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var W=z.string.indexOf(">",z.pos);if(W!=-1){var L=z.string.substring(z.start,W);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(L)&&(F.md_inside=!0)}return z.backUp(1),F.htmlState=fe.startState(V),u(z,F,_)}if(D.xml&&ge==="<"&&z.match(/^\/\w*?>/))return F.md_inside=!1,"tag";if(ge==="*"||ge==="_"){for(var k=1,H=z.pos==1?" ":z.string.charAt(z.pos-2);k<3&&z.eat(ge);)k++;var ee=z.peek()||" ",U=!/\s/.test(ee)&&(!d.test(ee)||/\s/.test(H)||d.test(H)),de=!/\s/.test(H)&&(!d.test(H)||/\s/.test(ee)||d.test(ee)),Ee=null,_e=null;if(k%2&&(!F.em&&U&&(ge==="*"||!de||d.test(H))?Ee=!0:F.em==ge&&de&&(ge==="*"||!U||d.test(ee))&&(Ee=!1)),k>1&&(!F.strong&&U&&(ge==="*"||!de||d.test(H))?_e=!0:F.strong==ge&&de&&(ge==="*"||!U||d.test(ee))&&(_e=!1)),_e!=null||Ee!=null){D.highlightFormatting&&(F.formatting=Ee==null?"strong":_e==null?"em":"strong em"),Ee===!0&&(F.em=ge),_e===!0&&(F.strong=ge);var we=c(F);return Ee===!1&&(F.em=!1),_e===!1&&(F.strong=!1),we}}else if(ge===" "&&(z.eat("*")||z.eat("_"))){if(z.peek()===" ")return c(F);z.backUp(1)}if(D.strikethrough){if(ge==="~"&&z.eatWhile(ge)){if(F.strikethrough){D.highlightFormatting&&(F.formatting="strikethrough");var we=c(F);return F.strikethrough=!1,we}else if(z.match(/^[^\s]/,!1))return F.strikethrough=!0,D.highlightFormatting&&(F.formatting="strikethrough"),c(F)}else if(ge===" "&&z.match(/^~~/,!0)){if(z.peek()===" ")return c(F);z.backUp(2)}}if(D.emoji&&ge===":"&&z.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){F.emoji=!0,D.highlightFormatting&&(F.formatting="emoji");var Ue=c(F);return F.emoji=!1,Ue}return ge===" "&&(z.match(/^ +$/,!1)?F.trailingSpace++:F.trailingSpace&&(F.trailingSpaceNewLine=!0)),c(F)}function a(z,F){var ne=z.next();if(ne===">"){F.f=F.inline=l,D.highlightFormatting&&(F.formatting="link");var ce=c(F);return ce?ce+=" ":ce="",ce+j.linkInline}return z.match(/^[^>]+/,!0),j.linkInline}function g(z,F){if(z.eatSpace())return null;var ne=z.next();return ne==="("||ne==="["?(F.f=F.inline=x(ne==="("?")":"]"),D.highlightFormatting&&(F.formatting="link-string"),F.linkHref=!0,c(F)):"error"}var f={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function x(z){return function(F,ne){var ce=F.next();if(ce===z){ne.f=ne.inline=l,D.highlightFormatting&&(ne.formatting="link-string");var ge=c(ne);return ne.linkHref=!1,ge}return F.match(f[z]),ne.linkHref=!0,c(ne)}}function P(z,F){return z.match(/^([^\]\\]|\\.)*\]:/,!1)?(F.f=G,z.next(),D.highlightFormatting&&(F.formatting="link"),F.linkText=!0,c(F)):s(z,F,l)}function G(z,F){if(z.match(/^\]:/,!0)){F.f=F.inline=X,D.highlightFormatting&&(F.formatting="link");var ne=c(F);return F.linkText=!1,ne}return z.match(/^([^\]\\]|\\.)+/,!0),j.linkText}function X(z,F){return z.eatSpace()?null:(z.match(/^[^\s]+/,!0),z.peek()===void 0?F.linkTitle=!0:z.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),F.f=F.inline=l,j.linkHref+" url")}var ie={startState:function(){return{f:p,prevLine:{stream:null},thisLine:{stream:null},block:p,htmlState:null,indentation:0,inline:l,text:h,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(z){return{f:z.f,prevLine:z.prevLine,thisLine:z.thisLine,block:z.block,htmlState:z.htmlState&&fe.copyState(V,z.htmlState),indentation:z.indentation,localMode:z.localMode,localState:z.localMode?fe.copyState(z.localMode,z.localState):null,inline:z.inline,text:z.text,formatting:!1,linkText:z.linkText,linkTitle:z.linkTitle,linkHref:z.linkHref,code:z.code,em:z.em,strong:z.strong,strikethrough:z.strikethrough,emoji:z.emoji,header:z.header,setext:z.setext,hr:z.hr,taskList:z.taskList,list:z.list,listStack:z.listStack.slice(0),quote:z.quote,indentedCode:z.indentedCode,trailingSpace:z.trailingSpace,trailingSpaceNewLine:z.trailingSpaceNewLine,md_inside:z.md_inside,fencedEndRE:z.fencedEndRE}},token:function(z,F){if(F.formatting=!1,z!=F.thisLine.stream){if(F.header=0,F.hr=!1,z.match(/^\s*$/,!0))return m(F),null;if(F.prevLine=F.thisLine,F.thisLine={stream:z},F.taskList=!1,F.trailingSpace=0,F.trailingSpaceNewLine=!1,!F.localState&&(F.f=F.block,F.f!=_)){var ne=z.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(F.indentation=ne,F.indentationDiff=null,ne>0)return null}}return F.f(z,F)},innerMode:function(z){return z.block==_?{state:z.htmlState,mode:V}:z.localState?{state:z.localState,mode:z.localMode}:{state:z,mode:ie}},indent:function(z,F,ne){return z.block==_&&V.indent?V.indent(z.htmlState,F,ne):z.localState&&z.localMode.indent?z.localMode.indent(z.localState,F,ne):fe.Pass},blankLine:m,getType:c,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return ie},"xml"),fe.defineMIME("text/markdown","markdown"),fe.defineMIME("text/x-markdown","markdown")})},osHv:function(gt,at,ue){(function(fe){fe(ue("VrN/"))})(function(fe){"use strict";var Q=fe.Pos;function D(d,o){return d.line-o.line||d.ch-o.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",y=new RegExp("<(/?)(["+V+"]["+I+"]*)","g");function j(d,o,s,u){this.line=o,this.ch=s,this.cm=d,this.text=d.getLine(o),this.min=u?Math.max(u.from,d.firstLine()):d.firstLine(),this.max=u?Math.min(u.to-1,d.lastLine()):d.lastLine()}function B(d,o){var s=d.cm.getTokenTypeAt(Q(d.line,o));return s&&/\btag\b/.test(s)}function M(d){return d.line>=d.max?void 0:(d.ch=0,d.text=d.cm.getLine(++d.line),!0)}function R(d){return d.line<=d.min?void 0:(d.text=d.cm.getLine(--d.line),d.ch=d.text.length,!0)}function b(d){for(;;){var o=d.text.indexOf(">",d.ch);if(o==-1){if(M(d))continue;return}if(!B(d,o+1)){d.ch=o+1;continue}var s=d.text.lastIndexOf("/",o),u=s>-1&&!/\S/.test(d.text.slice(s+1,o));return d.ch=o+1,u?"selfClose":"regular"}}function w(d){for(;;){var o=d.ch?d.text.lastIndexOf("<",d.ch-1):-1;if(o==-1){if(R(d))continue;return}if(!B(d,o+1)){d.ch=o;continue}y.lastIndex=o,d.ch=o;var s=y.exec(d.text);if(s&&s.index==o)return s}}function O(d){for(;;){y.lastIndex=d.ch;var o=y.exec(d.text);if(!o){if(M(d))continue;return}if(!B(d,o.index+1)){d.ch=o.index+1;continue}return d.ch=o.index+o[0].length,o}}function A(d){for(;;){var o=d.ch?d.text.lastIndexOf(">",d.ch-1):-1;if(o==-1){if(R(d))continue;return}if(!B(d,o+1)){d.ch=o;continue}var s=d.text.lastIndexOf("/",o),u=s>-1&&!/\S/.test(d.text.slice(s+1,o));return d.ch=o+1,u?"selfClose":"regular"}}function S(d,o){for(var s=[];;){var u=O(d),T,m=d.line,p=d.ch-(u?u[0].length:0);if(!u||!(T=b(d)))return;if(T=="selfClose")continue;if(u[1]){for(var _=s.length-1;_>=0;--_)if(s[_]==u[2]){s.length=_;break}if(_<0&&(!o||o==u[2]))return{tag:u[2],from:Q(m,p),to:Q(d.line,d.ch)}}else s.push(u[2])}}function C(d,o){for(var s=[];;){var u=A(d);if(!u)return;if(u=="selfClose"){w(d);continue}var T=d.line,m=d.ch,p=w(d);if(!p)return;if(p[1])s.push(p[2]);else{for(var _=s.length-1;_>=0;--_)if(s[_]==p[2]){s.length=_;break}if(_<0&&(!o||o==p[2]))return{tag:p[2],from:Q(d.line,d.ch),to:Q(T,m)}}}}fe.registerHelper("fold","xml",function(d,o){for(var s=new j(d,o.line,0);;){var u=O(s);if(!u||s.line!=o.line)return;var T=b(s);if(!T)return;if(!u[1]&&T!="selfClose"){var m=Q(s.line,s.ch),p=S(s,u[2]);return p&&D(p.from,m)>0?{from:m,to:p.from}:null}}}),fe.findMatchingTag=function(d,o,s){var u=new j(d,o.line,o.ch,s);if(u.text.indexOf(">")==-1&&u.text.indexOf("<")==-1)return;var T=b(u),m=T&&Q(u.line,u.ch),p=T&&w(u);if(!T||!p||D(u,o)>0)return;var _={from:Q(u.line,u.ch),to:m,tag:p[2]};return T=="selfClose"?{open:_,close:null,at:"open"}:p[1]?{open:C(u,p[2]),close:_,at:"close"}:(u=new j(d,m.line,m.ch,s),{open:_,close:S(u,p[2]),at:"open"})},fe.findEnclosingTag=function(d,o,s,u){for(var T=new j(d,o.line,o.ch,s);;){var m=C(T,u);if(!m)break;var p=new j(d,o.line,o.ch,s),_=S(p,m.tag);if(_)return{open:m,close:_}}},fe.scanForClosingTag=function(d,o,s,u){var T=new j(d,o.line,o.ch,u?{from:0,to:u}:null);return S(T,s)}})},p5ED:function(gt,at,ue){"use strict";var fe=ue("+L6B"),Q=ue("2/Rp"),D=ue("5Dmo"),V=ue("3S7+"),I=ue("k1fw"),y=ue("9og8"),j=ue("tJVT"),B=ue("WmNS"),M=ue.n(B),R=ue("q1tI"),b=ue.n(R),w=ue("vHTk"),O=ue.n(w),A=ue("yEEn"),S=ue("ZW9T"),C=ue("1vsH"),d=ue("V0Rq"),o=ue("m3rI");at.a=function(s){var u,T,m,p,_,v,c,h=s.editOffice,l=h===void 0?"view":h,a=s.data,g=s.theme,f=s.type,x=s.filename,P=s.monacoEditor,G=s.className,X=s.style,ie=s.close,z=s.onClose,F=s.hasMask,ne=s.disabledDownload,ce=Object(R.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),ge=Object(j.a)(ce,2),be=ge[0],Ie=ge[1],Te=Object(R.useState)(""),De=Object(j.a)(Te,2),we=De[0],Ae=De[1],ve=Object(R.useState)(),W=Object(j.a)(ve,2),L=W[0],k=W[1],H=window.ENV==="build"?"/react/build":"",ee=o.a.PROXY_SERVER||location.origin,U,de=1024*1024,Ee=10*de,_e=Object(R.useRef)();(u=a)!==null&&u!==void 0&&u.startsWith("/api")&&f!=="txt"&&(a=(o.a.API_SERVER||location.origin)+a),f==="office"&&(U=Object(C.T)(a).filesize,U>Ee&&(f="other")),x&&P&&(P.filename=x),Object(R.useEffect)(function(){var Pe,Xe,Fe=(Pe=document.cookie)===null||Pe===void 0||((Xe=Pe.replace(/\s/g,""))===null||Xe===void 0)?void 0:Xe.split(";");Fe==null||Fe.map(function(Ne){var We=Ne.split("=");We[0]==="_educoder_session"&&Ae(We[1])})},[]),Object(R.useEffect)(function(){f==="office"&&Ue()},[f,a]);var Ue=function(){var Pe=Object(y.a)(M.a.mark(function Xe(){var Fe,Ne,We;return M.a.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:return console.log("data:",a),Fe=a,a.startsWith("http")||(Fe=location.origin+Fe),Ne=new URL(Fe).pathname.split("/").pop(),He.next=6,Object(d.V)({attachment_id:Ne});case 6:We=He.sent,k(We);case 8:case"end":return He.stop()}},Xe)}));return function(){return Pe.apply(this,arguments)}}(),ke=function(){if(a.startsWith("http")||a.startsWith("blob:")){Oe();return}Object(C.z)(x||"educoder",a,x)},Oe=function(){Object(C.x)(x||"educoder",decodeURIComponent(a))};return b.a.createElement("div",{style:Object(I.a)({},X||{}),className:"".concat(F&&O.a.bgBlack," ").concat(f?O.a.wrp:"hide")},ie&&b.a.createElement("div",{className:O.a.close,ref:_e},!ne&&b.a.createElement(V.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return _e.current}},b.a.createElement("span",{onClick:Oe},b.a.createElement("i",{className:"icon-quxiaozhiding"}))),b.a.createElement(V.a,{title:"\u5173\u95ED",getPopupContainer:function(){return _e.current}},b.a.createElement("span",{className:"",onClick:z},b.a.createElement("i",{className:"icon-guanbi1"})))),b.a.createElement("div",{className:"".concat(O.a[G]," ").concat(G," ").concat(O.a.monaco," ").concat(f==="txt"?"show":"hide")},f==="txt"&&b.a.createElement(S.b,P)),f==="audio"&&b.a.createElement("audio",{src:"".concat(((T=a)===null||T===void 0?void 0:T.indexOf("http://"))>-1||((m=a)===null||m===void 0?void 0:m.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(a),autoPlay:!0}),f==="video"&&b.a.createElement(b.a.Fragment,null,((p=a)===null||p===void 0?void 0:p.indexOf("http"))>-1?b.a.createElement("video",{controls:!0,src:"".concat(a),autoPlay:!0}):b.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(a),autoPlay:!0})),f==="office"&&L&&b.a.createElement("iframe",{src:"".concat(H,"/office.html?key=").concat(L.key,"&url=").concat(ee+L.url,"&callbackUrl=").concat(ee+L.callbackUrl,"&fileType=").concat(L.fileType,"&title=").concat(L.title,"&model=").concat(l,"&officeServer=").concat(o.a.OFFICE_SERVER,"&disabledDownload=").concat(!!ne)}),f==="html"&&b.a.createElement("iframe",{src:a+"&disposition=inline"}),f==="pdf"&&b.a.createElement("iframe",{src:"".concat(H,"/js/pdfview/index.html?url=").concat(a,"&disabledDownload=").concat(!!ne)}),f==="image"&&b.a.createElement("img",{src:"".concat(((_=a)===null||_===void 0?void 0:_.indexOf("http://"))>-1||((v=a)===null||v===void 0?void 0:v.indexOf("https://"))>-1||(c=a)!==null&&c!==void 0&&c.startsWith("/api")?"":"data:image/png;base64,").concat(a)}),f==="other"&&b.a.createElement("div",null,b.a.createElement(Q.a,{type:"primary",size:"large",onClick:ke},b.a.createElement(A.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),f==="download"&&b.a.createElement(Q.a,{type:"primary",size:"large",onClick:ke},b.a.createElement(A.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(gt,at,ue){},rUJ1:function(gt,at){const ue=/[&<>"']/,fe=/[&<>"']/g,Q=/[<>"']|&(?!#?\w+;)/,D=/[<>"']|&(?!#?\w+;)/g,V={"&":"&","<":"<",">":">",'"':""","'":"'"},I=v=>V[v];function y(v,c){if(c){if(ue.test(v))return v.replace(fe,I)}else if(Q.test(v))return v.replace(D,I);return v}const j=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function B(v){return v.replace(j,(c,h)=>(h=h.toLowerCase(),h==="colon"?":":h.charAt(0)==="#"?h.charAt(1)==="x"?String.fromCharCode(parseInt(h.substring(2),16)):String.fromCharCode(+h.substring(1)):""))}const M=/(^|[^\[])\^/g;function R(v,c){v=v.source||v,c=c||"";const h={replace:(l,a)=>(a=a.source||a,a=a.replace(M,"$1"),v=v.replace(l,a),h),getRegex:()=>new RegExp(v,c)};return h}const b=/[^\w:]/g,w=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function O(v,c,h){if(v){let l;try{l=decodeURIComponent(B(h)).replace(b,"").toLowerCase()}catch(a){return null}if(l.indexOf("javascript:")===0||l.indexOf("vbscript:")===0||l.indexOf("data:")===0)return null}c&&!w.test(h)&&(h=o(c,h));try{h=encodeURI(h).replace(/%25/g,"%")}catch(l){return null}return h}const A={},S=/^[^:]+:\/*[^/]*$/,C=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(v,c){A[" "+v]||(S.test(v)?A[" "+v]=v+"/":A[" "+v]=m(v,"/",!0)),v=A[" "+v];const h=v.indexOf(":")===-1;return c.substring(0,2)==="//"?h?c:v.replace(C,"$1")+c:c.charAt(0)==="/"?h?c:v.replace(d,"$1")+c:v+c}const s={exec:function(){}};function u(v){let c=1,h,l;for(;c<arguments.length;c++){h=arguments[c];for(l in h)Object.prototype.hasOwnProperty.call(h,l)&&(v[l]=h[l])}return v}function T(v,c){const h=v.replace(/\|/g,(g,f,x)=>{let P=!1,G=f;for(;--G>=0&&x[G]==="\\";)P=!P;return P?"|":" |"}),l=h.split(/ \|/);let a=0;if(l.length>c)l.splice(c);else for(;l.length<c;)l.push("");for(;a<l.length;a++)l[a]=l[a].trim().replace(/\\\|/g,"|");return l}function m(v,c,h){const l=v.length;if(l===0)return"";let a=0;for(;a<l;){const g=v.charAt(l-a-1);if(g===c&&!h)a++;else if(g!==c&&h)a++;else break}return v.substr(0,l-a)}function p(v,c){if(v.indexOf(c[1])===-1)return-1;const h=v.length;let l=0,a=0;for(;a<h;a++)if(v[a]==="\\")a++;else if(v[a]===c[0])l++;else if(v[a]===c[1]&&(l--,l<0))return a;return-1}function _(v){v&&v.sanitize&&!v.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")}gt.exports={escape:y,unescape:B,edit:R,cleanUrl:O,resolveUrl:o,noopTest:s,merge:u,splitCells:T,rtrim:m,findClosingBracket:p,checkSanitizeDeprecation:_}},smFo:function(gt,at,ue){gt.exports={wrap:"wrap___1xSvp",header:"header___1niV1",title:"title____shwY",menu:"menu___2Y-rd",top:"top___1_d5Y",line:"line___1kciD",flexCenter:"flexCenter___3bP7s",like:"like___3lXjz",canLike:"canLike___AuDmL",attachmentName:"attachmentName___2SteY"}},ulZh:function(gt,at,ue){typeof window!="undefined"&&function(Q,D){gt.exports=D()}(this,function(){return function(fe){var Q={};function D(V){if(Q[V])return Q[V].exports;var I=Q[V]={i:V,l:!1,exports:{}};return fe[V].call(I.exports,I,I.exports,D),I.l=!0,I.exports}return D.m=fe,D.c=Q,D.d=function(V,I,y){D.o(V,I)||Object.defineProperty(V,I,{enumerable:!0,get:y})},D.r=function(V){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(V,"__esModule",{value:!0})},D.t=function(V,I){if(I&1&&(V=D(V)),I&8)return V;if(I&4&&typeof V=="object"&&V&&V.__esModule)return V;var y=Object.create(null);if(D.r(y),Object.defineProperty(y,"default",{enumerable:!0,value:V}),I&2&&typeof V!="string")for(var j in V)D.d(y,j,function(B){return V[B]}.bind(null,j));return y},D.n=function(V){var I=V&&V.__esModule?function(){return V.default}:function(){return V};return D.d(I,"a",I),I},D.o=function(V,I){return Object.prototype.hasOwnProperty.call(V,I)},D.p="/dist/",D(D.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(fe,Q,D){"use strict";var V=Object.prototype.hasOwnProperty,I="~";function y(){}Object.create&&(y.prototype=Object.create(null),new y().__proto__||(I=!1));function j(b,w,O){this.fn=b,this.context=w,this.once=O||!1}function B(b,w,O,A,S){if(typeof O!="function")throw new TypeError("The listener must be a function");var C=new j(O,A||b,S),d=I?I+w:w;return b._events[d]?b._events[d].fn?b._events[d]=[b._events[d],C]:b._events[d].push(C):(b._events[d]=C,b._eventsCount++),b}function M(b,w){--b._eventsCount===0?b._events=new y:delete b._events[w]}function R(){this._events=new y,this._eventsCount=0}R.prototype.eventNames=function(){var w=[],O,A;if(this._eventsCount===0)return w;for(A in O=this._events)V.call(O,A)&&w.push(I?A.slice(1):A);return Object.getOwnPropertySymbols?w.concat(Object.getOwnPropertySymbols(O)):w},R.prototype.listeners=function(w){var O=I?I+w:w,A=this._events[O];if(!A)return[];if(A.fn)return[A.fn];for(var S=0,C=A.length,d=new Array(C);S<C;S++)d[S]=A[S].fn;return d},R.prototype.listenerCount=function(w){var O=I?I+w:w,A=this._events[O];return A?A.fn?1:A.length:0},R.prototype.emit=function(w,O,A,S,C,d){var o=I?I+w:w;if(!this._events[o])return!1;var s=this._events[o],u=arguments.length,T,m;if(s.fn){s.once&&this.removeListener(w,s.fn,void 0,!0);switch(u){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,O),!0;case 3:return s.fn.call(s.context,O,A),!0;case 4:return s.fn.call(s.context,O,A,S),!0;case 5:return s.fn.call(s.context,O,A,S,C),!0;case 6:return s.fn.call(s.context,O,A,S,C,d),!0}for(m=1,T=new Array(u-1);m<u;m++)T[m-1]=arguments[m];s.fn.apply(s.context,T)}else{var p=s.length,_;for(m=0;m<p;m++){s[m].once&&this.removeListener(w,s[m].fn,void 0,!0);switch(u){case 1:s[m].fn.call(s[m].context);break;case 2:s[m].fn.call(s[m].context,O);break;case 3:s[m].fn.call(s[m].context,O,A);break;case 4:s[m].fn.call(s[m].context,O,A,S);break;default:if(!T)for(_=1,T=new Array(u-1);_<u;_++)T[_-1]=arguments[_];s[m].fn.apply(s[m].context,T)}}}return!0},R.prototype.on=function(w,O,A){return B(this,w,O,A,!1)},R.prototype.once=function(w,O,A){return B(this,w,O,A,!0)},R.prototype.removeListener=function(w,O,A,S){var C=I?I+w:w;if(!this._events[C])return this;if(!O)return M(this,C),this;var d=this._events[C];if(d.fn)d.fn===O&&(!S||d.once)&&(!A||d.context===A)&&M(this,C);else{for(var o=0,s=[],u=d.length;o<u;o++)(d[o].fn!==O||S&&!d[o].once||A&&d[o].context!==A)&&s.push(d[o]);s.length?this._events[C]=s.length===1?s[0]:s:M(this,C)}return this},R.prototype.removeAllListeners=function(w){var O;return w?(O=I?I+w:w,this._events[O]&&M(this,O)):(this._events=new y,this._eventsCount=0),this},R.prototype.off=R.prototype.removeListener,R.prototype.addListener=R.prototype.on,R.prefixed=I,R.EventEmitter=R,fe.exports=R},"./node_modules/url-toolkit/src/url-toolkit.js":function(fe,Q,D){(function(V){var I=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,y=/^([^\/?#]*)([^]*)$/,j=/(?:\/|^)\.(?=\/)/g,B=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,M={buildAbsoluteURL:function(R,b,w){if(w=w||{},R=R.trim(),b=b.trim(),!b){if(!w.alwaysNormalize)return R;var O=M.parseURL(R);if(!O)throw new Error("Error trying to parse base URL.");return O.path=M.normalizePath(O.path),M.buildURLFromParts(O)}var A=M.parseURL(b);if(!A)throw new Error("Error trying to parse relative URL.");if(A.scheme)return w.alwaysNormalize?(A.path=M.normalizePath(A.path),M.buildURLFromParts(A)):b;var S=M.parseURL(R);if(!S)throw new Error("Error trying to parse base URL.");if(!S.netLoc&&S.path&&S.path[0]!=="/"){var C=y.exec(S.path);S.netLoc=C[1],S.path=C[2]}S.netLoc&&!S.path&&(S.path="/");var d={scheme:S.scheme,netLoc:A.netLoc,path:null,params:A.params,query:A.query,fragment:A.fragment};if(!A.netLoc&&(d.netLoc=S.netLoc,A.path[0]!=="/"))if(!A.path)d.path=S.path,A.params||(d.params=S.params,A.query||(d.query=S.query));else{var o=S.path,s=o.substring(0,o.lastIndexOf("/")+1)+A.path;d.path=M.normalizePath(s)}return d.path===null&&(d.path=w.alwaysNormalize?M.normalizePath(A.path):A.path),M.buildURLFromParts(d)},parseURL:function(R){var b=I.exec(R);return b?{scheme:b[1]||"",netLoc:b[2]||"",path:b[3]||"",params:b[4]||"",query:b[5]||"",fragment:b[6]||""}:null},normalizePath:function(R){for(R=R.split("").reverse().join("").replace(j,"");R.length!==(R=R.replace(B,"")).length;);return R.split("").reverse().join("")},buildURLFromParts:function(R){return R.scheme+R.netLoc+R.path+R.params+R.query+R.fragment}};fe.exports=M})(this)},"./node_modules/webworkify-webpack/index.js":function(fe,Q,D){function V(w){var O={};function A(C){if(O[C])return O[C].exports;var d=O[C]={i:C,l:!1,exports:{}};return w[C].call(d.exports,d,d.exports,A),d.l=!0,d.exports}A.m=w,A.c=O,A.i=function(C){return C},A.d=function(C,d,o){A.o(C,d)||Object.defineProperty(C,d,{configurable:!1,enumerable:!0,get:o})},A.r=function(C){Object.defineProperty(C,"__esModule",{value:!0})},A.n=function(C){var d=C&&C.__esModule?function(){return C.default}:function(){return C};return A.d(d,"a",d),d},A.o=function(C,d){return Object.prototype.hasOwnProperty.call(C,d)},A.p="/",A.oe=function(C){throw console.error(C),C};var S=A(A.s=ENTRY_MODULE);return S.default||S}var I="[\\.|\\-|\\+|\\w|/|@]+",y="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+I+").*?\\)";function j(w){return(w+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function B(w){return!isNaN(1*w)}function M(w,O,A){var S={};S[A]=[];var C=O.toString(),d=C.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return S;for(var o=d[1],s=new RegExp("(\\\\n|\\W)"+j(o)+y,"g"),u;u=s.exec(C);){if(u[3]==="dll-reference")continue;S[A].push(u[3])}for(s=new RegExp("\\("+j(o)+'\\("(dll-reference\\s('+I+'))"\\)\\)'+y,"g");u=s.exec(C);)w[u[2]]||(S[A].push(u[1]),w[u[2]]=D(u[1]).m),S[u[2]]=S[u[2]]||[],S[u[2]].push(u[4]);for(var T=Object.keys(S),m=0;m<T.length;m++)for(var p=0;p<S[T[m]].length;p++)B(S[T[m]][p])&&(S[T[m]][p]=1*S[T[m]][p]);return S}function R(w){var O=Object.keys(w);return O.reduce(function(A,S){return A||w[S].length>0},!1)}function b(w,O){for(var A={main:[O]},S={main:[]},C={main:{}};R(A);)for(var d=Object.keys(A),o=0;o<d.length;o++){var s=d[o],u=A[s],T=u.pop();if(C[s]=C[s]||{},C[s][T]||!w[s][T])continue;C[s][T]=!0,S[s]=S[s]||[],S[s].push(T);for(var m=M(w,w[s][T],s),p=Object.keys(m),_=0;_<p.length;_++)A[p[_]]=A[p[_]]||[],A[p[_]]=A[p[_]].concat(m[p[_]])}return S}fe.exports=function(w,O){O=O||{};var A={main:D.m},S=O.all?{main:Object.keys(A.main)}:b(A,w),C="";Object.keys(S).filter(function(T){return T!=="main"}).forEach(function(T){for(var m=0;S[T][m];)m++;S[T].push(m),A[T][m]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",C=C+"var "+T+" = ("+V.toString().replace("ENTRY_MODULE",JSON.stringify(m))+")({"+S[T].map(function(p){return""+JSON.stringify(p)+": "+A[T][p].toString()}).join(",")+`});
|
|
`}),C=C+"new (("+V.toString().replace("ENTRY_MODULE",JSON.stringify(w))+")({"+S.main.map(function(T){return""+JSON.stringify(T)+": "+A.main[T].toString()}).join(",")+"}))(self);";var d=new window.Blob([C],{type:"text/javascript"});if(O.bare)return d;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,s=o.createObjectURL(d),u=new window.Worker(s);return u.objectURL=s,u}},"./src/config.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"hlsDefaultConfig",function(){return _}),D.d(Q,"mergeConfig",function(){return c}),D.d(Q,"enableStreamingMode",function(){return h});var V=D("./src/controller/abr-controller.ts"),I=D("./src/controller/audio-stream-controller.ts"),y=D("./src/controller/audio-track-controller.ts"),j=D("./src/controller/subtitle-stream-controller.ts"),B=D("./src/controller/subtitle-track-controller.ts"),M=D("./src/controller/buffer-controller.ts"),R=D("./src/controller/timeline-controller.ts"),b=D("./src/controller/cap-level-controller.ts"),w=D("./src/controller/fps-controller.ts"),O=D("./src/controller/eme-controller.ts"),A=D("./src/controller/cmcd-controller.ts"),S=D("./src/utils/xhr-loader.ts"),C=D("./src/utils/fetch-loader.ts"),d=D("./src/utils/cues.ts"),o=D("./src/utils/mediakeys-helper.ts"),s=D("./src/utils/logger.ts");function u(){return u=Object.assign||function(l){for(var a=1;a<arguments.length;a++){var g=arguments[a];for(var f in g)Object.prototype.hasOwnProperty.call(g,f)&&(l[f]=g[f])}return l},u.apply(this,arguments)}function T(l,a){var g=Object.keys(l);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(l);a&&(f=f.filter(function(x){return Object.getOwnPropertyDescriptor(l,x).enumerable})),g.push.apply(g,f)}return g}function m(l){for(var a=1;a<arguments.length;a++){var g=arguments[a]!=null?arguments[a]:{};a%2?T(Object(g),!0).forEach(function(f){p(l,f,g[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(g)):T(Object(g)).forEach(function(f){Object.defineProperty(l,f,Object.getOwnPropertyDescriptor(g,f))})}return l}function p(l,a,g){return a in l?Object.defineProperty(l,a,{value:g,enumerable:!0,configurable:!0,writable:!0}):l[a]=g,l}var _=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:S.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:V.default,bufferController:M.default,capLevelController:b.default,fpsController:w.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:o.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},v()),{},{subtitleStreamController:j.SubtitleStreamController,subtitleTrackController:B.default,timelineController:R.TimelineController,audioStreamController:I.default,audioTrackController:y.default,emeController:O.default,cmcdController:A.default});function v(){return{cueHandler:d.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function c(l,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return u({},l,a)}function h(l){var a=l.loader;if(a!==C.default&&a!==S.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),l.progressive=!1;else{var g=Object(C.fetchSupported)();g&&(l.loader=C.default,l.progressive=!0,l.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/polyfills/number.ts"),I=D("./src/utils/ewma-bandwidth-estimator.ts"),y=D("./src/events.ts"),j=D("./src/utils/buffer-helper.ts"),B=D("./src/errors.ts"),M=D("./src/types/loader.ts"),R=D("./src/utils/logger.ts");function b(A,S){for(var C=0;C<S.length;C++){var d=S[C];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(A,d.key,d)}}function w(A,S,C){return S&&b(A.prototype,S),C&&b(A,C),A}var O=function(){function A(C){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=C;var d=C.config;this.bwEstimator=new I.default(d.abrEwmaSlowVoD,d.abrEwmaFastVoD,d.abrEwmaDefaultEstimate),this.registerListeners()}var S=A.prototype;return S.registerListeners=function(){var d=this.hls;d.on(y.Events.FRAG_LOADING,this.onFragLoading,this),d.on(y.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(y.Events.FRAG_BUFFERED,this.onFragBuffered,this),d.on(y.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(y.Events.ERROR,this.onError,this)},S.unregisterListeners=function(){var d=this.hls;d.off(y.Events.FRAG_LOADING,this.onFragLoading,this),d.off(y.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(y.Events.FRAG_BUFFERED,this.onFragBuffered,this),d.off(y.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(y.Events.ERROR,this.onError,this)},S.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},S.onFragLoading=function(d,o){var s=o.frag;if(s.type===M.PlaylistLevelType.MAIN&&!this.timer){var u;this.fragCurrent=s,this.partCurrent=(u=o.part)!=null?u:null,this.timer=self.setInterval(this.onCheck,100)}},S.onLevelLoaded=function(d,o){var s=this.hls.config;o.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},S._abandonRulesCheck=function(){var d=this.fragCurrent,o=this.partCurrent,s=this.hls,u=s.autoLevelEnabled,T=s.config,m=s.media;if(!d||!m)return;var p=o?o.stats:d.stats,_=o?o.duration:d.duration;if(p.aborted){R.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!u||m.paused||!m.playbackRate||!m.readyState)return;var v=performance.now()-p.loading.start,c=Math.abs(m.playbackRate);if(v<=500*_/c)return;var h=s.levels,l=s.minAutoLevel,a=h[d.level],g=p.total||Math.max(p.loaded,Math.round(_*a.maxBitrate/8)),f=Math.max(1,p.bwEstimate?p.bwEstimate/8:p.loaded*1e3/v),x=(g-p.loaded)/f,P=m.currentTime,G=(j.BufferHelper.bufferInfo(m,P,T.maxBufferHole).end-P)/c;if(G>=2*_/c||x<=G)return;var X=Number.POSITIVE_INFINITY,ie;for(ie=d.level-1;ie>l;ie--){var z=h[ie].maxBitrate;if(X=_*z/(8*.8*f),X<G)break}if(X>=x)return;var F=this.bwEstimator.getEstimate();R.logger.warn("Fragment "+d.sn+(o?" part "+o.index:"")+" of level "+d.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+ie+`
|
|
Current BW estimate: `+(Object(V.isFiniteNumber)(F)?(F/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+x.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+X.toFixed(3)+` s
|
|
Time to underbuffer: `+G.toFixed(3)+" s"),s.nextLoadLevel=ie,this.bwEstimator.sample(v,p.loaded),this.clearTimer(),d.loader&&(this.fragCurrent=this.partCurrent=null,d.loader.abort()),s.trigger(y.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:d,part:o,stats:p})},S.onFragLoaded=function(d,o){var s=o.frag,u=o.part;if(s.type===M.PlaylistLevelType.MAIN&&Object(V.isFiniteNumber)(s.sn)){var T=u?u.stats:s.stats,m=u?u.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var p=this.hls.levels[s.level],_=(p.loaded?p.loaded.bytes:0)+T.loaded,v=(p.loaded?p.loaded.duration:0)+m;p.loaded={bytes:_,duration:v},p.realBitrate=Math.round(8*_/v)}if(s.bitrateTest){var c={stats:T,frag:s,part:u,id:s.type};this.onFragBuffered(y.Events.FRAG_BUFFERED,c),s.bitrateTest=!1}}},S.onFragBuffered=function(d,o){var s=o.frag,u=o.part,T=u?u.stats:s.stats;if(T.aborted)return;if(s.type!==M.PlaylistLevelType.MAIN||s.sn==="initSegment")return;var m=T.parsing.end-T.loading.start;this.bwEstimator.sample(m,T.loaded),T.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=m/1e3:this.bitrateTestDelay=0},S.onError=function(d,o){switch(o.details){case B.ErrorDetails.FRAG_LOAD_ERROR:case B.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},S.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},S.getNextABRAutoLevel=function(){var d=this.fragCurrent,o=this.partCurrent,s=this.hls,u=s.maxAutoLevel,T=s.config,m=s.minAutoLevel,p=s.media,_=o?o.duration:d?d.duration:0,v=p?p.currentTime:0,c=p&&p.playbackRate!==0?Math.abs(p.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():T.abrEwmaDefaultEstimate,l=(j.BufferHelper.bufferInfo(p,v,T.maxBufferHole).end-v)/c,a=this.findBestLevel(h,m,u,l,T.abrBandWidthFactor,T.abrBandWidthUpFactor);if(a>=0)return a;R.logger.trace((l?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var g=_?Math.min(_,T.maxStarvationDelay):T.maxStarvationDelay,f=T.abrBandWidthFactor,x=T.abrBandWidthUpFactor;if(!l){var P=this.bitrateTestDelay;if(P){var G=_?Math.min(_,T.maxLoadingDelay):T.maxLoadingDelay;g=G-P,R.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),f=x=1}}return a=this.findBestLevel(h,m,u,l+g,f,x),Math.max(a,0)},S.findBestLevel=function(d,o,s,u,T,m){for(var p,_=this.fragCurrent,v=this.partCurrent,c=this.lastLoadedFragLevel,h=this.hls.levels,l=h[c],a=!!(l!=null&&(p=l.details)!==null&&p!==void 0&&p.live),g=l==null?void 0:l.codecSet,f=v?v.duration:_?_.duration:0,x=s;x>=o;x--){var P=h[x];if(!P||g&&P.codecSet!==g)continue;var G=P.details,X=(v?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||f,ie=void 0;x<=c?ie=T*d:ie=m*d;var z=h[x].maxBitrate,F=z*X/ie;if(R.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+x+"/"+Math.round(ie)+"/"+z+"/"+X+"/"+u+"/"+F),ie>z&&(!F||a&&!this.bitrateTestDelay||F<u))return x}return-1},w(A,[{key:"nextAutoLevel",get:function(){var d=this._nextAutoLevel,o=this.bwEstimator;if(d!==-1&&(!o||!o.canEstimate()))return d;var s=this.getNextABRAutoLevel();return d!==-1&&(s=Math.min(d,s)),s},set:function(d){this._nextAutoLevel=d}}]),A}();Q.default=O},"./src/controller/audio-stream-controller.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/polyfills/number.ts"),I=D("./src/controller/base-stream-controller.ts"),y=D("./src/events.ts"),j=D("./src/utils/buffer-helper.ts"),B=D("./src/controller/fragment-tracker.ts"),M=D("./src/types/level.ts"),R=D("./src/types/loader.ts"),b=D("./src/loader/fragment.ts"),w=D("./src/demux/chunk-cache.ts"),O=D("./src/demux/transmuxer-interface.ts"),A=D("./src/types/transmuxer.ts"),S=D("./src/controller/fragment-finders.ts"),C=D("./src/utils/discontinuities.ts"),d=D("./src/errors.ts"),o=D("./src/utils/logger.ts");function s(){return s=Object.assign||function(_){for(var v=1;v<arguments.length;v++){var c=arguments[v];for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&(_[h]=c[h])}return _},s.apply(this,arguments)}function u(_,v){_.prototype=Object.create(v.prototype),_.prototype.constructor=_,T(_,v)}function T(_,v){return T=Object.setPrototypeOf||function(h,l){return h.__proto__=l,h},T(_,v)}var m=100,p=function(_){u(v,_);function v(h,l){var a;return a=_.call(this,h,l,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var c=v.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var l=this.hls;l.on(y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(y.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(y.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),l.on(y.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),l.on(y.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),l.on(y.Events.ERROR,this.onError,this),l.on(y.Events.BUFFER_RESET,this.onBufferReset,this),l.on(y.Events.BUFFER_CREATED,this.onBufferCreated,this),l.on(y.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),l.on(y.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(y.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var l=this.hls;l.off(y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(y.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(y.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),l.off(y.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),l.off(y.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),l.off(y.Events.ERROR,this.onError,this),l.off(y.Events.BUFFER_RESET,this.onBufferReset,this),l.off(y.Events.BUFFER_CREATED,this.onBufferCreated,this),l.off(y.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),l.off(y.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.off(y.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(l,a){var g=a.frag,f=a.id,x=a.initPTS;if(f==="main"){var P=g.cc;this.initPTS[g.cc]=x,this.log("InitPTS for cc: "+P+" found from main: "+x),this.videoTrackCC=P,this.state===I.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(l){if(!this.levels){this.startPosition=l,this.state=I.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(m),this.fragLoadError=0,a>0&&l===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=I.State.IDLE):(this.loadedmetadata=!1,this.state=I.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=l,this.tick()},c.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_TRACK:{var l,a=this.levels,g=this.trackId,f=a==null||((l=a[g])===null||l===void 0)?void 0:l.details;if(f){if(this.waitForCdnTuneIn(f))break;this.state=I.State.WAITING_INIT_PTS}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var x,P=performance.now(),G=this.retryDate;(!G||P>=G||(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 X=this.waitingData;if(X){var ie=X.frag,z=X.part,F=X.cache,ne=X.complete;if(this.initPTS[ie.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.FRAG_LOADING;var ce=F.flush(),ge={frag:ie,part:z,payload:ce,networkDetails:null};this._handleFragmentLoadProgress(ge),ne&&_.prototype._handleFragmentLoadComplete.call(this,ge)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+ie.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var be=this.getLoadPosition(),Ie=j.BufferHelper.bufferInfo(this.mediaBuffer,be,this.config.maxBufferHole),Te=Object(S.fragmentWithinToleranceTest)(Ie.end,this.config.maxFragLookUpTolerance,ie);Te<0&&(o.logger.log("Waiting fragment cc ("+ie.cc+") @ "+ie.start+" cancelled because another fragment at "+Ie.end+" is needed"),this.clearWaitingFragment())}}else this.state=I.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var l=this.waitingData;l&&(this.fragmentTracker.removeFragment(l.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.IDLE)},c.onTickEnd=function(){var l=this.media;if(!l||!l.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:l,g=a.buffered;!this.loadedmetadata&&g.length&&(this.loadedmetadata=!0),this.lastCurrentTime=l.currentTime},c.doTickIdle=function(){var l,a,g=this.hls,f=this.levels,x=this.media,P=this.trackId,G=g.config;if(!f||!f[P])return;if(!x&&(this.startFragRequested||!G.startFragPrefetch))return;var X=f[P],ie=X.details;if(!ie||ie.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(ie)){this.state=I.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,b.ElementaryStreamTypes.AUDIO,R.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,R.PlaylistLevelType.AUDIO);if(z===null)return;var F=z.len,ne=this.getMaxBufferLength(),ce=this.audioSwitch;if(F>=ne&&!ce)return;if(!ce&&this._streamEnded(z,ie)){g.trigger(y.Events.BUFFER_EOS,{type:"audio"}),this.state=I.State.ENDED;return}var ge=ie.fragments,be=ge[0].start,Ie=z.end;if(ce){var Te=this.getLoadPosition();Ie=Te,ie.PTSKnown&&Te<be&&((z.end>be||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),x.currentTime=be+.05))}var De=this.getNextFragment(Ie,ie);if(!De){this.bufferFlushed=!0;return}((l=De.decryptdata)===null||l===void 0?void 0:l.keyFormat)==="identity"&&!((a=De.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(De,ie):this.loadFragment(De,ie,Ie)},c.getMaxBufferLength=function(){var l=_.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,R.PlaylistLevelType.MAIN);return a===null?l:Math.max(l,a.len)},c.onMediaDetaching=function(){this.videoBuffer=null,_.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(l,a){var g=a.audioTracks;this.resetTransmuxer(),this.levels=g.map(function(f){return new M.Level(f)})},c.onAudioTrackSwitching=function(l,a){var g=!!a.url;this.trackId=a.id;var f=this.fragCurrent;f!=null&&f.loader&&f.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),g?this.setInterval(m):this.resetTransmuxer(),g?(this.audioSwitch=!0,this.state=I.State.IDLE):this.state=I.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(l,a){this.mainDetails=a.details},c.onAudioTrackLoaded=function(l,a){var g,f=this.levels,x=a.details,P=a.id;if(!f){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+x.startSN+","+x.endSN+"],duration:"+x.totalduration);var G=f[P],X=0;if(x.live||(g=G.details)!==null&&g!==void 0&&g.live){var ie=this.mainDetails;if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed||!ie)return;!G.details&&x.hasProgramDateTime&&ie.hasProgramDateTime?(Object(C.alignMediaPlaylistByPDT)(x,ie),X=x.fragments[0].start):X=this.alignPlaylists(x,G.details)}G.details=x,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!x.live)&&this.setStartPosition(G.details,X),this.state===I.State.WAITING_TRACK&&!this.waitForCdnTuneIn(x)&&(this.state=I.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(l){var a,g=l.frag,f=l.part,x=l.payload,P=this.config,G=this.trackId,X=this.levels;if(!X){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+g.sn+" of level "+g.level+" will not be buffered");return}var ie=X[G];console.assert(ie,"Audio track is defined on fragment load progress");var z=ie.details;console.assert(z,"Audio track details are defined on fragment load progress");var F=P.defaultAudioCodec||ie.audioCodec||"mp4a.40.2",ne=this.transmuxer;ne||(ne=this.transmuxer=new O.default(this.hls,R.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ce=this.initPTS[g.cc],ge=(a=g.initSegment)===null||a===void 0?void 0:a.data;if(ce!==void 0){var be=!1,Ie=f?f.index:-1,Te=Ie!==-1,De=new A.ChunkMetadata(g.level,g.sn,g.stats.chunkCount,x.byteLength,Ie,Te);ne.push(x,ge,F,"",g,f,z.totalduration,be,De,ce)}else{o.logger.log("Unknown video PTS for cc "+g.cc+", waiting for video PTS before demuxing audio frag "+g.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+G);var we=this.waitingData=this.waitingData||{frag:g,part:f,cache:new w.default,complete:!1},Ae=we.cache;Ae.push(new Uint8Array(x)),this.waitingVideoCC=this.videoTrackCC,this.state=I.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(l){if(this.waitingData){this.waitingData.complete=!0;return}_.prototype._handleFragmentLoadComplete.call(this,l)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(l,a){var g=a.tracks.audio;g&&(this.mediaBuffer=g.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},c.onFragBuffered=function(l,a){var g=a.frag,f=a.part;if(g.type!==R.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(g)){this.warn("Fragment "+g.sn+(f?" p: "+f.index:"")+" of level "+g.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}g.sn!=="initSegment"&&(this.fragPrevious=g,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(y.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(g,f)},c.onError=function(l,a){switch(a.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(R.PlaylistLevelType.AUDIO,a);break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==I.State.ERROR&&this.state!==I.State.STOPPED&&(this.state=a.fatal?I.State.ERROR:I.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var g=!0,f=this.getFwdBufferInfo(this.mediaBuffer,R.PlaylistLevelType.AUDIO);f&&f.len>.5&&(g=!this.reduceMaxBufferLength(f.len)),g&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,_.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(l,a){var g=a.type;g===b.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(l){var a,g="audio",f=this.hls,x=l.remuxResult,P=l.chunkMeta,G=this.getCurrentContext(P);if(!G){this.warn("The loading context changed while buffering fragment "+P.sn+" of level "+P.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(P.level);return}var X=G.frag,ie=G.part,z=x.audio,F=x.text,ne=x.id3,ce=x.initSegment;if(this.fragContextChanged(X))return;if(this.state=I.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),ce!=null&&ce.tracks&&(this._bufferInitSegment(ce.tracks,X,P),f.trigger(y.Events.FRAG_PARSING_INIT_SEGMENT,{frag:X,id:g,tracks:ce.tracks})),z){var ge=z.startPTS,be=z.endPTS,Ie=z.startDTS,Te=z.endDTS;ie&&(ie.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:ge,endPTS:be,startDTS:Ie,endDTS:Te}),X.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,ge,be,Ie,Te),this.bufferFragmentData(z,X,ie,P)}if(ne!=null&&(a=ne.samples)!==null&&a!==void 0&&a.length){var De=s({frag:X,id:g},ne);f.trigger(y.Events.FRAG_PARSING_METADATA,De)}if(F){var we=s({frag:X,id:g},F);f.trigger(y.Events.FRAG_PARSING_USERDATA,we)}},c._bufferInitSegment=function(l,a,g){if(this.state!==I.State.PARSING)return;l.video&&delete l.video;var f=l.audio;if(!f)return;f.levelCodec=f.codec,f.id="audio",this.log("Init audio buffer, container:"+f.container+", codecs[parsed]=["+f.codec+"]"),this.hls.trigger(y.Events.BUFFER_CODECS,l);var x=f.initSegment;if(x!=null&&x.byteLength){var P={type:"audio",frag:a,part:null,chunkMeta:g,parent:a.type,data:x};this.hls.trigger(y.Events.BUFFER_APPENDING,P)}this.tick()},c.loadFragment=function(l,a,g){var f=this.fragmentTracker.getState(l);this.fragCurrent=l,(this.audioSwitch||f===B.FragmentState.NOT_LOADED||f===B.FragmentState.PARTIAL)&&(l.sn==="initSegment"?this._loadInitSegment(l):a.live&&!Object(V.isFiniteNumber)(this.initPTS[l.cc])?(this.log("Waiting for video PTS in continuity counter "+l.cc+" of live stream before loading audio fragment "+l.sn+" of level "+this.trackId),this.state=I.State.WAITING_INIT_PTS):(this.startFragRequested=!0,_.prototype.loadFragment.call(this,l,a,g)))},c.completeAudioSwitch=function(){var l=this.hls,a=this.media,g=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),_.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,l.trigger(y.Events.AUDIO_TRACK_SWITCHED,{id:g})},v}(I.default);Q.default=p},"./src/controller/audio-track-controller.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/events.ts"),I=D("./src/errors.ts"),y=D("./src/controller/base-playlist-controller.ts"),j=D("./src/types/loader.ts");function B(O,A){for(var S=0;S<A.length;S++){var C=A[S];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(O,C.key,C)}}function M(O,A,S){return A&&B(O.prototype,A),S&&B(O,S),O}function R(O,A){O.prototype=Object.create(A.prototype),O.prototype.constructor=O,b(O,A)}function b(O,A){return b=Object.setPrototypeOf||function(C,d){return C.__proto__=d,C},b(O,A)}var w=function(O){R(A,O);function A(C){var d;return d=O.call(this,C,"[audio-track-controller]")||this,d.tracks=[],d.groupId=null,d.tracksInGroup=[],d.trackId=-1,d.trackName="",d.selectDefaultTrack=!0,d.registerListeners(),d}var S=A.prototype;return S.registerListeners=function(){var d=this.hls;d.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.on(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(V.Events.ERROR,this.onError,this)},S.unregisterListeners=function(){var d=this.hls;d.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),d.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.off(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(V.Events.ERROR,this.onError,this)},S.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,O.prototype.destroy.call(this)},S.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},S.onManifestParsed=function(d,o){this.tracks=o.audioTracks||[]},S.onAudioTrackLoaded=function(d,o){var s=o.id,u=o.details,T=this.tracksInGroup[s];if(!T){this.warn("Invalid audio track id "+s);return}var m=T.details;T.details=o.details,this.log("audioTrack "+s+" loaded ["+u.startSN+"-"+u.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,o,m))},S.onLevelLoading=function(d,o){this.switchLevel(o.level)},S.onLevelSwitching=function(d,o){this.switchLevel(o.level)},S.switchLevel=function(d){var o=this.hls.levels[d];if(!(o!=null&&o.audioGroupIds))return;var s=o.audioGroupIds[o.urlId];if(this.groupId!==s){this.groupId=s;var u=this.tracks.filter(function(m){return!s||m.groupId===s});this.selectDefaultTrack&&!u.some(function(m){return m.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=u;var T={audioTracks:u};this.log("Updating audio tracks, "+u.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(V.Events.AUDIO_TRACKS_UPDATED,T),this.selectInitialTrack()}},S.onError=function(d,o){if(O.prototype.onError.call(this,d,o),o.fatal||!o.context)return;o.context.type===j.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},S.setAudioTrack=function(d){var o=this.tracksInGroup;if(d<0||d>=o.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=o[this.trackId];this.log("Now switching to audio-track index "+d);var u=o[d],T=u.id,m=u.groupId,p=m===void 0?"":m,_=u.name,v=u.type,c=u.url;if(this.trackId=d,this.trackName=_,this.selectDefaultTrack=!1,this.hls.trigger(V.Events.AUDIO_TRACK_SWITCHING,{id:T,groupId:p,name:_,type:v,url:c}),u.details&&!u.details.live)return;var h=this.switchParams(u.url,s==null?void 0:s.details);this.loadPlaylist(h)},S.selectInitialTrack=function(){var d=this.tracksInGroup;console.assert(d.length,"Initial audio track should be selected when tracks are known");var o=this.trackName,s=this.findTrackId(o)||this.findTrackId();s!==-1?this.setAudioTrack(s):(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}))},S.findTrackId=function(d){for(var o=this.tracksInGroup,s=0;s<o.length;s++){var u=o[s];if((!this.selectDefaultTrack||u.default)&&(!d||d===u.name))return u.id}return-1},S.loadPlaylist=function(d){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var s=o.id,u=o.groupId,T=o.url;if(d)try{T=d.addDirectives(T)}catch(m){this.warn("Could not construct new URL with HLS Delivery Directives: "+m)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(V.Events.AUDIO_TRACK_LOADING,{url:T,id:s,groupId:u,deliveryDirectives:d||null})}},M(A,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(d){this.selectDefaultTrack=!1,this.setAudioTrack(d)}}]),A}(y.default);Q.default=w},"./src/controller/base-playlist-controller.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return M});var V=D("./src/polyfills/number.ts"),I=D("./src/types/level.ts"),y=D("./src/controller/level-helper.ts"),j=D("./src/utils/logger.ts"),B=D("./src/errors.ts"),M=function(){function R(w,O){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=j.logger.log.bind(j.logger,O+":"),this.warn=j.logger.warn.bind(j.logger,O+":"),this.hls=w}var b=R.prototype;return b.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},b.onError=function(O,A){A.fatal&&A.type===B.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},b.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},b.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},b.stopLoad=function(){this.canLoad=!1,this.clearTimer()},b.switchParams=function(O,A){var S=A==null?void 0:A.renditionReports;if(S)for(var C=0;C<S.length;C++){var d=S[C],o=""+d.URI;if(o===O.substr(-o.length)){var s=parseInt(d["LAST-MSN"]),u=parseInt(d["LAST-PART"]);if(A&&this.hls.config.lowLatencyMode){var T=Math.min(A.age-A.partTarget,A.targetduration);u!==void 0&&T>A.partTarget&&(u+=1)}if(Object(V.isFiniteNumber)(s))return new I.HlsUrlParameters(s,Object(V.isFiniteNumber)(u)?u:void 0,I.HlsSkip.No)}}},b.loadPlaylist=function(O){},b.shouldLoadTrack=function(O){return this.canLoad&&O&&!!O.url&&(!O.details||O.details.live)},b.playlistLoaded=function(O,A,S){var C=this,d=A.details,o=A.stats,s=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(d.advancedDateTime=Date.now()-s,d.live||S!=null&&S.live){if(d.reloaded(S),S&&this.log("live playlist "+O+" "+(d.advanced?"REFRESHED "+d.lastPartSn+"-"+d.lastPartIndex:"MISSED")),S&&d.fragments.length>0&&Object(y.mergeDetails)(S,d),!this.canLoad||!d.live)return;var u,T=void 0,m=void 0;if(d.canBlockReload&&d.endSN&&d.advanced){var p=this.hls.config.lowLatencyMode,_=d.lastPartSn,v=d.endSN,c=d.lastPartIndex,h=c!==-1,l=_===v,a=p?0:c;h?(T=l?v+1:_,m=l?a:c+1):T=v+1;var g=d.age,f=g+d.ageHeader,x=Math.min(f-d.partTarget,d.targetduration*1.5);if(x>0){if(S&&x>S.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+S.tuneInGoal+" to: "+x+" with playlist age: "+d.age),x=0;else{var P=Math.floor(x/d.targetduration);if(T+=P,m!==void 0){var G=Math.round(x%d.targetduration/d.partTarget);m+=G}this.log("CDN Tune-in age: "+d.ageHeader+"s last advanced "+g.toFixed(2)+"s goal: "+x+" skip sn "+P+" to part "+m)}d.tuneInGoal=x}if(u=this.getDeliveryDirectives(d,A.deliveryDirectives,T,m),p||!l){this.loadPlaylist(u);return}}else u=this.getDeliveryDirectives(d,A.deliveryDirectives,T,m);var X=Object(y.computeReloadInterval)(d,o);T!==void 0&&d.canBlockReload&&(X-=d.partTarget||1),this.log("reload live playlist "+O+" in "+Math.round(X)+" ms"),this.timer=self.setTimeout(function(){return C.loadPlaylist(u)},X)}else this.clearTimer()},b.getDeliveryDirectives=function(O,A,S,C){var d=Object(I.getSkipValue)(O,S);return A!=null&&A.skip&&O.deltaUpdateFailed&&(S=A.msn,C=A.part,d=I.HlsSkip.No),new I.HlsUrlParameters(S,C,d)},b.retryLoadingOrFail=function(O){var A=this,S=this.hls.config,C=this.retryCount<S.levelLoadingMaxRetry;if(C){var d;if(this.retryCount++,O.details.indexOf("LoadTimeOut")>-1&&(d=O.context)!==null&&d!==void 0&&d.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+O.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*S.levelLoadingRetryDelay,S.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return A.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+O.details+'"')}}else this.warn('cannot recover from error "'+O.details+'"'),this.clearTimer(),O.fatal=!0;return C},R}()},"./src/controller/base-stream-controller.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"State",function(){return v}),D.d(Q,"default",function(){return c});var V=D("./src/polyfills/number.ts"),I=D("./src/task-loop.ts"),y=D("./src/controller/fragment-tracker.ts"),j=D("./src/utils/buffer-helper.ts"),B=D("./src/utils/logger.ts"),M=D("./src/events.ts"),R=D("./src/errors.ts"),b=D("./src/types/transmuxer.ts"),w=D("./src/utils/mp4-tools.ts"),O=D("./src/utils/discontinuities.ts"),A=D("./src/controller/fragment-finders.ts"),S=D("./src/controller/level-helper.ts"),C=D("./src/loader/fragment-loader.ts"),d=D("./src/crypt/decrypter.ts"),o=D("./src/utils/time-ranges.ts"),s=D("./src/types/loader.ts");function u(h,l){for(var a=0;a<l.length;a++){var g=l[a];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(h,g.key,g)}}function T(h,l,a){return l&&u(h.prototype,l),a&&u(h,a),h}function m(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}function p(h,l){h.prototype=Object.create(l.prototype),h.prototype.constructor=h,_(h,l)}function _(h,l){return _=Object.setPrototypeOf||function(g,f){return g.__proto__=f,g},_(h,l)}var v={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"},c=function(h){p(l,h);function l(g,f,x){var P;return P=h.call(this)||this,P.hls=void 0,P.fragPrevious=null,P.fragCurrent=null,P.fragmentTracker=void 0,P.transmuxer=null,P._state=v.STOPPED,P.media=void 0,P.mediaBuffer=void 0,P.config=void 0,P.bitrateTest=!1,P.lastCurrentTime=0,P.nextLoadPosition=0,P.startPosition=0,P.loadedmetadata=!1,P.fragLoadError=0,P.retryDate=0,P.levels=null,P.fragmentLoader=void 0,P.levelLastLoaded=null,P.startFragRequested=!1,P.decrypter=void 0,P.initPTS=[],P.onvseeking=null,P.onvended=null,P.logPrefix="",P.log=void 0,P.warn=void 0,P.logPrefix=x,P.log=B.logger.log.bind(B.logger,x+":"),P.warn=B.logger.warn.bind(B.logger,x+":"),P.hls=g,P.fragmentLoader=new C.default(g.config),P.fragmentTracker=f,P.config=g.config,P.decrypter=new d.default(g,g.config),g.on(M.Events.KEY_LOADED,P.onKeyLoaded,m(P)),P}var a=l.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(f){},a.stopLoad=function(){this.fragmentLoader.abort();var f=this.fragCurrent;f&&this.fragmentTracker.removeFragment(f),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=v.STOPPED},a._streamEnded=function(f,x){var P=this.fragCurrent,G=this.fragmentTracker;if(!x.live&&P&&P.sn===x.endSN&&!f.nextStart){var X=G.getState(P);return X===y.FragmentState.PARTIAL||X===y.FragmentState.OK}return!1},a.onMediaAttached=function(f,x){var P=this.media=this.mediaBuffer=x.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),P.addEventListener("seeking",this.onvseeking),P.addEventListener("ended",this.onvended);var G=this.config;this.levels&&G.autoStartLoad&&this.state===v.STOPPED&&this.startLoad(G.startPosition)},a.onMediaDetaching=function(){var f=this.media;f!=null&&f.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),f&&(f.removeEventListener("seeking",this.onvseeking),f.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var f=this.config,x=this.fragCurrent,P=this.media,G=this.mediaBuffer,X=this.state,ie=P?P.currentTime:0,z=j.BufferHelper.bufferInfo(G||P,ie,f.maxBufferHole);if(this.log("media seeking to "+(Object(V.isFiniteNumber)(ie)?ie.toFixed(3):ie)+", state: "+X),X===v.ENDED)this.resetLoadingState();else if(x&&!z.len){var F=f.maxFragLookUpTolerance,ne=x.start-F,ce=x.start+x.duration+F,ge=ie>ce;(ie<ne||ge)&&(ge&&x.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),x.loader.abort()),this.resetLoadingState())}P&&(this.lastCurrentTime=ie),!this.loadedmetadata&&!z.len&&(this.nextLoadPosition=this.startPosition=ie),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(f,x){if(this.state!==v.KEY_LOADING||x.frag!==this.fragCurrent||!this.levels)return;this.state=v.IDLE;var P=this.levels[x.frag.level].details;P&&this.loadFragment(x.frag,P,x.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),h.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=v.STOPPED,this.hls.off(M.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,h.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(f,x){this.log("Loading key for "+f.sn+" of ["+x.startSN+"-"+x.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+f.level),this.state=v.KEY_LOADING,this.fragCurrent=f,this.hls.trigger(M.Events.KEY_LOADING,{frag:f})},a.loadFragment=function(f,x,P){this._loadFragForPlayback(f,x,P)},a._loadFragForPlayback=function(f,x,P){var G=this,X=function(z){if(G.fragContextChanged(f)){G.warn("Fragment "+f.sn+(z.part?" p: "+z.part.index:"")+" of level "+f.level+" was dropped during download."),G.fragmentTracker.removeFragment(f);return}f.stats.chunkCount++,G._handleFragmentLoadProgress(z)};this._doFragLoad(f,x,P,X).then(function(ie){if(!ie)return;G.fragLoadError=0;var z=G.state;if(G.fragContextChanged(f)){(z===v.FRAG_LOADING||z===v.BACKTRACKING||!G.fragCurrent&&z===v.PARSING)&&(G.fragmentTracker.removeFragment(f),G.state=v.IDLE);return}if("payload"in ie&&(G.log("Loaded fragment "+f.sn+" of level "+f.level),G.hls.trigger(M.Events.FRAG_LOADED,ie),G.state===v.BACKTRACKING)){G.fragmentTracker.backtrack(f,ie),G.resetFragmentLoading(f);return}G._handleFragmentLoadComplete(ie)}).catch(function(ie){G.warn(ie),G.resetFragmentLoading(f)})},a.flushMainBuffer=function(f,x,P){if(P===void 0&&(P=null),!(f-x))return;var G={startOffset:f,endOffset:x,type:P};this.fragLoadError=0,this.hls.trigger(M.Events.BUFFER_FLUSHING,G)},a._loadInitSegment=function(f){var x=this;this._doFragLoad(f).then(function(P){if(!P||x.fragContextChanged(f)||!x.levels)throw new Error("init load aborted");return P}).then(function(P){var G=x.hls,X=P.payload,ie=f.decryptdata;if(X&&X.byteLength>0&&ie&&ie.key&&ie.iv&&ie.method==="AES-128"){var z=self.performance.now();return x.decrypter.webCryptoDecrypt(new Uint8Array(X),ie.key.buffer,ie.iv.buffer).then(function(F){var ne=self.performance.now();return G.trigger(M.Events.FRAG_DECRYPTED,{frag:f,payload:F,stats:{tstart:z,tdecrypt:ne}}),P.payload=F,P})}return P}).then(function(P){var G=x.fragCurrent,X=x.hls,ie=x.levels;if(!ie)throw new Error("init load aborted, missing levels");var z=ie[f.level].details;console.assert(z,"Level details are defined when init segment is loaded");var F=f.stats;x.state=v.IDLE,x.fragLoadError=0,f.data=new Uint8Array(P.payload),F.parsing.start=F.buffering.start=self.performance.now(),F.parsing.end=F.buffering.end=self.performance.now(),P.frag===G&&X.trigger(M.Events.FRAG_BUFFERED,{stats:F,frag:G,part:null,id:f.type}),x.tick()}).catch(function(P){x.warn(P),x.resetFragmentLoading(f)})},a.fragContextChanged=function(f){var x=this.fragCurrent;return!f||!x||f.level!==x.level||f.sn!==x.sn||f.urlId!==x.urlId},a.fragBufferedComplete=function(f,x){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+f.type+" sn: "+f.sn+(x?" part: "+x.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+f.level+" "+o.default.toString(j.BufferHelper.getBuffered(P))),this.state=v.IDLE,this.tick()},a._handleFragmentLoadComplete=function(f){var x=this.transmuxer;if(!x)return;var P=f.frag,G=f.part,X=f.partsLoaded,ie=!X||X.length===0||X.some(function(F){return!F}),z=new b.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,G?G.index:-1,!ie);x.flush(z)},a._handleFragmentLoadProgress=function(f){},a._doFragLoad=function(f,x,P,G){var X=this;if(P===void 0&&(P=null),!this.levels)throw new Error("frag load aborted, missing levels");if(P=Math.max(f.start,P||0),this.config.lowLatencyMode&&x){var ie=x.partList;if(ie&&G){P>f.end&&x.fragmentHint&&(f=x.fragmentHint);var z=this.getNextPart(ie,f,P);if(z>-1){var F=ie[z];return this.log("Loading part sn: "+f.sn+" p: "+F.index+" cc: "+f.cc+" of playlist ["+x.startSN+"-"+x.endSN+"] parts [0-"+z+"-"+(ie.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+f.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=F.start+F.duration,this.state=v.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:f,part:ie[z],targetBufferTime:P}),this.doFragPartsLoad(f,ie,z,G).catch(function(ne){return X.handleFragLoadError(ne)})}else if(!f.url||this.loadedEndOfParts(ie,P))return Promise.resolve(null)}}return this.log("Loading fragment "+f.sn+" cc: "+f.cc+" "+(x?"of ["+x.startSN+"-"+x.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+f.level+", target: "+parseFloat(P.toFixed(3))),Object(V.isFiniteNumber)(f.sn)&&!this.bitrateTest&&(this.nextLoadPosition=f.start+f.duration),this.state=v.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:f,targetBufferTime:P}),this.fragmentLoader.load(f,G).catch(function(ne){return X.handleFragLoadError(ne)})},a.doFragPartsLoad=function(f,x,P,G){var X=this;return new Promise(function(ie,z){var F=[],ne=function ce(ge){var be=x[ge];X.fragmentLoader.loadPart(f,be,G).then(function(Ie){F[be.index]=Ie;var Te=Ie.part;X.hls.trigger(M.Events.FRAG_LOADED,Ie);var De=x[ge+1];if(De&&De.fragment===f)ce(ge+1);else return ie({frag:f,part:Te,partsLoaded:F})}).catch(z)};ne(P)})},a.handleFragLoadError=function(f){var x=f.data;return x&&x.details===R.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(x.frag,x.part):this.hls.trigger(M.Events.ERROR,x),null},a._handleTransmuxerFlush=function(f){var x=this.getCurrentContext(f);if(!x||this.state!==v.PARSING){this.fragCurrent||(this.state=v.IDLE);return}var P=x.frag,G=x.part,X=x.level,ie=self.performance.now();P.stats.parsing.end=ie,G&&(G.stats.parsing.end=ie),this.updateLevelTiming(P,G,X,f.partial)},a.getCurrentContext=function(f){var x=this.levels,P=f.level,G=f.sn,X=f.part;if(!x||!x[P])return this.warn("Levels object was unset while buffering fragment "+G+" of level "+P+". The current chunk will not be buffered."),null;var ie=x[P],z=X>-1?Object(S.getPartWith)(ie,G,X):null,F=z?z.fragment:Object(S.getFragmentWithSN)(ie,G,this.fragCurrent);return F?{frag:F,part:z,level:ie}:null},a.bufferFragmentData=function(f,x,P,G){if(!f||this.state!==v.PARSING)return;var X=f.data1,ie=f.data2,z=X;if(X&&ie&&(z=Object(w.appendUint8Array)(X,ie)),!z||!z.length)return;var F={type:f.type,frag:x,part:P,chunkMeta:G,parent:x.type,data:z};this.hls.trigger(M.Events.BUFFER_APPENDING,F),f.dropped&&f.independent&&!P&&this.flushBufferGap(x)},a.flushBufferGap=function(f){var x=this.media;if(!x)return;if(!j.BufferHelper.isBuffered(x,x.currentTime)){this.flushMainBuffer(0,f.start);return}var P=x.currentTime,G=j.BufferHelper.bufferInfo(x,P,0),X=f.duration,ie=Math.min(this.config.maxFragLookUpTolerance*2,X*.25),z=Math.max(Math.min(f.start-ie,G.end-ie),P+ie);f.start-z>ie&&this.flushMainBuffer(z,f.start)},a.getFwdBufferInfo=function(f,x){var P=this.config,G=this.getLoadPosition();if(!Object(V.isFiniteNumber)(G))return null;var X=j.BufferHelper.bufferInfo(f,G,P.maxBufferHole);if(X.len===0&&X.nextStart!==void 0){var ie=this.fragmentTracker.getBufferedFrag(G,x);if(ie&&X.nextStart<ie.end)return j.BufferHelper.bufferInfo(f,G,Math.max(X.nextStart,P.maxBufferHole))}return X},a.getMaxBufferLength=function(f){var x=this.config,P;return f?P=Math.max(8*x.maxBufferSize/f,x.maxBufferLength):P=x.maxBufferLength,Math.min(P,x.maxMaxBufferLength)},a.reduceMaxBufferLength=function(f){var x=this.config,P=f||x.maxBufferLength;return x.maxMaxBufferLength>=P?(x.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+x.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(f,x){var P,G,X=x.fragments,ie=X.length;if(!ie)return null;var z=this.config,F=X[0].start,ne;if(x.live){var ce=z.initialLiveManifestSize;if(ie<ce)return this.warn("Not enough fragments to start playback (have: "+ie+", need: "+ce+")"),null;!x.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(ne=this.getInitialLiveFragment(x,X),this.startPosition=ne?this.hls.liveSyncPosition||ne.start:f)}else f<=F&&(ne=X[0]);if(!ne){var ge=z.lowLatencyMode?x.partEnd:x.fragmentEnd;ne=this.getFragmentAtPosition(f,ge,x)}return(P=ne)!==null&&P!==void 0&&P.initSegment&&!((G=ne)!==null&&G!==void 0&&G.initSegment.data)&&!this.bitrateTest&&(ne=ne.initSegment),ne},a.getNextPart=function(f,x,P){for(var G=-1,X=!1,ie=!0,z=0,F=f.length;z<F;z++){var ne=f[z];if(ie=ie&&!ne.independent,G>-1&&P<ne.start)break;var ce=ne.loaded;!ce&&(X||ne.independent||ie)&&ne.fragment===x&&(G=z),X=ce}return G},a.loadedEndOfParts=function(f,x){var P=f[f.length-1];return P&&x>P.start&&P.loaded},a.getInitialLiveFragment=function(f,x){var P=this.fragPrevious,G=null;if(P){if(f.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),G=Object(A.findFragmentByPDT)(x,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!G){var X=P.sn+1;if(X>=f.startSN&&X<=f.endSN){var ie=x[X-f.startSN];P.cc===ie.cc&&(G=ie,this.log("Live playlist, switching playlist, load frag with next SN: "+G.sn))}G||(G=Object(A.findFragWithCC)(x,P.cc),G&&this.log("Live playlist, switching playlist, load frag with same CC: "+G.sn))}}else{var z=this.hls.liveSyncPosition;z!==null&&(G=this.getFragmentAtPosition(z,this.bitrateTest?f.fragmentEnd:f.edge,f))}return G},a.getFragmentAtPosition=function(f,x,P){var G=this.config,X=this.fragPrevious,ie=P.fragments,z=P.endSN,F=P.fragmentHint,ne=G.maxFragLookUpTolerance,ce=!!(G.lowLatencyMode&&P.partList&&F);ce&&F&&!this.bitrateTest&&(ie=ie.concat(F),z=F.sn);var ge;if(f<x){var be=f>x-ne?0:ne;ge=Object(A.findFragmentByPTS)(X,ie,f,be)}else ge=ie[ie.length-1];if(ge){var Ie=ge.sn-P.startSN,Te=X&&ge.level===X.level,De=ie[Ie+1],we=this.fragmentTracker.getState(ge);if(we===y.FragmentState.BACKTRACKED){ge=null;for(var Ae=Ie;ie[Ae]&&this.fragmentTracker.getState(ie[Ae])===y.FragmentState.BACKTRACKED;)X?ge=ie[Ae--]:ge=ie[--Ae];ge||(ge=De)}else X&&ge.sn===X.sn&&!ce&&(Te&&(ge.sn<z&&this.fragmentTracker.getState(De)!==y.FragmentState.OK?(this.log("SN "+ge.sn+" just loaded, load next one: "+De.sn),ge=De):ge=null))}return ge},a.synchronizeToLiveEdge=function(f){var x=this.config,P=this.media;if(!P)return;var G=this.hls.liveSyncPosition,X=P.currentTime,ie=f.fragments[0].start,z=f.edge,F=X>=ie-x.maxFragLookUpTolerance&&X<=z;if(G!==null&&P.duration>G&&(X<G||!F)){var ne=x.liveMaxLatencyDuration!==void 0?x.liveMaxLatencyDuration:x.liveMaxLatencyDurationCount*f.targetduration;(!F&&P.readyState<4||X<z-ne)&&(this.loadedmetadata||(this.nextLoadPosition=G),P.readyState&&(this.warn("Playback: "+X.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+G.toFixed(3)),P.currentTime=G))}},a.alignPlaylists=function(f,x){var P=this.levels,G=this.levelLastLoaded,X=this.fragPrevious,ie=G!==null?P[G]:null,z=f.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var F=f.fragments[0].start,ne=!x,ce=f.alignedSliding&&Object(V.isFiniteNumber)(F);if(ne||!ce&&!F){Object(O.alignStream)(X,ie,f);var ge=f.fragments[0].start;return this.log("Live playlist sliding: "+ge.toFixed(2)+" start-sn: "+(x?x.startSN:"na")+"->"+f.startSN+" prev-sn: "+(X?X.sn:"na")+" fragments: "+z),ge}return F},a.waitForCdnTuneIn=function(f){var x=3;return f.live&&f.canBlockReload&&f.tuneInGoal>Math.max(f.partHoldBack,f.partTarget*x)},a.setStartPosition=function(f,x){var P=this.startPosition;if(P<x&&(P=-1),P===-1||this.lastCurrentTime===-1){var G=f.startTimeOffset;Object(V.isFiniteNumber)(G)?(P=x+G,G<0&&(P+=f.totalduration),P=Math.min(Math.max(x,P),x+f.totalduration),this.log("Start time offset "+G+" found in playlist, adjust startPosition to "+P),this.startPosition=P):f.live?P=this.hls.liveSyncPosition||x:this.startPosition=P=0,this.lastCurrentTime=P}this.nextLoadPosition=P},a.getLoadPosition=function(){var f=this.media,x=0;return this.loadedmetadata&&f?x=f.currentTime:this.nextLoadPosition&&(x=this.nextLoadPosition),x},a.handleFragLoadAborted=function(f,x){this.transmuxer&&f.sn!=="initSegment"&&f.stats.aborted&&(this.warn("Fragment "+f.sn+(x?" part"+x.index:"")+" of level "+f.level+" was aborted"),this.resetFragmentLoading(f))},a.resetFragmentLoading=function(f){(!this.fragCurrent||!this.fragContextChanged(f))&&(this.state=v.IDLE)},a.onFragmentOrKeyLoadError=function(f,x){if(x.fatal)return;var P=x.frag;if(!P||P.type!==f)return;var G=this.fragCurrent;console.assert(G&&P.sn===G.sn&&P.level===G.level&&P.urlId===G.urlId,"Frag load error must match current frag to retry");var X=this.config;if(this.fragLoadError+1<=X.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(P.level))return;var ie=Math.min(Math.pow(2,this.fragLoadError)*X.fragLoadingRetryDelay,X.fragLoadingMaxRetryTimeout);this.warn("Fragment "+P.sn+" of "+f+" "+P.level+" failed to load, retrying in "+ie+"ms"),this.retryDate=self.performance.now()+ie,this.fragLoadError++,this.state=v.FRAG_LOADING_WAITING_RETRY}else x.levelRetry?(f===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=v.IDLE):(B.logger.error(x.details+" reaches max retry, redispatch as fatal ..."),x.fatal=!0,this.hls.stopLoad(),this.state=v.ERROR)},a.afterBufferFlushed=function(f,x,P){if(!f)return;var G=j.BufferHelper.getBuffered(f);this.fragmentTracker.detectEvictedFragments(x,G,P),this.state===v.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=v.IDLE},a.resetLiveStartWhenNotLoaded=function(f){if(!this.loadedmetadata){this.startFragRequested=!1;var x=this.levels?this.levels[f].details:null;if(x!=null&&x.live)return this.startPosition=-1,this.setStartPosition(x,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(f,x,P,G){var X=this,ie=P.details;console.assert(!!ie,"level.details must be defined");var z=Object.keys(f.elementaryStreams).reduce(function(F,ne){var ce=f.elementaryStreams[ne];if(ce){var ge=ce.endPTS-ce.startPTS;if(ge<=0)return X.warn("Could not parse fragment "+f.sn+" "+ne+" duration reliably ("+ge+") resetting transmuxer to fallback to playlist timing"),X.resetTransmuxer(),F||!1;var be=G?0:Object(S.updateFragPTSDTS)(ie,f,ce.startPTS,ce.endPTS,ce.startDTS,ce.endDTS);return X.hls.trigger(M.Events.LEVEL_PTS_UPDATED,{details:ie,level:P,drift:be,type:ne,frag:f,start:ce.startPTS,end:ce.endPTS}),!0}return F},!1);z?(this.state=v.PARSED,this.hls.trigger(M.Events.FRAG_PARSED,{frag:f,part:x})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},T(l,[{key:"state",get:function(){return this._state},set:function(f){var x=this._state;x!==f&&(this._state=f,this.log(x+"->"+f))}}]),l}(I.default)},"./src/controller/buffer-controller.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return A});var V=D("./src/polyfills/number.ts"),I=D("./src/events.ts"),y=D("./src/utils/logger.ts"),j=D("./src/errors.ts"),B=D("./src/utils/buffer-helper.ts"),M=D("./src/utils/mediasource-helper.ts"),R=D("./src/loader/fragment.ts"),b=D("./src/controller/buffer-operation-queue.ts"),w=Object(M.getMediaSource)(),O=/([ha]vc.)(?:\.[^.,]+)+/,A=function(){function S(d){var o=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var s=o.hls,u=o.media,T=o.mediaSource;y.logger.log("[buffer-controller]: Media source opened"),u&&(o.updateMediaElementDuration(),s.trigger(I.Events.MEDIA_ATTACHED,{media:u})),T&&T.removeEventListener("sourceopen",o._onMediaSourceOpen),o.checkPendingTracks()},this._onMediaSourceClose=function(){y.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){y.logger.log("[buffer-controller]: Media source ended")},this.hls=d,this._initSourceBuffer(),this.registerListeners()}var C=S.prototype;return C.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},C.destroy=function(){this.unregisterListeners(),this.details=null},C.registerListeners=function(){var o=this.hls;o.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(I.Events.BUFFER_RESET,this.onBufferReset,this),o.on(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(I.Events.BUFFER_EOS,this.onBufferEos,this),o.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(I.Events.FRAG_PARSED,this.onFragParsed,this),o.on(I.Events.FRAG_CHANGED,this.onFragChanged,this)},C.unregisterListeners=function(){var o=this.hls;o.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(I.Events.BUFFER_RESET,this.onBufferReset,this),o.off(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(I.Events.BUFFER_EOS,this.onBufferEos,this),o.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(I.Events.FRAG_PARSED,this.onFragParsed,this),o.off(I.Events.FRAG_CHANGED,this.onFragChanged,this)},C._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new b.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},C.onManifestParsed=function(o,s){var u=2;(s.audio&&!s.video||!s.altAudio)&&(u=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=u,this.details=null,y.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},C.onMediaAttaching=function(o,s){var u=this.media=s.media;if(u&&w){var T=this.mediaSource=new w;T.addEventListener("sourceopen",this._onMediaSourceOpen),T.addEventListener("sourceended",this._onMediaSourceEnded),T.addEventListener("sourceclose",this._onMediaSourceClose),u.src=self.URL.createObjectURL(T),this._objectUrl=u.src}},C.onMediaDetaching=function(){var o=this.media,s=this.mediaSource,u=this._objectUrl;if(s){if(y.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(T){y.logger.warn("[buffer-controller]: onMediaDetaching: "+T.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(u&&self.URL.revokeObjectURL(u),o.src===u?(o.removeAttribute("src"),o.load()):y.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)},C.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(s){var u=o.sourceBuffer[s];try{u&&(o.removeBufferListeners(s),o.mediaSource&&o.mediaSource.removeSourceBuffer(u),o.sourceBuffer[s]=void 0)}catch(T){y.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",T)}}),this._initSourceBuffer()},C.onBufferCodecs=function(o,s){var u=this,T=this.getSourceBufferTypes().length;if(Object.keys(s).forEach(function(m){if(T){var p=u.tracks[m];if(p&&typeof p.buffer.changeType=="function"){var _=s[m],v=_.codec,c=_.levelCodec,h=_.container,l=(p.levelCodec||p.codec).replace(O,"$1"),a=(c||v).replace(O,"$1");if(l!==a){var g=h+";codecs="+(c||v);u.appendChangeType(m,g)}}}else u.pendingTracks[m]=s[m]}),T)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},C.appendChangeType=function(o,s){var u=this,T=this.operationQueue,m={execute:function(){var _=u.sourceBuffer[o];_&&(y.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+s),_.changeType(s)),T.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(_){y.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",_)}};T.append(m,o)},C.onBufferAppending=function(o,s){var u=this,T=this.hls,m=this.operationQueue,p=this.tracks,_=s.data,v=s.type,c=s.frag,h=s.part,l=s.chunkMeta,a=l.buffering[v],g=self.performance.now();a.start=g;var f=c.stats.buffering,x=h?h.stats.buffering:null;f.start===0&&(f.start=g),x&&x.start===0&&(x.start=g);var P=p.audio,G=v==="audio"&&l.id===1&&(P==null?void 0:P.container)==="audio/mpeg",X={execute:function(){if(a.executeStart=self.performance.now(),G){var z=u.sourceBuffer[v];if(z){var F=c.start-z.timestampOffset;Math.abs(F)>=.1&&(y.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+c.start+" (delta: "+F+") sn: "+c.sn+")"),z.timestampOffset=c.start)}}u.appendExecutor(_,v)},onStart:function(){},onComplete:function(){var z=self.performance.now();a.executeEnd=a.end=z,f.first===0&&(f.first=z),x&&x.first===0&&(x.first=z);var F=u.sourceBuffer,ne={};for(var ce in F)ne[ce]=B.BufferHelper.getBuffered(F[ce]);u.appendError=0,u.hls.trigger(I.Events.BUFFER_APPENDED,{type:v,frag:c,part:h,chunkMeta:l,parent:c.type,timeRanges:ne})},onError:function(z){y.logger.error("[buffer-controller]: Error encountered while trying to append to the "+v+" SourceBuffer",z);var F={type:j.ErrorTypes.MEDIA_ERROR,parent:c.type,details:j.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?F.details=j.ErrorDetails.BUFFER_FULL_ERROR:(u.appendError++,F.details=j.ErrorDetails.BUFFER_APPEND_ERROR,u.appendError>T.config.appendErrorMaxRetry&&(y.logger.error("[buffer-controller]: Failed "+T.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),F.fatal=!0)),T.trigger(I.Events.ERROR,F)}};m.append(X,v)},C.onBufferFlushing=function(o,s){var u=this,T=this.operationQueue,m=function(_){return{execute:u.removeExecutor.bind(u,_,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){u.hls.trigger(I.Events.BUFFER_FLUSHED,{type:_})},onError:function(c){y.logger.warn("[buffer-controller]: Failed to remove from "+_+" SourceBuffer",c)}}};s.type?T.append(m(s.type),s.type):this.getSourceBufferTypes().forEach(function(p){T.append(m(p),p)})},C.onFragParsed=function(o,s){var u=this,T=s.frag,m=s.part,p=[],_=m?m.elementaryStreams:T.elementaryStreams;_[R.ElementaryStreamTypes.AUDIOVIDEO]?p.push("audiovideo"):(_[R.ElementaryStreamTypes.AUDIO]&&p.push("audio"),_[R.ElementaryStreamTypes.VIDEO]&&p.push("video"));var v=function(){var h=self.performance.now();T.stats.buffering.end=h,m&&(m.stats.buffering.end=h);var l=m?m.stats:T.stats;u.hls.trigger(I.Events.FRAG_BUFFERED,{frag:T,part:m,stats:l,id:T.type})};p.length===0&&y.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+T.type+" level: "+T.level+" sn: "+T.sn),this.blockBuffers(v,p)},C.onFragChanged=function(o,s){this.flushBackBuffer()},C.onBufferEos=function(o,s){var u=this,T=this.getSourceBufferTypes().reduce(function(m,p){var _=u.sourceBuffer[p];return(!s.type||s.type===p)&&(_&&!_.ended&&(_.ended=!0,y.logger.log("[buffer-controller]: "+p+" sourceBuffer now EOS"))),m&&!!(!_||_.ended)},!0);T&&this.blockBuffers(function(){var m=u.mediaSource;if(!m||m.readyState!=="open")return;m.endOfStream()})},C.onLevelUpdated=function(o,s){var u=s.details;if(!u.fragments.length)return;this.details=u,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},C.flushBackBuffer=function(){var o=this.hls,s=this.details,u=this.media,T=this.sourceBuffer;if(!u||s===null)return;var m=this.getSourceBufferTypes();if(!m.length)return;var p=s.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(V.isFiniteNumber)(p)||p<0)return;var _=u.currentTime,v=s.levelTargetDuration,c=Math.max(p,v),h=Math.floor(_/v)*v-c;m.forEach(function(l){var a=T[l];if(a){var g=B.BufferHelper.getBuffered(a);g.length>0&&h>g.start(0)&&(o.trigger(I.Events.BACK_BUFFER_REACHED,{bufferEnd:h}),s.live&&o.trigger(I.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h}),o.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:l}))}})},C.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,s=this.hls,u=this.media,T=this.mediaSource,m=o.fragments[0].start+o.totalduration,p=u.duration,_=Object(V.isFiniteNumber)(T.duration)?T.duration:0;o.live&&s.config.liveDurationInfinity?(y.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),T.duration=Infinity,this.updateSeekableRange(o)):(m>_&&m>p||!Object(V.isFiniteNumber)(p))&&(y.logger.log("[buffer-controller]: Updating Media Source duration to "+m.toFixed(3)),T.duration=m)},C.updateSeekableRange=function(o){var s=this.mediaSource,u=o.fragments,T=u.length;if(T&&o.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var m=Math.max(0,u[0].start),p=Math.max(m,m+o.totalduration);s.setLiveSeekableRange(m,p)}},C.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,s=this.operationQueue,u=this.pendingTracks,T=Object.keys(u).length;if(T&&!o||T===2){this.createSourceBuffers(u),this.pendingTracks={};var m=this.getSourceBufferTypes();if(m.length===0){this.hls.trigger(I.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}m.forEach(function(p){s.executeNext(p)})}},C.createSourceBuffers=function(o){var s=this.sourceBuffer,u=this.mediaSource;if(!u)throw Error("createSourceBuffers called when mediaSource was null");var T=0;for(var m in o)if(!s[m]){var p=o[m];if(!p)throw Error("source buffer exists for track "+m+", however track does not");var _=p.levelCodec||p.codec,v=p.container+";codecs="+_;y.logger.log("[buffer-controller]: creating sourceBuffer("+v+")");try{var c=s[m]=u.addSourceBuffer(v),h=m;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[m]={buffer:c,codec:_,container:p.container,levelCodec:p.levelCodec,id:p.id},T++}catch(l){y.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+l.message),this.hls.trigger(I.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:v})}}T&&this.hls.trigger(I.Events.BUFFER_CREATED,{tracks:this.tracks})},C._onSBUpdateStart=function(o){var s=this.operationQueue,u=s.current(o);u.onStart()},C._onSBUpdateEnd=function(o){var s=this.operationQueue,u=s.current(o);u.onComplete(),s.shiftAndExecuteNext(o)},C._onSBUpdateError=function(o,s){y.logger.error("[buffer-controller]: "+o+" SourceBuffer error",s),this.hls.trigger(I.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var u=this.operationQueue.current(o);u&&u.onError(s)},C.removeExecutor=function(o,s,u){var T=this.media,m=this.mediaSource,p=this.operationQueue,_=this.sourceBuffer,v=_[o];if(!T||!m||!v){y.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),p.shiftAndExecuteNext(o);return}var c=Object(V.isFiniteNumber)(T.duration)?T.duration:Infinity,h=Object(V.isFiniteNumber)(m.duration)?m.duration:Infinity,l=Math.max(0,s),a=Math.min(u,c,h);a>l?(y.logger.log("[buffer-controller]: Removing ["+l+","+a+"] from the "+o+" SourceBuffer"),console.assert(!v.updating,o+" sourceBuffer must not be updating"),v.remove(l,a)):p.shiftAndExecuteNext(o)},C.appendExecutor=function(o,s){var u=this.operationQueue,T=this.sourceBuffer,m=T[s];if(!m){y.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),u.shiftAndExecuteNext(s);return}m.ended=!1,console.assert(!m.updating,s+" sourceBuffer must not be updating"),m.appendBuffer(o)},C.blockBuffers=function(o,s){var u=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){y.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var T=this.operationQueue,m=s.map(function(p){return T.appendBlocker(p)});Promise.all(m).then(function(){o(),s.forEach(function(p){var _=u.sourceBuffer[p];(!_||!_.updating)&&T.shiftAndExecuteNext(p)})})},C.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},C.addBufferListener=function(o,s,u){var T=this.sourceBuffer[o];if(!T)return;var m=u.bind(this,o);this.listeners[o].push({event:s,listener:m}),T.addEventListener(s,m)},C.removeBufferListeners=function(o){var s=this.sourceBuffer[o];if(!s)return;this.listeners[o].forEach(function(u){s.removeEventListener(u.event,u.listener)})},S}()},"./src/controller/buffer-operation-queue.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return I});var V=D("./src/utils/logger.ts"),I=function(){function y(B){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=B}var j=y.prototype;return j.append=function(M,R){var b=this.queues[R];b.push(M),b.length===1&&this.buffers[R]&&this.executeNext(R)},j.insertAbort=function(M,R){var b=this.queues[R];b.unshift(M),this.executeNext(R)},j.appendBlocker=function(M){var R,b=new Promise(function(O){R=O}),w={execute:R,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(w,M),b},j.executeNext=function(M){var R=this.buffers,b=this.queues,w=R[M],O=b[M];if(O.length){var A=O[0];try{A.execute()}catch(S){V.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),A.onError(S),(!w||!w.updating)&&(O.shift(),this.executeNext(M))}}},j.shiftAndExecuteNext=function(M){this.queues[M].shift(),this.executeNext(M)},j.current=function(M){return this.queues[M][0]},y}()},"./src/controller/cap-level-controller.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/events.ts");function I(B,M){for(var R=0;R<M.length;R++){var b=M[R];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(B,b.key,b)}}function y(B,M,R){return M&&I(B.prototype,M),R&&I(B,R),B}var j=function(){function B(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 M=B.prototype;return M.setStreamController=function(b){this.streamController=b},M.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},M.registerListeners=function(){var b=this.hls;b.on(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.on(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.unregisterListener=function(){var b=this.hls;b.off(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.off(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.onFpsDropLevelCapping=function(b,w){B.isLevelAllowed(w.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(w.droppedLevel)},M.onMediaAttaching=function(b,w){this.media=w.media instanceof HTMLVideoElement?w.media:null},M.onManifestParsed=function(b,w){var O=this.hls;this.restrictedLevels=[],this.firstLevel=w.firstLevel,O.config.capLevelToPlayerSize&&w.video&&this.startCapping()},M.onBufferCodecs=function(b,w){var O=this.hls;O.config.capLevelToPlayerSize&&w.video&&this.startCapping()},M.onMediaDetaching=function(){this.stopCapping()},M.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var b=this.hls.levels;if(b.length){var w=this.hls;w.autoLevelCapping=this.getMaxLevel(b.length-1),w.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=w.autoLevelCapping}}},M.getMaxLevel=function(b){var w=this,O=this.hls.levels;if(!O.length)return-1;var A=O.filter(function(S,C){return B.isLevelAllowed(C,w.restrictedLevels)&&C<=b});return this.clientRect=null,B.getMaxLevelByMediaSize(A,this.mediaWidth,this.mediaHeight)},M.startCapping=function(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize()},M.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},M.getDimensions=function(){if(this.clientRect)return this.clientRect;var b=this.media,w={width:0,height:0};if(b){var O=b.getBoundingClientRect();w.width=O.width,w.height=O.height,!w.width&&!w.height&&(w.width=O.right-O.left||b.width||0,w.height=O.bottom-O.top||b.height||0)}return this.clientRect=w,w},B.isLevelAllowed=function(b,w){return w===void 0&&(w=[]),w.indexOf(b)===-1},B.getMaxLevelByMediaSize=function(b,w,O){if(!b||!b.length)return-1;for(var A=function(s,u){return u?s.width!==u.width||s.height!==u.height:!0},S=b.length-1,C=0;C<b.length;C+=1){var d=b[C];if((d.width>=w||d.height>=O)&&A(d,b[C+1])){S=C;break}}return S},y(B,[{key:"mediaWidth",get:function(){return this.getDimensions().width*B.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*B.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var b=1;try{b=self.devicePixelRatio}catch(w){}return b}}]),B}();Q.default=j},"./src/controller/cmcd-controller.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return A});var V=D("./src/events.ts"),I=D("./src/types/cmcd.ts"),y=D("./src/utils/buffer-helper.ts"),j=D("./src/utils/logger.ts");function B(S,C){for(var d=0;d<C.length;d++){var o=C[d];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(S,o.key,o)}}function M(S,C,d){return C&&B(S.prototype,C),d&&B(S,d),S}function R(S,C){var d=typeof Symbol!="undefined"&&S[Symbol.iterator]||S["@@iterator"];if(d)return(d=d.call(S)).next.bind(d);if(Array.isArray(S)||(d=b(S))||C&&S&&typeof S.length=="number"){d&&(S=d);var o=0;return function(){return o>=S.length?{done:!0}:{done:!1,value:S[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(S,C){if(!S)return;if(typeof S=="string")return w(S,C);var d=Object.prototype.toString.call(S).slice(8,-1);if(d==="Object"&&S.constructor&&(d=S.constructor.name),d==="Map"||d==="Set")return Array.from(S);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return w(S,C)}function w(S,C){(C==null||C>S.length)&&(C=S.length);for(var d=0,o=new Array(C);d<C;d++)o[d]=S[d];return o}function O(){return O=Object.assign||function(S){for(var C=1;C<arguments.length;C++){var d=arguments[C];for(var o in d)Object.prototype.hasOwnProperty.call(d,o)&&(S[o]=d[o])}return S},O.apply(this,arguments)}var A=function(){function S(d){var o=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){o.initialized&&(o.starved=!0),o.buffering=!0},this.onPlaying=function(){o.initialized||(o.initialized=!0),o.buffering=!1},this.applyPlaylistData=function(T){try{o.apply(T,{ot:I.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(m){j.logger.warn("Could not generate manifest CMCD data.",m)}},this.applyFragmentData=function(T){try{var m=T.frag,p=o.hls.levels[m.level],_=o.getObjectType(m),v={d:m.duration*1e3,ot:_};(_===I.CMCDObjectType.VIDEO||_===I.CMCDObjectType.AUDIO||_==I.CMCDObjectType.MUXED)&&(v.br=p.bitrate/1e3,v.tb=o.getTopBandwidth(_),v.bl=o.getBufferLength(_)),o.apply(T,v)}catch(c){j.logger.warn("Could not generate segment CMCD data.",c)}},this.hls=d;var s=this.config=d.config,u=s.cmcd;u!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=u.sessionId||S.uuid(),this.cid=u.contentId,this.useHeaders=u.useHeaders===!0,this.registerListeners())}var C=S.prototype;return C.registerListeners=function(){var o=this.hls;o.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on(V.Events.BUFFER_CREATED,this.onBufferCreated,this)},C.unregisterListeners=function(){var o=this.hls;o.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off(V.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},C.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},C.onMediaAttached=function(o,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},C.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},C.onBufferCreated=function(o,s){var u,T;this.audioBuffer=(u=s.tracks.audio)===null||u===void 0?void 0:u.buffer,this.videoBuffer=(T=s.tracks.video)===null||T===void 0?void 0:T.buffer},C.createData=function(){var o;return{v:I.CMCDVersion,sf:I.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(o=this.media)===null||o===void 0?void 0:o.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},C.apply=function(o,s){s===void 0&&(s={}),O(s,this.createData());var u=s.ot===I.CMCDObjectType.INIT||s.ot===I.CMCDObjectType.VIDEO||s.ot===I.CMCDObjectType.MUXED;if(this.starved&&u&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var T=S.toHeaders(s);if(!Object.keys(T).length)return;o.headers||(o.headers={}),O(o.headers,T)}else{var m=S.toQuery(s);if(!m)return;o.url=S.appendQueryToUri(o.url,m)}},C.getObjectType=function(o){var s=o.type;return s==="subtitle"?I.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?I.CMCDObjectType.INIT:s==="audio"?I.CMCDObjectType.AUDIO:s==="main"?this.hls.audioTracks.length?I.CMCDObjectType.VIDEO:I.CMCDObjectType.MUXED:void 0},C.getTopBandwidth=function(o){for(var s=0,u=o===I.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,T=R(u),m;!(m=T()).done;){var p=m.value;p.bitrate>s&&(s=p.bitrate)}return s>0?s:NaN},C.getBufferLength=function(o){var s=this.hls.media,u=o===I.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!u||!s)return NaN;var T=y.BufferHelper.bufferInfo(u,s.currentTime,this.config.maxBufferHole);return T.len*1e3},C.createPlaylistLoader=function(){var o=this.config.pLoader,s=this.applyPlaylistData,u=o||this.config.loader;return function(){function T(p){this.loader=void 0,this.loader=new u(p)}var m=T.prototype;return m.destroy=function(){this.loader.destroy()},m.abort=function(){this.loader.abort()},m.load=function(_,v,c){s(_),this.loader.load(_,v,c)},M(T,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),T}()},C.createFragmentLoader=function(){var o=this.config.fLoader,s=this.applyFragmentData,u=o||this.config.loader;return function(){function T(p){this.loader=void 0,this.loader=new u(p)}var m=T.prototype;return m.destroy=function(){this.loader.destroy()},m.abort=function(){this.loader.abort()},m.load=function(_,v,c){s(_),this.loader.load(_,v,c)},M(T,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),T}()},S.uuid=function(){var o=URL.createObjectURL(new Blob),s=o.toString();return URL.revokeObjectURL(o),s.substr(s.lastIndexOf("/")+1)},S.serialize=function(o){for(var s=[],u=function(G){return!Number.isNaN(G)&&G!=null&&G!==""&&G!==!1},T=function(G){return Math.round(G)},m=function(G){return T(G/100)*100},p=function(G){return encodeURIComponent(G)},_={br:T,d:T,bl:m,dl:m,mtp:m,nor:p,rtp:m,tb:T},v=Object.keys(o||{}).sort(),c=R(v),h;!(h=c()).done;){var l=h.value,a=o[l];if(!u(a))continue;if(l==="v"&&a===1)continue;if(l=="pr"&&a===1)continue;var g=_[l];g&&(a=g(a));var f=typeof a,x=void 0;l==="ot"||l==="sf"||l==="st"?x=l+"="+a:f==="boolean"?x=l:f==="number"?x=l+"="+a:x=l+"="+JSON.stringify(a),s.push(x)}return s.join(",")},S.toHeaders=function(o){for(var s=Object.keys(o),u={},T=["Object","Request","Session","Status"],m=[{},{},{},{}],p={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},_=0,v=s;_<v.length;_++){var c=v[_],h=p[c]!=null?p[c]:1;m[h][c]=o[c]}for(var l=0;l<m.length;l++){var a=S.serialize(m[l]);a&&(u["CMCD-"+T[l]]=a)}return u},S.toQuery=function(o){return"CMCD="+encodeURIComponent(S.serialize(o))},S.appendQueryToUri=function(o,s){if(!s)return o;var u=o.includes("?")?"&":"?";return""+o+u+s},S}()},"./src/controller/eme-controller.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/events.ts"),I=D("./src/errors.ts"),y=D("./src/utils/logger.ts"),j=D("./src/utils/mediakeys-helper.ts");function B(A,S){for(var C=0;C<S.length;C++){var d=S[C];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(A,d.key,d)}}function M(A,S,C){return S&&B(A.prototype,S),C&&B(A,C),A}var R=3,b=function(S,C,d){var o={audioCapabilities:[],videoCapabilities:[]};return S.forEach(function(s){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:d.audioRobustness||""})}),C.forEach(function(s){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:d.videoRobustness||""})}),[o]},w=function(S,C,d,o){switch(S){case j.KeySystems.WIDEVINE:return b(C,d,o);default:throw new Error("Unknown key-system: "+S)}},O=function(){function A(C){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=C,this._config=C.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var S=A.prototype;return S.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},S._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)},S._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)},S.getLicenseServerUrl=function(d){switch(d){case j.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+d+'"')},S._attemptKeySystemAccess=function(d,o,s){var u=this,T=w(d,o,s,this._drmSystemOptions);y.logger.log("Requesting encrypted media key-system access");var m=this.requestMediaKeySystemAccess(d,T);this.mediaKeysPromise=m.then(function(p){return u._onMediaKeySystemAccessObtained(d,p)}),m.catch(function(p){y.logger.error('Failed to obtain key-system "'+d+'" access:',p)})},S._onMediaKeySystemAccessObtained=function(d,o){var s=this;y.logger.log('Access for key-system "'+d+'" obtained');var u={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:d};this._mediaKeysList.push(u);var T=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(m){return u.mediaKeys=m,y.logger.log('Media-keys created for key-system "'+d+'"'),s._onMediaKeysCreated(),m});return T.catch(function(m){y.logger.error("Failed to create media-keys:",m)}),T},S._onMediaKeysCreated=function(){var d=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),d._onNewMediaKeySession(o.mediaKeysSession))})},S._onNewMediaKeySession=function(d){var o=this;y.logger.log("New key-system session "+d.sessionId),d.addEventListener("message",function(s){o._onKeySessionMessage(d,s.message)},!1)},S._onKeySessionMessage=function(d,o){y.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(s){y.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),d.update(s)})},S.onMediaEncrypted=function(d){var o=this;if(y.logger.log('Media is encrypted using "'+d.initDataType+'" init data type'),!this.mediaKeysPromise){y.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 s=function(T){if(!o._media)return;o._attemptSetMediaKeys(T),o._generateRequestWithPreferredKeySession(d.initDataType,d.initData)};this.mediaKeysPromise.then(s).catch(s)},S._attemptSetMediaKeys=function(d){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var o=this._mediaKeysList[0];if(!o||!o.mediaKeys){y.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}y.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},S._generateRequestWithPreferredKeySession=function(d,o){var s=this,u=this._mediaKeysList[0];if(!u){y.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(u.mediaKeysSessionInitialized){y.logger.warn("Key-Session already initialized but requested again");return}var T=u.mediaKeysSession;if(!T){y.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(!o){y.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}y.logger.log('Generating key-session request for "'+d+'" init data type'),u.mediaKeysSessionInitialized=!0,T.generateRequest(d,o).then(function(){y.logger.debug("Key-session generation succeeded")}).catch(function(m){y.logger.error("Error generating key-session request:",m),s.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},S._createLicenseXhr=function(d,o,s){var u=new XMLHttpRequest;u.responseType="arraybuffer",u.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,u,d,o,s);var T=this._licenseXhrSetup;if(T)try{T.call(this.hls,u,d),T=void 0}catch(m){y.logger.error(m)}try{u.readyState||u.open("POST",d,!0),T&&T.call(this.hls,u,d)}catch(m){throw new Error("issue setting up KeySystem license XHR "+m)}return u},S._onLicenseRequestReadyStageChange=function(d,o,s,u){switch(d.readyState){case 4:if(d.status===200){this._requestLicenseFailureCount=0,y.logger.log("License request succeeded");var T=d.response,m=this._licenseResponseCallback;if(m)try{T=m.call(this.hls,d,o)}catch(_){y.logger.error(_)}u(T)}else{if(y.logger.error("License Request XHR failed ("+o+"). Status: "+d.status+" ("+d.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 p=R-this._requestLicenseFailureCount+1;y.logger.warn("Retrying license request, "+p+" attempts left"),this._requestLicense(s,u)}break}},S._generateLicenseRequestChallenge=function(d,o){switch(d.mediaKeySystemDomain){case j.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+d.mediaKeySystemDomain)},S._requestLicense=function(d,o){y.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){y.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 u=this.getLicenseServerUrl(s.mediaKeySystemDomain),T=this._createLicenseXhr(u,d,o);y.logger.log("Sending license request to URL: "+u);var m=this._generateLicenseRequestChallenge(s,d);T.send(m)}catch(p){y.logger.error("Failure requesting DRM license: "+p),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},S.onMediaAttached=function(d,o){if(!this._emeEnabled)return;var s=o.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)},S.onMediaDetached=function(){var d=this._media,o=this._mediaKeysList;if(!d)return;d.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(o.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return d.setMediaKeys(null)}).catch(function(){})},S.onManifestParsed=function(d,o){if(!this._emeEnabled)return;var s=o.levels.map(function(T){return T.audioCodec}).filter(function(T){return!!T}),u=o.levels.map(function(T){return T.videoCodec}).filter(function(T){return!!T});this._attemptKeySystemAccess(j.KeySystems.WIDEVINE,s,u)},M(A,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),A}();Q.default=O},"./src/controller/fps-controller.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/events.ts"),I=D("./src/utils/logger.ts"),y=function(){function j(M){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=M,this.registerListeners()}var B=j.prototype;return B.setStreamController=function(R){this.streamController=R},B.registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},B.unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching)},B.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},B.onMediaAttaching=function(R,b){var w=this.hls.config;if(w.capLevelOnFPSDrop){var O=b.media instanceof self.HTMLVideoElement?b.media:null;this.media=O,O&&typeof O.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),w.fpsDroppedMonitoringPeriod)}},B.checkFPS=function(R,b,w){var O=performance.now();if(b){if(this.lastTime){var A=O-this.lastTime,S=w-this.lastDroppedFrames,C=b-this.lastDecodedFrames,d=1e3*S/A,o=this.hls;if(o.trigger(V.Events.FPS_DROP,{currentDropped:S,currentDecoded:C,totalDroppedFrames:w}),d>0&&S>o.config.fpsDroppedMonitoringThreshold*C){var s=o.currentLevel;I.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=s)&&(s=s-1,o.trigger(V.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:o.currentLevel}),o.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=O,this.lastDroppedFrames=w,this.lastDecodedFrames=b}},B.checkFPSInterval=function(){var R=this.media;if(R)if(this.isVideoPlaybackQualityAvailable){var b=R.getVideoPlaybackQuality();this.checkFPS(R,b.totalVideoFrames,b.droppedVideoFrames)}else this.checkFPS(R,R.webkitDecodedFrameCount,R.webkitDroppedFrameCount)},j}();Q.default=y},"./src/controller/fragment-finders.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"findFragmentByPDT",function(){return y}),D.d(Q,"findFragmentByPTS",function(){return j}),D.d(Q,"fragmentWithinToleranceTest",function(){return B}),D.d(Q,"pdtWithinToleranceTest",function(){return M}),D.d(Q,"findFragWithCC",function(){return R});var V=D("./src/polyfills/number.ts"),I=D("./src/utils/binary-search.ts");function y(b,w,O){if(w===null||!Array.isArray(b)||!b.length||!Object(V.isFiniteNumber)(w))return null;var A=b[0].programDateTime;if(w<(A||0))return null;var S=b[b.length-1].endProgramDateTime;if(w>=(S||0))return null;O=O||0;for(var C=0;C<b.length;++C){var d=b[C];if(M(w,O,d))return d}return null}function j(b,w,O,A){O===void 0&&(O=0),A===void 0&&(A=0);var S=null;if(b?S=w[b.sn-w[0].sn+1]||null:O===0&&w[0].start===0&&(S=w[0]),S&&B(O,A,S)===0)return S;var C=I.default.search(w,B.bind(null,O,A));return C||S}function B(b,w,O){b===void 0&&(b=0),w===void 0&&(w=0);var A=Math.min(w,O.duration+(O.deltaPTS?O.deltaPTS:0));return O.start+O.duration-A<=b?1:O.start-A>b&&O.start?-1:0}function M(b,w,O){var A=Math.min(w,O.duration+(O.deltaPTS?O.deltaPTS:0))*1e3,S=O.endProgramDateTime||0;return S-A>b}function R(b,w){return I.default.search(b,function(O){return O.cc<w?1:O.cc>w?-1:0})}},"./src/controller/fragment-tracker.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"FragmentState",function(){return y}),D.d(Q,"FragmentTracker",function(){return j});var V=D("./src/events.ts"),I=D("./src/types/loader.ts"),y;(function(R){R.NOT_LOADED="NOT_LOADED",R.BACKTRACKED="BACKTRACKED",R.APPENDING="APPENDING",R.PARTIAL="PARTIAL",R.OK="OK"})(y||(y={}));var j=function(){function R(w){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=w,this._registerListeners()}var b=R.prototype;return b._registerListeners=function(){var O=this.hls;O.on(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),O.on(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),O.on(V.Events.FRAG_LOADED,this.onFragLoaded,this)},b._unregisterListeners=function(){var O=this.hls;O.off(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),O.off(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),O.off(V.Events.FRAG_LOADED,this.onFragLoaded,this)},b.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},b.getAppendedFrag=function(O,A){if(A===I.PlaylistLevelType.MAIN){var S=this.activeFragment,C=this.activeParts;if(!S)return null;if(C)for(var d=C.length;d--;){var o=C[d],s=o?o.end:S.appendedPTS;if(o.start<=O&&s!==void 0&&O<=s)return d>9&&(this.activeParts=C.slice(d-9)),o}else if(S.start<=O&&S.appendedPTS!==void 0&&O<=S.appendedPTS)return S}return this.getBufferedFrag(O,A)},b.getBufferedFrag=function(O,A){for(var S=this.fragments,C=Object.keys(S),d=C.length;d--;){var o=S[C[d]];if((o==null?void 0:o.body.type)===A&&o.buffered){var s=o.body;if(s.start<=O&&O<=s.end)return s}}return null},b.detectEvictedFragments=function(O,A,S){var C=this;Object.keys(this.fragments).forEach(function(d){var o=C.fragments[d];if(!o)return;if(!o.buffered){o.body.type===S&&C.removeFragment(o.body);return}var s=o.range[O];if(!s)return;s.time.some(function(u){var T=!C.isTimeBuffered(u.startPTS,u.endPTS,A);return T&&C.removeFragment(o.body),T})})},b.detectPartialFragments=function(O){var A=this,S=this.timeRanges,C=O.frag,d=O.part;if(!S||C.sn==="initSegment")return;var o=M(C),s=this.fragments[o];if(!s)return;Object.keys(S).forEach(function(u){var T=C.elementaryStreams[u];if(!T)return;var m=S[u],p=d!==null||T.partial===!0;s.range[u]=A.getBufferedTimes(C,d,p,m)}),s.backtrack=s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body)},b.fragBuffered=function(O){var A=M(O),S=this.fragments[A];S&&(S.backtrack=S.loaded=null,S.buffered=!0)},b.getBufferedTimes=function(O,A,S,C){for(var d={time:[],partial:S},o=A?A.start:O.start,s=A?A.end:O.end,u=O.minEndPTS||s,T=O.maxStartPTS||o,m=0;m<C.length;m++){var p=C.start(m)-this.bufferPadding,_=C.end(m)+this.bufferPadding;if(T>=p&&u<=_){d.time.push({startPTS:Math.max(o,C.start(m)),endPTS:Math.min(s,C.end(m))});break}else if(o<_&&s>p)d.partial=!0,d.time.push({startPTS:Math.max(o,C.start(m)),endPTS:Math.min(s,C.end(m))});else if(s<=p)break}return d},b.getPartialFragment=function(O){var A=null,S,C,d,o=0,s=this.bufferPadding,u=this.fragments;return Object.keys(u).forEach(function(T){var m=u[T];if(!m)return;B(m)&&(C=m.body.start-s,d=m.body.end+s,O>=C&&O<=d&&(S=Math.min(O-C,d-O),o<=S&&(A=m.body,o=S)))}),A},b.getState=function(O){var A=M(O),S=this.fragments[A];return S?S.buffered?B(S)?y.PARTIAL:y.OK:S.backtrack?y.BACKTRACKED:y.APPENDING:y.NOT_LOADED},b.backtrack=function(O,A){var S=M(O),C=this.fragments[S];if(!C||C.backtrack)return null;var d=C.backtrack=A||C.loaded;return C.loaded=null,d},b.getBacktrackData=function(O){var A=M(O),S=this.fragments[A];if(S){var C,d=S.backtrack;if(d!=null&&(C=d.payload)!==null&&C!==void 0&&C.byteLength)return d;this.removeFragment(O)}return null},b.isTimeBuffered=function(O,A,S){for(var C,d,o=0;o<S.length;o++){if(C=S.start(o)-this.bufferPadding,d=S.end(o)+this.bufferPadding,O>=C&&A<=d)return!0;if(A<=C)return!1}return!1},b.onFragLoaded=function(O,A){var S=A.frag,C=A.part;if(S.sn==="initSegment"||S.bitrateTest||C)return;var d=M(S);this.fragments[d]={body:S,loaded:A,backtrack:null,buffered:!1,range:Object.create(null)}},b.onBufferAppended=function(O,A){var S=this,C=A.frag,d=A.part,o=A.timeRanges;if(C.type===I.PlaylistLevelType.MAIN)if(this.activeFragment=C,d){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(d)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(u){var T=o[u];if(S.detectEvictedFragments(u,T),!d)for(var m=0;m<T.length;m++)C.appendedPTS=Math.max(T.end(m),C.appendedPTS||0)})},b.onFragBuffered=function(O,A){this.detectPartialFragments(A)},b.hasFragment=function(O){var A=M(O);return!!this.fragments[A]},b.removeFragmentsInRange=function(O,A,S){var C=this;Object.keys(this.fragments).forEach(function(d){var o=C.fragments[d];if(!o)return;if(o.buffered){var s=o.body;s.type===S&&s.start<A&&s.end>O&&C.removeFragment(s)}})},b.removeFragment=function(O){var A=M(O);O.stats.loaded=0,O.clearElementaryStreamInfo(),delete this.fragments[A]},b.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},R}();function B(R){var b,w;return R.buffered&&(((b=R.range.video)===null||b===void 0?void 0:b.partial)||((w=R.range.audio)===null||w===void 0?void 0:w.partial))}function M(R){return R.type+"_"+R.level+"_"+R.urlId+"_"+R.sn}},"./src/controller/gap-controller.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"STALL_MINIMUM_DURATION_MS",function(){return B}),D.d(Q,"MAX_START_GAP_JUMP",function(){return M}),D.d(Q,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return R}),D.d(Q,"SKIP_BUFFER_RANGE_START",function(){return b}),D.d(Q,"default",function(){return w});var V=D("./src/utils/buffer-helper.ts"),I=D("./src/errors.ts"),y=D("./src/events.ts"),j=D("./src/utils/logger.ts"),B=250,M=2,R=.1,b=.05,w=function(){function O(S,C,d,o){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=S,this.media=C,this.fragmentTracker=d,this.hls=o}var A=O.prototype;return A.destroy=function(){this.hls=this.fragmentTracker=this.media=null},A.poll=function(C){var d=this.config,o=this.media,s=this.stalled,u=o.currentTime,T=o.seeking,m=this.seeking&&!T,p=!this.seeking&&T;if(this.seeking=T,u!==C){if(this.moved=!0,s!==null){if(this.stallReported){var _=self.performance.now()-s;j.logger.warn("playback not stuck anymore @"+u+", after "+Math.round(_)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((p||m)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!V.BufferHelper.getBuffered(o).length)return;var v=V.BufferHelper.bufferInfo(o,u,0),c=v.len>0,h=v.nextStart||0;if(!c&&!h)return;if(T){var l=v.len>M,a=!h||h-u>M&&!this.fragmentTracker.getPartialFragment(u);if(l||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var g,f=Math.max(h,v.start||0)-u,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=x==null||((g=x.details)===null||g===void 0)?void 0:g.live,G=P?x.details.targetduration*2:M;if(f>0&&f<=G){this._trySkipBufferHole(null);return}}var X=self.performance.now();if(s===null){this.stalled=X;return}var ie=X-s;!T&&ie>=B&&this._reportStall(v.len);var z=V.BufferHelper.bufferInfo(o,u,d.maxBufferHole);this._tryFixBufferStall(z,ie)},A._tryFixBufferStall=function(C,d){var o=this.config,s=this.fragmentTracker,u=this.media,T=u.currentTime,m=s.getPartialFragment(T);if(m){var p=this._trySkipBufferHole(m);if(p)return}C.len>o.maxBufferHole&&d>o.highBufferWatchdogPeriod*1e3&&(j.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},A._reportStall=function(C){var d=this.hls,o=this.media,s=this.stallReported;s||(this.stallReported=!0,j.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+C+")"),d.trigger(y.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:C}))},A._trySkipBufferHole=function(C){for(var d=this.config,o=this.hls,s=this.media,u=s.currentTime,T=0,m=V.BufferHelper.getBuffered(s),p=0;p<m.length;p++){var _=m.start(p);if(u+d.maxBufferHole>=T&&u<_){var v=Math.max(_+b,s.currentTime+R);return j.logger.warn("skipping hole, adjusting currentTime from "+u+" to "+v),this.moved=!0,this.stalled=null,s.currentTime=v,C&&o.trigger(y.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+u+" to "+v,frag:C}),v}T=m.end(p)}return 0},A._tryNudgeBuffer=function(){var C=this.config,d=this.hls,o=this.media,s=o.currentTime,u=(this.nudgeRetry||0)+1;if(this.nudgeRetry=u,u<C.nudgeMaxRetry){var T=s+u*C.nudgeOffset;j.logger.warn("Nudging 'currentTime' from "+s+" to "+T),o.currentTime=T,d.trigger(y.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else j.logger.error("Playhead still not moving while enough data buffered @"+s+" after "+C.nudgeMaxRetry+" nudges"),d.trigger(y.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},O}()},"./src/controller/id3-track-controller.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/events.ts"),I=D("./src/utils/texttrack-utils.ts"),y=D("./src/demux/id3.ts"),j=.25,B=function(){function M(b){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=b,this._registerListeners()}var R=M.prototype;return R.destroy=function(){this._unregisterListeners()},R._registerListeners=function(){var w=this.hls;w.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),w.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),w.on(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),w.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},R._unregisterListeners=function(){var w=this.hls;w.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),w.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),w.off(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),w.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},R.onMediaAttached=function(w,O){this.media=O.media},R.onMediaDetaching=function(){if(!this.id3Track)return;Object(I.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},R.getID3Track=function(w){if(!this.media)return;for(var O=0;O<w.length;O++){var A=w[O];if(A.kind==="metadata"&&A.label==="id3")return Object(I.sendAddTrackEvent)(A,this.media),A}return this.media.addTextTrack("metadata","id3")},R.onFragParsingMetadata=function(w,O){if(!this.media)return;var A=O.frag,S=O.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var C=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,d=0;d<S.length;d++){var o=y.getID3Frames(S[d].data);if(o){var s=S[d].pts,u=d<S.length-1?S[d+1].pts:A.end,T=u-s;T<=0&&(u=s+j);for(var m=0;m<o.length;m++){var p=o[m];if(!y.isTimeStampFrame(p)){var _=new C(s,u,"");_.value=p,this.id3Track.addCue(_)}}}}},R.onBufferFlushing=function(w,O){var A=O.startOffset,S=O.endOffset,C=O.type;if(!C||C==="audio"){var d=this.id3Track;d&&Object(I.removeCuesInRange)(d,A,S)}},M}();Q.default=B},"./src/controller/latency-controller.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return M});var V=D("./src/errors.ts"),I=D("./src/events.ts"),y=D("./src/utils/logger.ts");function j(R,b){for(var w=0;w<b.length;w++){var O=b[w];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(R,O.key,O)}}function B(R,b,w){return b&&j(R.prototype,b),w&&j(R,w),R}var M=function(){function R(w){var O=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 O.timeupdate()},this.hls=w,this.config=w.config,this.registerListeners()}var b=R.prototype;return b.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},b.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)},b.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)},b.onMediaAttached=function(O,A){this.media=A.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},b.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},b.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},b.onLevelUpdated=function(O,A){var S=A.details;this.levelDetails=S,S.advanced&&this.timeupdate(),!S.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},b.onError=function(O,A){if(A.details!==V.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,y.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},b.timeupdate=function(){var O=this.media,A=this.levelDetails;if(!O||!A)return;this.currentTime=O.currentTime;var S=this.computeLatency();if(S===null)return;this._latency=S;var C=this.config,d=C.lowLatencyMode,o=C.maxLiveSyncPlaybackRate;if(!d||o===1)return;var s=this.targetLatency;if(s===null)return;var u=S-s,T=Math.min(this.maxLatency,s+A.targetduration),m=u<T;if(A.live&&m&&u>.05&&this.forwardBufferLength>1){var p=Math.min(2,Math.max(1,o)),_=Math.round(2/(1+Math.exp(-.75*u-this.edgeStalled))*20)/20;O.playbackRate=Math.min(p,Math.max(1,_))}else O.playbackRate!==1&&O.playbackRate!==0&&(O.playbackRate=1)},b.estimateLiveEdge=function(){var O=this.levelDetails;return O===null?null:O.edge+O.age},b.computeLatency=function(){var O=this.estimateLiveEdge();return O===null?null:O-this.currentTime},B(R,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var O=this.config,A=this.levelDetails;return O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:A?O.liveMaxLatencyDurationCount*A.targetduration:0}},{key:"targetLatency",get:function(){var O=this.levelDetails;if(O===null)return null;var A=O.holdBack,S=O.partHoldBack,C=O.targetduration,d=this.config,o=d.liveSyncDuration,s=d.liveSyncDurationCount,u=d.lowLatencyMode,T=this.hls.userConfig,m=u&&S||A;(T.liveSyncDuration||T.liveSyncDurationCount||m===0)&&(m=o!==void 0?o:s*C);var p=C,_=1;return m+Math.min(this.stallCount*_,p)}},{key:"liveSyncPosition",get:function(){var O=this.estimateLiveEdge(),A=this.targetLatency,S=this.levelDetails;if(O===null||A===null||S===null)return null;var C=S.edge,d=O-A-this.edgeStalled,o=C-S.totalduration,s=C-(this.config.lowLatencyMode&&S.partTarget||S.targetduration);return Math.min(Math.max(o,d),s)}},{key:"drift",get:function(){var O=this.levelDetails;return O===null?1:O.drift}},{key:"edgeStalled",get:function(){var O=this.levelDetails;if(O===null)return 0;var A=(this.config.lowLatencyMode&&O.partTarget||O.targetduration)*3;return Math.max(O.age-A,0)}},{key:"forwardBufferLength",get:function(){var O=this.media,A=this.levelDetails;if(!O||!A)return 0;var S=O.buffered.length;return S?O.buffered.end(S-1):A.edge-this.currentTime}}]),R}()},"./src/controller/level-controller.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return d});var V=D("./src/types/level.ts"),I=D("./src/events.ts"),y=D("./src/errors.ts"),j=D("./src/utils/codecs.ts"),B=D("./src/controller/level-helper.ts"),M=D("./src/controller/base-playlist-controller.ts"),R=D("./src/types/loader.ts");function b(){return b=Object.assign||function(o){for(var s=1;s<arguments.length;s++){var u=arguments[s];for(var T in u)Object.prototype.hasOwnProperty.call(u,T)&&(o[T]=u[T])}return o},b.apply(this,arguments)}function w(o,s){for(var u=0;u<s.length;u++){var T=s[u];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(o,T.key,T)}}function O(o,s,u){return s&&w(o.prototype,s),u&&w(o,u),o}function A(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,S(o,s)}function S(o,s){return S=Object.setPrototypeOf||function(T,m){return T.__proto__=m,T},S(o,s)}var C=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(o){A(s,o);function s(T){var m;return m=o.call(this,T,"[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 u=s.prototype;return u._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)},u._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)},u.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},u.startLoad=function(){var m=this._levels;m.forEach(function(p){p.loadError=0}),o.prototype.startLoad.call(this)},u.onManifestLoaded=function(m,p){var _=[],v=[],c=[],h,l={},a,g=!1,f=!1,x=!1;if(p.levels.forEach(function(ie){var z=ie.attrs;g=g||!!(ie.width&&ie.height),f=f||!!ie.videoCodec,x=x||!!ie.audioCodec,C&&ie.audioCodec&&ie.audioCodec.indexOf("mp4a.40.34")!==-1&&(ie.audioCodec=void 0);var F=ie.bitrate+"-"+ie.attrs.RESOLUTION+"-"+ie.attrs.CODECS;a=l[F],a?a.url.push(ie.url):(a=new V.Level(ie),l[F]=a,_.push(a)),z&&(z.AUDIO&&Object(B.addGroupId)(a,"audio",z.AUDIO),z.SUBTITLES&&Object(B.addGroupId)(a,"text",z.SUBTITLES))}),(g||f)&&x&&(_=_.filter(function(ie){var z=ie.videoCodec,F=ie.width,ne=ie.height;return!!z||!!(F&&ne)})),_=_.filter(function(ie){var z=ie.audioCodec,F=ie.videoCodec;return(!z||Object(j.isCodecSupportedInMp4)(z,"audio"))&&(!F||Object(j.isCodecSupportedInMp4)(F,"video"))}),p.audioTracks&&(v=p.audioTracks.filter(function(ie){return!ie.audioCodec||Object(j.isCodecSupportedInMp4)(ie.audioCodec,"audio")}),Object(B.assignTrackIdsByGroup)(v)),p.subtitles&&(c=p.subtitles,Object(B.assignTrackIdsByGroup)(c)),_.length>0){h=_[0].bitrate,_.sort(function(ie,z){return ie.bitrate-z.bitrate}),this._levels=_;for(var P=0;P<_.length;P++)if(_[P].bitrate===h){this._firstLevel=P,this.log("manifest loaded, "+_.length+" level(s) found, first bitrate: "+h);break}var G=x&&!f,X={levels:_,audioTracks:v,subtitleTracks:c,firstLevel:this._firstLevel,stats:p.stats,audio:x,video:f,altAudio:!G&&v.some(function(ie){return!!ie.url})};this.hls.trigger(I.Events.MANIFEST_PARSED,X),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(I.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:p.url,reason:"no level with compatible codecs found in manifest"})},u.onError=function(m,p){if(o.prototype.onError.call(this,m,p),p.fatal)return;var _=p.context,v=this._levels[this.currentLevelIndex];if(_&&(_.type===R.PlaylistContextType.AUDIO_TRACK&&v.audioGroupIds&&_.groupId===v.audioGroupIds[v.urlId]||_.type===R.PlaylistContextType.SUBTITLE_TRACK&&v.textGroupIds&&_.groupId===v.textGroupIds[v.urlId])){this.redundantFailover(this.currentLevelIndex);return}var c=!1,h=!0,l;switch(p.details){case y.ErrorDetails.FRAG_LOAD_ERROR:case y.ErrorDetails.FRAG_LOAD_TIMEOUT:case y.ErrorDetails.KEY_LOAD_ERROR:case y.ErrorDetails.KEY_LOAD_TIMEOUT:if(p.frag){var a=this._levels[p.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(l=p.frag.level)):l=p.frag.level}break;case y.ErrorDetails.LEVEL_LOAD_ERROR:case y.ErrorDetails.LEVEL_LOAD_TIMEOUT:_&&(_.deliveryDirectives&&(h=!1),l=_.level),c=!0;break;case y.ErrorDetails.REMUX_ALLOC_ERROR:l=p.level,c=!0;break}l!==void 0&&this.recoverLevel(p,l,c,h)},u.recoverLevel=function(m,p,_,v){var c=m.details,h=this._levels[p];if(h.loadError++,_){var l=this.retryLoadingOrFail(m);if(l)m.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(v){var a=h.url.length;if(a>1&&h.loadError<a)m.levelRetry=!0,this.redundantFailover(p);else if(this.manualLevelIndex===-1){var g=p===0?this._levels.length-1:p-1;this.currentLevelIndex!==g&&this._levels[g].loadError===0&&(this.warn(c+": switch to "+g),m.levelRetry=!0,this.hls.nextAutoLevel=g)}}},u.redundantFailover=function(m){var p=this._levels[m],_=p.url.length;if(_>1){var v=(p.urlId+1)%_;this.warn("Switching to redundant URL-id "+v),this._levels.forEach(function(c){c.urlId=v}),this.level=m}},u.onFragLoaded=function(m,p){var _=p.frag;if(_!==void 0&&_.type===R.PlaylistLevelType.MAIN){var v=this._levels[_.level];v!==void 0&&(v.fragmentError=0,v.loadError=0)}},u.onLevelLoaded=function(m,p){var _,v=p.level,c=p.details,h=this._levels[v];if(!h){var l;this.warn("Invalid level index "+v),(l=p.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(c.deltaUpdateFailed=!0);return}v===this.currentLevelIndex?(h.fragmentError===0&&(h.loadError=0,this.retryCount=0),this.playlistLoaded(v,p,h.details)):(_=p.deliveryDirectives)!==null&&_!==void 0&&_.skip&&(c.deltaUpdateFailed=!0)},u.onAudioTrackSwitched=function(m,p){var _=this.hls.levels[this.currentLevelIndex];if(!_)return;if(_.audioGroupIds){for(var v=-1,c=this.hls.audioTracks[p.id].groupId,h=0;h<_.audioGroupIds.length;h++)if(_.audioGroupIds[h]===c){v=h;break}v!==_.urlId&&(_.urlId=v,this.startLoad())}},u.loadPlaylist=function(m){var p=this.currentLevelIndex,_=this._levels[p];if(this.canLoad&&_&&_.url.length>0){var v=_.urlId,c=_.url[v];if(m)try{c=m.addDirectives(c)}catch(h){this.warn("Could not construct new URL with HLS Delivery Directives: "+h)}this.log("Attempt loading level index "+p+(m?" at sn "+m.msn+" part "+m.part:"")+" with URL-id "+v+" "+c),this.clearTimer(),this.hls.trigger(I.Events.LEVEL_LOADING,{url:c,level:p,id:v,deliveryDirectives:m||null})}},u.removeLevel=function(m,p){var _=function(h,l){return l!==p},v=this._levels.filter(function(c,h){return h!==m?!0:c.url.length>1&&p!==void 0?(c.url=c.url.filter(_),c.audioGroupIds&&(c.audioGroupIds=c.audioGroupIds.filter(_)),c.textGroupIds&&(c.textGroupIds=c.textGroupIds.filter(_)),c.urlId=0,!0):!1}).map(function(c,h){var l=c.details;return l!=null&&l.fragments&&l.fragments.forEach(function(a){a.level=h}),c});this._levels=v,this.hls.trigger(I.Events.LEVELS_UPDATED,{levels:v})},O(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(m){var p,_=this._levels;if(_.length===0)return;if(this.currentLevelIndex===m&&(p=_[m])!==null&&p!==void 0&&p.details)return;if(m<0||m>=_.length){var v=m<0;if(this.hls.trigger(I.Events.ERROR,{type:y.ErrorTypes.OTHER_ERROR,details:y.ErrorDetails.LEVEL_SWITCH_ERROR,level:m,fatal:v,reason:"invalid level idx"}),v)return;m=Math.min(m,_.length-1)}this.clearTimer();var c=this.currentLevelIndex,h=_[c],l=_[m];this.log("switching to level "+m+" from "+c),this.currentLevelIndex=m;var a=b({},l,{level:m,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete a._urlId,this.hls.trigger(I.Events.LEVEL_SWITCHING,a);var g=l.details;if(!g||g.live){var f=this.switchParams(l.uri,h==null?void 0:h.details);this.loadPlaylist(f)}}},{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)}}]),s}(M.default)},"./src/controller/level-helper.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"addGroupId",function(){return y}),D.d(Q,"assignTrackIdsByGroup",function(){return j}),D.d(Q,"updatePTS",function(){return B}),D.d(Q,"updateFragPTSDTS",function(){return R}),D.d(Q,"mergeDetails",function(){return b}),D.d(Q,"mapPartIntersection",function(){return w}),D.d(Q,"mapFragmentIntersection",function(){return O}),D.d(Q,"adjustSliding",function(){return A}),D.d(Q,"addSliding",function(){return S}),D.d(Q,"computeReloadInterval",function(){return C}),D.d(Q,"getFragmentWithSN",function(){return d}),D.d(Q,"getPartWith",function(){return o});var V=D("./src/polyfills/number.ts"),I=D("./src/utils/logger.ts");function y(s,u,T){switch(u){case"audio":s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds.push(T);break;case"text":s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds.push(T);break}}function j(s){var u={};s.forEach(function(T){var m=T.groupId||"";T.id=u[m]=u[m]||0,u[m]++})}function B(s,u,T){var m=s[u],p=s[T];M(m,p)}function M(s,u){var T=u.startPTS;if(Object(V.isFiniteNumber)(T)){var m=0,p;u.sn>s.sn?(m=T-s.start,p=s):(m=s.start-T,p=u),p.duration!==m&&(p.duration=m)}else if(u.sn>s.sn){var _=s.cc===u.cc;_&&s.minEndPTS?u.start=s.start+(s.minEndPTS-s.start):u.start=s.start+s.duration}else u.start=Math.max(s.start-u.duration,0)}function R(s,u,T,m,p,_){var v=m-T;v<=0&&(I.logger.warn("Fragment should have a positive duration",u),m=T+u.duration,_=p+u.duration);var c=T,h=m,l=u.startPTS,a=u.endPTS;if(Object(V.isFiniteNumber)(l)){var g=Math.abs(l-T);Object(V.isFiniteNumber)(u.deltaPTS)?u.deltaPTS=Math.max(g,u.deltaPTS):u.deltaPTS=g,c=Math.max(T,l),T=Math.min(T,l),p=Math.min(p,u.startDTS),h=Math.min(m,a),m=Math.max(m,a),_=Math.max(_,u.endDTS)}u.duration=m-T;var f=T-u.start;u.appendedPTS=m,u.start=u.startPTS=T,u.maxStartPTS=c,u.startDTS=p,u.endPTS=m,u.minEndPTS=h,u.endDTS=_;var x=u.sn;if(!s||x<s.startSN||x>s.endSN)return 0;var P,G=x-s.startSN,X=s.fragments;for(X[G]=u,P=G;P>0;P--)M(X[P],X[P-1]);for(P=G;P<X.length-1;P++)M(X[P],X[P+1]);return s.fragmentHint&&M(X[X.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,f}function b(s,u){for(var T=null,m=s.fragments,p=m.length-1;p>=0;p--){var _=m[p].initSegment;if(_){T=_;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var v=0,c;if(O(s,u,function(P,G){P.relurl&&(v=P.cc-G.cc),Object(V.isFiniteNumber)(P.startPTS)&&Object(V.isFiniteNumber)(P.endPTS)&&(G.start=G.startPTS=P.startPTS,G.startDTS=P.startDTS,G.appendedPTS=P.appendedPTS,G.maxStartPTS=P.maxStartPTS,G.endPTS=P.endPTS,G.endDTS=P.endDTS,G.minEndPTS=P.minEndPTS,G.duration=P.endPTS-P.startPTS,G.duration&&(c=G),u.PTSKnown=u.alignedSliding=!0),G.elementaryStreams=P.elementaryStreams,G.loader=P.loader,G.stats=P.stats,G.urlId=P.urlId,P.initSegment&&(G.initSegment=P.initSegment,T=P.initSegment)}),T){var h=u.fragmentHint?u.fragments.concat(u.fragmentHint):u.fragments;h.forEach(function(P){var G;(!P.initSegment||P.initSegment.relurl===((G=T)===null||G===void 0?void 0:G.relurl))&&(P.initSegment=T)})}if(u.skippedSegments&&(u.deltaUpdateFailed=u.fragments.some(function(P){return!P}),u.deltaUpdateFailed)){I.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var l=u.skippedSegments;l--;)u.fragments.shift();u.startSN=u.fragments[0].sn,u.startCC=u.fragments[0].cc}var a=u.fragments;if(v){I.logger.warn("discontinuity sliding from playlist, take drift into account");for(var g=0;g<a.length;g++)a[g].cc+=v}u.skippedSegments&&(u.startCC=u.fragments[0].cc),w(s.partList,u.partList,function(P,G){G.elementaryStreams=P.elementaryStreams,G.stats=P.stats}),c?R(u,c,c.startPTS,c.endPTS,c.startDTS,c.endDTS):A(s,u),a.length&&(u.totalduration=u.edge-a[0].start),u.driftStartTime=s.driftStartTime,u.driftStart=s.driftStart;var f=u.advancedDateTime;if(u.advanced&&f){var x=u.edge;u.driftStart||(u.driftStartTime=f,u.driftStart=x),u.driftEndTime=f,u.driftEnd=x}else u.driftEndTime=s.driftEndTime,u.driftEnd=s.driftEnd,u.advancedDateTime=s.advancedDateTime}function w(s,u,T){if(s&&u)for(var m=0,p=0,_=s.length;p<=_;p++){var v=s[p],c=u[p+m];v&&c&&v.index===c.index&&v.fragment.sn===c.fragment.sn?T(v,c):m--}}function O(s,u,T){for(var m=u.skippedSegments,p=Math.max(s.startSN,u.startSN)-u.startSN,_=(s.fragmentHint?1:0)+(m?u.endSN:Math.min(s.endSN,u.endSN))-u.startSN,v=u.startSN-s.startSN,c=u.fragmentHint?u.fragments.concat(u.fragmentHint):u.fragments,h=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,l=p;l<=_;l++){var a=h[v+l],g=c[l];m&&!g&&l<m&&(g=u.fragments[l]=a),a&&g&&T(a,g)}}function A(s,u){var T=u.startSN+u.skippedSegments-s.startSN,m=s.fragments;if(T<0||T>=m.length)return;S(u,m[T].start)}function S(s,u){if(u){for(var T=s.fragments,m=s.skippedSegments;m<T.length;m++)T[m].start+=u;s.fragmentHint&&(s.fragmentHint.start+=u)}}function C(s,u){var T=1e3*s.levelTargetDuration,m=T/2,p=s.age,_=p>0&&p<T*3,v=u.loading.end-u.loading.start,c,h=s.availabilityDelay;if(s.updated===!1)if(_){var l=333*s.misses;c=Math.max(Math.min(m,v*2),l),s.availabilityDelay=(s.availabilityDelay||0)+c}else c=m;else _?(h=Math.min(h||T/2,p),s.availabilityDelay=h,c=h+T-p):c=T-v;return Math.round(c)}function d(s,u,T){if(!s||!s.details)return null;var m=s.details,p=m.fragments[u-m.startSN];return p||(p=m.fragmentHint,p&&p.sn===u?p:u<m.startSN&&T&&T.sn===u?T:null)}function o(s,u,T){if(!s||!s.details)return null;var m=s.details.partList;if(m)for(var p=m.length;p--;){var _=m[p];if(_.index===T&&_.fragment.sn===u)return _}return null}},"./src/controller/stream-controller.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return m});var V=D("./src/polyfills/number.ts"),I=D("./src/controller/base-stream-controller.ts"),y=D("./src/is-supported.ts"),j=D("./src/events.ts"),B=D("./src/utils/buffer-helper.ts"),M=D("./src/controller/fragment-tracker.ts"),R=D("./src/types/loader.ts"),b=D("./src/loader/fragment.ts"),w=D("./src/demux/transmuxer-interface.ts"),O=D("./src/types/transmuxer.ts"),A=D("./src/controller/gap-controller.ts"),S=D("./src/errors.ts"),C=D("./src/utils/logger.ts");function d(p,_){for(var v=0;v<_.length;v++){var c=_[v];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(p,c.key,c)}}function o(p,_,v){return _&&d(p.prototype,_),v&&d(p,v),p}function s(p,_){p.prototype=Object.create(_.prototype),p.prototype.constructor=p,u(p,_)}function u(p,_){return u=Object.setPrototypeOf||function(c,h){return c.__proto__=h,c},u(p,_)}var T=100,m=function(p){s(_,p);function _(c,h){var l;return l=p.call(this,c,h,"[stream-controller]")||this,l.audioCodecSwap=!1,l.gapController=null,l.level=-1,l._forceStartLoad=!1,l.altAudio=!1,l.audioOnly=!1,l.fragPlaying=null,l.onvplaying=null,l.onvseeked=null,l.fragLastKbps=0,l.stalled=!1,l.couldBacktrack=!1,l.audioCodecSwitch=!1,l.videoBuffer=null,l._registerListeners(),l}var v=_.prototype;return v._registerListeners=function(){var h=this.hls;h.on(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.on(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.on(j.Events.LEVEL_LOADING,this.onLevelLoading,this),h.on(j.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(j.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),h.on(j.Events.ERROR,this.onError,this),h.on(j.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.on(j.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),h.on(j.Events.BUFFER_CREATED,this.onBufferCreated,this),h.on(j.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.on(j.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),h.on(j.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v._unregisterListeners=function(){var h=this.hls;h.off(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.off(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.off(j.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(j.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),h.off(j.Events.ERROR,this.onError,this),h.off(j.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.off(j.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),h.off(j.Events.BUFFER_CREATED,this.onBufferCreated,this),h.off(j.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.off(j.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),h.off(j.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},v.startLoad=function(h){if(this.levels){var l=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(T),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var g=a.startLevel;g===-1&&(a.config.testBandwidth?(g=0,this.bitrateTest=!0):g=a.nextAutoLevel),this.level=a.nextLoadLevel=g,this.loadedmetadata=!1}l>0&&h===-1&&(this.log("Override startPosition with lastCurrentTime @"+l.toFixed(3)),h=l),this.state=I.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=h,this.tick()}else this._forceStartLoad=!0,this.state=I.State.STOPPED},v.stopLoad=function(){this._forceStartLoad=!1,p.prototype.stopLoad.call(this)},v.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_LEVEL:{var h,l=this.levels,a=this.level,g=l==null||((h=l[a])===null||h===void 0)?void 0:h.details;if(g&&(!g.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(g))break;this.state=I.State.IDLE;break}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var f,x=self.performance.now(),P=this.retryDate;(!P||x>=P||(f=this.media)!==null&&f!==void 0&&f.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=I.State.IDLE)}break;default:break}this.onTickEnd()},v.onTickEnd=function(){p.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},v.doTickIdle=function(){var h,l,a=this.hls,g=this.levelLastLoaded,f=this.levels,x=this.media,P=a.config,G=a.nextLoadLevel;if(g===null||!x&&(this.startFragRequested||!P.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!f||!f[G])return;var X=f[G];this.level=a.nextLoadLevel=G;var ie=X.details;if(!ie||this.state===I.State.WAITING_LEVEL||ie.live&&this.levelLastLoaded!==G){this.state=I.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:x,R.PlaylistLevelType.MAIN);if(z===null)return;var F=z.len,ne=this.getMaxBufferLength(X.maxBitrate);if(F>=ne)return;if(this._streamEnded(z,ie)){var ce={};this.altAudio&&(ce.type="video"),this.hls.trigger(j.Events.BUFFER_EOS,ce),this.state=I.State.ENDED;return}var ge=z.end,be=this.getNextFragment(ge,ie);if(this.couldBacktrack&&!this.fragPrevious&&be&&be.sn!=="initSegment"){var Ie=be.sn-ie.startSN;Ie>1&&(be=ie.fragments[Ie-1],this.fragmentTracker.removeFragment(be))}if(be&&this.fragmentTracker.getState(be)===M.FragmentState.OK&&this.nextLoadPosition>ge){var Te=this.audioOnly&&!this.altAudio?b.ElementaryStreamTypes.AUDIO:b.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(x,Te,R.PlaylistLevelType.MAIN),be=this.getNextFragment(this.nextLoadPosition,ie)}if(!be)return;be.initSegment&&!be.initSegment.data&&!this.bitrateTest&&(be=be.initSegment),((h=be.decryptdata)===null||h===void 0?void 0:h.keyFormat)==="identity"&&!((l=be.decryptdata)!==null&&l!==void 0&&l.key)?this.loadKey(be,ie):this.loadFragment(be,ie,ge)},v.loadFragment=function(h,l,a){var g,f=this.fragmentTracker.getState(h);if(this.fragCurrent=h,f===M.FragmentState.BACKTRACKED){var x=this.fragmentTracker.getBacktrackData(h);if(x){this._handleFragmentLoadProgress(x),this._handleFragmentLoadComplete(x);return}else f=M.FragmentState.NOT_LOADED}f===M.FragmentState.NOT_LOADED||f===M.FragmentState.PARTIAL?h.sn==="initSegment"?this._loadInitSegment(h):this.bitrateTest?(h.bitrateTest=!0,this.log("Fragment "+h.sn+" of level "+h.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(h)):(this.startFragRequested=!0,p.prototype.loadFragment.call(this,h,l,a)):f===M.FragmentState.APPENDING?this.reduceMaxBufferLength(h.duration)&&this.fragmentTracker.removeFragment(h):((g=this.media)===null||g===void 0?void 0:g.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},v.getAppendedFrag=function(h){var l=this.fragmentTracker.getAppendedFrag(h,R.PlaylistLevelType.MAIN);return l&&"fragment"in l?l.fragment:l},v.getBufferedFrag=function(h){return this.fragmentTracker.getBufferedFrag(h,R.PlaylistLevelType.MAIN)},v.followingBufferedFrag=function(h){return h?this.getBufferedFrag(h.end+.5):null},v.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},v.nextLevelSwitch=function(){var h=this.levels,l=this.media;if(l!=null&&l.readyState){var a,g=this.getAppendedFrag(l.currentTime);if(g&&g.start>1&&this.flushMainBuffer(0,g.start-1),!l.paused&&h){var f=this.hls.nextLoadLevel,x=h[f],P=this.fragLastKbps;P&&this.fragCurrent?a=this.fragCurrent.duration*x.maxBitrate/(1e3*P)+1:a=0}else a=0;var G=this.getBufferedFrag(l.currentTime+a);if(G){var X=this.followingBufferedFrag(G);if(X){this.abortCurrentFrag();var ie=X.maxStartPTS?X.maxStartPTS:X.start,z=X.duration,F=Math.max(G.end,ie+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},v.abortCurrentFrag=function(){var h=this.fragCurrent;this.fragCurrent=null,h!=null&&h.loader&&h.loader.abort(),this.state===I.State.KEY_LOADING&&(this.state=I.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},v.flushMainBuffer=function(h,l){p.prototype.flushMainBuffer.call(this,h,l,this.altAudio?"video":null)},v.onMediaAttached=function(h,l){p.prototype.onMediaAttached.call(this,h,l);var a=l.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new A.default(this.config,a,this.fragmentTracker,this.hls)},v.onMediaDetaching=function(){var h=this.media;h&&(h.removeEventListener("playing",this.onvplaying),h.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),p.prototype.onMediaDetaching.call(this)},v.onMediaPlaying=function(){this.tick()},v.onMediaSeeked=function(){var h=this.media,l=h?h.currentTime:null;Object(V.isFiniteNumber)(l)&&this.log("Media seeked to "+l.toFixed(3)),this.tick()},v.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(j.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},v.onManifestParsed=function(h,l){var a=!1,g=!1,f;l.levels.forEach(function(x){f=x.audioCodec,f&&(f.indexOf("mp4a.40.2")!==-1&&(a=!0),f.indexOf("mp4a.40.5")!==-1&&(g=!0))}),this.audioCodecSwitch=a&&g&&!Object(y.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=l.levels,this.startFragRequested=!1},v.onLevelLoading=function(h,l){var a=this.levels;if(!a||this.state!==I.State.IDLE)return;var g=a[l.level];(!g.details||g.details.live&&this.levelLastLoaded!==l.level||this.waitForCdnTuneIn(g.details))&&(this.state=I.State.WAITING_LEVEL)},v.onLevelLoaded=function(h,l){var a,g=this.levels,f=l.level,x=l.details,P=x.totalduration;if(!g){this.warn("Levels were reset while loading level "+f);return}this.log("Level "+f+" loaded ["+x.startSN+","+x.endSN+"], cc ["+x.startCC+", "+x.endCC+"] duration:"+P);var G=this.fragCurrent;G&&(this.state===I.State.FRAG_LOADING||this.state===I.State.FRAG_LOADING_WAITING_RETRY)&&(G.level!==l.level&&G.loader&&(this.state=I.State.IDLE,G.loader.abort()));var X=g[f],ie=0;if(x.live||(a=X.details)!==null&&a!==void 0&&a.live){if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed)return;ie=this.alignPlaylists(x,X.details)}if(X.details=x,this.levelLastLoaded=f,this.hls.trigger(j.Events.LEVEL_UPDATED,{details:x,level:f}),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,ie),this.tick()},v._handleFragmentLoadProgress=function(h){var l,a=h.frag,g=h.part,f=h.payload,x=this.levels;if(!x){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var P=x[a.level],G=P.details;if(!G){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var X=P.videoCodec,ie=G.PTSKnown||!G.live,z=(l=a.initSegment)===null||l===void 0?void 0:l.data,F=this._getAudioCodec(P),ne=this.transmuxer=this.transmuxer||new w.default(this.hls,R.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ce=g?g.index:-1,ge=ce!==-1,be=new O.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,f.byteLength,ce,ge),Ie=this.initPTS[a.cc];ne.push(f,z,F,X,a,g,G.totalduration,ie,be,Ie)},v.onAudioTrackSwitching=function(h,l){var a=this.altAudio,g=!!l.url,f=l.id;if(!g){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 P=this.hls;a&&P.trigger(j.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(j.Events.AUDIO_TRACK_SWITCHED,{id:f})}},v.onAudioTrackSwitched=function(h,l){var a=l.id,g=!!this.hls.audioTracks[a].url;if(g){var f=this.videoBuffer;f&&this.mediaBuffer!==f&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=f)}this.altAudio=g,this.tick()},v.onBufferCreated=function(h,l){var a=l.tracks,g,f,x=!1;for(var P in a){var G=a[P];if(G.id==="main"){if(f=P,g=G,P==="video"){var X=a[P];X&&(this.videoBuffer=X.buffer)}}else x=!0}x&&g?(this.log("Alternate track found, use "+f+".buffered to schedule main fragment loading"),this.mediaBuffer=g.buffer):this.mediaBuffer=this.media},v.onFragBuffered=function(h,l){var a=l.frag,g=l.part;if(a&&a.type!==R.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(g?" p: "+g.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===I.State.PARSED&&(this.state=I.State.IDLE);return}var f=g?g.stats:a.stats;this.fragLastKbps=Math.round(8*f.total/(f.buffering.end-f.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,g)},v.onError=function(h,l){switch(l.details){case S.ErrorDetails.FRAG_LOAD_ERROR:case S.ErrorDetails.FRAG_LOAD_TIMEOUT:case S.ErrorDetails.KEY_LOAD_ERROR:case S.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(R.PlaylistLevelType.MAIN,l);break;case S.ErrorDetails.LEVEL_LOAD_ERROR:case S.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==I.State.ERROR&&(l.fatal?(this.warn(""+l.details),this.state=I.State.ERROR):!l.levelRetry&&this.state===I.State.WAITING_LEVEL&&(this.state=I.State.IDLE));break;case S.ErrorDetails.BUFFER_FULL_ERROR:if(l.parent==="main"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var a=!0,g=this.getFwdBufferInfo(this.media,R.PlaylistLevelType.MAIN);g&&g.len>.5&&(a=!this.reduceMaxBufferLength(g.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},v.checkBuffer=function(){var h=this.media,l=this.gapController;if(!h||!l||!h.readyState)return;var a=B.BufferHelper.getBuffered(h);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):l.poll(this.lastCurrentTime),this.lastCurrentTime=h.currentTime},v.onFragLoadEmergencyAborted=function(){this.state=I.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},v.onBufferFlushed=function(h,l){var a=l.type;if(a!==b.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var g=(a===b.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(g,a,R.PlaylistLevelType.MAIN)}},v.onLevelsUpdated=function(h,l){this.levels=l.levels},v.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},v.seekToStartPos=function(){var h=this.media,l=h.currentTime,a=this.startPosition;if(a>=0&&l<a){if(h.seeking){C.logger.log("could not seek to "+a+", already seeking at "+l);return}var g=B.BufferHelper.getBuffered(h),f=g.length?g.start(0):0,x=f-a;x>0&&(x<this.config.maxBufferHole||x<this.config.maxFragLookUpTolerance)&&(C.logger.log("adjusting start position by "+x+" to match buffer start"),a+=x,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+l),h.currentTime=a}},v._getAudioCodec=function(h){var l=this.config.defaultAudioCodec||h.audioCodec;return this.audioCodecSwap&&l&&(this.log("Swapping audio codec"),l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),l},v._loadBitrateTestFrag=function(h){var l=this;this._doFragLoad(h).then(function(a){var g=l.hls;if(!a||g.nextLoadLevel||l.fragContextChanged(h))return;l.fragLoadError=0,l.state=I.State.IDLE,l.startFragRequested=!1,l.bitrateTest=!1;var f=h.stats;f.parsing.start=f.parsing.end=f.buffering.start=f.buffering.end=self.performance.now(),g.trigger(j.Events.FRAG_LOADED,a)})},v._handleTransmuxComplete=function(h){var l,a="main",g=this.hls,f=h.remuxResult,x=h.chunkMeta,P=this.getCurrentContext(x);if(!P){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 G=P.frag,X=P.part,ie=P.level,z=f.video,F=f.text,ne=f.id3,ce=f.initSegment,ge=this.altAudio?void 0:f.audio;if(this.fragContextChanged(G))return;if(this.state=I.State.PARSING,ce){ce.tracks&&(this._bufferInitSegment(ie,ce.tracks,G,x),g.trigger(j.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:a,tracks:ce.tracks}));var be=ce.initPTS,Ie=ce.timescale;Object(V.isFiniteNumber)(be)&&(this.initPTS[G.cc]=be,g.trigger(j.Events.INIT_PTS_FOUND,{frag:G,id:a,initPTS:be,timescale:Ie}))}if(z&&f.independent!==!1){if(ie.details){var Te=z.startPTS,De=z.endPTS,we=z.startDTS,Ae=z.endDTS;if(X)X.elementaryStreams[z.type]={startPTS:Te,endPTS:De,startDTS:we,endDTS:Ae};else if(z.firstKeyFrame&&z.independent&&(this.couldBacktrack=!0),z.dropped&&z.independent){var ve=this.getLoadPosition()+this.config.maxBufferHole;if(ve<Te){this.backtrack(G);return}G.setElementaryStreamInfo(z.type,G.start,De,G.start,Ae,!0)}G.setElementaryStreamInfo(z.type,Te,De,we,Ae),this.bufferFragmentData(z,G,X,x)}}else if(f.independent===!1){this.backtrack(G);return}if(ge){var W=ge.startPTS,L=ge.endPTS,k=ge.startDTS,H=ge.endDTS;X&&(X.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:W,endPTS:L,startDTS:k,endDTS:H}),G.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,W,L,k,H),this.bufferFragmentData(ge,G,X,x)}if(ne!=null&&(l=ne.samples)!==null&&l!==void 0&&l.length){var ee={frag:G,id:a,samples:ne.samples};g.trigger(j.Events.FRAG_PARSING_METADATA,ee)}if(F){var U={frag:G,id:a,samples:F.samples};g.trigger(j.Events.FRAG_PARSING_USERDATA,U)}},v._bufferInitSegment=function(h,l,a,g){var f=this;if(this.state!==I.State.PARSING)return;this.audioOnly=!!l.audio&&!l.video,this.altAudio&&!this.audioOnly&&delete l.audio;var x=l.audio,P=l.video,G=l.audiovideo;if(x){var X=h.audioCodec,ie=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(X&&(X.indexOf("mp4a.40.5")!==-1?X="mp4a.40.2":X="mp4a.40.5"),x.metadata.channelCount!==1&&ie.indexOf("firefox")===-1&&(X="mp4a.40.5")),ie.indexOf("android")!==-1&&x.container!=="audio/mpeg"&&(X="mp4a.40.2",this.log("Android: force audio codec to "+X)),h.audioCodec&&h.audioCodec!==X&&this.log('Swapping manifest audio codec "'+h.audioCodec+'" for "'+X+'"'),x.levelCodec=X,x.id="main",this.log("Init audio buffer, container:"+x.container+", codecs[selected/level/parsed]=["+(X||"")+"/"+(h.audioCodec||"")+"/"+x.codec+"]")}P&&(P.levelCodec=h.videoCodec,P.id="main",this.log("Init video buffer, container:"+P.container+", codecs[level/parsed]=["+(h.videoCodec||"")+"/"+P.codec+"]")),G&&this.log("Init audiovideo buffer, container:"+G.container+", codecs[level/parsed]=["+(h.attrs.CODECS||"")+"/"+G.codec+"]"),this.hls.trigger(j.Events.BUFFER_CODECS,l),Object.keys(l).forEach(function(z){var F=l[z],ne=F.initSegment;ne!=null&&ne.byteLength&&f.hls.trigger(j.Events.BUFFER_APPENDING,{type:z,data:ne,frag:a,part:null,chunkMeta:g,parent:a.type})}),this.tick()},v.backtrack=function(h){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(h);var l=this.fragmentTracker.backtrack(h);this.fragPrevious=null,this.nextLoadPosition=h.start,l?this.resetFragmentLoading(h):this.state=I.State.BACKTRACKING},v.checkFragmentChanged=function(){var h=this.media,l=null;if(h&&h.readyState>1&&h.seeking===!1){var a=h.currentTime;if(B.BufferHelper.isBuffered(h,a)?l=this.getAppendedFrag(a):B.BufferHelper.isBuffered(h,a+.1)&&(l=this.getAppendedFrag(a+.1)),l){var g=this.fragPlaying,f=l.level;(!g||l.sn!==g.sn||g.level!==f||l.urlId!==g.urlId)&&(this.hls.trigger(j.Events.FRAG_CHANGED,{frag:l}),(!g||g.level!==f)&&this.hls.trigger(j.Events.LEVEL_SWITCHED,{level:f}),this.fragPlaying=l)}}},o(_,[{key:"nextLevel",get:function(){var h=this.nextBufferedFrag;return h?h.level:-1}},{key:"currentLevel",get:function(){var h=this.media;if(h){var l=this.getAppendedFrag(h.currentTime);if(l)return l.level}return-1}},{key:"nextBufferedFrag",get:function(){var h=this.media;if(h){var l=this.getAppendedFrag(h.currentTime);return this.followingBufferedFrag(l)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),_}(I.default)},"./src/controller/subtitle-stream-controller.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"SubtitleStreamController",function(){return s});var V=D("./src/events.ts"),I=D("./src/utils/logger.ts"),y=D("./src/utils/buffer-helper.ts"),j=D("./src/controller/fragment-finders.ts"),B=D("./src/utils/discontinuities.ts"),M=D("./src/controller/level-helper.ts"),R=D("./src/controller/fragment-tracker.ts"),b=D("./src/controller/base-stream-controller.ts"),w=D("./src/types/loader.ts"),O=D("./src/types/level.ts");function A(u,T){for(var m=0;m<T.length;m++){var p=T[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(u,p.key,p)}}function S(u,T,m){return T&&A(u.prototype,T),m&&A(u,m),u}function C(u,T){u.prototype=Object.create(T.prototype),u.prototype.constructor=u,d(u,T)}function d(u,T){return d=Object.setPrototypeOf||function(p,_){return p.__proto__=_,p},d(u,T)}var o=500,s=function(u){C(T,u);function T(p,_){var v;return v=u.call(this,p,_,"[subtitle-stream-controller]")||this,v.levels=[],v.currentTrackId=-1,v.tracksBuffered=[],v.mainDetails=null,v._registerListeners(),v}var m=T.prototype;return m.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},m._registerListeners=function(){var _=this.hls;_.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),_.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),_.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),_.on(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),_.on(V.Events.ERROR,this.onError,this),_.on(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),_.on(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),_.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),_.on(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),_.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},m._unregisterListeners=function(){var _=this.hls;_.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),_.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),_.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),_.off(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),_.off(V.Events.ERROR,this.onError,this),_.off(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),_.off(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),_.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),_.off(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),_.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},m.startLoad=function(){this.stopLoad(),this.state=b.State.IDLE,this.setInterval(o),this.tick()},m.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},m.onLevelLoaded=function(_,v){this.mainDetails=v.details},m.onSubtitleFragProcessed=function(_,v){var c=v.frag,h=v.success;if(this.fragPrevious=c,this.state=b.State.IDLE,!h)return;var l=this.tracksBuffered[this.currentTrackId];if(!l)return;for(var a,g=c.start,f=0;f<l.length;f++)if(g>=l[f].start&&g<=l[f].end){a=l[f];break}var x=c.start+c.duration;a?a.end=x:(a={start:g,end:x},l.push(a)),this.fragmentTracker.fragBuffered(c)},m.onBufferFlushing=function(_,v){var c=v.startOffset,h=v.endOffset;if(c===0&&h!==Number.POSITIVE_INFINITY){var l=this.currentTrackId,a=this.levels;if(!a.length||!a[l]||!a[l].details)return;var g=a[l].details,f=g.targetduration,x=h-f;if(x<=0)return;v.endOffsetSubtitles=Math.max(0,x),this.tracksBuffered.forEach(function(P){for(var G=0;G<P.length;){if(P[G].end<=x){P.shift();continue}else if(P[G].start<x)P[G].start=x;else break;G++}}),this.fragmentTracker.removeFragmentsInRange(c,x,w.PlaylistLevelType.SUBTITLE)}},m.onError=function(_,v){var c,h=v.frag;if(!h||h.type!==w.PlaylistLevelType.SUBTITLE)return;(c=this.fragCurrent)!==null&&c!==void 0&&c.loader&&this.fragCurrent.loader.abort(),this.state=b.State.IDLE},m.onSubtitleTracksUpdated=function(_,v){var c=this,h=v.subtitleTracks;this.tracksBuffered=[],this.levels=h.map(function(l){return new O.Level(l)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(l){c.tracksBuffered[l.id]=[]}),this.mediaBuffer=null},m.onSubtitleTrackSwitch=function(_,v){if(this.currentTrackId=v.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var c=this.levels[this.currentTrackId];c!=null&&c.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,c&&this.setInterval(o)},m.onSubtitleTrackLoaded=function(_,v){var c,h=v.details,l=v.id,a=this.currentTrackId,g=this.levels;if(!g.length)return;var f=g[a];if(l>=g.length||l!==a||!f)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,h.live||(c=f.details)!==null&&c!==void 0&&c.live){var x=this.mainDetails;if(h.deltaUpdateFailed||!x)return;var P=x.fragments[0];if(!f.details)h.hasProgramDateTime&&x.hasProgramDateTime?Object(B.alignMediaPlaylistByPDT)(h,x):P&&Object(M.addSliding)(h,P.start);else{var G=this.alignPlaylists(h,f.details);G===0&&P&&Object(M.addSliding)(h,P.start)}}if(f.details=h,this.levelLastLoaded=l,this.tick(),h.live&&!this.fragCurrent&&this.media&&this.state===b.State.IDLE){var X=Object(j.findFragmentByPTS)(null,h.fragments,this.media.currentTime,0);X||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0)}},m._handleFragmentLoadComplete=function(_){var v=_.frag,c=_.payload,h=v.decryptdata,l=this.hls;if(this.fragContextChanged(v))return;if(c&&c.byteLength>0&&h&&h.key&&h.iv&&h.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(c),h.key.buffer,h.iv.buffer).then(function(g){var f=performance.now();l.trigger(V.Events.FRAG_DECRYPTED,{frag:v,payload:g,stats:{tstart:a,tdecrypt:f}})})}},m.doTick=function(){if(!this.media){this.state=b.State.IDLE;return}if(this.state===b.State.IDLE){var _,v=this.currentTrackId,c=this.levels;if(!c.length||!c[v]||!c[v].details)return;var h=c[v].details,l=h.targetduration,a=this.config,g=this.media,f=y.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,g.currentTime-l,a.maxBufferHole),x=f.end,P=f.len,G=this.getMaxBufferLength()+l;if(P>G)return;console.assert(h,"Subtitle track details are defined on idle subtitle stream controller tick");var X=h.fragments,ie=X.length,z=h.edge,F,ne=this.fragPrevious;if(x<z){var ce=a.maxFragLookUpTolerance;ne&&h.hasProgramDateTime&&(F=Object(j.findFragmentByPDT)(X,ne.endProgramDateTime,ce)),F||(F=Object(j.findFragmentByPTS)(ne,X,x,ce),!F&&ne&&ne.start<X[0].start&&(F=X[0]))}else F=X[ie-1];(_=F)!==null&&_!==void 0&&_.encrypted?(I.logger.log("Loading key for "+F.sn),this.state=b.State.KEY_LOADING,this.hls.trigger(V.Events.KEY_LOADING,{frag:F})):F&&this.fragmentTracker.getState(F)===R.FragmentState.NOT_LOADED&&this.loadFragment(F,h,x)}},m.loadFragment=function(_,v,c){this.fragCurrent=_,u.prototype.loadFragment.call(this,_,v,c)},S(T,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),T}(b.default)},"./src/controller/subtitle-track-controller.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/events.ts"),I=D("./src/utils/texttrack-utils.ts"),y=D("./src/controller/base-playlist-controller.ts"),j=D("./src/types/loader.ts");function B(A,S){for(var C=0;C<S.length;C++){var d=S[C];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(A,d.key,d)}}function M(A,S,C){return S&&B(A.prototype,S),C&&B(A,C),A}function R(A,S){A.prototype=Object.create(S.prototype),A.prototype.constructor=A,b(A,S)}function b(A,S){return b=Object.setPrototypeOf||function(d,o){return d.__proto__=o,d},b(A,S)}var w=function(A){R(S,A);function S(d){var o;return o=A.call(this,d,"[subtitle-track-controller]")||this,o.media=null,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.selectDefaultTrack=!0,o.queuedDefaultTrack=-1,o.trackChangeListener=function(){return o.onTextTracksChanged()},o.asyncPollTrackChange=function(){return o.pollTrackChange(0)},o.useTextTrackPolling=!1,o.subtitlePollingInterval=-1,o.subtitleDisplay=!0,o.registerListeners(),o}var C=S.prototype;return C.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,A.prototype.destroy.call(this)},C.registerListeners=function(){var o=this.hls;o.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(V.Events.ERROR,this.onError,this)},C.unregisterListeners=function(){var o=this.hls;o.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(V.Events.ERROR,this.onError,this)},C.onMediaAttached=function(o,s){if(this.media=s.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},C.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},C.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var o=O(this.media.textTracks);o.forEach(function(s){Object(I.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null},C.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},C.onManifestParsed=function(o,s){this.tracks=s.subtitleTracks},C.onSubtitleTrackLoaded=function(o,s){var u=s.id,T=s.details,m=this.trackId,p=this.tracksInGroup[m];if(!p){this.warn("Invalid subtitle track id "+u);return}var _=p.details;p.details=s.details,this.log("subtitle track "+u+" loaded ["+T.startSN+"-"+T.endSN+"]"),u===this.trackId&&(this.retryCount=0,this.playlistLoaded(u,s,_))},C.onLevelLoading=function(o,s){this.switchLevel(s.level)},C.onLevelSwitching=function(o,s){this.switchLevel(s.level)},C.switchLevel=function(o){var s=this.hls.levels[o];if(!(s!=null&&s.textGroupIds))return;var u=s.textGroupIds[s.urlId];if(this.groupId!==u){var T=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,m=this.tracks.filter(function(v){return!u||v.groupId===u});this.tracksInGroup=m;var p=this.findTrackId(T==null?void 0:T.name)||this.findTrackId();this.groupId=u;var _={subtitleTracks:m};this.log("Updating subtitle tracks, "+m.length+' track(s) found in "'+u+'" group-id'),this.hls.trigger(V.Events.SUBTITLE_TRACKS_UPDATED,_),p!==-1&&this.setSubtitleTrack(p,T)}},C.findTrackId=function(o){for(var s=this.tracksInGroup,u=0;u<s.length;u++){var T=s[u];if((!this.selectDefaultTrack||T.default)&&(!o||o===T.name))return T.id}return-1},C.onError=function(o,s){if(A.prototype.onError.call(this,o,s),s.fatal||!s.context)return;s.context.type===j.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},C.loadPlaylist=function(o){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var u=s.id,T=s.groupId,m=s.url;if(o)try{m=o.addDirectives(m)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Loading subtitle playlist for id "+u),this.hls.trigger(V.Events.SUBTITLE_TRACK_LOADING,{url:m,id:u,groupId:T,deliveryDirectives:o||null})}},C.toggleTrackModes=function(o){var s=this,u=this.media,T=this.subtitleDisplay,m=this.trackId;if(!u)return;var p=O(u.textTracks),_=p.filter(function(h){return h.groupId===s.groupId});if(o===-1)[].slice.call(p).forEach(function(h){h.mode="disabled"});else{var v=_[m];v&&(v.mode="disabled")}var c=_[o];c&&(c.mode=T?"showing":"hidden")},C.setSubtitleTrack=function(o,s){var u,T=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(u=T[o])!==null&&u!==void 0&&u.details)||o<-1||o>=T.length)return;this.clearTimer();var m=T[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,m){var p=m.id,_=m.groupId,v=_===void 0?"":_,c=m.name,h=m.type,l=m.url;this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:v,name:c,type:h,url:l});var a=this.switchParams(m.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:o})},C.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,s=O(this.media.textTracks),u=0;u<s.length;u++)if(s[u].mode==="hidden")o=u;else if(s[u].mode==="showing"){o=u;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},M(S,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(o,s)}}]),S}(y.default);function O(A){for(var S=[],C=0;C<A.length;C++){var d=A[C];d.kind==="subtitles"&&d.label&&S.push(A[C])}return S}Q.default=w},"./src/controller/timeline-controller.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"TimelineController",function(){return O});var V=D("./src/polyfills/number.ts"),I=D("./src/events.ts"),y=D("./src/utils/cea-608-parser.ts"),j=D("./src/utils/output-filter.ts"),B=D("./src/utils/webvtt-parser.ts"),M=D("./src/utils/texttrack-utils.ts"),R=D("./src/utils/imsc1-ttml-parser.ts"),b=D("./src/types/loader.ts"),w=D("./src/utils/logger.ts"),O=function(){function d(s){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=C(),this.captionsProperties=void 0,this.hls=s,this.config=s.config,this.Cues=s.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 u=new j.default(this,"textTrack1"),T=new j.default(this,"textTrack2"),m=new j.default(this,"textTrack3"),p=new j.default(this,"textTrack4");this.cea608Parser1=new y.default(1,u,T),this.cea608Parser2=new y.default(3,m,p)}s.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),s.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),s.on(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),s.on(I.Events.FRAG_LOADING,this.onFragLoading,this),s.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),s.on(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),s.on(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.on(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),s.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=d.prototype;return o.destroy=function(){var u=this.hls;u.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),u.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.off(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.off(I.Events.FRAG_LOADING,this.onFragLoading,this),u.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),u.off(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),u.off(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.off(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),u.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(u,T,m,p,_){for(var v=!1,c=_.length;c--;){var h=_[c],l=S(h[0],h[1],T,m);if(l>=0&&(h[0]=Math.min(h[0],T),h[1]=Math.max(h[1],m),v=!0,l/(m-T)>.5))return}if(v||_.push([T,m]),this.config.renderTextTracksNatively){var a=this.captionsTracks[u];this.Cues.newCue(a,T,m,p)}else{var g=this.Cues.newCue(null,T,m,p);this.hls.trigger(I.Events.CUES_PARSED,{type:"captions",cues:g,track:u})}},o.onInitPtsFound=function(u,T){var m=this,p=T.frag,_=T.id,v=T.initPTS,c=T.timescale,h=this.unparsedVttFrags;_==="main"&&(this.initPTS[p.cc]=v,this.timescale[p.cc]=c),h.length&&(this.unparsedVttFrags=[],h.forEach(function(l){m.onFragLoaded(I.Events.FRAG_LOADED,l)}))},o.getExistingTrack=function(u){var T=this.media;if(T)for(var m=0;m<T.textTracks.length;m++){var p=T.textTracks[m];if(p[u])return p}return null},o.createCaptionsTrack=function(u){this.config.renderTextTracksNatively?this.createNativeTrack(u):this.createNonNativeTrack(u)},o.createNativeTrack=function(u){if(this.captionsTracks[u])return;var T=this.captionsProperties,m=this.captionsTracks,p=this.media,_=T[u],v=_.label,c=_.languageCode,h=this.getExistingTrack(u);if(h)m[u]=h,Object(M.clearCurrentCues)(m[u]),Object(M.sendAddTrackEvent)(m[u],p);else{var l=this.createTextTrack("captions",v,c);l&&(l[u]=!0,m[u]=l)}},o.createNonNativeTrack=function(u){if(this.nonNativeCaptionsTracks[u])return;var T=this.captionsProperties[u];if(!T)return;var m=T.label,p={_id:u,label:m,kind:"captions",default:T.media?!!T.media.default:!1,closedCaptions:T.media};this.nonNativeCaptionsTracks[u]=p,this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[p]})},o.createTextTrack=function(u,T,m){var p=this.media;return p?p.addTextTrack(u,T,m):void 0},o.onMediaAttaching=function(u,T){this.media=T.media,this._cleanTracks()},o.onMediaDetaching=function(){var u=this.captionsTracks;Object.keys(u).forEach(function(T){Object(M.clearCurrentCues)(u[T]),delete u[T]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=C(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var u=this.media;if(!u)return;var T=u.textTracks;if(T)for(var m=0;m<T.length;m++)Object(M.clearCurrentCues)(T[m])},o.onSubtitleTracksUpdated=function(u,T){var m=this;this.textTracks=[];var p=T.subtitleTracks||[],_=p.some(function(l){return l.textCodec===R.IMSC1_CODEC});if(this.config.enableWebVTT||_&&this.config.enableIMSC1){var v=this.tracks&&p&&this.tracks.length===p.length;if(this.tracks=p||[],this.config.renderTextTracksNatively){var c=this.media?this.media.textTracks:[];this.tracks.forEach(function(l,a){var g;if(a<c.length){for(var f=null,x=0;x<c.length;x++)if(A(c[x],l)){f=c[x];break}f&&(g=f)}g?Object(M.clearCurrentCues)(g):(g=m.createTextTrack("subtitles",l.name,l.lang),g&&(g.mode="disabled")),g&&(g.groupId=l.groupId,m.textTracks.push(g))})}else if(!v&&this.tracks&&this.tracks.length){var h=this.tracks.map(function(l){return{label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}});this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:h})}}},o.onManifestLoaded=function(u,T){var m=this;this.config.enableCEA708Captions&&T.captions&&T.captions.forEach(function(p){var _=/(?:CC|SERVICE)([1-4])/.exec(p.instreamId);if(!_)return;var v="textTrack"+_[1],c=m.captionsProperties[v];if(!c)return;c.label=p.name,p.lang&&(c.languageCode=p.lang),c.media=p})},o.onFragLoading=function(u,T){var m=this.cea608Parser1,p=this.cea608Parser2,_=this.lastSn,v=this.lastPartIndex;if(!this.enabled||!(m&&p))return;if(T.frag.type===b.PlaylistLevelType.MAIN){var c,h,l=T.frag.sn,a=(c=T==null||((h=T.part)===null||h===void 0)?void 0:h.index)!=null?c:-1;l===_+1||l===_&&a===v+1||(m.reset(),p.reset()),this.lastSn=l,this.lastPartIndex=a}},o.onFragLoaded=function(u,T){var m=T.frag,p=T.payload,_=this.initPTS,v=this.unparsedVttFrags;if(m.type===b.PlaylistLevelType.SUBTITLE)if(p.byteLength){if(!Object(V.isFiniteNumber)(_[m.cc])){v.push(T),_.length&&this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:m,error:new Error("Missing initial subtitle PTS")});return}var c=m.decryptdata;if(c==null||c.key==null||c.method!=="AES-128"){var h=this.tracks[m.level],l=this.vttCCs;l[m.cc]||(l[m.cc]={start:m.start,prevCC:this.prevCC,new:!0},this.prevCC=m.cc),h&&h.textCodec===R.IMSC1_CODEC?this._parseIMSC1(m,p):this._parseVTTs(m,p,l)}}else this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:m,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(u,T){var m=this,p=this.hls;Object(R.parseIMSC1)(T,this.initPTS[u.cc],this.timescale[u.cc],function(_){m._appendCues(_,u.level),p.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:u})},function(_){w.logger.log("Failed to parse IMSC1: "+_),p.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:u,error:_})})},o._parseVTTs=function(u,T,m){var p=this,_=this.hls;Object(B.parseWebVTT)(T,this.initPTS[u.cc],this.timescale[u.cc],m,u.cc,u.start,function(v){p._appendCues(v,u.level),_.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:u})},function(v){p._fallbackToIMSC1(u,T),w.logger.log("Failed to parse VTT cue: "+v),_.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:u,error:v})})},o._fallbackToIMSC1=function(u,T){var m=this,p=this.tracks[u.level];p.textCodec||Object(R.parseIMSC1)(T,this.initPTS[u.cc],this.timescale[u.cc],function(){p.textCodec=R.IMSC1_CODEC,m._parseIMSC1(u,T)},function(){p.textCodec="wvtt"})},o._appendCues=function(u,T){var m=this.hls;if(this.config.renderTextTracksNatively){var p=this.textTracks[T];if(p.mode==="disabled")return;u.forEach(function(c){return Object(M.addCueToTrack)(p,c)})}else{var _=this.tracks[T],v=_.default?"default":"subtitles"+T;m.trigger(I.Events.CUES_PARSED,{type:"subtitles",cues:u,track:v})}},o.onFragDecrypted=function(u,T){var m=T.frag;if(m.type===b.PlaylistLevelType.SUBTITLE){if(!Object(V.isFiniteNumber)(this.initPTS[m.cc])){this.unparsedVttFrags.push(T);return}this.onFragLoaded(I.Events.FRAG_LOADED,T)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(u,T){var m=this.cea608Parser1,p=this.cea608Parser2;if(!this.enabled||!(m&&p))return;for(var _=0;_<T.samples.length;_++){var v=T.samples[_].bytes;if(v){var c=this.extractCea608Data(v);m.addData(T.samples[_].pts,c[0]),p.addData(T.samples[_].pts,c[1])}}},o.onBufferFlushing=function(u,T){var m=T.startOffset,p=T.endOffset,_=T.endOffsetSubtitles,v=T.type,c=this.media;if(!c||c.currentTime<p)return;if(!v||v==="video"){var h=this.captionsTracks;Object.keys(h).forEach(function(a){return Object(M.removeCuesInRange)(h[a],m,p)})}if(this.config.renderTextTracksNatively&&(m===0&&_!==void 0)){var l=this.textTracks;Object.keys(l).forEach(function(a){return Object(M.removeCuesInRange)(l[a],m,_)})}},o.extractCea608Data=function(u){for(var T=u[0]&31,m=2,p=[[],[]],_=0;_<T;_++){var v=u[m++],c=127&u[m++],h=127&u[m++],l=(4&v)!==0,a=3&v;if(c===0&&h===0)continue;l&&((a===0||a===1)&&(p[a].push(c),p[a].push(h)))}return p},d}();function A(d,o){return d&&d.label===o.name&&!(d.textTrack1||d.textTrack2)}function S(d,o,s,u){return Math.min(o,u)-Math.max(d,s)}function C(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return V});var V=function(){function I(j,B){this.subtle=void 0,this.aesIV=void 0,this.subtle=j,this.aesIV=B}var y=I.prototype;return y.decrypt=function(B,M){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},M,B)},I}()},"./src/crypt/aes-decryptor.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"removePadding",function(){return I}),D.d(Q,"default",function(){return y});var V=D("./src/utils/typed-array.ts");function I(j){var B=j.byteLength,M=B&&new DataView(j.buffer).getUint8(B-1);return M?Object(V.sliceUint8)(j,0,B-M):j}var y=function(){function j(){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 B=j.prototype;return B.uint8ArrayToUint32Array_=function(R){for(var b=new DataView(R),w=new Uint32Array(4),O=0;O<4;O++)w[O]=b.getUint32(O*4);return w},B.initTable=function(){var R=this.sBox,b=this.invSBox,w=this.subMix,O=w[0],A=w[1],S=w[2],C=w[3],d=this.invSubMix,o=d[0],s=d[1],u=d[2],T=d[3],m=new Uint32Array(256),p=0,_=0,v=0;for(v=0;v<256;v++)v<128?m[v]=v<<1:m[v]=v<<1^283;for(v=0;v<256;v++){var c=_^_<<1^_<<2^_<<3^_<<4;c=c>>>8^c&255^99,R[p]=c,b[c]=p;var h=m[p],l=m[h],a=m[l],g=m[c]*257^c*16843008;O[p]=g<<24|g>>>8,A[p]=g<<16|g>>>16,S[p]=g<<8|g>>>24,C[p]=g,g=a*16843009^l*65537^h*257^p*16843008,o[c]=g<<24|g>>>8,s[c]=g<<16|g>>>16,u[c]=g<<8|g>>>24,T[c]=g,p?(p=h^m[m[m[a^h]]],_^=m[m[_]]):p=_=1}},B.expandKey=function(R){for(var b=this.uint8ArrayToUint32Array_(R),w=!0,O=0;O<b.length&&w;)w=b[O]===this.key[O],O++;if(w)return;this.key=b;var A=this.keySize=b.length;if(A!==4&&A!==6&&A!==8)throw new Error("Invalid aes key size="+A);var S=this.ksRows=(A+6+1)*4,C,d,o=this.keySchedule=new Uint32Array(S),s=this.invKeySchedule=new Uint32Array(S),u=this.sBox,T=this.rcon,m=this.invSubMix,p=m[0],_=m[1],v=m[2],c=m[3],h,l;for(C=0;C<S;C++){if(C<A){h=o[C]=b[C];continue}l=h,C%A===0?(l=l<<8|l>>>24,l=u[l>>>24]<<24|u[l>>>16&255]<<16|u[l>>>8&255]<<8|u[l&255],l^=T[C/A|0]<<24):A>6&&C%A===4&&(l=u[l>>>24]<<24|u[l>>>16&255]<<16|u[l>>>8&255]<<8|u[l&255]),o[C]=h=(o[C-A]^l)>>>0}for(d=0;d<S;d++)C=S-d,d&3?l=o[C]:l=o[C-4],d<4||C<=4?s[d]=l:s[d]=p[u[l>>>24]]^_[u[l>>>16&255]]^v[u[l>>>8&255]]^c[u[l&255]],s[d]=s[d]>>>0},B.networkToHostOrderSwap=function(R){return R<<24|(R&65280)<<8|(R&16711680)>>8|R>>>24},B.decrypt=function(R,b,w){for(var O=this.keySize+6,A=this.invKeySchedule,S=this.invSBox,C=this.invSubMix,d=C[0],o=C[1],s=C[2],u=C[3],T=this.uint8ArrayToUint32Array_(w),m=T[0],p=T[1],_=T[2],v=T[3],c=new Int32Array(R),h=new Int32Array(c.length),l,a,g,f,x,P,G,X,ie,z,F,ne,ce,ge,be=this.networkToHostOrderSwap;b<c.length;){for(ie=be(c[b]),z=be(c[b+1]),F=be(c[b+2]),ne=be(c[b+3]),x=ie^A[0],P=ne^A[1],G=F^A[2],X=z^A[3],ce=4,ge=1;ge<O;ge++)l=d[x>>>24]^o[P>>16&255]^s[G>>8&255]^u[X&255]^A[ce],a=d[P>>>24]^o[G>>16&255]^s[X>>8&255]^u[x&255]^A[ce+1],g=d[G>>>24]^o[X>>16&255]^s[x>>8&255]^u[P&255]^A[ce+2],f=d[X>>>24]^o[x>>16&255]^s[P>>8&255]^u[G&255]^A[ce+3],x=l,P=a,G=g,X=f,ce=ce+4;l=S[x>>>24]<<24^S[P>>16&255]<<16^S[G>>8&255]<<8^S[X&255]^A[ce],a=S[P>>>24]<<24^S[G>>16&255]<<16^S[X>>8&255]<<8^S[x&255]^A[ce+1],g=S[G>>>24]<<24^S[X>>16&255]<<16^S[x>>8&255]<<8^S[P&255]^A[ce+2],f=S[X>>>24]<<24^S[x>>16&255]<<16^S[P>>8&255]<<8^S[G&255]^A[ce+3],h[b]=be(l^m),h[b+1]=be(f^p),h[b+2]=be(g^_),h[b+3]=be(a^v),m=ie,p=z,_=F,v=ne,b=b+4}return h.buffer},j}()},"./src/crypt/decrypter.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return b});var V=D("./src/crypt/aes-crypto.ts"),I=D("./src/crypt/fast-aes-key.ts"),y=D("./src/crypt/aes-decryptor.ts"),j=D("./src/utils/logger.ts"),B=D("./src/utils/mp4-tools.ts"),M=D("./src/utils/typed-array.ts"),R=16,b=function(){function w(A,S,C){var d=C===void 0?{}:C,o=d.removePKCS7Padding,s=o===void 0?!0:o;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=A,this.config=S,this.removePKCS7Padding=s,s)try{var u=self.crypto;u&&(this.subtle=u.subtle||u.webkitSubtle)}catch(T){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var O=w.prototype;return O.destroy=function(){this.observer=null},O.isSync=function(){return this.config.enableSoftwareAES},O.flush=function(){var S=this.currentResult;if(!S){this.reset();return}var C=new Uint8Array(S);return this.reset(),this.removePKCS7Padding?Object(y.removePadding)(C):C},O.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},O.decrypt=function(S,C,d,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(S),C,d);var s=this.flush();s&&o(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(S),C,d).then(o)},O.softwareDecrypt=function(S,C,d){var o=this.currentIV,s=this.currentResult,u=this.remainderData;this.logOnce("JS AES decrypt"),u&&(S=Object(B.appendUint8Array)(u,S),this.remainderData=null);var T=this.getValidChunk(S);if(!T.length)return null;o&&(d=o);var m=this.softwareDecrypter;m||(m=this.softwareDecrypter=new y.default),m.expandKey(C);var p=s;return this.currentResult=m.decrypt(T.buffer,0,d),this.currentIV=Object(M.sliceUint8)(T,-16).buffer,p||null},O.webCryptoDecrypt=function(S,C,d){var o=this,s=this.subtle;return(this.key!==C||!this.fastAesKey)&&(this.key=C,this.fastAesKey=new I.default(s,C)),this.fastAesKey.expandKey().then(function(u){if(!s)return Promise.reject(new Error("web crypto not initialized"));var T=new V.default(s,d);return T.decrypt(S.buffer,u)}).catch(function(u){return o.onWebCryptoError(u,S,C,d)})},O.onWebCryptoError=function(S,C,d,o){return j.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",S),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(C,d,o)},O.getValidChunk=function(S){var C=S,d=S.length-S.length%R;return d!==S.length&&(C=Object(M.sliceUint8)(S,0,d),this.remainderData=Object(M.sliceUint8)(S,d)),C},O.logOnce=function(S){if(!this.logEnabled)return;j.logger.log("[decrypter.ts]: "+S),this.logEnabled=!1},w}()},"./src/crypt/fast-aes-key.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return V});var V=function(){function I(j,B){this.subtle=void 0,this.key=void 0,this.subtle=j,this.key=B}var y=I.prototype;return y.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},I}()},"./src/demux/aacdemuxer.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/demux/base-audio-demuxer.ts"),I=D("./src/demux/adts.ts"),y=D("./src/utils/logger.ts"),j=D("./src/demux/id3.ts");function B(b,w){b.prototype=Object.create(w.prototype),b.prototype.constructor=b,M(b,w)}function M(b,w){return M=Object.setPrototypeOf||function(A,S){return A.__proto__=S,A},M(b,w)}var R=function(b){B(w,b);function w(A,S){var C;return C=b.call(this)||this,C.observer=void 0,C.config=void 0,C.observer=A,C.config=S,C}var O=w.prototype;return O.resetInitSegment=function(S,C,d){b.prototype.resetInitSegment.call(this,S,C,d),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:S,duration:d,inputTimeScale:9e4,dropped:0}},w.probe=function(S){if(!S)return!1;for(var C=j.getID3Data(S,0)||[],d=C.length,o=S.length;d<o;d++)if(I.probe(S,d))return y.logger.log("ADTS sync word found !"),!0;return!1},O.canParse=function(S,C){return I.canParse(S,C)},O.appendFrame=function(S,C,d){I.initTrackConfig(S,this.observer,C,d,S.manifestCodec);var o=I.appendFrame(S,C,d,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},w}(V.default);R.minProbeByteLength=9,Q.default=R},"./src/demux/adts.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"getAudioConfig",function(){return j}),D.d(Q,"isHeaderPattern",function(){return B}),D.d(Q,"getHeaderLength",function(){return M}),D.d(Q,"getFullFrameLength",function(){return R}),D.d(Q,"canGetFrameLength",function(){return b}),D.d(Q,"isHeader",function(){return w}),D.d(Q,"canParse",function(){return O}),D.d(Q,"probe",function(){return A}),D.d(Q,"initTrackConfig",function(){return S}),D.d(Q,"getFrameDuration",function(){return C}),D.d(Q,"parseFrameHeader",function(){return d}),D.d(Q,"appendFrame",function(){return o});var V=D("./src/utils/logger.ts"),I=D("./src/errors.ts"),y=D("./src/events.ts");function j(s,u,T,m){var p,_,v,c,h=navigator.userAgent.toLowerCase(),l=m,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];p=((u[T+2]&192)>>>6)+1;var g=(u[T+2]&60)>>>2;if(g>a.length-1){s.trigger(y.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+g});return}return v=(u[T+2]&1)<<2,v|=(u[T+3]&192)>>>6,V.logger.log("manifest codec:"+m+", ADTS type:"+p+", samplingIndex:"+g),/firefox/i.test(h)?g>=6?(p=5,c=new Array(4),_=g-3):(p=2,c=new Array(2),_=g):h.indexOf("android")!==-1?(p=2,c=new Array(2),_=g):(p=5,c=new Array(4),m&&(m.indexOf("mp4a.40.29")!==-1||m.indexOf("mp4a.40.5")!==-1)||!m&&g>=6?_=g-3:((m&&m.indexOf("mp4a.40.2")!==-1&&(g>=6&&v===1||/vivaldi/i.test(h))||!m&&v===1)&&(p=2,c=new Array(2)),_=g)),c[0]=p<<3,c[0]|=(g&14)>>1,c[1]|=(g&1)<<7,c[1]|=v<<3,p===5&&(c[1]|=(_&14)>>1,c[2]=(_&1)<<7,c[2]|=2<<2,c[3]=0),{config:c,samplerate:a[g],channelCount:v,codec:"mp4a.40."+p,manifestCodec:l}}function B(s,u){return s[u]===255&&(s[u+1]&246)===240}function M(s,u){return s[u+1]&1?7:9}function R(s,u){return(s[u+3]&3)<<11|s[u+4]<<3|(s[u+5]&224)>>>5}function b(s,u){return u+5<s.length}function w(s,u){return u+1<s.length&&B(s,u)}function O(s,u){return b(s,u)&&B(s,u)&&R(s,u)<=s.length-u}function A(s,u){if(w(s,u)){var T=M(s,u);if(u+T>=s.length)return!1;var m=R(s,u);if(m<=T)return!1;var p=u+m;return p===s.length||w(s,p)}return!1}function S(s,u,T,m,p){if(!s.samplerate){var _=j(u,T,m,p);if(!_)return;s.config=_.config,s.samplerate=_.samplerate,s.channelCount=_.channelCount,s.codec=_.codec,s.manifestCodec=_.manifestCodec,V.logger.log("parsed codec:"+s.codec+", rate:"+_.samplerate+", channels:"+_.channelCount)}}function C(s){return 1024*9e4/s}function d(s,u,T,m,p){var _=M(s,u),v=R(s,u);if(v-=_,v>0){var c=T+m*p;return{headerLength:_,frameLength:v,stamp:c}}}function o(s,u,T,m,p){var _=C(s.samplerate),v=d(u,T,m,p,_);if(v){var c=v.frameLength,h=v.headerLength,l=v.stamp,a=h+c,g=Math.max(0,T+a-u.length),f;g?(f=new Uint8Array(a-h),f.set(u.subarray(T+h,u.length),0)):f=u.subarray(T+h,T+a);var x={unit:f,pts:l};return g||s.samples.push(x),{sample:x,length:a,missing:g}}}},"./src/demux/base-audio-demuxer.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"initPTSFn",function(){return R});var V=D("./src/polyfills/number.ts"),I=D("./src/demux/id3.ts"),y=D("./src/demux/dummy-demuxed-track.ts"),j=D("./src/utils/mp4-tools.ts"),B=D("./src/utils/typed-array.ts"),M=function(){function b(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var w=b.prototype;return w.resetInitSegment=function(A,S,C){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},w.resetTimeStamp=function(){},w.resetContiguity=function(){},w.canParse=function(A,S){return!1},w.appendFrame=function(A,S,C){},w.demux=function(A,S){this.cachedData&&(A=Object(j.appendUint8Array)(this.cachedData,A),this.cachedData=null);var C=I.getID3Data(A,0),d=C?C.length:0,o,s,u=this._audioTrack,T=this._id3Track,m=C?I.getTimeStamp(C):void 0,p=A.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=R(m,S)),C&&C.length>0&&T.samples.push({pts:this.initPTS,dts:this.initPTS,data:C}),s=this.initPTS;d<p;){if(this.canParse(A,d)){var _=this.appendFrame(u,A,d);_?(this.frameIndex++,s=_.sample.pts,d+=_.length,o=d):d=p}else I.canParse(A,d)?(C=I.getID3Data(A,d),T.samples.push({pts:s,dts:s,data:C}),d+=C.length,o=d):d++;if(d===p&&o!==p){var v=Object(B.sliceUint8)(A,o);this.cachedData?this.cachedData=Object(j.appendUint8Array)(this.cachedData,v):this.cachedData=v}}return{audioTrack:u,avcTrack:Object(y.dummyTrack)(),id3Track:T,textTrack:Object(y.dummyTrack)()}},w.demuxSampleAes=function(A,S,C){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},w.flush=function(A){var S=this.cachedData;return S&&(this.cachedData=null,this.demux(S,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(y.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(y.dummyTrack)()}},w.destroy=function(){},b}(),R=function(w,O){return Object(V.isFiniteNumber)(w)?w*90:O*9e4};Q.default=M},"./src/demux/chunk-cache.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return V});var V=function(){function y(){this.chunks=[],this.dataLength=0}var j=y.prototype;return j.push=function(M){this.chunks.push(M),this.dataLength+=M.length},j.flush=function(){var M=this.chunks,R=this.dataLength,b;if(M.length)M.length===1?b=M[0]:b=I(M,R);else return new Uint8Array(0);return this.reset(),b},j.reset=function(){this.chunks.length=0,this.dataLength=0},y}();function I(y,j){for(var B=new Uint8Array(j),M=0,R=0;R<y.length;R++){var b=y[R];B.set(b,M),M+=b.length}return B}},"./src/demux/dummy-demuxed-track.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"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(fe,Q,D){"use strict";D.r(Q);var V=D("./src/utils/logger.ts"),I=function(){function y(B){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=B,this.bytesAvailable=B.byteLength,this.word=0,this.bitsAvailable=0}var j=y.prototype;return j.loadWord=function(){var M=this.data,R=this.bytesAvailable,b=M.byteLength-R,w=new Uint8Array(4),O=Math.min(4,R);if(O===0)throw new Error("no bytes available");w.set(M.subarray(b,b+O)),this.word=new DataView(w.buffer).getUint32(0),this.bitsAvailable=O*8,this.bytesAvailable-=O},j.skipBits=function(M){var R;this.bitsAvailable>M?(this.word<<=M,this.bitsAvailable-=M):(M-=this.bitsAvailable,R=M>>3,M-=R>>3,this.bytesAvailable-=R,this.loadWord(),this.word<<=M,this.bitsAvailable-=M)},j.readBits=function(M){var R=Math.min(this.bitsAvailable,M),b=this.word>>>32-R;return M>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=M-R,R>0&&this.bitsAvailable?b<<R|this.readBits(R):b},j.skipLZ=function(){var M;for(M=0;M<this.bitsAvailable;++M)if((this.word&2147483648>>>M)!==0)return this.word<<=M,this.bitsAvailable-=M,M;return this.loadWord(),M+this.skipLZ()},j.skipUEG=function(){this.skipBits(1+this.skipLZ())},j.skipEG=function(){this.skipBits(1+this.skipLZ())},j.readUEG=function(){var M=this.skipLZ();return this.readBits(M+1)-1},j.readEG=function(){var M=this.readUEG();return 1&M?1+M>>>1:-1*(M>>>1)},j.readBoolean=function(){return this.readBits(1)===1},j.readUByte=function(){return this.readBits(8)},j.readUShort=function(){return this.readBits(16)},j.readUInt=function(){return this.readBits(32)},j.skipScalingList=function(M){for(var R=8,b=8,w,O=0;O<M;O++)b!==0&&(w=this.readEG(),b=(R+w+256)%256),R=b===0?R:b},j.readSPS=function(){var M=0,R=0,b=0,w=0,O,A,S,C=this.readUByte.bind(this),d=this.readBits.bind(this),o=this.readUEG.bind(this),s=this.readBoolean.bind(this),u=this.skipBits.bind(this),T=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);C();var _=C();if(d(5),u(3),C(),m(),_===100||_===110||_===122||_===244||_===44||_===83||_===86||_===118||_===128){var v=o();if(v===3&&u(1),m(),m(),u(1),s())for(A=v!==3?8:12,S=0;S<A;S++)s()&&(S<6?p(16):p(64))}m();var c=o();if(c===0)o();else if(c===1)for(u(1),T(),T(),O=o(),S=0;S<O;S++)T();m(),u(1);var h=o(),l=o(),a=d(1);a===0&&u(1),u(1),s()&&(M=o(),R=o(),b=o(),w=o());var g=[1,1];if(s()&&s()){var f=C();switch(f){case 1:g=[1,1];break;case 2:g=[12,11];break;case 3:g=[10,11];break;case 4:g=[16,11];break;case 5:g=[40,33];break;case 6:g=[24,11];break;case 7:g=[20,11];break;case 8:g=[32,11];break;case 9:g=[80,33];break;case 10:g=[18,11];break;case 11:g=[15,11];break;case 12:g=[64,33];break;case 13:g=[160,99];break;case 14:g=[4,3];break;case 15:g=[3,2];break;case 16:g=[2,1];break;case 255:{g=[C()<<8|C(),C()<<8|C()];break}}}return{width:Math.ceil((h+1)*16-M*2-R*2),height:(2-a)*(l+1)*16-(a?2:4)*(b+w),pixelRatio:g}},j.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},y}();Q.default=I},"./src/demux/id3.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"isHeader",function(){return V}),D.d(Q,"isFooter",function(){return I}),D.d(Q,"getID3Data",function(){return y}),D.d(Q,"canParse",function(){return B}),D.d(Q,"getTimeStamp",function(){return M}),D.d(Q,"isTimeStampFrame",function(){return R}),D.d(Q,"getID3Frames",function(){return w}),D.d(Q,"decodeFrame",function(){return O}),D.d(Q,"utf8ArrayToStr",function(){return o}),D.d(Q,"testables",function(){return s});var V=function(p,_){return _+10<=p.length&&(p[_]===73&&p[_+1]===68&&p[_+2]===51&&(p[_+3]<255&&p[_+4]<255&&(p[_+6]<128&&p[_+7]<128&&p[_+8]<128&&p[_+9]<128)))},I=function(p,_){return _+10<=p.length&&(p[_]===51&&p[_+1]===68&&p[_+2]===73&&(p[_+3]<255&&p[_+4]<255&&(p[_+6]<128&&p[_+7]<128&&p[_+8]<128&&p[_+9]<128)))},y=function(p,_){for(var v=_,c=0;V(p,_);){c+=10;var h=j(p,_+6);c+=h,I(p,_+10)&&(c+=10),_+=c}return c>0?p.subarray(v,v+c):void 0},j=function(p,_){var v=0;return v=(p[_]&127)<<21,v|=(p[_+1]&127)<<14,v|=(p[_+2]&127)<<7,v|=p[_+3]&127,v},B=function(p,_){return V(p,_)&&j(p,_+6)+10<=p.length-_},M=function(p){for(var _=w(p),v=0;v<_.length;v++){var c=_[v];if(R(c))return d(c)}return},R=function(p){return p&&p.key==="PRIV"&&p.info==="com.apple.streaming.transportStreamTimestamp"},b=function(p){var _=String.fromCharCode(p[0],p[1],p[2],p[3]),v=j(p,4),c=10;return{type:_,size:v,data:p.subarray(c,c+v)}},w=function(p){for(var _=0,v=[];V(p,_);){var c=j(p,_+6);_+=10;for(var h=_+c;_+8<h;){var l=b(p.subarray(_)),a=O(l);a&&v.push(a),_+=l.size+10}I(p,_)&&(_+=10)}return v},O=function(p){return p.type==="PRIV"?A(p):p.type[0]==="W"?C(p):S(p)},A=function(p){if(p.size<2)return;var _=o(p.data,!0),v=new Uint8Array(p.data.subarray(_.length+1));return{key:p.type,info:_,data:v.buffer}},S=function(p){if(p.size<2)return;if(p.type==="TXXX"){var _=1,v=o(p.data.subarray(_),!0);_+=v.length+1;var c=o(p.data.subarray(_));return{key:p.type,info:v,data:c}}var h=o(p.data.subarray(1));return{key:p.type,data:h}},C=function(p){if(p.type==="WXXX"){if(p.size<2)return;var _=1,v=o(p.data.subarray(_),!0);_+=v.length+1;var c=o(p.data.subarray(_));return{key:p.type,info:v,data:c}}var h=o(p.data);return{key:p.type,data:h}},d=function(p){if(p.data.byteLength===8){var _=new Uint8Array(p.data),v=_[3]&1,c=(_[4]<<23)+(_[5]<<15)+(_[6]<<7)+_[7];return c/=45,v&&(c+=4772185884e-2),Math.round(c)}return},o=function(p,_){_===void 0&&(_=!1);var v=T();if(v){var c=v.decode(p);if(_){var h=c.indexOf("\0");return h!==-1?c.substring(0,h):c}return c.replace(/\0/g,"")}for(var l=p.length,a,g,f,x="",P=0;P<l;){if(a=p[P++],a===0&&_)return x;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:x+=String.fromCharCode(a);break;case 12:case 13:g=p[P++],x+=String.fromCharCode((a&31)<<6|g&63);break;case 14:g=p[P++],f=p[P++],x+=String.fromCharCode((a&15)<<12|(g&63)<<6|(f&63)<<0);break;default:}}return x},s={decodeTextFrame:S},u;function T(){return!u&&typeof self.TextDecoder!="undefined"&&(u=new self.TextDecoder("utf-8")),u}},"./src/demux/mp3demuxer.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/demux/base-audio-demuxer.ts"),I=D("./src/demux/id3.ts"),y=D("./src/utils/logger.ts"),j=D("./src/demux/mpegaudio.ts");function B(b,w){b.prototype=Object.create(w.prototype),b.prototype.constructor=b,M(b,w)}function M(b,w){return M=Object.setPrototypeOf||function(A,S){return A.__proto__=S,A},M(b,w)}var R=function(b){B(w,b);function w(){return b.apply(this,arguments)||this}var O=w.prototype;return O.resetInitSegment=function(S,C,d){b.prototype.resetInitSegment.call(this,S,C,d),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:S,duration:d,inputTimeScale:9e4,dropped:0}},w.probe=function(S){if(!S)return!1;for(var C=I.getID3Data(S,0)||[],d=C.length,o=S.length;d<o;d++)if(j.probe(S,d))return y.logger.log("MPEG Audio sync word found !"),!0;return!1},O.canParse=function(S,C){return j.canParse(S,C)},O.appendFrame=function(S,C,d){return this.initPTS===null?void 0:j.appendFrame(S,C,d,this.initPTS,this.frameIndex)},w}(V.default);R.minProbeByteLength=4,Q.default=R},"./src/demux/mp4demuxer.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/utils/mp4-tools.ts"),I=D("./src/demux/dummy-demuxed-track.ts"),y=function(){function j(M,R){this.remainderData=null,this.config=void 0,this.config=R}var B=j.prototype;return B.resetTimeStamp=function(){},B.resetInitSegment=function(){},B.resetContiguity=function(){},j.probe=function(R){return Object(V.findBox)({data:R,start:0,end:Math.min(R.length,16384)},["moof"]).length>0},B.demux=function(R){var b=R,w=Object(I.dummyTrack)();if(this.config.progressive){this.remainderData&&(b=Object(V.appendUint8Array)(this.remainderData,R));var O=Object(V.segmentValidRange)(b);this.remainderData=O.remainder,w.samples=O.valid||new Uint8Array}else w.samples=b;return{audioTrack:Object(I.dummyTrack)(),avcTrack:w,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},B.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)()}},B.demuxSampleAes=function(R,b,w){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},B.destroy=function(){},j}();y.minProbeByteLength=1024,Q.default=y},"./src/demux/mpegaudio.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"appendFrame",function(){return M}),D.d(Q,"parseHeader",function(){return R}),D.d(Q,"isHeaderPattern",function(){return b}),D.d(Q,"isHeader",function(){return w}),D.d(Q,"canParse",function(){return O}),D.d(Q,"probe",function(){return A});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],y=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],j=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],B=[0,1,1,4];function M(S,C,d,o,s){if(d+24>C.length)return;var u=R(C,d);if(u&&d+u.frameLength<=C.length){var T=u.samplesPerFrame*9e4/u.sampleRate,m=o+s*T,p={unit:C.subarray(d,d+u.frameLength),pts:m,dts:m};return S.config=[],S.channelCount=u.channelCount,S.samplerate=u.sampleRate,S.samples.push(p),{sample:p,length:u.frameLength,missing:0}}}function R(S,C){var d=S[C+1]>>3&3,o=S[C+1]>>1&3,s=S[C+2]>>4&15,u=S[C+2]>>2&3;if(d!==1&&s!==0&&s!==15&&u!==3){var T=S[C+2]>>1&1,m=S[C+3]>>6,p=d===3?3-o:o===3?3:4,_=I[p*14+s-1]*1e3,v=d===3?0:d===2?1:2,c=y[v*3+u],h=m===3?1:2,l=j[d][o],a=B[o],g=l*8*a,f=Math.floor(l*_/c+T)*a;if(V===null){var x=navigator.userAgent||"",P=x.match(/Chrome\/(\d+)/i);V=P?parseInt(P[1]):0}var G=!!V&&V<=87;return G&&o===2&&_>=224e3&&m===0&&(S[C+3]=S[C+3]|128),{sampleRate:c,channelCount:h,frameLength:f,samplesPerFrame:g}}}function b(S,C){return S[C]===255&&(S[C+1]&224)===224&&(S[C+1]&6)!==0}function w(S,C){return C+1<S.length&&b(S,C)}function O(S,C){var d=4;return b(S,C)&&d<=S.length-C}function A(S,C){if(C+1<S.length&&b(S,C)){var d=4,o=R(S,C),s=d;o!=null&&o.frameLength&&(s=o.frameLength);var u=C+s;return u===S.length||w(S,u)}return!1}},"./src/demux/sample-aes.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/crypt/decrypter.ts"),I=D("./src/demux/tsdemuxer.ts"),y=function(){function j(M,R,b){this.keyData=void 0,this.decrypter=void 0,this.keyData=b,this.decrypter=new V.default(M,R,{removePKCS7Padding:!1})}var B=j.prototype;return B.decryptBuffer=function(R,b){this.decrypter.decrypt(R,this.keyData.key.buffer,this.keyData.iv.buffer,b)},B.decryptAacSample=function(R,b,w,O){var A=R[b].unit,S=A.subarray(16,A.length-A.length%16),C=S.buffer.slice(S.byteOffset,S.byteOffset+S.length),d=this;this.decryptBuffer(C,function(o){var s=new Uint8Array(o);A.set(s,16),O||d.decryptAacSamples(R,b+1,w)})},B.decryptAacSamples=function(R,b,w){for(;;b++){if(b>=R.length){w();return}if(R[b].unit.length<32)continue;var O=this.decrypter.isSync();if(this.decryptAacSample(R,b,w,O),!O)return}},B.getAvcEncryptedData=function(R){for(var b=Math.floor((R.length-48)/160)*16+16,w=new Int8Array(b),O=0,A=32;A<=R.length-16;A+=160,O+=16)w.set(R.subarray(A,A+16),O);return w},B.getAvcDecryptedUnit=function(R,b){for(var w=new Uint8Array(b),O=0,A=32;A<=R.length-16;A+=160,O+=16)R.set(w.subarray(O,O+16),A);return R},B.decryptAvcSample=function(R,b,w,O,A,S){var C=Object(I.discardEPB)(A.data),d=this.getAvcEncryptedData(C),o=this;this.decryptBuffer(d.buffer,function(s){A.data=o.getAvcDecryptedUnit(C,s),S||o.decryptAvcSamples(R,b,w+1,O)})},B.decryptAvcSamples=function(R,b,w,O){if(R instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;b++,w=0){if(b>=R.length){O();return}for(var A=R[b].units;!(w>=A.length);w++){var S=A[w];if(S.data.length<=48||S.type!==1&&S.type!==5)continue;var C=this.decrypter.isSync();if(this.decryptAvcSample(R,b,w,O,S,C),!C)return}}},j}();Q.default=y},"./src/demux/transmuxer-interface.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return A});var V=D("./node_modules/webworkify-webpack/index.js"),I=D.n(V),y=D("./src/events.ts"),j=D("./src/demux/transmuxer.ts"),B=D("./src/utils/logger.ts"),M=D("./src/errors.ts"),R=D("./src/utils/mediasource-helper.ts"),b=D("./node_modules/eventemitter3/index.js"),w=D.n(b),O=Object(R.getMediaSource)()||{isTypeSupported:function(){return!1}},A=function(){function S(d,o,s,u){var T=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=d,this.id=o,this.onTransmuxComplete=s,this.onFlush=u;var m=d.config,p=function(l,a){a=a||{},a.frag=T.frag,a.id=T.id,d.trigger(l,a)};this.observer=new b.EventEmitter,this.observer.on(y.Events.FRAG_DECRYPTED,p),this.observer.on(y.Events.ERROR,p);var _={mp4:O.isTypeSupported("video/mp4"),mpeg:O.isTypeSupported("audio/mpeg"),mp3:O.isTypeSupported('audio/mp4; codecs="mp3"')},v=navigator.vendor;if(m.enableWorker&&typeof Worker!="undefined"){B.logger.log("demuxing in webworker");var c;try{c=this.worker=V("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),c.addEventListener("message",this.onwmsg),c.onerror=function(h){d.trigger(y.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(h.message+" ("+h.filename+":"+h.lineno+")")})},c.postMessage({cmd:"init",typeSupported:_,vendor:v,id:o,config:JSON.stringify(m)})}catch(h){B.logger.warn("Error in worker:",h),B.logger.error("Error while initializing DemuxerWorker, fallback to inline"),c&&self.URL.revokeObjectURL(c.objectURL),this.transmuxer=new j.default(this.observer,_,m,v,o),this.worker=null}}else this.transmuxer=new j.default(this.observer,_,m,v,o)}var C=S.prototype;return C.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var u=this.observer;u&&u.removeAllListeners(),this.observer=null},C.push=function(o,s,u,T,m,p,_,v,c,h){var l=this;c.transmuxing.start=self.performance.now();var a=this.transmuxer,g=this.worker,f=p?p.start:m.start,x=m.decryptdata,P=this.frag,G=!(P&&m.cc===P.cc),X=!(P&&c.level===P.level),ie=P?c.sn-P.sn:-1,z=this.part?c.part-this.part.index:1,F=!X&&(ie===1||ie===0&&z===1),ne=self.performance.now();(X||ie||m.stats.parsing.start===0)&&(m.stats.parsing.start=ne),p&&(z||!F)&&(p.stats.parsing.start=ne);var ce=new j.TransmuxState(G,F,v,X,f);if(!F||G){B.logger.log("[transmuxer-interface, "+m.type+"]: Starting new transmux session for sn: "+c.sn+" p: "+c.part+" level: "+c.level+" id: "+c.id+`
|
|
discontinuity: `+G+`
|
|
trackSwitch: `+X+`
|
|
contiguous: `+F+`
|
|
accurateTimeOffset: `+v+`
|
|
timeOffset: `+f);var ge=new j.TransmuxConfig(u,T,s,_,h);this.configureTransmuxer(ge)}if(this.frag=m,this.part=p,g)g.postMessage({cmd:"demux",data:o,decryptdata:x,chunkMeta:c,state:ce},o instanceof ArrayBuffer?[o]:[]);else if(a){var be=a.push(o,x,c,ce);Object(j.isPromise)(be)?be.then(function(Ie){l.handleTransmuxComplete(Ie)}):this.handleTransmuxComplete(be)}},C.flush=function(o){var s=this;o.transmuxing.start=self.performance.now();var u=this.transmuxer,T=this.worker;if(T)T.postMessage({cmd:"flush",chunkMeta:o});else if(u){var m=u.flush(o);Object(j.isPromise)(m)?m.then(function(p){s.handleFlushResult(p,o)}):this.handleFlushResult(m,o)}},C.handleFlushResult=function(o,s){var u=this;o.forEach(function(T){u.handleTransmuxComplete(T)}),this.onFlush(s)},C.onWorkerMessage=function(o){var s=o.data,u=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,u.trigger(s.event,s.data);break}}},C.configureTransmuxer=function(o){var s=this.worker,u=this.transmuxer;s?s.postMessage({cmd:"configure",config:o}):u&&u.configure(o)},C.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},S}()},"./src/demux/transmuxer-worker.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return M});var V=D("./src/demux/transmuxer.ts"),I=D("./src/events.ts"),y=D("./src/utils/logger.ts"),j=D("./node_modules/eventemitter3/index.js"),B=D.n(j);function M(A){var S=new j.EventEmitter,C=function(o,s){A.postMessage({event:o,data:s})};S.on(I.Events.FRAG_DECRYPTED,C),S.on(I.Events.ERROR,C),A.addEventListener("message",function(d){var o=d.data;switch(o.cmd){case"init":{var s=JSON.parse(o.config);A.transmuxer=new V.default(S,o.typeSupported,s,o.vendor,o.id),Object(y.enableLogs)(s.debug),C("init",null);break}case"configure":{A.transmuxer.configure(o.config);break}case"demux":{var u=A.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(V.isPromise)(u)?u.then(function(p){R(A,p)}):R(A,u);break}case"flush":{var T=o.chunkMeta,m=A.transmuxer.flush(T);Object(V.isPromise)(m)?m.then(function(p){w(A,p,T)}):w(A,m,T);break}default:break}})}function R(A,S){if(O(S.remuxResult))return;var C=[],d=S.remuxResult,o=d.audio,s=d.video;o&&b(C,o),s&&b(C,s),A.postMessage({event:"transmuxComplete",data:S},C)}function b(A,S){S.data1&&A.push(S.data1.buffer),S.data2&&A.push(S.data2.buffer)}function w(A,S,C){S.forEach(function(d){R(A,d)}),A.postMessage({event:"flush",data:C})}function O(A){return!A.audio&&!A.video&&!A.text&&!A.id3&&!A.initSegment}},"./src/demux/transmuxer.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return s}),D.d(Q,"isPromise",function(){return m}),D.d(Q,"TransmuxConfig",function(){return p}),D.d(Q,"TransmuxState",function(){return _});var V=D("./src/events.ts"),I=D("./src/errors.ts"),y=D("./src/crypt/decrypter.ts"),j=D("./src/demux/aacdemuxer.ts"),B=D("./src/demux/mp4demuxer.ts"),M=D("./src/demux/tsdemuxer.ts"),R=D("./src/demux/mp3demuxer.ts"),b=D("./src/remux/mp4-remuxer.ts"),w=D("./src/remux/passthrough-remuxer.ts"),O=D("./src/demux/chunk-cache.ts"),A=D("./src/utils/mp4-tools.ts"),S=D("./src/utils/logger.ts"),C;try{C=self.performance.now.bind(self.performance)}catch(v){S.logger.debug("Unable to use Performance API on this environment"),C=self.Date.now}var d=[{demux:M.default,remux:b.default},{demux:B.default,remux:w.default},{demux:j.default,remux:b.default},{demux:R.default,remux:b.default}],o=1024;d.forEach(function(v){var c=v.demux;o=Math.max(o,c.minProbeByteLength)});var s=function(){function v(h,l,a,g,f){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 O.default,this.observer=h,this.typeSupported=l,this.config=a,this.vendor=g,this.id=f}var c=v.prototype;return c.configure=function(l){this.transmuxConfig=l,this.decrypter&&this.decrypter.reset()},c.push=function(l,a,g,f){var x=this,P=g.transmuxing;P.executeStart=C();var G=new Uint8Array(l),X=this.cache,ie=this.config,z=this.currentTransmuxState,F=this.transmuxConfig;f&&(this.currentTransmuxState=f);var ne=u(G,a);if(ne&&ne.method==="AES-128"){var ce=this.getDecrypter();if(ie.enableSoftwareAES){var ge=ce.softwareDecrypt(G,ne.key.buffer,ne.iv.buffer);if(!ge)return P.executeEnd=C(),T(g);G=new Uint8Array(ge)}else return this.decryptionPromise=ce.webCryptoDecrypt(G,ne.key.buffer,ne.iv.buffer).then(function(Ee){var _e=x.push(Ee,null,g);return x.decryptionPromise=null,_e}),this.decryptionPromise}var be=f||z,Ie=be.contiguous,Te=be.discontinuity,De=be.trackSwitch,we=be.accurateTimeOffset,Ae=be.timeOffset,ve=F.audioCodec,W=F.videoCodec,L=F.defaultInitPts,k=F.duration,H=F.initSegmentData;if((Te||De)&&this.resetInitSegment(H,ve,W,k),Te&&this.resetInitialTimestamp(L),Ie||this.resetContiguity(),this.needsProbing(G,Te,De)){if(X.dataLength){var ee=X.flush();G=Object(A.appendUint8Array)(ee,G)}this.configureTransmuxer(G,F)}var U=this.transmux(G,ne,Ae,we,g),de=this.currentTransmuxState;return de.contiguous=!0,de.discontinuity=!1,de.trackSwitch=!1,P.executeEnd=C(),U},c.flush=function(l){var a=this,g=l.transmuxing;g.executeStart=C();var f=this.decrypter,x=this.cache,P=this.currentTransmuxState,G=this.decryptionPromise;if(G)return G.then(function(){return a.flush(l)});var X=[],ie=P.timeOffset;if(f){var z=f.flush();z&&X.push(this.push(z,null,l))}var F=x.dataLength;x.reset();var ne=this.demuxer,ce=this.remuxer;if(!ne||!ce)return F>=o&&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"}),g.executeEnd=C(),[T(l)];var ge=ne.flush(ie);return m(ge)?ge.then(function(be){return a.flushRemux(X,be,l),X}):(this.flushRemux(X,ge,l),X)},c.flushRemux=function(l,a,g){var f=a.audioTrack,x=a.avcTrack,P=a.id3Track,G=a.textTrack,X=this.currentTransmuxState,ie=X.accurateTimeOffset,z=X.timeOffset;S.logger.log("[transmuxer.ts]: Flushed fragment "+g.sn+(g.part>-1?" p: "+g.part:"")+" of level "+g.level);var F=this.remuxer.remux(f,x,P,G,z,ie,!0,this.id);l.push({remuxResult:F,chunkMeta:g}),g.transmuxing.executeEnd=C()},c.resetInitialTimestamp=function(l){var a=this.demuxer,g=this.remuxer;if(!a||!g)return;a.resetTimeStamp(l),g.resetTimeStamp(l)},c.resetContiguity=function(){var l=this.demuxer,a=this.remuxer;if(!l||!a)return;l.resetContiguity(),a.resetNextTimestamp()},c.resetInitSegment=function(l,a,g,f){var x=this.demuxer,P=this.remuxer;if(!x||!P)return;x.resetInitSegment(a,g,f),P.resetInitSegment(l,a,g)},c.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},c.transmux=function(l,a,g,f,x){var P;return a&&a.method==="SAMPLE-AES"?P=this.transmuxSampleAes(l,a,g,f,x):P=this.transmuxUnencrypted(l,g,f,x),P},c.transmuxUnencrypted=function(l,a,g,f){var x=this.demuxer.demux(l,a,!1,!this.config.progressive),P=x.audioTrack,G=x.avcTrack,X=x.id3Track,ie=x.textTrack,z=this.remuxer.remux(P,G,X,ie,a,g,!1,this.id);return{remuxResult:z,chunkMeta:f}},c.transmuxSampleAes=function(l,a,g,f,x){var P=this;return this.demuxer.demuxSampleAes(l,a,g).then(function(G){var X=P.remuxer.remux(G.audioTrack,G.avcTrack,G.id3Track,G.textTrack,g,f,!1,P.id);return{remuxResult:X,chunkMeta:x}})},c.configureTransmuxer=function(l,a){for(var g=this.config,f=this.observer,x=this.typeSupported,P=this.vendor,G=a.audioCodec,X=a.defaultInitPts,ie=a.duration,z=a.initSegmentData,F=a.videoCodec,ne,ce=0,ge=d.length;ce<ge;ce++)if(d[ce].demux.probe(l)){ne=d[ce];break}ne||(S.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),ne={demux:B.default,remux:w.default});var be=this.demuxer,Ie=this.remuxer,Te=ne.remux,De=ne.demux;(!Ie||!(Ie instanceof Te))&&(this.remuxer=new Te(f,g,x,P)),(!be||!(be instanceof De))&&(this.demuxer=new De(f,g,x),this.probe=De.probe),this.resetInitSegment(z,G,F,ie),this.resetInitialTimestamp(X)},c.needsProbing=function(l,a,g){return!this.demuxer||!this.remuxer||a||g},c.getDecrypter=function(){var l=this.decrypter;return l||(l=this.decrypter=new y.default(this.observer,this.config)),l},v}();function u(v,c){var h=null;return v.byteLength>0&&c!=null&&c.key!=null&&c.iv!==null&&c.method!=null&&(h=c),h}var T=function(c){return{remuxResult:{},chunkMeta:c}};function m(v){return"then"in v&&v.then instanceof Function}var p=function(c,h,l,a,g){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=c,this.videoCodec=h,this.initSegmentData=l,this.duration=a,this.defaultInitPts=g},_=function(c,h,l,a,g){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=c,this.contiguous=h,this.accurateTimeOffset=l,this.trackSwitch=a,this.timeOffset=g}},"./src/demux/tsdemuxer.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"discardEPB",function(){return T});var V=D("./src/demux/adts.ts"),I=D("./src/demux/mpegaudio.ts"),y=D("./src/demux/exp-golomb.ts"),j=D("./src/demux/id3.ts"),B=D("./src/demux/sample-aes.ts"),M=D("./src/events.ts"),R=D("./src/utils/mp4-tools.ts"),b=D("./src/utils/logger.ts"),w=D("./src/errors.ts"),O={video:1,audio:2,id3:3,text:4},A=function(){function m(_,v,c){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=_,this.config=v,this.typeSupported=c}m.probe=function(v){var c=m.syncOffset(v);return c<0?!1:(c&&b.logger.warn("MPEG2-TS detected but first sync word found @ offset "+c+", junk ahead ?"),!0)},m.syncOffset=function(v){for(var c=Math.min(1e3,v.length-3*188),h=0;h<c;){if(v[h]===71&&v[h+188]===71&&v[h+2*188]===71)return h;h++}return-1},m.createTrack=function(v,c){return{container:v==="video"||v==="audio"?"video/mp2t":void 0,type:v,id:O[v],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:v==="audio"?c:void 0}};var p=m.prototype;return p.resetInitSegment=function(v,c,h){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=m.createTrack("video",h),this._audioTrack=m.createTrack("audio",h),this._id3Track=m.createTrack("id3",h),this._txtTrack=m.createTrack("text",h),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=v,this.videoCodec=c,this._duration=h},p.resetTimeStamp=function(){},p.resetContiguity=function(){var v=this._audioTrack,c=this._avcTrack,h=this._id3Track;v&&(v.pesData=null),c&&(c.pesData=null),h&&(h.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},p.demux=function(v,c,h,l){h===void 0&&(h=!1),l===void 0&&(l=!1),h||(this.sampleAes=null);var a,g=this._avcTrack,f=this._audioTrack,x=this._id3Track,P=g.pid,G=g.pesData,X=f.pid,ie=x.pid,z=f.pesData,F=x.pesData,ne=!1,ce=this.pmtParsed,ge=this._pmtId,be=v.length;if(this.remainderData&&(v=Object(R.appendUint8Array)(this.remainderData,v),be=v.length,this.remainderData=null),be<188&&!l)return this.remainderData=v,{audioTrack:f,avcTrack:g,id3Track:x,textTrack:this._txtTrack};var Ie=Math.max(0,m.syncOffset(v));be-=(be+Ie)%188,be<v.byteLength&&!l&&(this.remainderData=new Uint8Array(v.buffer,be,v.buffer.byteLength-be));for(var Te=Ie;Te<be;Te+=188)if(v[Te]===71){var De=!!(v[Te+1]&64),we=((v[Te+1]&31)<<8)+v[Te+2],Ae=(v[Te+3]&48)>>4,ve=void 0;if(Ae>1){if(ve=Te+5+v[Te+4],ve===Te+188)continue}else ve=Te+4;switch(we){case P:De&&(G&&(a=o(G))&&this.parseAVCPES(a,!1),G={data:[],size:0}),G&&(G.data.push(v.subarray(ve,Te+188)),G.size+=Te+188-ve);break;case X:De&&(z&&(a=o(z))&&(f.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),z={data:[],size:0}),z&&(z.data.push(v.subarray(ve,Te+188)),z.size+=Te+188-ve);break;case ie:De&&(F&&(a=o(F))&&this.parseID3PES(a),F={data:[],size:0}),F&&(F.data.push(v.subarray(ve,Te+188)),F.size+=Te+188-ve);break;case 0:De&&(ve+=v[ve]+1),ge=this._pmtId=C(v,ve);break;case ge:{De&&(ve+=v[ve]+1);var W=d(v,ve,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,h);P=W.avc,P>0&&(g.pid=P),X=W.audio,X>0&&(f.pid=X,f.isAAC=W.isAAC),ie=W.id3,ie>0&&(x.pid=ie),ne&&!ce&&(b.logger.log("reparse from beginning"),ne=!1,Te=Ie-188),ce=this.pmtParsed=!0;break}case 17:case 8191:break;default:ne=!0;break}}else this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});g.pesData=G,f.pesData=z,x.pesData=F;var L={audioTrack:f,avcTrack:g,id3Track:x,textTrack:this._txtTrack};return l&&this.extractRemainingSamples(L),L},p.flush=function(){var v=this.remainderData;this.remainderData=null;var c;return v?c=this.demux(v,-1,!1,!0):c={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},p.extractRemainingSamples=function(v){var c=v.audioTrack,h=v.avcTrack,l=v.id3Track,a=h.pesData,g=c.pesData,f=l.pesData,x;a&&(x=o(a))?(this.parseAVCPES(x,!0),h.pesData=null):h.pesData=a,g&&(x=o(g))?(c.isAAC?this.parseAACPES(x):this.parseMPEGPES(x),c.pesData=null):(g!=null&&g.size&&b.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=g),f&&(x=o(f))?(this.parseID3PES(x),l.pesData=null):l.pesData=f},p.demuxSampleAes=function(v,c,h){var l=this.demux(v,h,!0,!this.config.progressive),a=this.sampleAes=new B.default(this.observer,this.config,c);return this.decrypt(l,a)},p.decrypt=function(v,c){return new Promise(function(h){var l=v.audioTrack,a=v.avcTrack;l.samples&&l.isAAC?c.decryptAacSamples(l.samples,0,function(){a.samples?c.decryptAvcSamples(a.samples,0,0,function(){h(v)}):h(v)}):a.samples&&c.decryptAvcSamples(a.samples,0,0,function(){h(v)})})},p.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},p.parseAVCPES=function(v,c){var h=this,l=this._avcTrack,a=this.parseAVCNALu(v.data),g=!1,f=this.avcSample,x,P=!1;v.data=null,f&&a.length&&!l.audFound&&(s(f,l),f=this.avcSample=S(!1,v.pts,v.dts,"")),a.forEach(function(G){switch(G.type){case 1:{x=!0,f||(f=h.avcSample=S(!0,v.pts,v.dts,"")),g&&(f.debug+="NDR "),f.frame=!0;var X=G.data;if(P&&X.length>4){var ie=new y.default(X).readSliceType();(ie===2||ie===4||ie===7||ie===9)&&(f.key=!0)}break}case 5:x=!0,f||(f=h.avcSample=S(!0,v.pts,v.dts,"")),g&&(f.debug+="IDR "),f.key=!0,f.frame=!0;break;case 6:{x=!0,g&&f&&(f.debug+="SEI ");var z=new y.default(T(G.data));z.readUByte();for(var F=0,ne=0,ce=!1,ge=0;!ce&&z.bytesAvailable>1;){F=0;do ge=z.readUByte(),F+=ge;while(ge===255);ne=0;do ge=z.readUByte(),ne+=ge;while(ge===255);if(F===4&&z.bytesAvailable!==0){ce=!0;var be=z.readUByte();if(be===181){var Ie=z.readUShort();if(Ie===49){var Te=z.readUInt();if(Te===1195456820){var De=z.readUByte();if(De===3){for(var we=z.readUByte(),Ae=z.readUByte(),ve=31&we,W=[we,Ae],L=0;L<ve;L++)W.push(z.readUByte()),W.push(z.readUByte()),W.push(z.readUByte());u(h._txtTrack.samples,{type:3,pts:v.pts,bytes:W})}}}}}else if(F===5&&z.bytesAvailable!==0){if(ce=!0,ne>16){for(var k=[],H=0;H<16;H++)k.push(z.readUByte().toString(16)),(H===3||H===5||H===7||H===9)&&k.push("-");for(var ee=ne-16,U=new Uint8Array(ee),de=0;de<ee;de++)U[de]=z.readUByte();u(h._txtTrack.samples,{pts:v.pts,payloadType:F,uuid:k.join(""),userData:Object(j.utf8ArrayToStr)(U),userDataBytes:U})}}else if(ne<z.bytesAvailable)for(var Ee=0;Ee<ne;Ee++)z.readUByte()}break}case 7:if(x=!0,P=!0,g&&f&&(f.debug+="SPS "),!l.sps){var _e=new y.default(G.data),Ue=_e.readSPS();l.width=Ue.width,l.height=Ue.height,l.pixelRatio=Ue.pixelRatio,l.sps=[G.data],l.duration=h._duration;for(var ke=G.data.subarray(1,4),Oe="avc1.",Pe=0;Pe<3;Pe++){var Xe=ke[Pe].toString(16);Xe.length<2&&(Xe="0"+Xe),Oe+=Xe}l.codec=Oe}break;case 8:x=!0,g&&f&&(f.debug+="PPS "),l.pps||(l.pps=[G.data]);break;case 9:x=!1,l.audFound=!0,f&&s(f,l),f=h.avcSample=S(!1,v.pts,v.dts,g?"AUD ":"");break;case 12:x=!1;break;default:x=!1,f&&(f.debug+="unknown NAL "+G.type+" ");break}if(f&&x){var Fe=f.units;Fe.push(G)}}),c&&f&&(s(f,l),this.avcSample=null)},p.getLastNalUnit=function(){var v,c=this.avcSample,h;if(!c||c.units.length===0){var l=this._avcTrack.samples;c=l[l.length-1]}if((v=c)!==null&&v!==void 0&&v.units){var a=c.units;h=a[a.length-1]}return h},p.parseAVCNALu=function(v){var c=v.byteLength,h=this._avcTrack,l=h.naluState||0,a=l,g=[],f=0,x,P,G,X=-1,ie=0;for(l===-1&&(X=0,ie=v[0]&31,l=0,f=1);f<c;){if(x=v[f++],!l){l=x?0:1;continue}if(l===1){l=x?0:2;continue}if(!x)l=3;else if(x===1){if(X>=0){var z={data:v.subarray(X,f-l-1),type:ie};g.push(z)}else{var F=this.getLastNalUnit();if(F&&(a&&f<=4-a&&(F.state&&(F.data=F.data.subarray(0,F.data.byteLength-a))),P=f-l-1,P>0)){var ne=new Uint8Array(F.data.byteLength+P);ne.set(F.data,0),ne.set(v.subarray(0,P),F.data.byteLength),F.data=ne,F.state=0}}f<c?(G=v[f]&31,X=f,ie=G,l=0):l=-1}else l=0}if(X>=0&&l>=0){var ce={data:v.subarray(X,c),type:ie,state:l};g.push(ce)}if(g.length===0){var ge=this.getLastNalUnit();if(ge){var be=new Uint8Array(ge.data.byteLength+v.byteLength);be.set(ge.data,0),be.set(v,ge.data.byteLength),ge.data=be}}return h.naluState=l,g},p.parseAACPES=function(v){var c=0,h=this._audioTrack,l=this.aacOverFlow,a=v.data;if(l){this.aacOverFlow=null;var g=l.sample.unit.byteLength,f=Math.min(l.missing,g),x=g-f;l.sample.unit.set(a.subarray(0,f),x),h.samples.push(l.sample),c=l.missing}var P,G;for(P=c,G=a.length;P<G-1&&!V.isHeader(a,P);P++);if(P!==c){var X,ie;if(P<G-1?(X="AAC PES did not start with ADTS header,offset:"+P,ie=!1):(X="no ADTS header found in AAC PES",ie=!0),b.logger.warn("parsing error:"+X),this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,fatal:ie,reason:X}),ie)return}V.initTrackConfig(h,this.observer,a,P,this.audioCodec);var z;if(v.pts!==void 0)z=v.pts;else if(l){var F=V.getFrameDuration(h.samplerate);z=l.sample.pts+F}else{b.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var ne=0;P<G;)if(V.isHeader(a,P)){if(P+5<G){var ce=V.appendFrame(h,a,P,z,ne);if(ce)if(ce.missing)this.aacOverFlow=ce;else{P+=ce.length,ne++;continue}}break}else P++},p.parseMPEGPES=function(v){var c=v.data,h=c.length,l=0,a=0,g=v.pts;if(g===void 0){b.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<h;)if(I.isHeader(c,a)){var f=I.appendFrame(this._audioTrack,c,a,g,l);if(f)a+=f.length,l++;else break}else a++},p.parseID3PES=function(v){if(v.pts===void 0){b.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(v)},m}();A.minProbeByteLength=188;function S(m,p,_,v){return{key:m,frame:!1,pts:p,dts:_,units:[],debug:v,length:0}}function C(m,p){return(m[p+10]&31)<<8|m[p+11]}function d(m,p,_,v){var c={audio:-1,avc:-1,id3:-1,isAAC:!0},h=(m[p+1]&15)<<8|m[p+2],l=p+3+h-4,a=(m[p+10]&15)<<8|m[p+11];for(p+=12+a;p<l;){var g=(m[p+1]&31)<<8|m[p+2];switch(m[p]){case 207:if(!v){b.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=g);break;case 21:c.id3===-1&&(c.id3=g);break;case 219:if(!v){b.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=g);break;case 3:case 4:_?c.audio===-1&&(c.audio=g,c.isAAC=!1):b.logger.log("MPEG audio found, not supported in this browser");break;case 36:b.logger.warn("Unsupported HEVC stream type found");break;default:break}p+=((m[p+3]&15)<<8|m[p+4])+5}return c}function o(m){var p=0,_,v,c,h,l,a=m.data;if(!m||m.size===0)return null;for(;a[0].length<19&&a.length>1;){var g=new Uint8Array(a[0].length+a[1].length);g.set(a[0]),g.set(a[1],a[0].length),a[0]=g,a.splice(1,1)}_=a[0];var f=(_[0]<<16)+(_[1]<<8)+_[2];if(f===1){if(v=(_[4]<<8)+_[5],v&&v>m.size-6)return null;var x=_[7];x&192&&(h=(_[9]&14)*536870912+(_[10]&255)*4194304+(_[11]&254)*16384+(_[12]&255)*128+(_[13]&254)/2,x&64?(l=(_[14]&14)*536870912+(_[15]&255)*4194304+(_[16]&254)*16384+(_[17]&255)*128+(_[18]&254)/2,h-l>60*9e4&&(b.logger.warn(Math.round((h-l)/9e4)+"s delta between PTS and DTS, align them"),h=l)):l=h),c=_[8];var P=c+9;if(m.size<=P)return null;m.size-=P;for(var G=new Uint8Array(m.size),X=0,ie=a.length;X<ie;X++){_=a[X];var z=_.byteLength;if(P)if(P>z){P-=z;continue}else _=_.subarray(P),z-=P,P=0;G.set(_,p),p+=z}return v&&(v-=c+3),{data:G,pts:h,dts:l,len:v}}return null}function s(m,p){if(m.units.length&&m.frame){if(m.pts===void 0){var _=p.samples,v=_.length;if(v){var c=_[v-1];m.pts=c.pts,m.dts=c.dts}else{p.dropped++;return}}p.samples.push(m)}m.debug.length&&b.logger.log(m.pts+"/"+m.dts+":"+m.debug)}function u(m,p){var _=m.length;if(_>0){if(p.pts>=m[_-1].pts)m.push(p);else for(var v=_-1;v>=0;v--)if(p.pts<m[v].pts){m.splice(v,0,p);break}}else m.push(p)}function T(m){for(var p=m.byteLength,_=[],v=1;v<p-2;)m[v]===0&&m[v+1]===0&&m[v+2]===3?(_.push(v+2),v+=2):v++;if(_.length===0)return m;var c=p-_.length,h=new Uint8Array(c),l=0;for(v=0;v<c;l++,v++)l===_[0]&&(l++,_.shift()),h[v]=m[l];return h}Q.default=A},"./src/errors.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"ErrorTypes",function(){return V}),D.d(Q,"ErrorDetails",function(){return I});var V;(function(y){y.NETWORK_ERROR="networkError",y.MEDIA_ERROR="mediaError",y.KEY_SYSTEM_ERROR="keySystemError",y.MUX_ERROR="muxError",y.OTHER_ERROR="otherError"})(V||(V={}));var I;(function(y){y.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",y.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",y.KEY_SYSTEM_NO_SESSION="keySystemNoSession",y.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",y.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",y.MANIFEST_LOAD_ERROR="manifestLoadError",y.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",y.MANIFEST_PARSING_ERROR="manifestParsingError",y.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",y.LEVEL_EMPTY_ERROR="levelEmptyError",y.LEVEL_LOAD_ERROR="levelLoadError",y.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",y.LEVEL_SWITCH_ERROR="levelSwitchError",y.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",y.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",y.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",y.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",y.FRAG_LOAD_ERROR="fragLoadError",y.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",y.FRAG_DECRYPT_ERROR="fragDecryptError",y.FRAG_PARSING_ERROR="fragParsingError",y.REMUX_ALLOC_ERROR="remuxAllocError",y.KEY_LOAD_ERROR="keyLoadError",y.KEY_LOAD_TIMEOUT="keyLoadTimeOut",y.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",y.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",y.BUFFER_APPEND_ERROR="bufferAppendError",y.BUFFER_APPENDING_ERROR="bufferAppendingError",y.BUFFER_STALLED_ERROR="bufferStalledError",y.BUFFER_FULL_ERROR="bufferFullError",y.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",y.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",y.INTERNAL_EXCEPTION="internalException",y.INTERNAL_ABORTED="aborted",y.UNKNOWN="unknown"})(I||(I={}))},"./src/events.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"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(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return m});var V=D("./node_modules/url-toolkit/src/url-toolkit.js"),I=D.n(V),y=D("./src/loader/playlist-loader.ts"),j=D("./src/loader/key-loader.ts"),B=D("./src/controller/id3-track-controller.ts"),M=D("./src/controller/latency-controller.ts"),R=D("./src/controller/level-controller.ts"),b=D("./src/controller/fragment-tracker.ts"),w=D("./src/controller/stream-controller.ts"),O=D("./src/is-supported.ts"),A=D("./src/utils/logger.ts"),S=D("./src/config.ts"),C=D("./node_modules/eventemitter3/index.js"),d=D.n(C),o=D("./src/events.ts"),s=D("./src/errors.ts");function u(p,_){for(var v=0;v<_.length;v++){var c=_[v];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(p,c.key,c)}}function T(p,_,v){return _&&u(p.prototype,_),v&&u(p,v),p}var m=function(){p.isSupported=function(){return Object(O.isSupported)()};function p(v){v===void 0&&(v={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new C.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var c=this.config=Object(S.mergeConfig)(p.DefaultConfig,v);this.userConfig=v,Object(A.enableLogs)(c.debug),this._autoLevelCapping=-1,c.progressive&&Object(S.enableStreamingMode)(c);var h=c.abrController,l=c.bufferController,a=c.capLevelController,g=c.fpsController,f=this.abrController=new h(this),x=this.bufferController=new l(this),P=this.capLevelController=new a(this),G=new g(this),X=new y.default(this),ie=new j.default(this),z=new B.default(this),F=this.levelController=new R.default(this),ne=new b.FragmentTracker(this),ce=this.streamController=new w.default(this,ne);P.setStreamController(ce),G.setStreamController(ce);var ge=[F,ce];this.networkControllers=ge;var be=[X,ie,f,x,P,G,z,ne];this.audioTrackController=this.createController(c.audioTrackController,null,ge),this.createController(c.audioStreamController,ne,ge),this.subtitleTrackController=this.createController(c.subtitleTrackController,null,ge),this.createController(c.subtitleStreamController,ne,ge),this.createController(c.timelineController,null,be),this.emeController=this.createController(c.emeController,null,be),this.cmcdController=this.createController(c.cmcdController,null,be),this.latencyController=this.createController(M.default,null,be),this.coreComponents=be}var _=p.prototype;return _.createController=function(c,h,l){if(c){var a=h?new c(this,h):new c(this);return l&&l.push(a),a}return null},_.on=function(c,h,l){l===void 0&&(l=this),this._emitter.on(c,h,l)},_.once=function(c,h,l){l===void 0&&(l=this),this._emitter.once(c,h,l)},_.removeAllListeners=function(c){this._emitter.removeAllListeners(c)},_.off=function(c,h,l,a){l===void 0&&(l=this),this._emitter.off(c,h,l,a)},_.listeners=function(c){return this._emitter.listeners(c)},_.emit=function(c,h,l){return this._emitter.emit(c,h,l)},_.trigger=function(c,h){if(this.config.debug)return this.emit(c,c,h);try{return this.emit(c,c,h)}catch(l){A.logger.error("An internal error happened while handling event "+c+'. Error message: "'+l.message+'". Here is a stacktrace:',l),this.trigger(o.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:c,error:l})}return!1},_.listenerCount=function(c){return this._emitter.listenerCount(c)},_.destroy=function(){A.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(c){return c.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(c){return c.destroy()}),this.coreComponents.length=0},_.attachMedia=function(c){A.logger.log("attachMedia"),this._media=c,this.trigger(o.Events.MEDIA_ATTACHING,{media:c})},_.detachMedia=function(){A.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},_.loadSource=function(c){this.stopLoad();var h=this.media,l=this.url,a=this.url=V.buildAbsoluteURL(self.location.href,c,{alwaysNormalize:!0});A.logger.log("loadSource:"+a),h&&l&&l!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(h)),this.trigger(o.Events.MANIFEST_LOADING,{url:c})},_.startLoad=function(c){c===void 0&&(c=-1),A.logger.log("startLoad("+c+")"),this.networkControllers.forEach(function(h){h.startLoad(c)})},_.stopLoad=function(){A.logger.log("stopLoad"),this.networkControllers.forEach(function(c){c.stopLoad()})},_.swapAudioCodec=function(){A.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},_.recoverMediaError=function(){A.logger.log("recoverMediaError");var c=this._media;this.detachMedia(),c&&this.attachMedia(c)},_.removeLevel=function(c,h){h===void 0&&(h=0),this.levelController.removeLevel(c,h)},T(p,[{key:"levels",get:function(){var c=this.levelController.levels;return c||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(c){A.logger.log("set currentLevel:"+c),this.loadLevel=c,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(c){A.logger.log("set nextLevel:"+c),this.levelController.manualLevel=c,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(c){A.logger.log("set loadLevel:"+c),this.levelController.manualLevel=c}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(c){this.levelController.nextLoadLevel=c}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(c){A.logger.log("set firstLevel:"+c),this.levelController.firstLevel=c}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(c){A.logger.log("set startLevel:"+c),c!==-1&&(c=Math.max(c,this.minAutoLevel)),this.levelController.startLevel=c}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(c){var h=!!c;h!==this.config.capLevelToPlayerSize&&(h?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=h)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(c){this._autoLevelCapping!==c&&(A.logger.log("set autoLevelCapping:"+c),this._autoLevelCapping=c)}},{key:"bandwidthEstimate",get:function(){var c=this.abrController.bwEstimator;return c?c.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var c=this.levels,h=this.config.minAutoBitrate;if(!c)return 0;for(var l=c.length,a=0;a<l;a++)if(c[a].maxBitrate>h)return a;return 0}},{key:"maxAutoLevel",get:function(){var c=this.levels,h=this.autoLevelCapping,l;return h===-1&&c&&c.length?l=c.length-1:l=h,l}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(c){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,c)}},{key:"audioTracks",get:function(){var c=this.audioTrackController;return c?c.audioTracks:[]}},{key:"audioTrack",get:function(){var c=this.audioTrackController;return c?c.audioTrack:-1},set:function(c){var h=this.audioTrackController;h&&(h.audioTrack=c)}},{key:"subtitleTracks",get:function(){var c=this.subtitleTrackController;return c?c.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var c=this.subtitleTrackController;return c?c.subtitleTrack:-1},set:function(c){var h=this.subtitleTrackController;h&&(h.subtitleTrack=c)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var c=this.subtitleTrackController;return c?c.subtitleDisplay:!1},set:function(c){var h=this.subtitleTrackController;h&&(h.subtitleDisplay=c)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(c){this.config.lowLatencyMode=c}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return o.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return p.defaultConfig?p.defaultConfig:S.hlsDefaultConfig},set:function(c){p.defaultConfig=c}}]),p}();m.defaultConfig=void 0},"./src/is-supported.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"isSupported",function(){return y}),D.d(Q,"changeTypeSupported",function(){return j});var V=D("./src/utils/mediasource-helper.ts");function I(){return self.SourceBuffer||self.WebKitSourceBuffer}function y(){var B=Object(V.getMediaSource)();if(!B)return!1;var M=I(),R=B&&typeof B.isTypeSupported=="function"&&B.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),b=!M||M.prototype&&typeof M.prototype.appendBuffer=="function"&&typeof M.prototype.remove=="function";return!!R&&!!b}function j(){var B,M=I();return typeof(M==null||((B=M.prototype)===null||B===void 0)?void 0:B.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return A}),D.d(Q,"LoadError",function(){return C});var V=D("./src/polyfills/number.ts"),I=D("./src/errors.ts");function y(d,o){d.prototype=Object.create(o.prototype),d.prototype.constructor=d,b(d,o)}function j(d){var o=typeof Map=="function"?new Map:void 0;return j=function(u){if(u===null||!R(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(u))return o.get(u);o.set(u,T)}function T(){return B(u,arguments,w(this).constructor)}return T.prototype=Object.create(u.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),b(T,u)},j(d)}function B(d,o,s){return M()?B=Reflect.construct:B=function(T,m,p){var _=[null];_.push.apply(_,m);var v=Function.bind.apply(T,_),c=new v;return p&&b(c,p.prototype),c},B.apply(null,arguments)}function M(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(d){return!1}}function R(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function b(d,o){return b=Object.setPrototypeOf||function(u,T){return u.__proto__=T,u},b(d,o)}function w(d){return w=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},w(d)}var O=Math.pow(2,17),A=function(){function d(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var o=d.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(u,T){var m=this,p=u.url;if(!p)return Promise.reject(new C({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,networkDetails:null},"Fragment does not have a "+(p?"part list":"url")));this.abort();var _=this.config,v=_.fLoader,c=_.loader;return new Promise(function(h,l){m.loader&&m.loader.destroy();var a=m.loader=u.loader=v?new v(_):new c(_),g=S(u),f={timeout:_.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:_.fragLoadingMaxRetryTimeout,highWaterMark:O};u.stats=a.stats,a.load(g,f,{onSuccess:function(P,G,X,ie){m.resetLoader(u,a),h({frag:u,part:null,payload:P.data,networkDetails:ie})},onError:function(P,G,X){m.resetLoader(u,a),l(new C({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,response:P,networkDetails:X}))},onAbort:function(P,G,X){m.resetLoader(u,a),l(new C({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:u,networkDetails:X}))},onTimeout:function(P,G,X){m.resetLoader(u,a),l(new C({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:u,networkDetails:X}))},onProgress:function(P,G,X,ie){T&&T({frag:u,part:null,payload:X,networkDetails:ie})}})})},o.loadPart=function(u,T,m){var p=this;this.abort();var _=this.config,v=_.fLoader,c=_.loader;return new Promise(function(h,l){p.loader&&p.loader.destroy();var a=p.loader=u.loader=v?new v(_):new c(_),g=S(u,T),f={timeout:_.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:_.fragLoadingMaxRetryTimeout,highWaterMark:O};T.stats=a.stats,a.load(g,f,{onSuccess:function(P,G,X,ie){p.resetLoader(u,a),p.updateStatsFromPart(u,T);var z={frag:u,part:T,payload:P.data,networkDetails:ie};m(z),h(z)},onError:function(P,G,X){p.resetLoader(u,a),l(new C({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,part:T,response:P,networkDetails:X}))},onAbort:function(P,G,X){u.stats.aborted=T.stats.aborted,p.resetLoader(u,a),l(new C({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:u,part:T,networkDetails:X}))},onTimeout:function(P,G,X){p.resetLoader(u,a),l(new C({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:u,part:T,networkDetails:X}))}})})},o.updateStatsFromPart=function(u,T){var m=u.stats,p=T.stats,_=p.total;if(m.loaded+=p.loaded,_){var v=Math.round(u.duration/T.duration),c=Math.min(Math.round(m.loaded/_),v),h=v-c,l=h*Math.round(m.loaded/c);m.total=m.loaded+l}else m.total=Math.max(m.loaded,m.total);var a=m.loading,g=p.loading;a.start?a.first+=g.first-g.start:(a.start=g.start,a.first=g.first),a.end=g.end},o.resetLoader=function(u,T){u.loader=null,this.loader===T&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),T.destroy()},d}();function S(d,o){o===void 0&&(o=null);var s=o||d,u={frag:d,part:o,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},T=s.byteRangeStartOffset,m=s.byteRangeEndOffset;return Object(V.isFiniteNumber)(T)&&Object(V.isFiniteNumber)(m)&&(u.rangeStart=T,u.rangeEnd=m),u}var C=function(d){y(o,d);function o(s){for(var u,T=arguments.length,m=new Array(T>1?T-1:0),p=1;p<T;p++)m[p-1]=arguments[p];return u=d.call.apply(d,[this].concat(m))||this,u.data=void 0,u.data=s,u}return o}(j(Error))},"./src/loader/fragment.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"ElementaryStreamTypes",function(){return A}),D.d(Q,"BaseSegment",function(){return S}),D.d(Q,"Fragment",function(){return C}),D.d(Q,"Part",function(){return d});var V=D("./src/polyfills/number.ts"),I=D("./node_modules/url-toolkit/src/url-toolkit.js"),y=D.n(I),j=D("./src/utils/logger.ts"),B=D("./src/loader/level-key.ts"),M=D("./src/loader/load-stats.ts");function R(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,b(o,s)}function b(o,s){return b=Object.setPrototypeOf||function(T,m){return T.__proto__=m,T},b(o,s)}function w(o,s){for(var u=0;u<s.length;u++){var T=s[u];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(o,T.key,T)}}function O(o,s,u){return s&&w(o.prototype,s),u&&w(o,u),o}var A;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(A||(A={}));var S=function(){function o(u){var T;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(T={},T[A.AUDIO]=null,T[A.VIDEO]=null,T[A.AUDIOVIDEO]=null,T),this.baseurl=u}var s=o.prototype;return s.setByteRange=function(T,m){var p=T.split("@",2),_=[];p.length===1?_[0]=m?m.byteRangeEndOffset:0:_[0]=parseInt(p[1]),_[1]=parseInt(p[0])+_[0],this._byteRange=_},O(o,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(I.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(T){this._url=T}}]),o}(),C=function(o){R(s,o);function s(T,m){var p;return p=o.call(this,m)||this,p._decryptdata=null,p.rawProgramDateTime=null,p.programDateTime=null,p.tagList=[],p.duration=0,p.sn=0,p.levelkey=void 0,p.type=void 0,p.loader=null,p.level=-1,p.cc=0,p.startPTS=void 0,p.endPTS=void 0,p.appendedPTS=void 0,p.startDTS=void 0,p.endDTS=void 0,p.start=0,p.deltaPTS=void 0,p.maxStartPTS=void 0,p.minEndPTS=void 0,p.stats=new M.LoadStats,p.urlId=0,p.data=void 0,p.bitrateTest=!1,p.title=null,p.initSegment=null,p.type=T,p}var u=s.prototype;return u.createInitializationVector=function(m){for(var p=new Uint8Array(16),_=12;_<16;_++)p[_]=m>>8*(15-_)&255;return p},u.setDecryptDataFromLevelKey=function(m,p){var _=m;return(m==null?void 0:m.method)==="AES-128"&&m.uri&&!m.iv&&(_=B.LevelKey.fromURI(m.uri),_.method=m.method,_.iv=this.createInitializationVector(p),_.keyFormat="identity"),_},u.setElementaryStreamInfo=function(m,p,_,v,c,h){h===void 0&&(h=!1);var l=this.elementaryStreams,a=l[m];if(!a){l[m]={startPTS:p,endPTS:_,startDTS:v,endDTS:c,partial:h};return}a.startPTS=Math.min(a.startPTS,p),a.endPTS=Math.max(a.endPTS,_),a.startDTS=Math.min(a.startDTS,v),a.endDTS=Math.max(a.endDTS,c)},u.clearElementaryStreamInfo=function(){var m=this.elementaryStreams;m[A.AUDIO]=null,m[A.VIDEO]=null,m[A.AUDIOVIDEO]=null},O(s,[{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&&j.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)}}]),s}(S),d=function(o){R(s,o);function s(u,T,m,p,_){var v;v=o.call(this,m)||this,v.fragOffset=0,v.duration=0,v.gap=!1,v.independent=!1,v.relurl=void 0,v.fragment=void 0,v.index=void 0,v.stats=new M.LoadStats,v.duration=u.decimalFloatingPoint("DURATION"),v.gap=u.bool("GAP"),v.independent=u.bool("INDEPENDENT"),v.relurl=u.enumeratedString("URI"),v.fragment=T,v.index=p;var c=u.enumeratedString("BYTERANGE");return c&&v.setByteRange(c,_),_&&(v.fragOffset=_.fragOffset+_.duration),v}return O(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var T=this.elementaryStreams;return!!(T.audio||T.video||T.audiovideo)}}]),s}(S)},"./src/loader/key-loader.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return j});var V=D("./src/events.ts"),I=D("./src/errors.ts"),y=D("./src/utils/logger.ts"),j=function(){function B(R){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=R,this._registerListeners()}var M=B.prototype;return M._registerListeners=function(){this.hls.on(V.Events.KEY_LOADING,this.onKeyLoading,this)},M._unregisterListeners=function(){this.hls.off(V.Events.KEY_LOADING,this.onKeyLoading)},M.destroy=function(){this._unregisterListeners();for(var b in this.loaders){var w=this.loaders[b];w&&w.destroy()}this.loaders={}},M.onKeyLoading=function(b,w){var O=w.frag,A=O.type,S=this.loaders[A];if(!O.decryptdata){y.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var C=O.decryptdata.uri;if(C!==this.decrypturl||this.decryptkey===null){var d=this.hls.config;if(S&&(y.logger.warn("abort previous key loader for type:"+A),S.abort()),!C){y.logger.warn("key uri is falsy");return}var o=d.loader,s=O.loader=this.loaders[A]=new o(d);this.decrypturl=C,this.decryptkey=null;var u={url:C,frag:O,responseType:"arraybuffer"},T={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:d.fragLoadingRetryDelay,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(u,T,m)}else this.decryptkey&&(O.decryptdata.key=this.decryptkey,this.hls.trigger(V.Events.KEY_LOADED,{frag:O}))},M.loadsuccess=function(b,w,O){var A=O.frag;if(!A.decryptdata){y.logger.error("after key load, decryptdata unset");return}this.decryptkey=A.decryptdata.key=new Uint8Array(b.data),A.loader=null,delete this.loaders[A.type],this.hls.trigger(V.Events.KEY_LOADED,{frag:A})},M.loaderror=function(b,w){var O=w.frag,A=O.loader;A&&A.abort(),delete this.loaders[O.type],this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:O,response:b})},M.loadtimeout=function(b,w){var O=w.frag,A=O.loader;A&&A.abort(),delete this.loaders[O.type],this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:O})},B}()},"./src/loader/level-details.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"LevelDetails",function(){return B});var V=D("./src/polyfills/number.ts");function I(M,R){for(var b=0;b<R.length;b++){var w=R[b];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(M,w.key,w)}}function y(M,R,b){return R&&I(M.prototype,R),b&&I(M,b),M}var j=10,B=function(){function M(b){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=b}var R=M.prototype;return R.reloaded=function(w){if(!w){this.advanced=!0,this.updated=!0;return}var O=this.lastPartSn-w.lastPartSn,A=this.lastPartIndex-w.lastPartIndex;this.updated=this.endSN!==w.endSN||!!A||!!O,this.advanced=this.endSN>w.endSN||O>0||O===0&&A>0,this.updated||this.advanced?this.misses=Math.floor(w.misses*.6):this.misses=w.misses+1,this.availabilityDelay=w.availabilityDelay},y(M,[{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||j}},{key:"drift",get:function(){var w=this.driftEndTime-this.driftStartTime;if(w>0){var O=this.driftEnd-this.driftStart;return O*1e3/w}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var w;return(w=this.partList)!==null&&w!==void 0&&w.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var w;return(w=this.fragments)!==null&&w!==void 0&&w.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 w;return(w=this.partList)!==null&&w!==void 0&&w.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var w;return(w=this.partList)!==null&&w!==void 0&&w.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),M}()},"./src/loader/level-key.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"LevelKey",function(){return B});var V=D("./node_modules/url-toolkit/src/url-toolkit.js"),I=D.n(V);function y(M,R){for(var b=0;b<R.length;b++){var w=R[b];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(M,w.key,w)}}function j(M,R,b){return R&&y(M.prototype,R),b&&y(M,b),M}var B=function(){M.fromURL=function(b,w){return new M(b,w)},M.fromURI=function(b){return new M(b)};function M(R,b){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,b?this._uri=Object(V.buildAbsoluteURL)(R,b,{alwaysNormalize:!0}):this._uri=R}return j(M,[{key:"uri",get:function(){return this._uri}}]),M}()},"./src/loader/load-stats.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"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(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return s});var V=D("./src/polyfills/number.ts"),I=D("./node_modules/url-toolkit/src/url-toolkit.js"),y=D.n(I),j=D("./src/loader/fragment.ts"),B=D("./src/loader/level-details.ts"),M=D("./src/loader/level-key.ts"),R=D("./src/utils/attr-list.ts"),b=D("./src/utils/logger.ts"),w=D("./src/utils/codecs.ts"),O=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,A=/#EXT-X-MEDIA:(.*)/g,S=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),C=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),d=/\.(mp4|m4s|m4v|m4a)$/i;function o(_){var v,c;return d.test((v=(c=I.parseURL(_))===null||c===void 0?void 0:c.path)!=null?v:"")}var s=function(){function _(){}return _.findGroup=function(c,h){for(var l=0;l<c.length;l++){var a=c[l];if(a.id===h)return a}},_.convertAVC1ToAVCOTI=function(c){var h=c.split(".");if(h.length>2){var l=h.shift()+".";return l+=parseInt(h.shift()).toString(16),l+=("000"+parseInt(h.shift()).toString(16)).substr(-4),l}return c},_.resolve=function(c,h){return I.buildAbsoluteURL(h,c,{alwaysNormalize:!0})},_.parseMasterPlaylist=function(c,h){var l=[],a={},g=!1;O.lastIndex=0;for(var f;(f=O.exec(c))!=null;)if(f[1]){var x=new R.AttrList(f[1]),P={attrs:x,bitrate:x.decimalInteger("AVERAGE-BANDWIDTH")||x.decimalInteger("BANDWIDTH"),name:x.NAME,url:_.resolve(f[2],h)},G=x.decimalResolution("RESOLUTION");G&&(P.width=G.width,P.height=G.height),u((x.CODECS||"").split(/[ ,]+/).filter(function(ie){return ie}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=_.convertAVC1ToAVCOTI(P.videoCodec)),l.push(P)}else if(f[3]){var X=new R.AttrList(f[3]);X["DATA-ID"]&&(g=!0,a[X["DATA-ID"]]=X)}return{levels:l,sessionData:g?a:null}},_.parseMasterPlaylistMedia=function(c,h,l,a){a===void 0&&(a=[]);var g,f=[],x=0;for(A.lastIndex=0;(g=A.exec(c))!==null;){var P=new R.AttrList(g[1]);if(P.TYPE===l){var G={attrs:P,bitrate:0,id:x++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:l,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?_.resolve(P.URI,h):""};if(a.length){var X=_.findGroup(a,G.groupId)||a[0];T(G,X,"audioCodec"),T(G,X,"textCodec")}f.push(G)}}return f},_.parseLevelPlaylist=function(c,h,l,a,g){var f=new B.LevelDetails(h),x=f.fragments,P=null,G=0,X=0,ie=0,z=0,F=null,ne=new j.Fragment(a,h),ce,ge,be,Ie=-1,Te=!1;for(S.lastIndex=0,f.m3u8=c;(ce=S.exec(c))!==null;){Te&&(Te=!1,ne=new j.Fragment(a,h),ne.start=ie,ne.sn=G,ne.cc=z,ne.level=l,P&&(ne.initSegment=P,ne.rawProgramDateTime=P.rawProgramDateTime));var De=ce[1];if(De){ne.duration=parseFloat(De);var we=(" "+ce[2]).slice(1);ne.title=we||null,ne.tagList.push(we?["INF",De,we]:["INF",De])}else if(ce[3])Object(V.isFiniteNumber)(ne.duration)&&(ne.start=ie,be&&(ne.levelkey=be),ne.sn=G,ne.level=l,ne.cc=z,ne.urlId=g,x.push(ne),ne.relurl=(" "+ce[3]).slice(1),p(ne,F),F=ne,ie+=ne.duration,G++,X=0,Te=!0);else if(ce[4]){var Ae=(" "+ce[4]).slice(1);F?ne.setByteRange(Ae,F):ne.setByteRange(Ae)}else if(ce[5])ne.rawProgramDateTime=(" "+ce[5]).slice(1),ne.tagList.push(["PROGRAM-DATE-TIME",ne.rawProgramDateTime]),Ie===-1&&(Ie=x.length);else{if(ce=ce[0].match(C),!ce){b.logger.warn("No matches on slow regex match for level playlist!");continue}for(ge=1;ge<ce.length&&!(typeof ce[ge]!="undefined");ge++);var ve=(" "+ce[ge]).slice(1),W=(" "+ce[ge+1]).slice(1),L=ce[ge+2]?(" "+ce[ge+2]).slice(1):"";switch(ve){case"PLAYLIST-TYPE":f.type=W.toUpperCase();break;case"MEDIA-SEQUENCE":G=f.startSN=parseInt(W);break;case"SKIP":{var k=new R.AttrList(W),H=k.decimalInteger("SKIPPED-SEGMENTS");if(Object(V.isFiniteNumber)(H)){f.skippedSegments=H;for(var ee=H;ee--;)x.unshift(null);G+=H}var U=k.enumeratedString("RECENTLY-REMOVED-DATERANGES");U&&(f.recentlyRemovedDateranges=U.split(" "));break}case"TARGETDURATION":f.targetduration=parseFloat(W);break;case"VERSION":f.version=parseInt(W);break;case"EXTM3U":break;case"ENDLIST":f.live=!1;break;case"#":(W||L)&&ne.tagList.push(L?[W,L]:[W]);break;case"DIS":z++;case"GAP":ne.tagList.push([ve]);break;case"BITRATE":ne.tagList.push([ve,W]);break;case"DISCONTINUITY-SEQ":z=parseInt(W);break;case"KEY":{var de,Ee=new R.AttrList(W),_e=Ee.enumeratedString("METHOD"),Ue=Ee.URI,ke=Ee.hexadecimalInteger("IV"),Oe=Ee.enumeratedString("KEYFORMATVERSIONS"),Pe=Ee.enumeratedString("KEYID"),Xe=(de=Ee.enumeratedString("KEYFORMAT"))!=null?de:"identity",Fe=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Fe.indexOf(Xe)>-1){b.logger.warn("Keyformat "+Xe+" is not supported from the manifest");continue}else if(Xe!=="identity")continue;_e&&(be=M.LevelKey.fromURL(h,Ue),Ue&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(_e)>=0&&(be.method=_e,be.keyFormat=Xe,Pe&&(be.keyID=Pe),Oe&&(be.keyFormatVersions=Oe),be.iv=ke));break}case"START":{var Ne=new R.AttrList(W),We=Ne.decimalFloatingPoint("TIME-OFFSET");Object(V.isFiniteNumber)(We)&&(f.startTimeOffset=We);break}case"MAP":{var Ze=new R.AttrList(W);ne.relurl=Ze.URI,Ze.BYTERANGE&&ne.setByteRange(Ze.BYTERANGE),ne.level=l,ne.sn="initSegment",be&&(ne.levelkey=be),ne.initSegment=null,P=ne,Te=!0;break}case"SERVER-CONTROL":{var He=new R.AttrList(W);f.canBlockReload=He.bool("CAN-BLOCK-RELOAD"),f.canSkipUntil=He.optionalFloat("CAN-SKIP-UNTIL",0),f.canSkipDateRanges=f.canSkipUntil>0&&He.bool("CAN-SKIP-DATERANGES"),f.partHoldBack=He.optionalFloat("PART-HOLD-BACK",0),f.holdBack=He.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Ye=new R.AttrList(W);f.partTarget=Ye.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ce=f.partList;Ce||(Ce=f.partList=[]);var $e=X>0?Ce[Ce.length-1]:void 0,qe=X++,ae=new j.Part(new R.AttrList(W),ne,h,qe,$e);Ce.push(ae),ne.duration+=ae.duration;break}case"PRELOAD-HINT":{var J=new R.AttrList(W);f.preloadHint=J;break}case"RENDITION-REPORT":{var $=new R.AttrList(W);f.renditionReports=f.renditionReports||[],f.renditionReports.push($);break}default:b.logger.warn("line parsed but not handled: "+ce);break}}}F&&!F.relurl?(x.pop(),ie-=F.duration,f.partList&&(f.fragmentHint=F)):f.partList&&(p(ne,F),ne.cc=z,f.fragmentHint=ne);var re=x.length,oe=x[0],q=x[re-1];if(ie+=f.skippedSegments*f.targetduration,ie>0&&re&&q){f.averagetargetduration=ie/re;var Z=q.sn;f.endSN=Z!=="initSegment"?Z:0,oe&&(f.startCC=oe.cc,oe.initSegment||f.fragments.every(function(se){return se.relurl&&o(se.relurl)})&&(b.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),ne=new j.Fragment(a,h),ne.relurl=q.relurl,ne.level=l,ne.sn="initSegment",oe.initSegment=ne,f.needSidxRanges=!0))}else f.endSN=0,f.startCC=0;return f.fragmentHint&&(ie+=f.fragmentHint.duration),f.totalduration=ie,f.endCC=z,Ie>0&&m(x,Ie),f},_}();function u(_,v){["video","audio","text"].forEach(function(c){var h=_.filter(function(a){return Object(w.isCodecType)(a,c)});if(h.length){var l=h.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});v[c+"Codec"]=l.length>0?l[0]:h[0],_=_.filter(function(a){return h.indexOf(a)===-1})}}),v.unknownCodecs=_}function T(_,v,c){var h=v[c];h&&(_[c]=h)}function m(_,v){for(var c=_[v],h=v;h--;){var l=_[h];if(!l)return;l.programDateTime=c.programDateTime-l.duration*1e3,c=l}}function p(_,v){_.rawProgramDateTime?_.programDateTime=Date.parse(_.rawProgramDateTime):v!=null&&v.programDateTime&&(_.programDateTime=v.endProgramDateTime),Object(V.isFiniteNumber)(_.programDateTime)||(_.programDateTime=null,_.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/polyfills/number.ts"),I=D("./src/events.ts"),y=D("./src/errors.ts"),j=D("./src/utils/logger.ts"),B=D("./src/utils/mp4-tools.ts"),M=D("./src/loader/m3u8-parser.ts"),R=D("./src/types/loader.ts"),b=D("./src/utils/attr-list.ts");function w(S){var C=S.type;switch(C){case R.PlaylistContextType.AUDIO_TRACK:return R.PlaylistLevelType.AUDIO;case R.PlaylistContextType.SUBTITLE_TRACK:return R.PlaylistLevelType.SUBTITLE;default:return R.PlaylistLevelType.MAIN}}function O(S,C){var d=S.url;return(d===void 0||d.indexOf("data:")===0)&&(d=C.url),d}var A=function(){function S(d){this.hls=void 0,this.loaders=Object.create(null),this.hls=d,this.registerListeners()}var C=S.prototype;return C.registerListeners=function(){var o=this.hls;o.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},C.unregisterListeners=function(){var o=this.hls;o.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(I.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},C.createInternalLoader=function(o){var s=this.hls.config,u=s.pLoader,T=s.loader,m=u||T,p=new m(s);return o.loader=p,this.loaders[o.type]=p,p},C.getInternalLoader=function(o){return this.loaders[o.type]},C.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},C.destroyInternalLoaders=function(){for(var o in this.loaders){var s=this.loaders[o];s&&s.destroy(),this.resetInternalLoader(o)}},C.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},C.onManifestLoading=function(o,s){var u=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:R.PlaylistContextType.MANIFEST,url:u,deliveryDirectives:null})},C.onLevelLoading=function(o,s){var u=s.id,T=s.level,m=s.url,p=s.deliveryDirectives;this.load({id:u,groupId:null,level:T,responseType:"text",type:R.PlaylistContextType.LEVEL,url:m,deliveryDirectives:p})},C.onAudioTrackLoading=function(o,s){var u=s.id,T=s.groupId,m=s.url,p=s.deliveryDirectives;this.load({id:u,groupId:T,level:null,responseType:"text",type:R.PlaylistContextType.AUDIO_TRACK,url:m,deliveryDirectives:p})},C.onSubtitleTrackLoading=function(o,s){var u=s.id,T=s.groupId,m=s.url,p=s.deliveryDirectives;this.load({id:u,groupId:T,level:null,responseType:"text",type:R.PlaylistContextType.SUBTITLE_TRACK,url:m,deliveryDirectives:p})},C.load=function(o){var s,u=this.hls.config,T=this.getInternalLoader(o);if(T){var m=T.context;if(m&&m.url===o.url){j.logger.trace("[playlist-loader]: playlist request ongoing");return}j.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),T.abort()}var p,_,v,c;switch(o.type){case R.PlaylistContextType.MANIFEST:p=u.manifestLoadingMaxRetry,_=u.manifestLoadingTimeOut,v=u.manifestLoadingRetryDelay,c=u.manifestLoadingMaxRetryTimeout;break;case R.PlaylistContextType.LEVEL:case R.PlaylistContextType.AUDIO_TRACK:case R.PlaylistContextType.SUBTITLE_TRACK:p=0,_=u.levelLoadingTimeOut;break;default:p=u.levelLoadingMaxRetry,_=u.levelLoadingTimeOut,v=u.levelLoadingRetryDelay,c=u.levelLoadingMaxRetryTimeout;break}if(T=this.createInternalLoader(o),(s=o.deliveryDirectives)!==null&&s!==void 0&&s.part){var h;if(o.type===R.PlaylistContextType.LEVEL&&o.level!==null?h=this.hls.levels[o.level].details:o.type===R.PlaylistContextType.AUDIO_TRACK&&o.id!==null?h=this.hls.audioTracks[o.id].details:o.type===R.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(h=this.hls.subtitleTracks[o.id].details),h){var l=h.partTarget,a=h.targetduration;l&&a&&(_=Math.min(Math.max(l*3,a*.8)*1e3,_))}}var g={timeout:_,maxRetry:p,retryDelay:v,maxRetryDelay:c,highWaterMark:0},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};T.load(o,g,f)},C.loadsuccess=function(o,s,u,T){if(T===void 0&&(T=null),u.isSidxRequest){this.handleSidxRequest(o,u),this.handlePlaylistLoaded(o,s,u,T);return}this.resetInternalLoader(u.type);var m=o.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,u,"no EXTM3U delimiter",T);return}s.parsing.start=performance.now(),m.indexOf("#EXTINF:")>0||m.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,s,u,T):this.handleMasterPlaylist(o,s,u,T)},C.loaderror=function(o,s,u){u===void 0&&(u=null),this.handleNetworkError(s,u,!1,o)},C.loadtimeout=function(o,s,u){u===void 0&&(u=null),this.handleNetworkError(s,u,!0)},C.handleMasterPlaylist=function(o,s,u,T){var m=this.hls,p=o.data,_=O(o,u),v=M.default.parseMasterPlaylist(p,_),c=v.levels,h=v.sessionData;if(!c.length){this.handleManifestParsingError(o,u,"no level found in manifest",T);return}var l=c.map(function(G){return{id:G.attrs.AUDIO,audioCodec:G.audioCodec}}),a=c.map(function(G){return{id:G.attrs.SUBTITLES,textCodec:G.textCodec}}),g=M.default.parseMasterPlaylistMedia(p,_,"AUDIO",l),f=M.default.parseMasterPlaylistMedia(p,_,"SUBTITLES",a),x=M.default.parseMasterPlaylistMedia(p,_,"CLOSED-CAPTIONS");if(g.length){var P=g.some(function(G){return!G.url});!P&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(j.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new b.AttrList({}),bitrate:0,url:""}))}m.trigger(I.Events.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:f,captions:x,url:_,stats:s,networkDetails:T,sessionData:h})},C.handleTrackOrLevelPlaylist=function(o,s,u,T){var m=this.hls,p=u.id,_=u.level,v=u.type,c=O(o,u),h=Object(V.isFiniteNumber)(p)?p:0,l=Object(V.isFiniteNumber)(_)?_:h,a=w(u),g=M.default.parseLevelPlaylist(o.data,c,l,a,h);if(!g.fragments.length){m.trigger(I.Events.ERROR,{type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:c,reason:"no fragments found in level",level:typeof u.level=="number"?u.level:void 0});return}if(v===R.PlaylistContextType.MANIFEST){var f={attrs:new b.AttrList({}),bitrate:0,details:g,name:"",url:c};m.trigger(I.Events.MANIFEST_LOADED,{levels:[f],audioTracks:[],url:c,stats:s,networkDetails:T,sessionData:null})}if(s.parsing.end=performance.now(),g.needSidxRanges){var x,P=(x=g.fragments[0].initSegment)===null||x===void 0?void 0:x.url;this.load({url:P,isSidxRequest:!0,type:v,level:_,levelDetails:g,id:p,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}u.levelDetails=g,this.handlePlaylistLoaded(o,s,u,T)},C.handleSidxRequest=function(o,s){var u=Object(B.parseSegmentIndex)(new Uint8Array(o.data));if(!u)return;var T=u.references,m=s.levelDetails;T.forEach(function(p,_){var v=p.info,c=m.fragments[_];c.byteRange.length===0&&c.setByteRange(String(1+v.end-v.start)+"@"+String(v.start)),c.initSegment&&c.initSegment.setByteRange(String(u.moovEndOffset)+"@0")})},C.handleManifestParsingError=function(o,s,u,T){this.hls.trigger(I.Events.ERROR,{type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===R.PlaylistContextType.MANIFEST,url:o.url,reason:u,response:o,context:s,networkDetails:T})},C.handleNetworkError=function(o,s,u,T){u===void 0&&(u=!1),j.logger.warn("[playlist-loader]: A network "+(u?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var m=y.ErrorDetails.UNKNOWN,p=!1,_=this.getInternalLoader(o);switch(o.type){case R.PlaylistContextType.MANIFEST:m=u?y.ErrorDetails.MANIFEST_LOAD_TIMEOUT:y.ErrorDetails.MANIFEST_LOAD_ERROR,p=!0;break;case R.PlaylistContextType.LEVEL:m=u?y.ErrorDetails.LEVEL_LOAD_TIMEOUT:y.ErrorDetails.LEVEL_LOAD_ERROR,p=!1;break;case R.PlaylistContextType.AUDIO_TRACK:m=u?y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case R.PlaylistContextType.SUBTITLE_TRACK:m=u?y.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:y.ErrorDetails.SUBTITLE_LOAD_ERROR,p=!1;break}_&&this.resetInternalLoader(o.type);var v={type:y.ErrorTypes.NETWORK_ERROR,details:m,fatal:p,url:o.url,loader:_,context:o,networkDetails:s};T&&(v.response=T),this.hls.trigger(I.Events.ERROR,v)},C.handlePlaylistLoaded=function(o,s,u,T){var m=u.type,p=u.level,_=u.id,v=u.groupId,c=u.loader,h=u.levelDetails,l=u.deliveryDirectives;if(!(h!=null&&h.targetduration)){this.handleManifestParsingError(o,u,"invalid target duration",T);return}if(!c)return;h.live&&(c.getCacheAge&&(h.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(h.ageHeader))&&(h.ageHeader=0));switch(m){case R.PlaylistContextType.MANIFEST:case R.PlaylistContextType.LEVEL:this.hls.trigger(I.Events.LEVEL_LOADED,{details:h,level:p||0,id:_||0,stats:s,networkDetails:T,deliveryDirectives:l});break;case R.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(I.Events.AUDIO_TRACK_LOADED,{details:h,id:_||0,groupId:v||"",stats:s,networkDetails:T,deliveryDirectives:l});break;case R.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(I.Events.SUBTITLE_TRACK_LOADED,{details:h,id:_||0,groupId:v||"",stats:s,networkDetails:T,deliveryDirectives:l});break}},S}();Q.default=A},"./src/polyfills/number.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"isFiniteNumber",function(){return V}),D.d(Q,"MAX_SAFE_INTEGER",function(){return I});var V=Number.isFinite||function(y){return typeof y=="number"&&isFinite(y)},I=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(fe,Q,D){"use strict";D.r(Q);var V=function(){function I(){}return I.getSilentFrame=function(j,B){switch(j){case"mp4a.40.2":if(B===1)return new Uint8Array([0,200,0,128,35,128]);if(B===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(B===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(B===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(B===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(B===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(B===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(B===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(B===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}();Q.default=V},"./src/remux/mp4-generator.ts":function(fe,Q,D){"use strict";D.r(Q);var V=Math.pow(2,32)-1,I=function(){function y(){}return y.init=function(){y.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 B;for(B in y.types)y.types.hasOwnProperty(B)&&(y.types[B]=[B.charCodeAt(0),B.charCodeAt(1),B.charCodeAt(2),B.charCodeAt(3)]);var M=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),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]);y.HDLR_TYPES={video:M,audio:R};var b=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),w=new Uint8Array([0,0,0,0,0,0,0,0]);y.STTS=y.STSC=y.STCO=w,y.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),y.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),y.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),y.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var O=new Uint8Array([105,115,111,109]),A=new Uint8Array([97,118,99,49]),S=new Uint8Array([0,0,0,1]);y.FTYP=y.box(y.types.ftyp,O,S,O,A),y.DINF=y.box(y.types.dinf,y.box(y.types.dref,b))},y.box=function(B){for(var M=8,R=arguments.length,b=new Array(R>1?R-1:0),w=1;w<R;w++)b[w-1]=arguments[w];for(var O=b.length,A=O;O--;)M+=b[O].byteLength;var S=new Uint8Array(M);for(S[0]=M>>24&255,S[1]=M>>16&255,S[2]=M>>8&255,S[3]=M&255,S.set(B,4),O=0,M=8;O<A;O++)S.set(b[O],M),M+=b[O].byteLength;return S},y.hdlr=function(B){return y.box(y.types.hdlr,y.HDLR_TYPES[B])},y.mdat=function(B){return y.box(y.types.mdat,B)},y.mdhd=function(B,M){M*=B;var R=Math.floor(M/(V+1)),b=Math.floor(M%(V+1));return y.box(y.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,B>>24&255,B>>16&255,B>>8&255,B&255,R>>24,R>>16&255,R>>8&255,R&255,b>>24,b>>16&255,b>>8&255,b&255,85,196,0,0]))},y.mdia=function(B){return y.box(y.types.mdia,y.mdhd(B.timescale,B.duration),y.hdlr(B.type),y.minf(B))},y.mfhd=function(B){return y.box(y.types.mfhd,new Uint8Array([0,0,0,0,B>>24,B>>16&255,B>>8&255,B&255]))},y.minf=function(B){return B.type==="audio"?y.box(y.types.minf,y.box(y.types.smhd,y.SMHD),y.DINF,y.stbl(B)):y.box(y.types.minf,y.box(y.types.vmhd,y.VMHD),y.DINF,y.stbl(B))},y.moof=function(B,M,R){return y.box(y.types.moof,y.mfhd(B),y.traf(R,M))},y.moov=function(B){for(var M=B.length,R=[];M--;)R[M]=y.trak(B[M]);return y.box.apply(null,[y.types.moov,y.mvhd(B[0].timescale,B[0].duration)].concat(R).concat(y.mvex(B)))},y.mvex=function(B){for(var M=B.length,R=[];M--;)R[M]=y.trex(B[M]);return y.box.apply(null,[y.types.mvex].concat(R))},y.mvhd=function(B,M){M*=B;var R=Math.floor(M/(V+1)),b=Math.floor(M%(V+1)),w=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,B>>24&255,B>>16&255,B>>8&255,B&255,R>>24,R>>16&255,R>>8&255,R&255,b>>24,b>>16&255,b>>8&255,b&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 y.box(y.types.mvhd,w)},y.sdtp=function(B){var M=B.samples||[],R=new Uint8Array(4+M.length),b,w;for(b=0;b<M.length;b++)w=M[b].flags,R[b+4]=w.dependsOn<<4|w.isDependedOn<<2|w.hasRedundancy;return y.box(y.types.sdtp,R)},y.stbl=function(B){return y.box(y.types.stbl,y.stsd(B),y.box(y.types.stts,y.STTS),y.box(y.types.stsc,y.STSC),y.box(y.types.stsz,y.STSZ),y.box(y.types.stco,y.STCO))},y.avc1=function(B){var M=[],R=[],b,w,O;for(b=0;b<B.sps.length;b++)w=B.sps[b],O=w.byteLength,M.push(O>>>8&255),M.push(O&255),M=M.concat(Array.prototype.slice.call(w));for(b=0;b<B.pps.length;b++)w=B.pps[b],O=w.byteLength,R.push(O>>>8&255),R.push(O&255),R=R.concat(Array.prototype.slice.call(w));var A=y.box(y.types.avcC,new Uint8Array([1,M[3],M[4],M[5],252|3,224|B.sps.length].concat(M).concat([B.pps.length]).concat(R))),S=B.width,C=B.height,d=B.pixelRatio[0],o=B.pixelRatio[1];return y.box(y.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,S>>8&255,S&255,C>>8&255,C&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),A,y.box(y.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),y.box(y.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,o>>24,o>>16&255,o>>8&255,o&255])))},y.esds=function(B){var M=B.config.length;return new Uint8Array([0,0,0,0,3,23+M,0,1,0,4,15+M,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([M]).concat(B.config).concat([6,1,2]))},y.mp4a=function(B){var M=B.samplerate;return y.box(y.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,B.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]),y.box(y.types.esds,y.esds(B)))},y.mp3=function(B){var M=B.samplerate;return y.box(y.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,B.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]))},y.stsd=function(B){return B.type==="audio"?!B.isAAC&&B.codec==="mp3"?y.box(y.types.stsd,y.STSD,y.mp3(B)):y.box(y.types.stsd,y.STSD,y.mp4a(B)):y.box(y.types.stsd,y.STSD,y.avc1(B))},y.tkhd=function(B){var M=B.id,R=B.duration*B.timescale,b=B.width,w=B.height,O=Math.floor(R/(V+1)),A=Math.floor(R%(V+1));return y.box(y.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,M&255,0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,A>>24,A>>16&255,A>>8&255,A&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,b>>8&255,b&255,0,0,w>>8&255,w&255,0,0]))},y.traf=function(B,M){var R=y.sdtp(B),b=B.id,w=Math.floor(M/(V+1)),O=Math.floor(M%(V+1));return y.box(y.types.traf,y.box(y.types.tfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255])),y.box(y.types.tfdt,new Uint8Array([1,0,0,0,w>>24,w>>16&255,w>>8&255,w&255,O>>24,O>>16&255,O>>8&255,O&255])),y.trun(B,R.length+16+20+8+16+8+8),R)},y.trak=function(B){return B.duration=B.duration||4294967295,y.box(y.types.trak,y.tkhd(B),y.mdia(B))},y.trex=function(B){var M=B.id;return y.box(y.types.trex,new Uint8Array([0,0,0,0,M>>24,M>>16&255,M>>8&255,M&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},y.trun=function(B,M){var R=B.samples||[],b=R.length,w=12+16*b,O=new Uint8Array(w),A,S,C,d,o,s;for(M+=8+w,O.set([0,0,15,1,b>>>24&255,b>>>16&255,b>>>8&255,b&255,M>>>24&255,M>>>16&255,M>>>8&255,M&255],0),A=0;A<b;A++)S=R[A],C=S.duration,d=S.size,o=S.flags,s=S.cts,O.set([C>>>24&255,C>>>16&255,C>>>8&255,C&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*A);return y.box(y.types.trun,O)},y.initSegment=function(B){y.types||y.init();var M=y.moov(B),R=new Uint8Array(y.FTYP.byteLength+M.byteLength);return R.set(y.FTYP),R.set(M,y.FTYP.byteLength),R},y}();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,Q.default=I},"./src/remux/mp4-remuxer.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return s}),D.d(Q,"normalizePts",function(){return u});var V=D("./src/polyfills/number.ts"),I=D("./src/remux/aac-helper.ts"),y=D("./src/remux/mp4-generator.ts"),j=D("./src/events.ts"),B=D("./src/errors.ts"),M=D("./src/utils/logger.ts"),R=D("./src/types/loader.ts"),b=D("./src/utils/timescale-conversion.ts");function w(){return w=Object.assign||function(_){for(var v=1;v<arguments.length;v++){var c=arguments[v];for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&(_[h]=c[h])}return _},w.apply(this,arguments)}var O=10*1e3,A=1024,S=1152,C=null,d=null,o=!1,s=function(){function _(c,h,l,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=c,this.config=h,this.typeSupported=l,this.ISGenerated=!1,C===null){var g=navigator.userAgent||"",f=g.match(/Chrome\/(\d+)/i);C=f?parseInt(f[1]):0}if(d===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);d=x?parseInt(x[1]):0}o=!!C&&C<75||!!d&&d<600}var v=_.prototype;return v.destroy=function(){},v.resetTimeStamp=function(h){M.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=h},v.resetNextTimestamp=function(){M.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},v.resetInitSegment=function(){M.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},v.getVideoStartPts=function(h){var l=!1,a=h.reduce(function(g,f){var x=f.pts-g;return x<-4294967296?(l=!0,u(g,f.pts)):x>0?g:f.pts},h[0].pts);return l&&M.logger.debug("PTS rollover detected"),a},v.remux=function(h,l,a,g,f,x,P,G){var X,ie,z,F,ne,ce,ge=f,be=f,Ie=h.pid>-1,Te=l.pid>-1,De=l.samples.length,we=h.samples.length>0,Ae=De>1,ve=(!Ie||we)&&(!Te||Ae)||this.ISGenerated||P;if(ve){this.ISGenerated||(z=this.generateIS(h,l,f));var W=this.isVideoContiguous,L=-1;if(Ae&&(L=T(l.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(ce=!0,L>0){M.logger.warn("[mp4-remuxer]: Dropped "+L+" out of "+De+" video samples due to a missing keyframe");var k=this.getVideoStartPts(l.samples);l.samples=l.samples.slice(L),l.dropped+=L,be+=(l.samples[0].pts-k)/(l.timescale||9e4)}else L===-1&&(M.logger.warn("[mp4-remuxer]: No keyframe found out of "+De+" video samples"),ce=!1);if(this.ISGenerated){if(we&&Ae){var H=this.getVideoStartPts(l.samples),ee=u(h.samples[0].pts,H)-H,U=ee/l.inputTimeScale;ge+=Math.max(0,U),be+=Math.max(0,-U)}if(we){if(h.samplerate||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(h,l,f)),ie=this.remuxAudio(h,ge,this.isAudioContiguous,x,Te||Ae||G===R.PlaylistLevelType.AUDIO?be:void 0),Ae){var de=ie?ie.endPTS-ie.startPTS:0;l.inputTimeScale||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(h,l,f)),X=this.remuxVideo(l,be,W,de)}}else Ae&&(X=this.remuxVideo(l,be,W,0));X&&(X.firstKeyFrame=L,X.independent=L!==-1)}}return this.ISGenerated&&(a.samples.length&&(ne=this.remuxID3(a,f)),g.samples.length&&(F=this.remuxText(g,f))),{audio:ie,video:X,initSegment:z,independent:ce,text:F,id3:ne}},v.generateIS=function(h,l,a){var g=h.samples,f=l.samples,x=this.typeSupported,P={},G=!Object(V.isFiniteNumber)(this._initPTS),X="audio/mp4",ie,z,F;if(G&&(ie=z=Infinity),h.config&&g.length&&(h.timescale=h.samplerate,h.isAAC||(x.mpeg?(X="audio/mpeg",h.codec=""):x.mp3&&(h.codec="mp3")),P.audio={id:"audio",container:X,codec:h.codec,initSegment:!h.isAAC&&x.mpeg?new Uint8Array(0):y.default.initSegment([h]),metadata:{channelCount:h.channelCount}},G&&(F=h.inputTimeScale,ie=z=g[0].pts-Math.round(F*a))),l.sps&&l.pps&&f.length&&(l.timescale=l.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:l.codec,initSegment:y.default.initSegment([l]),metadata:{width:l.width,height:l.height}},G)){F=l.inputTimeScale;var ne=this.getVideoStartPts(f),ce=Math.round(F*a);z=Math.min(z,u(f[0].dts,ne)-ce),ie=Math.min(ie,ne-ce)}if(Object.keys(P).length)return this.ISGenerated=!0,G&&(this._initPTS=ie,this._initDTS=z),{tracks:P,initPTS:ie,timescale:F}},v.remuxVideo=function(h,l,a,g){var f=h.inputTimeScale,x=h.samples,P=[],G=x.length,X=this._initPTS,ie=this.nextAvcDts,z=8,F,ne,ce,ge=Number.POSITIVE_INFINITY,be=Number.NEGATIVE_INFINITY,Ie=0,Te=!1;if(!a||ie===null){var De=l*f,we=x[0].pts-u(x[0].dts,x[0].pts);ie=De-we}for(var Ae=0;Ae<G;Ae++){var ve=x[Ae];if(ve.pts=u(ve.pts-X,ie),ve.dts=u(ve.dts-X,ie),ve.dts>ve.pts){var W=9e4*.2;Ie=Math.max(Math.min(Ie,ve.pts-ve.dts),-1*W)}ve.dts<x[Ae>0?Ae-1:Ae].dts&&(Te=!0)}Te&&x.sort(function(Tt,ot){var Ve=Tt.dts-ot.dts,vt=Tt.pts-ot.pts;return Ve||vt}),ne=x[0].dts,ce=x[x.length-1].dts;var L=Math.round((ce-ne)/(G-1));if(Ie<0){if(Ie<L*-2){M.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(b.toMsFromMpegTsClock)(-L,!0)+" ms");for(var k=Ie,H=0;H<G;H++)x[H].dts=k=Math.max(k,x[H].pts-L),x[H].pts=Math.max(k,x[H].pts)}else{M.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(b.toMsFromMpegTsClock)(Ie,!0)+" ms to overcome this issue");for(var ee=0;ee<G;ee++)x[ee].dts=x[ee].dts+Ie}ne=x[0].dts}if(a){var U=ne-ie,de=U>L,Ee=U<-1;if(de||Ee){de?M.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(U,!0)+" ms ("+U+"dts) hole between fragments detected, filling it"):M.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(-U,!0)+" ms ("+U+"dts) overlapping between fragments detected"),ne=ie;var _e=x[0].pts-U;x[0].dts=ne,x[0].pts=_e,M.logger.log("Video: First PTS/DTS adjusted: "+Object(b.toMsFromMpegTsClock)(_e,!0)+"/"+Object(b.toMsFromMpegTsClock)(ne,!0)+", delta: "+Object(b.toMsFromMpegTsClock)(U,!0)+" ms")}}o&&(ne=Math.max(0,ne));for(var Ue=0,ke=0,Oe=0;Oe<G;Oe++){for(var Pe=x[Oe],Xe=Pe.units,Fe=Xe.length,Ne=0,We=0;We<Fe;We++)Ne+=Xe[We].data.length;ke+=Ne,Ue+=Fe,Pe.length=Ne,Pe.dts=Math.max(Pe.dts,ne),Pe.pts=Math.max(Pe.pts,Pe.dts,0),ge=Math.min(Pe.pts,ge),be=Math.max(Pe.pts,be)}ce=x[G-1].dts;var Ze=ke+4*Ue+8,He;try{He=new Uint8Array(Ze)}catch(Tt){this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ze,reason:"fail allocating video mdat "+Ze});return}var Ye=new DataView(He.buffer);Ye.setUint32(0,Ze),He.set(y.default.types.mdat,4);for(var Ce=0;Ce<G;Ce++){for(var $e=x[Ce],qe=$e.units,ae=0,J=0,$=qe.length;J<$;J++){var re=qe[J],oe=re.data,q=re.data.byteLength;Ye.setUint32(z,q),z+=4,He.set(oe,z),z+=q,ae+=4+q}if(Ce<G-1)F=x[Ce+1].dts-$e.dts;else{var Z=this.config,se=$e.dts-x[Ce>0?Ce-1:Ce].dts;if(Z.stretchShortVideoTrack&&this.nextAudioPts!==null){var le=Math.floor(Z.maxBufferHole*f),pe=(g?ge+g*f:this.nextAudioPts)-$e.pts;pe>le?(F=pe-se,F<0&&(F=se),M.logger.log("[mp4-remuxer]: It is approximately "+pe/90+" ms to the next segment; using duration "+F/90+" ms for the last video frame.")):F=se}else F=se}var ye=Math.round($e.pts-$e.dts);P.push(new m($e.key,F,ae,ye))}if(P.length&&C&&C<70){var Le=P[0].flags;Le.dependsOn=2,Le.isNonSync=0}console.assert(F!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=ie=ce+F,this.isVideoContiguous=!0;var Me=y.default.moof(h.sequenceNumber++,ne,w({},h,{samples:P})),et="video",rt={data1:Me,data2:He,startPTS:ge/f,endPTS:(be+F)/f,startDTS:ne/f,endDTS:ie/f,type:et,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:h.dropped};return h.samples=[],h.dropped=0,console.assert(He.length,"MDAT length must not be zero"),rt},v.remuxAudio=function(h,l,a,g,f){var x=h.inputTimeScale,P=h.samplerate?h.samplerate:x,G=x/P,X=h.isAAC?A:S,ie=X*G,z=this._initPTS,F=!h.isAAC&&this.typeSupported.mpeg,ne=[],ce=h.samples,ge=F?0:8,be=this.nextAudioPts||-1,Ie=l*x;if(this.isAudioContiguous=a=a||ce.length&&be>0&&(g&&Math.abs(Ie-be)<9e3||Math.abs(u(ce[0].pts-z,Ie)-be)<20*ie),ce.forEach(function(oe){oe.pts=u(oe.pts-z,Ie)}),!a||be<0){if(ce=ce.filter(function(oe){return oe.pts>=0}),!ce.length)return;f===0?be=0:g?be=Math.max(0,Ie):be=ce[0].pts}if(h.isAAC)for(var Te=f!==void 0,De=this.config.maxAudioFramesDrift,we=0,Ae=be;we<ce.length;we++){var ve=ce[we],W=ve.pts,L=W-Ae,k=Math.abs(1e3*L/x);if(L<=-De*ie&&Te)we===0&&(M.logger.warn("Audio frame @ "+(W/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*L/x)+" ms."),this.nextAudioPts=be=Ae=W);else if(L>=De*ie&&k<O&&Te){var H=Math.round(L/ie);Ae=W-H*ie,Ae<0&&(H--,Ae+=ie),we===0&&(this.nextAudioPts=be=Ae),M.logger.warn("[mp4-remuxer]: Injecting "+H+" audio frame @ "+(Ae/x).toFixed(3)+"s due to "+Math.round(1e3*L/x)+" ms gap.");for(var ee=0;ee<H;ee++){var U=Math.max(Ae,0),de=I.default.getSilentFrame(h.manifestCodec||h.codec,h.channelCount);de||(M.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),de=ve.unit.subarray()),ce.splice(we,0,{unit:de,pts:U}),Ae+=ie,we++}}ve.pts=Ae,Ae+=ie}for(var Ee=null,_e=null,Ue,ke=0,Oe=ce.length;Oe--;)ke+=ce[Oe].unit.byteLength;for(var Pe=0,Xe=ce.length;Pe<Xe;Pe++){var Fe=ce[Pe],Ne=Fe.unit,We=Fe.pts;if(_e!==null){var Ze=ne[Pe-1];Ze.duration=Math.round((We-_e)/G)}else if(a&&h.isAAC&&(We=be),Ee=We,ke>0){ke+=ge;try{Ue=new Uint8Array(ke)}catch(oe){this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ke,reason:"fail allocating audio mdat "+ke});return}if(!F){var He=new DataView(Ue.buffer);He.setUint32(0,ke),Ue.set(y.default.types.mdat,4)}}else return;Ue.set(Ne,ge);var Ye=Ne.byteLength;ge+=Ye,ne.push(new m(!0,X,Ye,0)),_e=We}var Ce=ne.length;if(!Ce)return;var $e=ne[ne.length-1];this.nextAudioPts=be=_e+G*$e.duration;var qe=F?new Uint8Array(0):y.default.moof(h.sequenceNumber++,Ee/G,w({},h,{samples:ne}));h.samples=[];var ae=Ee/x,J=be/x,$="audio",re={data1:qe,data2:Ue,startPTS:ae,endPTS:J,startDTS:ae,endDTS:J,type:$,hasAudio:!0,hasVideo:!1,nb:Ce};return this.isAudioContiguous=!0,console.assert(Ue.length,"MDAT length must not be zero"),re},v.remuxEmptyAudio=function(h,l,a,g){var f=h.inputTimeScale,x=h.samplerate?h.samplerate:f,P=f/x,G=this.nextAudioPts,X=(G!==null?G:g.startDTS*f)+this._initDTS,ie=g.endDTS*f+this._initDTS,z=P*A,F=Math.ceil((ie-X)/z),ne=I.default.getSilentFrame(h.manifestCodec||h.codec,h.channelCount);if(M.logger.warn("[mp4-remuxer]: remux empty Audio"),!ne){M.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ce=[],ge=0;ge<F;ge++){var be=X+ge*z;ce.push({unit:ne,pts:be,dts:be})}return h.samples=ce,this.remuxAudio(h,l,a,!1)},v.remuxID3=function(h,l){var a=h.samples.length;if(!a)return;for(var g=h.inputTimeScale,f=this._initPTS,x=this._initDTS,P=0;P<a;P++){var G=h.samples[P];G.pts=u(G.pts-f,l*g)/g,G.dts=u(G.dts-x,l*g)/g}var X=h.samples;return h.samples=[],{samples:X}},v.remuxText=function(h,l){var a=h.samples.length;if(!a)return;for(var g=h.inputTimeScale,f=this._initPTS,x=0;x<a;x++){var P=h.samples[x];P.pts=u(P.pts-f,l*g)/g}h.samples.sort(function(X,ie){return X.pts-ie.pts});var G=h.samples;return h.samples=[],{samples:G}},_}();function u(_,v){var c;if(v===null)return _;for(v<_?c=-8589934592:c=8589934592;Math.abs(_-v)>4294967296;)_+=c;return _}function T(_){for(var v=0;v<_.length;v++)if(_[v].key)return v;return-1}var m=function(v,c,h,l){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=c,this.size=h,this.cts=l,this.flags=new p(v)},p=function(v){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=v?2:1,this.isNonSync=v?0:1}},"./src/remux/passthrough-remuxer.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/polyfills/number.ts"),I=D("./src/utils/mp4-tools.ts"),y=D("./src/loader/fragment.ts"),j=D("./src/utils/logger.ts"),B=function(){function b(){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 w=b.prototype;return w.destroy=function(){},w.resetTimeStamp=function(A){this.initPTS=A,this.lastEndDTS=null},w.resetNextTimestamp=function(){this.lastEndDTS=null},w.resetInitSegment=function(A,S,C){this.audioCodec=S,this.videoCodec=C,this.generateInitSegment(A),this.emitInitSegment=!0},w.generateInitSegment=function(A){var S=this.audioCodec,C=this.videoCodec;if(!A||!A.byteLength){this.initTracks=void 0,this.initData=void 0;return}var d=this.initData=Object(I.parseInitSegment)(A);S||(S=R(d.audio,y.ElementaryStreamTypes.AUDIO)),C||(C=R(d.video,y.ElementaryStreamTypes.VIDEO));var o={};d.audio&&d.video?o.audiovideo={container:"video/mp4",codec:S+","+C,initSegment:A,id:"main"}:d.audio?o.audio={container:"audio/mp4",codec:S,initSegment:A,id:"audio"}:d.video?o.video={container:"video/mp4",codec:C,initSegment:A,id:"main"}:j.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},w.remux=function(A,S,C,d,o){var s=this.initPTS,u=this.lastEndDTS,T={audio:void 0,video:void 0,text:d,id3:C,initSegment:void 0};Object(V.isFiniteNumber)(u)||(u=this.lastEndDTS=o||0);var m=S.samples;if(!m||!m.length)return T;var p={initPTS:void 0,timescale:1},_=this.initData;if((!_||!_.length)&&(this.generateInitSegment(m),_=this.initData),!_||!_.length)return j.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),T;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1),Object(V.isFiniteNumber)(s)||(this.initPTS=p.initPTS=s=M(_,m,u));var v=Object(I.getDuration)(m,_),c=u,h=v+c;Object(I.offsetStartDTS)(_,m,s),v>0?this.lastEndDTS=h:(j.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var l=!!_.audio,a=!!_.video,g="";l&&(g+="audio"),a&&(g+="video");var f={data1:m,startPTS:c,startDTS:c,endPTS:h,endDTS:h,type:g,hasAudio:l,hasVideo:a,nb:1,dropped:0};return T.audio=f.type==="audio"?f:void 0,T.video=f.type!=="audio"?f:void 0,T.text=d,T.id3=C,T.initSegment=p,T},b}(),M=function(w,O,A){return Object(I.getStartDTS)(w,O)-A};function R(b,w){var O=b==null?void 0:b.codec;return O&&O.length>4?O:O==="hvc1"?"hvc1.1.c.L120.90":O==="av01"?"av01.0.04M.08":O==="avc1"||w===y.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}Q.default=B},"./src/task-loop.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"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 y=I.prototype;return y.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},y.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},y.onHandlerDestroyed=function(){},y.hasInterval=function(){return!!this._tickInterval},y.hasNextTick=function(){return!!this._tickTimer},y.setInterval=function(B){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,B),!0)},y.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},y.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},y.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},y.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},y.doTick=function(){},I}()},"./src/types/cmcd.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"CMCDVersion",function(){return V}),D.d(Q,"CMCDObjectType",function(){return I}),D.d(Q,"CMCDStreamingFormat",function(){return y}),D.d(Q,"CMCDStreamType",function(){return j});var V=1,I;(function(B){B.MANIFEST="m",B.AUDIO="a",B.VIDEO="v",B.MUXED="av",B.INIT="i",B.CAPTION="c",B.TIMED_TEXT="tt",B.KEY="k",B.OTHER="o"})(I||(I={}));var y;(function(B){B.DASH="d",B.HLS="h",B.SMOOTH="s",B.OTHER="o"})(y||(y={}));var j;(function(B){B.VOD="v",B.LIVE="l"})(j||(j={}))},"./src/types/level.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"HlsSkip",function(){return y}),D.d(Q,"getSkipValue",function(){return j}),D.d(Q,"HlsUrlParameters",function(){return B}),D.d(Q,"Level",function(){return M});function V(R,b){for(var w=0;w<b.length;w++){var O=b[w];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(R,O.key,O)}}function I(R,b,w){return b&&V(R.prototype,b),w&&V(R,w),R}var y;(function(R){R.No="",R.Yes="YES",R.v2="v2"})(y||(y={}));function j(R,b){var w=R.canSkipUntil,O=R.canSkipDateRanges,A=R.endSN,S=b!==void 0?b-A:0;return w&&S<w?O?y.v2:y.Yes:y.No}var B=function(){function R(w,O,A){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=w,this.part=O,this.skip=A}var b=R.prototype;return b.addDirectives=function(O){var A=new self.URL(O);return this.msn!==void 0&&A.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&A.searchParams.set("_HLS_part",this.part.toString()),this.skip&&A.searchParams.set("_HLS_skip",this.skip),A.toString()},R}(),M=function(){function R(b){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=[b.url],this.attrs=b.attrs,this.bitrate=b.bitrate,b.details&&(this.details=b.details),this.id=b.id||0,this.name=b.name,this.width=b.width||0,this.height=b.height||0,this.audioCodec=b.audioCodec,this.videoCodec=b.videoCodec,this.unknownCodecs=b.unknownCodecs,this.codecSet=[b.videoCodec,b.audioCodec].filter(function(w){return w}).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(w){var O=w%this.url.length;this._urlId!==O&&(this.details=void 0,this._urlId=O)}}]),R}()},"./src/types/loader.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"PlaylistContextType",function(){return V}),D.d(Q,"PlaylistLevelType",function(){return I});var V;(function(y){y.MANIFEST="manifest",y.LEVEL="level",y.AUDIO_TRACK="audioTrack",y.SUBTITLE_TRACK="subtitleTrack"})(V||(V={}));var I;(function(y){y.MAIN="main",y.AUDIO="audio",y.SUBTITLE="subtitle"})(I||(I={}))},"./src/types/transmuxer.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"ChunkMetadata",function(){return V});var V=function(j,B,M,R,b,w){R===void 0&&(R=0),b===void 0&&(b=-1),w===void 0&&(w=!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=j,this.sn=B,this.id=M,this.size=R,this.part=b,this.partial=w};function I(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"AttrList",function(){return y});var V=/^(\d+)x(\d+)$/,I=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,y=function(){function j(M){typeof M=="string"&&(M=j.parseAttrList(M));for(var R in M)M.hasOwnProperty(R)&&(this[R]=M[R])}var B=j.prototype;return B.decimalInteger=function(R){var b=parseInt(this[R],10);return b>Number.MAX_SAFE_INTEGER?Infinity:b},B.hexadecimalInteger=function(R){if(this[R]){var b=(this[R]||"0x").slice(2);b=(b.length&1?"0":"")+b;for(var w=new Uint8Array(b.length/2),O=0;O<b.length/2;O++)w[O]=parseInt(b.slice(O*2,O*2+2),16);return w}else return null},B.hexadecimalIntegerAsNumber=function(R){var b=parseInt(this[R],16);return b>Number.MAX_SAFE_INTEGER?Infinity:b},B.decimalFloatingPoint=function(R){return parseFloat(this[R])},B.optionalFloat=function(R,b){var w=this[R];return w?parseFloat(w):b},B.enumeratedString=function(R){return this[R]},B.bool=function(R){return this[R]==="YES"},B.decimalResolution=function(R){var b=V.exec(this[R]);return b===null?void 0:{width:parseInt(b[1],10),height:parseInt(b[2],10)}},j.parseAttrList=function(R){var b,w={},O='"';for(I.lastIndex=0;(b=I.exec(R))!==null;){var A=b[2];A.indexOf(O)===0&&A.lastIndexOf(O)===A.length-1&&(A=A.slice(1,-1)),w[b[1]]=A}return w},j}()},"./src/utils/binary-search.ts":function(fe,Q,D){"use strict";D.r(Q);var V={search:function(y,j){for(var B=0,M=y.length-1,R=null,b=null;B<=M;){R=(B+M)/2|0,b=y[R];var w=j(b);if(w>0)B=R+1;else if(w<0)M=R-1;else return b}return null}};Q.default=V},"./src/utils/buffer-helper.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"BufferHelper",function(){return y});var V=D("./src/utils/logger.ts"),I={length:0,start:function(){return 0},end:function(){return 0}},y=function(){function j(){}return j.isBuffered=function(M,R){try{if(M){for(var b=j.getBuffered(M),w=0;w<b.length;w++)if(R>=b.start(w)&&R<=b.end(w))return!0}}catch(O){}return!1},j.bufferInfo=function(M,R,b){try{if(M){var w=j.getBuffered(M),O=[],A;for(A=0;A<w.length;A++)O.push({start:w.start(A),end:w.end(A)});return this.bufferedInfo(O,R,b)}}catch(S){}return{len:0,start:R,end:R,nextStart:void 0}},j.bufferedInfo=function(M,R,b){R=Math.max(0,R),M.sort(function(p,_){var v=p.start-_.start;return v||_.end-p.end});var w=[];if(b)for(var O=0;O<M.length;O++){var A=w.length;if(A){var S=w[A-1].end;M[O].start-S<b?M[O].end>S&&(w[A-1].end=M[O].end):w.push(M[O])}else w.push(M[O])}else w=M;for(var C=0,d,o=R,s=R,u=0;u<w.length;u++){var T=w[u].start,m=w[u].end;if(R+b>=T&&R<m)o=T,s=m,C=s-R;else if(R+b<T){d=T;break}}return{len:C,start:o||0,end:s||0,nextStart:d}},j.getBuffered=function(M){try{return M.buffered}catch(R){return V.logger.log("failed to get media.buffered",R),I}},j}()},"./src/utils/cea-608-parser.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"Row",function(){return s}),D.d(Q,"CaptionScreen",function(){return u});var V=D("./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},y=function(h){var l=h;return I.hasOwnProperty(h)&&(l=I[h]),String.fromCharCode(l)},j=15,B=100,M={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},b={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},w={25:2,26:4,29:6,30:8,31:10,27:13,28:15},O=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],A;(function(c){c[c.ERROR=0]="ERROR",c[c.TEXT=1]="TEXT",c[c.WARNING=2]="WARNING",c[c.INFO=2]="INFO",c[c.DEBUG=3]="DEBUG",c[c.DATA=3]="DATA"})(A||(A={}));var S=function(){function c(){this.time=null,this.verboseLevel=A.ERROR}var h=c.prototype;return h.log=function(a,g){this.verboseLevel>=a&&V.logger.log(this.time+" ["+a+"] "+g)},c}(),C=function(h){for(var l=[],a=0;a<h.length;a++)l.push(h[a].toString(16));return l},d=function(){function c(l,a,g,f,x){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=l||"white",this.underline=a||!1,this.italics=g||!1,this.background=f||"black",this.flash=x||!1}var h=c.prototype;return h.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},h.setStyles=function(a){for(var g=["foreground","underline","italics","background","flash"],f=0;f<g.length;f++){var x=g[f];a.hasOwnProperty(x)&&(this[x]=a[x])}},h.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},h.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},h.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},h.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},c}(),o=function(){function c(l,a,g,f,x,P){this.uchar=void 0,this.penState=void 0,this.uchar=l||" ",this.penState=new d(a,g,f,x,P)}var h=c.prototype;return h.reset=function(){this.uchar=" ",this.penState.reset()},h.setChar=function(a,g){this.uchar=a,this.penState.copy(g)},h.setPenState=function(a){this.penState.copy(a)},h.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},h.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},h.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},c}(),s=function(){function c(l){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<B;a++)this.chars.push(new o);this.logger=l,this.pos=0,this.currPenState=new d}var h=c.prototype;return h.equals=function(a){for(var g=!0,f=0;f<B;f++)if(!this.chars[f].equals(a.chars[f])){g=!1;break}return g},h.copy=function(a){for(var g=0;g<B;g++)this.chars[g].copy(a.chars[g])},h.isEmpty=function(){for(var a=!0,g=0;g<B;g++)if(!this.chars[g].isEmpty()){a=!1;break}return a},h.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(A.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>B&&(this.logger.log(A.DEBUG,"Too large cursor position "+this.pos),this.pos=B)},h.moveCursor=function(a){var g=this.pos+a;if(a>1)for(var f=this.pos+1;f<g+1;f++)this.chars[f].setPenState(this.currPenState);this.setCursor(g)},h.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},h.insertChar=function(a){a>=144&&this.backSpace();var g=y(a);if(this.pos>=B){this.logger.log(A.ERROR,"Cannot insert "+a.toString(16)+" ("+g+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(g,this.currPenState),this.moveCursor(1)},h.clearFromPos=function(a){var g;for(g=a;g<B;g++)this.chars[g].reset()},h.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},h.clearToEndOfRow=function(){this.clearFromPos(this.pos)},h.getTextString=function(){for(var a=[],g=!0,f=0;f<B;f++){var x=this.chars[f].uchar;x!==" "&&(g=!1),a.push(x)}return g?"":a.join("")},h.setPenStyles=function(a){this.currPenState.setStyles(a);var g=this.chars[this.pos];g.setPenState(this.currPenState)},c}(),u=function(){function c(l){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<j;a++)this.rows.push(new s(l));this.logger=l,this.currRow=j-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var h=c.prototype;return h.reset=function(){for(var a=0;a<j;a++)this.rows[a].clear();this.currRow=j-1},h.equals=function(a){for(var g=!0,f=0;f<j;f++)if(!this.rows[f].equals(a.rows[f])){g=!1;break}return g},h.copy=function(a){for(var g=0;g<j;g++)this.rows[g].copy(a.rows[g])},h.isEmpty=function(){for(var a=!0,g=0;g<j;g++)if(!this.rows[g].isEmpty()){a=!1;break}return a},h.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},h.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},h.insertChar=function(a){var g=this.rows[this.currRow];g.insertChar(a)},h.setPen=function(a){var g=this.rows[this.currRow];g.setPenStyles(a)},h.moveCursor=function(a){var g=this.rows[this.currRow];g.moveCursor(a)},h.setCursor=function(a){this.logger.log(A.INFO,"setCursor: "+a);var g=this.rows[this.currRow];g.setCursor(a)},h.setPAC=function(a){this.logger.log(A.INFO,"pacData = "+JSON.stringify(a));var g=a.row-1;if(this.nrRollUpRows&&g<this.nrRollUpRows-1&&(g=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==g){for(var f=0;f<j;f++)this.rows[f].clear();var x=this.currRow+1-this.nrRollUpRows,P=this.lastOutputScreen;if(P){var G=P.rows[x].cueStartTime,X=this.logger.time;if(G&&X!==null&&G<X)for(var ie=0;ie<this.nrRollUpRows;ie++)this.rows[g-this.nrRollUpRows+ie+1].copy(P.rows[x+ie])}}this.currRow=g;var z=this.rows[this.currRow];if(a.indent!==null){var F=a.indent,ne=Math.max(F-1,0);z.setCursor(a.indent),a.color=z.chars[ne].penState.foreground}var ce={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ce)},h.setBkgData=function(a){this.logger.log(A.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},h.setRollUpRows=function(a){this.nrRollUpRows=a},h.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(A.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(A.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,g=this.rows.splice(a,1)[0];g.clear(),this.rows.splice(this.currRow,0,g),this.logger.log(A.INFO,"Rolling up")},h.getDisplayText=function(a){a=a||!1;for(var g=[],f="",x=-1,P=0;P<j;P++){var G=this.rows[P].getTextString();G&&(x=P+1,a?g.push("Row "+x+": '"+G+"'"):g.push(G.trim()))}return g.length>0&&(a?f="["+g.join(" | ")+"]":f=g.join(`
|
|
`)),f},h.getTextAndFormat=function(){return this.rows},c}(),T=function(){function c(l,a,g){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=l,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new u(g),this.nonDisplayedMemory=new u(g),this.lastOutputScreen=new u(g),this.currRollUpRow=this.displayedMemory.rows[j-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=g}var h=c.prototype;return h.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[j-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},h.getHandler=function(){return this.outputFilter},h.setHandler=function(a){this.outputFilter=a},h.setPAC=function(a){this.writeScreen.setPAC(a)},h.setBkgData=function(a){this.writeScreen.setBkgData(a)},h.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(A.INFO,"MODE="+a),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=a},h.insertChars=function(a){for(var g=0;g<a.length;g++)this.writeScreen.insertChar(a[g]);var f=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(A.INFO,f+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(A.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},h.ccRCL=function(){this.logger.log(A.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},h.ccBS=function(){if(this.logger.log(A.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},h.ccAOF=function(){},h.ccAON=function(){},h.ccDER=function(){this.logger.log(A.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},h.ccRU=function(a){this.logger.log(A.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},h.ccFON=function(){this.logger.log(A.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},h.ccRDC=function(){this.logger.log(A.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},h.ccTR=function(){this.logger.log(A.INFO,"TR"),this.setMode("MODE_TEXT")},h.ccRTD=function(){this.logger.log(A.INFO,"RTD"),this.setMode("MODE_TEXT")},h.ccEDM=function(){this.logger.log(A.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},h.ccCR=function(){this.logger.log(A.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},h.ccENM=function(){this.logger.log(A.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},h.ccEOC=function(){if(this.logger.log(A.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(A.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},h.ccTO=function(a){this.logger.log(A.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},h.ccMIDROW=function(a){var g={flash:!1};if(g.underline=a%2===1,g.italics=a>=46,g.italics)g.foreground="white";else{var f=Math.floor(a/2)-16,x=["white","green","blue","cyan","red","yellow","magenta"];g.foreground=x[f]}this.logger.log(A.INFO,"MIDROW: "+JSON.stringify(g)),this.writeScreen.setPen(g)},h.outputDataUpdate=function(a){a===void 0&&(a=!1);var g=this.logger.time;if(g===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=g:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,g,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:g),this.lastOutputScreen.copy(this.displayedMemory))},h.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},c}(),m=function(){function c(l,a,g){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var f=new S;this.channels=[null,new T(l,a,f),new T(l+1,g,f)],this.cmdHistory=v(),this.logger=f}var h=c.prototype;return h.getHandler=function(a){return this.channels[a].getHandler()},h.setHandler=function(a,g){this.channels[a].setHandler(g)},h.addData=function(a,g){var f,x,P,G=!1;this.logger.time=a;for(var X=0;X<g.length;X+=2){if(x=g[X]&127,P=g[X+1]&127,x===0&&P===0)continue;if(this.logger.log(A.DATA,"["+C([g[X],g[X+1]])+"] -> ("+C([x,P])+")"),f=this.parseCmd(x,P),f||(f=this.parseMidrow(x,P)),f||(f=this.parsePAC(x,P)),f||(f=this.parseBackgroundAttributes(x,P)),!f&&(G=this.parseChars(x,P),G)){var ie=this.currentChannel;if(ie&&ie>0){var z=this.channels[ie];z.insertChars(G)}else this.logger.log(A.WARNING,"No channel found yet. TEXT-MODE?")}!f&&!G&&this.logger.log(A.WARNING,"Couldn't parse cleaned data "+C([x,P])+" orig: "+C([g[X],g[X+1]]))}},h.parseCmd=function(a,g){var f=this.cmdHistory,x=(a===20||a===28||a===21||a===29)&&g>=32&&g<=47,P=(a===23||a===31)&&g>=33&&g<=35;if(!(x||P))return!1;if(_(a,g,f))return p(null,null,f),this.logger.log(A.DEBUG,"Repeated command ("+C([a,g])+") is dropped"),!0;var G=a===20||a===21||a===23?1:2,X=this.channels[G];return a===20||a===21||a===28||a===29?g===32?X.ccRCL():g===33?X.ccBS():g===34?X.ccAOF():g===35?X.ccAON():g===36?X.ccDER():g===37?X.ccRU(2):g===38?X.ccRU(3):g===39?X.ccRU(4):g===40?X.ccFON():g===41?X.ccRDC():g===42?X.ccTR():g===43?X.ccRTD():g===44?X.ccEDM():g===45?X.ccCR():g===46?X.ccENM():g===47&&X.ccEOC():X.ccTO(g-32),p(a,g,f),this.currentChannel=G,!0},h.parseMidrow=function(a,g){var f=0;if((a===17||a===25)&&g>=32&&g<=47){if(a===17?f=1:f=2,f!==this.currentChannel)return this.logger.log(A.ERROR,"Mismatch channel in midrow parsing"),!1;var x=this.channels[f];return x?(x.ccMIDROW(g),this.logger.log(A.DEBUG,"MIDROW ("+C([a,g])+")"),!0):!1}return!1},h.parsePAC=function(a,g){var f,x=this.cmdHistory,P=(a>=17&&a<=23||a>=25&&a<=31)&&g>=64&&g<=127,G=(a===16||a===24)&&g>=64&&g<=95;if(!(P||G))return!1;if(_(a,g,x))return p(null,null,x),!0;var X=a<=23?1:2;g>=64&&g<=95?f=X===1?M[a]:b[a]:f=X===1?R[a]:w[a];var ie=this.channels[X];return ie?(ie.setPAC(this.interpretPAC(f,g)),p(a,g,x),this.currentChannel=X,!0):!1},h.interpretPAC=function(a,g){var f,x={color:null,italics:!1,indent:null,underline:!1,row:a};return g>95?f=g-96:f=g-64,x.underline=(f&1)===1,f<=13?x.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(f/2)]:f<=15?(x.italics=!0,x.color="white"):x.indent=Math.floor((f-16)/2)*4,x},h.parseChars=function(a,g){var f,x=null,P=null;if(a>=25?(f=2,P=a-8):(f=1,P=a),P>=17&&P<=19){var G;P===17?G=g+80:P===18?G=g+112:G=g+144,this.logger.log(A.INFO,"Special char '"+y(G)+"' in channel "+f),x=[G]}else a>=32&&a<=127&&(x=g===0?[a]:[a,g]);if(x){var X=C(x);this.logger.log(A.DEBUG,"Char codes = "+X.join(",")),p(a,g,this.cmdHistory)}return x},h.parseBackgroundAttributes=function(a,g){var f=(a===16||a===24)&&g>=32&&g<=47,x=(a===23||a===31)&&g>=45&&g<=47;if(!(f||x))return!1;var P,G={};a===16||a===24?(P=Math.floor((g-32)/2),G.background=O[P],g%2===1&&(G.background=G.background+"_semi")):g===45?G.background="transparent":(G.foreground="black",g===47&&(G.underline=!0));var X=a<=23?1:2,ie=this.channels[X];return ie.setBkgData(G),p(a,g,this.cmdHistory),!0},h.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var g=this.channels[a];g&&g.reset()}this.cmdHistory=v()},h.cueSplitAtTime=function(a){for(var g=0;g<this.channels.length;g++){var f=this.channels[g];f&&f.cueSplitAtTime(a)}},c}();function p(c,h,l){l.a=c,l.b=h}function _(c,h,l){return l.a===c&&l.b===h}function v(){return{a:null,b:null}}Q.default=m},"./src/utils/codecs.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"isCodecType",function(){return I}),D.d(Q,"isCodecSupportedInMp4",function(){return y});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(j,B){var M=V[B];return!!M&&M[j.slice(0,4)]===!0}function y(j,B){return MediaSource.isTypeSupported((B||"video")+'/mp4;codecs="'+j+'"')}},"./src/utils/cues.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/utils/vttparser.ts"),I=D("./src/utils/webvtt-parser.ts"),y=D("./src/utils/texttrack-utils.ts"),j=/\s/,B={newCue:function(R,b,w,O){for(var A=[],S,C,d,o,s,u=self.VTTCue||self.TextTrackCue,T=0;T<O.rows.length;T++)if(S=O.rows[T],d=!0,o=0,s="",!S.isEmpty()){for(var m=0;m<S.chars.length;m++)j.test(S.chars[m].uchar)&&d?o++:(s+=S.chars[m].uchar,d=!1);S.cueStartTime=b,b===w&&(w+=1e-4),o>=16?o--:o++;var p=Object(V.fixLineBreaks)(s.trim()),_=Object(I.generateCueId)(b,w,p);(!R||!R.cues||!R.cues.getCueById(_))&&(C=new u(b,w,p),C.id=_,C.line=T+1,C.align="left",C.position=10+Math.min(80,Math.floor(o*8/32)*10),A.push(C))}return R&&A.length&&(A.sort(function(v,c){return v.line==="auto"||c.line==="auto"?0:v.line>8&&c.line>8?c.line-v.line:v.line-c.line}),A.forEach(function(v){return Object(y.addCueToTrack)(R,v)})),A}};Q.default=B},"./src/utils/discontinuities.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"findFirstFragWithCC",function(){return j}),D.d(Q,"shouldAlignOnDiscontinuities",function(){return B}),D.d(Q,"findDiscontinuousReferenceFrag",function(){return M}),D.d(Q,"adjustSlidingStart",function(){return b}),D.d(Q,"alignStream",function(){return w}),D.d(Q,"alignPDT",function(){return A}),D.d(Q,"alignFragmentByPDTDelta",function(){return S}),D.d(Q,"alignMediaPlaylistByPDT",function(){return C});var V=D("./src/polyfills/number.ts"),I=D("./src/utils/logger.ts"),y=D("./src/controller/level-helper.ts");function j(d,o){for(var s=null,u=0,T=d.length;u<T;u++){var m=d[u];if(m&&m.cc===o){s=m;break}}return s}function B(d,o,s){return!!(o.details&&(s.endCC>s.startCC||d&&d.cc<s.startCC))}function M(d,o){var s=d.fragments,u=o.fragments;if(!u.length||!s.length){I.logger.log("No fragments to align");return}var T=j(s,u[0].cc);if(!T||T&&!T.startPTS){I.logger.log("No frag in previous level to align on");return}return T}function R(d,o){if(d){var s=d.start+o;d.start=d.startPTS=s,d.endPTS=s+d.duration}}function b(d,o){for(var s=o.fragments,u=0,T=s.length;u<T;u++)R(s[u],d);o.fragmentHint&&R(o.fragmentHint,d),o.alignedSliding=!0}function w(d,o,s){if(!o)return;O(d,s,o),!s.alignedSliding&&o.details&&A(s,o.details),!s.alignedSliding&&o.details&&!s.skippedSegments&&Object(y.adjustSliding)(o.details,s)}function O(d,o,s){if(B(d,s,o)){var u=M(s.details,o);u&&Object(V.isFiniteNumber)(u.start)&&(I.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),b(u.start,o))}}function A(d,o){if(!o.fragments.length||!d.hasProgramDateTime||!o.hasProgramDateTime)return;var s=o.fragments[0].programDateTime,u=d.fragments[0].programDateTime,T=(u-s)/1e3+o.fragments[0].start;T&&Object(V.isFiniteNumber)(T)&&(I.logger.log("Adjusting PTS using programDateTime delta "+(u-s)+"ms, sliding:"+T.toFixed(3)+" "+d.url+" "),b(T,d))}function S(d,o){var s=d.programDateTime;if(!s)return;var u=(s-o)/1e3;d.start=d.startPTS=u,d.endPTS=u+d.duration}function C(d,o){if(!o.fragments.length||!d.hasProgramDateTime||!o.hasProgramDateTime)return;var s=o.fragments[0].programDateTime,u=o.fragments[0].start,T=s-u*1e3;d.fragments.forEach(function(m){S(m,T)}),d.fragmentHint&&S(d.fragmentHint,T),d.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/utils/ewma.ts"),I=function(){function y(B,M,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(B),this.fast_=new V.default(M)}var j=y.prototype;return j.update=function(M,R){var b=this.slow_,w=this.fast_;this.slow_.halfLife!==M&&(this.slow_=new V.default(M,b.getEstimate(),b.getTotalWeight())),this.fast_.halfLife!==R&&(this.fast_=new V.default(R,w.getEstimate(),w.getTotalWeight()))},j.sample=function(M,R){M=Math.max(M,this.minDelayMs_);var b=8*R,w=M/1e3,O=b/w;this.fast_.sample(w,O),this.slow_.sample(w,O)},j.canEstimate=function(){var M=this.fast_;return M&&M.getTotalWeight()>=this.minWeight_},j.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},j.destroy=function(){},y}();Q.default=I},"./src/utils/ewma.ts":function(fe,Q,D){"use strict";D.r(Q);var V=function(){function I(j,B,M){B===void 0&&(B=0),M===void 0&&(M=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=j,this.alpha_=j?Math.exp(Math.log(.5)/j):0,this.estimate_=B,this.totalWeight_=M}var y=I.prototype;return y.sample=function(B,M){var R=Math.pow(this.alpha_,B);this.estimate_=M*(1-R)+R*this.estimate_,this.totalWeight_+=B},y.getTotalWeight=function(){return this.totalWeight_},y.getEstimate=function(){if(this.alpha_){var B=1-Math.pow(this.alpha_,this.totalWeight_);if(B)return this.estimate_/B}return this.estimate_},I}();Q.default=V},"./src/utils/fetch-loader.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"fetchSupported",function(){return S});var V=D("./src/polyfills/number.ts"),I=D("./src/loader/load-stats.ts"),y=D("./src/demux/chunk-cache.ts");function j(u,T){u.prototype=Object.create(T.prototype),u.prototype.constructor=u,w(u,T)}function B(u){var T=typeof Map=="function"?new Map:void 0;return B=function(p){if(p===null||!b(p))return p;if(typeof p!="function")throw new TypeError("Super expression must either be null or a function");if(typeof T!="undefined"){if(T.has(p))return T.get(p);T.set(p,_)}function _(){return M(p,arguments,O(this).constructor)}return _.prototype=Object.create(p.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),w(_,p)},B(u)}function M(u,T,m){return R()?M=Reflect.construct:M=function(_,v,c){var h=[null];h.push.apply(h,v);var l=Function.bind.apply(_,h),a=new l;return c&&w(a,c.prototype),a},M.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(u){return!1}}function b(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function w(u,T){return w=Object.setPrototypeOf||function(p,_){return p.__proto__=_,p},w(u,T)}function O(u){return O=Object.setPrototypeOf?Object.getPrototypeOf:function(m){return m.__proto__||Object.getPrototypeOf(m)},O(u)}function A(){return A=Object.assign||function(u){for(var T=1;T<arguments.length;T++){var m=arguments[T];for(var p in m)Object.prototype.hasOwnProperty.call(m,p)&&(u[p]=m[p])}return u},A.apply(this,arguments)}function S(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(u){}return!1}var C=function(){function u(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||o,this.controller=new self.AbortController,this.stats=new I.LoadStats}var T=u.prototype;return T.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},T.abortInternal=function(){var p=this.response;(!p||!p.ok)&&(this.stats.aborted=!0,this.controller.abort())},T.abort=function(){var p;this.abortInternal(),(p=this.callbacks)!==null&&p!==void 0&&p.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},T.load=function(p,_,v){var c=this,h=this.stats;if(h.loading.start)throw new Error("Loader can only be used once.");h.loading.start=self.performance.now();var l=d(p,this.controller.signal),a=v.onProgress,g=p.responseType==="arraybuffer",f=g?"byteLength":"length";this.context=p,this.config=_,this.callbacks=v,this.request=this.fetchSetup(p,l),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){c.abortInternal(),v.onTimeout(h,p,c.response)},_.timeout),self.fetch(this.request).then(function(x){if(c.response=c.loader=x,!x.ok){var P=x.status,G=x.statusText;throw new s(G||"fetch, bad network response",P,x)}return h.loading.first=Math.max(self.performance.now(),h.loading.start),h.total=parseInt(x.headers.get("Content-Length")||"0"),a&&Object(V.isFiniteNumber)(_.highWaterMark)?c.loadProgressively(x,h,p,_.highWaterMark,a):g?x.arrayBuffer():x.text()}).then(function(x){var P=c.response;self.clearTimeout(c.requestTimeout),h.loading.end=Math.max(self.performance.now(),h.loading.first),h.loaded=h.total=x[f];var G={url:P.url,data:x};a&&!Object(V.isFiniteNumber)(_.highWaterMark)&&a(h,p,x,P),v.onSuccess(G,h,p,P)}).catch(function(x){if(self.clearTimeout(c.requestTimeout),h.aborted)return;var P=x.code||0;v.onError({code:P,text:x.message},p,x.details)})},T.getCacheAge=function(){var p=null;if(this.response){var _=this.response.headers.get("age");p=_?parseFloat(_):null}return p},T.loadProgressively=function(p,_,v,c,h){c===void 0&&(c=0);var l=new y.default,a=p.body.getReader(),g=function f(){return a.read().then(function(x){if(x.done)return l.dataLength&&h(_,v,l.flush(),p),Promise.resolve(new ArrayBuffer(0));var P=x.value,G=P.length;return _.loaded+=G,G<c||l.dataLength?(l.push(P),l.dataLength>=c&&h(_,v,l.flush(),p)):h(_,v,P,p),f()}).catch(function(){return Promise.reject()})};return g()},u}();function d(u,T){var m={method:"GET",mode:"cors",credentials:"same-origin",signal:T,headers:new self.Headers(A({},u.headers))};return u.rangeEnd&&m.headers.set("Range","bytes="+u.rangeStart+"-"+String(u.rangeEnd-1)),m}function o(u,T){return new self.Request(u.url,T)}var s=function(u){j(T,u);function T(m,p,_){var v;return v=u.call(this,m)||this,v.code=void 0,v.details=void 0,v.code=p,v.details=_,v}return T}(B(Error));Q.default=C},"./src/utils/imsc1-ttml-parser.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"IMSC1_CODEC",function(){return b}),D.d(Q,"parseIMSC1",function(){return S});var V=D("./src/utils/mp4-tools.ts"),I=D("./src/utils/vttparser.ts"),y=D("./src/utils/vttcue.ts"),j=D("./src/demux/id3.ts"),B=D("./src/utils/timescale-conversion.ts"),M=D("./src/utils/webvtt-parser.ts");function R(){return R=Object.assign||function(c){for(var h=1;h<arguments.length;h++){var l=arguments[h];for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&(c[a]=l[a])}return c},R.apply(this,arguments)}var b="stpp.ttml.im1t",w=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,O=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,A={left:"start",center:"center",right:"end",start:"start",end:"end"};function S(c,h,l,a,g){var f=Object(V.findBox)(new Uint8Array(c),["mdat"]);if(f.length===0){g(new Error("Could not parse IMSC1 mdat"));return}var x=f[0],P=Object(j.utf8ArrayToStr)(new Uint8Array(c,x.start,x.end-x.start)),G=Object(B.toTimescaleFromScale)(h,1,l);try{a(C(P,G))}catch(X){g(X)}}function C(c,h){var l=new DOMParser,a=l.parseFromString(c,"text/xml"),g=a.getElementsByTagName("tt")[0];if(!g)throw new Error("Invalid ttml");var f={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},x=Object.keys(f).reduce(function(z,F){return z[F]=g.getAttribute("ttp:"+F)||f[F],z},{}),P=g.getAttribute("xml:space")!=="preserve",G=o(d(g,"styling","style")),X=o(d(g,"layout","region")),ie=d(g,"body","[begin]");return[].map.call(ie,function(z){var F=s(z,P);if(!F||!z.hasAttribute("begin"))return null;var ne=p(z.getAttribute("begin"),x),ce=p(z.getAttribute("dur"),x),ge=p(z.getAttribute("end"),x);if(ne===null)throw m(z);if(ge===null){if(ce===null)throw m(z);ge=ne+ce}var be=new y.default(ne-h,ge-h,F);be.id=Object(M.generateCueId)(be.startTime,be.endTime,be.text);var Ie=X[z.getAttribute("region")],Te=G[z.getAttribute("style")];be.position=10,be.size=80;var De=u(Ie,Te),we=De.textAlign;if(we){var Ae=A[we];Ae&&(be.lineAlign=Ae),be.align=we}return R(be,De),be}).filter(function(z){return z!==null})}function d(c,h,l){var a=c.getElementsByTagName(h)[0];return a?[].slice.call(a.querySelectorAll(l)):[]}function o(c){return c.reduce(function(h,l){var a=l.getAttribute("xml:id");return a&&(h[a]=l),h},{})}function s(c,h){return[].slice.call(c.childNodes).reduce(function(l,a,g){var f;return a.nodeName==="br"&&g?l+`
|
|
`:(f=a.childNodes)!==null&&f!==void 0&&f.length?s(a,h):h?l+a.textContent.trim().replace(/\s+/g," "):l+a.textContent},"")}function u(c,h){var l="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(g,f){var x=T(h,l,f)||T(c,l,f);return x&&(g[f]=x),g},{})}function T(c,h,l){return c.hasAttributeNS(h,l)?c.getAttributeNS(h,l):null}function m(c){return new Error("Could not parse ttml timestamp "+c)}function p(c,h){if(!c)return null;var l=Object(I.parseTimeStamp)(c);return l===null&&(w.test(c)?l=_(c,h):O.test(c)&&(l=v(c,h))),l}function _(c,h){var l=w.exec(c),a=(l[4]|0)+(l[5]|0)/h.subFrameRate;return(l[1]|0)*3600+(l[2]|0)*60+(l[3]|0)+a/h.frameRate}function v(c,h){var l=O.exec(c),a=Number(l[1]),g=l[2];switch(g){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/h.frameRate;case"t":return a/h.tickRate}return a}},"./src/utils/logger.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"enableLogs",function(){return M}),D.d(Q,"logger",function(){return R});var V=function(){},I={trace:V,debug:V,log:V,warn:V,info:V,error:V},y=I;function j(b){var w=self.console[b];return w?w.bind(self.console,"["+b+"] >"):V}function B(b){for(var w=arguments.length,O=new Array(w>1?w-1:0),A=1;A<w;A++)O[A-1]=arguments[A];O.forEach(function(S){y[S]=b[S]?b[S].bind(b):j(S)})}function M(b){if(self.console&&b===!0||typeof b=="object"){B(b,"debug","log","info","warn","error");try{y.log()}catch(w){y=I}}else y=I}var R=y},"./src/utils/mediakeys-helper.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"KeySystems",function(){return V}),D.d(Q,"requestMediaKeySystemAccess",function(){return I});var V;(function(y){y.WIDEVINE="com.widevine.alpha",y.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(fe,Q,D){"use strict";D.r(Q),D.d(Q,"getMediaSource",function(){return V});function V(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"bin2str",function(){return B}),D.d(Q,"readUint16",function(){return M}),D.d(Q,"readUint32",function(){return R}),D.d(Q,"writeUint32",function(){return b}),D.d(Q,"findBox",function(){return w}),D.d(Q,"parseSegmentIndex",function(){return O}),D.d(Q,"parseInitSegment",function(){return A}),D.d(Q,"getStartDTS",function(){return S}),D.d(Q,"getDuration",function(){return C}),D.d(Q,"computeRawDurationFromSamples",function(){return d}),D.d(Q,"offsetStartDTS",function(){return o}),D.d(Q,"segmentValidRange",function(){return s}),D.d(Q,"appendUint8Array",function(){return u});var V=D("./src/utils/typed-array.ts"),I=D("./src/loader/fragment.ts"),y=Math.pow(2,32)-1,j=[].push;function B(T){return String.fromCharCode.apply(null,T)}function M(T,m){"data"in T&&(m+=T.start,T=T.data);var p=T[m]<<8|T[m+1];return p<0?65536+p:p}function R(T,m){"data"in T&&(m+=T.start,T=T.data);var p=T[m]<<24|T[m+1]<<16|T[m+2]<<8|T[m+3];return p<0?4294967296+p:p}function b(T,m,p){"data"in T&&(m+=T.start,T=T.data),T[m]=p>>24,T[m+1]=p>>16&255,T[m+2]=p>>8&255,T[m+3]=p&255}function w(T,m){var p=[];if(!m.length)return p;var _,v,c;"data"in T?(_=T.data,v=T.start,c=T.end):(_=T,v=0,c=_.byteLength);for(var h=v;h<c;){var l=R(_,h),a=B(_.subarray(h+4,h+8)),g=l>1?h+l:c;if(a===m[0])if(m.length===1)p.push({data:_,start:h+8,end:g});else{var f=w({data:_,start:h+8,end:g},m.slice(1));f.length&&j.apply(p,f)}h=g}return p}function O(T){var m=w(T,["moov"]),p=m[0],_=p?p.end:null,v=w(T,["sidx"]);if(!v||!v[0])return null;var c=[],h=v[0],l=h.data[0],a=l===0?8:16,g=R(h,a);a+=4;var f=0,x=0;l===0?a+=8:a+=16,a+=2;var P=h.end+x,G=M(h,a);a+=2;for(var X=0;X<G;X++){var ie=a,z=R(h,ie);ie+=4;var F=z&2147483647,ne=(z&2147483648)>>>31;if(ne===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ce=R(h,ie);ie+=4,c.push({referenceSize:F,subsegmentDuration:ce,info:{duration:ce/g,start:P,end:P+F-1}}),P+=F,ie+=4,a=ie}return{earliestPresentationTime:f,timescale:g,version:l,referencesCount:G,references:c,moovEndOffset:_}}function A(T){for(var m=[],p=w(T,["moov","trak"]),_=0;_<p.length;_++){var v=p[_],c=w(v,["tkhd"])[0];if(c){var h=c.data[c.start],l=h===0?12:20,a=R(c,l),g=w(v,["mdia","mdhd"])[0];if(g){h=g.data[g.start],l=h===0?12:20;var f=R(g,l),x=w(v,["mdia","hdlr"])[0];if(x){var P=B(x.data.subarray(x.start+8,x.start+12)),G={soun:I.ElementaryStreamTypes.AUDIO,vide:I.ElementaryStreamTypes.VIDEO}[P];if(G){var X=w(v,["mdia","minf","stbl","stsd"])[0],ie=void 0;X&&(ie=B(X.data.subarray(X.start+12,X.start+16))),m[a]={timescale:f,type:G},m[G]={timescale:f,id:a,codec:ie}}}}}}var z=w(T,["moov","mvex","trex"]);return z.forEach(function(F){var ne=R(F,4),ce=m[ne];ce&&(ce.default={duration:R(F,12),flags:R(F,20)})}),m}function S(T,m){return w(m,["moof","traf"]).reduce(function(p,_){var v=w(_,["tfdt"])[0],c=v.data[v.start],h=w(_,["tfhd"]).reduce(function(l,a){var g=R(a,4),f=T[g];if(f){var x=R(v,4);c===1&&(x*=Math.pow(2,32),x+=R(v,8));var P=f.timescale||9e4,G=x/P;if(isFinite(G)&&(l===null||G<l))return G}return l},null);return h!==null&&isFinite(h)&&(p===null||h<p)?h:p},null)||0}function C(T,m){for(var p=0,_=0,v=0,c=w(T,["moof","traf"]),h=0;h<c.length;h++){var l=c[h],a=w(l,["tfhd"])[0],g=R(a,4),f=m[g];if(!f)continue;var x=f.default,P=R(a,0)|(x==null?void 0:x.flags),G=x==null?void 0:x.duration;P&8&&(P&2?G=R(a,12):G=R(a,8));for(var X=f.timescale||9e4,ie=w(l,["trun"]),z=0;z<ie.length;z++){if(G){var F=R(ie[z],4);p=G*F}else p=d(ie[z]);f.type===I.ElementaryStreamTypes.VIDEO?_+=p/X:f.type===I.ElementaryStreamTypes.AUDIO&&(v+=p/X)}}if(_===0&&v===0){var ne=O(T);if(ne!=null&&ne.references)return ne.references.reduce(function(ce,ge){return ce+ge.info.duration||0},0)}return _||v}function d(T){var m=R(T,0),p=8;m&1&&(p+=4),m&4&&(p+=4);for(var _=0,v=R(T,4),c=0;c<v;c++){if(m&256){var h=R(T,p);_+=h,p+=4}m&512&&(p+=4),m&1024&&(p+=4),m&2048&&(p+=4)}return _}function o(T,m,p){w(m,["moof","traf"]).forEach(function(_){w(_,["tfhd"]).forEach(function(v){var c=R(v,4),h=T[c];if(!h)return;var l=h.timescale||9e4;w(_,["tfdt"]).forEach(function(a){var g=a.data[a.start],f=R(a,4);if(g===0)b(a,4,f-p*l);else{f*=Math.pow(2,32),f+=R(a,8),f-=p*l,f=Math.max(f,0);var x=Math.floor(f/(y+1)),P=Math.floor(f%(y+1));b(a,4,x),b(a,8,P)}})})})}function s(T){var m={valid:null,remainder:null},p=w(T,["moof"]);if(p){if(p.length<2)return m.remainder=T,m}else return m;var _=p[p.length-1];return m.valid=Object(V.sliceUint8)(T,0,_.start-8),m.remainder=Object(V.sliceUint8)(T,_.start-8),m}function u(T,m){var p=new Uint8Array(T.length+m.length);return p.set(T),p.set(m,T.length),p}},"./src/utils/output-filter.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"default",function(){return V});var V=function(){function I(j,B){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=j,this.trackName=B}var y=I.prototype;return y.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},y.newCue=function(B,M,R){(this.startTime===null||this.startTime>B)&&(this.startTime=B),this.endTime=M,this.screen=R,this.timelineController.createCaptionsTrack(this.trackName)},y.reset=function(){this.cueRanges=[]},I}()},"./src/utils/texttrack-utils.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"sendAddTrackEvent",function(){return I}),D.d(Q,"addCueToTrack",function(){return y}),D.d(Q,"clearCurrentCues",function(){return j}),D.d(Q,"removeCuesInRange",function(){return B}),D.d(Q,"getCuesInRange",function(){return R});var V=D("./src/utils/logger.ts");function I(b,w){var O;try{O=new Event("addtrack")}catch(A){O=document.createEvent("Event"),O.initEvent("addtrack",!1,!1)}O.track=b,w.dispatchEvent(O)}function y(b,w){var O=b.mode;if(O==="disabled"&&(b.mode="hidden"),b.cues&&!b.cues.getCueById(w.id))try{if(b.addCue(w),!b.cues.getCueById(w.id))throw new Error("addCue is failed for: "+w)}catch(S){V.logger.debug("[texttrack-utils]: "+S);var A=new self.TextTrackCue(w.startTime,w.endTime,w.text);A.id=w.id,b.addCue(A)}O==="disabled"&&(b.mode=O)}function j(b){var w=b.mode;if(w==="disabled"&&(b.mode="hidden"),b.cues)for(var O=b.cues.length;O--;)b.removeCue(b.cues[O]);w==="disabled"&&(b.mode=w)}function B(b,w,O){var A=b.mode;if(A==="disabled"&&(b.mode="hidden"),b.cues&&b.cues.length>0)for(var S=R(b.cues,w,O),C=0;C<S.length;C++)b.removeCue(S[C]);A==="disabled"&&(b.mode=A)}function M(b,w){if(w<b[0].startTime)return 0;var O=b.length-1;if(w>b[O].endTime)return-1;for(var A=0,S=O;A<=S;){var C=Math.floor((S+A)/2);if(w<b[C].startTime)S=C-1;else if(w>b[C].startTime&&A<O)A=C+1;else return C}return b[A].startTime-w<w-b[S].startTime?A:S}function R(b,w,O){var A=[],S=M(b,w);if(S>-1)for(var C=S,d=b.length;C<d;C++){var o=b[C];if(o.startTime>=w&&o.endTime<=O)A.push(o);else if(o.startTime>O)return A}return A}},"./src/utils/time-ranges.ts":function(fe,Q,D){"use strict";D.r(Q);var V={toString:function(y){for(var j="",B=y.length,M=0;M<B;M++)j+="["+y.start(M).toFixed(3)+","+y.end(M).toFixed(3)+"]";return j}};Q.default=V},"./src/utils/timescale-conversion.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"toTimescaleFromBase",function(){return I}),D.d(Q,"toTimescaleFromScale",function(){return y}),D.d(Q,"toMsFromMpegTsClock",function(){return j}),D.d(Q,"toMpegTsClockFromTimescale",function(){return B});var V=9e4;function I(M,R,b,w){b===void 0&&(b=1),w===void 0&&(w=!1);var O=M*R*b;return w?Math.round(O):O}function y(M,R,b,w){return b===void 0&&(b=1),w===void 0&&(w=!1),I(M,R,1/b,w)}function j(M,R){return R===void 0&&(R=!1),I(M,1e3,1/V,R)}function B(M,R){return R===void 0&&(R=1),I(M,V,1/R)}},"./src/utils/typed-array.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"sliceUint8",function(){return V});function V(I,y,j){return Uint8Array.prototype.slice?I.slice(y,j):new Uint8Array(Array.prototype.slice.call(I,y,j))}},"./src/utils/vttcue.ts":function(fe,Q,D){"use strict";D.r(Q),Q.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var V=["","lr","rl"],I=["start","middle","end","left","right"];function y(b,w){if(typeof w!="string")return!1;if(!Array.isArray(b))return!1;var O=w.toLowerCase();return~b.indexOf(O)?O:!1}function j(b){return y(V,b)}function B(b){return y(I,b)}function M(b){for(var w=arguments.length,O=new Array(w>1?w-1:0),A=1;A<w;A++)O[A-1]=arguments[A];for(var S=1;S<arguments.length;S++){var C=arguments[S];for(var d in C)b[d]=C[d]}return b}function R(b,w,O){var A=this,S={enumerable:!0};A.hasBeenReset=!1;var C="",d=!1,o=b,s=w,u=O,T=null,m="",p=!0,_="auto",v="start",c=50,h="middle",l=50,a="middle";Object.defineProperty(A,"id",M({},S,{get:function(){return C},set:function(f){C=""+f}})),Object.defineProperty(A,"pauseOnExit",M({},S,{get:function(){return d},set:function(f){d=!!f}})),Object.defineProperty(A,"startTime",M({},S,{get:function(){return o},set:function(f){if(typeof f!="number")throw new TypeError("Start time must be set to a number.");o=f,this.hasBeenReset=!0}})),Object.defineProperty(A,"endTime",M({},S,{get:function(){return s},set:function(f){if(typeof f!="number")throw new TypeError("End time must be set to a number.");s=f,this.hasBeenReset=!0}})),Object.defineProperty(A,"text",M({},S,{get:function(){return u},set:function(f){u=""+f,this.hasBeenReset=!0}})),Object.defineProperty(A,"region",M({},S,{get:function(){return T},set:function(f){T=f,this.hasBeenReset=!0}})),Object.defineProperty(A,"vertical",M({},S,{get:function(){return m},set:function(f){var x=j(f);if(x===!1)throw new SyntaxError("An invalid or illegal string was specified.");m=x,this.hasBeenReset=!0}})),Object.defineProperty(A,"snapToLines",M({},S,{get:function(){return p},set:function(f){p=!!f,this.hasBeenReset=!0}})),Object.defineProperty(A,"line",M({},S,{get:function(){return _},set:function(f){if(typeof f!="number"&&f!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");_=f,this.hasBeenReset=!0}})),Object.defineProperty(A,"lineAlign",M({},S,{get:function(){return v},set:function(f){var x=B(f);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");v=x,this.hasBeenReset=!0}})),Object.defineProperty(A,"position",M({},S,{get:function(){return c},set:function(f){if(f<0||f>100)throw new Error("Position must be between 0 and 100.");c=f,this.hasBeenReset=!0}})),Object.defineProperty(A,"positionAlign",M({},S,{get:function(){return h},set:function(f){var x=B(f);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");h=x,this.hasBeenReset=!0}})),Object.defineProperty(A,"size",M({},S,{get:function(){return l},set:function(f){if(f<0||f>100)throw new Error("Size must be between 0 and 100.");l=f,this.hasBeenReset=!0}})),Object.defineProperty(A,"align",M({},S,{get:function(){return a},set:function(f){var x=B(f);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");a=x,this.hasBeenReset=!0}})),A.displayState=void 0}return R.prototype.getCueAsHTML=function(){var b=self.WebVTT;return b.convertCueToDOMTree(self,this.text)},R}()},"./src/utils/vttparser.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"parseTimeStamp",function(){return y}),D.d(Q,"fixLineBreaks",function(){return w}),D.d(Q,"VTTParser",function(){return O});var V=D("./src/utils/vttcue.ts"),I=function(){function A(){}var S=A.prototype;return S.decode=function(d,o){if(!d)return"";if(typeof d!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(d))},A}();function y(A){function S(d,o,s,u){return(d|0)*3600+(o|0)*60+(s|0)+parseFloat(u||0)}var C=A.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return C?parseFloat(C[2])>59?S(C[2],C[3],0,C[4]):S(C[1],C[2],C[3],C[4]):null}var j=function(){function A(){this.values=Object.create(null)}var S=A.prototype;return S.set=function(d,o){!this.get(d)&&o!==""&&(this.values[d]=o)},S.get=function(d,o,s){return s?this.has(d)?this.values[d]:o[s]:this.has(d)?this.values[d]:o},S.has=function(d){return d in this.values},S.alt=function(d,o,s){for(var u=0;u<s.length;++u)if(o===s[u]){this.set(d,o);break}},S.integer=function(d,o){/^-?\d+$/.test(o)&&this.set(d,parseInt(o,10))},S.percent=function(d,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var s=parseFloat(o);if(s>=0&&s<=100)return this.set(d,s),!0}return!1},A}();function B(A,S,C,d){var o=d?A.split(d):[A];for(var s in o){if(typeof o[s]!="string")continue;var u=o[s].split(C);if(u.length!==2)continue;var T=u[0],m=u[1];S(T,m)}}var M=new V.default(0,0,""),R=M.align==="middle"?"middle":"center";function b(A,S,C){var d=A;function o(){var T=y(A);if(T===null)throw new Error("Malformed timestamp: "+d);return A=A.replace(/^[^\sa-zA-Z-]+/,""),T}function s(T,m){var p=new j;B(T,function(c,h){var l;switch(c){case"region":for(var a=C.length-1;a>=0;a--)if(C[a].id===h){p.set(c,C[a].region);break}break;case"vertical":p.alt(c,h,["rl","lr"]);break;case"line":l=h.split(","),p.integer(c,l[0]),p.percent(c,l[0])&&p.set("snapToLines",!1),p.alt(c,l[0],["auto"]),l.length===2&&p.alt("lineAlign",l[1],["start",R,"end"]);break;case"position":l=h.split(","),p.percent(c,l[0]),l.length===2&&p.alt("positionAlign",l[1],["start",R,"end","line-left","line-right","auto"]);break;case"size":p.percent(c,h);break;case"align":p.alt(c,h,["start",R,"end","left","right"]);break}},/:/,/\s/),m.region=p.get("region",null),m.vertical=p.get("vertical","");var _=p.get("line","auto");_==="auto"&&M.line===-1&&(_=-1),m.line=_,m.lineAlign=p.get("lineAlign","start"),m.snapToLines=p.get("snapToLines",!0),m.size=p.get("size",100),m.align=p.get("align",R);var v=p.get("position","auto");v==="auto"&&M.position===50&&(v=m.align==="start"||m.align==="left"?0:m.align==="end"||m.align==="right"?100:50),m.position=v}function u(){A=A.replace(/^\s+/,"")}if(u(),S.startTime=o(),u(),A.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+d);A=A.substr(3),u(),S.endTime=o(),u(),s(A,S)}function w(A){return A.replace(/<br(?: \/)?>/gi,`
|
|
`)}var O=function(){function A(){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 S=A.prototype;return S.parse=function(d){var o=this;d&&(o.buffer+=o.decoder.decode(d,{stream:!0}));function s(){var v=o.buffer,c=0;for(v=w(v);c<v.length&&v[c]!=="\r"&&v[c]!==`
|
|
`;)++c;var h=v.substr(0,c);return v[c]==="\r"&&++c,v[c]===`
|
|
`&&++c,o.buffer=v.substr(c),h}function u(v){B(v,function(c,h){},/:/)}try{var T="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;T=s();var m=T.match(/^()?WEBVTT([ \t].*)?$/);if(!m||!m[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var p=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;p?p=!1:T=s();switch(o.state){case"HEADER":/:/.test(T)?u(T):T||(o.state="ID");continue;case"NOTE":T||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(T)){o.state="NOTE";break}if(!T)continue;if(o.cue=new V.default(0,0,""),o.state="CUE",T.indexOf("-->")===-1){o.cue.id=T;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{b(T,o.cue,o.regionList)}catch(v){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var _=T.indexOf("-->")!==-1;if(!T||_&&(p=!0)){o.oncue&&o.cue&&o.oncue(o.cue),o.cue=null,o.state="ID";continue}if(o.cue===null)continue;o.cue.text&&(o.cue.text+=`
|
|
`),o.cue.text+=T}continue;case"BADCUE":T||(o.state="ID")}}}catch(v){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},S.flush=function(){var d=this;try{if((d.cue||d.state==="HEADER")&&(d.buffer+=`
|
|
|
|
`,d.parse()),d.state==="INITIAL"||d.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){d.onparsingerror&&d.onparsingerror(o)}return d.onflush&&d.onflush(),this},A}()},"./src/utils/webvtt-parser.ts":function(fe,Q,D){"use strict";D.r(Q),D.d(Q,"generateCueId",function(){return O}),D.d(Q,"parseWebVTT",function(){return S});var V=D("./src/polyfills/number.ts"),I=D("./src/utils/vttparser.ts"),y=D("./src/demux/id3.ts"),j=D("./src/utils/timescale-conversion.ts"),B=D("./src/remux/mp4-remuxer.ts"),M=/\r\n|\n\r|\n|\r/g,R=function(d,o,s){return s===void 0&&(s=0),d.substr(s,o.length)===o},b=function(d){var o=parseInt(d.substr(-3)),s=parseInt(d.substr(-6,2)),u=parseInt(d.substr(-9,2)),T=d.length>9?parseInt(d.substr(0,d.indexOf(":"))):0;if(!Object(V.isFiniteNumber)(o)||!Object(V.isFiniteNumber)(s)||!Object(V.isFiniteNumber)(u)||!Object(V.isFiniteNumber)(T))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+d);return o+=1e3*s,o+=60*1e3*u,o+=60*60*1e3*T,o},w=function(d){for(var o=5381,s=d.length;s;)o=o*33^d.charCodeAt(--s);return(o>>>0).toString()};function O(C,d,o){return w(C.toString())+w(d.toString())+w(o)}var A=function(d,o,s){var u=d[o],T=d[u.prevCC];if(!T||!T.new&&u.new){d.ccOffset=d.presentationOffset=u.start,u.new=!1;return}for(;(m=T)!==null&&m!==void 0&&m.new;){var m;d.ccOffset+=u.start-T.start,u.new=!1,u=T,T=d[u.prevCC]}d.presentationOffset=s};function S(C,d,o,s,u,T,m,p){var _=new I.VTTParser,v=Object(y.utf8ArrayToStr)(new Uint8Array(C)).trim().replace(M,`
|
|
`).split(`
|
|
`),c=[],h=Object(j.toMpegTsClockFromTimescale)(d,o),l="00:00.000",a=0,g=0,f,x=!0,P=!1;_.oncue=function(G){var X=s[u],ie=s.ccOffset,z=(a-h)/9e4;if(X!=null&&X.new&&(g!==void 0?ie=s.ccOffset=X.start:A(s,u,z)),z&&(ie=z-s.presentationOffset),P){var F=G.endTime-G.startTime,ne=Object(B.normalizePts)((G.startTime+ie-g)*9e4,T*9e4)/9e4;G.startTime=ne,G.endTime=ne+F}var ce=G.text.trim();G.text=decodeURIComponent(encodeURIComponent(ce)),G.id||(G.id=O(G.startTime,G.endTime,ce)),G.endTime>0&&c.push(G)},_.onparsingerror=function(G){f=G},_.onflush=function(){if(f){p(f);return}m(c)},v.forEach(function(G){if(x)if(R(G,"X-TIMESTAMP-MAP=")){x=!1,P=!0,G.substr(16).split(",").forEach(function(X){R(X,"LOCAL:")?l=X.substr(6):R(X,"MPEGTS:")&&(a=parseInt(X.substr(7)))});try{g=b(l)/1e3}catch(X){P=!1,f=X}return}else G===""&&(x=!1);_.parse(G+`
|
|
`)}),_.flush()}},"./src/utils/xhr-loader.ts":function(fe,Q,D){"use strict";D.r(Q);var V=D("./src/utils/logger.ts"),I=D("./src/loader/load-stats.ts"),y=/^age:\s*[\d.]+\s*$/m,j=function(){function B(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 M=B.prototype;return M.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},M.abortInternal=function(){var b=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),b&&(b.onreadystatechange=null,b.onprogress=null,b.readyState!==4&&(this.stats.aborted=!0,b.abort()))},M.abort=function(){var b;this.abortInternal(),(b=this.callbacks)!==null&&b!==void 0&&b.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},M.load=function(b,w,O){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=b,this.config=w,this.callbacks=O,this.retryDelay=w.retryDelay,this.loadInternal()},M.loadInternal=function(){var b=this.config,w=this.context;if(!b)return;var O=this.loader=new self.XMLHttpRequest,A=this.stats;A.loading.first=0,A.loaded=0;var S=this.xhrSetup;try{if(S)try{S(O,w.url)}catch(o){O.open("GET",w.url,!0),S(O,w.url)}O.readyState||O.open("GET",w.url,!0);var C=this.context.headers;if(C)for(var d in C)O.setRequestHeader(d,C[d])}catch(o){this.callbacks.onError({code:O.status,text:o.message},w,O);return}w.rangeEnd&&O.setRequestHeader("Range","bytes="+w.rangeStart+"-"+(w.rangeEnd-1)),O.onreadystatechange=this.readystatechange.bind(this),O.onprogress=this.loadprogress.bind(this),O.responseType=w.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout),O.send()},M.readystatechange=function(){var b=this.context,w=this.loader,O=this.stats;if(!b||!w)return;var A=w.readyState,S=this.config;if(O.aborted)return;if(A>=2)if(self.clearTimeout(this.requestTimeout),O.loading.first===0&&(O.loading.first=Math.max(self.performance.now(),O.loading.start)),A===4){w.onreadystatechange=null,w.onprogress=null;var C=w.status;if(C>=200&&C<300){O.loading.end=Math.max(self.performance.now(),O.loading.first);var d,o;if(b.responseType==="arraybuffer"?(d=w.response,o=d.byteLength):(d=w.responseText,o=d.length),O.loaded=O.total=o,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(O,b,d,w),!this.callbacks)return;var u={url:w.responseURL,data:d};this.callbacks.onSuccess(u,O,b,w)}else O.retry>=S.maxRetry||C>=400&&C<499?(V.logger.error(C+" while loading "+b.url),this.callbacks.onError({code:C,text:w.statusText},b,w)):(V.logger.warn(C+" while loading "+b.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,S.maxRetryDelay),O.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),S.timeout)},M.loadtimeout=function(){V.logger.warn("timeout while loading "+this.context.url);var b=this.callbacks;b&&(this.abortInternal(),b.onTimeout(this.stats,this.context,this.loader))},M.loadprogress=function(b){var w=this.stats;w.loaded=b.loaded,b.lengthComputable&&(w.total=b.total)},M.getCacheAge=function(){var b=null;if(this.loader&&y.test(this.loader.getAllResponseHeaders())){var w=this.loader.getResponseHeader("age");b=w?parseFloat(w):null}return b},B}();Q.default=j}}).default})},vHTk:function(gt,at,ue){gt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|