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.
NewEduCoderBuild/p__RestFul__Edit__index.7ab...

410 lines
896 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[218,7],{"+NIl":function(wt,pt,se){(function(re){re(se("VrN/"))})(function(re){"use strict";re.defineMode("stex",function(Z,D){"use strict";function Y(L,w){L.cmdState.push(w)}function N(L){return L.cmdState.length>0?L.cmdState[L.cmdState.length-1]:null}function M(L){var w=L.cmdState.pop();w&&w.closeBracket()}function H(L){for(var w=L.cmdState,b=w.length-1;b>=0;b--){var u=w[b];if(u.name=="DEFAULT")continue;return u}return{styleIdentifier:function(){return null}}}function U(L,w,b){return function(){this.name=L,this.bracketNo=0,this.style=w,this.styles=b,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var P={};P.importmodule=U("importmodule","tag",["string","builtin"]),P.documentclass=U("documentclass","tag",["","atom"]),P.usepackage=U("usepackage","tag",["atom"]),P.begin=U("begin","tag",["atom"]),P.end=U("end","tag",["atom"]),P.label=U("label","tag",["atom"]),P.ref=U("ref","tag",["atom"]),P.eqref=U("eqref","tag",["atom"]),P.cite=U("cite","tag",["atom"]),P.bibitem=U("bibitem","tag",["atom"]),P.Bibitem=U("Bibitem","tag",["atom"]),P.RBibitem=U("RBibitem","tag",["atom"]),P.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function _(L,w){L.f=w}function y(L,w){var b;if(L.match(/^\\[a-zA-Z@]+/)){var u=L.current().slice(1);return b=P.hasOwnProperty(u)?P[u]:P.DEFAULT,b=new b,Y(w,b),_(w,R),b.style}if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/\\]/))return"tag";if(L.match("\\["))return _(w,function(l,h){return A(l,h,"\\]")}),"keyword";if(L.match("\\("))return _(w,function(l,h){return A(l,h,"\\)")}),"keyword";if(L.match("$$"))return _(w,function(l,h){return A(l,h,"$$")}),"keyword";if(L.match("$"))return _(w,function(l,h){return A(l,h,"$")}),"keyword";var o=L.next();if(o=="%")return L.skipToEnd(),"comment";if(o=="}"||o=="]"){if(b=N(w),b)b.closeBracket(o),_(w,R);else return"error";return"bracket"}else return o=="{"||o=="["?(b=P.DEFAULT,b=new b,Y(w,b),"bracket"):/\d/.test(o)?(L.eatWhile(/[\w.%]/),"atom"):(L.eatWhile(/[\w\-_]/),b=H(w),b.name=="begin"&&(b.argument=L.current()),b.styleIdentifier())}function A(L,w,b){if(L.eatSpace())return null;if(b&&L.match(b))return _(w,y),"keyword";if(L.match(/^\\[a-zA-Z@]+/))return"tag";if(L.match(/^[a-zA-Z]+/))return"variable-2";if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/]/))return"tag";if(L.match(/^[\^_&]/))return"tag";if(L.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(L.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var u=L.next();return u=="{"||u=="}"||u=="["||u=="]"||u=="("||u==")"?"bracket":u=="%"?(L.skipToEnd(),"comment"):"error"}function R(L,w){var b=L.peek(),u;return b=="{"||b=="["?(u=N(w),u.openBracket(b),L.eat(b),_(w,y),"bracket"):/[ \t\r]/.test(b)?(L.eat(b),null):(_(w,y),M(w),y(L,w))}return{startState:function(){var L=D.inMathMode?function(w,b){return A(w,b)}:y;return{cmdState:[],f:L}},copyState:function(L){return{cmdState:L.cmdState.slice(),f:L.f}},token:function(L,w){return w.f(L,w)},blankLine:function(L){L.f=y,L.cmdState.length=0},lineComment:"%"}}),re.defineMIME("text/x-stex","stex"),re.defineMIME("text/x-latex","stex")})},"19Vz":function(wt,pt,se){(function(re){re(se("VrN/"))})(function(re){re.defineOption("placeholder","",function(U,P,_){var y=_&&_!=re.Init;if(P&&!y)U.on("blur",N),U.on("change",M),U.on("swapDoc",M),re.on(U.getInputField(),"compositionupdate",U.state.placeholderCompose=function(){Y(U)}),M(U);else if(!P&&y){U.off("blur",N),U.off("change",M),U.off("swapDoc",M),re.off(U.getInputField(),"compositionupdate",U.state.placeholderCompose),Z(U);var A=U.getWrapperElement();A.className=A.className.replace(" CodeMirror-empty","")}P&&!U.hasFocus()&&N(U)});function Z(U){U.state.placeholder&&(U.state.placeholder.parentNode.removeChild(U.state.placeholder),U.state.placeholder=null)}function D(U){Z(U);var P=U.state.placeholder=document.createElement("pre");P.style.cssText="height: 0; overflow: visible",P.style.direction=U.getOption("direction"),P.className="CodeMirror-placeholder CodeMirror-line-like";var _=U.getOption("placeholder");typeof _=="string"&&(_=document.createTextNode(_)),P.appendChild(_),U.display.lineSpace.insertBefore(P,U.display.lineSpace.firstChild)}function Y(U){setTimeout(function(){var P=!1,_=U.getInputField();_.nodeName=="TEXTAREA"?P=!_.value:U.lineCount()==1&&(P=!/[^\u200b]/.test(_.querySelector(".CodeMirror-line").textContent)),P?D(U):Z(U)},20)}function N(U){H(U)&&D(U)}function M(U){var P=U.getWrapperElement(),_=H(U);P.className=P.className.replace(" CodeMirror-empty","")+(_?" CodeMirror-empty":""),_?D(U):Z(U)}function H(U){return U.lineCount()===1&&U.getLine(0)===""}})},"1eCo":function(wt,pt,se){(function(re){re(se("VrN/"))})(function(re){"use strict";var Z={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},D={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};re.defineMode("xml",function(Y,N){var M=Y.indentUnit,H={},U=N.htmlMode?Z:D;for(var P in U)H[P]=U[P];for(var P in N)H[P]=N[P];var _,y;function A(a,x){function v(G){return x.tokenize=G,G(a,x)}var T=a.next();if(T=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?v(w("atom","]]>")):null:a.match("--")?v(w("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),v(b(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),x.tokenize=w("meta","?>"),"meta"):(_=a.eat("/")?"closeTag":"openTag",x.tokenize=R,"tag bracket");if(T=="&"){var I;return a.eat("#")?a.eat("x")?I=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):I=a.eatWhile(/[\d]/)&&a.eat(";"):I=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),I?"atom":"error"}else return a.eatWhile(/[^&<]/),null}A.isInText=!0;function R(a,x){var v=a.next();if(v==">"||v=="/"&&a.eat(">"))return x.tokenize=A,_=v==">"?"endTag":"selfcloseTag","tag bracket";if(v=="=")return _="equals",null;if(v=="<"){x.tokenize=A,x.state=h,x.tagName=x.tagStart=null;var T=x.tokenize(a,x);return T?T+" tag error":"tag error"}else return/[\'\"]/.test(v)?(x.tokenize=L(v),x.stringStartCol=a.column(),x.tokenize(a,x)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function L(a){var x=function(v,T){for(;!v.eol();)if(v.next()==a){T.tokenize=R;break}return"string"};return x.isInAttribute=!0,x}function w(a,x){return function(v,T){for(;!v.eol();){if(v.match(x)){T.tokenize=A;break}v.next()}return a}}function b(a){return function(x,v){for(var T;(T=x.next())!=null;){if(T=="<")return v.tokenize=b(a+1),v.tokenize(x,v);if(T==">")if(a==1){v.tokenize=A;break}else return v.tokenize=b(a-1),v.tokenize(x,v)}return"meta"}}function u(a,x,v){this.prev=a.context,this.tagName=x,this.indent=a.indented,this.startOfLine=v,(H.doNotIndent.hasOwnProperty(x)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function l(a,x){for(var v;;){if(!a.context)return;if(v=a.context.tagName,!H.contextGrabbers.hasOwnProperty(v)||!H.contextGrabbers[v].hasOwnProperty(x))return;o(a)}}function h(a,x,v){return a=="openTag"?(v.tagStart=x.column(),C):a=="closeTag"?g:h}function C(a,x,v){return a=="word"?(v.tagName=x.current(),y="tag",E):H.allowMissingTagName&&a=="endTag"?(y="tag bracket",E(a,x,v)):(y="error",C)}function g(a,x,v){if(a=="word"){var T=x.current();return v.context&&v.context.tagName!=T&&H.implicitlyClosed.hasOwnProperty(v.context.tagName)&&o(v),v.context&&v.context.tagName==T||H.matchClosing===!1?(y="tag",p):(y="tag error",k)}else return H.allowMissingTagName&&a=="endTag"?(y="tag bracket",p(a,x,v)):(y="error",k)}function p(a,x,v){return a!="endTag"?(y="error",p):(o(v),h)}function k(a,x,v){return y="error",p(a,x,v)}function E(a,x,v){if(a=="word")return y="attribute",f;if(a=="endTag"||a=="selfcloseTag"){var T=v.tagName,I=v.tagStart;return v.tagName=v.tagStart=null,a=="selfcloseTag"||H.autoSelfClosers.hasOwnProperty(T)?l(v,T):(l(v,T),v.context=new u(v,T,I==v.indented)),h}return y="error",E}function f(a,x,v){return a=="equals"?m:(H.allowMissing||(y="error"),E(a,x,v))}function m(a,x,v){return a=="string"?d:a=="word"&&H.allowUnquoted?(y="string",E):(y="error",E(a,x,v))}function d(a,x,v){return a=="string"?d:E(a,x,v)}return{startState:function(a){var x={tokenize:A,state:h,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(x.baseIndent=a),x},token:function(a,x){if(!x.tagName&&a.sol()&&(x.indented=a.indentation()),a.eatSpace())return null;_=null;var v=x.tokenize(a,x);return(v||_)&&v!="comment"&&(y=null,x.state=x.state(_||v,a,x),y&&(v=y=="error"?v+" error":y)),v},indent:function(a,x,v){var T=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+M;if(T&&T.noIndent)return re.Pass;if(a.tokenize!=R&&a.tokenize!=A)return v?v.match(/^(\s*)/)[0].length:0;if(a.tagName)return H.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+M*(H.multilineTagIndentFactor||1);if(H.alignCDATA&&/<!\[CDATA\[/.test(x))return 0;var I=x&&/^<(\/)?([\w_:\.-]*)/.exec(x);if(I&&I[1])for(;T;)if(T.tagName==I[2]){T=T.prev;break}else if(H.implicitlyClosed.hasOwnProperty(T.tagName))T=T.prev;else break;else if(I)for(;T;){var G=H.contextGrabbers[T.tagName];if(G&&G.hasOwnProperty(I[2]))T=T.prev;else break}for(;T&&T.prev&&!T.startOfLine;)T=T.prev;return T?T.indent+M:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:H.htmlMode?"html":"xml",helperType:H.htmlMode?"html":"xml",skipAttribute:function(a){a.state==m&&(a.state=E)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var x=[],v=a.context;v;v=v.prev)v.tagName&&x.push(v.tagName);return x.reverse()}}}),re.defineMIME("text/xml","xml"),re.defineMIME("application/xml","xml"),re.mimeModes.hasOwnProperty("text/html")||re.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"7Cbv":function(wt,pt,se){"use strict";var re=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),Z=new Uint8Array(16);function D(){if(!re)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return re(Z)}var Y=/^(?:[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 N(R){return typeof R=="string"&&Y.test(R)}for(var M=N,H=[],U=0;U<256;++U)H.push((U+256).toString(16).substr(1));function P(R){var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,w=(H[R[L+0]]+H[R[L+1]]+H[R[L+2]]+H[R[L+3]]+"-"+H[R[L+4]]+H[R[L+5]]+"-"+H[R[L+6]]+H[R[L+7]]+"-"+H[R[L+8]]+H[R[L+9]]+"-"+H[R[L+10]]+H[R[L+11]]+H[R[L+12]]+H[R[L+13]]+H[R[L+14]]+H[R[L+15]]).toLowerCase();if(!M(w))throw TypeError("Stringified UUID is invalid");return w}var _=P;function y(R,L,w){R=R||{};var b=R.random||(R.rng||D)();if(b[6]=b[6]&15|64,b[8]=b[8]&63|128,L){w=w||0;for(var u=0;u<16;++u)L[w+u]=b[u];return L}return _(b)}var A=pt.a=y},"7ahc":function(wt,pt,se){"use strict";se.d(pt,"a",function(){return C});var re=se("k1fw"),Z=se("0Owb"),D=se("+L6B"),Y=se("2/Rp"),N=se("y8nQ"),M=se("Vl3Y"),H=se("tJVT"),U=se("OaEy"),P=se("2fM7"),_=se("q1tI"),y=se.n(_),A=se("VrN/"),R=se.n(A),L=se("p77/"),w=se.n(L),b=se("c5Ni"),u=se.n(b),o=P.a.Option,l={labelCol:{span:4},wrapperCol:{span:20}},h={asp:["ASP","vbscript"],actionscript:["ActionScript(3.0)/Flash/Flex","clike"],bash:["Bash/Bat","shell"],css:["CSS","css"],c:["C","clike"],cpp:["C++","clike"],csharp:["C#","clike"],coffeescript:["CoffeeScript","coffeescript"],d:["D","d"],dart:["Dart","dart"],delphi:["Delphi/Pascal","pascal"],erlang:["Erlang","erlang"],go:["Golang","go"],groovy:["Groovy","groovy"],html:["HTML","text/html"],java:["Java","clike"],json:["JSON","text/json"],javascript:["Javascript","javascript"],lua:["Lua","lua"],less:["LESS","css"],markdown:["Markdown","gfm"],"objective-c":["Objective-C","clike"],php:["PHP","php"],perl:["Perl","perl"],python:["Python","python"],r:["R","r"],rst:["reStructedText","rst"],ruby:["Ruby","ruby"],sql:["SQL","sql"],sass:["SASS/SCSS","sass"],shell:["Shell","shell"],scala:["Scala","clike"],swift:["Swift","clike"],vb:["VB/VBScript","vb"],xml:["XML","text/xml"],yaml:["YAML","yaml"]};pt.b=function(g){var p=g.callback,k=g.onCancel,E=Object(_.useState)("python"),f=Object(H.a)(E,2),m=f[0],d=f[1];function a(v){d(h[v][1])}function x(v){p(v)}return y.a.createElement(M.a,Object(Z.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:x}),y.a.createElement(M.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},y.a.createElement(P.a,{onChange:a},Object.keys(h).map(function(v){return y.a.createElement(o,{key:v,value:v},h[v][0])}))),y.a.createElement(M.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},y.a.createElement(C,{mode:m})),y.a.createElement("div",{className:"flex-container flex-end"},y.a.createElement(Y.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),y.a.createElement(Y.a,{type:"ghost",onClick:k},"\u53D6\u6D88")))};function C(g){var p=g.value,k=g.onChange,E=g.mode,f=g.options,m=f===void 0?{}:f,d=Object(_.useRef)(),a=Object(_.useState)(),x=Object(H.a)(a,2),v=x[0],T=x[1];return Object(_.useEffect)(function(){if(v){function I(G){var V=G.getValue();k&&k(V)}return v.on("change",I),function(){v.off("change",I)}}},[v,k]),Object(_.useEffect)(function(){v&&v.setOption("mode",E)},[v,E]),Object(_.useEffect)(function(){v&&((p!==v.getValue()||p==="")&&setTimeout(function(){v.setValue(p||" ")},300))},[v,p]),Object(_.useEffect)(function(){if(d.current&&!v){var I=R.a.fromTextArea(d.current,Object(re.a)({mode:E,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},m));T(I)}},[d.current,v]),y.a.createElement("div",{className:"my-codemirror-container"},y.a.createElement("textarea",{ref:d}))}},"7ixt":function(wt,pt,se){"use strict";se.d(pt,"a",function(){return D});var re={adjustX:1,adjustY:1},Z=[0,0],D={left:{points:["cr","cl"],overflow:re,offset:[-4,0],targetOffset:Z},right:{points:["cl","cr"],overflow:re,offset:[4,0],targetOffset:Z},top:{points:["bc","tc"],overflow:re,offset:[0,-4],targetOffset:Z},bottom:{points:["tc","bc"],overflow:re,offset:[0,4],targetOffset:Z},topLeft:{points:["bl","tl"],overflow:re,offset:[0,-4],targetOffset:Z},leftTop:{points:["tr","tl"],overflow:re,offset:[-4,0],targetOffset:Z},topRight:{points:["br","tr"],overflow:re,offset:[0,-4],targetOffset:Z},rightTop:{points:["tl","tr"],overflow:re,offset:[4,0],targetOffset:Z},bottomRight:{points:["tr","br"],overflow:re,offset:[0,4],targetOffset:Z},rightBottom:{points:["bl","br"],overflow:re,offset:[4,0],targetOffset:Z},bottomLeft:{points:["tl","bl"],overflow:re,offset:[0,4],targetOffset:Z},leftBottom:{points:["br","bl"],overflow:re,offset:[-4,0],targetOffset:Z}},Y=D},"8EBN":function(wt,pt,se){(function(re){re(se("VrN/"))})(function(re){"use strict";re.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var Z=0;Z<re.modeInfo.length;Z++){var D=re.modeInfo[Z];D.mimes&&(D.mime=D.mimes[0])}re.findModeByMIME=function(Y){Y=Y.toLowerCase();for(var N=0;N<re.modeInfo.length;N++){var M=re.modeInfo[N];if(M.mime==Y)return M;if(M.mimes){for(var H=0;H<M.mimes.length;H++)if(M.mimes[H]==Y)return M}}if(/\+xml$/.test(Y))return re.findModeByMIME("application/xml");if(/\+json$/.test(Y))return re.findModeByMIME("application/json")},re.findModeByExtension=function(Y){Y=Y.toLowerCase();for(var N=0;N<re.modeInfo.length;N++){var M=re.modeInfo[N];if(M.ext){for(var H=0;H<M.ext.length;H++)if(M.ext[H]==Y)return M}}},re.findModeByFileName=function(Y){for(var N=0;N<re.modeInfo.length;N++){var M=re.modeInfo[N];if(M.file&&M.file.test(Y))return M}var H=Y.lastIndexOf("."),U=H>-1&&Y.substring(H+1,Y.length);if(U)return re.findModeByExtension(U)},re.findModeByName=function(Y){Y=Y.toLowerCase();for(var N=0;N<re.modeInfo.length;N++){var M=re.modeInfo[N];if(M.name.toLowerCase()==Y)return M;if(M.alias){for(var H=0;H<M.alias.length;H++)if(M.alias[H].toLowerCase()==Y)return M}}}})},"8hTe":function(wt,pt,se){wt.exports={button:"button___1wy9m"}},"9Bee":function(wt,pt,se){"use strict";var re=se("DYRE"),Z=se("zeV3"),D=se("+L6B"),Y=se("2/Rp"),N=se("k1fw"),M=se("9og8"),H=se("tJVT"),U=se("WmNS"),P=se.n(U),_=se("q1tI"),y=se.n(_),A=se("vg9a"),R=se("DlQD"),L=se.n(R),w=se("rUJ1");function b(W,s){var c=W.match(/^(\s+)(?:```)/);if(c===null)return s;var O=c[1];return s.split(`
`).map(function($){var F=$.match(/^\s+/);if(F===null)return $;var he=Object(H.a)(F,1),Re=he[0];return Re.length>=O.length?$.slice(O.length):$}).join(`
`)}var u=[],o=["<ul>"],l=new L.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function C(){u.length=0,o=["<ul>"]}var g={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function p(W,s,c,O){if(s>=W.length||W[s].level<=c)return s;var $=W[s];O.push("<li><a href='#"+$.anchor+"'>"+$.text+"</a>"),s++;var F=[];return s=p(W,s,$.level,F),F.length>0&&(O.push("<ul>"),F.forEach(function(he){O.push(he)}),O.push("</ul>")),O.push("</li>"),s=p(W,s,c,O),s}function k(){return p(u,0,0,o),o.push("</ul>"),o.join("")}var E={heading:function(s){var c=h.exec(s);if(c)return{type:"heading",raw:c[0],depth:c[1].length,text:c[2]}},fences:function(s){var c=this.rules.block.fences.exec(s);if(c){var O=c[0],$=b(O,c[3]||""),F=c[2]?c[2].trim():c[2];if(["latex","katex","math"].indexOf(F)>=0){var he=d(),Re=$;$=he,a[he]={type:"block",expression:Re}}return{type:"code",raw:O,lang:F,text:$}}}},f=/(?:\${2})([^\n`]+?)(?:\${2})/gi,m=0,d=function(){return"__special_katext_id_".concat(m++,"__")},a={};function x(){return a}function v(){m=0,a={}}function T(W){return W=W.replace(f,function(s,c){var O=d();return a[O]={type:"inline",expression:c},O}),W}var I=l.listitem;l.listitem=function(W){return I(T(W))};var G=l.paragraph;l.paragraph=function(W){return G(T(W))};var V=l.tablecell;l.tablecell=function(W,s){return V(T(W),s)},l.code=function(W,s,c){var O=(s||"").match(/\S*/)[0];return O?["latex","katex","math"].indexOf(O)>=0?"<p class='editormd-tex'>".concat(W,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(c?W:Object(w.escape)(W,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(c?W:Object(w.escape)(W,!0))+"</code></pre>"},l.heading=function(W,s,c){var O=this.options.headerPrefix+c.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return u.push({anchor:O,level:s,text:W}),"<h"+s+' id="'+O+'">'+W+"</h"+s+">"},L.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),L.a.use({tokenizer:E,renderer:l});var Q=L.a,z=se("SJMd"),j=se("ulZh"),q=se.n(j),ie=se("m3rI"),ce=se("Oy/b"),ve=se("p5ED"),Oe=se("ErOA");/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var xe=function(W,s){return(xe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,O){c.__proto__=O}||function(c,O){for(var $ in O)Object.prototype.hasOwnProperty.call(O,$)&&(c[$]=O[$])})(W,s)};function Te(W,s){function c(){this.constructor=W}xe(W,s),W.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function we(W,s,c,O){return new(c||(c=Promise))(function($,F){function he(ht){try{Ke(O.next(ht))}catch(Pe){F(Pe)}}function Re(ht){try{Ke(O.throw(ht))}catch(Pe){F(Pe)}}function Ke(ht){var Pe;ht.done?$(ht.value):(Pe=ht.value,Pe instanceof c?Pe:new c(function(vt){vt(Pe)})).then(he,Re)}Ke((O=O.apply(W,s||[])).next())})}function Se(W,s){var c,O,$,F,he={label:0,sent:function(){if(1&$[0])throw $[1];return $[1]},trys:[],ops:[]};return F={next:Re(0),throw:Re(1),return:Re(2)},typeof Symbol=="function"&&(F[Symbol.iterator]=function(){return this}),F;function Re(Ke){return function(ht){return function(Pe){if(c)throw new TypeError("Generator is already executing.");for(;he;)try{if(c=1,O&&($=2&Pe[0]?O.return:Pe[0]?O.throw||(($=O.return)&&$.call(O),0):O.next)&&!($=$.call(O,Pe[1])).done)return $;switch(O=0,$&&(Pe=[2&Pe[0],$.value]),Pe[0]){case 0:case 1:$=Pe;break;case 4:return he.label++,{value:Pe[1],done:!1};case 5:he.label++,O=Pe[1],Pe=[0];continue;case 7:Pe=he.ops.pop(),he.trys.pop();continue;default:if(!($=he.trys,($=$.length>0&&$[$.length-1])||Pe[0]!==6&&Pe[0]!==2)){he=0;continue}if(Pe[0]===3&&(!$||Pe[1]>$[0]&&Pe[1]<$[3])){he.label=Pe[1];break}if(Pe[0]===6&&he.label<$[1]){he.label=$[1],$=Pe;break}if($&&he.label<$[2]){he.label=$[2],he.ops.push(Pe);break}$[2]&&he.ops.pop(),he.trys.pop();continue}Pe=s.call(W,he)}catch(vt){Pe=[6,vt],O=0}finally{c=$=0}if(5&Pe[0])throw Pe[1];return{value:Pe[0]?Pe[1]:void 0,done:!0}}([Ke,ht])}}}function pe(){for(var W=0,s=0,c=arguments.length;s<c;s++)W+=arguments[s].length;var O=Array(W),$=0;for(s=0;s<c;s++)for(var F=arguments[s],he=0,Re=F.length;he<Re;he++,$++)O[$]=F[he];return O}var oe=function(){function W(){}return W.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},W.setAttributes=function(s,c){for(var O=0,$=c;O<$.length;O++){var F=$[O],he=F[0],Re=F[1];s.setAttribute(he,Re)}},W.createRect=function(s,c,O){var $=document.createElementNS("http://www.w3.org/2000/svg","rect");return $.setAttribute("width",s.toString()),$.setAttribute("height",c.toString()),O&&W.setAttributes($,O),$},W.createLine=function(s,c,O,$,F){var he=document.createElementNS("http://www.w3.org/2000/svg","line");return he.setAttribute("x1",s.toString()),he.setAttribute("y1",c.toString()),he.setAttribute("x2",O.toString()),he.setAttribute("y2",$.toString()),F&&W.setAttributes(he,F),he},W.createPolygon=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg","polygon");return O.setAttribute("points",s),c&&W.setAttributes(O,c),O},W.createCircle=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg","circle");return O.setAttribute("cx",(s/2).toString()),O.setAttribute("cy",(s/2).toString()),O.setAttribute("r",s.toString()),c&&W.setAttributes(O,c),O},W.createEllipse=function(s,c,O){var $=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return $.setAttribute("cx",(s/2).toString()),$.setAttribute("cy",(c/2).toString()),$.setAttribute("rx",(s/2).toString()),$.setAttribute("ry",(c/2).toString()),O&&W.setAttributes($,O),$},W.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&W.setAttributes(c,s),c},W.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},W.createMarker=function(s,c,O,$,F,he,Re){var Ke=document.createElementNS("http://www.w3.org/2000/svg","marker");return W.setAttributes(Ke,[["id",s],["orient",c],["markerWidth",O.toString()],["markerHeight",$.toString()],["refX",F.toString()],["refY",he.toString()]]),Ke.appendChild(Re),Ke},W.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&W.setAttributes(c,s),c},W.createTSpan=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg","tspan");return O.textContent=s,c&&W.setAttributes(O,c),O},W.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&W.setAttributes(c,s),c},W.createPoint=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return O.x=s,O.y=c,O},W.createPath=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg","path");return O.setAttribute("d",s),c&&W.setAttributes(O,c),O},W}(),De=function(){function W(){}return W.addKey=function(s){W.key=s},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}(),Ve=function(){function W(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return W.prototype.rasterize=function(s,c,O){var $=this;return new Promise(function(F){var he=O!==void 0?O:document.createElement("canvas");s===null&&($.markersOnly=!0,$.naturalSize=!1);var Re=document.createElementNS("http://www.w3.org/2000/svg","svg");Re.setAttribute("xmlns","http://www.w3.org/2000/svg"),Re.setAttribute("width",c.width.baseVal.valueAsString),Re.setAttribute("height",c.height.baseVal.valueAsString),Re.setAttribute("viewBox","0 0 "+c.viewBox.baseVal.width.toString()+" "+c.viewBox.baseVal.height.toString()),Re.innerHTML=c.innerHTML,$.naturalSize===!0?(Re.width.baseVal.value=s.naturalWidth,Re.height.baseVal.value=s.naturalHeight):$.width!==void 0&&$.height!==void 0&&(Re.width.baseVal.value=$.width,Re.height.baseVal.value=$.height),he.width=Re.width.baseVal.value,he.height=Re.height.baseVal.value;var Ke=Re.outerHTML,ht=he.getContext("2d");$.markersOnly!==!0&&ht.drawImage(s,0,0,he.width,he.height);var Pe=window.URL,vt=new Image(he.width,he.height);vt.setAttribute("crossOrigin","anonymous");var Nt=new Blob([Ke],{type:"image/svg+xml"}),Kt=Pe.createObjectURL(Nt);vt.onload=function(){ht.drawImage(vt,0,0),Pe.revokeObjectURL(Kt);var Or=he.toDataURL($.imageType,$.imageQuality);F(Or)},vt.src=Kt})},W}(),ze=function(){},et=function(){function W(s){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}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(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},W.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},W.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new Je("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Je("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new Je("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new ke("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new ke("fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},W.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},W}(),Je=function(W,s){this.selector=W,this.style=s},ke=function(W,s){this.localName=W,this.style=s},Ie=function(){function W(s,c,O,$,F){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=s,this.displayMode=c,this.markerItems=O,this.uiStyleSettings=$,this.styles=F,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(s){var c=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var O=document.createElement("div");O.className=this.toolbarBlockStyleClass.name,O.style.whiteSpace="nowrap",this.uiContainer.appendChild(O),this.addActionButton(O,'<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(O,'<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(O,'<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(O,'<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(O,'<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(O,'<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(O,'<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(O,'<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(F){var he=document.createElement("div");he.className=""+c.toolbarButtonStyleClass.name,he.setAttribute("data-type-name",F.typeName),he.innerHTML=F.icon,he.addEventListener("click",function(){c.markerToolbarButtonClicked(he,F)}),c.buttons.push(he),c.markerButtons.push(he)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var $=document.createElement("div");$.className=this.toolbarBlockStyleClass.name,$.style.whiteSpace="nowrap",$.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild($),this.addActionButton($,'<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($,'<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(s){this.buttonClickListeners.push(s)},W.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},W.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},W.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var s=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var c=0;c<this.markerButtons.length;c++)c<s||c===s&&this.markerButtons.length-1===s?this.markerButtonBlock.appendChild(this.markerButtons[c]):(c===s&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[c]))}},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 s=this;this.buttons.forEach(function(c){c.className=c.className.replace(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name,"").trim(),c.className=c.className.replace(s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:s.toolbarActiveButtonStyleColorsClass.name,"").trim(),c.className+=" "+(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name)})},W.prototype.addActionButton=function(s,c,O){var $=this,F=document.createElement("div");switch(F.className=""+this.toolbarButtonStyleClass.name,F.innerHTML=c,F.setAttribute("data-action",O),F.addEventListener("click",function(){$.actionToolbarButtonClicked(F,O)}),O){case"select":F.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":F.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":F.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":F.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":F.style.fill=this.uiStyleSettings.closeButtonColor}s.appendChild(F),this.buttons.push(F)},W.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new ke("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 ke("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new ke("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new ke("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 ke("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new ke("toolbar_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
padding: `+s+`px;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new ke("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new ke("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Je("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new Je("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},W.prototype.markerToolbarButtonClicked=function(s,c){this.setActiveButton(s),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(O){return O("marker",c)}),this.markerButtonOverflowBlock.style.display="none"},W.prototype.actionToolbarButtonClicked=function(s,c){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(O){return O("action",c)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},W.prototype.setActiveButton=function(s){this.resetButtonStyles(),s.className=s.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),s.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},W.prototype.setActiveMarkerButton=function(s){var c=this.markerButtons.find(function(O){return O.getAttribute("data-type-name")===s});c&&this.setActiveButton(c)},W.prototype.setCurrentMarker=function(s){var c=this;this.currentMarker=s,this.buttons.filter(function(O){return/delete|notes/.test(O.getAttribute("data-action"))}).forEach(function(O){c.currentMarker===void 0?(O.style.fillOpacity="0.4",O.style.pointerEvents="none"):(O.style.fillOpacity="1",O.style.pointerEvents="all")})},W}(),He=function(){function W(s,c,O,$){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=c,this.uiStyleSettings=O,this.styles=$,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return W.prototype.addStyles=function(){var s;this.toolboxStyleClass=this.styles.addClass(new ke("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 ke("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var c=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new ke("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new ke("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new ke("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 ke("toolbox-panel-row_colors",`
background-color: `+((s=this.uiStyleSettings.toolboxBackgroundColor)!==null&&s!==void 0?s:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new ke("toolbox_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*c)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*c)+`px;
padding: `+c+`px;
box-sizing: content-box;
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new ke("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new ke("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new Je("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Je("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`))},W.prototype.show=function(s){var c;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolboxStyleClass.name+" "+((c=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&c!==void 0?c:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},W.prototype.setPanelButtons=function(s){var c,O,$=this;this.panels=s,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((c=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&c!==void 0?c:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((O=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&O!==void 0?O:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(F){var he;F.uiStyleSettings=$.uiStyleSettings;var Re=document.createElement("div");Re.className=$.toolboxButtonStyleClass.name+" "+((he=$.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&he!==void 0?he:$.toolboxButtonStyleColorsClass.name),Re.innerHTML=F.icon,Re.title=F.title,Re.addEventListener("click",function(){$.panelButtonClick(F)}),$.panelButtons.push(Re),$.buttonRow.appendChild(Re)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},W.prototype.panelButtonClick=function(s){var c=this,O=-1;if(s!==this.activePanel){O=this.panels.indexOf(s),this.panelRow.innerHTML="";var $=s.getUi();$.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild($),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=s}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){c.displayMode==="inline"?c.panelRow.style.display="none":c.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(F,he){var Re,Ke;F.className=c.toolboxButtonStyleClass.name+" "+(he===O?""+((Re=c.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Re!==void 0?Re:c.toolboxActiveButtonStyleColorsClass.name):""+((Ke=c.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Ke!==void 0?Ke:c.toolboxButtonStyleColorsClass.name))})},W}(),Ge=function(W,s){this.title=W,this.icon=s},je=function(W){function s(c,O,$,F){var he=W.call(this,c,F||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return he.colors=[],he.addTransparent=!1,he.colorBoxes=[],he.colors=O,he.currentColor=$,he.setCurrentColor=he.setCurrentColor.bind(he),he.getColorBox=he.getColorBox.bind(he),he}return Te(s,W),s.prototype.getUi=function(){var c=this,O=document.createElement("div");return O.style.overflow="hidden",O.style.whiteSpace="nowrap",this.colors.forEach(function($){var F=c.getColorBox($);O.appendChild(F),c.colorBoxes.push(F)}),O},s.prototype.getColorBox=function(c){var O=this,$=this.uiStyleSettings.toolbarHeight/4,F=this.uiStyleSettings.toolbarHeight-$,he=document.createElement("div");he.style.display="inline-block",he.style.boxSizing="content-box",he.style.width=F-2+"px",he.style.height=F-2+"px",he.style.padding="1px",he.style.marginRight="2px",he.style.marginBottom="2px",he.style.borderWidth="2px",he.style.borderStyle="solid",he.style.borderRadius=(F+2)/2+"px",he.style.borderColor=c===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",he.addEventListener("click",function(){O.setCurrentColor(c,he)});var Re=document.createElement("div");return Re.style.display="inline-block",Re.style.width=F-2+"px",Re.style.height=F-2+"px",Re.style.backgroundColor=c,Re.style.borderRadius=F/2+"px",c==="transparent"&&(Re.style.fill=this.uiStyleSettings.toolboxAccentColor,Re.innerHTML=`<svg viewBox="0 0 24 24">
<path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />
</svg>`),he.appendChild(Re),he},s.prototype.setCurrentColor=function(c,O){var $=this;this.currentColor=c,this.colorBoxes.forEach(function(F){F.style.borderColor=F===O?$.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(c)},s}(Ge),_e=function(){function W(s,c,O){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=c,this.globalSettings=O,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(s){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(s,c){},W.prototype.dblClick=function(s,c){},W.prototype.manipulate=function(s){},W.prototype.pointerUp=function(s){this.stateChanged()},W.prototype.dispose=function(){},W.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},W.prototype.getState=function(){return{typeName:W.typeName,state:this.state,notes:this.notes}},W.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},W.prototype.scale=function(s,c){},W.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},W.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},W.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var s=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),s.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(s)&&this.onStateChanged(this)}},W.typeName="MarkerBase",W}(),Be=function(){function W(){this.findGripByVisual=this.findGripByVisual.bind(this)}return W.prototype.findGripByVisual=function(s){return this.topLeft.ownsTarget(s)?this.topLeft:this.topCenter.ownsTarget(s)?this.topCenter:this.topRight.ownsTarget(s)?this.topRight:this.centerLeft.ownsTarget(s)?this.centerLeft:this.centerRight.ownsTarget(s)?this.centerRight:this.bottomLeft.ownsTarget(s)?this.bottomLeft:this.bottomCenter.ownsTarget(s)?this.bottomCenter:this.bottomRight.ownsTarget(s)?this.bottomRight:void 0},W}(),$e=function(){function W(){this.GRIP_SIZE=10,this.visual=oe.createGroup(),this.visual.appendChild(oe.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(oe.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return W.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},W}(),qe=function(){function W(){}return W.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},W.toSVGMatrix=function(s,c){return s.a=c.a,s.b=c.b,s.c=c.c,s.d=c.d,s.e=c.e,s.f=c.f,s},W}(),Qe=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.left=0,F.top=0,F.width=0,F.height=0,F.defaultSize={x:50,y:20},F.offsetX=0,F.offsetY=0,F.rotationAngle=0,F.CB_DISTANCE=10,F._suppressMarkerCreateEvent=!1,F.container.transform.baseVal.appendItem(oe.createTransform()),F.setupControlBox(),F}return Te(s,W),Object.defineProperty(s.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"visual",{get:function(){return this._visual},set:function(c){this._visual=c;var O=oe.createTransform();this._visual.transform.baseVal.appendItem(O)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!!W.prototype.ownsTarget.call(this,c)||!!(this.controlGrips.findGripByVisual(c)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(c))},s.prototype.pointerDown=function(c,O){W.prototype.pointerDown.call(this,c,O),this.state==="new"&&(this.left=c.x,this.top=c.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var $=this.unrotatePoint(c);if(this.manipulationStartX=$.x,this.manipulationStartY=$.y,this.offsetX=$.x-this.left,this.offsetY=$.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(O),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(O)){this.activeGrip=this.rotatorGrip;var F=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=F.x-this.width/2,this.top=F.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var he=this.container.transform.baseVal.getItem(0);he.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(he,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(c){var O=this.state;W.prototype.pointerUp.call(this,c),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(c),this._state="select",O==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},s.prototype.moveVisual=function(c){this.visual.style.transform="translate("+c.x+"px, "+c.y+"px)"},s.prototype.manipulate=function(c){var O=this.unrotatePoint(c);this.state==="creating"?this.resize(c):this.state==="move"?(this.left=this.manipulationStartLeft+(O.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(O.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(O):this.state==="rotate"&&this.rotate(c)},s.prototype.resize=function(c){var O=this.manipulationStartLeft,$=this.manipulationStartWidth,F=this.manipulationStartTop,he=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:O=this.manipulationStartLeft+c.x-this.manipulationStartX,$=this.manipulationStartWidth+this.manipulationStartLeft-O;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:$=this.manipulationStartWidth+c.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:F=this.manipulationStartTop+c.y-this.manipulationStartY,he=this.manipulationStartHeight+this.manipulationStartTop-F;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:he=this.manipulationStartHeight+c.y-this.manipulationStartY}$>=0?(this.left=O,this.width=$):(this.left=O+$,this.width=-$),he>=0?(this.top=F,this.height=he):(this.top=F+he,this.height=-he),this.setSize()},s.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},s.prototype.rotate=function(c){if(Math.abs(c.x-this.centerX)>.1){var O=Math.sign(c.x-this.centerX);this.rotationAngle=180*Math.atan((c.y-this.centerY)/(c.x-this.centerX))/Math.PI+90*O,this.applyRotation()}},s.prototype.applyRotation=function(){var c=this.container.transform.baseVal.getItem(0);c.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(c,0)},s.prototype.rotatePoint=function(c){if(this.rotationAngle===0)return c;var O=this.container.getCTM(),$=oe.createPoint(c.x,c.y);return{x:($=$.matrixTransform(O)).x,y:$.y}},s.prototype.unrotatePoint=function(c){if(this.rotationAngle===0)return c;var O=this.container.getCTM();O=O.inverse();var $=oe.createPoint(c.x,c.y);return{x:($=$.matrixTransform(O)).x,y:$.y}},s.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=oe.createGroup();var c=oe.createTransform();c.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(c),this.container.appendChild(this.controlBox),this.controlRect=oe.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=oe.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 Be,this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){var c=this.controlBox.transform.baseVal.getItem(0);c.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(c,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},s.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},s.prototype.createGrip=function(){var c=new $e;return c.visual.transform.baseVal.appendItem(oe.createTransform()),this.controlBox.appendChild(c.visual),c},s.prototype.positionGrips=function(){var c=this.controlGrips.topLeft.GRIP_SIZE,O=-c/2,$=O,F=(this.width+this.CB_DISTANCE)/2-c/2,he=(this.height+this.CB_DISTANCE)/2-c/2,Re=this.height+this.CB_DISTANCE-c/2,Ke=this.width+this.CB_DISTANCE-c/2;this.positionGrip(this.controlGrips.topLeft.visual,O,$),this.positionGrip(this.controlGrips.topCenter.visual,F,$),this.positionGrip(this.controlGrips.topRight.visual,Ke,$),this.positionGrip(this.controlGrips.centerLeft.visual,O,he),this.positionGrip(this.controlGrips.centerRight.visual,Ke,he),this.positionGrip(this.controlGrips.bottomLeft.visual,O,Re),this.positionGrip(this.controlGrips.bottomCenter.visual,F,Re),this.positionGrip(this.controlGrips.bottomRight.visual,Ke,Re),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,F,$-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(c,O,$){var F=c.transform.baseVal.getItem(0);F.setTranslate(O,$),c.transform.baseVal.replaceItem(F,0)},s.prototype.hideControlBox=function(){this.controlBox.style.display="none"},s.prototype.showControlBox=function(){this.controlBox.style.display=""},s.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:qe.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:qe.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},W.prototype.getState.call(this))},s.prototype.restoreState=function(c){W.prototype.restoreState.call(this,c);var O=c;this.left=O.left,this.top=O.top,this.width=O.width,this.height=O.height,this.rotationAngle=O.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(qe.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,O.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(qe.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,O.containerTransformMatrix))},s.prototype.scale=function(c,O){W.prototype.scale.call(this,c,O);var $=this.rotatePoint({x:this.left,y:this.top}),F=this.unrotatePoint({x:$.x*c,y:$.y*O});this.left=F.x,this.top=F.y,this.width=this.width*c,this.height=this.height*O,this.adjustControlBox()},s}(_e),Ze=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.fillColor="transparent",F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.opacity=1,F.setStrokeColor=F.setStrokeColor.bind(F),F.setFillColor=F.setFillColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.createVisual=F.createVisual.bind(F),F}return Te(s,W),s.prototype.ownsTarget=function(c){return!(!W.prototype.ownsTarget.call(this,c)&&c!==this.visual)},s.prototype.createVisual=function(){this.visual=oe.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,O){W.prototype.pointerDown.call(this,c,O),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){W.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){W.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){W.prototype.setSize.call(this),oe.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){W.prototype.pointerUp.call(this,c),this.setSize()},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.visual&&oe.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(c),this.stateChanged()},s.prototype.setFillColor=function(c){this.fillColor=c,this.visual&&oe.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.visual&&oe.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.visual&&oe.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},W.prototype.getState.call(this))},s.prototype.restoreState=function(c){var O=c;this.fillColor=O.fillColor,this.strokeColor=O.strokeColor,this.strokeWidth=O.strokeWidth,this.strokeDasharray=O.strokeDasharray,this.opacity=O.opacity,this.createVisual(),W.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,O){W.prototype.scale.call(this,c,O),this.setSize()},s.title="Rectangle marker",s}(Qe),ct=function(W){function s(c,O,$,F){var he=W.call(this,c,F||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return he.widths=[],he.widthBoxes=[],he.widths=O,he.currentWidth=$,he.setCurrentWidth=he.setCurrentWidth.bind(he),he}return Te(s,W),s.prototype.getUi=function(){var c=this,O=document.createElement("div");return O.style.display="flex",O.style.overflow="hidden",O.style.flexGrow="2",this.widths.forEach(function($){var F=document.createElement("div");F.style.display="flex",F.style.flexGrow="2",F.style.alignItems="center",F.style.justifyContent="space-between",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.borderColor=$===c.currentWidth?c.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){c.setCurrentWidth($,F)}),O.appendChild(F);var he=document.createElement("div");he.innerText=$.toString(),he.style.marginRight="5px",F.appendChild(he);var Re=document.createElement("div");Re.style.minHeight="20px",Re.style.flexGrow="2",Re.style.display="flex",Re.style.alignItems="center";var Ke=document.createElement("hr");Ke.style.minWidth="20px",Ke.style.border="0px",Ke.style.borderTop=$+"px solid "+c.uiStyleSettings.toolboxColor,Ke.style.flexGrow="2",Re.appendChild(Ke),F.appendChild(Re),c.widthBoxes.push(F)}),O},s.prototype.setCurrentWidth=function(c,O){var $=this;this.currentWidth=c,this.widthBoxes.forEach(function(F){F.style.borderColor=F===O?$.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}(Ge),it=function(W){function s(c,O,$,F){var he=W.call(this,c,F||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return he.styles=[],he.styleBoxes=[],he.styles=O,he.currentStyle=$,he.setCurrentStyle=he.setCurrentStyle.bind(he),he}return Te(s,W),s.prototype.getUi=function(){var c=this,O=document.createElement("div");return O.style.display="flex",O.style.overflow="hidden",O.style.flexGrow="2",this.styles.forEach(function($){var F=document.createElement("div");F.style.display="flex",F.style.alignItems="center",F.style.justifyContent="space-between",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.overflow="hidden",F.style.maxWidth=100/c.styles.length-5+"%",F.style.borderColor=$===c.currentStyle?c.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){c.setCurrentStyle($,F)}),O.appendChild(F);var he=document.createElement("div");he.style.minHeight="20px",he.style.flexGrow="2",he.style.overflow="hidden";var Re=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+c.uiStyleSettings.toolboxColor+'" stroke-width="3" '+($!==""?'stroke-dasharray="'+$+'"':"")+` />
</svg>`;he.innerHTML=Re,F.appendChild(he),c.styleBoxes.push(F)}),O},s.prototype.setCurrentStyle=function(c,O){var $=this;this.currentStyle=c,this.styleBoxes.forEach(function(F){F.style.borderColor=F===O?$.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}(Ge),rt=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.strokeColor=$.defaultColor,F.strokeWidth=$.defaultStrokeWidth,F.strokeDasharray=$.defaultStrokeDasharray,F.strokePanel=new je("Line color",$.defaultColorSet,$.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.strokeWidthPanel=new ct("Line width",$.defaultStrokeWidths,$.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new it("Line style",$.defaultStrokeDasharrays,$.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F}return Te(s,W),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=W.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="FrameMarker",s.title="Frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',s}(Ze),Ce=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},lt=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.x1=0,F.y1=0,F.x2=0,F.y2=0,F.defaultLength=50,F.manipulationStartX=0,F.manipulationStartY=0,F.manipulationStartX1=0,F.manipulationStartY1=0,F.manipulationStartX2=0,F.manipulationStartY2=0,F.setupControlBox(),F}return Te(s,W),s.prototype.ownsTarget=function(c){return!!W.prototype.ownsTarget.call(this,c)||!(!this.grip1.ownsTarget(c)&&!this.grip2.ownsTarget(c))},s.prototype.pointerDown=function(c,O){W.prototype.pointerDown.call(this,c,O),this.manipulationStartX=c.x,this.manipulationStartY=c.y,this.state==="new"&&(this.x1=c.x,this.y1=c.y,this.x2=c.x,this.y2=c.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(O)?this.activeGrip=this.grip1:this.grip2.ownsTarget(O)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(c){var O=this.state;W.prototype.pointerUp.call(this,c),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(c),this._state="select",O==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},s.prototype.adjustVisual=function(){},s.prototype.manipulate=function(c){this.state==="creating"?this.resize(c):this.state==="move"?(this.x1=this.manipulationStartX1+c.x-this.manipulationStartX,this.y1=this.manipulationStartY1+c.y-this.manipulationStartY,this.x2=this.manipulationStartX2+c.x-this.manipulationStartX,this.y2=this.manipulationStartY2+c.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(c)},s.prototype.resize=function(c){switch(this.activeGrip){case this.grip1:this.x1=c.x,this.y1=c.y;break;case this.grip2:case void 0:this.x2=c.x,this.y2=c.y}this.adjustVisual(),this.adjustControlBox()},s.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=oe.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){this.positionGrips()},s.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},s.prototype.createGrip=function(){var c=new $e;return c.visual.transform.baseVal.appendItem(oe.createTransform()),this.controlBox.appendChild(c.visual),c},s.prototype.positionGrips=function(){var c=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-c/2,this.y1-c/2),this.positionGrip(this.grip2.visual,this.x2-c/2,this.y2-c/2)},s.prototype.positionGrip=function(c,O,$){var F=c.transform.baseVal.getItem(0);F.setTranslate(O,$),c.transform.baseVal.replaceItem(F,0)},s.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},W.prototype.getState.call(this))},s.prototype.restoreState=function(c){W.prototype.restoreState.call(this,c);var O=c;this.x1=O.x1,this.y1=O.y1,this.x2=O.x2,this.y2=O.y2},s.prototype.scale=function(c,O){W.prototype.scale.call(this,c,O),this.x1=this.x1*c,this.y1=this.y1*O,this.x2=this.x2*c,this.y2=this.y2*O,this.adjustVisual(),this.adjustControlBox()},s}(_e),nt=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.setStrokeColor=F.setStrokeColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.strokeColor=$.defaultColor,F.strokeWidth=$.defaultStrokeWidth,F.strokeDasharray=$.defaultStrokeDasharray,F.strokePanel=new je("Line color",$.defaultColorSet,$.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.strokeWidthPanel=new ct("Line width",$.defaultStrokeWidths,$.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new it("Line style",$.defaultStrokeDasharrays,$.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F}return Te(s,W),s.prototype.ownsTarget=function(c){return!(!W.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.selectorLine&&c!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=oe.createGroup(),this.selectorLine=oe.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=oe.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,O){W.prototype.pointerDown.call(this,c,O),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},s.prototype.adjustVisual=function(){this.selectorLine&&this.visibleLine&&(this.selectorLine.setAttribute("x1",this.x1.toString()),this.selectorLine.setAttribute("y1",this.y1.toString()),this.selectorLine.setAttribute("x2",this.x2.toString()),this.selectorLine.setAttribute("y2",this.y2.toString()),this.visibleLine.setAttribute("x1",this.x1.toString()),this.visibleLine.setAttribute("y1",this.y1.toString()),this.visibleLine.setAttribute("x2",this.x2.toString()),this.visibleLine.setAttribute("y2",this.y2.toString()),oe.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),oe.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),oe.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.adjustVisual(),this.colorChanged(c)},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.adjustVisual()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},W.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){W.prototype.restoreState.call(this,c);var O=c;this.strokeColor=O.strokeColor,this.strokeWidth=O.strokeWidth,this.strokeDasharray=O.strokeDasharray,this.createVisual(),this.adjustVisual()},s.typeName="LineMarker",s.title="Line marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',s}(lt),Ae=function(W){function s(c,O,$,F){var he=W.call(this,c,F||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return he.fonts=[],he.fontBoxes=[],he.fonts=O,he.currentFont=$,he.setCurrentFont=he.setCurrentFont.bind(he),he}return Te(s,W),s.prototype.getUi=function(){var c=this,O=document.createElement("div");return O.style.overflow="hidden",O.style.flexGrow="2",this.fonts.forEach(function($){var F=document.createElement("div");F.style.display="inline-block",F.style.alignItems="center",F.style.justifyContent="space-between",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.overflow="hidden",F.style.maxWidth=100/c.fonts.length-5+"%",F.style.borderColor=$===c.currentFont?c.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){c.setCurrentFont($,F)}),O.appendChild(F);var he=document.createElement("div");he.style.display="flex",he.style.minHeight="20px",he.style.flexGrow="2",he.style.fontFamily=$,he.style.overflow="hidden";var Re=document.createElement("div");Re.style.whiteSpace="nowrap",Re.style.overflow="hidden",Re.style.textOverflow="ellipsis",Re.innerHTML="The quick brown fox jumps over the lazy dog",he.appendChild(Re),F.appendChild(he),c.fontBoxes.push(F)}),O},s.prototype.setCurrentFont=function(c,O){var $=this;this.currentFont=c,this.fontBoxes.forEach(function(F){F.style.borderColor=F===O?$.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}(Ge),Fe=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.color="transparent",F.padding=5,F.DEFAULT_TEXT="your text here",F.text=F.DEFAULT_TEXT,F.isMoved=!1,F.color=$.defaultColor,F.fontFamily=$.defaultFontFamily,F.defaultSize={x:100,y:30},F.setColor=F.setColor.bind(F),F.setFont=F.setFont.bind(F),F.renderText=F.renderText.bind(F),F.sizeText=F.sizeText.bind(F),F.textEditDivClicked=F.textEditDivClicked.bind(F),F.showTextEditor=F.showTextEditor.bind(F),F.setSize=F.setSize.bind(F),F.positionTextEditor=F.positionTextEditor.bind(F),F.colorPanel=new je("Color",$.defaultColorSet,$.defaultColor),F.colorPanel.onColorChanged=F.setColor,F.fontFamilyPanel=new Ae("Font",$.defaultFontFamilies,$.defaultFontFamily),F.fontFamilyPanel.onFontChanged=F.setFont,F}return Te(s,W),s.prototype.ownsTarget=function(c){if(W.prototype.ownsTarget.call(this,c)||c===this.visual||c===this.textElement||c===this.bgRectangle)return!0;var O=!1;return this.textElement.childNodes.forEach(function($){$===c&&(O=!0)}),O},s.prototype.createVisual=function(){this.visual=oe.createGroup(),this.bgRectangle=oe.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=oe.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(oe.createTransform()),this.textElement.transform.baseVal.appendItem(oe.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(c,O){W.prototype.pointerDown.call(this,c,O),this.isMoved=!1,this.pointerDownPoint=c,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.renderText=function(){var c=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(O){c.textElement.appendChild(oe.createTSpan(O.trim()===""?" ":O.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var c=this.textElement.getBBox(),O=1;if(c.width>0&&c.height>0){var $=(1*this.width-this.width*this.padding*2/100)/c.width,F=(1*this.height-this.height*this.padding*2/100)/c.height;O=Math.min($,F)}return O},s.prototype.getTextPosition=function(c){var O=this.textElement.getBBox(),$=0,F=0;return O.width>0&&O.height>0&&($=(this.width-O.width*c)/2,F=this.height/2-O.height*c/2),{x:$,y:F}},s.prototype.sizeText=function(){var c=this.textElement.getBBox(),O=this.getTextScale(),$=this.getTextPosition(O);$.y-=c.y*O,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+$.x+"px, "+$.y+"px) scale("+O+", "+O+")":(this.textElement.transform.baseVal.getItem(0).setTranslate($.x,$.y),this.textElement.transform.baseVal.getItem(1).setScale(O,O))},s.prototype.manipulate=function(c){W.prototype.manipulate.call(this,c),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(c.x-this.pointerDownPoint.x)>5||Math.abs(c.y-this.pointerDownPoint.y)>5)},s.prototype.resize=function(c){W.prototype.resize.call(this,c),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){W.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(oe.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),oe.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(c){var O=this.state;O==="creating"&&(this._suppressMarkerCreateEvent=!0),W.prototype.pointerUp.call(this,c),this.setSize(),(O==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},s.prototype.showTextEditor=function(){var c=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(O){O.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var O=Number.parseFloat(c.textEditor.style.fontSize);c.textEditor.clientWidth>=Number.parseInt(c.textEditor.style.maxWidth)&&O>.9;)O-=.1,c.textEditor.style.fontSize=Math.max(O,.9)+"em"}),this.textEditor.addEventListener("keyup",function(O){O.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(O){if(O.clipboardData){var $=O.clipboardData.getData("text"),F=window.getSelection();if(!F.rangeCount)return!1;F.deleteFromDocument(),F.getRangeAt(0).insertNode(document.createTextNode($)),O.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){c.textEditDivClicked(c.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},s.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var c=this.getTextScale(),O=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),$=this.textElement.getBBox(),F={x:$.width*c,y:$.height*c};O.x-=F.x/2,O.y-=F.y/2,this.textEditor.style.top=O.y+"px",this.textEditor.style.left=O.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-O.x+"px",this.textEditor.style.fontSize=Math.max(16*c,12)+"px",this.textElement.style.display="none"}},s.prototype.textEditDivClicked=function(c){this.text=c.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},s.prototype.select=function(){W.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),W.prototype.deselect.call(this)},s.prototype.dblClick=function(c,O){W.prototype.dblClick.call(this,c,O),this.showTextEditor()},s.prototype.setColor=function(c){this.textElement&&oe.setAttributes(this.textElement,[["fill",c]]),this.color=c,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(c)},s.prototype.setFont=function(c){this.textElement&&oe.setAttributes(this.textElement,[["font-family",c]]),this.fontFamily=c,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},s.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},s.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},W.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var O=c;this.color=O.color,this.fontFamily=O.fontFamily,this.padding=O.padding,this.text=O.text,this.createVisual(),W.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,O){W.prototype.scale.call(this,c,O),this.setSize(),this.sizeText(),this.positionTextEditor()},s.typeName="TextMarker",s.title="Text marker",s.icon='<svg viewBox="0 0 24 24"><path d="M9.6 14L12 7.7l2.4 6.3M11 5L5.5 19h2.2l1.1-3H15l1.1 3h2.2L13 5h-2z"/></svg>',s}(Qe),ge=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.color="transparent",F.lineWidth=3,F.drawing=!1,F.pixelRatio=1,F.color=$.defaultColor,F.lineWidth=$.defaultStrokeWidth,F.pixelRatio=$.freehandPixelRatio,F.setColor=F.setColor.bind(F),F.addCanvas=F.addCanvas.bind(F),F.finishCreation=F.finishCreation.bind(F),F.setLineWidth=F.setLineWidth.bind(F),F.colorPanel=new je("Color",$.defaultColorSet,$.defaultColor),F.colorPanel.onColorChanged=F.setColor,F.lineWidthPanel=new ct("Line width",$.defaultStrokeWidths,$.defaultStrokeWidth),F.lineWidthPanel.onWidthChanged=F.setLineWidth,F}return Te(s,W),s.prototype.ownsTarget=function(c){return!(!W.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=oe.createGroup(),this.drawingImage=oe.createImage(),this.visual.appendChild(this.drawingImage);var c=oe.createTransform();this.visual.transform.baseVal.appendItem(c),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,O){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(c.x,c.y),this.drawing=!0):W.prototype.pointerDown.call(this,c,O)},s.prototype.manipulate=function(c){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(c.x,c.y),this.canvasContext.stroke()):W.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){W.prototype.resize.call(this,c),oe.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),oe.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):W.prototype.pointerUp.call(this,c)},s.prototype.addCanvas=function(){this.overlayContainer.innerHTML="",this.canvasElement=document.createElement("canvas"),this.canvasElement.width=this.overlayContainer.clientWidth*this.pixelRatio,this.canvasElement.height=this.overlayContainer.clientHeight*this.pixelRatio,this.canvasContext=this.canvasElement.getContext("2d"),this.canvasContext.scale(this.pixelRatio,this.pixelRatio),this.overlayContainer.appendChild(this.canvasElement)},s.prototype.select=function(){this.state==="creating"&&this.finishCreation(),W.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),W.prototype.deselect.call(this)},s.prototype.finishCreation=function(){for(var c=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),O=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],$=O[0],F=O[1],he=O[2],Re=O[3],Ke=!1,ht=0;ht<this.canvasElement.height;ht++)for(var Pe=0;Pe<this.canvasElement.width;Pe++)c.data[ht*this.canvasElement.width*4+4*Pe+3]>0&&(Ke=!0,ht<F&&(F=ht),Pe<$&&($=Pe),ht>Re&&(Re=ht),Pe>he&&(he=Pe));if(Ke){this.left=$/this.pixelRatio,this.top=F/this.pixelRatio,this.width=(he-$)/this.pixelRatio,this.height=(Re-F)/this.pixelRatio;var vt=document.createElement("canvas");vt.width=he-$,vt.height=Re-F,vt.getContext("2d").putImageData(this.canvasContext.getImageData($,F,he-$,Re-F),0,0),this.drawingImgUrl=vt.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},s.prototype.setDrawingImage=function(){oe.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),oe.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(c){this.color=c,this.colorChanged(c)},s.prototype.setLineWidth=function(c){this.lineWidth=c},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({drawingImgUrl:this.drawingImgUrl},W.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){this.createVisual(),W.prototype.restoreState.call(this,c),this.drawingImgUrl=c.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(c,O){W.prototype.scale.call(this,c,O),this.setDrawingImage()},s.typeName="FreehandMarker",s.title="Freehand marker",s.icon='<svg viewBox="0 0 24 24"><path d="M9.75 20.85c1.78-.7 1.39-2.63.49-3.85-.89-1.25-2.12-2.11-3.36-2.94A9.817 9.817 0 014.54 12c-.28-.33-.85-.94-.27-1.06.59-.12 1.61.46 2.13.68.91.38 1.81.82 2.65 1.34l1.01-1.7C8.5 10.23 6.5 9.32 4.64 9.05c-1.06-.16-2.18.06-2.54 1.21-.32.99.19 1.99.77 2.77 1.37 1.83 3.5 2.71 5.09 4.29.34.33.75.72.95 1.18.21.44.16.47-.31.47-1.24 0-2.79-.97-3.8-1.61l-1.01 1.7c1.53.94 4.09 2.41 5.96 1.79m11.09-15.6c.22-.22.22-.58 0-.79l-1.3-1.3a.562.562 0 00-.78 0l-1.02 1.02 2.08 2.08M11 10.92V13h2.08l6.15-6.15-2.08-2.08L11 10.92z"/></svg>',s}(Qe),de=function(W){function s(c,O,$){var F=W.call(this,c,$||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return F.typeBoxes=[],F.currentType=O,F.setCurrentType=F.setCurrentType.bind(F),F}return Te(s,W),s.prototype.getUi=function(){var c=this,O=document.createElement("div");O.style.display="flex",O.style.overflow="hidden",O.style.flexGrow="2";for(var $=function(Re){var Ke="both";switch(Re){case 0:Ke="both";break;case 1:Ke="start";break;case 2:Ke="end";break;case 3:Ke="none"}var ht=document.createElement("div");if(ht.style.display="flex",ht.style.flexGrow="2",ht.style.alignItems="center",ht.style.justifyContent="space-between",ht.style.padding="5px",ht.style.borderWidth="2px",ht.style.borderStyle="solid",ht.style.borderColor=Ke===F.currentType?F.uiStyleSettings.toolboxAccentColor:"transparent",ht.addEventListener("click",function(){c.setCurrentType(Ke,ht)}),O.appendChild(ht),Ke==="both"||Ke==="start"){var Pe=document.createElement("div");Pe.style.display="flex",Pe.style.alignItems="center",Pe.style.minHeight="20px",Pe.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="`+(F.uiStyleSettings!==void 0?F.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,Pe.style.marginLeft="5px",ht.appendChild(Pe)}var vt=document.createElement("div");vt.style.display="flex",vt.style.alignItems="center",vt.style.minHeight="20px",vt.style.flexGrow="2";var Nt=document.createElement("hr");if(Nt.style.minWidth="20px",Nt.style.border="0px",Nt.style.borderTop="3px solid "+(F.uiStyleSettings!==void 0?F.uiStyleSettings.toolboxColor:"#eeeeee"),Nt.style.flexGrow="2",vt.appendChild(Nt),ht.appendChild(vt),Ke==="both"||Ke==="end"){var Kt=document.createElement("div");Kt.style.display="flex",Kt.style.alignItems="center",Kt.style.minHeight="20px",Kt.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="`+(F.uiStyleSettings!==void 0?F.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,Kt.style.marginRight="5px",ht.appendChild(Kt)}F.typeBoxes.push(ht)},F=this,he=0;he<4;he++)$(he);return O},s.prototype.setCurrentType=function(c,O){var $=this;this.currentType=c,this.typeBoxes.forEach(function(F){F.style.borderColor=F===O?$.uiStyleSettings!==void 0?$.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}(Ge),fe=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.arrowType="end",F.arrowBaseHeight=10,F.arrowBaseWidth=10,F.getArrowPoints=F.getArrowPoints.bind(F),F.setArrowType=F.setArrowType.bind(F),F.arrowTypePanel=new de("Arrow type","end"),F.arrowTypePanel.onArrowTypeChanged=F.setArrowType,F}return Te(s,W),s.prototype.ownsTarget=function(c){return!(!W.prototype.ownsTarget.call(this,c)&&c!==this.arrow1&&c!==this.arrow2)},s.prototype.getArrowPoints=function(c,O){var $=this.arrowBaseWidth+2*this.strokeWidth,F=this.arrowBaseHeight+2*this.strokeWidth;return c-$/2+","+(O+F/2)+" "+c+","+(O-F/2)+" "+(c+$/2)+","+(O+F/2)},s.prototype.createTips=function(){this.arrow1=oe.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(oe.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=oe.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(oe.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(c,O){W.prototype.pointerDown.call(this,c,O),this.state==="creating"&&this.createTips()},s.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",oe.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),oe.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var c=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),O=this.arrow1.transform.baseVal.getItem(0);O.setRotate(c,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(O,0);var $=this.arrow2.transform.baseVal.getItem(0);$.setRotate(c+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem($,0)}},s.prototype.setArrowType=function(c){this.arrowType=c,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({arrowType:this.arrowType},W.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){W.prototype.restoreState.call(this,c);var O=c;this.arrowType=O.arrowType,this.createTips(),this.adjustVisual()},s.typeName="ArrowMarker",s.title="Arrow marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',s}(nt),ee=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.fillColor=$.defaultFillColor,F.strokeWidth=0,F.fillPanel=new je("Color",$.defaultColorSet,$.defaultFillColor),F.fillPanel.onColorChanged=F.setFillColor,F}return Te(s,W),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=W.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="CoverMarker",s.title="Cover marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',s}(Ze),te=function(W){function s(c,O,$,F){var he=W.call(this,c,F||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return he.opacities=[],he.opacityBoxes=[],he.opacities=O,he.currentOpacity=$,he.setCurrentOpacity=he.setCurrentOpacity.bind(he),he}return Te(s,W),s.prototype.getUi=function(){var c=this,O=document.createElement("div");return O.style.display="flex",O.style.overflow="hidden",O.style.flexGrow="2",O.style.justifyContent="space-between",this.opacities.forEach(function($){var F=document.createElement("div");F.style.display="flex",F.style.alignItems="center",F.style.justifyContent="center",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.borderColor=$===c.currentOpacity?c.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){c.setCurrentOpacity($,F)}),O.appendChild(F);var he=document.createElement("div");he.innerText=100*$+"%",F.appendChild(he),c.opacityBoxes.push(F)}),O},s.prototype.setCurrentOpacity=function(c,O){var $=this;this.currentOpacity=c,this.opacityBoxes.forEach(function(F){F.style.borderColor=F===O?$.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}(Ge),ne=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.setOpacity=F.setOpacity.bind(F),F.fillColor=$.defaultHighlightColor,F.strokeWidth=0,F.opacity=$.defaultHighlightOpacity,F.fillPanel=new je("Color",$.defaultColorSet,F.fillColor),F.fillPanel.onColorChanged=F.setFillColor,F.opacityPanel=new te("Opacity",$.defaultOpacitySteps,F.opacity),F.opacityPanel.onOpacityChanged=F.setOpacity,F}return Te(s,W),s.prototype.setOpacity=function(c){this.opacity=c,this.visual&&oe.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=W.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="HighlightMarker",s.title="Highlight marker",s.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',s}(ee),ue='<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>',me=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.bgColor="transparent",F.tipPosition={x:0,y:0},F.tipBase1Position={x:0,y:0},F.tipBase2Position={x:0,y:0},F.tipMoving=!1,F.color=$.defaultStrokeColor,F.bgColor=$.defaultFillColor,F.fontFamily=$.defaultFontFamily,F.defaultSize={x:100,y:30},F.setBgColor=F.setBgColor.bind(F),F.getTipPoints=F.getTipPoints.bind(F),F.positionTip=F.positionTip.bind(F),F.setTipPoints=F.setTipPoints.bind(F),F.colorPanel=new je("Text color",$.defaultColorSet,F.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>'),F.colorPanel.onColorChanged=F.setColor,F.bgColorPanel=new je("Fill color",$.defaultColorSet,F.bgColor,ue),F.bgColorPanel.onColorChanged=F.setBgColor,F.fontFamilyPanel=new Ae("Font",$.defaultFontFamilies,$.defaultFontFamily),F.fontFamilyPanel.onFontChanged=F.setFont,F.tipGrip=new $e,F.tipGrip.visual.transform.baseVal.appendItem(oe.createTransform()),F.controlBox.appendChild(F.tipGrip.visual),F}return Te(s,W),s.prototype.ownsTarget=function(c){return W.prototype.ownsTarget.call(this,c)||this.tipGrip.ownsTarget(c)||this.tip===c},s.prototype.createTip=function(){oe.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=oe.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(c,O){this.state==="new"&&W.prototype.pointerDown.call(this,c,O),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(O)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):W.prototype.pointerDown.call(this,c,O)},s.prototype.pointerUp=function(c){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,W.prototype.pointerUp.call(this,c);else{var O=this.state==="creating";W.prototype.pointerUp.call(this,c),this.setTipPoints(O),this.positionTip()}},s.prototype.manipulate=function(c){if(this.tipMoving){var O=this.unrotatePoint(c);this.tipPosition={x:O.x-this.manipulationStartLeft,y:O.y-this.manipulationStartTop},this.positionTip()}else W.prototype.manipulate.call(this,c)},s.prototype.setBgColor=function(c){this.bgRectangle&&this.tip&&(oe.setAttributes(this.bgRectangle,[["fill",c]]),oe.setAttributes(this.tip,[["fill",c]])),this.bgColor=c,this.fillColorChanged(c)},s.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},s.prototype.setTipPoints=function(c){c===void 0&&(c=!1);var O=Math.min(this.height/2,15),$=this.height/5;c&&(this.tipPosition={x:O+$/2,y:this.height+20});var F=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?F<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?($=this.width/5,O=Math.min(this.width/2,15),this.tipBase1Position={x:O,y:0},this.tipBase2Position={x:O+$,y:0}):(this.tipBase1Position={x:0,y:O},this.tipBase2Position={x:0,y:O+$}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?F<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?($=this.width/5,O=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-O-$,y:0},this.tipBase2Position={x:this.width-O,y:0}):(this.tipBase1Position={x:this.width,y:O},this.tipBase2Position={x:this.width,y:O+$}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?F<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?($=this.width/5,O=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-O-$,y:this.height},this.tipBase2Position={x:this.width-O,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-O-$},this.tipBase2Position={x:this.width,y:this.height-O}):F<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?($=this.width/5,O=Math.min(this.width/2,15),this.tipBase1Position={x:O,y:this.height},this.tipBase2Position={x:O+$,y:this.height}):(this.tipBase1Position={x:0,y:this.height-O},this.tipBase2Position={x:0,y:this.height-O-$})},s.prototype.resize=function(c){W.prototype.resize.call(this,c),this.positionTip()},s.prototype.positionTip=function(){oe.setAttributes(this.tip,[["points",this.getTipPoints()]]);var c=this.tipGrip.visual.transform.baseVal.getItem(0);c.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(c,0)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.select=function(){this.positionTip(),W.prototype.select.call(this)},s.prototype.getState=function(){var c=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},W.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var O=c;this.bgColor=O.bgColor,this.tipPosition=O.tipPosition,W.prototype.restoreState.call(this,c),this.createTip(),this.setTipPoints()},s.prototype.scale=function(c,O){W.prototype.scale.call(this,c,O),this.tipPosition={x:this.tipPosition.x*c,y:this.tipPosition.y*O},this.positionTip()},s.typeName="CalloutMarker",s.title="Callout marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 2h16a2 2 0 012 2v12a2 2 0 01-2 2h-4l-4 4-4-4H4a2 2 0 01-2-2V4a2 2 0 012-2m0 2v12h4.83L12 19.17 15.17 16H20V4H4m2 3h12v2H6V7m0 4h10v2H6v-2z"/></svg>',s}(Fe),Ee=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.fillColor="transparent",F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.opacity=1,F.strokeColor=$.defaultColor,F.strokeWidth=$.defaultStrokeWidth,F.strokeDasharray=$.defaultStrokeDasharray,F.fillColor=$.defaultFillColor,F.setStrokeColor=F.setStrokeColor.bind(F),F.setFillColor=F.setFillColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.setOpacity=F.setOpacity.bind(F),F.createVisual=F.createVisual.bind(F),F.strokePanel=new je("Line color",pe($.defaultColorSet,["transparent"]),$.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.fillPanel=new je("Fill color",pe($.defaultColorSet,["transparent"]),F.fillColor,ue),F.fillPanel.onColorChanged=F.setFillColor,F.strokeWidthPanel=new ct("Line width",$.defaultStrokeWidths,$.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new it("Line style",$.defaultStrokeDasharrays,$.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F.opacityPanel=new te("Opacity",$.defaultOpacitySteps,F.opacity),F.opacityPanel.onOpacityChanged=F.setOpacity,F}return Te(s,W),s.prototype.ownsTarget=function(c){return!(!W.prototype.ownsTarget.call(this,c)&&c!==this.visual)},s.prototype.createVisual=function(){this.visual=oe.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,O){W.prototype.pointerDown.call(this,c,O),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){W.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){W.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){W.prototype.setSize.call(this),oe.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},s.prototype.pointerUp=function(c){W.prototype.pointerUp.call(this,c),this.setSize()},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.visual&&oe.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(c),this.stateChanged()},s.prototype.setFillColor=function(c){this.fillColor=c,this.visual&&oe.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(c),this.stateChanged()},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.visual&&oe.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.visual&&oe.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.setOpacity=function(c){this.opacity=c,this.visual&&oe.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},W.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var O=c;this.fillColor=O.fillColor,this.strokeColor=O.strokeColor,this.strokeWidth=O.strokeWidth,this.strokeDasharray=O.strokeDasharray,this.opacity=O.opacity,this.createVisual(),W.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,O){W.prototype.scale.call(this,c,O),this.setSize()},s.typeName="EllipseMarker",s.title="Ellipse marker",s.icon='<svg viewBox="0 0 24 24"><path d="M12 4C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',s}(Qe),Me=function(W){function s(c,O,$){return W.call(this,c,O,$)||this}return Te(s,W),Object.defineProperty(s.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!(!W.prototype.ownsTarget.call(this,c)&&c!==this.tip1&&c!==this.tip2)},s.prototype.createTips=function(){this.tip1=oe.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(oe.createTransform()),this.visual.appendChild(this.tip1),this.tip2=oe.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(oe.createTransform()),this.visual.appendChild(this.tip2)},s.prototype.pointerDown=function(c,O){W.prototype.pointerDown.call(this,c,O),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(W.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(oe.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()]]),oe.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 c=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),O=this.tip1.transform.baseVal.getItem(0);O.setRotate(c,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(O,0);var $=this.tip2.transform.baseVal.getItem(0);$.setRotate(c+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem($,0)}},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=W.prototype.getState.call(this);return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){W.prototype.restoreState.call(this,c),this.createTips(),this.adjustVisual()},s.typeName="MeasurementMarker",s.title="Measurement marker",s.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',s}(nt),tt=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.strokePanel.colors=$.defaultColorSet,F.fillColor="transparent",F}return Te(s,W),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=W.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="EllipseFrameMarker",s.title="Ellipse frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',s}(Ee),mt=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(s){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(s)||(this.undoStack.push(s),JSON.stringify(this.lastRedoStep)!==JSON.stringify(s)&&this.redoStack.splice(0,this.redoStack.length))},W.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},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 s=this.undoStack.pop();return s!==void 0&&this.redoStack.push(s),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}(),dt=function(W){function s(c,O,$){var F=W.call(this,c,O,$)||this;return F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.curveX=0,F.curveY=0,F.manipulationStartCurveX=0,F.manipulationStartCurveY=0,F.setStrokeColor=F.setStrokeColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.positionGrips=F.positionGrips.bind(F),F.addControlGrips=F.addControlGrips.bind(F),F.adjustVisual=F.adjustVisual.bind(F),F.setupControlBox=F.setupControlBox.bind(F),F.resize=F.resize.bind(F),F.strokeColor=$.defaultColor,F.strokeWidth=$.defaultStrokeWidth,F.strokeDasharray=$.defaultStrokeDasharray,F.strokePanel=new je("Line color",$.defaultColorSet,$.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.strokeWidthPanel=new ct("Line width",$.defaultStrokeWidths,$.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new it("Line style",$.defaultStrokeDasharrays,$.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F}return Te(s,W),s.prototype.ownsTarget=function(c){return!(!W.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.selectorCurve&&c!==this.visibleCurve&&!this.curveGrip.ownsTarget(c))},s.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},s.prototype.createVisual=function(){this.visual=oe.createGroup(),this.selectorCurve=oe.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=oe.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,O){W.prototype.pointerDown.call(this,c,O),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=c.x,this.curveY=c.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(O)&&(this.activeGrip=this.curveGrip,this._state="resize")},s.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),oe.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),oe.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),oe.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){W.prototype.setupControlBox.call(this),this.curveControlLine1=oe.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=oe.createLine(this.x2,this.y2,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.insertBefore(this.curveControlLine1,this.controlBox.firstChild),this.controlBox.insertBefore(this.curveControlLine2,this.controlBox.firstChild)},s.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,W.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){W.prototype.positionGrips.call(this);var c=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-c/2,this.curveY-c/2),this.curveControlLine1&&this.curveControlLine2&&(this.curveControlLine1.setAttribute("x1",this.x1.toString()),this.curveControlLine1.setAttribute("y1",this.y1.toString()),this.curveControlLine1.setAttribute("x2",this.curveX.toString()),this.curveControlLine1.setAttribute("y2",this.curveY.toString()),this.curveControlLine2.setAttribute("x1",this.x2.toString()),this.curveControlLine2.setAttribute("y1",this.y2.toString()),this.curveControlLine2.setAttribute("x2",this.curveX.toString()),this.curveControlLine2.setAttribute("y2",this.curveY.toString()))},s.prototype.manipulate=function(c){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+c.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+c.y-this.manipulationStartY),W.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){this.activeGrip===this.curveGrip&&(this.curveX=c.x,this.curveY=c.y),W.prototype.resize.call(this,c),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.adjustVisual(),this.colorChanged(c)},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.adjustVisual()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.adjustVisual()},s.prototype.scale=function(c,O){this.curveX=this.curveX*c,this.curveY=this.curveY*O,W.prototype.scale.call(this,c,O)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},W.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){W.prototype.restoreState.call(this,c);var O=c;this.strokeColor=O.strokeColor,this.strokeWidth=O.strokeWidth,this.strokeDasharray=O.strokeDasharray,this.curveX=O.curveX,this.curveY=O.curveY,this.createVisual(),this.adjustVisual()},s.typeName="CurveMarker",s.title="Curve marker",s.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',s}(lt),Ct=function(){function W(s,c){c===void 0&&(c=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=c}return Object.defineProperty(W.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),W.prototype.preventDefault=function(){this._defaultPrevented=!0},W}(),St=function(W){function s(c,O,$){var F=W.call(this,c,!1)||this;return F.dataUrl=O,F.state=$,F}return Te(s,W),s}(Ct),st=function(W){function s(c,O,$){$===void 0&&($=!1);var F=W.call(this,c,$)||this;return F.marker=O,F}return Te(s,W),s}(Ct),Ft=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(s,c){this[s].push(c)},W.prototype.removeEventListener=function(s,c){var O=this[s].indexOf(c);O>-1&&this[s].splice(O,1)},W}(),_t=function(){function W(s){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new Ce,this._isOpen=!1,this.undoRedoManager=new mt,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 Ft,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=W.instanceCounter++,this.styles=new et(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=s,this.targetRoot=document.body,this.width=s.clientWidth,this.height=s.clientHeight,this.styles.removeStyleSheet(),this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.toolbarButtonClicked=this.toolbarButtonClicked.bind(this),this.createNewMarker=this.createNewMarker.bind(this),this.addNewMarker=this.addNewMarker.bind(this),this.markerCreated=this.markerCreated.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onDblClick=this.onDblClick.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.deleteSelectedMarker=this.deleteSelectedMarker.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.removeMarker=this.removeMarker.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this),this.onPopupTargetResize=this.onPopupTargetResize.bind(this),this.showNotesEditor=this.showNotesEditor.bind(this),this.hideNotesEditor=this.hideNotesEditor.bind(this),this.stepZoom=this.stepZoom.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.markerStateChanged=this.markerStateChanged.bind(this),this.switchToSelectMode=this.switchToSelectMode.bind(this),this.addDefs=this.addDefs.bind(this),this.addDefsToImage=this.addDefsToImage.bind(this)}return Object.defineProperty(W.prototype,"ALL_MARKER_TYPES",{get:function(){return[rt,ge,fe,Fe,tt,Ee,ne,me,Me,ee,nt,dt]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[rt,ge,fe,Fe,Ee,ne,me]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"BASIC_MARKER_TYPES",{get:function(){return[rt,ge,fe,Fe,ne]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var c=this;this._availableMarkerTypes.splice(0),s.forEach(function(O){if(typeof O=="string"){var $=c.ALL_MARKER_TYPES.find(function(F){return F.typeName===O});$!==void 0&&c._availableMarkerTypes.push($)}else c._availableMarkerTypes.push(O)})},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(s){this._zoomLevel=s,this.editorCanvas&&this.contentDiv&&(this.editorCanvas.style.transform="scale("+this._zoomLevel+")",this.contentDiv.scrollTo({left:(this.editorCanvas.clientWidth*this._zoomLevel-this.contentDiv.clientWidth)/2,top:(this.editorCanvas.clientHeight*this._zoomLevel-this.contentDiv.clientHeight)/2}))},enumerable:!1,configurable:!0}),Object.defineProperty(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(),De.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},W.prototype.show=function(){var s=this;this.styles.styleSheetRoot===void 0&&ze.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=ze.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(c){return c(new Ct(s))})},W.prototype.render=function(){return we(this,void 0,void 0,function(){var s;return Se(this,function(c){switch(c.label){case 0:return this.setCurrentMarker(),(s=new Ve).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.markersOnly=this.renderMarkersOnly,s.width=this.renderWidth,s.height=this.renderHeight,[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return c.sent(),[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,c.sent()]}})})},W.prototype.close=function(s){var c=this;if(s===void 0&&(s=!1),this.isOpen){var O=!1;s||this.eventListeners.beforeclose.forEach(function($){var F=new Ct(c,!0);$(F),F.defaultPrevented&&(O=!0)}),O||(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($){return $(new Ct(c))}),this.detachEvents(),this._isOpen=!1)}},W.prototype.addMarkersToToolbar=function(){for(var s,c=[],O=0;O<arguments.length;O++)c[O]=arguments[O];(s=this._availableMarkerTypes).push.apply(s,c)},W.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(c){s(c.dataUrl,c.state)})},W.prototype.removeRenderEventListener=function(s){},W.prototype.addCloseEventListener=function(s){this.addEventListener("close",function(){s()})},W.prototype.removeCloseEventListener=function(s){},W.prototype.setupResizeObserver=function(){var s=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return s.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},W.prototype.onPopupTargetResize=function(){var s=1*this.target.clientWidth/this.target.clientHeight,c=this.editorCanvas.clientWidth/s>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*s:this.editorCanvas.clientWidth,O=c<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/s;this.resize(c,O)},W.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},W.prototype.resize=function(s,c){this._isResizing=!0;var O=s/this.imageWidth,$=c/this.imageHeight;this.imageWidth=Math.round(s),this.imageHeight=Math.round(c),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(O,$),this._isResizing=!1},W.prototype.scaleMarkers=function(s,c){var O,$=this;this._currentMarker&&this._currentMarker instanceof Fe?this._currentMarker.scale(s,c):(O=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(F){F!==$._currentMarker&&F.scale(s,c)}),O!==void 0&&this.setCurrentMarker(O)},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 s=this.editingTarget.getBoundingClientRect(),c=this.editorCanvas.getBoundingClientRect();this.left=s.left-c.left,this.top=s.top-c.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 s,c=[],O=0;O<arguments.length;O++)c[O]=arguments[O];this.defs=oe.createDefs(),this.addDefsToImage(),(s=this.defs).append.apply(s,c)},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 s=document.createElement("a");s.href="https://markerjs.com/",s.target="_blank",s.innerHTML='<svg viewBox="0 0 112 96" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path fill="#e5f20d" fill-opacity=".647" d="M0 40.386h111.96V95.62H0z"/><path d="M93.61 61.452c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.591 1.048-1.481 0-2.222-.74-2.222-2.22 0-16.617-.533-29.347-1.604-38.192-1.068-8.842-2.92-13.265-5.552-13.265-4.443 0-10.94 15.509-19.497 46.52v.124c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.592 1.048-1.48 0-2.22-.74-2.22-2.22 0-3.29.165-8.392.493-15.302.33-7.732.494-13.82.494-18.262 0-6.17-.186-10.55-.556-13.142-.37-2.591-1.172-3.887-2.406-3.887-2.796 0-6.333 5.12-10.612 15.363C38.494 34.367 34.01 46.44 29.32 60.34l-1.11 3.209a5.714 5.714 0 01-1.42 2.097c-.617.578-1.295.864-2.036.864-.987 0-1.644-.081-1.974-.247-.328-.162-.533-.656-.617-1.48-.41-4.03-.74-9.418-.987-16.165-.163-1.728-.329-4.566-.494-8.515-.822-13.901-1.562-23.3-2.221-28.196-.657-4.893-.987-7.628-.987-8.205 0-.657.33-1.44.987-2.345.659-.903 1.276-1.357 1.85-1.357 1.319 0 2.387.947 3.21 2.838.411.906.863 4.526 1.357 10.859.493 6.335.905 14.19 1.233 23.568l.617 18.88c4.527-13.983 9.216-26.673 14.068-38.068C45.65 6.686 50.093.988 54.123.988c2.715 0 4.566 1.974 5.553 5.923.987 3.949 1.481 9.667 1.481 17.152 0 3.949-.081 9.625-.247 17.029l-.123 5.676c3.373-11.762 6.725-21.634 10.057-29.615 3.331-7.979 6.685-11.97 10.056-11.97 8.475 0 12.71 18.757 12.71 56.269z" fill-rule="nonzero"/></svg>',s.title="Powered by marker.js",s.style.display="grid",s.style.alignItems="center",s.style.justifyItems="center",s.style.padding="3px",s.style.width="20px",s.style.height="20px",this.logoUI.appendChild(s),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},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 s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new Ie(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new He(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},W.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},W.prototype.removeMarker=function(s){this.markerImage.removeChild(s.container),this.markers.indexOf(s)>-1&&this.markers.splice(this.markers.indexOf(s),1),s.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(s,c){if(s==="marker"&&c!==void 0)this.createNewMarker(c);else if(s==="action")switch(c){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 s=this;if(this._currentMarker!==void 0){var c=!1;if(this.eventListeners.markerbeforedelete.forEach(function($){var F=new st(s,s._currentMarker,!0);$(F),F.defaultPrevented&&(c=!0)}),!c){var O=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($){return $(new st(s,O))})}}},W.prototype.clear=function(){var s=this,c=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(he){var Re=new st(s,void 0,!0);he(Re),Re.defaultPrevented&&(c=!0)}),!c)){this.setCurrentMarker();for(var O=function(he){var Re=$.markers[he];$.setCurrentMarker($.markers[he]),$._currentMarker.dispose(),$.markerImage.removeChild($._currentMarker.container),$.markers.splice($.markers.indexOf($._currentMarker),1),$.eventListeners.markerdelete.forEach(function(Ke){return Ke(new st(s,Re))})},$=this,F=this.markers.length-1;F>=0;F--)O(F);this.addUndoStep()}},Object.defineProperty(W.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),W.prototype.showNotesEditor=function(){var s;this._currentMarker!==void 0&&(this.overlayContainer.innerHTML="",this.notesArea=document.createElement("textarea"),this.notesArea.className=this.uiStyleSettings.notesAreaStyleClassName,this.notesArea.style.pointerEvents="auto",this.notesArea.style.alignSelf="stretch",this.notesArea.style.width="100%",this.notesArea.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.notesArea.value=(s=this._currentMarker.notes)!==null&&s!==void 0?s:"",this.overlayContainer.appendChild(this.notesArea))},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 s=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var c=this.getState(),O=this.undoRedoManager.getLastUndoStep();if(!O||O.width===c.width&&O.height===c.height){var $=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(c),$<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(F){return F(new Ct(s))})}else this.undoRedoManager.replaceLastUndoStep(c),this.eventListeners.statechange.forEach(function(F){return F(new Ct(s))})}},W.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},W.prototype.undoStep=function(){var s=this,c=this.undoRedoManager.undo();c!==void 0&&(this.restoreState(c),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(O){return O(new Ct(s))}))},W.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},W.prototype.redoStep=function(){var s=this,c=this.undoRedoManager.redo();c!==void 0&&(this.restoreState(c),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(O){return O(new Ct(s))}))},W.prototype.stepZoom=function(){var s=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=s<this.zoomSteps.length-1?this.zoomSteps[s+1]:this.zoomSteps[0]},W.prototype.panTo=function(s){this.contentDiv.scrollBy({left:this.prevPanPoint.x-s.x,top:this.prevPanPoint.y-s.y}),this.prevPanPoint=s},W.prototype.startRenderAndClose=function(){return we(this,void 0,void 0,function(){var s,c,O=this;return Se(this,function($){switch($.label){case 0:return[4,this.render()];case 1:return s=$.sent(),c=this.getState(),this.eventListeners.render.forEach(function(F){return F(new St(O,s,c))}),this.close(!0),[2]}})})},W.prototype.getState=function(s){s===!0&&this.setCurrentMarker();var c={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(O){return c.markers.push(O.getState())}),c},W.prototype.restoreState=function(s){var c=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);s.markers.forEach(function(O){var $=c._availableMarkerTypes.find(function(he){return he.typeName===O.typeName});if($!==void 0){var F=c.addNewMarker($);F.restoreState(O),c.markers.push(F)}}),s.width&&s.height&&(s.width!==this.imageWidth||s.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/s.width,this.imageHeight/s.height),this.eventListeners.restorestate.forEach(function(O){return O(new Ct(c))})},W.prototype.addNewMarker=function(s){var c=oe.createGroup();return this.markerImage.appendChild(c),new s(c,this.overlayContainer,this.settings)},W.prototype.createNewMarker=function(s){var c,O=this;(c=typeof s=="string"?this._availableMarkerTypes.find(function($){return $.typeName===s}):s)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(c),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(c.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function($){return $(new st(O,O._currentMarker))}))},W.prototype.markerCreated=function(s){var c=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof ge&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(ge):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(O){return O(new st(c,c._currentMarker))})},W.prototype.colorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=s,this.settings.defaultStrokeColor=s)},W.prototype.fillColorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=s)},W.prototype.markerStateChanged=function(s){var c=this;this.eventListeners.markerchange.forEach(function(O){return O(new st(c,s))})},W.prototype.setCurrentMarker=function(s){var c=this;this._currentMarker!==s&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(O){return O(new st(c,c._currentMarker))})),this._currentMarker=s,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(O){return O(new st(c,c._currentMarker))}))},W.prototype.onPointerDown=function(s){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||s.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var c=this.markers.find(function(O){return O.ownsTarget(s.target)});c!==void 0?(this.setCurrentMarker(c),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:s.clientX,y:s.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY))},W.prototype.onDblClick=function(s){if(this._isFocused||this.focus(),this.mode==="select"){var c=this.markers.find(function(O){return O.ownsTarget(s.target)});c!==void 0&&c!==this._currentMarker&&this.setCurrentMarker(c),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target):this.setCurrentMarker()}},W.prototype.onPointerMove=function(s){this.touchPoints!==1&&s.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||s.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(s.clientX,s.clientY)):this.zoomLevel>1&&this.panTo({x:s.clientX,y:s.clientY}))},W.prototype.onPointerUp=function(s){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(s.clientX,s.clientY)),this.isDragging=!1,this.addUndoStep()},W.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},W.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},W.prototype.clientToLocalCoordinates=function(s,c){var O=this.markerImage.getBoundingClientRect();return{x:(s-O.left)/this.zoomLevel,y:(c-O.top)/this.zoomLevel}},W.prototype.onWindowResize=function(){this.positionUI()},W.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.styles.settings.toolbarHeight+"px"}this.positionMarkerImage(),this.positionLogo()},W.prototype.addLicenseKey=function(s){De.addKey(s)},W.prototype.addEventListener=function(s,c){this.eventListeners.addEventListener(s,c)},W.prototype.removeEventListener=function(s,c){this.eventListeners.removeEventListener(s,c)},W.prototype.renderState=function(s){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(s),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(W.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),W.prototype.focus=function(){var s=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(c){return c(new Ct(s))}))},W.prototype.blur=function(){var s=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(c){return c(new Ct(s))}))},W.instanceCounter=0,W}();/* **********************************
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 Zt=function(W,s){return(Zt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,O){c.__proto__=O}||function(c,O){for(var $ in O)Object.prototype.hasOwnProperty.call(O,$)&&(c[$]=O[$])})(W,s)};function Xt(W,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function c(){this.constructor=W}Zt(W,s),W.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function Ot(W,s,c,O){return new(c||(c=Promise))(function($,F){function he(ht){try{Ke(O.next(ht))}catch(Pe){F(Pe)}}function Re(ht){try{Ke(O.throw(ht))}catch(Pe){F(Pe)}}function Ke(ht){var Pe;ht.done?$(ht.value):(Pe=ht.value,Pe instanceof c?Pe:new c(function(vt){vt(Pe)})).then(he,Re)}Ke((O=O.apply(W,s||[])).next())})}function Ir(W,s){var c,O,$,F,he={label:0,sent:function(){if(1&$[0])throw $[1];return $[1]},trys:[],ops:[]};return F={next:Re(0),throw:Re(1),return:Re(2)},typeof Symbol=="function"&&(F[Symbol.iterator]=function(){return this}),F;function Re(Ke){return function(ht){return function(Pe){if(c)throw new TypeError("Generator is already executing.");for(;he;)try{if(c=1,O&&($=2&Pe[0]?O.return:Pe[0]?O.throw||(($=O.return)&&$.call(O),0):O.next)&&!($=$.call(O,Pe[1])).done)return $;switch(O=0,$&&(Pe=[2&Pe[0],$.value]),Pe[0]){case 0:case 1:$=Pe;break;case 4:return he.label++,{value:Pe[1],done:!1};case 5:he.label++,O=Pe[1],Pe=[0];continue;case 7:Pe=he.ops.pop(),he.trys.pop();continue;default:if(!($=he.trys,($=$.length>0&&$[$.length-1])||Pe[0]!==6&&Pe[0]!==2)){he=0;continue}if(Pe[0]===3&&(!$||Pe[1]>$[0]&&Pe[1]<$[3])){he.label=Pe[1];break}if(Pe[0]===6&&he.label<$[1]){he.label=$[1],$=Pe;break}if($&&he.label<$[2]){he.label=$[2],he.ops.push(Pe);break}$[2]&&he.ops.pop(),he.trys.pop();continue}Pe=s.call(W,he)}catch(vt){Pe=[6,vt],O=0}finally{c=$=0}if(5&Pe[0])throw Pe[1];return{value:Pe[0]?Pe[1]:void 0,done:!0}}([Ke,ht])}}}var Kr=function(){function W(){}return W.addKey=function(s){W.key=s},Object.defineProperty(W,"isLicensed",{get:function(){return!!W.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(W.key)},enumerable:!1,configurable:!0}),W}(),bt=function(){function W(){}return W.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},W.setAttributes=function(s,c){for(var O=0,$=c;O<$.length;O++){var F=$[O],he=F[0],Re=F[1];s.setAttribute(he,Re)}},W.createRect=function(s,c,O){var $=document.createElementNS("http://www.w3.org/2000/svg","rect");return $.setAttribute("width",s.toString()),$.setAttribute("height",c.toString()),O&&W.setAttributes($,O),$},W.createLine=function(s,c,O,$,F){var he=document.createElementNS("http://www.w3.org/2000/svg","line");return he.setAttribute("x1",s.toString()),he.setAttribute("y1",c.toString()),he.setAttribute("x2",O.toString()),he.setAttribute("y2",$.toString()),F&&W.setAttributes(he,F),he},W.createPolygon=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg","polygon");return O.setAttribute("points",s),c&&W.setAttributes(O,c),O},W.createCircle=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg","circle");return O.setAttribute("cx",(s/2).toString()),O.setAttribute("cy",(s/2).toString()),O.setAttribute("r",s.toString()),c&&W.setAttributes(O,c),O},W.createEllipse=function(s,c,O){var $=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return $.setAttribute("cx",(s/2).toString()),$.setAttribute("cy",(c/2).toString()),$.setAttribute("rx",(s/2).toString()),$.setAttribute("ry",(c/2).toString()),O&&W.setAttributes($,O),$},W.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&W.setAttributes(c,s),c},W.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},W.createMarker=function(s,c,O,$,F,he,Re){var Ke=document.createElementNS("http://www.w3.org/2000/svg","marker");return W.setAttributes(Ke,[["id",s],["orient",c],["markerWidth",O.toString()],["markerHeight",$.toString()],["refX",F.toString()],["refY",he.toString()]]),Ke.appendChild(Re),Ke},W.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&W.setAttributes(c,s),c},W.createTSpan=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg","tspan");return O.textContent=s,c&&W.setAttributes(O,c),O},W.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&W.setAttributes(c,s),c},W.createPoint=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return O.x=s,O.y=c,O},W.createPath=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg","path");return O.setAttribute("d",s),c&&W.setAttributes(O,c),O},W.createElement=function(s,c){var O=document.createElementNS("http://www.w3.org/2000/svg",s);return c&&W.setAttributes(O,c),O},W.getHollowRectanglePath=function(s,c,O,$,F,he,Re,Ke){return"M"+s+","+c+"V"+(c+$)+"H"+(s+O)+"V"+c+"H"+F+"V"+he+"H"+(F+Re)+"V"+(he+Ke)+"H"+F+"V"+c+"Z"},W}(),Nr=function(){function W(s){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}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:"#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(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(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},W.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},W.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new hr("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new hr("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new hr("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new pr("_fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new pr("_fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},W.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},W}(),hr=function(W,s){this.selector=W,this.style=s},pr=function(W,s){this.localName=W,this.style=s},Br=function(){function W(){this.blocks=[],this.display=""}return W.prototype.addButtonBlock=function(s){s.className=this.blockClassName,s.buttonClassName=this.buttonClassName,s.buttonColorsClassName=this.buttonColorsClassName,s.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(s)},W.prototype.addElementBlock=function(s){s.className===void 0&&(s.className=this.blockClassName),this.blocks.push(s)},W.prototype.getUI=function(){var s=document.createElement("div");return s.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,s.style.display=this.display,this.blocks.forEach(function(c){return s.appendChild(c.getUI())}),s},W}(),ci=function(){function W(){}return W.prototype.getUI=function(){var s=document.createElement("div");if(s.className=this.className,this.minWidth!==void 0&&(s.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":s.style.justifyContent="flex-start";break;case"center":s.style.justifyContent="center";break;case"end":s.style.justifyContent="flex-end"}return s.style.whiteSpace="nowrap",s},W}(),qr=function(W){function s(){var c=W!==null&&W.apply(this,arguments)||this;return c.buttons=[],c}return Xt(s,W),s.prototype.addButton=function(c){c.className=this.buttonClassName,c.colorsClassName=this.buttonColorsClassName,c.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(c)},s.prototype.getUI=function(){var c=W.prototype.getUI.call(this);return this.buttons.forEach(function(O){return c.appendChild(O.getUI())}),c},s}(ci),It=function(){function W(s,c){this._isActive=!1,this._isHidden=!1,this._icon=s,this.title=c,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(W.prototype,"icon",{get:function(){return this._icon},set:function(s){this._icon=s,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isActive",{get:function(){return this._isActive},set:function(s){this._isActive=s,this.adjustClassName()},enumerable:!1,configurable:!0}),W.prototype.getUI=function(){var s=this;return this.buttonContainer=document.createElement("div"),this.buttonContainer.title=this.title,this.buttonContainer.className=this.className+" "+this.colorsClassName,this.adjustClassName(),this.buttonContainer.innerHTML=this._icon,this.onClick&&this.buttonContainer.addEventListener("click",function(){return s.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},W.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,"")))},W.prototype.hide=function(){this._isHidden=!0},W}(),ut=function(W){function s(){var c=W!==null&&W.apply(this,arguments)||this;return c.elements=[],c}return Xt(s,W),s.prototype.addElement=function(c){this.elements.push(c)},s.prototype.getUI=function(){var c=W.prototype.getUI.call(this);return this.elements.forEach(function(O){return c.appendChild(O)}),c},s}(ci),Hr=function(){function W(s,c){this.horizontal=s,this.vertical=c}return Object.defineProperty(W.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),W.prototype.getVerticalLength=function(s){return s/this.ratio},W.prototype.getHorizontalLength=function(s){return s*this.ratio},W}(),ei=function(){function W(){}return W.getIcon=function(s,c){if(s>0&&c>0){var O=new Hr(s,c),$=O.ratio>=1?20:O.getHorizontalLength(20),F=O.ratio<1?20:O.getVerticalLength(20),he=document.createElementNS("http://www.w3.org/2000/svg","svg");he.setAttribute("xmlns","http://www.w3.org/2000/svg"),he.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(he);var Re=bt.createDefs();he.appendChild(Re);var Ke=bt.createElement("clipPath",[["id","text-bg-clip"]]);Re.appendChild(Ke);var ht=bt.createPath(bt.getHollowRectanglePath((24-$)/2,(24-F)/2,$,F,(24-$)/2+2,(24-F)/2+2,$-4,F-4));he.appendChild(ht);var Pe=bt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Pe.appendChild(bt.createTSpan(s+":"+c)),he.appendChild(Pe);var vt=Pe.getBBox();bt.setAttributes(Pe,[["x",((24-vt.width)/2).toString()],["y",((24-vt.height)/2-vt.y).toString()]]);var Nt=bt.createPath(bt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(vt.width))/2,(24-Math.ceil(vt.height))/2,Math.ceil(vt.width),Math.ceil(vt.height)));return Ke.appendChild(Nt),bt.setAttributes(ht,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(he),he.outerHTML}return'<svg viewBox="0 0 24 24"><path d="M19 12h-2v3h-3v2h5v-5M7 9h3V7H5v5h2V9m14-6H3a2 2 0 00-2 2v14a2 2 0 002 2h18a2 2 0 002-2V5a2 2 0 00-2-2m0 16H3V5h18v14z"/></svg>'},W}(),mr=function(W){function s(c,O,$){var F=W.call(this,c,O)||this;return F.isDropdownOpen=!1,F.onClick=F.dropdownButtonClicked,F.dropdownButtons=$,F}return Xt(s,W),s.prototype.setupDropdown=function(){var c=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(O){O.className=c.className,O.colorsClassName=c.colorsClassName,c.dropdownBlock.appendChild(O.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},s.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},s.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},s.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},s.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},s.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},s}(It),kt=function(){function W(s,c){this.GRIP_SIZE=10,this.color=s,this.fillColor=c,this.visual=bt.createGroup(),this.visual.appendChild(bt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(bt.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return W.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},W.prototype.setCenter=function(s,c){this.visual.childNodes.forEach(function(O){return bt.setAttributes(O,[["cx",s.toString()],["cy",c.toString()]])})},W}(),Fr=function(){function W(s,c,O,$){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=s,this.canvasHeight=c,this.margin=O,this.container=$,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(W.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(s){this._aspectRatio=s,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.gridContainer&&bt.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),W.prototype.open=function(){var s=this;this.cropShadeElement=bt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=bt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var c=0;c<this.numberOfGridLines;c++)this.horizontalGridLines.push(bt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(bt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(O){return s.gridContainer.appendChild(O)}),this.verticalGridLines.forEach(function(O){return s.gridContainer.appendChild(O)}),this.cropRectElement=bt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},W.prototype.setCropRectangle=function(s){this.cropRect=s;var c=Object.assign({},this.cropRect);this.zoomFactor!==1&&(c.width=this.cropRect.width*this.zoomFactor,c.height=this.cropRect.height*this.zoomFactor,c.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-c.width/2,c.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-c.height/2),bt.setAttributes(this.cropRectElement,[["x",c.x.toString()],["y",c.y.toString()],["width",c.width.toString()],["height",c.height.toString()]]);var O=c.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(F,he){var Re=c.y+O*(he+1);bt.setAttributes(F,[["x1",""+c.x],["y1",""+Re],["x2",""+(c.x+c.width)],["y2",""+Re]])});var $=c.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(F,he){var Re=c.x+$*(he+1);bt.setAttributes(F,[["x1",""+Re],["y1",""+c.y],["x2",""+Re],["y2",""+(c.y+c.height)]])}),bt.setAttributes(this.cropShadeElement,[["d",bt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,c.x,c.y,c.width,c.height)]]),this.topLeftGrip.setCenter(c.x,c.y),this.topRightGrip.setCenter(c.x+c.width,c.y),this.bottomLeftGrip.setCenter(c.x,c.y+c.height),this.bottomRightGrip.setCenter(c.x+c.width,c.y+c.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},W.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)},W.prototype.clientToLocalCoordinates=function(s,c){var O=this.container.getBoundingClientRect();return{x:s-O.left+this.margin,y:c-O.top+this.margin}},W.prototype.onPointerDown=function(s){this.container.setPointerCapture(s.pointerId),this.previousPoint=this.clientToLocalCoordinates(s.clientX,s.clientY),this.cropRectElement===s.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(s.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(s.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(s.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(s.target)&&(this.activeGrip=this.bottomRightGrip)},W.prototype.onPointerMove=function(s){if(this.isMoving)this.move(this.clientToLocalCoordinates(s.clientX,s.clientY));else if(this.activeGrip){var c=this.clientToLocalCoordinates(s.clientX,s.clientY);this.resize(c)}s.preventDefault()},W.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},W.prototype.move=function(s){var c=s.x-this.previousPoint.x,O=s.y-this.previousPoint.y;this.zoomFactor!==1&&(c=-c/this.zoomFactor,O=-O/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+c),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+O),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=s},W.prototype.resize=function(s){var c=Object.assign({},this.cropRect),O=s.x-this.previousPoint.x,$=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:c.x+O<this.margin&&(O=this.margin-c.x),c.x+=O,c.width=this.cropRect.x+this.cropRect.width-c.x;break;case this.bottomRightGrip:case this.topRightGrip:c.width+O>this.canvasWidth*this.zoomFactor&&(O=this.canvasWidth*this.zoomFactor-c.width),c.width+=O}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(c.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(O),c.height=this.aspectRatio.getVerticalLength(c.width)):(c.y+=$,c.height=this.cropRect.y+this.cropRect.height-c.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?c.height=this.aspectRatio.getVerticalLength(c.width):c.height+=$}c.width<10&&(c.x=this.cropRect.x,c.width=10),c.height<10&&(c.y=this.cropRect.y,c.height=10),this.previousPoint=s,c.x>=this.margin&&c.y>=this.margin&&c.x-this.margin+c.width<=this.canvasWidth&&c.y-this.margin+c.height<=this.canvasHeight&&(this.cropRect=c,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},W.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var s=this.cropRect.x+this.cropRect.width/2,c=this.cropRect.y+this.cropRect.height/2,O=this.aspectRatio.getHorizontalLength(this.cropRect.height),$=this.aspectRatio.getVerticalLength(this.cropRect.width);O/this.canvasWidth<$/this.canvasHeight?this.cropRect.width=O:this.cropRect.height=$,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=s-this.cropRect.width/2,this.cropRect.y=c-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)}},W.prototype.getRescaledRect=function(s,c,O,$,F,he){var Re=O/s,Ke=$/c;return{x:(F.x-he)*Re+he,y:(F.y-he)*Ke+he,width:F.width*Re,height:F.height*Ke}},W.prototype.scaleCanvas=function(s,c){var O=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,c,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=c,this.onCropChange&&this.onCropChange(O),this.setCropRectangle(O)},W}(),Vr=function(){function W(s){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=s,this.uiContainer=document.createElement("div"),this.getUI=this.getUI.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.setAngleLabel=this.setAngleLabel.bind(this),this.positionScaleShape=this.positionScaleShape.bind(this)}return Object.defineProperty(W.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),W.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},W.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},W.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},W.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},W.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var s=this.angleLabelText.getBBox();bt.setAttributes(this.angleLabelElement,[["x",((this.width-s.width)/2).toString()],["y",(this.height/2).toString()]])}},W.prototype.positionScaleShape=function(){if(this.scaleShape){var s=this.scaleShape.transform.baseVal.getItem(0);s.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(s,0)}},W.prototype.getVisual=function(){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width",this.width+"px"),s.setAttribute("height",this.height+"px"),s.setAttribute("viewBox","0 0 "+this.width+" "+this.height),s.style.flexShrink="0",document.body.appendChild(s);for(var c="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,O=1;O<=this.width/5+10;O++){var $=O%5==0?this.height/3:this.height/6;c+="h4v"+-$+"h1v"+$}c+="v1H0Z",this.scaleShape=bt.createPath(c);var F=bt.createTransform();this.scaleShape.transform.baseVal.appendItem(F),s.appendChild(this.scaleShape),this.angleLabelElement=bt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=bt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var he=bt.createTSpan("");return he.innerHTML="&deg;",this.angleLabelElement.appendChild(he),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},W}(),fi=function(){function W(){this.naturalSize=!1,this.imageType="image/png"}return W.prototype.rasterize=function(s,c,O,$,F,he,Re){var Ke=this;return new Promise(function(ht){var Pe=document.createElement("canvas");Pe.width=s.width.baseVal.value-2*$,Pe.height=s.height.baseVal.value-2*$;var vt=1,Nt=1;Ke.naturalSize===!0?(vt=c.naturalWidth/(s.width.baseVal.value-2*$)/he,Nt=c.naturalHeight/(s.height.baseVal.value-2*$)/Re,Pe.width=c.naturalWidth/he,Pe.height=c.naturalHeight/Re):Ke.width!==void 0&&Ke.height!==void 0&&(vt=Ke.width/O.width,Nt=Ke.height/O.height,Pe.width*=vt,Pe.height*=Nt);var Kt=Pe.getContext("2d");Kt.translate(Pe.width/2,Pe.height/2),Kt.rotate(F*Math.PI/180),Kt.scale(he,Re),Kt.translate(-Pe.width/2,-Pe.height/2),Kt.drawImage(c,0,0,Pe.width,Pe.height);var Or=document.createElement("canvas");Or.width=O.width*vt,Or.height=O.height*Nt,Or.getContext("2d").putImageData(Kt.getImageData((O.x-$)*vt,(O.y-$)*Nt,O.width*vt,O.height*Nt),0,0),ht(Or.toDataURL(Ke.imageType,Ke.imageQuality))})},W}(),Ue=function(){function W(s){this._zoomToCropEnabled=!0,this.zoomFactor=1,this.flippedHorizontally=!1,this.flippedVertically=!1,this._isGridVisible=!0,this._gridLines=2,this._rotationAngle=0,this.scaleFactor=1,this.renderEventListeners=[],this.closeEventListeners=[],this._isOpen=!1,this.CANVAS_MARGIN=20,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.displayMode="inline",this.popupMargin=30,this.toolbarHeight=40,this.aspectRatios=[{horizontal:0,vertical:0},{horizontal:4,vertical:3},{horizontal:3,vertical:2},{horizontal:16,vertical:9},{horizontal:1,vertical:1},{horizontal:3,vertical:4},{horizontal:2,vertical:3},{horizontal:9,vertical:16}],this._instanceNo=W.instanceCounter++,this.styles=new Nr(this.instanceNo),this.target=s,this.targetRoot=document.body,this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.rotateBy=this.rotateBy.bind(this),this.applyRotation=this.applyRotation.bind(this),this.cropRectChanged=this.cropRectChanged.bind(this),this.zoomToCrop=this.zoomToCrop.bind(this),this.unzoomFromCrop=this.unzoomFromCrop.bind(this),this.rotateLeftButtonClicked=this.rotateLeftButtonClicked.bind(this),this.rotateRightButtonClicked=this.rotateRightButtonClicked.bind(this),this.flipHorizontallyButtonClicked=this.flipHorizontallyButtonClicked.bind(this),this.flipVerticallyButtonClicked=this.flipVerticallyButtonClicked.bind(this),this.applyFlip=this.applyFlip.bind(this),this.startRenderAndClose=this.startRenderAndClose.bind(this),this.render=this.render.bind(this),this.onPopupResize=this.onPopupResize.bind(this),this.applyAspectRatio=this.applyAspectRatio.bind(this)}return Object.defineProperty(W.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"gridLines",{get:function(){return this._gridLines},set:function(s){this._gridLines=s,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(s){this._rotationAngle=s,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"aspectRatio",{get:function(){var s;return(s=this._aspectRatio)!==null&&s!==void 0?s:this.aspectRatios[0]},set:function(s){this._aspectRatio=s},enumerable:!1,configurable:!0}),W.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},W.prototype.show=function(){this.showUI(),this.open()},W.prototype.close=function(s){s===void 0&&(s=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),s||this.closeEventListeners.forEach(function(c){return c()}),this._isOpen=!1)},W.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},W.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},W.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},W.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},W.prototype.setupResizeObserver=function(){var s=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},W.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var s=1*this.target.clientWidth/this.target.clientHeight,c=this.contentDiv.clientWidth/s>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*s:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,O=c+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/s;this.resize(c,O)}},W.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},W.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",bt.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},W.prototype.resize=function(s,c){this.imageWidth=Math.round(s),this.imageHeight=Math.round(c),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()},W.prototype.setEditingTarget=function(){var s=document.createElement("canvas");s.width=this.target.naturalWidth,s.height=this.target.naturalHeight,s.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var c=s.toDataURL();bt.setAttributes(this.editingTarget,[["href",c]]),this.setEditingTargetSize()},W.prototype.setTopLeft=function(){var s=this.target.getBoundingClientRect(),c=this.editorCanvas.getBoundingClientRect();this.left=s.left-c.left-this.CANVAS_MARGIN,this.top=s.top-c.top-this.CANVAS_MARGIN},W.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=bt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=bt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=bt.createGroup(),this.editingTargetRotationScaleContainer=bt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var s=bt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(s);var c=bt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(c),this.editingTargetContainer=bt.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)},W.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},W.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=bt.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Fr(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()},W.prototype.zoomToCrop=function(){if(this.cropRect){var s=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,c=this.cropRect.y-this.CANVAS_MARGIN+this.cropRect.height/2;this.zoomFactor=Math.min(this.imageWidth/this.cropRect.width,this.imageHeight/this.cropRect.height),this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin=s+"px "+c+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-s+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-c+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},W.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)},W.prototype.cropRectChanged=function(s){this.cropRect=s,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},W.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},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.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var s=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,c=this.target.offsetTop>s+this.CANVAS_MARGIN?this.target.offsetTop-(s+this.CANVAS_MARGIN):0;this.coverDiv.style.top=c+"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},W.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},W.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new Br,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 c=new qr;c.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(c);var O=[];this.aspectRatios.forEach(function(Nt){var Kt=new It(ei.getIcon(Nt.horizontal,Nt.vertical),Nt.horizontal===0&&Nt.vertical===0?"FREE":Nt.horizontal+":"+Nt.vertical);Kt.onClick=function(){return s.ratioButtonClicked(Nt)},O.push(Kt)}),this.aspectRatioButton=new mr(ei.getIcon(0,0),"Aspect ratio",O),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,c.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var $=new It('<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");$.isActive=this.isGridVisible,$.onClick=function(){s.isGridVisible=!s.isGridVisible,$.isActive=s.isGridVisible},c.addButton($);var F=new It('<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(F.isActive=this.zoomToCropEnabled,F.onClick=function(){s.zoomToCropEnabled=!s.zoomToCropEnabled,F.isActive=s.zoomToCropEnabled},c.addButton(F),!Kr.isLicensed){var he=new ut;this.topToolbar.addElementBlock(he);var Re=document.createElement("div");Re.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Ke=document.createElement("a");Ke.style.color="currentColor",Ke.href="https://markerjs.com/products/cropro",Ke.target="_blank",Ke.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>',Re.appendChild(Ke),he.addElement(Re)}var ht=new qr;ht.minWidth=3*this.toolbarHeight+"px",ht.contentAlign="end",this.topToolbar.addButtonBlock(ht);var Pe=new It('<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");Pe.onClick=this.startRenderAndClose,ht.addButton(Pe),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Pe.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var vt=new It('<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");vt.onClick=this.close,ht.addButton(vt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(vt.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},W.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new Br,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 c=new qr;c.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(c);var O=new It('<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");O.onClick=this.rotateLeftButtonClicked,c.addButton(O);var $=new It('<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");$.onClick=this.rotateRightButtonClicked,c.addButton($);var F=new ut;F.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(F),this.straightener=new Vr("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(ht){s.rotateBy(ht),s.straightener.angle=s.rotationAngle},F.addElement(this.straightener.getUI());var he=new qr;he.minWidth=2*this.toolbarHeight+"px",he.contentAlign="end",this.bottomToolbar.addButtonBlock(he);var Re=new It('<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");Re.onClick=this.flipHorizontallyButtonClicked,he.addButton(Re);var Ke=new It('<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");Ke.onClick=this.flipVerticallyButtonClicked,he.addButton(Ke)},W.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},W.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ei.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},W.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new Hr(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},W.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},W.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},W.prototype.restoreState=function(s){if(s){var c=this.cropLayer.getRescaledRect(s.width,s.height,this.imageWidth,this.imageHeight,s.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(c),this.cropRectChanged(c),this.flippedHorizontally=s.flippedHorizontally,this.flippedVertically=s.flippedVertically,this.applyFlip(),this.rotationAngle=s.rotationAngle,this.applyRotation()}},W.prototype.clientToLocalCoordinates=function(s,c){var O=this.cropImage.getBoundingClientRect();return{x:s-O.left,y:c-O.top}},W.prototype.onWindowResize=function(){this.positionUI()},W.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var s=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)"}this.positionCropImage()},W.prototype.rotateLeftButtonClicked=function(){var s=this.rotationAngle-90;this.rotationAngle%90!=0&&(s+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(s)},W.prototype.rotateRightButtonClicked=function(){var s=this.rotationAngle+90;this.rotationAngle%90!=0&&(s-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(s)},W.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},W.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},W.prototype.applyRotation=function(){var s=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var c=this.editingTargetRotationContainer.transform.baseVal.getItem(0);c.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(c,0);var O=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/O.width,this.imageHeight/O.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=s},W.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},W.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},W.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},W.prototype.startRenderAndClose=function(){return Ot(this,void 0,void 0,function(){var s,c;return Ir(this,function(O){switch(O.label){case 0:return[4,this.render()];case 1:return s=O.sent(),c=this.getState(),this.renderEventListeners.forEach(function($){return $(s,c)}),this.close(!0),[2]}})})},W.prototype.render=function(){return Ot(this,void 0,void 0,function(){var s;return Ir(this,function(c){switch(c.label){case 0:return(s=new fi).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.width=this.renderWidth,s.height=this.renderHeight,this.unzoomFromCrop(),bt.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 1:return c.sent(),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return[2,c.sent()]}})})},W.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new pr("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 pr("toolbar_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarBlockStyleClass=this.styles.addClass(new pr("toolbar-block",`
display: flex;
align-items: center;
box-sizing: content-box;
`));var s=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new pr("toolbar_button",`
display: inline-block;
width: `+(this.toolbarHeight-2*s)+`px;
height: `+(this.toolbarHeight-2*s)+`px;
padding: `+s+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new pr("toolbar_button_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new pr("toolbar_active_button",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
`)),this.styles.addRule(new hr("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.toolbarHeight/2+`px;
`)),this.styles.addRule(new hr("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new pr("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 pr("toolbar_dropdown_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new pr("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 pr("toolbar_straightener",`
display: flex;
overflow: hidden;
justify-content: center;
height: `+(this.toolbarHeight-2*s)+`px;
padding: `+s+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new pr("toolbar_straightener_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`))},W.instanceCounter=0,W}(),Et=se("8hTe"),pi=se.n(Et),mi=/<pre[^>]*>/g;function gi(W){var s=document.createElement("div");return s.innerHTML=W,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var vi=pt.a=function(W){var s=W.value,c=s===void 0?"":s,O=W.edit,$=O===void 0?!1:O,F=W.className,he=W.showTextOnly,Re=W.showLines,Ke=W.replaces,ht=W.zoomImg,Pe=W.hasMask,vt=W.style,Nt=vt===void 0?{}:vt,Kt=W.stylesPrev,Or=Kt===void 0?{}:Kt,gr=String(c),vr=Object(_.useRef)(),Xr=Object(_.useRef)(),Oi=Object(_.useState)(""),nr=Object(H.a)(Oi,2),Ur=nr[0],oi=nr[1],si=Object(_.useState)("office"),_r=Object(H.a)(si,2),_i=_r[0],yi=_r[1],zi=function(){var Bt=new Ue(Xr.current);Bt.displayMode="popup",Bt.addRenderEventListener(function(){var dr=Object(M.a)(P.a.mark(function Dt(qt){var Wt;return P.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:return vr.current.style.display="none",ar.next=3,Object(Oe.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt}});case 3:Wt=ar.sent,Wt!=null&&Wt.id&&Ke(Xr.current.getAttribute("src").replace(ie.a.API_SERVER,""),"/api/attachments/".concat(Wt==null?void 0:Wt.id,"?type=").concat(Wt.content_type));case 5:case"end":return ar.stop()}},Dt)}));return function(Dt){return dr.apply(this,arguments)}}()),Bt.show()},Ki=function(){var Bt=new _t(Xr.current);Bt.settings.displayMode="popup",Bt.addEventListener("render",function(){var dr=Object(M.a)(P.a.mark(function Dt(qt){var Wt;return P.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:if(vr.current.style.display="none",!Xr.current){ar.next=6;break}return ar.next=4,Object(Oe.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt.dataUrl}});case 4:Wt=ar.sent,Wt!=null&&Wt.id&&Ke(Xr.current.getAttribute("src").replace(ie.a.API_SERVER,""),"/api/attachments/".concat(Wt==null?void 0:Wt.id,"?type=").concat(Wt.content_type));case 6:case"end":return ar.stop()}},Dt)}));return function(Dt){return dr.apply(this,arguments)}}()),Bt.show(),window.markerArea=Bt},Yr=Object(_.useMemo)(function(){vr.current&&(vr.current.style.zIndex=-1);try{var Jt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Bt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,dr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;gr=gr.replace(Jt,"("+ie.a.API_SERVER+"/api/attachments/").replace(Bt,'"'+ie.a.API_SERVER+"/api/attachments/").replace(dr,'"'+ie.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(ti){}var Dt=Q(gr),qt=x();if(gr.match(/\[TOC\]/)&&(Dt=Dt.replace("<p>[TOC]</p>",k()),C()),Dt=Dt.replace(/(__special_katext_id_\d+__)/g,function(ti,ar){var Er=qt[ar],Vi=Er.type,Ei=Er.expression;return Object(ce.renderToString)(gi(Ei)||"",{displayMode:Vi==="block",throwOnError:!1,output:"html"})}),Dt=Dt.replace(/▁/g,"\u2581\u2581\u2581"),v(),he){var Wt=document.createElement("div");return Wt.innerHTML=Dt,Wt.innerText}return setTimeout(function(){return dn()},500),Dt},[gr]),Gr=Object(_.useRef)();g.WebkitLineClamp=Re,Re&&(Nt=Object(N.a)(Object(N.a)({},Nt),g));function bi(Jt){var Bt=Jt.target;if(Bt.tagName.toUpperCase()==="IMG"){if(ht){var dr=Bt.getAttribute("src");oi(dr),yi("image")}}else if(Bt.tagName.toUpperCase()==="A"){var Dt=Bt.getAttribute("href");if(Dt.indexOf("office")>-1)Jt.preventDefault(),oi(Dt),yi("office");else if(Dt.indexOf("application/pdf")>-1)Jt.preventDefault(),oi(Dt),yi("pdf");else if(Dt.indexOf("text/html")>-1)Jt.preventDefault(),oi(Dt),yi("html");else if(Dt.startsWith("#")){Jt.preventDefault();var qt=document.getElementById(Dt.replace("#",""));qt&&qt.scrollIntoView(!0)}}}var dn=function(){var Bt,dr=(Bt=Gr.current)===null||Bt===void 0?void 0:Bt.querySelectorAll("video");dr==null||dr.forEach(function(Dt){if(Dt.oncontextmenu=function(){return!1},Dt.src.indexOf(".m3u8")>-1&&!Dt.canPlayType("application/vnd.apple.mpegurl")){if(q.a.isSupported()){var qt=new q.a;qt.loadSource(Dt.src),qt.attachMedia(Dt)}}})};Object(_.useEffect)(function(){if(Gr.current&&Yr&&(Yr.match(mi)&&window.PR.prettyPrint()),Gr.current)return Gr.current.addEventListener("click",bi),function(){Gr.current.removeEventListener("click",bi),v(),C()}},[Yr,Gr.current,bi]);var xi=function(Bt){if(!$)return;Bt.target.nodeName==="IMG"?(vr.current.style.zIndex=1,vr.current.style.display="flex",vr.current.style.width=Bt.target.clientWidth+"px",vr.current.style.height=Bt.target.clientHeight+"px",vr.current.style.top=Bt.target.offsetTop+"px",vr.current.style.left=Bt.target.offsetLeft+"px",Xr.current.src=Bt.target.getAttribute("src")):vr.current.style.display="none"};return y.a.createElement("div",{style:{position:"relative"}},y.a.createElement("div",{ref:Gr,style:Object(N.a)({},Nt),className:"".concat(F||""," markdown-body ").concat(pi.a.mdBody),onMouseOver:xi,dangerouslySetInnerHTML:{__html:Yr}}),y.a.createElement("div",{ref:vr,className:pi.a.button},y.a.createElement(Z.a,null,y.a.createElement(Y.a,{onClick:function(){return zi()}},"\u88C1\u526A"),y.a.createElement(Y.a,{onClick:function(){return Ki()}},"\u7F16\u8F91"))),y.a.createElement("img",{ref:Xr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),y.a.createElement(ve.a,{close:!0,data:Ur,type:Ur!=null&&Ur.length?_i:"",style:Object(N.a)({},Or),onClose:function(){return oi("")}}))}},"9VGf":function(wt,pt,se){"use strict";se.d(pt,"a",function(){return D});var re=se("q1tI"),Z=se.n(re);function D(Y,N){var M=Object(re.useRef)();Object(re.useEffect)(function(){M.current=Y}),Object(re.useEffect)(function(){function H(){M.current()}if(N!==null){var U=setInterval(H,N);return function(){return clearInterval(U)}}},[N])}},Bd2K:function(wt,pt,se){(function(re){re(se("VrN/"),se("osHv"))})(function(re){re.defineOption("autoCloseTags",!1,function(P,_,y){if(y!=re.Init&&y&&P.removeKeyMap("autoCloseTags"),!_)return;var A={name:"autoCloseTags"};(typeof _!="object"||_.whenClosing!==!1)&&(A["'/'"]=function(R){return M(R)}),(typeof _!="object"||_.whenOpening!==!1)&&(A["'>'"]=function(R){return Y(R)}),P.addKeyMap(A)});var Z=["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 Y(P){if(P.getOption("disableInput"))return re.Pass;for(var _=P.listSelections(),y=[],A=P.getOption("autoCloseTags"),R=0;R<_.length;R++){if(!_[R].empty())return re.Pass;var L=_[R].head,w=P.getTokenAt(L),b=re.innerMode(P.getMode(),w.state),u=b.state,o=b.mode.xmlCurrentTag&&b.mode.xmlCurrentTag(u),l=o&&o.name;if(!l)return re.Pass;var h=b.mode.configuration=="html",C=typeof A=="object"&&A.dontCloseTags||h&&Z,g=typeof A=="object"&&A.indentTags||h&&D;w.end>L.ch&&(l=l.slice(0,l.length-w.end+L.ch));var p=l.toLowerCase();if(!l||w.type=="string"&&(w.end!=L.ch||!/[\"\']/.test(w.string.charAt(w.string.length-1))||w.string.length==1)||w.type=="tag"&&o.close||w.string.indexOf("/")==L.ch-w.start-1||C&&H(C,p)>-1||U(P,b.mode.xmlCurrentContext&&b.mode.xmlCurrentContext(u)||[],l,L,!0))return re.Pass;var k=typeof A=="object"&&A.emptyTags;if(k&&H(k,l)>-1){y[R]={text:"/>",newPos:re.Pos(L.line,L.ch+2)};continue}var E=g&&H(g,p)>-1;y[R]={indent:E,text:">"+(E?`
`:"")+"</"+l+">",newPos:E?re.Pos(L.line+1,0):re.Pos(L.line,L.ch+1)}}for(var f=typeof A=="object"&&A.dontIndentOnAutoClose,R=_.length-1;R>=0;R--){var m=y[R];P.replaceRange(m.text,_[R].head,_[R].anchor,"+insert");var d=P.listSelections().slice(0);d[R]={head:m.newPos,anchor:m.newPos},P.setSelections(d),!f&&m.indent&&(P.indentLine(m.newPos.line,null,!0),P.indentLine(m.newPos.line+1,null,!0))}}function N(P,_){for(var y=P.listSelections(),A=[],R=_?"/":"</",L=P.getOption("autoCloseTags"),w=typeof L=="object"&&L.dontIndentOnSlash,b=0;b<y.length;b++){if(!y[b].empty())return re.Pass;var u=y[b].head,o=P.getTokenAt(u),l=re.innerMode(P.getMode(),o.state),h=l.state;if(_&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=u.ch-1))return re.Pass;var C,g=l.mode.name!="xml"&&P.getMode().name=="htmlmixed";if(g&&l.mode.name=="javascript")C=R+"script";else if(g&&l.mode.name=="css")C=R+"style";else{var p=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(h);if(!p||p.length&&U(P,p,p[p.length-1],u))return re.Pass;C=R+p[p.length-1]}P.getLine(u.line).charAt(o.end)!=">"&&(C+=">"),A[b]=C}if(P.replaceSelections(A),y=P.listSelections(),!w)for(var b=0;b<y.length;b++)(b==y.length-1||y[b].head.line<y[b+1].head.line)&&P.indentLine(y[b].head.line)}function M(P){return P.getOption("disableInput")?re.Pass:N(P,!0)}re.commands.closeTag=function(P){return N(P)};function H(P,_){if(P.indexOf)return P.indexOf(_);for(var y=0,A=P.length;y<A;++y)if(P[y]==_)return y;return-1}function U(P,_,y,A,R){if(!re.scanForClosingTag)return!1;var L=Math.min(P.lastLine()+1,A.line+500),w=re.scanForClosingTag(P,A,null,L);if(!w||w.tag!=y)return!1;for(var b=R?1:0,u=_.length-1;u>=0&&_[u]==y;u--)++b;A=w.to;for(var u=1;u<b;u++){var o=re.scanForClosingTag(P,A,null,L);if(!o||o.tag!=y)return!1;A=o.to}return!0}})},BjJ7:function(wt,pt,se){"use strict";se.d(pt,"d",function(){return Z}),se.d(pt,"c",function(){return D}),se.d(pt,"e",function(){return Y}),se.d(pt,"b",function(){return N}),se.d(pt,"a",function(){return H});var re=se("m3rI");function Z(U){var P=!0;if(U.length>0){for(var _=0;_<U.length;_++)if(U[_].compile_success==0||!U[_].compile_success){P=!1;break}}else P=!1;return P}function D(U){for(var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",_=[],y=0;y<U.length;y++){var A=U[y],R=P?"".concat(P,"/").concat(A.name):"".concat(A.name);_.push({title:A.name,isLeaf:!(A.type==="tree"),key:R})}return _}function Y(U,P,_){for(var y=0;y<U.length;y++){var A=U[y];if(A.key===P){A.children=_;break}A.children&&Y(A.children,P,_)}return U}function N(U,P,_){var y;return function(){var A=this,R=arguments,L=function(){y=null,_||U.apply(A,R)},w=_&&!y;clearTimeout(y),y=setTimeout(L,P),w&&U.apply(A,R)}}var M=!0,H=re.a.API_SERVER},"C+DQ":function(wt,pt,se){},DlQD:function(wt,pt,se){(function(re,Z){wt.exports=Z()})(this,function(){"use strict";function re(ge,de){for(var fe=0;fe<de.length;fe++){var ee=de[fe];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(ge,ee.key,ee)}}function Z(ge,de,fe){return de&&re(ge.prototype,de),fe&&re(ge,fe),ge}function D(ge,de){if(!ge)return;if(typeof ge=="string")return Y(ge,de);var fe=Object.prototype.toString.call(ge).slice(8,-1);if(fe==="Object"&&ge.constructor&&(fe=ge.constructor.name),fe==="Map"||fe==="Set")return Array.from(ge);if(fe==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(fe))return Y(ge,de)}function Y(ge,de){(de==null||de>ge.length)&&(de=ge.length);for(var fe=0,ee=new Array(de);fe<de;fe++)ee[fe]=ge[fe];return ee}function N(ge,de){var fe;if(typeof Symbol=="undefined"||ge[Symbol.iterator]==null){if(Array.isArray(ge)||(fe=D(ge))||de&&ge&&typeof ge.length=="number"){fe&&(ge=fe);var ee=0;return function(){return ee>=ge.length?{done:!0}:{done:!1,value:ge[ee++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}return fe=ge[Symbol.iterator](),fe.next.bind(fe)}function M(ge,de){return de={exports:{}},ge(de,de.exports),de.exports}var H=M(function(ge){function de(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function fe(ee){ge.exports.defaults=ee}ge.exports={defaults:de(),getDefaults:de,changeDefaults:fe}}),U=H.defaults,P=H.getDefaults,_=H.changeDefaults,y=/[&<>"']/,A=/[&<>"']/g,R=/[<>"']|&(?!#?\w+;)/,L=/[<>"']|&(?!#?\w+;)/g,w={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},b=function(de){return w[de]};function u(ge,de){if(de){if(y.test(ge))return ge.replace(A,b)}else if(R.test(ge))return ge.replace(L,b);return ge}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(ge){return ge.replace(o,function(de,fe){return fe=fe.toLowerCase(),fe==="colon"?":":fe.charAt(0)==="#"?fe.charAt(1)==="x"?String.fromCharCode(parseInt(fe.substring(2),16)):String.fromCharCode(+fe.substring(1)):""})}var h=/(^|[^\[])\^/g;function C(ge,de){ge=ge.source||ge,de=de||"";var fe={replace:function(te,ne){return ne=ne.source||ne,ne=ne.replace(h,"$1"),ge=ge.replace(te,ne),fe},getRegex:function(){return new RegExp(ge,de)}};return fe}var g=/[^\w:]/g,p=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(ge,de,fe){if(ge){var ee;try{ee=decodeURIComponent(l(fe)).replace(g,"").toLowerCase()}catch(te){return null}if(ee.indexOf("javascript:")===0||ee.indexOf("vbscript:")===0||ee.indexOf("data:")===0)return null}de&&!p.test(fe)&&(fe=a(de,fe));try{fe=encodeURI(fe).replace(/%25/g,"%")}catch(te){return null}return fe}var E={},f=/^[^:]+:\/*[^/]*$/,m=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(ge,de){E[" "+ge]||(f.test(ge)?E[" "+ge]=ge+"/":E[" "+ge]=I(ge,"/",!0)),ge=E[" "+ge];var fe=ge.indexOf(":")===-1;return de.substring(0,2)==="//"?fe?de:ge.replace(m,"$1")+de:de.charAt(0)==="/"?fe?de:ge.replace(d,"$1")+de:ge+de}var x={exec:function(){}};function v(ge){for(var de=1,fe,ee;de<arguments.length;de++){fe=arguments[de];for(ee in fe)Object.prototype.hasOwnProperty.call(fe,ee)&&(ge[ee]=fe[ee])}return ge}function T(ge,de){var fe=ge.replace(/\|/g,function(ne,ue,me){for(var Ee=!1,Me=ue;--Me>=0&&me[Me]==="\\";)Ee=!Ee;return Ee?"|":" |"}),ee=fe.split(/ \|/),te=0;if(ee.length>de)ee.splice(de);else for(;ee.length<de;)ee.push("");for(;te<ee.length;te++)ee[te]=ee[te].trim().replace(/\\\|/g,"|");return ee}function I(ge,de,fe){var ee=ge.length;if(ee===0)return"";for(var te=0;te<ee;){var ne=ge.charAt(ee-te-1);if(ne===de&&!fe)te++;else if(ne!==de&&fe)te++;else break}return ge.substr(0,ee-te)}function G(ge,de){if(ge.indexOf(de[1])===-1)return-1;for(var fe=ge.length,ee=0,te=0;te<fe;te++)if(ge[te]==="\\")te++;else if(ge[te]===de[0])ee++;else if(ge[te]===de[1]&&(ee--,ee<0))return te;return-1}function V(ge){ge&&ge.sanitize&&!ge.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}var Q={escape:u,unescape:l,edit:C,cleanUrl:k,resolveUrl:a,noopTest:x,merge:v,splitCells:T,rtrim:I,findClosingBracket:G,checkSanitizeDeprecation:V},z=H.defaults,j=Q.rtrim,q=Q.splitCells,ie=Q.escape,ce=Q.findClosingBracket;function ve(ge,de,fe){var ee=de.href,te=de.title?ie(de.title):null,ne=ge[1].replace(/\\([\[\]])/g,"$1");return ge[0].charAt(0)!=="!"?{type:"link",raw:fe,href:ee,title:te,text:ne}:{type:"image",raw:fe,href:ee,title:te,text:ie(ne)}}function Oe(ge,de){var fe=ge.match(/^(\s+)(?:```)/);if(fe===null)return de;var ee=fe[1];return de.split(`
`).map(function(te){var ne=te.match(/^\s+/);if(ne===null)return te;var ue=ne[0];return ue.length>=ee.length?te.slice(ee.length):te}).join(`
`)}var xe=function(){function ge(fe){this.options=fe||z}var de=ge.prototype;return de.space=function(ee){var te=this.rules.block.newline.exec(ee);if(te)return te[0].length>1?{type:"space",raw:te[0]}:{raw:`
`}},de.code=function(ee,te){var ne=this.rules.block.code.exec(ee);if(ne){var ue=te[te.length-1];if(ue&&ue.type==="paragraph")return{raw:ne[0],text:ne[0].trimRight()};var me=ne[0].replace(/^ {4}/gm,"");return{type:"code",raw:ne[0],codeBlockStyle:"indented",text:this.options.pedantic?me:j(me,`
`)}}},de.fences=function(ee){var te=this.rules.block.fences.exec(ee);if(te){var ne=te[0],ue=Oe(ne,te[3]||"");return{type:"code",raw:ne,lang:te[2]?te[2].trim():te[2],text:ue}}},de.heading=function(ee){var te=this.rules.block.heading.exec(ee);if(te)return{type:"heading",raw:te[0],depth:te[1].length,text:te[2]}},de.nptable=function(ee){var te=this.rules.block.nptable.exec(ee);if(te){var ne={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
`):[],raw:te[0]};if(ne.header.length===ne.align.length){var ue=ne.align.length,me;for(me=0;me<ue;me++)/^ *-+: *$/.test(ne.align[me])?ne.align[me]="right":/^ *:-+: *$/.test(ne.align[me])?ne.align[me]="center":/^ *:-+ *$/.test(ne.align[me])?ne.align[me]="left":ne.align[me]=null;for(ue=ne.cells.length,me=0;me<ue;me++)ne.cells[me]=q(ne.cells[me],ne.header.length);return ne}}},de.hr=function(ee){var te=this.rules.block.hr.exec(ee);if(te)return{type:"hr",raw:te[0]}},de.blockquote=function(ee){var te=this.rules.block.blockquote.exec(ee);if(te){var ne=te[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:te[0],text:ne}}},de.list=function(ee){var te=this.rules.block.list.exec(ee);if(te){for(var ne=te[0],ue=te[2],me=ue.length>1,Ee=ue[ue.length-1]===")",Me={type:"list",raw:ne,ordered:me,start:me?+ue.slice(0,-1):"",loose:!1,items:[]},tt=te[0].match(this.rules.block.item),mt=!1,dt,Ct,St,st,Ft,_t,Zt,Xt=tt.length,Ot=0;Ot<Xt;Ot++)dt=tt[Ot],ne=dt,Ct=dt.length,dt=dt.replace(/^ *([*+-]|\d+[.)]) */,""),~dt.indexOf(`
`)&&(Ct-=dt.length,dt=this.options.pedantic?dt.replace(/^ {1,4}/gm,""):dt.replace(new RegExp("^ {1,"+Ct+"}","gm"),"")),Ot!==Xt-1&&(St=this.rules.block.bullet.exec(tt[Ot+1])[0],(me?St.length===1||!Ee&&St[St.length-1]===")":St.length>1||this.options.smartLists&&St!==ue)&&(st=tt.slice(Ot+1).join(`
`),Me.raw=Me.raw.substring(0,Me.raw.length-st.length),Ot=Xt-1)),Ft=mt||/\n\n(?!\s*$)/.test(dt),Ot!==Xt-1&&(mt=dt.charAt(dt.length-1)===`
`,Ft||(Ft=mt)),Ft&&(Me.loose=!0),_t=/^\[[ xX]\] /.test(dt),Zt=void 0,_t&&(Zt=dt[1]!==" ",dt=dt.replace(/^\[[ xX]\] +/,"")),Me.items.push({type:"list_item",raw:ne,task:_t,checked:Zt,loose:Ft,text:dt});return Me}},de.html=function(ee){var te=this.rules.block.html.exec(ee);if(te)return{type:this.options.sanitize?"paragraph":"html",raw:te[0],pre:!this.options.sanitizer&&(te[1]==="pre"||te[1]==="script"||te[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(te[0]):ie(te[0]):te[0]}},de.def=function(ee){var te=this.rules.block.def.exec(ee);if(te){te[3]&&(te[3]=te[3].substring(1,te[3].length-1));var ne=te[1].toLowerCase().replace(/\s+/g," ");return{tag:ne,raw:te[0],href:te[2],title:te[3]}}},de.table=function(ee){var te=this.rules.block.table.exec(ee);if(te){var ne={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
`):[]};if(ne.header.length===ne.align.length){ne.raw=te[0];var ue=ne.align.length,me;for(me=0;me<ue;me++)/^ *-+: *$/.test(ne.align[me])?ne.align[me]="right":/^ *:-+: *$/.test(ne.align[me])?ne.align[me]="center":/^ *:-+ *$/.test(ne.align[me])?ne.align[me]="left":ne.align[me]=null;for(ue=ne.cells.length,me=0;me<ue;me++)ne.cells[me]=q(ne.cells[me].replace(/^ *\| *| *\| *$/g,""),ne.header.length);return ne}}},de.lheading=function(ee){var te=this.rules.block.lheading.exec(ee);if(te)return{type:"heading",raw:te[0],depth:te[2].charAt(0)==="="?1:2,text:te[1]}},de.paragraph=function(ee){var te=this.rules.block.paragraph.exec(ee);if(te)return{type:"paragraph",raw:te[0],text:te[1].charAt(te[1].length-1)===`
`?te[1].slice(0,-1):te[1]}},de.text=function(ee,te){var ne=this.rules.block.text.exec(ee);if(ne){var ue=te[te.length-1];return ue&&ue.type==="text"?{raw:ne[0],text:ne[0]}:{type:"text",raw:ne[0],text:ne[0]}}},de.escape=function(ee){var te=this.rules.inline.escape.exec(ee);if(te)return{type:"escape",raw:te[0],text:ie(te[1])}},de.tag=function(ee,te,ne){var ue=this.rules.inline.tag.exec(ee);if(ue)return!te&&/^<a /i.test(ue[0])?te=!0:te&&/^<\/a>/i.test(ue[0])&&(te=!1),!ne&&/^<(pre|code|kbd|script)(\s|>)/i.test(ue[0])?ne=!0:ne&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ue[0])&&(ne=!1),{type:this.options.sanitize?"text":"html",raw:ue[0],inLink:te,inRawBlock:ne,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):ie(ue[0]):ue[0]}},de.link=function(ee){var te=this.rules.inline.link.exec(ee);if(te){var ne=ce(te[2],"()");if(ne>-1){var ue=te[0].indexOf("!")===0?5:4,me=ue+te[1].length+ne;te[2]=te[2].substring(0,ne),te[0]=te[0].substring(0,me).trim(),te[3]=""}var Ee=te[2],Me="";if(this.options.pedantic){var tt=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Ee);tt?(Ee=tt[1],Me=tt[3]):Me=""}else Me=te[3]?te[3].slice(1,-1):"";Ee=Ee.trim().replace(/^<([\s\S]*)>$/,"$1");var mt=ve(te,{href:Ee&&Ee.replace(this.rules.inline._escapes,"$1"),title:Me&&Me.replace(this.rules.inline._escapes,"$1")},te[0]);return mt}},de.reflink=function(ee,te){var ne;if((ne=this.rules.inline.reflink.exec(ee))||(ne=this.rules.inline.nolink.exec(ee))){var ue=(ne[2]||ne[1]).replace(/\s+/g," ");if(ue=te[ue.toLowerCase()],!ue||!ue.href){var me=ne[0].charAt(0);return{type:"text",raw:me,text:me}}var Ee=ve(ne,ue,ne[0]);return Ee}},de.strong=function(ee,te,ne){ne===void 0&&(ne="");var ue=this.rules.inline.strong.start.exec(ee);if(ue&&(!ue[1]||ue[1]&&(ne===""||this.rules.inline.punctuation.exec(ne)))){te=te.slice(-1*ee.length);var me=ue[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;me.lastIndex=0;for(var Ee;(ue=me.exec(te))!=null;)if(Ee=this.rules.inline.strong.middle.exec(te.slice(0,ue.index+3)),Ee)return{type:"strong",raw:ee.slice(0,Ee[0].length),text:ee.slice(2,Ee[0].length-2)}}},de.em=function(ee,te,ne){ne===void 0&&(ne="");var ue=this.rules.inline.em.start.exec(ee);if(ue&&(!ue[1]||ue[1]&&(ne===""||this.rules.inline.punctuation.exec(ne)))){te=te.slice(-1*ee.length);var me=ue[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;me.lastIndex=0;for(var Ee;(ue=me.exec(te))!=null;)if(Ee=this.rules.inline.em.middle.exec(te.slice(0,ue.index+2)),Ee)return{type:"em",raw:ee.slice(0,Ee[0].length),text:ee.slice(1,Ee[0].length-1)}}},de.codespan=function(ee){var te=this.rules.inline.code.exec(ee);if(te){var ne=te[2].replace(/\n/g," "),ue=/[^ ]/.test(ne),me=ne.startsWith(" ")&&ne.endsWith(" ");return ue&&me&&(ne=ne.substring(1,ne.length-1)),ne=ie(ne,!0),{type:"codespan",raw:te[0],text:ne}}},de.br=function(ee){var te=this.rules.inline.br.exec(ee);if(te)return{type:"br",raw:te[0]}},de.del=function(ee){var te=this.rules.inline.del.exec(ee);if(te)return{type:"del",raw:te[0],text:te[1]}},de.autolink=function(ee,te){var ne=this.rules.inline.autolink.exec(ee);if(ne){var ue,me;return ne[2]==="@"?(ue=ie(this.options.mangle?te(ne[1]):ne[1]),me="mailto:"+ue):(ue=ie(ne[1]),me=ue),{type:"link",raw:ne[0],text:ue,href:me,tokens:[{type:"text",raw:ue,text:ue}]}}},de.url=function(ee,te){var ne;if(ne=this.rules.inline.url.exec(ee)){var ue,me;if(ne[2]==="@")ue=ie(this.options.mangle?te(ne[0]):ne[0]),me="mailto:"+ue;else{var Ee;do Ee=ne[0],ne[0]=this.rules.inline._backpedal.exec(ne[0])[0];while(Ee!==ne[0]);ue=ie(ne[0]),ne[1]==="www."?me="http://"+ue:me=ue}return{type:"link",raw:ne[0],text:ue,href:me,tokens:[{type:"text",raw:ue,text:ue}]}}},de.inlineText=function(ee,te,ne){var ue=this.rules.inline.text.exec(ee);if(ue){var me;return te?me=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):ie(ue[0]):ue[0]:me=ie(this.options.smartypants?ne(ue[0]):ue[0]),{type:"text",raw:ue[0],text:me}}},ge}(),Te=Q.noopTest,we=Q.edit,Se=Q.merge,pe={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:Te,table:Te,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};pe._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,pe._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,pe.def=we(pe.def).replace("label",pe._label).replace("title",pe._title).getRegex(),pe.bullet=/(?:[*+-]|\d{1,9}[.)])/,pe.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,pe.item=we(pe.item,"gm").replace(/bull/g,pe.bullet).getRegex(),pe.list=we(pe.list).replace(/bull/g,pe.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+pe.def.source+")").getRegex(),pe._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",pe._comment=/<!--(?!-?>)[\s\S]*?-->/,pe.html=we(pe.html,"i").replace("comment",pe._comment).replace("tag",pe._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),pe.paragraph=we(pe._paragraph).replace("hr",pe.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",pe._tag).getRegex(),pe.blockquote=we(pe.blockquote).replace("paragraph",pe.paragraph).getRegex(),pe.normal=Se({},pe),pe.gfm=Se({},pe.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),pe.gfm.nptable=we(pe.gfm.nptable).replace("hr",pe.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",pe._tag).getRegex(),pe.gfm.table=we(pe.gfm.table).replace("hr",pe.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",pe._tag).getRegex(),pe.pedantic=Se({},pe.normal,{html:we(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",pe._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:Te,paragraph:we(pe.normal._paragraph).replace("hr",pe.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",pe.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var oe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Te,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:Te,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};oe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",oe.punctuation=we(oe.punctuation).replace(/punctuation/g,oe._punctuation).getRegex(),oe._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",oe._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",oe.em.start=we(oe.em.start).replace(/punctuation/g,oe._punctuation).getRegex(),oe.em.middle=we(oe.em.middle).replace(/punctuation/g,oe._punctuation).replace(/overlapSkip/g,oe._overlapSkip).getRegex(),oe.em.endAst=we(oe.em.endAst,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.em.endUnd=we(oe.em.endUnd,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.strong.start=we(oe.strong.start).replace(/punctuation/g,oe._punctuation).getRegex(),oe.strong.middle=we(oe.strong.middle).replace(/punctuation/g,oe._punctuation).replace(/blockSkip/g,oe._blockSkip).getRegex(),oe.strong.endAst=we(oe.strong.endAst,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.strong.endUnd=we(oe.strong.endUnd,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.blockSkip=we(oe._blockSkip,"g").getRegex(),oe.overlapSkip=we(oe._overlapSkip,"g").getRegex(),oe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,oe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,oe._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])?)+(?![-_])/,oe.autolink=we(oe.autolink).replace("scheme",oe._scheme).replace("email",oe._email).getRegex(),oe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,oe.tag=we(oe.tag).replace("comment",pe._comment).replace("attribute",oe._attribute).getRegex(),oe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,oe._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,oe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,oe.link=we(oe.link).replace("label",oe._label).replace("href",oe._href).replace("title",oe._title).getRegex(),oe.reflink=we(oe.reflink).replace("label",oe._label).getRegex(),oe.reflinkSearch=we(oe.reflinkSearch,"g").replace("reflink",oe.reflink).replace("nolink",oe.nolink).getRegex(),oe.normal=Se({},oe),oe.pedantic=Se({},oe.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",oe._label).getRegex(),reflink:we(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",oe._label).getRegex()}),oe.gfm=Se({},oe.normal,{escape:we(oe.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),oe.gfm.url=we(oe.gfm.url,"i").replace("email",oe.gfm._extended_email).getRegex(),oe.breaks=Se({},oe.gfm,{br:we(oe.br).replace("{2,}","*").getRegex(),text:we(oe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var De={block:pe,inline:oe},Ve=H.defaults,ze=De.block,et=De.inline;function Je(ge){return ge.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 ke(ge){var de="",fe,ee,te=ge.length;for(fe=0;fe<te;fe++)ee=ge.charCodeAt(fe),Math.random()>.5&&(ee="x"+ee.toString(16)),de+="&#"+ee+";";return de}var Ie=function(){function ge(fe){this.tokens=[],this.tokens.links=Object.create(null),this.options=fe||Ve,this.options.tokenizer=this.options.tokenizer||new xe,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ee={block:ze.normal,inline:et.normal};this.options.pedantic?(ee.block=ze.pedantic,ee.inline=et.pedantic):this.options.gfm&&(ee.block=ze.gfm,this.options.breaks?ee.inline=et.breaks:ee.inline=et.gfm),this.tokenizer.rules=ee}ge.lex=function(ee,te){var ne=new ge(te);return ne.lex(ee)};var de=ge.prototype;return de.lex=function(ee){return ee=ee.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(ee,this.tokens,!0),this.inline(this.tokens),this.tokens},de.blockTokens=function(ee,te,ne){te===void 0&&(te=[]),ne===void 0&&(ne=!0),ee=ee.replace(/^ +$/gm,"");for(var ue,me,Ee,Me;ee;){if(ue=this.tokenizer.space(ee)){ee=ee.substring(ue.raw.length),ue.type&&te.push(ue);continue}if(ue=this.tokenizer.code(ee,te)){ee=ee.substring(ue.raw.length),ue.type?te.push(ue):(Me=te[te.length-1],Me.raw+=`
`+ue.raw,Me.text+=`
`+ue.text);continue}if(ue=this.tokenizer.fences(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.heading(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.nptable(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.hr(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.blockquote(ee)){ee=ee.substring(ue.raw.length),ue.tokens=this.blockTokens(ue.text,[],ne),te.push(ue);continue}if(ue=this.tokenizer.list(ee)){for(ee=ee.substring(ue.raw.length),Ee=ue.items.length,me=0;me<Ee;me++)ue.items[me].tokens=this.blockTokens(ue.items[me].text,[],!1);te.push(ue);continue}if(ue=this.tokenizer.html(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ne&&(ue=this.tokenizer.def(ee))){ee=ee.substring(ue.raw.length),this.tokens.links[ue.tag]||(this.tokens.links[ue.tag]={href:ue.href,title:ue.title});continue}if(ue=this.tokenizer.table(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.lheading(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ne&&(ue=this.tokenizer.paragraph(ee))){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.text(ee,te)){ee=ee.substring(ue.raw.length),ue.type?te.push(ue):(Me=te[te.length-1],Me.raw+=`
`+ue.raw,Me.text+=`
`+ue.text);continue}if(ee){var tt="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(tt);break}else throw new Error(tt)}}return te},de.inline=function(ee){var te,ne,ue,me,Ee,Me,tt=ee.length;for(te=0;te<tt;te++){Me=ee[te];switch(Me.type){case"paragraph":case"text":case"heading":{Me.tokens=[],this.inlineTokens(Me.text,Me.tokens);break}case"table":{for(Me.tokens={header:[],cells:[]},me=Me.header.length,ne=0;ne<me;ne++)Me.tokens.header[ne]=[],this.inlineTokens(Me.header[ne],Me.tokens.header[ne]);for(me=Me.cells.length,ne=0;ne<me;ne++)for(Ee=Me.cells[ne],Me.tokens.cells[ne]=[],ue=0;ue<Ee.length;ue++)Me.tokens.cells[ne][ue]=[],this.inlineTokens(Ee[ue],Me.tokens.cells[ne][ue]);break}case"blockquote":{this.inline(Me.tokens);break}case"list":{for(me=Me.items.length,ne=0;ne<me;ne++)this.inline(Me.items[ne].tokens);break}}}return ee},de.inlineTokens=function(ee,te,ne,ue,me){te===void 0&&(te=[]),ne===void 0&&(ne=!1),ue===void 0&&(ue=!1),me===void 0&&(me="");var Ee,Me=ee,tt;if(this.tokens.links){var mt=Object.keys(this.tokens.links);if(mt.length>0)for(;(tt=this.tokenizer.rules.inline.reflinkSearch.exec(Me))!=null;)mt.includes(tt[0].slice(tt[0].lastIndexOf("[")+1,-1))&&(Me=Me.slice(0,tt.index)+"["+"a".repeat(tt[0].length-2)+"]"+Me.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(tt=this.tokenizer.rules.inline.blockSkip.exec(Me))!=null;)Me=Me.slice(0,tt.index)+"["+"a".repeat(tt[0].length-2)+"]"+Me.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;ee;){if(Ee=this.tokenizer.escape(ee)){ee=ee.substring(Ee.raw.length),te.push(Ee);continue}if(Ee=this.tokenizer.tag(ee,ne,ue)){ee=ee.substring(Ee.raw.length),ne=Ee.inLink,ue=Ee.inRawBlock,te.push(Ee);continue}if(Ee=this.tokenizer.link(ee)){ee=ee.substring(Ee.raw.length),Ee.type==="link"&&(Ee.tokens=this.inlineTokens(Ee.text,[],!0,ue)),te.push(Ee);continue}if(Ee=this.tokenizer.reflink(ee,this.tokens.links)){ee=ee.substring(Ee.raw.length),Ee.type==="link"&&(Ee.tokens=this.inlineTokens(Ee.text,[],!0,ue)),te.push(Ee);continue}if(Ee=this.tokenizer.strong(ee,Me,me)){ee=ee.substring(Ee.raw.length),Ee.tokens=this.inlineTokens(Ee.text,[],ne,ue),te.push(Ee);continue}if(Ee=this.tokenizer.em(ee,Me,me)){ee=ee.substring(Ee.raw.length),Ee.tokens=this.inlineTokens(Ee.text,[],ne,ue),te.push(Ee);continue}if(Ee=this.tokenizer.codespan(ee)){ee=ee.substring(Ee.raw.length),te.push(Ee);continue}if(Ee=this.tokenizer.br(ee)){ee=ee.substring(Ee.raw.length),te.push(Ee);continue}if(Ee=this.tokenizer.del(ee)){ee=ee.substring(Ee.raw.length),Ee.tokens=this.inlineTokens(Ee.text,[],ne,ue),te.push(Ee);continue}if(Ee=this.tokenizer.autolink(ee,ke)){ee=ee.substring(Ee.raw.length),te.push(Ee);continue}if(!ne&&(Ee=this.tokenizer.url(ee,ke))){ee=ee.substring(Ee.raw.length),te.push(Ee);continue}if(Ee=this.tokenizer.inlineText(ee,ue,Je)){ee=ee.substring(Ee.raw.length),me=Ee.raw.slice(-1),te.push(Ee);continue}if(ee){var dt="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(dt);break}else throw new Error(dt)}}return te},Z(ge,null,[{key:"rules",get:function(){return{block:ze,inline:et}}}]),ge}(),He=H.defaults,Ge=Q.cleanUrl,je=Q.escape,_e=function(){function ge(fe){this.options=fe||He}var de=ge.prototype;return de.code=function(ee,te,ne){var ue=(te||"").match(/\S*/)[0];if(this.options.highlight){var me=this.options.highlight(ee,ue);me!=null&&me!==ee&&(ne=!0,ee=me)}return ue?'<pre><code class="'+this.options.langPrefix+je(ue,!0)+'">'+(ne?ee:je(ee,!0))+`</code></pre>
`:"<pre><code>"+(ne?ee:je(ee,!0))+`</code></pre>
`},de.blockquote=function(ee){return`<blockquote>
`+ee+`</blockquote>
`},de.html=function(ee){return ee},de.heading=function(ee,te,ne,ue){return this.options.headerIds?"<h"+te+' id="'+this.options.headerPrefix+ue.slug(ne)+'">'+ee+"</h"+te+`>
`:"<h"+te+">"+ee+"</h"+te+`>
`},de.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},de.list=function(ee,te,ne){var ue=te?"ol":"ul",me=te&&ne!==1?' start="'+ne+'"':"";return"<"+ue+me+`>
`+ee+"</"+ue+`>
`},de.listitem=function(ee){return"<li>"+ee+`</li>
`},de.checkbox=function(ee){return"<input "+(ee?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},de.paragraph=function(ee){return"<p>"+ee+`</p>
`},de.table=function(ee,te){return te&&(te="<tbody>"+te+"</tbody>"),`<table>
<thead>
`+ee+`</thead>
`+te+`</table>
`},de.tablerow=function(ee){return`<tr>
`+ee+`</tr>
`},de.tablecell=function(ee,te){var ne=te.header?"th":"td",ue=te.align?"<"+ne+' align="'+te.align+'">':"<"+ne+">";return ue+ee+"</"+ne+`>
`},de.strong=function(ee){return"<strong>"+ee+"</strong>"},de.em=function(ee){return"<em>"+ee+"</em>"},de.codespan=function(ee){return"<code>"+ee+"</code>"},de.br=function(){return this.options.xhtml?"<br/>":"<br>"},de.del=function(ee){return"<del>"+ee+"</del>"},de.link=function(ee,te,ne){if(ee=Ge(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ne;var ue='<a href="'+je(ee)+'"';return te&&(ue+=' title="'+te+'"'),ue+=">"+ne+"</a>",ue},de.image=function(ee,te,ne){if(ee=Ge(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ne;var ue='<img src="'+ee+'" alt="'+ne+'"';return te&&(ue+=' title="'+te+'"'),ue+=this.options.xhtml?"/>":">",ue},de.text=function(ee){return ee},ge}(),Be=function(){function ge(){}var de=ge.prototype;return de.strong=function(ee){return ee},de.em=function(ee){return ee},de.codespan=function(ee){return ee},de.del=function(ee){return ee},de.html=function(ee){return ee},de.text=function(ee){return ee},de.link=function(ee,te,ne){return""+ne},de.image=function(ee,te,ne){return""+ne},de.br=function(){return""},ge}(),$e=function(){function ge(){this.seen={}}var de=ge.prototype;return de.slug=function(ee){var te=ee.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(te)){var ne=te;do this.seen[ne]++,te=ne+"-"+this.seen[ne];while(this.seen.hasOwnProperty(te))}return this.seen[te]=0,te},ge}(),qe=H.defaults,Qe=Q.unescape,Ze=function(){function ge(fe){this.options=fe||qe,this.options.renderer=this.options.renderer||new _e,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Be,this.slugger=new $e}ge.parse=function(ee,te){var ne=new ge(te);return ne.parse(ee)};var de=ge.prototype;return de.parse=function(ee,te){te===void 0&&(te=!0);var ne="",ue,me,Ee,Me,tt,mt,dt,Ct,St,st,Ft,_t,Zt,Xt,Ot,Ir,Kr,bt,Nr=ee.length;for(ue=0;ue<Nr;ue++){st=ee[ue];switch(st.type){case"space":continue;case"hr":{ne+=this.renderer.hr();continue}case"heading":{ne+=this.renderer.heading(this.parseInline(st.tokens),st.depth,Qe(this.parseInline(st.tokens,this.textRenderer)),this.slugger);continue}case"code":{ne+=this.renderer.code(st.text,st.lang,st.escaped);continue}case"table":{for(Ct="",dt="",Me=st.header.length,me=0;me<Me;me++)dt+=this.renderer.tablecell(this.parseInline(st.tokens.header[me]),{header:!0,align:st.align[me]});for(Ct+=this.renderer.tablerow(dt),St="",Me=st.cells.length,me=0;me<Me;me++){for(mt=st.tokens.cells[me],dt="",tt=mt.length,Ee=0;Ee<tt;Ee++)dt+=this.renderer.tablecell(this.parseInline(mt[Ee]),{header:!1,align:st.align[Ee]});St+=this.renderer.tablerow(dt)}ne+=this.renderer.table(Ct,St);continue}case"blockquote":{St=this.parse(st.tokens),ne+=this.renderer.blockquote(St);continue}case"list":{for(Ft=st.ordered,_t=st.start,Zt=st.loose,Me=st.items.length,St="",me=0;me<Me;me++)Ot=st.items[me],Ir=Ot.checked,Kr=Ot.task,Xt="",Ot.task&&(bt=this.renderer.checkbox(Ir),Zt?Ot.tokens.length>0&&Ot.tokens[0].type==="text"?(Ot.tokens[0].text=bt+" "+Ot.tokens[0].text,Ot.tokens[0].tokens&&Ot.tokens[0].tokens.length>0&&Ot.tokens[0].tokens[0].type==="text"&&(Ot.tokens[0].tokens[0].text=bt+" "+Ot.tokens[0].tokens[0].text)):Ot.tokens.unshift({type:"text",text:bt}):Xt+=bt),Xt+=this.parse(Ot.tokens,Zt),St+=this.renderer.listitem(Xt,Kr,Ir);ne+=this.renderer.list(St,Ft,_t);continue}case"html":{ne+=this.renderer.html(st.text);continue}case"paragraph":{ne+=this.renderer.paragraph(this.parseInline(st.tokens));continue}case"text":{for(St=st.tokens?this.parseInline(st.tokens):st.text;ue+1<Nr&&ee[ue+1].type==="text";)st=ee[++ue],St+=`
`+(st.tokens?this.parseInline(st.tokens):st.text);ne+=te?this.renderer.paragraph(St):St;continue}default:{var hr='Token with "'+st.type+'" type was not found.';if(this.options.silent){console.error(hr);return}else throw new Error(hr)}}}return ne},de.parseInline=function(ee,te){te=te||this.renderer;var ne="",ue,me,Ee=ee.length;for(ue=0;ue<Ee;ue++){me=ee[ue];switch(me.type){case"escape":{ne+=te.text(me.text);break}case"html":{ne+=te.html(me.text);break}case"link":{ne+=te.link(me.href,me.title,this.parseInline(me.tokens,te));break}case"image":{ne+=te.image(me.href,me.title,me.text);break}case"strong":{ne+=te.strong(this.parseInline(me.tokens,te));break}case"em":{ne+=te.em(this.parseInline(me.tokens,te));break}case"codespan":{ne+=te.codespan(me.text);break}case"br":{ne+=te.br();break}case"del":{ne+=te.del(this.parseInline(me.tokens,te));break}case"text":{ne+=te.text(me.text);break}default:{var Me='Token with "'+me.type+'" type was not found.';if(this.options.silent){console.error(Me);return}else throw new Error(Me)}}}return ne},ge}(),ct=Q.merge,it=Q.checkSanitizeDeprecation,rt=Q.escape,Ce=H.getDefaults,lt=H.changeDefaults,nt=H.defaults;function Ae(ge,de,fe){if(typeof ge=="undefined"||ge===null)throw new Error("marked(): input parameter is undefined or null");if(typeof ge!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(ge)+", string expected");if(typeof de=="function"&&(fe=de,de=null),de=ct({},Ae.defaults,de||{}),it(de),fe){var ee=de.highlight,te;try{te=Ie.lex(ge,de)}catch(Ee){return fe(Ee)}var ne=function(Me){var tt;if(!Me)try{tt=Ze.parse(te,de)}catch(mt){Me=mt}return de.highlight=ee,Me?fe(Me):fe(null,tt)};if(!ee||ee.length<3)return ne();if(delete de.highlight,!te.length)return ne();var ue=0;Ae.walkTokens(te,function(Ee){Ee.type==="code"&&(ue++,setTimeout(function(){ee(Ee.text,Ee.lang,function(Me,tt){if(Me)return ne(Me);tt!=null&&tt!==Ee.text&&(Ee.text=tt,Ee.escaped=!0),ue--,ue===0&&ne()})},0))}),ue===0&&ne();return}try{var me=Ie.lex(ge,de);return de.walkTokens&&Ae.walkTokens(me,de.walkTokens),Ze.parse(me,de)}catch(Ee){if(Ee.message+=`
Please report this to https://github.com/markedjs/marked.`,de.silent)return"<p>An error occurred:</p><pre>"+rt(Ee.message+"",!0)+"</pre>";throw Ee}}Ae.options=Ae.setOptions=function(ge){return ct(Ae.defaults,ge),lt(Ae.defaults),Ae},Ae.getDefaults=Ce,Ae.defaults=nt,Ae.use=function(ge){var de=ct({},ge);if(ge.renderer&&function(){var ee=Ae.defaults.renderer||new _e,te=function(me){var Ee=ee[me];ee[me]=function(){for(var Me=arguments.length,tt=new Array(Me),mt=0;mt<Me;mt++)tt[mt]=arguments[mt];var dt=ge.renderer[me].apply(ee,tt);return dt===!1&&(dt=Ee.apply(ee,tt)),dt}};for(var ne in ge.renderer)te(ne);de.renderer=ee}(),ge.tokenizer&&function(){var ee=Ae.defaults.tokenizer||new xe,te=function(me){var Ee=ee[me];ee[me]=function(){for(var Me=arguments.length,tt=new Array(Me),mt=0;mt<Me;mt++)tt[mt]=arguments[mt];var dt=ge.tokenizer[me].apply(ee,tt);return dt===!1&&(dt=Ee.apply(ee,tt)),dt}};for(var ne in ge.tokenizer)te(ne);de.tokenizer=ee}(),ge.walkTokens){var fe=Ae.defaults.walkTokens;de.walkTokens=function(ee){ge.walkTokens(ee),fe&&fe(ee)}}Ae.setOptions(de)},Ae.walkTokens=function(ge,de){for(var fe=N(ge),ee;!(ee=fe()).done;){var te=ee.value;de(te);switch(te.type){case"table":{for(var ne=N(te.tokens.header),ue;!(ue=ne()).done;){var me=ue.value;Ae.walkTokens(me,de)}for(var Ee=N(te.tokens.cells),Me;!(Me=Ee()).done;)for(var tt=Me.value,mt=N(tt),dt;!(dt=mt()).done;){var Ct=dt.value;Ae.walkTokens(Ct,de)}break}case"list":{Ae.walkTokens(te.items,de);break}default:te.tokens&&Ae.walkTokens(te.tokens,de)}}},Ae.Parser=Ze,Ae.parser=Ze.parse,Ae.Renderer=_e,Ae.TextRenderer=Be,Ae.Lexer=Ie,Ae.lexer=Ie.lex,Ae.Tokenizer=xe,Ae.Slugger=$e,Ae.parse=Ae;var Fe=Ae;return Fe})},ELLl:function(wt,pt,se){(function(re){re(se("VrN/"))})(function(re){var Z={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},D=re.Pos;re.defineOption("autoCloseBrackets",!1,function(w,b,u){u&&u!=re.Init&&(w.removeKeyMap(N),w.state.closeBrackets=null),b&&(M(Y(b,"pairs")),w.state.closeBrackets=b,w.addKeyMap(N))});function Y(w,b){return b=="pairs"&&typeof w=="string"?w:typeof w=="object"&&w[b]!=null?w[b]:Z[b]}var N={Backspace:P,Enter:_};function M(w){for(var b=0;b<w.length;b++){var u=w.charAt(b),o="'"+u+"'";N[o]||(N[o]=H(u))}}M(Z.pairs+"`");function H(w){return function(b){return A(b,w)}}function U(w){var b=w.state.closeBrackets;if(!b||b.override)return b;var u=w.getModeAt(w.getCursor());return u.closeBrackets||b}function P(w){var b=U(w);if(!b||w.getOption("disableInput"))return re.Pass;for(var u=Y(b,"pairs"),o=w.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return re.Pass;var h=R(w,o[l].head);if(!h||u.indexOf(h)%2!=0)return re.Pass}for(var l=o.length-1;l>=0;l--){var C=o[l].head;w.replaceRange("",D(C.line,C.ch-1),D(C.line,C.ch+1),"+delete")}}function _(w){var b=U(w),u=b&&Y(b,"explode");if(!u||w.getOption("disableInput"))return re.Pass;for(var o=w.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return re.Pass;var h=R(w,o[l].head);if(!h||u.indexOf(h)%2!=0)return re.Pass}w.operation(function(){var C=w.lineSeparator()||`
`;w.replaceSelection(C+C,null),w.execCommand("goCharLeft"),o=w.listSelections();for(var g=0;g<o.length;g++){var p=o[g].head.line;w.indentLine(p,null,!0),w.indentLine(p+1,null,!0)}})}function y(w){var b=re.cmpPos(w.anchor,w.head)>0;return{anchor:new D(w.anchor.line,w.anchor.ch+(b?-1:1)),head:new D(w.head.line,w.head.ch+(b?1:-1))}}function A(w,b){var u=U(w);if(!u||w.getOption("disableInput"))return re.Pass;var o=Y(u,"pairs"),l=o.indexOf(b);if(l==-1)return re.Pass;for(var h=Y(u,"closeBefore"),C=Y(u,"triples"),g=o.charAt(l+1)==b,p=w.listSelections(),k=l%2==0,E,f=0;f<p.length;f++){var m=p[f],d=m.head,a,x=w.getRange(d,D(d.line,d.ch+1));if(k&&!m.empty())a="surround";else if((g||!k)&&x==b)g&&L(w,d)?a="both":C.indexOf(b)>=0&&w.getRange(d,D(d.line,d.ch+3))==b+b+b?a="skipThree":a="skip";else if(g&&d.ch>1&&C.indexOf(b)>=0&&w.getRange(D(d.line,d.ch-2),d)==b+b){if(d.ch>2&&/\bstring/.test(w.getTokenTypeAt(D(d.line,d.ch-2))))return re.Pass;a="addFour"}else if(g){var v=d.ch==0?" ":w.getRange(D(d.line,d.ch-1),d);if(!re.isWordChar(x)&&v!=b&&!re.isWordChar(v))a="both";else return re.Pass}else if(k&&(x.length===0||/\s/.test(x)||h.indexOf(x)>-1))a="both";else return re.Pass;if(!E)E=a;else if(E!=a)return re.Pass}var T=l%2?o.charAt(l-1):b,I=l%2?b:o.charAt(l+1);w.operation(function(){if(E=="skip")w.execCommand("goCharRight");else if(E=="skipThree")for(var G=0;G<3;G++)w.execCommand("goCharRight");else if(E=="surround"){for(var V=w.getSelections(),G=0;G<V.length;G++)V[G]=T+V[G]+I;w.replaceSelections(V,"around"),V=w.listSelections().slice();for(var G=0;G<V.length;G++)V[G]=y(V[G]);w.setSelections(V)}else E=="both"?(w.replaceSelection(T+I,null),w.triggerElectric(T+I),w.execCommand("goCharLeft")):E=="addFour"&&(w.replaceSelection(T+T+T+T,"before"),w.execCommand("goCharRight"))})}function R(w,b){var u=w.getRange(D(b.line,b.ch-1),D(b.line,b.ch+1));return u.length==2?u:null}function L(w,b){var u=w.getTokenAt(D(b.line,b.ch+1));return/\bstring/.test(u.type)&&u.start==b.ch&&(b.ch==0||!/\bstring/.test(w.getTokenTypeAt(b)))}})},Gytx:function(wt,pt){wt.exports=function(re,Z,D,Y){var N=D?D.call(Y,re,Z):void 0;if(N!==void 0)return!!N;if(re===Z)return!0;if(typeof re!="object"||!re||typeof Z!="object"||!Z)return!1;var M=Object.keys(re),H=Object.keys(Z);if(M.length!==H.length)return!1;for(var U=Object.prototype.hasOwnProperty.bind(Z),P=0;P<M.length;P++){var _=M[P];if(!U(_))return!1;var y=re[_],A=Z[_];if(N=D?D.call(Y,y,A,_):void 0,N===!1||N===void 0&&y!==A)return!1}return!0}},HmJG:function(wt,pt,se){},LdHM:function(wt,pt,se){"use strict";se.d(pt,"b",function(){return h}),se.d(pt,"a",function(){return g});var re=se("1OyB"),Z=se("vuIU"),D=se("Ji7U"),Y=se("LK+K"),N=se("q1tI"),M=se("rePB"),H=se("Ff2n"),U=se("ODXe"),P=se("4IlW"),_=se("bX4T"),y=se("YrtM"),A=se("TSYQ"),R=se.n(A),L=se("+nKL"),w=se("8OUc"),b=function(q,ie){var ce=q.prefixCls,ve=q.id,Oe=q.flattenOptions,xe=q.childrenAsData,Te=q.values,we=q.searchValue,Se=q.multiple,pe=q.defaultActiveFirstOption,oe=q.height,De=q.itemHeight,Ve=q.notFoundContent,ze=q.open,et=q.menuItemSelectedIcon,Je=q.virtual,ke=q.onSelect,Ie=q.onToggleOpen,He=q.onActiveValue,Ge=q.onScroll,je=q.onMouseEnter,_e="".concat(ce,"-item"),Be=Object(y.a)(function(){return Oe},[ze,Oe],function(Fe,ge){return ge[0]&&Fe[1]!==ge[1]}),$e=N.useRef(null),qe=function(ge){ge.preventDefault()},Qe=function(ge){$e.current&&$e.current.scrollTo({index:ge})},Ze=function(ge){for(var de=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,fe=Be.length,ee=0;ee<fe;ee+=1){var te=(ge+ee*de+fe)%fe,ne=Be[te],ue=ne.group,me=ne.data;if(!ue&&!me.disabled)return te}return-1},ct=N.useState(function(){return Ze(0)}),it=Object(U.a)(ct,2),rt=it[0],Ce=it[1],lt=function(ge){Ce(ge);var de=Be[ge];if(!de){He(null,-1);return}He(de.data.value,ge)};N.useEffect(function(){lt(pe!==!1?Ze(0):-1)},[Be.length,we]),N.useEffect(function(){var Fe=setTimeout(function(){if(!Se&&ze&&Te.size===1){var ge=Array.from(Te)[0],de=Be.findIndex(function(fe){var ee=fe.data;return ee.value===ge});lt(de),Qe(de)}});return function(){return clearTimeout(Fe)}},[ze]);var nt=function(ge){ge!==void 0&&ke(ge,{selected:!Te.has(ge)}),Se||Ie(!1)};if(N.useImperativeHandle(ie,function(){return{onKeyDown:function(ge){var de=ge.which;switch(de){case P.a.UP:case P.a.DOWN:{var fe=0;if(de===P.a.UP?fe=-1:de===P.a.DOWN&&(fe=1),fe!==0){var ee=Ze(rt+fe,fe);Qe(ee),lt(ee)}break}case P.a.ENTER:{var te=Be[rt];te&&!te.data.disabled?nt(te.data.value):nt(void 0),ze&&ge.preventDefault();break}case P.a.ESC:Ie(!1)}},onKeyUp:function(){},scrollTo:function(ge){Qe(ge)}}}),Be.length===0)return N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),className:"".concat(_e,"-empty"),onMouseDown:qe},Ve);function Ae(Fe){var ge=Be[Fe];if(!ge)return null;var de=ge.data||{},fe=de.value,ee=de.label,te=de.children,ne=Object(_.a)(de,!0),ue=xe?te:ee;return ge?N.createElement("div",Object.assign({"aria-label":typeof ue=="string"?ue:null},ne,{key:Fe,role:"option",id:"".concat(ve,"_list_").concat(Fe),"aria-selected":Te.has(fe)}),fe):null}return N.createElement(N.Fragment,null,N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),style:{height:0,width:0,overflow:"hidden"}},Ae(rt-1),Ae(rt),Ae(rt+1)),N.createElement(L.a,{itemKey:"key",ref:$e,data:Be,height:oe,itemHeight:De,fullHeight:!1,onMouseDown:qe,onScroll:Ge,virtual:Je,onMouseEnter:je},function(Fe,ge){var de,fe=Fe.group,ee=Fe.groupOption,te=Fe.data,ne=te.label,ue=te.key;if(fe)return N.createElement("div",{className:R()(_e,"".concat(_e,"-group"))},ne!==void 0?ne:ue);var me=te.disabled,Ee=te.value,Me=te.title,tt=te.children,mt=te.style,dt=te.className,Ct=Object(H.a)(te,["disabled","value","title","children","style","className"]),St=Te.has(Ee),st="".concat(_e,"-option"),Ft=R()(_e,st,dt,(de={},Object(M.a)(de,"".concat(st,"-grouped"),ee),Object(M.a)(de,"".concat(st,"-active"),rt===ge&&!me),Object(M.a)(de,"".concat(st,"-disabled"),me),Object(M.a)(de,"".concat(st,"-selected"),St),de)),_t=xe?tt:ne,Zt=!et||typeof et=="function"||St;return N.createElement("div",Object.assign({},Ct,{"aria-selected":St,className:Ft,title:Me,onMouseMove:function(){if(rt===ge||me)return;lt(ge)},onClick:function(){me||nt(Ee)},style:mt}),N.createElement("div",{className:"".concat(st,"-content")},_t||Ee),N.isValidElement(et)||St,Zt&&N.createElement(w.a,{className:"".concat(_e,"-option-state"),customizeIcon:et,customizeIconProps:{isSelected:St}},St?"\u2713":null))}))},u=N.forwardRef(b);u.displayName="OptionList";var o=u,l=function(){return null};l.isSelectOption=!0;var h=l,C=function(){return null};C.isSelectOptGroup=!0;var g=C,p=se("VTBJ"),k=se("Zm9Q");function E(j){var q=j.key,ie=j.props,ce=ie.children,ve=ie.value,Oe=Object(H.a)(ie,["children","value"]);return Object(p.a)({key:q,value:ve!==void 0?ve:q,children:ce},Oe)}function f(j){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(k.a)(j).map(function(ie,ce){if(!N.isValidElement(ie)||!ie.type)return null;var ve=ie.type.isSelectOptGroup,Oe=ie.key,xe=ie.props,Te=xe.children,we=Object(H.a)(xe,["children"]);return q||!ve?E(ie):Object(p.a)(Object(p.a)({key:"__RC_SELECT_GRP__".concat(Oe===null?ce:Oe,"__"),label:Oe},we),{},{options:f(Te)})}).filter(function(ie){return ie})}var m=se("2Qr1"),d=se("qNPg"),a=se("U8pU"),x=se("Kwbf"),v=se("WKfj");function T(j){var q=j.mode,ie=j.options,ce=j.children,ve=j.backfill,Oe=j.allowClear,xe=j.placeholder,Te=j.getInputElement,we=j.showSearch,Se=j.onSearch,pe=j.defaultOpen,oe=j.autoFocus,De=j.labelInValue,Ve=j.value,ze=j.inputValue,et=j.optionLabelProp,Je=q==="multiple"||q==="tags",ke=we!==void 0?we:Je||q==="combobox",Ie=ie||f(ce);if(Object(x.a)(q!=="tags"||Ie.every(function(_e){return!_e.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),q==="tags"||q==="combobox"){var He=Ie.some(function(_e){return _e.options?_e.options.some(function(Be){return typeof("value"in Be?Be.value:Be.key)=="number"}):typeof("value"in _e?_e.value:_e.key)=="number"});Object(x.a)(!He,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(x.a)(q!=="combobox"||!et,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(x.a)(q==="combobox"||!ve,"`backfill` only works with `combobox` mode."),Object(x.a)(q==="combobox"||!Te,"`getInputElement` only work with `combobox` mode."),Object(x.b)(q!=="combobox"||!Te||!Oe||!xe,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Se&&!ke&&q!=="combobox"&&q!=="tags"&&Object(x.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(x.b)(!pe||oe,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Ve!=null){var Ge=Object(v.d)(Ve);Object(x.a)(!De||Ge.every(function(_e){return Object(a.a)(_e)==="object"&&("key"in _e||"value"in _e)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(x.a)(!Je||Array.isArray(Ve),"`value` should be array when `mode` is `multiple` or `tags`")}if(ce){var je=null;Object(k.a)(ce).some(function(_e){if(!N.isValidElement(_e)||!_e.type)return!1;var Be=_e.type;if(Be.isSelectOption)return!1;if(Be.isSelectOptGroup){var $e=Object(k.a)(_e.props.children).every(function(qe){return!N.isValidElement(qe)||!_e.type||qe.type.isSelectOption?!0:(je=qe.type,!1)});return!$e}return je=Be,!0}),je&&Object(x.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(je.displayName||je.name||je,"`.")),Object(x.a)(ze===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var I=T,G=Object(d.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:f,flattenOptions:m.d,getLabeledValue:m.e,filterOptions:m.b,isValueDisabled:m.g,findValueOption:m.c,warningProps:I,fillOptionsWithMissingValue:m.a}),V=function(j){Object(D.a)(ie,j);var q=Object(Y.a)(ie);function ie(){var ce;return Object(re.a)(this,ie),ce=q.apply(this,arguments),ce.selectRef=N.createRef(),ce.focus=function(){ce.selectRef.current.focus()},ce.blur=function(){ce.selectRef.current.blur()},ce}return Object(Z.a)(ie,[{key:"render",value:function(){return N.createElement(G,Object.assign({ref:this.selectRef},this.props))}}]),ie}(N.Component);V.Option=h,V.OptGroup=g;var Q=V,z=pt.c=Q},M8RZ:function(wt,pt,se){"use strict";se.d(pt,"a",function(){return P});var re=se("fWQN"),Z=se("mtLc"),D=se("yKVA"),Y=se("879j"),N=se("q1tI"),M=se.n(N),H=se("i8i4"),U=se.n(H),P=function(_){Object(D.a)(A,_);var y=Object(Y.a)(A);function A(R){var L;Object(re.a)(this,A),L=y.call(this,R);var w=window.document;return L.node=w.createElement("div"),w.body.appendChild(L.node),L}return Object(Z.a)(A,[{key:"render",value:function(){var L=this.props.children;return Object(H.createPortal)(L,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),A}(M.a.Component)},OLES:function(wt,pt,se){"use strict";var re=se("U8pU"),Z=se("VTBJ"),D=se("Ff2n"),Y=se("q1tI"),N=se("uciX"),M=se("7ixt"),H=function(R){var L=R.overlay,w=R.prefixCls,b=R.id,u=R.overlayInnerStyle;return Y.createElement("div",{className:"".concat(w,"-inner"),id:b,role:"tooltip",style:u},typeof L=="function"?L():L)},U=H,P=function(R,L){var w=R.overlayClassName,b=R.trigger,u=b===void 0?["hover"]:b,o=R.mouseEnterDelay,l=o===void 0?0:o,h=R.mouseLeaveDelay,C=h===void 0?.1:h,g=R.overlayStyle,p=R.prefixCls,k=p===void 0?"rc-tooltip":p,E=R.children,f=R.onVisibleChange,m=R.afterVisibleChange,d=R.transitionName,a=R.animation,x=R.placement,v=x===void 0?"right":x,T=R.align,I=T===void 0?{}:T,G=R.destroyTooltipOnHide,V=G===void 0?!1:G,Q=R.defaultVisible,z=R.getTooltipContainer,j=R.overlayInnerStyle,q=Object(D.a)(R,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),ie=Object(Y.useRef)(null);Object(Y.useImperativeHandle)(L,function(){return ie.current});var ce=Object(Z.a)({},q);"visible"in R&&(ce.popupVisible=R.visible);var ve=function(){var Se=R.arrowContent,pe=Se===void 0?null:Se,oe=R.overlay,De=R.id;return[Y.createElement("div",{className:"".concat(k,"-arrow"),key:"arrow"},pe),Y.createElement(U,{key:"content",prefixCls:k,id:De,overlay:oe,overlayInnerStyle:j})]},Oe=!1,xe=!1;if(typeof V=="boolean")Oe=V;else if(V&&Object(re.a)(V)==="object"){var Te=V.keepParent;Oe=Te===!0,xe=Te===!1}return Y.createElement(N.a,Object.assign({popupClassName:w,prefixCls:k,popup:ve,action:u,builtinPlacements:M.a,popupPlacement:v,ref:ie,popupAlign:I,getPopupContainer:z,onPopupVisibleChange:f,afterPopupVisibleChange:m,popupTransitionName:d,popupAnimation:a,defaultPopupVisible:Q,destroyPopupOnHide:Oe,autoDestroy:xe,mouseLeaveDelay:C,popupStyle:g,mouseEnterDelay:l},ce),E)},_=Object(Y.forwardRef)(P),y=pt.a=_},Ot1p:function(wt,pt,se){"use strict";var re=se("2qtc"),Z=se("kLXV"),D=se("rAM+"),Y=se("miYZ"),N=se("tsqr"),M=se("9og8"),H=se("tJVT"),U=se("jrin"),P=se("WmNS"),_=se.n(P),y=se("q1tI"),A=se.n(y),R=se("VrN/"),L=se.n(R),w=se("bdgK"),b=se("p77/"),u=se("Bd2K"),o=se("ELLl"),l=se("19Vz"),h=se("lZu9"),C=se("+NIl"),g=se("kSUc"),p=se("9Bee"),k=function(me){var Ee=me.value,Me=Ee===void 0?"":Ee,tt=me.className,mt=me.showTextOnly,dt=me.showLines,Ct=me.style,St=Ct===void 0?{}:Ct,st=Object(y.useMemo)(function(){return""},[Me]);return A.a.createElement(A.a.Fragment,null,A.a.createElement("div",{dangerouslySetInnerHTML:{__html:st}}))},E=se("0Owb"),f=se("dejd"),m=se("C+DQ"),d=se("1vsH"),a=se("m3rI"),x=[{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 v(me){var Ee=me.onActionCallback,Me=me.title,tt=me.icon,mt=me.actionName,dt=me.className,Ct=dt===void 0?"":dt,St=me.children;function st(){Ee(mt)}return A.a.createElement("a",{title:Me,className:Ct,onClick:st},A.a.createElement("i",{className:"md-iconfont ".concat(tt)}),St)}var T=function(me){var Ee=me.watch,Me=me.showNullButton,tt=me.onActionCallback,mt=me.fullScreen,dt=me.insertTemp,Ct=me.hidetoolBar,St=me.uuid,st=me.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(d.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(d.F)("_educoder_session"),"&key=").concat(St,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var Ft=[].concat(x,[{title:"".concat(Ee?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(Ee?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return A.a.createElement("ul",{className:"markdown-toolbar-container"},!Ct&&Ft.map(function(_t,Zt){return A.a.createElement("li",{key:Zt},_t.actionName?A.a.createElement(v,Object(E.a)({},_t,{onActionCallback:tt})):A.a.createElement("span",{className:"v-line"}))}),Me?A.a.createElement("li",null,A.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:tt},A.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,dt&&A.a.createElement("li",null,A.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(dt),onActionCallback:tt},A.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),A.a.createElement("li",{className:"btn-full-screen"},A.a.createElement(v,{icon:"".concat(mt?"icon-shrink":"icon-enlarge"),title:mt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:tt})))},I=se("M8RZ"),G=se("+L6B"),V=se("2/Rp"),Q=se("y8nQ"),z=se("Vl3Y"),j=se("5NDa"),q=se("5rEg"),ie={labelCol:{span:4},wrapperCol:{span:20}},ce=function(me){var Ee=me.callback,Me=me.onCancel;function tt(mt){Ee(mt)}return A.a.createElement(z.a,Object(E.a)({},ie,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:tt}),A.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},A.a.createElement(q.a,null)),A.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},A.a.createElement(q.a,null)),A.a.createElement("div",{className:"flex-container flex-end"},A.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(V.a,{type:"ghost",onClick:Me},"\u53D6\u6D88")))},ve=se("7ahc"),Oe=se("HmJG"),xe=se("BjJ7"),Te=z.a.useForm,we={width:280,marginRight:10},Se={labelCol:{span:5},wrapperCol:{span:19}},pe=function(me){var Ee=me.callback,Me=me.onCancel,tt=Te(),mt=Object(H.a)(tt,1),dt=mt[0];function Ct(Ft){Ee(Ft)}function St(Ft,_t){if(Ft.status===-1){N.b.error(Ft.message);return}dt.setFieldsValue({src:"/api/attachments/".concat(Ft.id),type:_t.type})}function st(Ft){var _t=Ft.target.files[0];De(_t,St)}return A.a.createElement(z.a,Object(E.a)({form:dt},Se,{className:"upload-image-panel",onFinish:Ct}),A.a.createElement(z.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},A.a.createElement("div",{className:"flex-container"},A.a.createElement(z.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},A.a.createElement(q.a,{style:we})),A.a.createElement(oe,{onFileChange:st}))),A.a.createElement(z.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},A.a.createElement(q.a,{style:{width:264}})),A.a.createElement(z.a.Item,{style:{textAlign:"right"}},A.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(V.a,{type:"ghost",onClick:Me},"\u53D6\u6D88")))};function oe(me){var Ee=me.onFileChange;return A.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",A.a.createElement("input",{type:"file",onChange:Ee}))}function De(me,Ee){if(!me)throw new String("\u6CA1\u6709\u6587\u4EF6");var Me=new FormData;Me.append("editormd-image-file",me),Me.append("file_param_name","editormd-image-file"),Me.append("byxhr","true");var tt=new window.XMLHttpRequest;tt.withCredentials=!0,tt.addEventListener("load",function(mt){Ee(JSON.parse(mt.target.responseText),me)},!1),tt.addEventListener("error",function(mt){console.error(mt)},!1),tt.open("POST","".concat(xe.a,"/api/attachments.json")),tt.send(Me)}var Ve=se("giR+"),ze=se("fyUT"),et=se("7Kak"),Je=se("9yH6"),ke=Je.a.Group,Ie={margin:"0 8px"},He=function(me){var Ee=me.callback,Me=me.onCancel;function tt(mt){Ee(mt)}return A.a.createElement(z.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:tt},A.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},A.a.createElement("span",{style:Ie},"\u5355\u5143\u683C\u6570\uFF1A"),A.a.createElement("span",{style:Ie},"\u884C\u6570"),A.a.createElement(z.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},A.a.createElement(ze.a,null)),A.a.createElement("span",{style:Ie},"\u5217\u6570"),A.a.createElement(z.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},A.a.createElement(ze.a,null))),A.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},A.a.createElement("span",{style:Ie},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),A.a.createElement(z.a.Item,{name:"align"},A.a.createElement(ke,null,A.a.createElement(Je.a,{value:"default"},A.a.createElement("i",{className:"fa fa-align-justify"})),A.a.createElement(Je.a,{value:"left"},A.a.createElement("i",{className:"fa fa-align-left"})),A.a.createElement(Je.a,{value:"center"},A.a.createElement("i",{className:"fa fa-align-center"})),A.a.createElement(Je.a,{value:"right"},A.a.createElement("i",{className:"fa fa-align-right"}))))),A.a.createElement("div",{className:"flex-container flex-end"},A.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(V.a,{type:"ghost",onClick:Me},"\u53D6\u6D88")))},Ge=se("ErOA"),je=se("7Cbv"),_e="link",Be="upload-image",$e="code-block",qe="add-table",Qe="------------",Ze={default:Qe,left:":".concat(Qe),center:":".concat(Qe,":"),right:"".concat(Qe,":")},ct=se("9VGf"),it,rt;function Ce(){}var lt=0,nt=1e4,Ae="\u2581",Fe=`
**\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 ge(me){return/^\d+$/.test(me)?"".concat(me,"px"):me}var de=navigator.platform.toUpperCase().indexOf("MAC")>=0,fe=de?"Cmd":"Ctrl",ee=["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"],te=(it={},Object(U.a)(it,fe+"-B","bold"),Object(U.a)(it,fe+"-I","italic"),it),ne=(rt={},Object(U.a)(rt,_e,"\u6DFB\u52A0\u94FE\u63A5"),Object(U.a)(rt,$e,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(U.a)(rt,Be,"\u6DFB\u52A0\u6587\u4EF6"),Object(U.a)(rt,qe,"\u6DFB\u52A0\u8868\u683C"),rt),ue=pt.a=function(me){var Ee=me.defaultValue,Me=Ee===void 0?"":Ee,tt=me.onChange,mt=me.width,dt=mt===void 0?"100%":mt,Ct=me.height,St=Ct===void 0?400:Ct,st=me.miniToolbar,Ft=st===void 0?!1:st,_t=me.isFocus,Zt=_t===void 0?!1:_t,Xt=me.watch,Ot=me.insertTemp,Ir=me.mode,Kr=Ir===void 0?"markdown":Ir,bt=me.id,Nr=bt===void 0?"markdown-editor-id":bt,hr=me.showResizeBar,pr=hr===void 0?!1:hr,Br=me.noStorage,ci=Br===void 0?!1:Br,qr=me.showNullButton,It=qr===void 0?!1:qr,ut=me.hidetoolBar,Hr=ut===void 0?!1:ut,ei=me.fullScreen,mr=ei===void 0?!1:ei,kt=me.onBlur,Fr=me.onCMBeforeChange,Vr=me.onFullScreen,fi=me.className,Ue=fi===void 0?"":fi,Et=me.disablePaste,pi=Et===void 0?!1:Et,mi=me.placeholder,gi=mi===void 0?"":mi,vi=me.values,W=vi===void 0?"":vi,s=Object(y.useState)(null),c=Object(H.a)(s,2),O=c[0],$=c[1],F=Object(y.useState)(Me),he=Object(H.a)(F,2),Re=he[0],Ke=he[1],ht=Object(y.useState)(Xt),Pe=Object(H.a)(ht,2),vt=Pe[0],Nt=Pe[1],Kt=Object(y.useState)(mr),Or=Object(H.a)(Kt,2),gr=Or[0],vr=Or[1],Xr=Object(y.useState)(""),Oi=Object(H.a)(Xr,2),nr=Oi[0],Ur=Oi[1],oi=Object(y.useState)(0),si=Object(H.a)(oi,2),_r=si[0],_i=si[1],yi=Object(y.useState)(St),zi=Object(H.a)(yi,2),Ki=zi[0],Yr=zi[1],Gr=Object(y.useState)(!1),bi=Object(H.a)(Gr,2),dn=bi[0],xi=bi[1],Jt=Object(y.useRef)(Object(je.a)()),Bt=Object(y.useRef)(!1),dr=Object(y.useRef)(),Dt=Object(y.useRef)(),qt=Object(y.useRef)(),Wt=Object(y.useRef)(),ti=Object(y.useRef)(),ar=function(){var ft=Object(M.a)(_.a.mark(function Tt(){var yt,Lt;return _.a.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:return Gt.next=2,Object(Ge.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Jt.current}});case 2:Lt=Gt.sent,Lt!=null&&(yt=Lt.attachments)!==null&&yt!==void 0&&yt.length&&(console.log("cm:",O,Dt),Lt.attachments.map(function(Mt){Mt.content_type.indexOf("image")>-1?O.replaceSelection("![,](/api/attachments/".concat(Mt.id,"?type=").concat(Mt.content_type,")")):Mt.content_type.indexOf("video")>-1?O.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Mt.content_type.indexOf("pdf")>-1?O.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Mt.id,"?type=").concat(Mt.content_type,'&disposition=inline" target="_blank">').concat(Mt.name,"</a>")):O.replaceSelection("[".concat(Mt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Mt.id,"?type=").concat(Mt.content_type,")"))}));case 4:case"end":return Gt.stop()}},Tt)}));return function(){return ft.apply(this,arguments)}}();Object(y.useEffect)(function(){Ke(W),O==null||O.setValue(W)},[W]),Object(y.useEffect)(function(){Vr==null||Vr(gr)},[gr]),Object(y.useEffect)(function(){if(Dt.current){var ft=L.a.fromTextArea(Dt.current,{mode:Kr,lineNumbers:!Ft,lineWrapping:!0,value:Me,autoCloseTags:!0,autoCloseBrackets:!0});Zt&&ft.focus();function Tt(yt,Lt){if(pi){Lt.preventDefault();return}var Pt=Lt.clipboardData;if(Pt){var Gt=Pt.types.toString(),Mt=Pt.items;if(Gt==="Files"||Pt.types.indexOf("Files")>-1){if(Lt.preventDefault(),Kr=="stex")return;try{var rr,Cr=Mt[1];((rr=Mt[0])===null||rr===void 0?void 0:rr.kind)==="file"&&(Cr=Mt[0]);var Rt=Cr.getAsFile(),li=Rt.name.split(".").pop();De(Rt,function(Ut){if(Ut.id){var wr,yr,zr;(Rt==null||((wr=Rt.type)===null||wr===void 0)?void 0:wr.indexOf("image"))>-1?ft.replaceSelection("![,](/api/attachments/".concat(Ut.id,"?type=").concat(Ut.content_type,")")):(Rt==null||((yr=Rt.type)===null||yr===void 0)?void 0:yr.indexOf("video"))>-1?ft.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,'"></video>')):(Rt==null||((zr=Rt.type)===null||zr===void 0)?void 0:zr.indexOf("pdf"))>-1?ft.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Rt.type,'&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):ee.includes(li)?ft.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,'?type=office&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):ft.replaceSelection("[".concat(Rt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Ut.content_type,")"))}else(Ut==null?void 0:Ut.status)===401&&(document.location.href="/user/login")})}catch(Ut){N.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return ft.on("paste",Tt),ft.on("dragleave",function(yt,Lt){qt.current.classList.remove("mouse-hover-md")}),ft.on("dragover",function(yt,Lt){qt.current.classList.add("mouse-hover-md")}),ft.on("drop",function(yt,Lt){qt.current.classList.add("mouse-hover-md");var Pt;if(Pt=Lt.dataTransfer.files,Pt.length>0){Lt.preventDefault(),Lt.stopPropagation();for(var Gt=function(Cr){var Rt=Pt[Cr],li=Rt.name.split(".").pop();De(Rt,function(Ut){if(Ut.id){var wr,yr,zr;(Rt==null||((wr=Rt.type)===null||wr===void 0)?void 0:wr.indexOf("image"))>-1?ft.replaceSelection("![,](/api/attachments/".concat(Ut.id,"?type=").concat(Ut.content_type,")")):(Rt==null||((yr=Rt.type)===null||yr===void 0)?void 0:yr.indexOf("video"))>-1?ft.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,'"></video>')):(Rt==null||((zr=Rt.type)===null||zr===void 0)?void 0:zr.indexOf("pdf"))>-1?ft.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Rt.type,'&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):ee.includes(li)?ft.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,'?type=office&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):ft.replaceSelection("[".concat(Rt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Ut.content_type,")"))}else(Ut==null?void 0:Ut.status)===401&&(document.location.href="/user/login")})},Mt=0;Mt<Pt.length;Mt++)Gt(Mt)}}),$(ft),function(){ft.off("paste",Tt)}}},[]);var Er=Object(y.useCallback)(function(){if(qt.current)try{}catch(ft){console.log(ft,"---- to set md editor body height")}},[Ki,qt,gr]);Object(y.useEffect)(function(){function ft(){var yt=new w.default(function(Lt){var Pt=Object(D.a)(Lt),Gt;try{for(Pt.s();!(Gt=Pt.n()).done;){var Mt=Gt.value;(Mt.target.offsetHeight>0||Mt.target.offsetWidth>0)&&(Er(),O.setSize("100%","100%"),O.refresh())}}catch(rr){Pt.e(rr)}finally{Pt.f()}});return yt.observe(Dt.current.parentElement),yt}if(O){var Tt=ft();return function(){Tt.unobserve(Dt.current.parentElement)}}},[O,Er]),Object(y.useEffect)(function(){if(O){for(var ft=[],Tt=function(){var Mt=Lt[yt];Pt=Object(H.a)(Mt,2);var rr=Pt[0],Cr=Pt[1],Rt=Object(U.a)({},rr,function(){Vi(Cr)});ft.push(Rt),O.addKeyMap(Rt)},yt=0,Lt=Object.entries(te);yt<Lt.length;yt++){var Pt;Tt()}return dr.current=setInterval(function(){Bt.current&&ar()},4e3),function(){clearInterval(dr.current);var Gt=Object(D.a)(ft),Mt;try{for(Gt.s();!(Mt=Gt.n()).done;){var rr=Mt.value;O.removeKeyMap(rr)}}catch(Cr){Gt.e(Cr)}finally{Gt.f()}}}},[O]),Object(y.useEffect)(function(){mr!==gr&&vr(mr)},[mr]),Object(ct.a)(function(){if(!ci&&_r>0){var ft=new Date().getTime(),Tt=window.sessionStorage.getItem(Nr);ft>=_r+nt&&(!Tt||Tt!==Re)&&(window.sessionStorage.setItem(Nr,Re),xi(!0))}},nt),Object(y.useEffect)(function(){Nt(Xt)},[O,Xt]),Object(y.useEffect)(function(){O&&(Zt&&O.focus())},[O,Zt]),Object(y.useEffect)(function(){if(vt&&O){var ft=O.getScrollerElement();function Tt(yt){var Lt=yt.target;if(ti.current){var Pt=Lt.scrollTop/Lt.scrollHeight;ti.current.scrollTop=ti.current.scrollHeight*Pt}}return ft.addEventListener("scroll",Tt),function(){ft.removeEventListener("scroll",Tt)}}},[O,vt]),Object(y.useEffect)(function(){if(O&&Fr){function ft(Tt,yt){Fr(Tt,yt)}return O.on("beforeChange",ft),function(){O.off("beforeChange",ft)}}},[O,Fr]),Object(y.useEffect)(function(){if(O&&kt){function ft(){kt(O.getValue())}return O.on("blur",ft),function(){O.off("blur",ft)}}},[O,kt]),Object(y.useEffect)(function(){if(O){function ft(Tt){var yt=Tt.getValue();Ke(yt),_i(new Date().getTime()),Tt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),tt&&tt(yt)}return O.on("change",ft),function(){O.off("change",ft)}}},[O,tt]),Object(y.useEffect)(function(){O&&(Me==null?(O.setValue(""),Ke("")):Me!==O.getValue()&&(O.setValue(Me),Ke(Me),O.setCursor(O.lineCount(),0)))},[O,Me]);var Vi=Object(y.useCallback)(function(ft){var Tt=O.getCursor(),yt=O.getSelection(),Lt=yt.split(`
`);switch(ft){case"bold":return O.replaceSelection("**"+yt+"**"),yt===""&&O.setCursor(Tt.line,Tt.ch+2),O.focus();case"italic":return O.replaceSelection("*"+yt+"*"),yt===""&&O.setCursor(Tt.line,Tt.ch+1),O.focus();case"code":return O.replaceSelection("`"+yt+"`"),yt===""&&O.setCursor(Tt.line,Tt.ch+1),O.focus();case"inline-latex":return O.replaceSelection("`$$"+yt+"$$`"),yt===""&&O.setCursor(Tt.line,Tt.ch+3),O.focus();case"latex":return O.replaceSelection("```latex\n"+yt+"\n```"),O.setCursor(Tt.line+1,yt.length+1),O.focus();case"line-break":return O.replaceSelection(`<br/>
`),O.focus();case"list-ul":return yt===""?O.replaceSelection("- "+yt):O.replaceSelection(Lt.map(function(Pt){return Pt===""?"":"- ".concat(Pt)}).join(`
`)),O.focus();case"list-ol":return yt===""?O.replaceSelection("1. "+yt):O.replaceSelection(Lt.map(function(Pt,Gt){return Pt===""?"":"".concat(Gt+1,". ").concat(Pt)}).join(`
`)),O.focus();case"add-null-ch":return yt===""&&O.setCursor(Tt.line,Tt.ch+1),O.replaceSelection(Ae),O.focus();case"inster-template-1":return yt===""&&O.setCursor(Tt.line,Tt.ch),O.replaceSelection(Fe),O.focus();case"eraser":return O.setValue(""),O.focus();case"trigger-watch":return Nt(!vt),O.focus();case"trigger-full-screen":return vr(!gr),O.focus();case _e:Ur(_e);return;case $e:Ur($e);return;case Be:Ur(Be);return;case qe:Ur(qe);return;default:throw new Error}},[O,vt,gr]),Ei=Object(y.useCallback)(function(ft){Ur("");switch(nr){case _e:var Tt=ft.title,yt=ft.link;return O.replaceSelection("[".concat(Tt,"](").concat(yt,")")),O.focus();case $e:var Lt=ft.language,Pt=ft.content;return O.replaceSelection(["```"+Lt,Pt,"```"].join(`
`)),O.focus();case Be:var Gt=ft.src,Mt=ft.alt;return Mt?O.replaceSelection("![ ".concat(Mt," ]( ").concat(Gt,' "').concat(Mt,'" )')):O.replaceSelection("![,](".concat(Gt,")")),O.focus();case qe:for(var rr=ft.row,Cr=ft.col,Rt=ft.align,li=`
`,Ut=0;Ut<rr;Ut++){for(var wr=[],yr=[],zr=0;zr<Cr;zr++)Ut===1&&yr.push(Ze[Rt]),wr.push(" ");Ut===1&&(li+="| ".concat(yr.join(" | "),` |
`)),li+="| ".concat(wr.join(Cr===1?"":" | "),` |
`)}return O.replaceSelection(li+`
`),O.focus();default:throw new Error}},[O,nr]),cn=Object(y.useMemo)(function(){switch(nr){case _e:return A.a.createElement(ce,{callback:Ei,onCancel:Si});case $e:return A.a.createElement(ve.b,{callback:Ei,onCancel:Si});case Be:return A.a.createElement(pe,{callback:Ei,onCancel:Si});case qe:return A.a.createElement(He,{callback:Ei,onCancel:Si});default:return null}},[nr]);function Si(){Ur("")}Object(y.useEffect)(function(){if(Wt.current){var ft=Wt.current,Tt=!1,yt=0;function Lt(Mt){Tt=!0,yt=Mt.pageY}function Pt(){Tt=!1}function Gt(Mt){if(Tt){var rr=Mt.pageY-yt;rr<0&&(rr=0),rr>300&&(rr=300);var Cr=St+rr+"px";Yr(Cr)}}return ft.addEventListener("mousedown",Lt),document.addEventListener("mousemove",Gt),document.addEventListener("mouseup",Pt),function(){ft.removeEventListener("mousedown",Lt),document.removeEventListener("mousemove",Gt),document.removeEventListener("mouseup",Pt)}}},[O,Wt]),Object(y.useEffect)(function(){Yr(St)},[St]);var ri=ge(dt),fn=ge(Ki),$r={width:ri,height:fn},pn=Object(y.useMemo)(function(){if(_r){var ft=new Date(_r),Tt=ft.getHours(),yt=ft.getMinutes(),Lt=ft.getSeconds();return Tt=Tt<10?"0"+Tt:Tt,yt=yt<10?"0"+yt:yt,Lt=Lt<10?"0"+Lt:Lt,"".concat(Tt,":").concat(yt,":").concat(Lt)}return 0},[_r]);function jn(){window.sessionStorage.removeItem(Nr),xi(!1),_i(0)}function Mi(){xi(!1),_i(0),O.setValue(window.sessionStorage.getItem(Nr))}function ua(ft,Tt){var yt=O.getValue();yt=yt.replace(ft,Tt),Ke(yt),O==null||O.setValue(yt)}return A.a.createElement(y.Fragment,null,A.a.createElement("div",{className:"markdown-editor-wrapper",ref:qt},A.a.createElement("div",{className:"markdown-editor-container ".concat(Ue," ").concat(vt?"on-preview":""," ").concat(Ft?"mini":""," ").concat(gr?"full-screen":""),style:$r},A.a.createElement(T,{insertTemp:Ot,watch:vt,fullScreen:gr,showNullButton:It,onActionCallback:Vi,hidetoolBar:Hr,uuid:Jt.current,setOpenPhones:function(){Bt.current=!0}}),A.a.createElement("div",{className:"markdown-editor-body"},A.a.createElement("div",{className:"codemirror-container"},A.a.createElement("textarea",{ref:Dt,placeholder:gi})),vt?A.a.createElement("div",{ref:ti,className:"preview-container"},Kr==="stex"&&A.a.createElement(k,{value:Re}),Kr!=="stex"&&A.a.createElement(p.a,{edit:!0,value:Re,replaces:ua})):null))),pr?A.a.createElement("a",{ref:Wt,className:"editor-resize"}):null,A.a.createElement(I.a,null,ne[nr]?A.a.createElement(Z.a,{centered:!0,title:ne[nr],visible:!0,onCancel:Si,footer:null,className:"markdown-popup-form"},cn):null))}},SJMd:function(wt,pt){/**
* @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 se,re,Z,D=!1,Y,N;window.PR_SHOULD_USE_CONTINUATION=!0;var M,H;(function(){var U=window,P=["break,continue,do,else,for,if,return,while"],_=[P,"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"],y=[_,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],A=[y,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],R=[y,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],L=[y,"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"],w="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",b=[y,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],u="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",o=[P,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],l=[P,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],h=[P,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],C=[A,L,R,b,u,o,l,h],g=/^(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",k="kwd",E="com",f="typ",m="lit",d="pun",a="pln",x="tag",v="dec",T="src",I="atn",G="atv",V="nocode",Q="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(ke){for(var Ie=0,He=!1,Ge=!1,je=0,_e=ke.length;je<_e;++je){var Be=ke[je];if(Be.ignoreCase)Ge=!0;else if(/[a-z]/i.test(Be.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){He=!0,Ge=!1;break}}var $e={b:8,t:9,n:10,v:11,f:12,r:13};function qe(rt){var Ce=rt.charCodeAt(0);if(Ce!==92)return Ce;var lt=rt.charAt(1);return Ce=$e[lt],Ce||("0"<=lt&&lt<="7"?parseInt(rt.substring(1),8):lt==="u"||lt==="x"?parseInt(rt.substring(2),16):rt.charCodeAt(1))}function Qe(rt){if(rt<32)return(rt<16?"\\x0":"\\x")+rt.toString(16);var Ce=String.fromCharCode(rt);return Ce==="\\"||Ce==="-"||Ce==="]"||Ce==="^"?"\\"+Ce:Ce}function Ze(rt){var Ce=rt.substring(1,rt.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")),lt=[],nt=Ce[0]==="^",Ae=["["];nt&&Ae.push("^");for(var Fe=nt?1:0,ge=Ce.length;Fe<ge;++Fe){var de=Ce[Fe];if(/\\[bdsw]/i.test(de))Ae.push(de);else{var fe=qe(de),ee;Fe+2<ge&&Ce[Fe+1]==="-"?(ee=qe(Ce[Fe+2]),Fe+=2):ee=fe,lt.push([fe,ee]),ee<65||fe>122||(ee<65||fe>90||lt.push([Math.max(65,fe)|32,Math.min(ee,90)|32]),ee<97||fe>122||lt.push([Math.max(97,fe)&~32,Math.min(ee,122)&~32]))}}lt.sort(function(me,Ee){return me[0]-Ee[0]||Ee[1]-me[1]});for(var te=[],ne=[],Fe=0;Fe<lt.length;++Fe){var ue=lt[Fe];ue[0]<=ne[1]+1?ne[1]=Math.max(ne[1],ue[1]):te.push(ne=ue)}for(var Fe=0;Fe<te.length;++Fe){var ue=te[Fe];Ae.push(Qe(ue[0])),ue[1]>ue[0]&&(ue[1]+1>ue[0]&&Ae.push("-"),Ae.push(Qe(ue[1])))}return Ae.push("]"),Ae.join("")}function ct(rt){for(var Ce=rt.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")),lt=Ce.length,nt=[],Ae=0,Fe=0;Ae<lt;++Ae){var ge=Ce[Ae];if(ge==="(")++Fe;else if(ge.charAt(0)==="\\"){var de=+ge.substring(1);de&&(de<=Fe?nt[de]=-1:Ce[Ae]=Qe(de))}}for(var Ae=1;Ae<nt.length;++Ae)nt[Ae]===-1&&(nt[Ae]=++Ie);for(var Ae=0,Fe=0;Ae<lt;++Ae){var ge=Ce[Ae];if(ge==="(")++Fe,nt[Fe]||(Ce[Ae]="(?:");else if(ge.charAt(0)==="\\"){var de=+ge.substring(1);de&&de<=Fe&&(Ce[Ae]="\\"+nt[de])}}for(var Ae=0;Ae<lt;++Ae)Ce[Ae]==="^"&&Ce[Ae+1]!=="^"&&(Ce[Ae]="");if(rt.ignoreCase&&He)for(var Ae=0;Ae<lt;++Ae){var ge=Ce[Ae],fe=ge.charAt(0);ge.length>=2&&fe==="["?Ce[Ae]=Ze(ge):fe!=="\\"&&(Ce[Ae]=ge.replace(/[a-zA-Z]/g,function(ne){var ue=ne.charCodeAt(0);return"["+String.fromCharCode(ue&~32,ue|32)+"]"}))}return Ce.join("")}for(var it=[],je=0,_e=ke.length;je<_e;++je){var Be=ke[je];if(Be.global||Be.multiline)throw new Error(""+Be);it.push("(?:"+ct(Be)+")")}return new RegExp(it.join("|"),Ge?"gi":"g")}function j(ke,Ie){var He=/(?:^|\s)nocode(?:\s|$)/,Ge=[],je=0,_e=[],Be=0;function $e(qe){var Qe=qe.nodeType;if(Qe==1){if(He.test(qe.className))return;for(var Ze=qe.firstChild;Ze;Ze=Ze.nextSibling)$e(Ze);var ct=qe.nodeName.toLowerCase();(ct==="br"||ct==="li")&&(Ge[Be]=`
`,_e[Be<<1]=je++,_e[Be++<<1|1]=qe)}else if(Qe==3||Qe==4){var it=qe.nodeValue;it.length&&(Ie?it=it.replace(/\r\n?/g,`
`):it=it.replace(/[ \t\r\n]+/g," "),Ge[Be]=it,_e[Be<<1]=je,je+=it.length,_e[Be++<<1|1]=qe)}}return $e(ke),{sourceCode:Ge.join("").replace(/\n$/,""),spans:_e}}function q(ke,Ie,He,Ge,je){if(!He)return;var _e={sourceNode:ke,pre:1,langExtension:null,numberLines:null,sourceCode:He,spans:null,basePos:Ie,decorations:null};Ge(_e),je.push.apply(je,_e.decorations)}var ie=/\S/;function ce(ke){for(var Ie=void 0,He=ke.firstChild;He;He=He.nextSibling){var Ge=He.nodeType;Ie=Ge===1?Ie?ke:He:Ge===3&&ie.test(He.nodeValue)?ke:Ie}return Ie===ke?void 0:Ie}function ve(ke,Ie){var He={},Ge;(function(){for(var Be=ke.concat(Ie),$e=[],qe={},Qe=0,Ze=Be.length;Qe<Ze;++Qe){var ct=Be[Qe],it=ct[3];if(it)for(var rt=it.length;--rt>=0;)He[it.charAt(rt)]=ct;var Ce=ct[1],lt=""+Ce;qe.hasOwnProperty(lt)||($e.push(Ce),qe[lt]=null)}$e.push(/[\0-\uffff]/),Ge=z($e)})();var je=Ie.length,_e=function(Be){for(var $e=Be.sourceCode,qe=Be.basePos,Qe=Be.sourceNode,Ze=[qe,a],ct=0,it=$e.match(Ge)||[],rt={},Ce=0,lt=it.length;Ce<lt;++Ce){var nt=it[Ce],Ae=rt[nt],Fe=void 0,ge;if(typeof Ae=="string")ge=!1;else{var de=He[nt.charAt(0)];if(de)Fe=nt.match(de[1]),Ae=de[0];else{for(var fe=0;fe<je;++fe)if(de=Ie[fe],Fe=nt.match(de[1]),Fe){Ae=de[0];break}Fe||(Ae=a)}ge=Ae.length>=5&&Ae.substring(0,5)==="lang-",ge&&!(Fe&&typeof Fe[1]=="string")&&(ge=!1,Ae=T),ge||(rt[nt]=Ae)}var ee=ct;if(ct+=nt.length,!ge)Ze.push(qe+ee,Ae);else{var te=Fe[1],ne=nt.indexOf(te),ue=ne+te.length;Fe[2]&&(ue=nt.length-Fe[2].length,ne=ue-te.length);var me=Ae.substring(5);q(Qe,qe+ee,nt.substring(0,ne),_e,Ze),q(Qe,qe+ee+ne,te,oe(me,te),Ze),q(Qe,qe+ee+ue,nt.substring(ue),_e,Ze)}}Be.decorations=Ze};return _e}function Oe(ke){var Ie=[],He=[];ke.tripleQuotedStrings?Ie.push([p,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):ke.multiLineStrings?Ie.push([p,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Ie.push([p,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),ke.verbatimStrings&&He.push([p,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Ge=ke.hashComments;Ge&&(ke.cStyleComments?(Ge>1?Ie.push([E,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Ie.push([E,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),He.push([p,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Ie.push([E,/^#[^\r\n]*/,null,"#"])),ke.cStyleComments&&(He.push([E,/^\/\/[^\r\n]*/,null]),He.push([E,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var je=ke.regexLiterals;if(je){var _e=je>1?"":`
\r`,Be=_e?".":"[\\S\\s]",$e="/(?=[^/*"+_e+"])(?:[^/\\x5B\\x5C"+_e+"]|\\x5C"+Be+"|\\x5B(?:[^\\x5C\\x5D"+_e+"]|\\x5C"+Be+")*(?:\\x5D|$))+/";He.push(["lang-regex",RegExp("^"+Q+"("+$e+")")])}var qe=ke.types;qe&&He.push([f,qe]);var Qe=(""+ke.keywords).replace(/^ | $/g,"");Qe.length&&He.push([k,new RegExp("^(?:"+Qe.replace(/[\s,]+/g,"|")+")\\b"),null]),Ie.push([a,/^\s+/,null,` \r
\xA0`]);var Ze="^.[^\\s\\w.$@'\"`/\\\\]*";return ke.regexLiterals&&(Ze+="(?!s*/)"),He.push([m,/^@[a-z_$][a-z_$@0-9]*/i,null],[f,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[m,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[d,new RegExp(Ze),null]),ve(Ie,He)}var xe=Oe({keywords:C,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Te(ke,Ie,He){for(var Ge=/(?:^|\s)nocode(?:\s|$)/,je=/\r\n?|\n/,_e=ke.ownerDocument,Be=_e.createElement("li");ke.firstChild;)Be.appendChild(ke.firstChild);var $e=[Be];function qe(Ce){var lt=Ce.nodeType;if(lt==1&&!Ge.test(Ce.className))if(Ce.nodeName==="br")Qe(Ce),Ce.parentNode&&Ce.parentNode.removeChild(Ce);else for(var nt=Ce.firstChild;nt;nt=nt.nextSibling)qe(nt);else if((lt==3||lt==4)&&He){var Ae=Ce.nodeValue,Fe=Ae.match(je);if(Fe){var ge=Ae.substring(0,Fe.index);Ce.nodeValue=ge;var de=Ae.substring(Fe.index+Fe[0].length);if(de){var fe=Ce.parentNode;fe.insertBefore(_e.createTextNode(de),Ce.nextSibling)}Qe(Ce),ge||Ce.parentNode.removeChild(Ce)}}}function Qe(Ce){for(;!Ce.nextSibling;)if(Ce=Ce.parentNode,!Ce)return;function lt(Fe,ge){var de=ge?Fe.cloneNode(!1):Fe,fe=Fe.parentNode;if(fe){var ee=lt(fe,1),te=Fe.nextSibling;ee.appendChild(de);for(var ne=te;ne;ne=te)te=ne.nextSibling,ee.appendChild(ne)}return de}for(var nt=lt(Ce.nextSibling,0),Ae;(Ae=nt.parentNode)&&Ae.nodeType===1;)nt=Ae;$e.push(nt)}for(var Ze=0;Ze<$e.length;++Ze)qe($e[Ze]);Ie===(Ie|0)&&$e[0].setAttribute("value",Ie);var ct=_e.createElement("ol");ct.className="linenums";for(var it=Math.max(0,Ie-1|0)||0,Ze=0,rt=$e.length;Ze<rt;++Ze)Be=$e[Ze],Be.className="L"+(Ze+it)%10,Be.firstChild||Be.appendChild(_e.createTextNode("\xA0")),ct.appendChild(Be);ke.appendChild(ct)}function we(ke){var Ie=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Ie=Ie&&+Ie[1]<=8;var He=/\n/g,Ge=ke.sourceCode,je=Ge.length,_e=0,Be=ke.spans,$e=Be.length,qe=0,Qe=ke.decorations,Ze=Qe.length,ct=0;Qe[Ze]=je;var it,rt;for(rt=it=0;rt<Ze;)Qe[rt]!==Qe[rt+2]?(Qe[it++]=Qe[rt++],Qe[it++]=Qe[rt++]):rt+=2;for(Ze=it,rt=it=0;rt<Ze;){for(var Ce=Qe[rt],lt=Qe[rt+1],nt=rt+2;nt+2<=Ze&&Qe[nt+1]===lt;)nt+=2;Qe[it++]=Ce,Qe[it++]=lt,rt=nt}Ze=Qe.length=it;var Ae=ke.sourceNode,Fe="";Ae&&(Fe=Ae.style.display,Ae.style.display="none");try{for(var ge=null;qe<$e;){var de=Be[qe],fe=Be[qe+2]||je,ee=Qe[ct+2]||je,nt=Math.min(fe,ee),te=Be[qe+1],ne;if(te.nodeType!==1&&(ne=Ge.substring(_e,nt))){Ie&&(ne=ne.replace(He,"\r")),te.nodeValue=ne;var ue=te.ownerDocument,me=ue.createElement("span");me.className=Qe[ct+1];var Ee=te.parentNode;Ee.replaceChild(me,te),me.appendChild(te),_e<fe&&(Be[qe+1]=te=ue.createTextNode(Ge.substring(nt,fe)),Ee.insertBefore(te,me.nextSibling))}_e=nt,_e>=fe&&(qe+=2),_e>=ee&&(ct+=2)}}finally{Ae&&(Ae.style.display=Fe)}}var Se={};function pe(ke,Ie){for(var He=Ie.length;--He>=0;){var Ge=Ie[He];Se.hasOwnProperty(Ge)?U.console&&console.warn("cannot override language handler %s",Ge):Se[Ge]=ke}}function oe(ke,Ie){return ke&&Se.hasOwnProperty(ke)||(ke=/^\s*</.test(Ie)?"default-markup":"default-code"),Se[ke]}pe(xe,["default-code"]),pe(ve([],[[a,/^[^<?]+/],[v,/^<!\w[^>]*(?:>|$)/],[E,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[d,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),pe(ve([[a,/^[\s]+/,null,` \r
`],[G,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[x,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[I,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[d,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),pe(ve([],[[G,/^[\s\S]+/]]),["uq.val"]),pe(Oe({keywords:A,hashComments:!0,cStyleComments:!0,types:g}),["c","cc","cpp","cxx","cyc","m"]),pe(Oe({keywords:"null,true,false"}),["json"]),pe(Oe({keywords:L,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:g}),["cs"]),pe(Oe({keywords:R,cStyleComments:!0}),["java"]),pe(Oe({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),pe(Oe({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),pe(Oe({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),pe(Oe({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),pe(Oe({keywords:b,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),pe(Oe({keywords:w,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),pe(ve([],[[p,/^[\s\S]+/]]),["regex"]);function De(ke){var Ie=ke.langExtension;try{var He=j(ke.sourceNode,ke.pre),Ge=He.sourceCode;ke.sourceCode=Ge,ke.spans=He.spans,ke.basePos=0,oe(Ie,Ge)(ke),we(ke)}catch(je){U.console&&console.log(je&&je.stack||je)}}function Ve(ke,Ie,He){var Ge=He||!1,je=Ie||null,_e=document.createElement("div");_e.innerHTML="<pre>"+ke+"</pre>",_e=_e.firstChild,Ge&&Te(_e,Ge,!0);var Be={langExtension:je,numberLines:Ge,sourceNode:_e,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return De(Be),_e.innerHTML}function ze(ke,Ie){var He=Ie||document.body,Ge=He.ownerDocument||document;function je(de){return He.getElementsByTagName(de)}for(var _e=[je("pre"),je("code"),je("xmp")],Be=[],$e=0;$e<_e.length;++$e)for(var qe=0,Qe=_e[$e].length;qe<Qe;++qe)Be.push(_e[$e][qe]);_e=null;var Ze=Date;Ze.now||(Ze={now:function(){return+new Date}});var ct=0,it=/\blang(?:uage)?-([\w.]+)(?!\S)/,rt=/\bprettyprint\b/,Ce=/\bprettyprinted\b/,lt=/pre|xmp/i,nt=/^code$/i,Ae=/^(?:pre|code|xmp)$/i,Fe={};function ge(){for(var de=U.PR_SHOULD_USE_CONTINUATION?Ze.now()+250:Infinity;ct<Be.length&&Ze.now()<de;ct++){for(var fe=Be[ct],ee=Fe,te=fe;te=te.previousSibling;){var ne=te.nodeType,ue=(ne===7||ne===8)&&te.nodeValue;if(ue?!/^\??prettify\b/.test(ue):ne!==3||/\S/.test(te.nodeValue))break;if(ue){ee={},ue.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Xt,Ot,Ir){ee[Ot]=Ir});break}}var me=fe.className;if((ee!==Fe||rt.test(me))&&!Ce.test(me)){for(var Ee=!1,Me=fe.parentNode;Me;Me=Me.parentNode){var tt=Me.tagName;if(Ae.test(tt)&&Me.className&&rt.test(Me.className)){Ee=!0;break}}if(!Ee){fe.className+=" prettyprinted";var mt=ee.lang;if(!mt){mt=me.match(it);var dt;!mt&&(dt=ce(fe))&&nt.test(dt.tagName)&&(mt=dt.className.match(it)),mt&&(mt=mt[1])}var Ct;if(lt.test(fe.tagName))Ct=1;else{var St=fe.currentStyle,st=Ge.defaultView,Ft=St?St.whiteSpace:st&&st.getComputedStyle?st.getComputedStyle(fe,null).getPropertyValue("white-space"):0;Ct=Ft&&Ft.substring(0,3)==="pre"}var _t=ee.linenums;(_t=_t==="true"||+_t)||(_t=me.match(/\blinenums\b(?::(\d+))?/),_t=_t?_t[1]&&_t[1].length?+_t[1]:!0:!1),_t&&Te(fe,_t,Ct);var Zt={langExtension:mt,sourceNode:fe,numberLines:_t,pre:Ct,sourceCode:null,basePos:null,spans:null,decorations:null};De(Zt)}}}ct<Be.length?U.setTimeout(ge,250):typeof ke=="function"&&ke()}ge()}var et=U.PR={createSimpleLexer:ve,registerLangHandler:pe,sourceDecorator:Oe,PR_ATTRIB_NAME:I,PR_ATTRIB_VALUE:G,PR_COMMENT:E,PR_DECLARATION:v,PR_KEYWORD:k,PR_LITERAL:m,PR_NOCODE:V,PR_PLAIN:a,PR_PUNCTUATION:d,PR_SOURCE:T,PR_STRING:p,PR_TAG:x,PR_TYPE:f,prettyPrintOne:D?U.prettyPrintOne=Ve:M=Ve,prettyPrint:H=D?U.prettyPrint=ze:H=ze},Je=U.define;typeof Je=="function"&&Je.amd&&Je("google-code-prettify",[],function(){return et})})()},"VrN/":function(wt,pt,se){(function(re,Z){wt.exports=Z()})(this,function(){"use strict";var re=navigator.userAgent,Z=navigator.platform,D=/gecko\/\d/i.test(re),Y=/MSIE \d/.test(re),N=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(re),M=/Edge\/(\d+)/.exec(re),H=Y||N||M,U=H&&(Y?document.documentMode||6:+(M||N)[1]),P=!M&&/WebKit\//.test(re),_=P&&/Qt\/\d+\.\d+/.test(re),y=!M&&/Chrome\//.test(re),A=/Opera\//.test(re),R=/Apple Computer/.test(navigator.vendor),L=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(re),w=/PhantomJS/.test(re),b=!M&&/AppleWebKit/.test(re)&&/Mobile\/\w+/.test(re),u=/Android/.test(re),o=b||u||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(re),l=b||/Mac/.test(Z),h=/\bCrOS\b/.test(re),C=/win/i.test(Z),g=A&&re.match(/Version\/(\d*\.\d*)/);g&&(g=Number(g[1])),g&&g>=15&&(A=!1,P=!0);var p=l&&(_||A&&(g==null||g<12.11)),k=D||H&&U>=9;function E(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var f=function(e,t){var i=e.className,r=E(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 m(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function d(e,t){return m(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 S=0;S<t.length;++S)n.appendChild(t[S]);return n}function x(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var v;document.createRange?v=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:v=function(e,t,i){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(n){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};function T(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function I(){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;E(t).test(i)||(e.className+=(i?" ":"")+t)}function V(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!E(i[r]).test(t)&&(t+=" "+i[r]);return t}var Q=function(e){e.select()};b?Q=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:H&&(Q=function(e){try{e.select()}catch(t){}});function z(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function j(e,t,i){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function q(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var S=r||0,B=n||0;;){var K=e.indexOf(" ",S);if(K<0||K>=t)return B+(t-S);B+=K-S,B+=i-B%i,S=K+1}}var ie=function(){this.id=null,this.f=null,this.time=0,this.handler=z(this.onTimeout,this)};ie.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},ie.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=i)};function ce(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var ve=50,Oe={toString:function(){return"CodeMirror.Pass"}},xe={scroll:!1},Te={origin:"*mouse"},we={origin:"+move"};function Se(e,t,i){for(var r=0,n=0;;){var S=e.indexOf(" ",r);S==-1&&(S=e.length);var B=S-r;if(S==e.length||n+B>=t)return r+Math.min(B,t-n);if(n+=S-r,n+=i-n%i,r=S+1,n>=t)return r}}var pe=[""];function oe(e){for(;pe.length<=e;)pe.push(De(pe)+" ");return pe[e]}function De(e){return e[e.length-1]}function Ve(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function ze(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function et(){}function Je(e,t){var i;return Object.create?i=Object.create(e):(et.prototype=e,i=new et),t&&j(t,i),i}var ke=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Ie(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||ke.test(e))}function He(e,t){return t?t.source.indexOf("\\w")>-1&&Ie(e)?!0:t.test(e):Ie(e)}function Ge(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var je=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function _e(e){return e.charCodeAt(0)>=768&&je.test(e)}function Be(e,t,i){for(;(i<0?t>0:t<e.length)&&_e(e.charAt(t));)t+=i;return t}function $e(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,S=r<0?Math.ceil(n):Math.floor(n);if(S==t)return e(S)?t:i;e(S)?i=S:t=S+r}}function qe(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,S=0;S<e.length;++S){var B=e[S];(B.from<i&&B.to>t||t==i&&B.to==t)&&(r(Math.max(B.from,t),Math.min(B.to,i),B.level==1?"rtl":"ltr",S),n=!0)}n||r(t,i,"ltr")}var Qe=null;function Ze(e,t,i){var r;Qe=null;for(var n=0;n<e.length;++n){var S=e[n];if(S.from<t&&S.to>t)return n;S.to==t&&(S.from!=S.to&&i=="before"?r=n:Qe=n),S.from==t&&(S.from!=S.to&&i!="before"?r=n:Qe=n)}return r!=null?r:Qe}var ct=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(J){return J<=247?e.charAt(J):1424<=J&&J<=1524?"R":1536<=J&&J<=1785?t.charAt(J-1536):1774<=J&&J<=2220?"r":8192<=J&&J<=8203?"w":J==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,S=/[LRr]/,B=/[Lb1n]/,K=/[1n]/;function X(J,ae,le){this.level=J,this.from=ae,this.to=le}return function(J,ae){var le=ae=="ltr"?"L":"R";if(J.length==0||ae=="ltr"&&!r.test(J))return!1;for(var be=J.length,ye=[],Le=0;Le<be;++Le)ye.push(i(J.charCodeAt(Le)));for(var Ne=0,We=le;Ne<be;++Ne){var Xe=ye[Ne];Xe=="m"?ye[Ne]=We:We=Xe}for(var at=0,Ye=le;at<be;++at){var ot=ye[at];ot=="1"&&Ye=="r"?ye[at]="n":S.test(ot)&&(Ye=ot,ot=="r"&&(ye[at]="R"))}for(var xt=1,gt=ye[0];xt<be-1;++xt){var At=ye[xt];At=="+"&&gt=="1"&&ye[xt+1]=="1"?ye[xt]="1":At==","&&gt==ye[xt+1]&&(gt=="1"||gt=="n")&&(ye[xt]=gt),gt=At}for(var zt=0;zt<be;++zt){var lr=ye[zt];if(lr==",")ye[zt]="N";else if(lr=="%"){var Yt=void 0;for(Yt=zt+1;Yt<be&&ye[Yt]=="%";++Yt);for(var Pr=zt&&ye[zt-1]=="!"||Yt<be&&ye[Yt]=="1"?"1":"N",kr=zt;kr<Yt;++kr)ye[kr]=Pr;zt=Yt-1}}for(var er=0,Dr=le;er<be;++er){var fr=ye[er];Dr=="L"&&fr=="1"?ye[er]="L":S.test(fr)&&(Dr=fr)}for(var ir=0;ir<be;++ir)if(n.test(ye[ir])){var tr=void 0;for(tr=ir+1;tr<be&&n.test(ye[tr]);++tr);for(var $t=(ir?ye[ir-1]:le)=="L",Rr=(tr<be?ye[tr]:le)=="L",un=$t==Rr?$t?"L":"R":le,Ri=ir;Ri<tr;++Ri)ye[Ri]=un;ir=tr-1}for(var xr=[],ai,ur=0;ur<be;)if(B.test(ye[ur])){var Va=ur;for(++ur;ur<be&&B.test(ye[ur]);++ur);xr.push(new X(0,Va,ur))}else{var di=ur,Hi=xr.length,Gi=ae=="rtl"?1:0;for(++ur;ur<be&&ye[ur]!="L";++ur);for(var Tr=di;Tr<ur;)if(K.test(ye[Tr])){di<Tr&&(xr.splice(Hi,0,new X(1,di,Tr)),Hi+=Gi);var hn=Tr;for(++Tr;Tr<ur&&K.test(ye[Tr]);++Tr);xr.splice(Hi,0,new X(2,hn,Tr)),Hi+=Gi,di=Tr}else++Tr;di<ur&&xr.splice(Hi,0,new X(1,di,ur))}return ae=="ltr"&&(xr[0].level==1&&(ai=J.match(/^\s+/))&&(xr[0].from=ai[0].length,xr.unshift(new X(0,0,ai[0].length))),De(xr).level==1&&(ai=J.match(/\s+$/))&&(De(xr).to-=ai[0].length,xr.push(new X(0,be-ai[0].length,be)))),ae=="rtl"?xr.reverse():xr}}();function it(e,t){var i=e.order;return i==null&&(i=e.order=ct(e.text,t)),i}var rt=[],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]||rt).concat(i)}};function lt(e,t){return e._handlers&&e._handlers[t]||rt}function nt(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 S=ce(n,i);S>-1&&(r[t]=n.slice(0,S).concat(n.slice(S+1)))}}}function Ae(e,t){var i=lt(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 Fe(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Ae(e,i||t.type,e,t),ne(t)||t.codemirrorIgnore}function ge(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;for(var i=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)ce(i,t[r])==-1&&i.push(t[r])}function de(e,t){return lt(e,t).length>0}function fe(e){e.prototype.on=function(t,i){Ce(this,t,i)},e.prototype.off=function(t,i){nt(this,t,i)}}function ee(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function te(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ne(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ue(e){ee(e),te(e)}function me(e){return e.target||e.srcElement}function Ee(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),l&&e.ctrlKey&&t==1&&(t=3),t}var Me=function(){if(H&&U<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),tt;function mt(e){if(tt==null){var t=a("span","\u200B");d(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(tt=t.offsetWidth<=1&&t.offsetHeight>2&&!(H&&U<8))}var i=tt?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var dt;function Ct(e){if(dt!=null)return dt;var t=d(e,document.createTextNode("A\u062EA")),i=v(t,0,1).getBoundingClientRect(),r=v(t,1,2).getBoundingClientRect();return m(e),!i||i.left==i.right?!1:dt=r.right-i.right<3}var St=`
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 S=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),B=S.indexOf("\r");B!=-1?(i.push(S.slice(0,B)),t+=B+1):(i.push(S),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},st=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},Ft=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),_t=null;function Zt(e){if(_t!=null)return _t;var t=d(e,a("span","x")),i=t.getBoundingClientRect(),r=v(t,0,1).getBoundingClientRect();return _t=Math.abs(i.left-r.left)>1}var Xt={},Ot={};function Ir(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Xt[e]=t}function Kr(e,t){Ot[e]=t}function bt(e){if(typeof e=="string"&&Ot.hasOwnProperty(e))e=Ot[e];else if(e&&typeof e.name=="string"&&Ot.hasOwnProperty(e.name)){var t=Ot[e.name];typeof t=="string"&&(t={name:t}),e=Je(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return bt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return bt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Nr(e,t){t=bt(t);var i=Xt[t.name];if(!i)return Nr(e,"text/plain");var r=i(e,t);if(hr.hasOwnProperty(t.name)){var n=hr[t.name];for(var S in n){if(!n.hasOwnProperty(S))continue;r.hasOwnProperty(S)&&(r["_"+S]=r[S]),r[S]=n[S]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var B in t.modeProps)r[B]=t.modeProps[B];return r}var hr={};function pr(e,t){var i=hr.hasOwnProperty(e)?hr[e]:hr[e]={};j(t,i)}function Br(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 ci(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 qr(e,t,i){return e.startState?e.startState(t,i):!0}var It=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};It.prototype.eol=function(){return this.pos>=this.string.length},It.prototype.sol=function(){return this.pos==this.lineStart},It.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},It.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},It.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},It.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},It.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},It.prototype.skipToEnd=function(){this.pos=this.string.length},It.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},It.prototype.backUp=function(e){this.pos-=e},It.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=q(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},It.prototype.indentation=function(){return q(this.string,null,this.tabSize)-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},It.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(B){return i?B.toLowerCase():B},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var S=this.string.slice(this.pos).match(e);return S&&S.index>0?null:(S&&t!==!1&&(this.pos+=S[0].length),S)}},It.prototype.current=function(){return this.string.slice(this.start,this.pos)},It.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},It.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},It.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function ut(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],S=n.chunkSize();if(t<S){i=n;break}t-=S}return i.lines[t]}function Hr(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(S){var B=S.text;n==i.line&&(B=B.slice(0,i.ch)),n==t.line&&(B=B.slice(t.ch)),r.push(B),++n}),r}function ei(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function mr(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function kt(e){if(e.parent==null)return null;for(var t=e.parent,i=ce(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var n=0;!(r.children[n]==t);++n)i+=r.children[n].chunkSize();return i+t.first}function Fr(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],S=n.height;if(t<S){e=n;continue e}t-=S,i+=n.chunkSize()}return i}while(!e.lines);for(var B=0;B<e.lines.length;++B){var K=e.lines[B],X=K.height;if(t<X)break;t-=X}return i+B}function Vr(e,t){return t>=e.first&&t<e.first+e.size}function fi(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Ue(e,t,i){if(i===void 0&&(i=null),!(this instanceof Ue))return new Ue(e,t,i);this.line=e,this.ch=t,this.sticky=i}function Et(e,t){return e.line-t.line||e.ch-t.ch}function pi(e,t){return e.sticky==t.sticky&&Et(e,t)==0}function mi(e){return Ue(e.line,e.ch)}function gi(e,t){return Et(e,t)<0?t:e}function vi(e,t){return Et(e,t)<0?e:t}function W(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function s(e,t){if(t.line<e.first)return Ue(e.first,0);var i=e.first+e.size-1;return t.line>i?Ue(i,ut(e,i).text.length):c(t,ut(e,t.line).text.length)}function c(e,t){var i=e.ch;return i==null||i>t?Ue(e.line,t):i<0?Ue(e.line,0):e}function O(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=s(e,t[r]);return i}var $=function(e,t){this.state=e,this.lookAhead=t},F=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};F.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},F.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}},F.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},F.fromSaved=function(e,t,i){return t instanceof $?new F(e,Br(e.mode,t.state),i,t.lookAhead):new F(e,Br(e.mode,t),i)},F.prototype.save=function(e){var t=e!==!1?Br(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new $(t,this.maxLookAhead):t};function he(e,t,i,r){var n=[e.state.modeGen],S={};gr(e,t.text,e.doc.mode,i,function(J,ae){return n.push(J,ae)},S,r);for(var B=i.state,K=function(J){i.baseTokens=n;var ae=e.state.overlays[J],le=1,be=0;i.state=!0,gr(e,t.text,ae.mode,i,function(ye,Le){for(var Ne=le;be<ye;){var We=n[le];We>ye&&n.splice(le,1,ye,n[le+1],We),le+=2,be=Math.min(ye,We)}if(!Le)return;if(ae.opaque)n.splice(Ne,le-Ne,ye,"overlay "+Le),le=Ne+2;else for(;Ne<le;Ne+=2){var Xe=n[Ne+1];n[Ne+1]=(Xe?Xe+" ":"")+"overlay "+Le}},S),i.state=B,i.baseTokens=null,i.baseTokenPos=1},X=0;X<e.state.overlays.length;++X)K(X);return{styles:n,classes:S.bgClass||S.textClass?S:null}}function Re(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Ke(e,kt(t)),n=t.text.length>e.options.maxHighlightLength&&Br(e.doc.mode,r.state),S=he(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=S.styles,S.classes?t.styleClasses=S.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 Ke(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new F(r,!0,t);var S=vr(e,t,i),B=S>r.first&&ut(r,S-1).stateAfter,K=B?F.fromSaved(r,B,S):new F(r,qr(r.mode),S);return r.iter(S,t,function(X){ht(e,X.text,K);var J=K.line;X.stateAfter=J==t-1||J%5==0||J>=n.viewFrom&&J<n.viewTo?K.save():null,K.nextLine()}),i&&(r.modeFrontier=K.line),K}function ht(e,t,i,r){var n=e.doc.mode,S=new It(t,e.options.tabSize,i);for(S.start=S.pos=r||0,t==""&&Pe(n,i.state);!S.eol();)vt(n,S,i.state),S.start=S.pos}function Pe(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=ci(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function vt(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=ci(e,i).mode);var S=e.token(t,i);if(t.pos>t.start)return S}throw new Error("Mode "+e.name+" failed to advance stream.")}var Nt=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Kt(e,t,i,r){var n=e.doc,S=n.mode,B;t=s(n,t);var K=ut(n,t.line),X=Ke(e,t.line,i),J=new It(K.text,e.options.tabSize,X),ae;for(r&&(ae=[]);(r||J.pos<t.ch)&&!J.eol();)J.start=J.pos,B=vt(S,J,X.state),r&&ae.push(new Nt(J,B,Br(n.mode,X.state)));return r?ae:new Nt(J,B,X.state)}function Or(e,t){if(e)for(;;){var i=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i)break;e=e.slice(0,i.index)+e.slice(i.index+i[0].length);var r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+i[2])}return e}function gr(e,t,i,r,n,S,B){var K=i.flattenSpans;K==null&&(K=e.options.flattenSpans);var X=0,J=null,ae=new It(t,e.options.tabSize,r),le,be=e.options.addModeClass&&[null];for(t==""&&Or(Pe(i,r.state),S);!ae.eol();){if(ae.pos>e.options.maxHighlightLength?(K=!1,B&&ht(e,t,r,ae.pos),ae.pos=t.length,le=null):le=Or(vt(i,ae,r.state,be),S),be){var ye=be[0].name;ye&&(le="m-"+(le?ye+" "+le:ye))}if(!K||J!=le){for(;X<ae.start;)X=Math.min(ae.start,X+5e3),n(X,J);J=le}ae.start=ae.pos}for(;X<ae.pos;){var Le=Math.min(ae.pos,X+5e3);n(Le,J),X=Le}}function vr(e,t,i){for(var r,n,S=e.doc,B=i?-1:t-(e.doc.mode.innerMode?1e3:100),K=t;K>B;--K){if(K<=S.first)return S.first;var X=ut(S,K-1),J=X.stateAfter;if(J&&(!i||K+(J instanceof $?J.lookAhead:0)<=S.modeFrontier))return K;var ae=q(X.text,null,e.options.tabSize);(n==null||r>ae)&&(n=K-1,r=ae)}return n}function Xr(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var i=e.first,r=t-1;r>i;r--){var n=ut(e,r).stateAfter;if(n&&(!(n instanceof $)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Oi=!1,nr=!1;function Ur(){Oi=!0}function oi(){nr=!0}function si(e,t,i){this.marker=e,this.from=t,this.to=i}function _r(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function _i(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function yi(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function zi(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var S=e[n],B=S.marker,K=S.from==null||(B.inclusiveLeft?S.from<=t:S.from<t);if(K||S.from==t&&B.type=="bookmark"&&(!i||!S.marker.insertLeft)){var X=S.to==null||(B.inclusiveRight?S.to>=t:S.to>t);(r||(r=[])).push(new si(B,S.from,X?null:S.to))}}return r}function Ki(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var S=e[n],B=S.marker,K=S.to==null||(B.inclusiveRight?S.to>=t:S.to>t);if(K||S.from==t&&B.type=="bookmark"&&(!i||S.marker.insertLeft)){var X=S.from==null||(B.inclusiveLeft?S.from<=t:S.from<t);(r||(r=[])).push(new si(B,X?null:S.from-t,S.to==null?null:S.to-t))}}return r}function Yr(e,t){if(t.full)return null;var i=Vr(e,t.from.line)&&ut(e,t.from.line).markedSpans,r=Vr(e,t.to.line)&&ut(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,S=t.to.ch,B=Et(t.from,t.to)==0,K=zi(i,n,B),X=Ki(r,S,B),J=t.text.length==1,ae=De(t.text).length+(J?n:0);if(K)for(var le=0;le<K.length;++le){var be=K[le];if(be.to==null){var ye=_r(X,be.marker);ye?J&&(be.to=ye.to==null?null:ye.to+ae):be.to=n}}if(X)for(var Le=0;Le<X.length;++Le){var Ne=X[Le];if(Ne.to!=null&&(Ne.to+=ae),Ne.from==null){var We=_r(K,Ne.marker);We||(Ne.from=ae,J&&(K||(K=[])).push(Ne))}else Ne.from+=ae,J&&(K||(K=[])).push(Ne)}K&&(K=Gr(K)),X&&X!=K&&(X=Gr(X));var Xe=[K];if(!J){var at=t.text.length-2,Ye;if(at>0&&K)for(var ot=0;ot<K.length;++ot)K[ot].to==null&&(Ye||(Ye=[])).push(new si(K[ot].marker,null,null));for(var xt=0;xt<at;++xt)Xe.push(Ye);Xe.push(X)}return Xe}function Gr(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 bi(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(ye){if(ye.markedSpans)for(var Le=0;Le<ye.markedSpans.length;++Le){var Ne=ye.markedSpans[Le].marker;Ne.readOnly&&(!r||ce(r,Ne)==-1)&&(r||(r=[])).push(Ne)}}),!r)return null;for(var n=[{from:t,to:i}],S=0;S<r.length;++S)for(var B=r[S],K=B.find(0),X=0;X<n.length;++X){var J=n[X];if(Et(J.to,K.from)<0||Et(J.from,K.to)>0)continue;var ae=[X,1],le=Et(J.from,K.from),be=Et(J.to,K.to);(le<0||!B.inclusiveLeft&&!le)&&ae.push({from:J.from,to:K.from}),(be>0||!B.inclusiveRight&&!be)&&ae.push({from:K.to,to:J.to}),n.splice.apply(n,ae),X+=ae.length-3}return n}function dn(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 xi(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function Jt(e){return e.inclusiveLeft?-1:0}function Bt(e){return e.inclusiveRight?1:0}function dr(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),S=Et(r.from,n.from)||Jt(e)-Jt(t);if(S)return-S;var B=Et(r.to,n.to)||Bt(e)-Bt(t);return B||t.id-e.id}function Dt(e,t){var i=nr&&e.markedSpans,r;if(i)for(var n=void 0,S=0;S<i.length;++S)n=i[S],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||dr(r,n.marker)<0)&&(r=n.marker);return r}function qt(e){return Dt(e,!0)}function Wt(e){return Dt(e,!1)}function ti(e,t){var i=nr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var S=i[n];S.marker.collapsed&&(S.from==null||S.from<t)&&(S.to==null||S.to>t)&&(!r||dr(r,S.marker)<0)&&(r=S.marker)}return r}function ar(e,t,i,r,n){var S=ut(e,t),B=nr&&S.markedSpans;if(B)for(var K=0;K<B.length;++K){var X=B[K];if(!X.marker.collapsed)continue;var J=X.marker.find(0),ae=Et(J.from,i)||Jt(X.marker)-Jt(n),le=Et(J.to,r)||Bt(X.marker)-Bt(n);if(ae>=0&&le<=0||ae<=0&&le>=0)continue;if(ae<=0&&(X.marker.inclusiveRight&&n.inclusiveLeft?Et(J.to,i)>=0:Et(J.to,i)>0)||ae>=0&&(X.marker.inclusiveRight&&n.inclusiveLeft?Et(J.from,r)<=0:Et(J.from,r)<0))return!0}}function Er(e){for(var t;t=qt(e);)e=t.find(-1,!0).line;return e}function Vi(e){for(var t;t=Wt(e);)e=t.find(1,!0).line;return e}function Ei(e){for(var t,i;t=Wt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function cn(e,t){var i=ut(e,t),r=Er(i);return i==r?t:kt(r)}function Si(e,t){if(t>e.lastLine())return t;var i=ut(e,t),r;if(!ri(e,i))return t;for(;r=Wt(i);)i=r.find(1,!0).line;return kt(i)+1}function ri(e,t){var i=nr&&t.markedSpans;if(i)for(var r=void 0,n=0;n<i.length;++n){if(r=i[n],!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&fn(e,t,r))return!0}}function fn(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return fn(e,r.line,_r(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,S=0;S<t.markedSpans.length;++S)if(n=t.markedSpans[S],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&fn(e,t,n))return!0}function $r(e){e=Er(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 S=i.parent;S;i=S,S=i.parent)for(var B=0;B<S.children.length;++B){var K=S.children[B];if(K==i)break;t+=K.height}return t}function pn(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=qt(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Wt(r);){var S=i.find(0,!0);t-=r.text.length-S.from.ch,r=S.to.line,t+=r.text.length-S.to.ch}return t}function jn(e){var t=e.display,i=e.doc;t.maxLine=ut(i,i.first),t.maxLineLength=pn(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=pn(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Mi=function(e,t,i){this.text=e,xi(this,t),this.height=i?i(this):1};Mi.prototype.lineNo=function(){return kt(this)},fe(Mi);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),dn(e),xi(e,i);var n=r?r(e):1;n!=e.height&&mr(e,n)}function ft(e){e.parent=null,dn(e)}var Tt={},yt={};function Lt(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?yt:Tt;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Pt(e,t){var i=x("span",null,null,P?"padding-right: .1px":null),r={pre:x("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 S=n?t.rest[n-1]:t.line,B=void 0;r.pos=0,r.addToken=Mt,Ct(e.display.measure)&&(B=it(S,e.doc.direction))&&(r.addToken=Cr(r.addToken,B)),r.map=[];var K=t!=e.display.externalMeasured&&kt(S);li(S,r,Re(e,S,K)),S.styleClasses&&(S.styleClasses.bgClass&&(r.bgClass=V(S.styleClasses.bgClass,r.bgClass||"")),S.styleClasses.textClass&&(r.textClass=V(S.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(mt(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(P){var X=r.content.lastChild;(/\bcm-tab\b/.test(X.className)||X.querySelector&&X.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Ae(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=V(r.pre.className,r.textClass||"")),r}function Gt(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 Mt(e,t,i,r,n,S,B){if(!t)return;var K=e.splitSpaces?rr(t,e.trailingSpace):t,X=e.cm.state.specialChars,J=!1,ae;if(!X.test(t))e.col+=t.length,ae=document.createTextNode(K),e.map.push(e.pos,e.pos+t.length,ae),H&&U<9&&(J=!0),e.pos+=t.length;else{ae=document.createDocumentFragment();for(var le=0;;){X.lastIndex=le;var be=X.exec(t),ye=be?be.index-le:t.length-le;if(ye){var Le=document.createTextNode(K.slice(le,le+ye));H&&U<9?ae.appendChild(a("span",[Le])):ae.appendChild(Le),e.map.push(e.pos,e.pos+ye,Le),e.col+=ye,e.pos+=ye}if(!be)break;le+=ye+1;var Ne=void 0;if(be[0]==" "){var We=e.cm.options.tabSize,Xe=We-e.col%We;Ne=ae.appendChild(a("span",oe(Xe),"cm-tab")),Ne.setAttribute("role","presentation"),Ne.setAttribute("cm-text"," "),e.col+=Xe}else be[0]=="\r"||be[0]==`
`?(Ne=ae.appendChild(a("span",be[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Ne.setAttribute("cm-text",be[0]),e.col+=1):(Ne=e.cm.options.specialCharPlaceholder(be[0]),Ne.setAttribute("cm-text",be[0]),H&&U<9?ae.appendChild(a("span",[Ne])):ae.appendChild(Ne),e.col+=1);e.map.push(e.pos,e.pos+1,Ne),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,i||r||n||J||S||B){var at=i||"";r&&(at+=r),n&&(at+=n);var Ye=a("span",[ae],at,S);if(B)for(var ot in B)B.hasOwnProperty(ot)&&ot!="style"&&ot!="class"&&Ye.setAttribute(ot,B[ot]);return e.content.appendChild(Ye)}e.content.appendChild(ae)}function rr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var S=e.charAt(n);S==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(S="\xA0"),r+=S,i=S==" "}return r}function Cr(e,t){return function(i,r,n,S,B,K,X){n=n?n+" cm-force-border":"cm-force-border";for(var J=i.pos,ae=J+r.length;;){for(var le=void 0,be=0;be<t.length&&!(le=t[be],le.to>J&&le.from<=J);be++);if(le.to>=ae)return e(i,r,n,S,B,K,X);e(i,r.slice(0,le.to-J),n,S,null,K,X),S=null,r=r.slice(le.to-J),J=le.to}}}function Rt(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 li(e,t,i){var r=e.markedSpans,n=e.text,S=0;if(!r){for(var B=1;B<i.length;B+=2)t.addToken(t,n.slice(S,S=i[B]),Lt(i[B+1],t.cm.options));return}for(var K=n.length,X=0,J=1,ae="",le,be,ye=0,Le,Ne,We,Xe,at;;){if(ye==X){Le=Ne=We=be="",at=null,Xe=null,ye=Infinity;for(var Ye=[],ot=void 0,xt=0;xt<r.length;++xt){var gt=r[xt],At=gt.marker;if(At.type=="bookmark"&&gt.from==X&&At.widgetNode)Ye.push(At);else if(gt.from<=X&&(gt.to==null||gt.to>X||At.collapsed&&gt.to==X&&gt.from==X)){if(gt.to!=null&&gt.to!=X&&ye>gt.to&&(ye=gt.to,Ne=""),At.className&&(Le+=" "+At.className),At.css&&(be=(be?be+";":"")+At.css),At.startStyle&&gt.from==X&&(We+=" "+At.startStyle),At.endStyle&&gt.to==ye&&(ot||(ot=[])).push(At.endStyle,gt.to),At.title&&((at||(at={})).title=At.title),At.attributes)for(var zt in At.attributes)(at||(at={}))[zt]=At.attributes[zt];At.collapsed&&(!Xe||dr(Xe.marker,At)<0)&&(Xe=gt)}else gt.from>X&&ye>gt.from&&(ye=gt.from)}if(ot)for(var lr=0;lr<ot.length;lr+=2)ot[lr+1]==ye&&(Ne+=" "+ot[lr]);if(!Xe||Xe.from==X)for(var Yt=0;Yt<Ye.length;++Yt)Rt(t,0,Ye[Yt]);if(Xe&&(Xe.from||0)==X){if(Rt(t,(Xe.to==null?K+1:Xe.to)-X,Xe.marker,Xe.from==null),Xe.to==null)return;Xe.to==X&&(Xe=!1)}}if(X>=K)break;for(var Pr=Math.min(K,ye);;){if(ae){var kr=X+ae.length;if(!Xe){var er=kr>Pr?ae.slice(0,Pr-X):ae;t.addToken(t,er,le?le+Le:Le,We,X+er.length==ye?Ne:"",be,at)}if(kr>=Pr){ae=ae.slice(Pr-X),X=Pr;break}X=kr,We=""}ae=n.slice(S,S=i[J++]),le=Lt(i[J++],t.cm.options)}}}function Ut(e,t,i){this.line=t,this.rest=Ei(t),this.size=this.rest?kt(De(this.rest))-i+1:1,this.node=this.text=null,this.hidden=ri(e,t)}function wr(e,t,i){for(var r=[],n,S=t;S<i;S=n){var B=new Ut(e.doc,ut(e.doc,S),S);n=S+B.size,r.push(B)}return r}var yr=null;function zr(e){yr?yr.ops.push(e):e.ownsGroup=yr={ops:[e],delayedCallbacks:[]}}function Rs(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 Os(e,t){var i=e.ownsGroup;if(!i)return;try{Rs(i)}finally{yr=null,t(i)}}var mn=null;function cr(e,t){var i=lt(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;yr?n=yr.delayedCallbacks:mn?n=mn:(n=mn=[],setTimeout(_s,0));for(var S=function(K){n.push(function(){return i[K].apply(null,r)})},B=0;B<i.length;++B)S(B)}function _s(){var e=mn;mn=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 S=t.changes[n];S=="text"?Ps(e,t):S=="gutter"?Za(e,t,i,r):S=="class"?ha(e,t):S=="widget"&&Is(e,t,r)}t.changes=null}function gn(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),H&&U<8&&(e.node.style.zIndex=2)),e.node}function Ms(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=gn(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):Pt(e,t)}function Ps(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,ha(e,t)):i&&(t.text.className=i)}function ha(e,t){Ms(e,t),t.line.wrapClass?gn(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=gn(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 S=t.line.gutterMarkers;if(e.options.lineNumbers||S){var B=gn(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),B.insertBefore(K,t.text),t.line.gutterClass&&(K.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!S||!S["CodeMirror-linenumbers"])&&(t.lineNumber=K.appendChild(a("div",fi(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),S)for(var X=0;X<e.display.gutterSpecs.length;++X){var J=e.display.gutterSpecs[X].className,ae=S.hasOwnProperty(J)&&S[J];ae&&K.appendChild(a("div",[ae],"CodeMirror-gutter-elt","left: "+r.gutterLeft[J]+"px; width: "+r.gutterWidth[J]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=E("CodeMirror-linewidget"),n=t.node.firstChild,S=void 0;n;n=S)S=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),ha(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 S=gn(i),B=0,K=t.widgets;B<K.length;++B){var X=K[B],J=a("div",[X.node],"CodeMirror-linewidget"+(X.className?" "+X.className:""));X.handleMouseEvents||J.setAttribute("cm-ignore-events","true"),Bs(X,J,i,r),e.display.input.setUneditable(J),n&&X.above?S.insertBefore(J,i.gutter||i.text):S.appendChild(J),cr(X,"redraw")}}function Bs(e,t,i,r){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);var n=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(n-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=n+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function vn(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!T(document.body,e.node)){var i="position: relative;";e.coverGutter&&(i+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(i+="width: "+t.display.wrapper.clientWidth+"px;"),d(t.display.measure,a("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function ui(e,t){for(var i=me(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function Wn(e){return e.lineSpace.offsetTop}function da(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function qa(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=d(e.measure,a("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function ii(e){return ve-e.display.nativeBarWidth}function Pi(e){return e.display.scroller.clientWidth-ii(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-ii(e)-e.display.barHeight}function Fs(e,t,i){var r=e.options.lineWrapping,n=r&&Pi(e);if(!t.measure.heights||r&&t.measure.width!=n){var S=t.measure.heights=[];if(r){t.measure.width=n;for(var B=t.text.firstChild.getClientRects(),K=0;K<B.length-1;K++){var X=B[K],J=B[K+1];Math.abs(X.bottom-J.bottom)>2&&S.push((X.bottom+J.top)/2-i.top)}}S.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(kt(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Us(e,t){t=Er(t);var i=kt(t),r=e.display.externalMeasured=new Ut(e.doc,t,i);r.lineN=i;var n=r.built=Pt(e,r);return r.text=n.pre,d(e.display.lineMeasure,n.pre),r}function to(e,t,i,r){return ni(e,Xi(e,t),i,r)}function fa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Bi(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function Xi(e,t){var i=kt(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=Us(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 ni(e,t,i,r,n){t.before&&(i=-1);var S=i+(r||""),B;return t.cache.hasOwnProperty(S)?B=t.cache[S]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Fs(e,t.view,t.rect),t.hasHeights=!0),B=Ws(e,t,i,r),B.bogus||(t.cache[S]=B)),{left:B.left,right:B.right,top:n?B.rtop:B.top,bottom:n?B.rbottom:B.bottom}}var ro={left:0,right:0,top:0,bottom:0};function io(e,t,i){for(var r,n,S,B,K,X,J=0;J<e.length;J+=3)if(K=e[J],X=e[J+1],t<K?(n=0,S=1,B="left"):t<X?(n=t-K,S=n+1):(J==e.length-3||t==X&&e[J+3]>t)&&(S=X-K,n=S-1,t>=X&&(B="right")),n!=null){if(r=e[J+2],K==X&&i==(r.insertLeft?"left":"right")&&(B=i),i=="left"&&n==0)for(;J&&e[J-2]==e[J-3]&&e[J-1].insertLeft;)r=e[(J-=3)+2],B="left";if(i=="right"&&n==X-K)for(;J<e.length-3&&e[J+3]==e[J+4]&&!e[J+5].insertLeft;)r=e[(J+=3)+2],B="right";break}return{node:r,start:n,end:S,collapse:B,coverStart:K,coverEnd:X}}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),S=n.node,B=n.start,K=n.end,X=n.collapse,J;if(S.nodeType==3){for(var ae=0;ae<4;ae++){for(;B&&_e(t.line.text.charAt(n.coverStart+B));)--B;for(;n.coverStart+K<n.coverEnd&&_e(t.line.text.charAt(n.coverStart+K));)++K;if(H&&U<9&&B==0&&K==n.coverEnd-n.coverStart?J=S.parentNode.getBoundingClientRect():J=js(v(S,B,K).getClientRects(),r),J.left||J.right||B==0)break;K=B,B=B-1,X="right"}H&&U<11&&(J=Hs(e.display.measure,J))}else{B>0&&(X=r="right");var le;e.options.lineWrapping&&(le=S.getClientRects()).length>1?J=le[r=="right"?le.length-1:0]:J=S.getBoundingClientRect()}if(H&&U<9&&!B&&(!J||!J.left&&!J.right)){var be=S.parentNode.getClientRects()[0];be?J={left:be.left,right:be.left+$i(e.display),top:be.top,bottom:be.bottom}:J=ro}for(var ye=J.top-t.rect.top,Le=J.bottom-t.rect.top,Ne=(ye+Le)/2,We=t.view.measure.heights,Xe=0;Xe<We.length-1&&!(Ne<We[Xe]);Xe++);var at=Xe?We[Xe-1]:0,Ye=We[Xe],ot={left:(X=="right"?J.right:J.left)-t.rect.left,right:(X=="left"?J.left:J.right)-t.rect.left,top:at,bottom:Ye};return!J.left&&!J.right&&(ot.bogus=!0),e.options.singleCursorHeightPerLine||(ot.rtop=ye,ot.rbottom=Le),ot}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Zt(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,m(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)no(e.display.view[t])}function yn(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 y&&u?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return y&&u?-(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+=vn(e.widgets[i]));return t}function Hn(e,t,i,r,n){if(!n){var S=pa(t);i.top+=S,i.bottom+=S}if(r=="line")return i;r||(r="local");var B=$r(t);if(r=="local"?B+=Wn(e.display):B-=e.display.viewOffset,r=="page"||r=="window"){var K=e.display.lineSpace.getBoundingClientRect();B+=K.top+(r=="window"?0:so());var X=K.left+(r=="window"?0:oo());i.left+=X,i.right+=X}return i.top+=B,i.bottom+=B,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 S=e.display.sizer.getBoundingClientRect();r+=S.left,n+=S.top}var B=e.display.lineSpace.getBoundingClientRect();return{left:r-B.left,top:n-B.top}}function ma(e,t,i,r,n){return r||(r=ut(e.doc,t.line)),Hn(e,r,to(e,r,t.ch,n),i)}function Zr(e,t,i,r,n,S){r=r||ut(e.doc,t.line),n||(n=Xi(e,r));function B(Le,Ne){var We=ni(e,n,Le,Ne?"right":"left",S);return Ne?We.left=We.right:We.right=We.left,Hn(e,r,We,i)}var K=it(r,e.doc.direction),X=t.ch,J=t.sticky;if(X>=r.text.length?(X=r.text.length,J="before"):X<=0&&(X=0,J="after"),!K)return B(J=="before"?X-1:X,J=="before");function ae(Le,Ne,We){var Xe=K[Ne],at=Xe.level==1;return B(We?Le-1:Le,at!=We)}var le=Ze(K,X,J),be=Qe,ye=ae(X,le,J=="before");return be!=null&&(ye.other=ae(X,be,J!="before")),ye}function uo(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=$i(e.display)*t.ch);var r=ut(e.doc,t.line),n=$r(r)+Wn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ga(e,t,i,r,n){var S=Ue(e,t,i);return S.xRel=n,r&&(S.outside=r),S}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=Fr(r,i),S=r.first+r.size-1;if(n>S)return ga(r.first+r.size-1,ut(r,S).text.length,null,1,1);t<0&&(t=0);for(var B=ut(r,n);;){var K=Gs(e,B,n,t,i),X=ti(B,K.ch+(K.xRel>0||K.outside>0?1:0));if(!X)return K;var J=X.find(1);if(J.line==n)return J;B=ut(r,n=J.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,S=$e(function(B){return ni(e,i,B-1).bottom<=r},n,0);return n=$e(function(B){return ni(e,i,B).top>r},S,n),{begin:S,end:n}}function co(e,t,i,r){i||(i=Xi(e,t));var n=Hn(e,t,ni(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-=$r(t);var S=Xi(e,t),B=pa(t),K=0,X=t.text.length,J=!0,ae=it(t,e.doc.direction);if(ae){var le=(e.options.lineWrapping?Ks:zs)(e,t,i,S,ae,r,n);J=le.level!=1,K=J?le.from:le.to-1,X=J?le.to:le.from-1}var be=null,ye=null,Le=$e(function(xt){var gt=ni(e,S,xt);return gt.top+=B,gt.bottom+=B,ya(gt,r,n,!1)?(gt.top<=n&&gt.left<=r&&(be=xt,ye=gt),!0):!1},K,X),Ne,We,Xe=!1;if(ye){var at=r-ye.left<ye.right-r,Ye=at==J;Le=be+(Ye?0:1),We=Ye?"after":"before",Ne=at?ye.left:ye.right}else{!J&&(Le==X||Le==K)&&Le++,We=Le==0?"after":Le==t.text.length?"before":ni(e,S,Le-(J?1:0)).bottom+B<=n==J?"after":"before";var ot=Zr(e,Ue(i,Le,We),"line",t,S);Ne=ot.left,Xe=n<ot.top?-1:n>=ot.bottom?1:0}return Le=Be(t.text,Le,1),ga(i,Le,We,Xe,r-Ne)}function zs(e,t,i,r,n,S,B){var K=$e(function(le){var be=n[le],ye=be.level!=1;return ya(Zr(e,Ue(i,ye?be.to:be.from,ye?"before":"after"),"line",t,r),S,B,!0)},0,n.length-1),X=n[K];if(K>0){var J=X.level!=1,ae=Zr(e,Ue(i,J?X.from:X.to,J?"after":"before"),"line",t,r);ya(ae,S,B,!0)&&ae.top>B&&(X=n[K-1])}return X}function Ks(e,t,i,r,n,S,B){var K=ho(e,t,r,B),X=K.begin,J=K.end;/\s/.test(t.text.charAt(J-1))&&J--;for(var ae=null,le=null,be=0;be<n.length;be++){var ye=n[be];if(ye.from>=J||ye.to<=X)continue;var Le=ye.level!=1,Ne=ni(e,r,Le?Math.min(J,ye.to)-1:Math.max(X,ye.from)).right,We=Ne<S?S-Ne+1e9:Ne-S;(!ae||le>We)&&(ae=ye,le=We)}return ae||(ae=n[n.length-1]),ae.from<X&&(ae={from:X,to:ae.to,level:ae.level}),ae.to>J&&(ae={from:ae.from,to:J,level:ae.level}),ae}var Ii;function Yi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Ii==null){Ii=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Ii.appendChild(document.createTextNode("x")),Ii.appendChild(a("br"));Ii.appendChild(document.createTextNode("x"))}d(e.measure,Ii);var i=Ii.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),m(e.measure),i||1}function $i(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),i=a("pre",[t],"CodeMirror-line-like");d(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function ba(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,S=t.gutters.firstChild,B=0;S;S=S.nextSibling,++B){var K=e.display.gutterSpecs[B].className;i[K]=S.offsetLeft+S.clientLeft+n,r[K]=S.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=Yi(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/$i(e.display)-3);return function(n){if(ri(e.doc,n))return 0;var S=0;if(n.widgets)for(var B=0;B<n.widgets.length;B++)n.widgets[B].height&&(S+=n.widgets[B].height);return i?S+(Math.ceil(n.text.length/r)||1)*t:S+t}}function Ea(e){var t=e.doc,i=fo(e);t.iter(function(r){var n=i(r);n!=r.height&&mr(r,n)})}function Ni(e,t,i,r){var n=e.display;if(!i&&me(t).getAttribute("cm-not-content")=="true")return null;var S,B,K=n.lineSpace.getBoundingClientRect();try{S=t.clientX-K.left,B=t.clientY-K.top}catch(le){return null}var X=va(e,S,B),J;if(r&&X.xRel>0&&(J=ut(e.doc,X.line).text).length==X.ch){var ae=q(J,J.length,e.options.tabSize)-J.length;X=Ue(X.line,Math.max(0,Math.round((S-qa(e.display).left)/$i(e.display))-ae))}return X}function Bi(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 Ar(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)nr&&cn(e.doc,t)<n.viewTo&&Ci(e);else if(i<=n.viewFrom)nr&&Si(e.doc,i+r)>n.viewFrom?Ci(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)Ci(e);else if(t<=n.viewFrom){var S=Gn(e,i,i+r,1);S?(n.view=n.view.slice(S.index),n.viewFrom=S.lineN,n.viewTo+=r):Ci(e)}else if(i>=n.viewTo){var B=Gn(e,t,t,-1);B?(n.view=n.view.slice(0,B.index),n.viewTo=B.lineN):Ci(e)}else{var K=Gn(e,t,t,-1),X=Gn(e,i,i+r,1);K&&X?(n.view=n.view.slice(0,K.index).concat(wr(e,K.lineN,X.lineN)).concat(n.view.slice(X.index)),n.viewTo+=r):Ci(e)}var J=n.externalMeasured;J&&(i<J.lineN?J.lineN+=r:t<J.lineN+J.size&&(n.externalMeasured=null))}function Ti(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 S=r.view[Bi(e,t)];if(S.node==null)return;var B=S.changes||(S.changes=[]);ce(B,i)==-1&&B.push(i)}function Ci(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Gn(e,t,i,r){var n=Bi(e,t),S,B=e.display.view;if(!nr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var K=e.display.viewFrom,X=0;X<n;X++)K+=B[X].size;if(K!=t){if(r>0){if(n==B.length-1)return null;S=K+B[n].size-t,n++}else S=K-t;t+=S,i+=S}for(;cn(e.doc,i)!=i;){if(n==(r<0?0:B.length-1))return null;i+=r*B[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=wr(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=wr(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Bi(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(wr(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,Bi(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 bn(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(),S=r.selection=document.createDocumentFragment(),B=0;B<i.sel.ranges.length;B++){if(!t&&B==i.sel.primIndex)continue;var K=i.sel.ranges[B];if(K.from().line>=e.display.viewTo||K.to().line<e.display.viewFrom)continue;var X=K.empty();(X||e.options.showCursorWhenSelecting)&&go(e,K.head,n),X||Xs(e,K,S)}return r}function go(e,t,i){var r=Zr(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 S=i.appendChild(a("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));S.style.display="",S.style.left=r.other.left+"px",S.style.top=r.other.top+"px",S.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function zn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,S=document.createDocumentFragment(),B=qa(e.display),K=B.left,X=Math.max(r.sizerWidth,Pi(e)-r.sizer.offsetLeft)-B.right,J=n.direction=="ltr";function ae(Ye,ot,xt,gt){ot<0&&(ot=0),ot=Math.round(ot),gt=Math.round(gt),S.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+Ye+`px;
top: `+ot+"px; width: "+(xt==null?X-Ye:xt)+`px;
height: `+(gt-ot)+"px"))}function le(Ye,ot,xt){var gt=ut(n,Ye),At=gt.text.length,zt,lr;function Yt(er,Dr){return ma(e,Ue(Ye,er),"div",gt,Dr)}function Pr(er,Dr,fr){var ir=co(e,gt,null,er),tr=Dr=="ltr"==(fr=="after")?"left":"right",$t=fr=="after"?ir.begin:ir.end-(/\s/.test(gt.text.charAt(ir.end-1))?2:1);return Yt($t,tr)[tr]}var kr=it(gt,n.direction);return qe(kr,ot||0,xt==null?At:xt,function(er,Dr,fr,ir){var tr=fr=="ltr",$t=Yt(er,tr?"left":"right"),Rr=Yt(Dr-1,tr?"right":"left"),un=ot==null&&er==0,Ri=xt==null&&Dr==At,xr=ir==0,ai=!kr||ir==kr.length-1;if(Rr.top-$t.top<=3){var ur=(J?un:Ri)&&xr,Va=(J?Ri:un)&&ai,di=ur?K:(tr?$t:Rr).left,Hi=Va?X:(tr?Rr:$t).right;ae(di,$t.top,Hi-di,$t.bottom)}else{var Gi,Tr,hn,Xa;tr?(Gi=J&&un&&xr?K:$t.left,Tr=J?X:Pr(er,fr,"before"),hn=J?K:Pr(Dr,fr,"after"),Xa=J&&Ri&&ai?X:Rr.right):(Gi=J?Pr(er,fr,"before"):K,Tr=!J&&un&&xr?X:$t.right,hn=!J&&Ri&&ai?K:Rr.left,Xa=J?Pr(Dr,fr,"after"):X),ae(Gi,$t.top,Tr-Gi,$t.bottom),$t.bottom<Rr.top&&ae(K,$t.bottom,null,Rr.top),ae(hn,Rr.top,Xa-hn,Rr.bottom)}(!zt||zn($t,zt)<0)&&(zt=$t),zn(Rr,zt)<0&&(zt=Rr),(!lr||zn($t,lr)<0)&&(lr=$t),zn(Rr,lr)<0&&(lr=Rr)}),{start:zt,end:lr}}var be=t.from(),ye=t.to();if(be.line==ye.line)le(be.line,be.ch,ye.ch);else{var Le=ut(n,be.line),Ne=ut(n,ye.line),We=Er(Le)==Er(Ne),Xe=le(be.line,be.ch,We?Le.text.length+1:null).end,at=le(ye.line,We?0:null,ye.ch).start;We&&(Xe.top<at.top-2?(ae(Xe.right,Xe.top,null,Xe.bottom),ae(K,at.top,at.left,at.bottom)):ae(Xe.right,Xe.top,at.left-Xe.right,Xe.bottom)),Xe.bottom<at.top&&ae(K,Xe.bottom,null,at.top)}i.appendChild(S)}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()||Zi(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,Zi(e))},100)}function Ta(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(Ae(e,"focus",e,t),e.state.focused=!0,G(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),P&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Sa(e)}function Zi(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Ae(e,"blur",e,t),e.state.focused=!1,f(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Kn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],S=e.options.lineWrapping,B=void 0,K=0;if(n.hidden)continue;if(H&&U<8){var X=n.node.offsetTop+n.node.offsetHeight;B=X-i,i=X}else{var J=n.node.getBoundingClientRect();B=J.bottom-J.top,!S&&n.text.firstChild&&(K=n.text.firstChild.getBoundingClientRect().right-J.left-1)}var ae=n.line.height-B;if((ae>.005||ae<-.005)&&(mr(n.line,B),bo(n.line),n.rest))for(var le=0;le<n.rest.length;le++)bo(n.rest[le]);if(K>e.display.sizerWidth){var be=Math.ceil(K/$i(e.display));be>e.display.maxLineLength&&(e.display.maxLineLength=be,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 Vn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Wn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,S=Fr(t,r),B=Fr(t,n);if(i&&i.ensure){var K=i.ensure.from.line,X=i.ensure.to.line;K<S?(S=K,B=Fr(t,$r(ut(t,K))+e.wrapper.clientHeight)):Math.min(X,t.lastLine())>=B&&(S=Fr(t,$r(ut(t,X))-e.wrapper.clientHeight),B=X)}return{from:S,to:Math.max(B,S+1)}}function Ys(e,t){if(Fe(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&&!w){var S=a("div","\u200B",null,`position: absolute;
top: `+(t.top-i.viewOffset-Wn(e.display))+`px;
height: `+(t.bottom-t.top+ii(e)+i.barHeight)+`px;
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(S),S.scrollIntoView(n),e.display.lineSpace.removeChild(S)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?Ue(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?Ue(t.line,t.ch+1,"before"):t);for(var S=0;S<5;S++){var B=!1,K=Zr(e,t),X=!i||i==t?K:Zr(e,i);n={left:Math.min(K.left,X.left),top:Math.min(K.top,X.top)-r,right:Math.max(K.left,X.left),bottom:Math.max(K.bottom,X.bottom)+r};var J=Ca(e,n),ae=e.doc.scrollTop,le=e.doc.scrollLeft;if(J.scrollTop!=null&&(En(e,J.scrollTop),Math.abs(e.doc.scrollTop-ae)>1&&(B=!0)),J.scrollLeft!=null&&(Fi(e,J.scrollLeft),Math.abs(e.doc.scrollLeft-le)>1&&(B=!0)),!B)break}return n}function Zs(e,t){var i=Ca(e,t);i.scrollTop!=null&&En(e,i.scrollTop),i.scrollLeft!=null&&Fi(e,i.scrollLeft)}function Ca(e,t){var i=e.display,r=Yi(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,S=ca(e),B={};t.bottom-t.top>S&&(t.bottom=t.top+S);var K=e.doc.height+da(i),X=t.top<r,J=t.bottom>K-r;if(t.top<n)B.scrollTop=X?0:t.top;else if(t.bottom>n+S){var ae=Math.min(t.top,(J?K:t.bottom)-S);ae!=n&&(B.scrollTop=ae)}var le=e.options.fixedGutter?0:i.gutters.offsetWidth,be=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-le,ye=Pi(e)-i.gutters.offsetWidth,Le=t.right-t.left>ye;return Le&&(t.right=t.left+ye),t.left<10?B.scrollLeft=0:t.left<be?B.scrollLeft=Math.max(0,t.left+le-(Le?0:10)):t.right>ye+be-3&&(B.scrollLeft=t.right+(Le?0:10)-ye),B}function wa(e,t){if(t==null)return;Xn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Ji(e){Xn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function xn(e,t,i){(t!=null||i!=null)&&Xn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Xn(e),e.curOp.scrollToPos=t}function Xn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=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});xn(e,n.scrollLeft,n.scrollTop)}function En(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;D||La(e,{top:t}),Eo(e,t,!0),D&&La(e),Cn(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,Ao(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function Sn(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+da(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+ii(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var Ui=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,H&&U<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Ui.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 S=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+S)+"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}},Ui.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ui.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ui.prototype.zeroWidthHack=function(){var e=l&&!L?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new ie,this.disableVert=new ie},Ui.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),S=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);S!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},Ui.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Tn=function(){};Tn.prototype.update=function(){return{bottom:0,right:0}},Tn.prototype.setScrollLeft=function(){},Tn.prototype.setScrollTop=function(){},Tn.prototype.clear=function(){};function Qi(e,t){t||(t=Sn(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&&Kn(e),So(e,Sn(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:Ui,null:Tn};function Co(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&f(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):En(e,t)},e),e.display.scrollbars.addClass&&G(e.display.wrapper,e.display.scrollbars.addClass)}var Qs=0;function ji(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},zr(e.curOp)}function Wi(e){var t=e.curOp;t&&Os(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 S=0;S<t.length;S++)il(t[S]);for(var B=0;B<t.length;B++)nl(t[B])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&jn(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Yn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&Aa(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Kn(t),e.barMeasure=Sn(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+ii(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Pi(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==I();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Qi(t,e.barMeasure),e.updatedDisplay&&Da(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,s(r,e.scrollToPos.from),s(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var S=e.maybeHiddenMarkers,B=e.maybeUnhiddenMarkers;if(S)for(var K=0;K<S.length;++K)S[K].lines.length||Ae(S[K],"hide");if(B)for(var X=0;X<B.length;++X)B[X].lines.length&&Ae(B[X],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Ae(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Mr(e,t){if(e.curOp)return t();ji(e);try{return t()}finally{Wi(e)}}function or(e,t){return function(){if(e.curOp)return t.apply(e,arguments);ji(e);try{return t.apply(e,arguments)}finally{Wi(e)}}}function Sr(e){return function(){if(this.curOp)return e.apply(this,arguments);ji(this);try{return e.apply(this,arguments)}finally{Wi(this)}}}function sr(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);ji(t);try{return e.apply(this,arguments)}finally{Wi(t)}}}function Cn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,z(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=Ke(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(S){if(r.line>=e.display.viewFrom){var B=S.styles,K=S.text.length>e.options.maxHighlightLength?Br(t.mode,r.state):null,X=he(e,S,r,!0);K&&(r.state=K),S.styles=X.styles;var J=S.styleClasses,ae=X.classes;ae?S.styleClasses=ae:J&&(S.styleClasses=null);for(var le=!B||B.length!=S.styles.length||J!=ae&&(!J||!ae||J.bgClass!=ae.bgClass||J.textClass!=ae.textClass),be=0;!le&&be<B.length;++be)le=B[be]!=S.styles[be];le&&n.push(r.line),S.stateAfter=r.save(),r.nextLine()}else S.text.length<=e.options.maxHighlightLength&&ht(e,S.text,r),S.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return Cn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&Mr(e,function(){for(var S=0;S<n.length;S++)Ti(e,n[S],"text")})}var Yn=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Vn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Pi(e),this.force=i,this.dims=ba(e),this.events=[]};Yn.prototype.signal=function(e,t){de(e,t)&&this.events.push(arguments)},Yn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)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=ii(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=ii(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=I();if(!t||!T(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&T(e.display.lineDiv,r.anchorNode)&&(i.anchorNode=r.anchorNode,i.anchorOffset=r.anchorOffset,i.focusNode=r.focusNode,i.focusOffset=r.focusOffset)}return i}function ll(e){if(!e||!e.activeElt||e.activeElt==I())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&T(document.body,e.anchorNode)&&T(document.body,e.focusNode)){var t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset),i.collapse(!1),t.removeAllRanges(),t.addRange(i),t.extend(e.focusNode,e.focusOffset)}}function Aa(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return Ci(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&po(e)==0)return!1;Lo(e)&&(Ci(e),t.dims=ba(e));var n=r.first+r.size,S=Math.max(t.visible.from-e.options.viewportMargin,r.first),B=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<S&&S-i.viewFrom<20&&(S=Math.max(r.first,i.viewFrom)),i.viewTo>B&&i.viewTo-B<20&&(B=Math.min(n,i.viewTo)),nr&&(S=cn(e.doc,S),B=Si(e.doc,B));var K=S!=i.viewFrom||B!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,S,B),i.viewOffset=$r(ut(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var X=po(e);if(!K&&X==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var J=sl(e);return X>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),X>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(J),m(i.cursorDiv),m(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,K&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,Cn(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==Pi(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+da(e.display)-ca(e),i.top)}),t.visible=Vn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Vn(e.display,e.doc,i));if(!Aa(e,t))break;Kn(e);var n=Sn(e);bn(e),Qi(e,n),Da(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 La(e,t){var i=new Yn(e,t);if(Aa(e,i)){Kn(e),wo(e,i);var r=Sn(e);bn(e),Qi(e,r),Da(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,S=r.lineDiv,B=S.firstChild;function K(Le){var Ne=Le.nextSibling;return P&&l&&e.display.currentWheelTarget==Le?Le.style.display="none":Le.parentNode.removeChild(Le),Ne}for(var X=r.view,J=r.viewFrom,ae=0;ae<X.length;ae++){var le=X[ae];if(!le.hidden)if(!le.node||le.node.parentNode!=S){var be=Ns(e,le,J,i);S.insertBefore(be,B)}else{for(;B!=le.node;)B=K(B);var ye=n&&t!=null&&t<=J&&le.lineNumber;le.changes&&(ce(le.changes,"gutter")>-1&&(ye=!1),Ya(e,le,J,i)),ye&&(m(le.lineNumber),le.lineNumber.appendChild(document.createTextNode(fi(e.options,J)))),B=le.node.nextSibling}J+=le.size}for(;B;)B=K(B)}function ka(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Da(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+ii(e)+"px"}function Ao(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,S=r+"px",B=0;B<i.length;B++)if(!i[B].hidden){e.options.fixedGutter&&(i[B].gutter&&(i[B].gutter.style.left=S),i[B].gutterBackground&&(i[B].gutterBackground.style.left=S));var K=i[B].alignable;if(K)for(var X=0;X<K.length;X++)K[X].style.left=S}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Lo(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=fi(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")),S=n.firstChild.offsetWidth,B=n.offsetWidth-S;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(S,r.lineGutter.offsetWidth-B)+1,r.lineNumWidth=r.lineNumInnerWidth+B,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",ka(e.display),!0}return!1}function Ra(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var S=e[n],B=null;if(typeof S!="string"&&(B=S.style,S=S.className),S=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:S,style:B})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function ko(e){var t=e.gutters,i=e.gutterSpecs;m(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],S=n.className,B=n.style,K=t.appendChild(a("div",null,"CodeMirror-gutter "+S));B&&(K.style.cssText=B),S=="CodeMirror-linenumbers"&&(e.lineGutter=K,K.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",ka(e)}function wn(e){ko(e.display),Ar(e),Ao(e)}function hl(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=x("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=x("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var S=x("div",[n.lineSpace],"CodeMirror-lines");n.mover=a("div",[S],null,"position: relative"),n.sizer=a("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=a("div",null,null,"position: absolute; height: "+ve+"px; width: 1px;"),n.gutters=a("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=a("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=a("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),H&&U<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!P&&!(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=Ra(r.gutters,r.lineNumbers),ko(n),i.init(n)}var $n=0,jr=null;H?jr=-.53:D?jr=15:y?jr=-.7:R&&(jr=-1/3);function Do(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 dl(e){var t=Do(e);return t.x*=jr,t.y*=jr,t}function Ro(e,t){var i=Do(t),r=i.x,n=i.y,S=e.display,B=S.scroller,K=B.scrollWidth>B.clientWidth,X=B.scrollHeight>B.clientHeight;if(!(r&&K||n&&X))return;if(n&&l&&P){e:for(var J=t.target,ae=S.view;J!=B;J=J.parentNode)for(var le=0;le<ae.length;le++)if(ae[le].node==J){e.display.currentWheelTarget=J;break e}}if(r&&!D&&!A&&jr!=null){n&&X&&En(e,Math.max(0,B.scrollTop+n*jr)),Fi(e,Math.max(0,B.scrollLeft+r*jr)),(!n||n&&X)&&ee(t),S.wheelStartX=null;return}if(n&&jr!=null){var be=n*jr,ye=e.doc.scrollTop,Le=ye+S.wrapper.clientHeight;be<0?ye=Math.max(0,ye+be-50):Le=Math.min(e.doc.height,Le+be+50),La(e,{top:ye,bottom:Le})}$n<20&&(S.wheelStartX==null?(S.wheelStartX=B.scrollLeft,S.wheelStartY=B.scrollTop,S.wheelDX=r,S.wheelDY=n,setTimeout(function(){if(S.wheelStartX==null)return;var Ne=B.scrollLeft-S.wheelStartX,We=B.scrollTop-S.wheelStartY,Xe=We&&S.wheelDY&&We/S.wheelDY||Ne&&S.wheelDX&&Ne/S.wheelDX;if(S.wheelStartX=S.wheelStartY=null,!Xe)return;jr=(jr*$n+Xe)/($n+1),++$n},200)):(S.wheelDX+=r,S.wheelDY+=n))}var Wr=function(e,t){this.ranges=e,this.primIndex=t};Wr.prototype.primary=function(){return this.ranges[this.primIndex]},Wr.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(!pi(i.anchor,r.anchor)||!pi(i.head,r.head))return!1}return!0},Wr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new jt(mi(this.ranges[t].anchor),mi(this.ranges[t].head));return new Wr(e,this.primIndex)},Wr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Wr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(Et(t,r.from())>=0&&Et(e,r.to())<=0)return i}return-1};var jt=function(e,t){this.anchor=e,this.head=t};jt.prototype.from=function(){return vi(this.anchor,this.head)},jt.prototype.to=function(){return gi(this.anchor,this.head)},jt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Jr(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(be,ye){return Et(be.from(),ye.from())}),i=ce(t,n);for(var S=1;S<t.length;S++){var B=t[S],K=t[S-1],X=Et(K.to(),B.from());if(r&&!B.empty()?X>0:X>=0){var J=vi(K.from(),B.from()),ae=gi(K.to(),B.to()),le=K.empty()?B.from()==B.head:K.from()==K.head;S<=i&&--i,t.splice(--S,2,new jt(le?ae:J,le?J:ae))}}return new Wr(t,i)}function wi(e,t){return new Wr([new jt(e,t||e)],0)}function Ai(e){return e.text?Ue(e.from.line+e.text.length-1,De(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Oo(e,t){if(Et(e,t.from)<0)return e;if(Et(e,t.to)<=0)return Ai(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+=Ai(t).ch-t.to.ch),Ue(i,r)}function Oa(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new jt(Oo(n.anchor,t),Oo(n.head,t)))}return Jr(e.cm,i,e.sel.primIndex)}function _o(e,t,i){return e.line==t.line?Ue(i.line,e.ch-t.ch+i.ch):Ue(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=Ue(e.first,0),S=n,B=0;B<t.length;B++){var K=t[B],X=_o(K.from,n,S),J=_o(Ai(K),n,S);if(n=K.to,S=J,i=="around"){var ae=e.sel.ranges[B],le=Et(ae.head,ae.anchor)<0;r[B]=new jt(le?J:X,le?X:J)}else r[B]=new jt(X,X)}return new Wr(r,e.sel.primIndex)}function _a(e){e.doc.mode=Nr(e.options,e.doc.modeOption),An(e)}function An(e){e.doc.iter(function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,Cn(e,100),e.state.modeGen++,e.curOp&&Ar(e)}function Mo(e,t){return t.from.ch==0&&t.to.ch==0&&De(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Ma(e,t,i,r){function n(at){return i?i[at]:null}function S(at,Ye,ot){ua(at,Ye,ot,r),cr(at,"change",at,t)}function B(at,Ye){for(var ot=[],xt=at;xt<Ye;++xt)ot.push(new Mi(J[xt],n(xt),r));return ot}var K=t.from,X=t.to,J=t.text,ae=ut(e,K.line),le=ut(e,X.line),be=De(J),ye=n(J.length-1),Le=X.line-K.line;if(t.full)e.insert(0,B(0,J.length)),e.remove(J.length,e.size-J.length);else if(Mo(e,t)){var Ne=B(0,J.length-1);S(le,le.text,ye),Le&&e.remove(K.line,Le),Ne.length&&e.insert(K.line,Ne)}else if(ae==le)if(J.length==1)S(ae,ae.text.slice(0,K.ch)+be+ae.text.slice(X.ch),ye);else{var We=B(1,J.length-1);We.push(new Mi(be+ae.text.slice(X.ch),ye,r)),S(ae,ae.text.slice(0,K.ch)+J[0],n(0)),e.insert(K.line+1,We)}else if(J.length==1)S(ae,ae.text.slice(0,K.ch)+J[0]+le.text.slice(X.ch),n(0)),e.remove(K.line+1,Le);else{S(ae,ae.text.slice(0,K.ch)+J[0],n(0)),S(le,be+le.text.slice(X.ch),ye);var Xe=B(1,J.length-1);Le>1&&e.remove(K.line+1,Le-1),e.insert(K.line+1,Xe)}cr(e,"change",e,t)}function Li(e,t,i){function r(n,S,B){if(n.linked)for(var K=0;K<n.linked.length;++K){var X=n.linked[K];if(X.doc==S)continue;var J=B&&X.sharedHist;if(i&&!J)continue;t(X.doc,J),r(X.doc,n,J)}}r(e,null,!0)}function Po(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ea(e),_a(e),Io(e),e.options.lineWrapping||jn(e),e.options.mode=t.modeOption,Ar(e)}function Io(e){(e.doc.direction=="rtl"?G:f)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Mr(e,function(){Io(e),Ar(e)})}function Zn(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 Pa(e,t){var i={from:mi(t.from),to:Ai(t),text:Hr(e,t.from,t.to)};return Fo(e,i,t.from.line,t.to.line+1),Li(e,function(r){return Fo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=De(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),De(e.done);if(e.done.length&&!De(e.done).ranges)return De(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),De(e.done)}function Bo(e,t,i,r){var n=e.history;n.undone.length=0;var S=+new Date,B,K;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>S-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(B=pl(n,n.lastOp==r)))K=De(B.changes),Et(t.from,t.to)==0&&Et(t.from,K.to)==0?K.to=Ai(t):B.changes.push(Pa(e,t));else{var X=De(n.done);for((!X||!X.ranges)&&Jn(e.sel,n.done),B={changes:[Pa(e,t)],generation:n.generation},n.done.push(B);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=S,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,S=r&&r.origin;i==n.lastSelOp||S&&n.lastSelOrigin==S&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==S||ml(e,S,De(n.done),t))?n.done[n.done.length-1]=t:Jn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=S,n.lastSelOp=i,r&&r.clearRedo!==!1&&No(n.undone)}function Jn(e,t){var i=De(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Fo(e,t,i,r){var n=t["spans_"+e.id],S=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(B){B.markedSpans&&((n||(n=t["spans_"+e.id]={}))[S]=B.markedSpans),++S})}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 Uo(e,t){var i=yl(e,t),r=Yr(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var S=i[n],B=r[n];if(S&&B){e:for(var K=0;K<B.length;++K){for(var X=B[K],J=0;J<S.length;++J)if(S[J].marker==X.marker)continue e;S.push(X)}}else B&&(i[n]=B)}return i}function qi(e,t,i){for(var r=[],n=0;n<e.length;++n){var S=e[n];if(S.ranges){r.push(i?Wr.prototype.deepCopy.call(S):S);continue}var B=S.changes,K=[];r.push({changes:K});for(var X=0;X<B.length;++X){var J=B[X],ae=void 0;if(K.push({from:J.from,to:J.to,text:J.text}),t)for(var le in J)(ae=le.match(/^spans_(\d+)$/))&&(ce(t,Number(ae[1]))>-1&&(De(K)[le]=J[le],delete J[le]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var S=Et(t,n)<0;S!=Et(i,n)<0?(n=t,t=i):S!=Et(t,i)<0&&(t=i)}return new jt(n,t)}else return new jt(i||t,t)}function Qn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),br(e,new Wr([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),S=0;S<e.sel.ranges.length;S++)r[S]=Ia(e.sel.ranges[S],t[S],null,n);var B=Jr(e.cm,r,e.sel.primIndex);br(e,B,i)}function Na(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,br(e,Jr(e.cm,n,e.sel.primIndex),r)}function Wo(e,t,i,r){br(e,wi(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var S=0;S<n.length;S++)this.ranges[S]=new jt(s(e,n[S].anchor),s(e,n[S].head))},origin:i&&i.origin};return Ae(e,"beforeSelectionChange",e,r),e.cm&&Ae(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Jr(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,i){var r=e.history.done,n=De(r);n&&n.ranges?(r[r.length-1]=t,qn(e,t,i)):br(e,t,i)}function br(e,t,i){qn(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function qn(e,t,i){(de(e,"beforeSelectionChange")||e.cm&&de(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(Et(t.primary().head,e.sel.primary().head)<0?-1:1);Go(e,Ko(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Ji(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,ge(e.cm)),cr(e,"cursorActivity",e)}function zo(e){Go(e,Ko(e,e.sel,null,!1))}function Ko(e,t,i,r){for(var n,S=0;S<t.ranges.length;S++){var B=t.ranges[S],K=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[S],X=ea(e,B.anchor,K&&K.anchor,i,r),J=ea(e,B.head,K&&K.head,i,r);(n||X!=B.anchor||J!=B.head)&&(n||(n=t.ranges.slice(0,S)),n[S]=new jt(X,J))}return n?Jr(e.cm,n,t.primIndex):t}function en(e,t,i,r,n){var S=ut(e,t.line);if(S.markedSpans)for(var B=0;B<S.markedSpans.length;++B){var K=S.markedSpans[B],X=K.marker,J="selectLeft"in X?!X.selectLeft:X.inclusiveLeft,ae="selectRight"in X?!X.selectRight:X.inclusiveRight;if((K.from==null||(J?K.from<=t.ch:K.from<t.ch))&&(K.to==null||(ae?K.to>=t.ch:K.to>t.ch))){if(n&&(Ae(X,"beforeCursorEnter"),X.explicitlyCleared))if(S.markedSpans){--B;continue}else break;if(!X.atomic)continue;if(i){var le=X.find(r<0?1:-1),be=void 0;if((r<0?ae:J)&&(le=Vo(e,le,-r,le&&le.line==t.line?S:null)),le&&le.line==t.line&&(be=Et(le,i))&&(r<0?be<0:be>0))return en(e,le,t,r,n)}var ye=X.find(r<0?-1:1);return(r<0?J:ae)&&(ye=Vo(e,ye,r,ye.line==t.line?S:null)),ye?en(e,ye,t,r,n):null}}return t}function ea(e,t,i,r,n){var S=r||1,B=en(e,t,i,S,n)||!n&&en(e,t,i,S,!0)||en(e,t,i,-S,n)||!n&&en(e,t,i,-S,!0);return B||(e.cantEdit=!0,Ue(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?s(e,Ue(t.line-1)):null:i>0&&t.ch==(r||ut(e,t.line)).text.length?t.line<e.first+e.size-1?Ue(t.line+1,0):null:new Ue(t.line,t.ch+i)}function Xo(e){e.setSelection(Ue(e.firstLine(),0),Ue(e.lastLine()),xe)}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,S,B,K){n&&(r.from=s(e,n)),S&&(r.to=s(e,S)),B&&(r.text=B),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 tn(e,t,i){if(e.cm){if(!e.cm.curOp)return or(e.cm,tn)(e,t,i);if(e.cm.state.suppressEdits)return}if((de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=Oi&&!i&&bi(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]==""&&Et(t.from,t.to)==0)return;var i=Oa(e,t);Bo(e,t,i,e.cm?e.cm.curOp.id:NaN),Ln(e,t,i,Yr(e,t));var r=[];Li(e,function(n,S){!S&&ce(r,n.history)==-1&&(qo(n.history,t),r.push(n.history)),Ln(n,t,null,Yr(n,t))})}function ta(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,S,B=e.sel,K=t=="undo"?n.done:n.undone,X=t=="undo"?n.undone:n.done,J=0;J<K.length&&!(S=K[J],i?S.ranges&&!S.equals(e.sel):!S.ranges);J++);if(J==K.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(S=K.pop(),S.ranges){if(Jn(S,X),i&&!S.equals(e.sel)){br(e,S,{clearRedo:!1});return}B=S}else if(r){K.push(S);return}else break;var ae=[];Jn(B,X),X.push({changes:ae,generation:n.generation}),n.generation=S.generation||++n.maxGeneration;for(var le=de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"),be=function(Ne){var We=S.changes[Ne];if(We.origin=t,le&&!Yo(e,We,!1))return K.length=0,{};ae.push(Pa(e,We));var Xe=Ne?Oa(e,We):De(K);Ln(e,We,Xe,Uo(e,We)),!Ne&&e.cm&&e.cm.scrollIntoView({from:We.from,to:Ai(We)});var at=[];Li(e,function(Ye,ot){!ot&&ce(at,Ye.history)==-1&&(qo(Ye.history,We),at.push(Ye.history)),Ln(Ye,We,null,Uo(Ye,We))})},ye=S.changes.length-1;ye>=0;--ye){var Le=be(ye);if(Le)return Le.v}}function Zo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Wr(Ve(e.sel.ranges,function(n){return new jt(Ue(n.anchor.line+t,n.anchor.ch),Ue(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){Ar(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Ti(e.cm,r,"gutter")}}function Ln(e,t,i,r){if(e.cm&&!e.cm.curOp)return or(e.cm,Ln)(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:Ue(e.first,0),to:Ue(t.to.line+n,t.to.ch),text:[De(t.text)],origin:t.origin}}var S=e.lastLine();t.to.line>S&&(t={from:t.from,to:Ue(S,ut(e,S).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Hr(e,t.from,t.to),i||(i=Oa(e,t)),e.cm?xl(e.cm,t,r):Ma(e,t,r),qn(e,i,xe),e.cantEdit&&ea(e,Ue(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,S=t.from,B=t.to,K=!1,X=S.line;e.options.lineWrapping||(X=kt(Er(ut(r,S.line))),r.iter(X,B.line+1,function(ye){if(ye==n.maxLine)return K=!0,!0})),r.sel.contains(t.from,t.to)>-1&&ge(e),Ma(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(X,S.line+t.text.length,function(ye){var Le=pn(ye);Le>n.maxLineLength&&(n.maxLine=ye,n.maxLineLength=Le,n.maxLineChanged=!0,K=!1)}),K&&(e.curOp.updateMaxLine=!0)),Xr(r,S.line),Cn(e,400);var J=t.text.length-(B.line-S.line)-1;t.full?Ar(e):S.line==B.line&&t.text.length==1&&!Mo(e.doc,t)?Ti(e,S.line,"text"):Ar(e,S.line,B.line+1,J);var ae=de(e,"changes"),le=de(e,"change");if(le||ae){var be={from:S,to:B,text:t.text,removed:t.removed,origin:t.origin};le&&cr(e,"change",e,be),ae&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(be)}e.display.selForContextMenu=null}function rn(e,t,i,r,n){var S;r||(r=i),Et(r,i)<0&&(S=[r,i],i=S[0],r=S[1]),typeof t=="string"&&(t=e.splitLines(t)),tn(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 S=e[n],B=!0;if(S.ranges){S.copied||(S=e[n]=S.deepCopy(),S.copied=!0);for(var K=0;K<S.ranges.length;K++)Jo(S.ranges[K].anchor,t,i,r),Jo(S.ranges[K].head,t,i,r);continue}for(var X=0;X<S.changes.length;++X){var J=S.changes[X];if(i<J.from.line)J.from=Ue(J.from.line+r,J.from.ch),J.to=Ue(J.to.line+r,J.to.ch);else if(t<=J.to.line){B=!1;break}}B||(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 kn(e,t,i,r){var n=t,S=t;return typeof t=="number"?S=ut(e,W(e,t)):n=kt(t),n==null?null:(r(S,n)&&e.cm&&Ti(e.cm,n,i),S)}function Dn(e){this.lines=e,this.parent=null;for(var t=0,i=0;i<e.length;++i)e[i].parent=this,t+=e[i].height;this.height=t}Dn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var i=e,r=e+t;i<r;++i){var n=this.lines[i];this.height-=n.height,ft(n),cr(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 Rn(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}Rn.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 S=Math.min(t,n-e),B=r.height;if(r.removeInner(e,S),this.height-=B-r.height,n==S&&(this.children.splice(i--,1),r.parent=null),(t-=S)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Dn))){var K=[];this.collapse(K),this.children=[new Dn(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],S=n.chunkSize();if(e<=S){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var B=n.lines.length%25+25,K=B;K<n.lines.length;){var X=new Dn(n.lines.slice(K,K+=25));n.height-=X.height,this.children.splice(++r,0,X),X.parent=this}n.lines=n.lines.slice(0,B),this.maybeSpill()}break}e-=S}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new Rn(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=ce(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new Rn(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],S=n.chunkSize();if(e<S){var B=Math.min(t,S-e);if(n.iterN(e,B,i))return!0;if((t-=B)==0)break;e=0}else e-=S}}};var On=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};On.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=kt(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 S=vn(this);mr(i,Math.max(0,i.height-S)),e&&(Mr(e,function(){es(e,i,-S),Ti(e,r,"widget")}),cr(e,"lineWidgetCleared",e,this,r))},On.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=vn(this)-t;if(!n)return;ri(this.doc,r)||mr(r,r.height+n),i&&Mr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),cr(i,"lineWidgetChanged",i,e,kt(r))})},fe(On);function es(e,t,i){$r(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&wa(e,i)}function El(e,t,i,r){var n=new On(e,i,r),S=e.cm;return S&&n.noHScroll&&(S.display.alignWidgets=!0),kn(e,t,"widget",function(B){var K=B.widgets||(B.widgets=[]);if(n.insertAt==null?K.push(n):K.splice(Math.min(K.length-1,Math.max(0,n.insertAt)),0,n),n.line=B,S&&!ri(e,B)){var X=$r(B)<e.scrollTop;mr(B,B.height+vn(n)),X&&wa(S,n.height),S.curOp.forceUpdate=!0}return!0}),S&&cr(S,"lineWidgetAdded",S,n,typeof t=="number"?t:kt(t)),n}var ts=0,ki=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ts};ki.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&ji(e),de(this,"clear")){var i=this.find();i&&cr(this,"clear",i.from,i.to)}for(var r=null,n=null,S=0;S<this.lines.length;++S){var B=this.lines[S],K=_r(B.markedSpans,this);e&&!this.collapsed?Ti(e,kt(B),"text"):e&&(K.to!=null&&(n=kt(B)),K.from!=null&&(r=kt(B))),B.markedSpans=_i(B.markedSpans,K),K.from==null&&this.collapsed&&!ri(this.doc,B)&&e&&mr(B,Yi(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var X=0;X<this.lines.length;++X){var J=Er(this.lines[X]),ae=pn(J);ae>e.display.maxLineLength&&(e.display.maxLine=J,e.display.maxLineLength=ae,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Ar(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&&cr(e,"markerCleared",e,this,r,n),t&&Wi(e),this.parent&&this.parent.clear()},ki.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var S=this.lines[n],B=_r(S.markedSpans,this);if(B.from!=null&&(i=Ue(t?S:kt(S),B.from),e==-1))return i;if(B.to!=null&&(r=Ue(t?S:kt(S),B.to),e==1))return r}return i&&{from:i,to:r}},ki.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;Mr(r,function(){var n=t.line,S=kt(t.line),B=fa(r,S);if(B&&(no(B),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!ri(i.doc,n)&&i.height!=null){var K=i.height;i.height=null;var X=vn(i)-K;X&&mr(n,n.height+X)}cr(r,"markerChanged",r,e)})},ki.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||ce(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},ki.prototype.detachLine=function(e){if(this.lines.splice(ce(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},fe(ki);function nn(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return or(e.cm,nn)(e,t,i,r,n);var S=new ki(e,n),B=Et(t,i);if(r&&j(r,S,!1),B>0||B==0&&S.clearWhenEmpty!==!1)return S;if(S.replacedWith&&(S.collapsed=!0,S.widgetNode=x("span",[S.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||S.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(S.widgetNode.insertLeft=!0)),S.collapsed){if(ar(e,t.line,t,i,S)||t.line!=i.line&&ar(e,i.line,t,i,S))throw new Error("Inserting collapsed marker partially overlapping an existing one");oi()}S.addToHistory&&Bo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var K=t.line,X=e.cm,J;if(e.iter(K,i.line+1,function(le){X&&S.collapsed&&!X.options.lineWrapping&&Er(le)==X.display.maxLine&&(J=!0),S.collapsed&&K!=t.line&&mr(le,0),yi(le,new si(S,K==t.line?t.ch:null,K==i.line?i.ch:null)),++K}),S.collapsed&&e.iter(t.line,i.line+1,function(le){ri(e,le)&&mr(le,0)}),S.clearOnEnter&&Ce(S,"beforeCursorEnter",function(){return S.clear()}),S.readOnly&&(Ur(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),S.collapsed&&(S.id=++ts,S.atomic=!0),X){if(J&&(X.curOp.updateMaxLine=!0),S.collapsed)Ar(X,t.line,i.line+1);else if(S.className||S.startStyle||S.endStyle||S.css||S.attributes||S.title)for(var ae=t.line;ae<=i.line;ae++)Ti(X,ae,"text");S.atomic&&zo(X.doc),cr(X,"markerAdded",X,S)}return S}var _n=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};_n.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();cr(this,"clear")},_n.prototype.find=function(e,t){return this.primary.find(e,t)},fe(_n);function Sl(e,t,i,r,n){r=j(r),r.shared=!1;var S=[nn(e,t,i,r,n)],B=S[0],K=r.widgetNode;return Li(e,function(X){K&&(r.widgetNode=K.cloneNode(!0)),S.push(nn(X,s(X,t),s(X,i),r,n));for(var J=0;J<X.linked.length;++J)if(X.linked[J].isParent)return;B=De(S)}),new _n(S,B)}function rs(e){return e.findMarks(Ue(e.first,0),e.clipPos(Ue(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(),S=e.clipPos(n.from),B=e.clipPos(n.to);if(Et(S,B)){var K=nn(e,S,B,r.primary,r.primary.type);r.markers.push(K),K.parent=r}}}function Cl(e){for(var t=function(r){var n=e[r],S=[n.primary.doc];Li(n.primary.doc,function(X){return S.push(X)});for(var B=0;B<n.markers.length;B++){var K=n.markers[B];ce(S,K.doc)==-1&&(K.parent=null,n.markers.splice(B--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,Lr=function(e,t,i,r,n){if(!(this instanceof Lr))return new Lr(e,t,i,r,n);i==null&&(i=0),Rn.call(this,[new Dn([new Mi("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var S=Ue(i,0);this.sel=wi(S),this.history=new Zn(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)),Ma(this,{from:S,to:S,text:e}),br(this,wi(S),xe)};Lr.prototype=Je(Rn.prototype,{constructor:Lr,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=ei(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:sr(function(e){var t=Ue(this.first,0),i=this.first+this.size-1;tn(this,{from:t,to:Ue(i,ut(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&xn(this.cm,0,0),br(this,wi(t),xe)}),replaceRange:function(e,t,i,r){t=s(this,t),i=i?s(this,i):t,rn(this,e,t,i,r)},getRange:function(e,t,i){var r=Hr(this,s(this,e),s(this,t));return i===!1?r:r.join(i||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Vr(this,e))return ut(this,e)},getLineNumber:function(e){return kt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=ut(this,e)),Er(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return s(this,e)},getCursor:function(e){var t=this.sel.primary(),i;return e==null||e=="head"?i=t.head:e=="anchor"?i=t.anchor:e=="end"||e=="to"||e===!1?i=t.to():i=t.from(),i},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:sr(function(e,t,i){Wo(this,s(this,typeof e=="number"?Ue(e,t||0):e),null,i)}),setSelection:sr(function(e,t,i){Wo(this,s(this,e),s(this,t||e),i)}),extendSelection:sr(function(e,t,i){Qn(this,s(this,e),t&&s(this,t),i)}),extendSelections:sr(function(e,t){jo(this,O(this,e),t)}),extendSelectionsBy:sr(function(e,t){var i=Ve(this.sel.ranges,e);jo(this,O(this,i),t)}),setSelections:sr(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new jt(s(this,e[n].anchor),s(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),br(this,Jr(this.cm,r,t),i)}),addSelection:sr(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new jt(s(this,e),s(this,t||e))),br(this,Jr(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=Hr(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=Hr(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:sr(function(e,t,i){for(var r=[],n=this.sel,S=0;S<n.ranges.length;S++){var B=n.ranges[S];r[S]={from:B.from(),to:B.to(),text:this.splitLines(e[S]),origin:i}}for(var K=t&&t!="end"&&cl(this,r,t),X=r.length-1;X>=0;X--)tn(this,r[X]);K?Ho(this,K):this.cm&&Ji(this.cm)}),undo:sr(function(){ta(this,"undo")}),redo:sr(function(){ta(this,"redo")}),undoSelection:sr(function(){ta(this,"undo",!0)}),redoSelection:sr(function(){ta(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++i;return{undo:t,redo:i}},clearHistory:function(){var e=this;this.history=new Zn(this.history.maxGeneration),Li(this,function(t){return t.history=e.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:qi(this.history.done),undone:qi(this.history.undone)}},setHistory:function(e){var t=this.history=new Zn(this.history.maxGeneration);t.done=qi(e.done.slice(0),null,!0),t.undone=qi(e.undone.slice(0),null,!0)},setGutterMarker:sr(function(e,t,i){return kn(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&Ge(n)&&(r.gutterMarkers=null),!0})}),clearGutter:sr(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&kn(t,i,"gutter",function(){return i.gutterMarkers[e]=null,Ge(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!Vr(this,e))return null;if(t=e,e=ut(this,e),!e)return null}else if(t=kt(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:sr(function(e,t,i){return kn(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(E(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:sr(function(e,t,i){return kn(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",S=r[n];if(S)if(i==null)r[n]=null;else{var B=S.match(E(i));if(!B)return!1;var K=B.index+B[0].length;r[n]=S.slice(0,B.index)+(!B.index||K==S.length?"":" ")+S.slice(K)||null}else return!1;return!0})}),addLineWidget:sr(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return nn(this,s(this,e),s(this,t),i,i&&i.type||"range")},setBookmark:function(e,t){var i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=s(this,e),nn(this,e,e,i,"bookmark")},findMarksAt:function(e){e=s(this,e);var t=[],i=ut(this,e.line).markedSpans;if(i)for(var r=0;r<i.length;++r){var n=i[r];(n.from==null||n.from<=e.ch)&&(n.to==null||n.to>=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=s(this,e),t=s(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(S){var B=S.markedSpans;if(B)for(var K=0;K<B.length;K++){var X=B[K];!(X.to!=null&&n==e.line&&e.ch>=X.to||X.from==null&&n!=e.line||X.from!=null&&n==t.line&&X.from>=t.ch)&&(!i||i(X.marker))&&r.push(X.marker.parent||X.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 S=n.text.length+r;if(S>e)return t=e,!0;e-=S,++i}),s(this,Ue(i,t))},indexFromPos:function(e){e=s(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var i=this.lineSeparator().length;return this.iter(this.first,e.line,function(r){t+=r.text.length+i}),t},copy:function(e){var t=new Lr(ei(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 Lr(ei(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 Vt&&(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];Li(e,function(n){return r.push(n.id)},!0),e.history=new Zn(null),e.history.done=qi(this.history.done,r),e.history.undone=qi(this.history.undone,r)}},iterLinkedDocs:function(e){Li(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):St(e)},lineSeparator:function(){return this.lineSep||`
`},setDirection:sr(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)})}),Lr.prototype.eachLine=Lr.prototype.iter;var is=0;function Al(e){var t=this;if(ns(t),Fe(t,e)||ui(t.display,e))return;ee(e),H&&(is=+new Date);var i=Ni(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,S=Array(n),B=0,K=function(){++B==n&&or(t,function(){i=s(t.doc,i);var ye={from:i,to:i,text:t.doc.splitLines(S.filter(function(Le){return Le!=null}).join(t.doc.lineSeparator())),origin:"paste"};tn(t.doc,ye),Ho(t.doc,wi(s(t.doc,i),s(t.doc,Ai(ye))))})()},X=function(ye,Le){if(t.options.allowDropFileTypes&&ce(t.options.allowDropFileTypes,ye.type)==-1){K();return}var Ne=new FileReader;Ne.onerror=function(){return K()},Ne.onload=function(){var We=Ne.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(We)){K();return}S[Le]=We,K()},Ne.readAsText(ye)},J=0;J<r.length;J++)X(r[J],J);else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var ae=e.dataTransfer.getData("Text");if(ae){var le;if(t.state.draggingText&&!t.state.draggingText.copy&&(le=t.listSelections()),qn(t.doc,wi(i,i)),le)for(var be=0;be<le.length;++be)rn(t.doc,"",le[be].anchor,le[be].head,"drag");t.replaceSelection(ae,"around","paste"),t.display.input.focus()}}catch(ye){}}}function Ll(e,t){if(H&&(!e.state.draggingText||+new Date-is<100)){ue(t);return}if(Fe(e,t)||ui(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!R){var i=a("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",A&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),A&&i.parentNode.removeChild(i)}}function kl(e,t){var i=Ni(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)),d(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 S=0;S<i.length;S++)e(i[S])})}var os=!1;function Dl(){if(os)return;Rl(),os=!0}function Rl(){var e;Ce(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Ol)},100))}),Ce(window,"blur",function(){return as(Zi)})}function Ol(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var Di={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},Mn=0;Mn<10;Mn++)Di[Mn+48]=Di[Mn+96]=String(Mn);for(var ra=65;ra<=90;ra++)Di[ra]=String.fromCharCode(ra);for(var Pn=1;Pn<=12;Pn++)Di[Pn+111]=Di[Pn+63235]="F"+Pn;var hi={};hi.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"},hi.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"},hi.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"},hi.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"]},hi.default=l?hi.macDefault:hi.pcDefault;function _l(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,S,B=0;B<t.length-1;B++){var K=t[B];if(/^(cmd|meta|m)$/i.test(K))S=!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),S&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Ml(e){var t={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if(r=="..."){delete e[i];continue}for(var n=Ve(i.split(" "),_l),S=0;S<n.length;S++){var B=void 0,K=void 0;S==n.length-1?(K=n.join(" "),B=r):(K=n.slice(0,S+1).join(" "),B="...");var X=t[K];if(!X)t[K]=B;else if(X!=B)throw new Error("Inconsistent bindings for "+K)}delete e[i]}for(var J in t)e[J]=t[J];return e}function an(e,t,i,r){t=ia(t);var n=t.call?t.call(e,r):t[e];if(n===!1)return"nothing";if(n==="...")return"multi";if(n!=null&&i(n))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return an(e,t.fallthrough,i,r);for(var S=0;S<t.fallthrough.length;S++){var B=an(e,t.fallthrough[S],i,r);if(B)return B}}}function ss(e){var t=typeof e=="string"?e:Di[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(A&&e.keyCode==34&&e.char)return!1;var i=Di[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),ls(i,e,t))}function ia(e){return typeof e=="string"?hi[e]:e}function on(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var S=t(i[n]);r.length&&Et(S.from,De(r).to)<=0;){var B=r.pop();if(Et(B.from,S.from)<0){S.from=B.from;break}}r.push(S)}Mr(e,function(){for(var K=r.length-1;K>=0;K--)rn(e.doc,"",r[K].from,r[K].to,"+delete");Ji(e)})}function Ba(e,t,i){var r=Be(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Fa(e,t,i){var r=Ba(e,t.ch,i);return r==null?null:new Ue(t.line,r,i<0?"after":"before")}function Ua(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var S=it(i,t.doc.direction);if(S){var B=n<0?De(S):S[0],K=n<0==(B.level==1),X=K?"after":"before",J;if(B.level>0||t.doc.direction=="rtl"){var ae=Xi(t,i);J=n<0?i.text.length-1:0;var le=ni(t,ae,J).top;J=$e(function(be){return ni(t,ae,be).top==le},n<0==(B.level==1)?B.from:B.to-1,J),X=="before"&&(J=Ba(i,J,1))}else J=n<0?B.to:B.from;return new Ue(r,J,X)}}return new Ue(r,n<0?i.text.length:0,n<0?"before":"after")}function Pl(e,t,i,r){var n=it(t,e.doc.direction);if(!n)return Fa(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var S=Ze(n,i.ch,i.sticky),B=n[S];if(e.doc.direction=="ltr"&&B.level%2==0&&(r>0?B.to>i.ch:B.from<i.ch))return Fa(t,i,r);var K=function(Xe,at){return Ba(t,Xe instanceof Ue?Xe.ch:Xe,at)},X,J=function(Xe){return e.options.lineWrapping?(X=X||Xi(e,t),co(e,t,X,Xe)):{begin:0,end:t.text.length}},ae=J(i.sticky=="before"?K(i,-1):i.ch);if(e.doc.direction=="rtl"||B.level==1){var le=B.level==1==r<0,be=K(i,le?1:-1);if(be!=null&&(le?be<=B.to&&be<=ae.end:be>=B.from&&be>=ae.begin)){var ye=le?"before":"after";return new Ue(i.line,be,ye)}}var Le=function(Xe,at,Ye){for(var ot=function(zt,lr){return lr?new Ue(i.line,K(zt,1),"before"):new Ue(i.line,zt,"after")};Xe>=0&&Xe<n.length;Xe+=at){var xt=n[Xe],gt=at>0==(xt.level!=1),At=gt?Ye.begin:K(Ye.end,-1);if(xt.from<=At&&At<xt.to)return ot(At,gt);if(At=gt?xt.from:K(xt.to,-1),Ye.begin<=At&&At<Ye.end)return ot(At,gt)}},Ne=Le(S+r,r,ae);if(Ne)return Ne;var We=r>0?ae.end:K(ae.begin,-1);return We!=null&&!(r>0&&We==t.text.length)&&(Ne=Le(r>0?0:n.length-1,r,J(We)),Ne)?Ne:null}var In={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),xe)},killLine:function(e){return on(e,function(t){if(t.empty()){var i=ut(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:Ue(t.head.line+1,0)}:{from:t.head,to:Ue(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return on(e,function(t){return{from:Ue(t.from().line,0),to:s(e.doc,Ue(t.to().line+1,0))}})},delLineLeft:function(e){return on(e,function(t){return{from:Ue(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return on(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){return on(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div");return{from:t.from(),to:r}})},undo:function(e){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(Ue(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Ue(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return hs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return ds(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/)?ds(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 S=i[n].from(),B=q(e.getLine(S.line),S.ch,r);t.push(oe(r-B%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Mr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,S=ut(e.doc,n.line).text;if(S){if(n.ch==S.length&&(n=new Ue(n.line,n.ch-1)),n.ch>0)n=new Ue(n.line,n.ch+1),e.replaceRange(S.charAt(n.ch-1)+S.charAt(n.ch-2),Ue(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var B=ut(e.doc,n.line-1).text;B&&(n=new Ue(n.line,1),e.replaceRange(S.charAt(0)+e.doc.lineSeparator()+B.charAt(B.length-1),Ue(n.line-1,B.length-1),n,"+transpose"))}}i.push(new jt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Mr(e,function(){for(var t=e.listSelections(),i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(var r=0;r<t.length;r++)e.indentLine(t[r].from().line,null,!0);Ji(e)})},openLine:function(e){return e.replaceSelection(`
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function hs(e,t){var i=ut(e.doc,t),r=Er(i);return r!=i&&(t=kt(r)),Ua(!0,e,r,t,1)}function Il(e,t){var i=ut(e.doc,t),r=Vi(i);return r!=i&&(t=kt(r)),Ua(!0,e,i,t,-1)}function ds(e,t){var i=hs(e,t.line),r=ut(e.doc,i.line),n=it(r,e.doc.direction);if(!n||n[0].level==0){var S=Math.max(i.ch,r.text.search(/\S/)),B=t.line==i.line&&t.ch<=S&&t.ch;return Ue(i.line,B?0:S,i.sticky)}return i}function na(e,t,i){if(typeof t=="string"&&(t=In[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)!=Oe}finally{e.display.shift=r,e.state.suppressEdits=!1}return n}function Nl(e,t,i){for(var r=0;r<e.state.keyMaps.length;r++){var n=an(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&an(t,e.options.extraKeys,i,e)||an(t,e.options.keyMap,i,e)}var Bl=new ie;function Nn(e,t,i,r){var n=e.state.keySeq;if(n){if(ss(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Bl.set(50,function(){e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())}),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"&&cr(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(ee(i),Sa(e)),!!n}function fs(e,t){var i=us(t,!0);return i?t.shiftKey&&!e.state.keySeq?Nn(e,"Shift-"+i,t,function(r){return na(e,r,!0)})||Nn(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return na(e,r)}):Nn(e,i,t,function(r){return na(e,r)}):!1}function Fl(e,t,i){return Nn(e,"'"+i+"'",t,function(r){return na(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=I(),Fe(t,e))return;H&&U<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=fs(t,e);A&&(ja=r?i:null,!r&&i==88&&!Ft&&(l?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),D&&!l&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Ul(t)}function Ul(e){var t=e.display.lineDiv;G(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(f(t,"CodeMirror-crosshair"),nt(document,"keyup",i),nt(document,"mouseover",i))}Ce(document,"keyup",i),Ce(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),Fe(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(ui(t.display,e)||Fe(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(A&&i==ja){ja=null,ee(e);return}if(A&&(!e.which||e.which<10)&&fs(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Fl(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&&Et(t,this.pos)==0&&i==this.button};var Bn,Fn;function Wl(e,t){var i=+new Date;return Fn&&Fn.compare(i,e,t)?(Bn=Fn=null,"triple"):Bn&&Bn.compare(i,e,t)?(Fn=new Wa(i,e,t),Bn=null,"double"):(Bn=new Wa(i,e,t),Fn=null,"single")}function vs(e){var t=this,i=t.display;if(Fe(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,ui(i,e)){P||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=Ni(t,e),n=Ee(e),S=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,S,e))return;n==1?r?zl(t,r,S,e):me(e)==i.scroller&&ee(e):n==2?(r&&Qn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(k?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,i,r,n){var S="Click";return r=="double"?S="Double"+S:r=="triple"&&(S="Triple"+S),S=(t==1?"Left":t==2?"Middle":"Right")+S,Nn(e,ls(S,n),n,function(B){if(typeof B=="string"&&(B=In[B]),!B)return!1;var K=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),K=B(e,i)!=Oe}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 S=h?i.shiftKey&&i.metaKey:i.altKey;n.unit=S?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=l?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(l?i.altKey:i.ctrlKey)),n}function zl(e,t,i,r){H?setTimeout(z(vo,e),0):e.curOp.focus=I();var n=Gl(e,i,r),S=e.doc.sel,B;e.options.dragDrop&&Me&&!e.isReadOnly()&&i=="single"&&(B=S.contains(t))>-1&&(Et((B=S.ranges[B]).from(),t)<0||t.xRel>0)&&(Et(B.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,S=!1,B=or(e,function(J){P&&(n.scroller.draggable=!1),e.state.draggingText=!1,nt(n.wrapper.ownerDocument,"mouseup",B),nt(n.wrapper.ownerDocument,"mousemove",K),nt(n.scroller,"dragstart",X),nt(n.scroller,"drop",B),S||(ee(J),r.addNew||Qn(e.doc,i,null,null,r.extend),P&&!R||H&&U==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),K=function(J){S=S||Math.abs(t.clientX-J.clientX)+Math.abs(t.clientY-J.clientY)>=10},X=function(){return S=!0};P&&(n.scroller.draggable=!0),e.state.draggingText=B,B.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Ce(n.wrapper.ownerDocument,"mouseup",B),Ce(n.wrapper.ownerDocument,"mousemove",K),Ce(n.scroller,"dragstart",X),Ce(n.scroller,"drop",B),yo(e),setTimeout(function(){return n.input.focus()},20)}function ys(e,t,i){if(i=="char")return new jt(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new jt(Ue(t.line,0),s(e.doc,Ue(t.line+1,0)));var r=i(e,t);return new jt(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,S=e.doc;ee(t);var B,K,X=S.sel,J=X.ranges;if(r.addNew&&!r.extend?(K=S.sel.contains(i),K>-1?B=J[K]:B=new jt(i,i)):(B=S.sel.primary(),K=S.sel.primIndex),r.unit=="rectangle")r.addNew||(B=new jt(i,i)),i=Ni(e,t,!0,!0),K=-1;else{var ae=ys(e,i,r.unit);r.extend?B=Ia(B,ae.anchor,ae.head,r.extend):B=ae}r.addNew?K==-1?(K=J.length,br(S,Jr(e,J.concat([B]),K),{scroll:!1,origin:"*mouse"})):J.length>1&&J[K].empty()&&r.unit=="char"&&!r.extend?(br(S,Jr(e,J.slice(0,K).concat(J.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),X=S.sel):Na(S,K,B,Te):(K=0,br(S,new Wr([B],0),Te),X=S.sel);var le=i;function be(Ye){if(Et(le,Ye)==0)return;if(le=Ye,r.unit=="rectangle"){for(var ot=[],xt=e.options.tabSize,gt=q(ut(S,i.line).text,i.ch,xt),At=q(ut(S,Ye.line).text,Ye.ch,xt),zt=Math.min(gt,At),lr=Math.max(gt,At),Yt=Math.min(i.line,Ye.line),Pr=Math.min(e.lastLine(),Math.max(i.line,Ye.line));Yt<=Pr;Yt++){var kr=ut(S,Yt).text,er=Se(kr,zt,xt);zt==lr?ot.push(new jt(Ue(Yt,er),Ue(Yt,er))):kr.length>er&&ot.push(new jt(Ue(Yt,er),Ue(Yt,Se(kr,lr,xt))))}ot.length||ot.push(new jt(i,i)),br(S,Jr(e,X.ranges.slice(0,K).concat(ot),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(Ye)}else{var Dr=B,fr=ys(e,Ye,r.unit),ir=Dr.anchor,tr;Et(fr.anchor,ir)>0?(tr=fr.head,ir=vi(Dr.from(),fr.anchor)):(tr=fr.anchor,ir=gi(Dr.to(),fr.head));var $t=X.ranges.slice(0);$t[K]=Xl(e,new jt(s(S,ir),tr)),br(S,Jr(e,$t,K),Te)}}var ye=n.wrapper.getBoundingClientRect(),Le=0;function Ne(Ye){var ot=++Le,xt=Ni(e,Ye,!0,r.unit=="rectangle");if(!xt)return;if(Et(xt,le)!=0){e.curOp.focus=I(),be(xt);var gt=Vn(n,S);(xt.line>=gt.to||xt.line<gt.from)&&setTimeout(or(e,function(){Le==ot&&Ne(Ye)}),150)}else{var At=Ye.clientY<ye.top?-20:Ye.clientY>ye.bottom?20:0;At&&setTimeout(or(e,function(){if(Le!=ot)return;n.scroller.scrollTop+=At,Ne(Ye)}),50)}}function We(Ye){e.state.selectingText=!1,Le=Infinity,Ye&&(ee(Ye),n.input.focus()),nt(n.wrapper.ownerDocument,"mousemove",Xe),nt(n.wrapper.ownerDocument,"mouseup",at),S.history.lastSelOrigin=null}var Xe=or(e,function(Ye){Ye.buttons===0||!Ee(Ye)?We(Ye):Ne(Ye)}),at=or(e,We);e.state.selectingText=at,Ce(n.wrapper.ownerDocument,"mousemove",Xe),Ce(n.wrapper.ownerDocument,"mouseup",at)}function Xl(e,t){var i=t.anchor,r=t.head,n=ut(e.doc,i.line);if(Et(i,r)==0&&i.sticky==r.sticky)return t;var S=it(n);if(!S)return t;var B=Ze(S,i.ch,i.sticky),K=S[B];if(K.from!=i.ch&&K.to!=i.ch)return t;var X=B+(K.from==i.ch==(K.level!=1)?0:1);if(X==0||X==S.length)return t;var J;if(r.line!=i.line)J=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var ae=Ze(S,r.ch,r.sticky),le=ae-B||(r.ch-i.ch)*(K.level==1?-1:1);ae==X-1||ae==X?J=le<0:J=le>0}var be=S[X+(J?-1:0)],ye=J==(be.level==1),Le=ye?be.from:be.to,Ne=ye?"after":"before";return i.ch==Le&&i.sticky==Ne?t:new jt(new Ue(i.line,Le,Ne),r)}function bs(e,t,i,r){var n,S;if(t.touches)n=t.touches[0].clientX,S=t.touches[0].clientY;else try{n=t.clientX,S=t.clientY}catch(be){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ee(t);var B=e.display,K=B.lineDiv.getBoundingClientRect();if(S>K.bottom||!de(e,i))return ne(t);S-=K.top-B.viewOffset;for(var X=0;X<e.display.gutterSpecs.length;++X){var J=B.gutters.childNodes[X];if(J&&J.getBoundingClientRect().right>=n){var ae=Fr(e.doc,S),le=e.display.gutterSpecs[X];return Ae(e,i,e,ae,le.className,t),ne(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function xs(e,t){if(ui(e.display,t)||Yl(e,t))return;if(Fe(e,t,"contextmenu"))return;k||e.display.input.onContextMenu(t)}function Yl(e,t){return de(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-"),yn(e)}var sn={toString:function(){return"CodeMirror.Init"}},Ss={},aa={};function $l(e){var t=e.optionHandlers;function i(r,n,S,B){e.defaults[r]=n,S&&(t[r]=B?function(K,X,J){J!=sn&&S(K,X,J)}:S)}e.defineOption=i,e.Init=sn,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,_a(r)},!0),i("indentUnit",2,_a,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){An(r),yn(r),Ar(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var S=[],B=r.doc.first;r.doc.iter(function(X){for(var J=0;;){var ae=X.text.indexOf(n,J);if(ae==-1)break;J=ae+n.length,S.push(Ue(B,ae))}B++});for(var K=S.length-1;K>=0;K--)rn(r.doc,n,S[K],Ue(S[K].line,S[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,S){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),S!=sn&&r.refresh()}),i("specialCharPlaceholder",Gt,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",!C),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),wn(r)},!0),i("keyMap","default",function(r,n,S){var B=ia(n),K=S!=sn&&ia(S);K&&K.detach&&K.detach(r,B),B.attach&&B.attach(r,K||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Jl,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=Ra(n,r.options.lineNumbers),wn(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 Qi(r)},!0),i("scrollbarStyle","native",function(r){Co(r),Qi(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=Ra(r.options.gutters,n),wn(r)},!0),i("firstLineNumber",1,wn,!0),i("lineNumberFormatter",function(r){return r},wn,!0),i("showCursorWhenSelecting",!1,bn,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Zi(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,Zl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,bn,!0),i("singleCursorHeightPerLine",!0,bn,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,An,!0),i("addModeClass",!1,An,!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,An,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function Zl(e,t,i){var r=i&&i!=sn;if(!t!=!r){var n=e.display.dragFunctions,S=t?Ce:nt;S(e.display.scroller,"dragstart",n.start),S(e.display.scroller,"dragenter",n.enter),S(e.display.scroller,"dragover",n.over),S(e.display.scroller,"dragleave",n.leave),S(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):(f(e.display.wrapper,"CodeMirror-wrap"),jn(e)),Ea(e),Ar(e),yn(e),setTimeout(function(){return Qi(e)},100)}function Vt(e,t){var i=this;if(!(this instanceof Vt))return new Vt(e,t);this.options=t=t?j(t):{},j(Ss,t,!1);var r=t.value;typeof r=="string"?r=new Lr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Vt.inputStyles[t.inputStyle](this),S=this.display=new hl(e,r,n,t);S.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 ie,keySeq:null,specialChars:null},t.autofocus&&!o&&S.input.focus(),H&&U<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),Dl(),ji(this),this.curOp.forceUpdate=!0,Po(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Zi(this);for(var B in aa)aa.hasOwnProperty(B)&&aa[B](this,t[B],sn);Lo(this),t.finishInit&&t.finishInit(this);for(var K=0;K<Ga.length;++K)Ga[K](this);Wi(this),P&&t.lineWrapping&&getComputedStyle(S.lineDiv).textRendering=="optimizelegibility"&&(S.lineDiv.style.textRendering="auto")}Vt.defaults=Ss,Vt.optionHandlers=aa;function Ql(e){var t=e.display;Ce(t.scroller,"mousedown",or(e,vs)),H&&U<11?Ce(t.scroller,"dblclick",or(e,function(X){if(Fe(e,X))return;var J=Ni(e,X);if(!J||Ha(e,X)||ui(e.display,X))return;ee(X);var ae=e.findWordAt(J);Qn(e.doc,ae.anchor,ae.head)})):Ce(t.scroller,"dblclick",function(X){return Fe(e,X)||ee(X)}),Ce(t.scroller,"contextmenu",function(X){return xs(e,X)}),Ce(t.input.getField(),"contextmenu",function(X){t.scroller.contains(X.target)||xs(e,X)});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 S(X){if(X.touches.length!=1)return!1;var J=X.touches[0];return J.radiusX<=1&&J.radiusY<=1}function B(X,J){if(J.left==null)return!0;var ae=J.left-X.left,le=J.top-X.top;return ae*ae+le*le>20*20}Ce(t.scroller,"touchstart",function(X){if(!Fe(e,X)&&!S(X)&&!Ha(e,X)){t.input.ensurePolled(),clearTimeout(i);var J=+new Date;t.activeTouch={start:J,moved:!1,prev:J-r.end<=300?r:null},X.touches.length==1&&(t.activeTouch.left=X.touches[0].pageX,t.activeTouch.top=X.touches[0].pageY)}}),Ce(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Ce(t.scroller,"touchend",function(X){var J=t.activeTouch;if(J&&!ui(t,X)&&J.left!=null&&!J.moved&&new Date-J.start<300){var ae=e.coordsChar(t.activeTouch,"page"),le;!J.prev||B(J,J.prev)?le=new jt(ae,ae):!J.prev.prev||B(J,J.prev.prev)?le=e.findWordAt(ae):le=new jt(Ue(ae.line,0),s(e.doc,Ue(ae.line+1,0))),e.setSelection(le.anchor,le.head),e.focus(),ee(X)}n()}),Ce(t.scroller,"touchcancel",n),Ce(t.scroller,"scroll",function(){t.scroller.clientHeight&&(En(e,t.scroller.scrollTop),Fi(e,t.scroller.scrollLeft,!0),Ae(e,"scroll",e))}),Ce(t.scroller,"mousewheel",function(X){return Ro(e,X)}),Ce(t.scroller,"DOMMouseScroll",function(X){return Ro(e,X)}),Ce(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(X){Fe(e,X)||ue(X)},over:function(X){Fe(e,X)||(kl(e,X),ue(X))},start:function(X){return Ll(e,X)},drop:or(e,Al),leave:function(X){Fe(e,X)||ns(e)}};var K=t.input.getField();Ce(K,"keyup",function(X){return ms.call(e,X)}),Ce(K,"keydown",or(e,ps)),Ce(K,"keypress",or(e,gs)),Ce(K,"focus",function(X){return Ta(e,X)}),Ce(K,"blur",function(X){return Zi(e,X)})}var Ga=[];Vt.defineInitHook=function(e){return Ga.push(e)};function Un(e,t,i,r){var n=e.doc,S;i==null&&(i="add"),i=="smart"&&(n.mode.indent?S=Ke(e,t).state:i="prev");var B=e.options.tabSize,K=ut(n,t),X=q(K.text,null,B);K.stateAfter&&(K.stateAfter=null);var J=K.text.match(/^\s*/)[0],ae;if(!r&&!/\S/.test(K.text))ae=0,i="not";else if(i=="smart"&&(ae=n.mode.indent(S,K.text.slice(J.length),K.text),ae==Oe||ae>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?ae=q(ut(n,t-1).text,null,B):ae=0:i=="add"?ae=X+e.options.indentUnit:i=="subtract"?ae=X-e.options.indentUnit:typeof i=="number"&&(ae=X+i),ae=Math.max(0,ae);var le="",be=0;if(e.options.indentWithTabs)for(var ye=Math.floor(ae/B);ye;--ye)be+=B,le+=" ";if(be<ae&&(le+=oe(ae-be)),le!=J)return rn(n,le,Ue(t,0),Ue(t,J.length),"+input"),K.stateAfter=null,!0;for(var Le=0;Le<n.sel.ranges.length;Le++){var Ne=n.sel.ranges[Le];if(Ne.head.line==t&&Ne.head.ch<J.length){var We=Ue(t,J.length);Na(n,Le,new jt(We,We));break}}}var Qr=null;function oa(e){Qr=e}function za(e,t,i,r,n){var S=e.doc;e.display.shift=!1,r||(r=S.sel);var B=+new Date-200,K=n=="paste"||e.state.pasteIncoming>B,X=St(t),J=null;if(K&&r.ranges.length>1)if(Qr&&Qr.text.join(`
`)==t){if(r.ranges.length%Qr.text.length==0){J=[];for(var ae=0;ae<Qr.text.length;ae++)J.push(S.splitLines(Qr.text[ae]))}}else X.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(J=Ve(X,function(Xe){return[Xe]}));for(var le=e.curOp.updateInput,be=r.ranges.length-1;be>=0;be--){var ye=r.ranges[be],Le=ye.from(),Ne=ye.to();ye.empty()&&(i&&i>0?Le=Ue(Le.line,Le.ch-i):e.state.overwrite&&!K?Ne=Ue(Ne.line,Math.min(ut(S,Ne.line).text.length,Ne.ch+De(X).length)):K&&Qr&&Qr.lineWise&&Qr.text.join(`
`)==X.join(`
`)&&(Le=Ne=Ue(Le.line,0)));var We={from:Le,to:Ne,text:J?J[be%J.length]:X,origin:n||(K?"paste":e.state.cutIncoming>B?"cut":"+input")};tn(e.doc,We),cr(e,"inputRead",e,We)}t&&!K&&Cs(e,t),Ji(e),e.curOp.updateInput<2&&(e.curOp.updateInput=le),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&&Mr(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 S=e.getModeAt(n.head),B=!1;if(S.electricChars){for(var K=0;K<S.electricChars.length;K++)if(t.indexOf(S.electricChars.charAt(K))>-1){B=Un(e,n.head.line,"smart");break}}else S.electricInput&&(S.electricInput.test(ut(e.doc,n.head.line).text.slice(0,n.head.ch))&&(B=Un(e,n.head.line,"smart")));B&&cr(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,S={anchor:Ue(n,0),head:Ue(n+1,0)};i.push(S),t.push(e.getRange(S.anchor,S.head))}return{text:t,ranges:i}}function As(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Ls(){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 P?e.style.width="1000px":e.setAttribute("wrap","off"),b&&(e.style.border="1px solid black"),As(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 S=this.options,B=S[r];if(S[r]==n&&r!="mode")return;S[r]=n,t.hasOwnProperty(r)&&or(this,t[r])(this,n,B),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"](ia(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,S=0;S<n.length;++S)if(n[S]==r||n[S].name==r)return n.splice(S,1),!0},addOverlay:Sr(function(r,n){var S=r.token?r:e.getMode(this.options,r);if(S.startState)throw new Error("Overlays may not be stateful.");ze(this.state.overlays,{mode:S,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(B){return B.priority}),this.state.modeGen++,Ar(this)}),removeOverlay:Sr(function(r){for(var n=this.state.overlays,S=0;S<n.length;++S){var B=n[S].modeSpec;if(B==r||typeof r=="string"&&B.name==r){n.splice(S,1),this.state.modeGen++,Ar(this);return}}}),indentLine:Sr(function(r,n,S){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),Vr(this.doc,r)&&Un(this,r,n,S)}),indentSelection:Sr(function(r){for(var n=this.doc.sel.ranges,S=-1,B=0;B<n.length;B++){var K=n[B];if(K.empty())K.head.line>S&&(Un(this,K.head.line,r,!0),S=K.head.line,B==this.doc.sel.primIndex&&Ji(this));else{var X=K.from(),J=K.to(),ae=Math.max(S,X.line);S=Math.min(this.lastLine(),J.line-(J.ch?0:1))+1;for(var le=ae;le<S;++le)Un(this,le,r);var be=this.doc.sel.ranges;X.ch==0&&n.length==be.length&&be[B].from().ch>0&&Na(this.doc,B,new jt(X,be[B].to()),xe)}}}),getTokenAt:function(r,n){return Kt(this,r,n)},getLineTokens:function(r,n){return Kt(this,Ue(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=Re(this,ut(this.doc,r.line)),S=0,B=(n.length-1)/2,K=r.ch,X;if(K==0)X=n[2];else for(;;){var J=S+B>>1;if((J?n[J*2-1]:0)>=K)B=J;else if(n[J*2+1]<K)S=J+1;else{X=n[J*2+2];break}}var ae=X?X.indexOf("overlay "):-1;return ae<0?X:ae==0?null:X.slice(0,ae-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 S=[];if(!i.hasOwnProperty(n))return S;var B=i[n],K=this.getModeAt(r);if(typeof K[n]=="string")B[K[n]]&&S.push(B[K[n]]);else if(K[n])for(var X=0;X<K[n].length;X++){var J=B[K[n][X]];J&&S.push(J)}else K.helperType&&B[K.helperType]?S.push(B[K.helperType]):B[K.name]&&S.push(B[K.name]);for(var ae=0;ae<B._global.length;ae++){var le=B._global[ae];le.pred(K,this)&&ce(S,le.val)==-1&&S.push(le.val)}return S},getStateAfter:function(r,n){var S=this.doc;return r=W(S,r==null?S.first+S.size-1:r),Ke(this,r+1,n).state},cursorCoords:function(r,n){var S,B=this.doc.sel.primary();return r==null?S=B.head:typeof r=="object"?S=s(this.doc,r):S=r?B.from():B.to(),Zr(this,S,n||"page")},charCoords:function(r,n){return ma(this,s(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,Fr(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,S){var B=!1,K;if(typeof r=="number"){var X=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>X&&(r=X,B=!0),K=ut(this.doc,r)}else K=r;return Hn(this,K,{top:0,left:0},n||"page",S||B).top+(B?this.doc.height-$r(K):0)},defaultTextHeight:function(){return Yi(this.display)},defaultCharWidth:function(){return $i(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,S,B,K){var X=this.display;r=Zr(this,s(this.doc,r));var J=r.bottom,ae=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),X.sizer.appendChild(n),B=="over")J=r.top;else if(B=="above"||B=="near"){var le=Math.max(X.wrapper.clientHeight,this.doc.height),be=Math.max(X.sizer.clientWidth,X.lineSpace.clientWidth);(B=="above"||r.bottom+n.offsetHeight>le)&&r.top>n.offsetHeight?J=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=le&&(J=r.bottom),ae+n.offsetWidth>be&&(ae=be-n.offsetWidth)}n.style.top=J+"px",n.style.left=n.style.right="",K=="right"?(ae=X.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(K=="left"?ae=0:K=="middle"&&(ae=(X.sizer.clientWidth-n.offsetWidth)/2),n.style.left=ae+"px"),S&&Zs(this,{left:ae,top:J,right:ae+n.offsetWidth,bottom:J+n.offsetHeight})},triggerOnKeyDown:Sr(ps),triggerOnKeyPress:Sr(gs),triggerOnKeyUp:ms,triggerOnMouseDown:Sr(vs),execCommand:function(r){if(In.hasOwnProperty(r))return In[r].call(null,this)},triggerElectric:Sr(function(r){Cs(this,r)}),findPosH:function(r,n,S,B){var K=1;n<0&&(K=-1,n=-n);for(var X=s(this.doc,r),J=0;J<n&&!(X=Ka(this.doc,X,K,S,B),X.hitSide);++J);return X},moveH:Sr(function(r,n){var S=this;this.extendSelectionsBy(function(B){return S.display.shift||S.doc.extend||B.empty()?Ka(S.doc,B.head,r,n,S.options.rtlMoveVisually):r<0?B.from():B.to()},we)}),deleteH:Sr(function(r,n){var S=this.doc.sel,B=this.doc;S.somethingSelected()?B.replaceSelection("",null,"+delete"):on(this,function(K){var X=Ka(B,K.head,r,n,!1);return r<0?{from:X,to:K.head}:{from:K.head,to:X}})}),findPosV:function(r,n,S,B){var K=1,X=B;n<0&&(K=-1,n=-n);for(var J=s(this.doc,r),ae=0;ae<n;++ae){var le=Zr(this,J,"div");if(X==null?X=le.left:le.left=X,J=ks(this,le,K,S),J.hitSide)break}return J},moveV:Sr(function(r,n){var S=this,B=this.doc,K=[],X=!this.display.shift&&!B.extend&&B.sel.somethingSelected();if(B.extendSelectionsBy(function(ae){if(X)return r<0?ae.from():ae.to();var le=Zr(S,ae.head,"div");ae.goalColumn!=null&&(le.left=ae.goalColumn),K.push(le.left);var be=ks(S,le,r,n);return n=="page"&&ae==B.sel.primary()&&wa(S,ma(S,be,"div").top-le.top),be},we),K.length)for(var J=0;J<B.sel.ranges.length;J++)B.sel.ranges[J].goalColumn=K[J]}),findWordAt:function(r){var n=this.doc,S=ut(n,r.line).text,B=r.ch,K=r.ch;if(S){var X=this.getHelper(r,"wordChars");(r.sticky=="before"||K==S.length)&&B?--B:++K;for(var J=S.charAt(B),ae=He(J,X)?function(le){return He(le,X)}:/\s/.test(J)?function(le){return/\s/.test(le)}:function(le){return!/\s/.test(le)&&!He(le)};B>0&&ae(S.charAt(B-1));)--B;for(;K<S.length&&ae(S.charAt(K));)++K}return new jt(Ue(r.line,B),Ue(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"):f(this.display.cursorDiv,"CodeMirror-overwrite"),Ae(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==I()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:Sr(function(r,n){xn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-ii(this)-this.display.barHeight,width:r.scrollWidth-ii(this)-this.display.barWidth,clientHeight:ca(this),clientWidth:Pi(this)}},scrollIntoView:Sr(function(r,n){r==null?(r={from:this.doc.sel.primary().head,to:null},n==null&&(n=this.options.cursorScrollMargin)):typeof r=="number"?r={from:Ue(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:Sr(function(r,n){var S=this,B=function(X){return typeof X=="number"||/^\d+$/.test(String(X))?X+"px":X};r!=null&&(this.display.wrapper.style.width=B(r)),n!=null&&(this.display.wrapper.style.height=B(n)),this.options.lineWrapping&&ao(this);var K=this.display.viewFrom;this.doc.iter(K,this.display.viewTo,function(X){if(X.widgets){for(var J=0;J<X.widgets.length;J++)if(X.widgets[J].noHScroll){Ti(S,K,"widget");break}}++K}),this.curOp.forceUpdate=!0,Ae(this,"refresh",this)}),operation:function(r){return Mr(this,r)},startOperation:function(){return ji(this)},endOperation:function(){return Wi(this)},refresh:Sr(function(){var r=this.display.cachedTextHeight;Ar(this),this.curOp.forceUpdate=!0,yn(this),xn(this,this.doc.scrollLeft,this.doc.scrollTop),ka(this.display),(r==null||Math.abs(r-Yi(this.display))>.5||this.options.lineWrapping)&&Ea(this),Ae(this,"refresh",this)}),swapDoc:Sr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Po(this,r),yn(this),this.display.input.reset(),xn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,cr(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},fe(e),e.registerHelper=function(r,n,S){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=S},e.registerGlobalHelper=function(r,n,S,B){e.registerHelper(r,n,B),i[r]._global.push({pred:S,val:B})}}function Ka(e,t,i,r,n){var S=t,B=i,K=ut(e,t.line),X=n&&e.direction=="rtl"?-i:i;function J(){var at=t.line+X;return at<e.first||at>=e.first+e.size?!1:(t=new Ue(at,t.ch,t.sticky),K=ut(e,at))}function ae(at){var Ye;if(r=="codepoint"){var ot=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(ot)?Ye=null:Ye=new Ue(t.line,Math.max(0,Math.min(K.text.length,t.ch+i*(ot>=55296&&ot<56320?2:1))),-i)}else n?Ye=Pl(e.cm,K,t,i):Ye=Fa(K,t,i);if(Ye==null)if(!at&&J())t=Ua(n,e.cm,K,t.line,X);else return!1;else t=Ye;return!0}if(r=="char"||r=="codepoint")ae();else if(r=="column")ae(!0);else if(r=="word"||r=="group")for(var le=null,be=r=="group",ye=e.cm&&e.cm.getHelper(t,"wordChars"),Le=!0;!(i<0&&!ae(!Le));Le=!1){var Ne=K.text.charAt(t.ch)||`
`,We=He(Ne,ye)?"w":be&&Ne==`
`?"n":!be||/\s/.test(Ne)?null:"p";if(be&&!Le&&!We&&(We="s"),le&&le!=We){i<0&&(i=1,ae(),t.sticky="after");break}if(We&&(le=We),i>0&&!ae(!Le))break}var Xe=ea(e,t,S,B,!0);return pi(S,Xe)&&(Xe.hitSide=!0),Xe}function ks(e,t,i,r){var n=e.doc,S=t.left,B;if(r=="page"){var K=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),X=Math.max(K-.5*Yi(e.display),3);B=(i>0?t.bottom:t.top)+i*X}else r=="line"&&(B=i>0?t.bottom+3:t.top-3);for(var J;!(J=va(e,S,B),!J.outside);){if(i<0?B<=0:B>=n.height){J.hitSide=!0;break}B+=i*5}return J}var Ht=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new ie,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Ht.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;As(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function S(K){for(var X=K.target;X;X=X.parentNode){if(X==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(X.className))break}return!1}Ce(n,"paste",function(K){if(!S(K)||Fe(r,K)||Ts(K,r))return;U<=11&&setTimeout(or(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 B(K){if(!S(K)||Fe(r,K))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()}),K.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var X=ws(r);oa({lineWise:!0,text:X.text}),K.type=="cut"&&r.operation(function(){r.setSelections(X.ranges,0,xe),r.replaceSelection("",null,"cut")})}else return;if(K.clipboardData){K.clipboardData.clearData();var J=Qr.text.join(`
`);if(K.clipboardData.setData("Text",J),K.clipboardData.getData("Text")==J){K.preventDefault();return}}var ae=Ls(),le=ae.firstChild;r.display.lineSpace.insertBefore(ae,r.display.lineSpace.firstChild),le.value=Qr.text.join(`
`);var be=document.activeElement;Q(le),setTimeout(function(){r.display.lineSpace.removeChild(ae),be.focus(),be==n&&i.showPrimarySelection()},50)}Ce(n,"copy",B),Ce(n,"cut",B)},Ht.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Ht.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},Ht.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Ht.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Ht.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 S=sa(t,e.anchorNode,e.anchorOffset),B=sa(t,e.focusNode,e.focusOffset);if(S&&!S.bad&&B&&!B.bad&&Et(vi(S,B),r)==0&&Et(gi(S,B),n)==0)return;var K=t.display.view,X=r.line>=t.display.viewFrom&&Ds(t,r)||{node:K[0].measure.map[2],offset:0},J=n.line<t.display.viewTo&&Ds(t,n);if(!J){var ae=K[K.length-1].measure,le=ae.maps?ae.maps[ae.maps.length-1]:ae.map;J={node:le[le.length-1],offset:le[le.length-2]-le[le.length-3]}}if(!X||!J){e.removeAllRanges();return}var be=e.rangeCount&&e.getRangeAt(0),ye;try{ye=v(X.node,X.offset,J.offset,J.node)}catch(Le){}ye&&(!D&&t.state.focused?(e.collapse(X.node,X.offset),ye.collapsed||(e.removeAllRanges(),e.addRange(ye))):(e.removeAllRanges(),e.addRange(ye)),be&&e.anchorNode==null?e.addRange(be):D&&this.startGracePeriod()),this.rememberSelection()},Ht.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)},Ht.prototype.showMultipleSelections=function(e){d(this.cm.display.cursorDiv,e.cursors),d(this.cm.display.selectionDiv,e.selection)},Ht.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Ht.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return T(this.div,t)},Ht.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Ht.prototype.blur=function(){this.div.blur()},Ht.prototype.getField=function(){return this.div},Ht.prototype.supportsTouch=function(){return!0},Ht.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():Mr(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)},Ht.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Ht.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(u&&y&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var i=sa(t,e.anchorNode,e.anchorOffset),r=sa(t,e.focusNode,e.focusOffset);i&&r&&Mr(t,function(){br(t.doc,wi(i,r),xe),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},Ht.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=Ue(r.line-1,ut(e.doc,r.line-1).length)),n.ch==ut(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=Ue(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var S,B,K;r.line==t.viewFrom||(S=Bi(e,r.line))==0?(B=kt(t.view[0].line),K=t.view[0].node):(B=kt(t.view[S].line),K=t.view[S-1].node.nextSibling);var X=Bi(e,n.line),J,ae;if(X==t.view.length-1?(J=t.viewTo-1,ae=t.lineDiv.lastChild):(J=kt(t.view[X+1].line)-1,ae=t.view[X+1].node.previousSibling),!K)return!1;for(var le=e.doc.splitLines(tu(e,K,ae,B,J)),be=Hr(e.doc,Ue(B,0),Ue(J,ut(e.doc,J).text.length));le.length>1&&be.length>1;)if(De(le)==De(be))le.pop(),be.pop(),J--;else if(le[0]==be[0])le.shift(),be.shift(),B++;else break;for(var ye=0,Le=0,Ne=le[0],We=be[0],Xe=Math.min(Ne.length,We.length);ye<Xe&&Ne.charCodeAt(ye)==We.charCodeAt(ye);)++ye;for(var at=De(le),Ye=De(be),ot=Math.min(at.length-(le.length==1?ye:0),Ye.length-(be.length==1?ye:0));Le<ot&&at.charCodeAt(at.length-Le-1)==Ye.charCodeAt(Ye.length-Le-1);)++Le;if(le.length==1&&be.length==1&&B==r.line)for(;ye&&ye>r.ch&&at.charCodeAt(at.length-Le-1)==Ye.charCodeAt(Ye.length-Le-1);)ye--,Le++;le[le.length-1]=at.slice(0,at.length-Le).replace(/^\u200b+/,""),le[0]=le[0].slice(ye).replace(/\u200b+$/,"");var xt=Ue(B,ye),gt=Ue(J,be.length?De(be).length-Le:0);if(le.length>1||le[0]||Et(xt,gt))return rn(e.doc,le,xt,gt,"+input"),!0},Ht.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ht.prototype.reset=function(){this.forceCompositionEnd()},Ht.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Ht.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)},Ht.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Mr(this.cm,function(){return Ar(e.cm)})},Ht.prototype.setUneditable=function(e){e.contentEditable="false"},Ht.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||or(this.cm,za)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Ht.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Ht.prototype.onContextMenu=function(){},Ht.prototype.resetPosition=function(){},Ht.prototype.needsContentAttribute=!0;function Ds(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=ut(e.doc,t.line),n=eo(i,r,t.line),S=it(r,e.doc.direction),B="left";if(S){var K=Ze(S,t.ch);B=K%2?"right":"left"}var X=io(n.map,t.ch,B);return X.offset=X.collapse=="right"?X.end:X.start,X}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function ln(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var S="",B=!1,K=e.doc.lineSeparator(),X=!1;function J(ye){return function(Le){return Le.id==ye}}function ae(){B&&(S+=K,X&&(S+=K),B=X=!1)}function le(ye){ye&&(ae(),S+=ye)}function be(ye){if(ye.nodeType==1){var Le=ye.getAttribute("cm-text");if(Le){le(Le);return}var Ne=ye.getAttribute("cm-marker"),We;if(Ne){var Xe=e.findMarks(Ue(r,0),Ue(n+1,0),J(+Ne));Xe.length&&(We=Xe[0].find(0))&&le(Hr(e.doc,We.from,We.to).join(K));return}if(ye.getAttribute("contenteditable")=="false")return;var at=/^(pre|div|p|li|table|br)$/i.test(ye.nodeName);if(!/^br$/i.test(ye.nodeName)&&ye.textContent.length==0)return;at&&ae();for(var Ye=0;Ye<ye.childNodes.length;Ye++)be(ye.childNodes[Ye]);/^(pre|p)$/i.test(ye.nodeName)&&(X=!0),at&&(B=!0)}else ye.nodeType==3&&le(ye.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(be(t),t==i);)t=t.nextSibling,X=!1;return S}function sa(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return ln(e.clipPos(Ue(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 S=e.display.view[n];if(S.node==r)return ru(S,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!T(r,t))return ln(Ue(kt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var S=e.rest?De(e.rest):e.line;return ln(Ue(kt(S),S.text.length),n)}var B=t.nodeType==3?t:null,K=t;for(!B&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(B=t.firstChild,i&&(i=B.nodeValue.length));K.parentNode!=r;)K=K.parentNode;var X=e.measure,J=X.maps;function ae(We,Xe,at){for(var Ye=-1;Ye<(J?J.length:0);Ye++)for(var ot=Ye<0?X.map:J[Ye],xt=0;xt<ot.length;xt+=3){var gt=ot[xt+2];if(gt==We||gt==Xe){var At=kt(Ye<0?e.line:e.rest[Ye]),zt=ot[xt]+at;return(at<0||gt!=We)&&(zt=ot[xt+(at?1:0)]),Ue(At,zt)}}}var le=ae(B,K,i);if(le)return ln(le,n);for(var be=K.nextSibling,ye=B?B.nodeValue.length-i:0;be;be=be.nextSibling){if(le=ae(be,be.firstChild,0),le)return ln(Ue(le.line,le.ch-ye),n);ye+=be.textContent.length}for(var Le=K.previousSibling,Ne=i;Le;Le=Le.previousSibling){if(le=ae(Le,Le.firstChild,-1),le)return ln(Ue(le.line,le.ch+Ne),n);Ne+=Le.textContent.length}}var Qt=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new ie,this.hasSelection=!1,this.composing=null};Qt.prototype.init=function(e){var t=this,i=this,r=this.cm;this.createField(e);var n=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),b&&(n.style.width="0px"),Ce(n,"input",function(){H&&U>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Ce(n,"paste",function(B){if(Fe(r,B)||Ts(B,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function S(B){if(Fe(r,B))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var K=ws(r);oa({lineWise:!0,text:K.text}),B.type=="cut"?r.setSelections(K.ranges,null,xe):(i.prevInput="",n.value=K.text.join(`
`),Q(n))}else return;B.type=="cut"&&(r.state.cutIncoming=+new Date)}Ce(n,"cut",S),Ce(n,"copy",S),Ce(e.scroller,"paste",function(B){if(ui(e,B)||Fe(r,B))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var K=new Event("paste");K.clipboardData=B.clipboardData,n.dispatchEvent(K)}),Ce(e.lineSpace,"selectstart",function(B){ui(e,B)||ee(B)}),Ce(n,"compositionstart",function(){var B=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:B,range:r.markText(B,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Ce(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},Qt.prototype.createField=function(e){this.wrapper=Ls(),this.textarea=this.wrapper.firstChild},Qt.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Qt.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var n=Zr(e,i.sel.primary().head,"div"),S=t.wrapper.getBoundingClientRect(),B=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+B.top-S.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+B.left-S.left))}return r},Qt.prototype.showSelection=function(e){var t=this.cm,i=t.display;d(i.cursorDiv,e.cursors),d(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Qt.prototype.reset=function(e){if(this.contextMenuPending||this.composing)return;var t=this.cm;if(t.somethingSelected()){this.prevInput="";var i=t.getSelection();this.textarea.value=i,t.state.focused&&Q(this.textarea),H&&U>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",H&&U>=9&&(this.hasSelection=null))},Qt.prototype.getField=function(){return this.textarea},Qt.prototype.supportsTouch=function(){return!1},Qt.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||I()!=this.textarea))try{this.textarea.focus()}catch(e){}},Qt.prototype.blur=function(){this.textarea.blur()},Qt.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Qt.prototype.receivedFocus=function(){this.slowPoll()},Qt.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()})},Qt.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)},Qt.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||st(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(H&&U>=9&&this.hasSelection===n||l&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var S=n.charCodeAt(0);if(S==8203&&!r&&(r="\u200B"),S==8666)return this.reset(),this.cm.execCommand("undo")}for(var B=0,K=Math.min(r.length,n.length);B<K&&r.charCodeAt(B)==n.charCodeAt(B);)++B;return Mr(t,function(){za(t,n.slice(B),r.length-B,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},Qt.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Qt.prototype.onKeyPress=function(){H&&U>=9&&(this.hasSelection=null),this.fastPoll()},Qt.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var S=Ni(i,e),B=r.scroller.scrollTop;if(!S||A)return;var K=i.options.resetSelectionOnContextMenu;K&&i.doc.sel.contains(S)==-1&&or(i,br)(i.doc,wi(S),xe);var X=n.style.cssText,J=t.wrapper.style.cssText,ae=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
top: `+(e.clientY-ae.top-5)+"px; left: "+(e.clientX-ae.left-5)+`px;
z-index: 1000; background: `+(H?"rgba(255, 255, 255, .05)":"transparent")+`;
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var le;P&&(le=window.scrollY),r.input.focus(),P&&window.scrollTo(null,le),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=ye,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function be(){if(n.selectionStart!=null){var Ne=i.somethingSelected(),We="\u200B"+(Ne?n.value:"");n.value="\u21DA",n.value=We,t.prevInput=Ne?"":"\u200B",n.selectionStart=1,n.selectionEnd=We.length,r.selForContextMenu=i.doc.sel}}function ye(){if(t.contextMenuPending!=ye)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=J,n.style.cssText=X,H&&U<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=B),n.selectionStart!=null){(!H||H&&U<9)&&be();var Ne=0,We=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?or(i,Xo)(i):Ne++<10?r.detectingSelectAll=setTimeout(We,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(We,200)}}if(H&&U>=9&&be(),k){ue(e);var Le=function(){nt(window,"mouseup",Le),setTimeout(ye,20)};Ce(window,"mouseup",Le)}else setTimeout(ye,50)},Qt.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},Qt.prototype.setUneditable=function(){},Qt.prototype.needsContentAttribute=!1;function iu(e,t){if(t=t?j(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=I();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 S=e.form;n=S.submit;try{var B=S.submit=function(){r(),S.submit=n,S.submit(),S.submit=B}}catch(X){}}t.finishInit=function(X){X.save=r,X.getTextArea=function(){return e},X.toTextArea=function(){X.toTextArea=isNaN,r(),e.parentNode.removeChild(X.getWrapperElement()),e.style.display="",e.form&&(nt(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var K=Vt(function(X){return e.parentNode.insertBefore(X,e.nextSibling)},t);return K}function nu(e){e.off=nt,e.on=Ce,e.wheelEventPixels=dl,e.Doc=Lr,e.splitLines=St,e.countColumn=q,e.findColumn=Se,e.isWordChar=Ie,e.Pass=Oe,e.signal=Ae,e.Line=Mi,e.changeEnd=Ai,e.scrollbarModel=To,e.Pos=Ue,e.cmpPos=Et,e.modes=Xt,e.mimeModes=Ot,e.resolveMode=bt,e.getMode=Nr,e.modeExtensions=hr,e.extendMode=pr,e.copyState=Br,e.startState=qr,e.innerMode=ci,e.commands=In,e.keyMap=hi,e.keyName=us,e.isModifierKey=ss,e.lookupKey=an,e.normalizeKeyMap=Ml,e.StringStream=It,e.SharedTextMarker=_n,e.TextMarker=ki,e.LineWidget=On,e.e_preventDefault=ee,e.e_stopPropagation=te,e.e_stop=ue,e.addClass=G,e.contains=T,e.rmClass=f,e.keyNames=Di}$l(Vt),ql(Vt);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in Lr.prototype)Lr.prototype.hasOwnProperty(la)&&ce(au,la)<0&&(Vt.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(Lr.prototype[la]));return fe(Lr),Vt.inputStyles={textarea:Qt,contenteditable:Ht},Vt.defineMode=function(e){!Vt.defaults.mode&&e!="null"&&(Vt.defaults.mode=e),Ir.apply(this,arguments)},Vt.defineMIME=Kr,Vt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Vt.defineMIME("text/plain","null"),Vt.defineExtension=function(e,t){Vt.prototype[e]=t},Vt.defineDocExtension=function(e,t){Lr.prototype[e]=t},Vt.fromTextArea=iu,nu(Vt),Vt.version="5.58.2",Vt})},VwnK:function(wt,pt,se){"use strict";se.r(pt);var re=se("+L6B"),Z=se("2/Rp"),D=se("OaEy"),Y=se("2fM7"),N=se("14J3"),M=se("BMrR"),H=se("5NDa"),U=se("5rEg"),P=se("jCWc"),_=se("kPKH"),y=se("jrin"),A=se("miYZ"),R=se("tsqr"),L=se("k1fw"),w=se("9og8"),b=se("y8nQ"),u=se("Vl3Y"),o=se("tJVT"),l=se("PpiC"),h=se("WmNS"),C=se.n(h),g=se("q1tI"),p=se.n(g),k=se("9kvl"),E=se("ErOA"),f=se("xKgJ"),m=se("Ot1p"),d=function(x){var v,T,I,G=x.user,V=x.globalSetting,Q=x.loading,z=x.dispatch,j=x.restful,q=Object(l.a)(x,["user","globalSetting","loading","dispatch","restful"]),ie=Object(g.useState)({content:"",message:"",status:0,contacts:[],address:"",data:[]}),ce=Object(o.a)(ie,2),ve=ce[0],Oe=ce[1],xe=Object(g.useState)(!0),Te=Object(o.a)(xe,2),we=Te[0],Se=Te[1],pe=q.match.params,oe=u.a.useForm(),De=Object(o.a)(oe,1),Ve=De[0],ze=Object(g.useState)(`
##### \u7B80\u8981\u63CF\u8FF0
- \u7528\u6237\u6CE8\u518C\u63A5\u53E3
##### \u8BF7\u6C42URL
- \` http://xx.com/api/user/register \`
##### \u8BF7\u6C42\u65B9\u5F0F
- POST
##### \u53C2\u6570
|\u53C2\u6570\u540D|\u5FC5\u9009|\u7C7B\u578B|\u8BF4\u660E|
|:---- |:---|:----- |----- |
|username |\u662F |string |\u7528\u6237\u540D |
|password |\u662F |string | \u5BC6\u7801 |
|name |\u5426 |string | \u6635\u79F0 |
##### \u8FD4\u56DE\u793A\u4F8B
\`\`\`
{
"error_code": 0,
"data": {
"uid": "1",
"username": "12154545",
"name": "\u5434\u7CFB\u6302",
"groupid": 2 ,
"reg_time": "1436864169",
"last_login_time": "0",
}
}
\`\`\`
##### \u8FD4\u56DE\u53C2\u6570\u8BF4\u660E
|\u53C2\u6570\u540D|\u7C7B\u578B|\u8BF4\u660E|
|:----- |:-----|----- |
|groupid |int |\u7528\u6237\u7EC4id\uFF0C1\uFF1A\u8D85\u7EA7\u7BA1\u7406\u5458\uFF1B2\uFF1A\u666E\u901A\u7528\u6237 |
##### \u5907\u6CE8
- \u66F4\u591A\u8FD4\u56DE\u9519\u8BEF\u4EE3\u7801\u8BF7\u770B\u9996\u9875\u7684\u9519\u8BEF\u4EE3\u7801\u63CF\u8FF0
\u6B22\u8FCE\u4F7F\u7528\uFF01`),et=Object(o.a)(ze,2),Je=et[0],ke=et[1];Object(g.useEffect)(function(){Ve.resetFields()},[pe.id]);var Ie=function(){var Ge=Object(w.a)(C.a.mark(function je(_e){var Be,$e,qe;return C.a.wrap(function(Ze){for(;;)switch(Ze.prev=Ze.next){case 0:return Ze.next=2,Ve.getFieldsValue();case 2:return Be=Ze.sent,$e="/api/restfuls.json",pe.id!=0&&($e="/api/restfuls/".concat(pe.id,".json")),Ze.next=7,Object(E.a)($e,{method:pe.id!=0?"put":"post",body:Object(L.a)(Object(L.a)({file_type:0},Be),{},{parent_id:Be.parent_id||""})});case 7:qe=Ze.sent,qe.status===0&&(R.b.success("\u6DFB\u52A0\u6210\u529F"),q.history.push("/ch/rest/".concat(qe.data.id)));case 9:case"end":return Ze.stop()}},je)}));return function(_e){return Ge.apply(this,arguments)}}(),He=function(){var Ge=Object(w.a)(C.a.mark(function je(){var _e;return C.a.wrap(function($e){for(;;)switch($e.prev=$e.next){case 0:return $e.next=2,z({type:"restful/getRestful"});case 2:if(!(pe.id!=0)){$e.next=8;break}return $e.next=5,z({type:"restful/getRestfulDetail",payload:Object(L.a)({},pe)});case 5:_e=$e.sent,Ve.setFieldsValue({description:_e==null?void 0:_e.description,name:_e==null?void 0:_e.name}),Object(f.o)()||q.history.replace("/403");case 8:case"end":return $e.stop()}},je)}));return function(){return Ge.apply(this,arguments)}}();return Object(g.useEffect)(function(){var Ge,je;if((Ge=j.restful)!==null&&Ge!==void 0&&Ge.data&&Ve.setFieldsValue({parent_id:pe.categoryId*1}),(je=j.restfulDetail)!==null&&je!==void 0&&je.description&&pe.id!=0){var _e;ke((_e=j.restfulDetail)===null||_e===void 0?void 0:_e.description)}},[j.restful,(v=j.restfulDetail)===null||v===void 0?void 0:v.description]),Object(g.useEffect)(function(){Se(!0),He()},[pe.id]),p.a.createElement("section",null,p.a.createElement("aside",{className:"edu-container mt30"},p.a.createElement(u.a,{onFinish:Ie,form:Ve,initialValues:Object(y.a)({},"name","")},p.a.createElement(M.a,{className:"mt30"},p.a.createElement(_.a,{flex:"80px",className:"font14"},"\u76EE\u5F55\u540D\u79F0\uFF1A"),p.a.createElement(_.a,{flex:"1"},p.a.createElement(u.a.Item,{name:"name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u76EE\u5F55\u540D\u79F0"}]},p.a.createElement(U.a,{placeholder:"\u8BF7\u8F93\u5165\u540D\u79F0\uFF0C\u6700\u5927\u9650\u523660\u4E2A\u5B57\u7B26 ",maxLength:60})))),p.a.createElement(M.a,{className:""},p.a.createElement(_.a,{flex:"80px",className:"font14"},"\u6240\u5C5E\u76EE\u5F55:"),p.a.createElement(_.a,{flex:"1"},p.a.createElement(u.a.Item,{name:"parent_id",rules:[{required:!0,message:"\u6240\u5C5E\u76EE\u5F55"}]},p.a.createElement(Y.a,{showSearch:!0,style:{width:200},placeholder:"\u8BF7\u9009\u62E9\u76EE\u5F55",optionFilterProp:"children",filterOption:function(je,_e){return _e.children.toLowerCase().indexOf(je.toLowerCase())>=0}},p.a.createElement(Y.a.Option,{value:0,key:9999},"\u6839\u76EE\u5F55"),j==null||((T=j.restful)===null||T===void 0||((I=T.data)===null||I===void 0))?void 0:I.map(function(Ge,je){return p.a.createElement(Y.a.Option,{value:Ge.id,key:je},Ge.title)}))))),p.a.createElement(u.a.Item,{name:"description",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u76EE\u5F55\u540D\u79F0"}]},p.a.createElement(m.a,{defaultValue:Je,watch:!0,height:600})),p.a.createElement(M.a,{align:"middle",justify:"center"},p.a.createElement(_.a,null,p.a.createElement(Z.a,{style:{width:130},size:"large",type:"primary",htmlType:"submit"},"\u4FDD\u5B58"))),p.a.createElement("div",{className:"mt40"}))))};pt.default=Object(k.a)(function(a){var x=a.user,v=a.loading,T=a.globalSetting,I=a.restful;return{user:x,globalSetting:T,restful:I,loading:v.models.index}})(d)},Y1PL:function(wt,pt,se){"use strict";se.r(pt),se.d(pt,"ResizableTextArea",function(){return ce});var re=se("wx14"),Z=se("1OyB"),D=se("vuIU"),Y=se("Ji7U"),N=se("LK+K"),M=se("q1tI"),H=se("VTBJ"),U=se("rePB"),P=se("Zm9Q"),_=se("Kwbf"),y=se("c+Xe"),A=se("m+aA"),R=se("bdgK"),L=new Map;function w(xe){xe.forEach(function(Te){var we,Se=Te.target;(we=L.get(Se))===null||we===void 0||we.forEach(function(pe){return pe(Se)})})}var b=new R.default(w),u=null,o=null;function l(xe,Te){L.has(xe)||(L.set(xe,new Set),b.observe(xe)),L.get(xe).add(Te)}function h(xe,Te){L.has(xe)&&(L.get(xe).delete(Te),L.get(xe).size||(b.unobserve(xe),L.delete(xe)))}var C=function(xe){Object(Y.a)(we,xe);var Te=Object(N.a)(we);function we(){return Object(Z.a)(this,we),Te.apply(this,arguments)}return Object(D.a)(we,[{key:"render",value:function(){return this.props.children}}]),we}(M.Component),g=M.createContext(null);function p(xe){var Te=xe.children,we=xe.onBatchResize,Se=M.useRef(0),pe=M.useRef([]),oe=M.useContext(g),De=M.useCallback(function(Ve,ze,et){Se.current+=1;var Je=Se.current;pe.current.push({size:Ve,element:ze,data:et}),Promise.resolve().then(function(){Je===Se.current&&(we==null||we(pe.current),pe.current=[])}),oe==null||oe(Ve,ze,et)},[we,oe]);return M.createElement(g.Provider,{value:De},Te)}function k(xe){var Te=xe.children,we=xe.disabled,Se=M.useRef(null),pe=M.useRef(null),oe=M.useContext(g),De=M.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Ve=M.isValidElement(Te)&&Object(y.c)(Te),ze=Ve?Te.ref:null,et=M.useMemo(function(){return Object(y.a)(ze,Se)},[ze,Se]),Je=M.useRef(xe);Je.current=xe;var ke=M.useCallback(function(Ie){var He=Je.current,Ge=He.onResize,je=He.data,_e=Ie.getBoundingClientRect(),Be=_e.width,$e=_e.height,qe=Ie.offsetWidth,Qe=Ie.offsetHeight,Ze=Math.floor(Be),ct=Math.floor($e);if(De.current.width!==Ze||De.current.height!==ct||De.current.offsetWidth!==qe||De.current.offsetHeight!==Qe){var it={width:Ze,height:ct,offsetWidth:qe,offsetHeight:Qe};De.current=it;var rt=qe===Math.round(Be)?Be:qe,Ce=Qe===Math.round($e)?$e:Qe,lt=Object(H.a)(Object(H.a)({},it),{},{offsetWidth:rt,offsetHeight:Ce});oe==null||oe(lt,Ie,je),Ge&&Promise.resolve().then(function(){Ge(lt,Ie)})}},[]);return M.useEffect(function(){var Ie=Object(A.a)(Se.current)||Object(A.a)(pe.current);return Ie&&!we&&l(Ie,ke),function(){return h(Ie,ke)}},[Se.current,we]),M.createElement(C,{ref:pe},Ve?M.cloneElement(Te,{ref:et}):Te)}var E="rc-observer-key";function f(xe){var Te=xe.children,we=Object(P.a)(Te);return we.map(function(Se,pe){var oe=(Se==null?void 0:Se.key)||"".concat(E,"-").concat(pe);return M.createElement(k,Object(re.a)({},xe,{key:oe}),Se)})}f.Collection=p;var m=f,d=se("bT9E"),a=se("TSYQ"),x=se.n(a),v=`
min-height:0 !important;
max-height:none !important;
height:0 !important;
visibility:hidden !important;
overflow:hidden !important;
position:absolute !important;
z-index:-1000 !important;
top:0 !important;
right:0 !important
`,T=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],I={},G;function V(xe){var Te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,we=xe.getAttribute("id")||xe.getAttribute("data-reactid")||xe.getAttribute("name");if(Te&&I[we])return I[we];var Se=window.getComputedStyle(xe),pe=Se.getPropertyValue("box-sizing")||Se.getPropertyValue("-moz-box-sizing")||Se.getPropertyValue("-webkit-box-sizing"),oe=parseFloat(Se.getPropertyValue("padding-bottom"))+parseFloat(Se.getPropertyValue("padding-top")),De=parseFloat(Se.getPropertyValue("border-bottom-width"))+parseFloat(Se.getPropertyValue("border-top-width")),Ve=T.map(function(et){return"".concat(et,":").concat(Se.getPropertyValue(et))}).join(";"),ze={sizingStyle:Ve,paddingSize:oe,borderSize:De,boxSizing:pe};return Te&&we&&(I[we]=ze),ze}function Q(xe){var Te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,we=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Se=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)),xe.getAttribute("wrap")?G.setAttribute("wrap",xe.getAttribute("wrap")):G.removeAttribute("wrap");var pe=V(xe,Te),oe=pe.paddingSize,De=pe.borderSize,Ve=pe.boxSizing,ze=pe.sizingStyle;G.setAttribute("style","".concat(ze,";").concat(v)),G.value=xe.value||xe.placeholder||"";var et=Number.MIN_SAFE_INTEGER,Je=Number.MAX_SAFE_INTEGER,ke=G.scrollHeight,Ie;if(Ve==="border-box"?ke+=De:Ve==="content-box"&&(ke-=oe),we!==null||Se!==null){G.value=" ";var He=G.scrollHeight-oe;we!==null&&(et=He*we,Ve==="border-box"&&(et=et+oe+De),ke=Math.max(et,ke)),Se!==null&&(Je=He*Se,Ve==="border-box"&&(Je=Je+oe+De),Ie=ke>Je?"":"hidden",ke=Math.min(Je,ke))}return{height:ke,minHeight:et,maxHeight:Je,overflowY:Ie,resize:"none"}}var z=se("Gytx"),j=se.n(z),q;(function(xe){xe[xe.NONE=0]="NONE",xe[xe.RESIZING=1]="RESIZING",xe[xe.RESIZED=2]="RESIZED"})(q||(q={}));var ie=function(xe){Object(Y.a)(we,xe);var Te=Object(N.a)(we);function we(Se){var pe;return Object(Z.a)(this,we),pe=Te.call(this,Se),pe.nextFrameActionId=void 0,pe.resizeFrameId=void 0,pe.textArea=void 0,pe.saveTextArea=function(oe){pe.textArea=oe},pe.handleResize=function(oe){var De=pe.state.resizeStatus,Ve=pe.props,ze=Ve.autoSize,et=Ve.onResize;if(De!==q.NONE)return;typeof et=="function"&&et(oe),ze&&pe.resizeOnNextFrame()},pe.resizeOnNextFrame=function(){cancelAnimationFrame(pe.nextFrameActionId),pe.nextFrameActionId=requestAnimationFrame(pe.resizeTextarea)},pe.resizeTextarea=function(){var oe=pe.props.autoSize;if(!oe||!pe.textArea)return;var De=oe.minRows,Ve=oe.maxRows,ze=Q(pe.textArea,!1,De,Ve);pe.setState({textareaStyles:ze,resizeStatus:q.RESIZING},function(){cancelAnimationFrame(pe.resizeFrameId),pe.resizeFrameId=requestAnimationFrame(function(){pe.setState({resizeStatus:q.RESIZED},function(){pe.resizeFrameId=requestAnimationFrame(function(){pe.setState({resizeStatus:q.NONE}),pe.fixFirefoxAutoScroll()})})})})},pe.renderTextArea=function(){var oe=pe.props,De=oe.prefixCls,Ve=De===void 0?"rc-textarea":De,ze=oe.autoSize,et=oe.onResize,Je=oe.className,ke=oe.disabled,Ie=pe.state,He=Ie.textareaStyles,Ge=Ie.resizeStatus,je=Object(d.a)(pe.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),_e=x()(Ve,Je,Object(U.a)({},"".concat(Ve,"-disabled"),ke));"value"in je&&(je.value=je.value||"");var Be=Object(H.a)(Object(H.a)(Object(H.a)({},pe.props.style),He),Ge===q.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return M.createElement(m,{onResize:pe.handleResize,disabled:!(ze||et)},M.createElement("textarea",Object(re.a)({},je,{className:_e,style:Be,ref:pe.saveTextArea})))},pe.state={textareaStyles:{},resizeStatus:q.NONE},pe}return Object(D.a)(we,[{key:"componentDidUpdate",value:function(pe){(pe.value!==this.props.value||!j()(pe.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var pe=this.textArea.selectionStart,oe=this.textArea.selectionEnd;this.textArea.setSelectionRange(pe,oe)}}catch(De){}}},{key:"render",value:function(){return this.renderTextArea()}}]),we}(M.Component),ce=ie,ve=function(xe){Object(Y.a)(we,xe);var Te=Object(N.a)(we);function we(Se){var pe;Object(Z.a)(this,we),pe=Te.call(this,Se),pe.resizableTextArea=void 0,pe.focus=function(){pe.resizableTextArea.textArea.focus()},pe.saveTextArea=function(De){pe.resizableTextArea=De},pe.handleChange=function(De){var Ve=pe.props.onChange;pe.setValue(De.target.value,function(){pe.resizableTextArea.resizeTextarea()}),Ve&&Ve(De)},pe.handleKeyDown=function(De){var Ve=pe.props,ze=Ve.onPressEnter,et=Ve.onKeyDown;De.keyCode===13&&ze&&ze(De),et&&et(De)};var oe=typeof Se.value=="undefined"||Se.value===null?Se.defaultValue:Se.value;return pe.state={value:oe},pe}return Object(D.a)(we,[{key:"setValue",value:function(pe,oe){"value"in this.props||this.setState({value:pe},oe)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return M.createElement(ce,Object(re.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(pe){return"value"in pe?{value:pe.value}:null}}]),we}(M.Component),Oe=pt.default=ve},ZpRC:function(wt,pt,se){"use strict";function re(y){return typeof y=="object"&&y!=null&&y.nodeType===1}function Z(y,A){return(!A||y!=="hidden")&&y!=="visible"&&y!=="clip"}function D(y,A){if(y.clientHeight<y.scrollHeight||y.clientWidth<y.scrollWidth){var R=getComputedStyle(y,null);return Z(R.overflowY,A)||Z(R.overflowX,A)||function(L){var w=function(b){if(!b.ownerDocument||!b.ownerDocument.defaultView)return null;try{return b.ownerDocument.defaultView.frameElement}catch(u){return null}}(L);return!!w&&(w.clientHeight<L.scrollHeight||w.clientWidth<L.scrollWidth)}(y)}return!1}function Y(y,A,R,L,w,b,u,o){return b<y&&u>A||b>y&&u<A?0:b<=y&&o<=R||u>=A&&o>=R?b-y-L:u>A&&o<R||b<y&&o>R?u-A+w:0}var N=function(y,A){var R=window,L=A.scrollMode,w=A.block,b=A.inline,u=A.boundary,o=A.skipOverflowHiddenElements,l=typeof u=="function"?u:function(He){return He!==u};if(!re(y))throw new TypeError("Invalid target");for(var h=document.scrollingElement||document.documentElement,C=[],g=y;re(g)&&l(g);){if((g=g.parentElement)===h){C.push(g);break}g!=null&&g===document.body&&D(g)&&!D(document.documentElement)||g!=null&&D(g,o)&&C.push(g)}for(var p=R.visualViewport?R.visualViewport.width:innerWidth,k=R.visualViewport?R.visualViewport.height:innerHeight,E=window.scrollX||pageXOffset,f=window.scrollY||pageYOffset,m=y.getBoundingClientRect(),d=m.height,a=m.width,x=m.top,v=m.right,T=m.bottom,I=m.left,G=w==="start"||w==="nearest"?x:w==="end"?T:x+d/2,V=b==="center"?I+a/2:b==="end"?v:I,Q=[],z=0;z<C.length;z++){var j=C[z],q=j.getBoundingClientRect(),ie=q.height,ce=q.width,ve=q.top,Oe=q.right,xe=q.bottom,Te=q.left;if(L==="if-needed"&&x>=0&&I>=0&&T<=k&&v<=p&&x>=ve&&T<=xe&&I>=Te&&v<=Oe)return Q;var we=getComputedStyle(j),Se=parseInt(we.borderLeftWidth,10),pe=parseInt(we.borderTopWidth,10),oe=parseInt(we.borderRightWidth,10),De=parseInt(we.borderBottomWidth,10),Ve=0,ze=0,et="offsetWidth"in j?j.offsetWidth-j.clientWidth-Se-oe:0,Je="offsetHeight"in j?j.offsetHeight-j.clientHeight-pe-De:0;if(h===j)Ve=w==="start"?G:w==="end"?G-k:w==="nearest"?Y(f,f+k,k,pe,De,f+G,f+G+d,d):G-k/2,ze=b==="start"?V:b==="center"?V-p/2:b==="end"?V-p:Y(E,E+p,p,Se,oe,E+V,E+V+a,a),Ve=Math.max(0,Ve+f),ze=Math.max(0,ze+E);else{Ve=w==="start"?G-ve-pe:w==="end"?G-xe+De+Je:w==="nearest"?Y(ve,xe,ie,pe,De+Je,G,G+d,d):G-(ve+ie/2)+Je/2,ze=b==="start"?V-Te-Se:b==="center"?V-(Te+ce/2)+et/2:b==="end"?V-Oe+oe+et:Y(Te,Oe,ce,Se,oe+et,V,V+a,a);var ke=j.scrollLeft,Ie=j.scrollTop;G+=Ie-(Ve=Math.max(0,Math.min(Ie+Ve,j.scrollHeight-ie+Je))),V+=ke-(ze=Math.max(0,Math.min(ke+ze,j.scrollWidth-ce+et)))}Q.push({el:j,top:Ve,left:ze})}return Q};function M(y){return y===Object(y)&&Object.keys(y).length!==0}function H(y,A){A===void 0&&(A="auto");var R="scrollBehavior"in document.body.style;y.forEach(function(L){var w=L.el,b=L.top,u=L.left;w.scroll&&R?w.scroll({top:b,left:u,behavior:A}):(w.scrollTop=b,w.scrollLeft=u)})}function U(y){return y===!1?{block:"end",inline:"nearest"}:M(y)?y:{block:"start",inline:"nearest"}}function P(y,A){var R=!y.ownerDocument.documentElement.contains(y);if(M(A)&&typeof A.behavior=="function")return A.behavior(R?[]:N(y,A));if(R)return;var L=U(A);return H(N(y,L),L.behavior)}var _=pt.a=P},bT9E:function(wt,pt,se){"use strict";se.d(pt,"a",function(){return Z});var re=se("VTBJ");function Z(D,Y){var N=Object(re.a)({},D);return Array.isArray(Y)&&Y.forEach(function(M){delete N[M]}),N}},c5Ni:function(wt,pt,se){},dejd:function(wt,pt,se){},dmUQ:function(wt,pt,se){"use strict";var re=se("Ff2n"),Z=se("rePB"),D=se("1OyB"),Y=se("vuIU"),N=se("Ji7U"),M=se("md7G"),H=se("foSv"),U=se("q1tI"),P=se.n(U),_=se("TSYQ"),y=se.n(_),A=se("4IlW");function R(d,a){var x=Object.keys(d);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(d);a&&(v=v.filter(function(T){return Object.getOwnPropertyDescriptor(d,T).enumerable})),x.push.apply(x,v)}return x}function L(d){for(var a=1;a<arguments.length;a++){var x=arguments[a]!=null?arguments[a]:{};a%2?R(Object(x),!0).forEach(function(v){Object(Z.a)(d,v,x[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(x)):R(Object(x)).forEach(function(v){Object.defineProperty(d,v,Object.getOwnPropertyDescriptor(x,v))})}return d}function w(d){var a=b();return function(){var v=Object(H.a)(d),T;if(a){var I=Object(H.a)(this).constructor;T=Reflect.construct(v,arguments,I)}else T=v.apply(this,arguments);return Object(M.a)(this,T)}}function b(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(d){return!1}}function u(){}function o(d){d.preventDefault()}var l=function(a){return a.replace(/[^\w.-]+/g,"")},h=200,C=600,g=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,p=function(a){return a!=null},k=function(a,x){return x===a||typeof x=="number"&&typeof a=="number"&&isNaN(x)&&isNaN(a)},E=function(d){Object(N.a)(x,d);var a=w(x);function x(v){var T;Object(D.a)(this,x),T=a.call(this,v),T.onKeyDown=function(V){var Q=T.props,z=Q.onKeyDown,j=Q.onPressEnter;if(V.keyCode===A.a.UP){var q=T.getRatio(V);T.up(V,q,null),T.stop()}else if(V.keyCode===A.a.DOWN){var ie=T.getRatio(V);T.down(V,ie,null),T.stop()}else V.keyCode===A.a.ENTER&&j&&j(V);if(T.recordCursorPosition(),T.lastKeyCode=V.keyCode,z){for(var ce=arguments.length,ve=new Array(ce>1?ce-1:0),Oe=1;Oe<ce;Oe++)ve[Oe-1]=arguments[Oe];z.apply(void 0,[V].concat(ve))}},T.onKeyUp=function(V){var Q=T.props.onKeyUp;if(T.stop(),T.recordCursorPosition(),Q){for(var z=arguments.length,j=new Array(z>1?z-1:0),q=1;q<z;q++)j[q-1]=arguments[q];Q.apply(void 0,[V].concat(j))}},T.onChange=function(V){var Q=T.props.onChange;T.state.focused&&(T.inputting=!0),T.rawInput=T.props.parser(T.getValueFromEvent(V)),T.setState({inputValue:T.rawInput}),Q(T.toNumber(T.rawInput))},T.onMouseUp=function(){var V=T.props.onMouseUp;T.recordCursorPosition(),V&&V.apply(void 0,arguments)},T.onFocus=function(){var V;T.setState({focused:!0}),(V=T.props).onFocus.apply(V,arguments)},T.onBlur=function(){var V=T.props.onBlur;T.inputting=!1,T.setState({focused:!1});var Q=T.getCurrentValidValue(T.state.inputValue),z=T.setValue(Q,u);if(V){var j=T.input.value,q=T.getInputDisplayValue({focus:!1,value:z});T.input.value=q&&Number(q),V.apply(void 0,arguments),T.input.value=j}},T.getRatio=function(V){var Q=1;return V.metaKey||V.ctrlKey?Q=.1:V.shiftKey&&(Q=10),Q},T.getFullNum=function(V){return isNaN(V)?V:/e/i.test(String(V))?Number(V).toFixed(18).replace(/\.?0+$/,""):V},T.getPrecision=function(V){if(p(T.props.precision))return T.props.precision;var Q=String(V);if(Q.indexOf("e-")>=0)return parseInt(Q.slice(Q.indexOf("e-")+2),10);var z=0;return Q.indexOf(".")>=0&&(z=Q.length-Q.indexOf(".")-1),z},T.getInputDisplayValue=function(V){var Q=V||T.state,z=Q.focused,j=Q.inputValue,q=Q.value,ie;z?ie=j:ie=T.toPrecisionAsStep(q),ie==null&&(ie="");var ce=T.formatWrapper(ie);return p(T.props.decimalSeparator)&&(ce=ce.toString().replace(".",T.props.decimalSeparator)),ce},T.recordCursorPosition=function(){try{T.cursorStart=T.input.selectionStart,T.cursorEnd=T.input.selectionEnd,T.currentValue=T.input.value,T.cursorBefore=T.input.value.substring(0,T.cursorStart),T.cursorAfter=T.input.value.substring(T.cursorEnd)}catch(V){}},T.restoreByAfter=function(V){if(V===void 0)return!1;var Q=T.input.value,z=Q.lastIndexOf(V);if(z===-1)return!1;var j=T.cursorBefore.length;return T.lastKeyCode===A.a.DELETE&&T.cursorBefore.charAt(j-1)===V[0]?(T.fixCaret(j,j),!0):z+V.length===Q.length?(T.fixCaret(z,z),!0):!1},T.partRestoreByAfter=function(V){return V===void 0?!1:Array.prototype.some.call(V,function(Q,z){var j=V.substring(z);return T.restoreByAfter(j)})},T.isNotCompleteNumber=function(V){return isNaN(V)||V===""||V===null||V&&V.toString().indexOf(".")===V.toString().length-1},T.stop=function(){T.autoStepTimer&&clearTimeout(T.autoStepTimer)},T.down=function(V,Q,z){T.pressingUpOrDown=!0,T.step("down",V,Q,z)},T.up=function(V,Q,z){T.pressingUpOrDown=!0,T.step("up",V,Q,z)},T.saveInput=function(V){T.input=V};var I=v.value;I===void 0&&(I=v.defaultValue),T.state={focused:v.autoFocus};var G=T.getValidValue(T.toNumber(I));return T.state=L(L({},T.state),{},{inputValue:T.toPrecisionAsStep(G),value:G}),T}return Object(Y.a)(x,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(T){var I=this.props,G=I.value,V=I.onChange,Q=I.max,z=I.min,j=this.state.focused;if(T){if(!k(T.value,G)||!k(T.max,Q)||!k(T.min,z)){var q=j?G:this.getValidValue(G),ie;this.pressingUpOrDown?ie=q:this.inputting?ie=this.rawInput:ie=this.toPrecisionAsStep(q),this.setState({value:q,inputValue:ie})}var ce="value"in this.props?G:this.state.value;"max"in this.props&&T.max!==Q&&typeof ce=="number"&&ce>Q&&V&&V(Q),"min"in this.props&&T.min!==z&&typeof ce=="number"&&ce<z&&V&&V(z)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var ve=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===A.a.BACKSPACE?ve=this.cursorStart-1:this.lastKeyCode===A.a.DELETE&&(ve=this.cursorStart):ve=this.input.value.length,this.fixCaret(ve,ve)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case A.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case A.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(Oe){}if(this.lastKeyCode=null,!this.pressingUpOrDown)return;this.props.focusOnUpDown&&this.state.focused&&(document.activeElement!==this.input&&this.focus())}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(T){var I=T;return I===""?I="":this.isNotCompleteNumber(parseFloat(I))?I=this.state.value:I=this.getValidValue(I),this.toNumber(I)}},{key:"getValueFromEvent",value:function(T){var I=T.target.value.trim().replace(/。/g,".");return p(this.props.decimalSeparator)&&(I=I.replace(this.props.decimalSeparator,".")),I}},{key:"getValidValue",value:function(T){var I=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,V=parseFloat(T);return isNaN(V)?T:(V<I&&(V=I),V>G&&(V=G),V)}},{key:"setValue",value:function(T,I){var G=this.props.precision,V=this.isNotCompleteNumber(parseFloat(T))?null:parseFloat(T),Q=this.state.value,z=Q===void 0?null:Q,j=this.state.inputValue,q=j===void 0?null:j,ie=typeof V=="number"?V.toFixed(G):"".concat(V),ce=V!==z||ie!=="".concat(q);return"value"in this.props?(q=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:q},I)):this.setState({value:V,inputValue:this.toPrecisionAsStep(T)},I),ce&&this.props.onChange(V),V}},{key:"getMaxPrecision",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.props,V=G.precision,Q=G.step;if(p(V))return V;var z=this.getPrecision(I),j=this.getPrecision(Q),q=this.getPrecision(T);return T?Math.max(q,z+j):z+j}},{key:"getPrecisionFactor",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.getMaxPrecision(T,I);return Math.pow(10,G)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(T){return this.props.formatter?this.props.formatter(T):T}},{key:"toPrecisionAsStep",value:function(T){if(this.isNotCompleteNumber(T)||T==="")return T;var I=Math.abs(this.getMaxPrecision(T));return isNaN(I)?T.toString():Number(T).toFixed(I)}},{key:"toNumber",value:function(T){var I=this.props.precision,G=this.state.focused,V=T&&T.length>16&&G;return this.isNotCompleteNumber(T)||V?T:p(I)?Math.round(T*Math.pow(10,I))/Math.pow(10,I):Number(T)}},{key:"upStep",value:function(T,I){var G=this.props.step,V=this.getPrecisionFactor(T,I),Q=Math.abs(this.getMaxPrecision(T,I)),z=((V*T+V*G*I)/V).toFixed(Q);return this.toNumber(z)}},{key:"downStep",value:function(T,I){var G=this.props.step,V=this.getPrecisionFactor(T,I),Q=Math.abs(this.getMaxPrecision(T,I)),z=((V*T-V*G*I)/V).toFixed(Q);return this.toNumber(z)}},{key:"step",value:function(T,I){var G=this,V=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,Q=arguments.length>3?arguments[3]:void 0;this.stop(),I&&(I.persist(),I.preventDefault());var z=this.props;if(z.disabled)return;var j=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(j))return;var q=this["".concat(T,"Step")](j,V),ie=q>z.max||q<z.min;if(q>z.max?q=z.max:q<z.min&&(q=z.min),this.setValue(q,null),this.setState({focused:!0},function(){G.pressingUpOrDown=!1}),ie)return;this.autoStepTimer=setTimeout(function(){G[T](I,V,!0)},Q?h:C)}},{key:"fixCaret",value:function(T,I){if(T===void 0||I===void 0||!this.input||!this.input.value)return;try{var G=this.input.selectionStart,V=this.input.selectionEnd;(T!==G||I!==V)&&this.input.setSelectionRange(T,I)}catch(Q){}}},{key:"render",value:function(){var T,I=this.props,G=I.prefixCls,V=I.disabled,Q=I.readOnly,z=I.useTouch,j=I.autoComplete,q=I.upHandler,ie=I.downHandler,ce=I.className,ve=I.max,Oe=I.min,xe=I.style,Te=I.title,we=I.onMouseEnter,Se=I.onMouseLeave,pe=I.onMouseOver,oe=I.onMouseOut,De=I.required,Ve=I.onClick,ze=I.tabIndex,et=I.type,Je=I.placeholder,ke=I.id,Ie=I.inputMode,He=I.pattern,Ge=I.step,je=I.maxLength,_e=I.autoFocus,Be=I.name,$e=I.onPaste,qe=I.onInput,Qe=Object(re.a)(I,["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"]),Ze=this.state,ct=Ze.value,it=Ze.focused,rt=y()(G,(T={},Object(Z.a)(T,ce,!!ce),Object(Z.a)(T,"".concat(G,"-disabled"),V),Object(Z.a)(T,"".concat(G,"-focused"),it),T)),Ce={};Object.keys(Qe).forEach(function(ue){(ue.substr(0,5)==="data-"||ue.substr(0,5)==="aria-"||ue==="role")&&(Ce[ue]=Qe[ue])});var lt=!Q&&!V,nt=this.getInputDisplayValue(null),Ae=(ct||ct===0)&&(isNaN(ct)||Number(ct)>=ve),Fe=(ct||ct===0)&&(isNaN(ct)||Number(ct)<=Oe),ge=Ae||V||Q,de=Fe||V||Q,fe=y()("".concat(G,"-handler"),"".concat(G,"-handler-up"),Object(Z.a)({},"".concat(G,"-handler-up-disabled"),ge)),ee=y()("".concat(G,"-handler"),"".concat(G,"-handler-down"),Object(Z.a)({},"".concat(G,"-handler-down-disabled"),de)),te=z?{onTouchStart:ge?u:this.up,onTouchEnd:this.stop}:{onMouseDown:ge?u:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},ne=z?{onTouchStart:de?u:this.down,onTouchEnd:this.stop}:{onMouseDown:de?u:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return P.a.createElement("div",{className:rt,style:xe,title:Te,onMouseEnter:we,onMouseLeave:Se,onMouseOver:pe,onMouseOut:oe,onFocus:function(){return null},onBlur:function(){return null}},P.a.createElement("div",{className:"".concat(G,"-handler-wrap")},P.a.createElement("span",Object.assign({unselectable:"on"},te,{role:"button","aria-label":"Increase Value","aria-disabled":ge,className:fe}),q||P.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-up-inner"),onClick:o})),P.a.createElement("span",Object.assign({unselectable:"on"},ne,{role:"button","aria-label":"Decrease Value","aria-disabled":de,className:ee}),ie||P.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-down-inner"),onClick:o}))),P.a.createElement("div",{className:"".concat(G,"-input-wrap")},P.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":Oe,"aria-valuemax":ve,"aria-valuenow":ct,required:De,type:et,placeholder:Je,onPaste:$e,onClick:Ve,onMouseUp:this.onMouseUp,className:"".concat(G,"-input"),tabIndex:ze,autoComplete:j,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:lt?this.onKeyDown:u,onKeyUp:lt?this.onKeyUp:u,autoFocus:_e,maxLength:je,readOnly:Q,disabled:V,max:ve,min:Oe,step:Ge,name:Be,title:Te,id:ke,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(nt),pattern:He,inputMode:Ie,onInput:qe},Ce))))}}]),x}(P.a.Component);E.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:g,min:-g,step:1,style:{},onChange:u,onKeyDown:u,onPressEnter:u,onFocus:u,onBlur:u,parser:l,required:!1,autoComplete:"off"};var f=E,m=pt.a=f},kSUc:function(wt,pt,se){},lZu9:function(wt,pt,se){(function(re){re(se("VrN/"),se("1eCo"),se("8EBN"))})(function(re){"use strict";re.defineMode("markdown",function(Z,D){var Y=re.getMode(Z,"text/html"),N=Y.name=="null";function M(z){if(re.findModeByName){var j=re.findModeByName(z);j&&(z=j.mime||j.mimes[0])}var q=re.getMode(Z,z);return q.name=="null"?null:q}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 H={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 U in H)H.hasOwnProperty(U)&&D.tokenTypeOverrides[U]&&(H[U]=D.tokenTypeOverrides[U]);var P=/^([*\-_])(?:\s*\1){2,}\s*$/,_=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,y=/^\[(x| )\](?=\s)/i,A=D.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,R=/^ {0,3}(?:\={1,}|-{2,})\s*$/,L=/^[^#!\[\]*_\\<>` "'(~:]+/,w=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,b=/^\s*\[[^\]]+?\]:.*$/,u=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function l(z,j,q){return j.f=j.inline=q,q(z,j)}function h(z,j,q){return j.f=j.block=q,q(z,j)}function C(z){return!z||!/\S/.test(z.string)}function g(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==k){var j=N;if(!j){var q=re.innerMode(Y,z.htmlState);j=q.mode.name=="xml"&&q.state.tagStart===null&&!q.state.context&&q.state.tokenize.isInText}j&&(z.f=d,z.block=p,z.htmlState=null)}return z.trailingSpace=0,z.trailingSpaceNewLine=!1,z.prevLine=z.thisLine,z.thisLine={stream:null},null}function p(z,j){var q=z.column()===j.indentation,ie=C(j.prevLine.stream),ce=j.indentedCode,ve=j.prevLine.hr,Oe=j.list!==!1,xe=(j.listStack[j.listStack.length-1]||0)+3;j.indentedCode=!1;var Te=j.indentation;if(j.indentationDiff===null&&(j.indentationDiff=j.indentation,Oe)){for(j.list=null;Te<j.listStack[j.listStack.length-1];)j.listStack.pop(),j.listStack.length?j.indentation=j.listStack[j.listStack.length-1]:j.list=!1;j.list!==!1&&(j.indentationDiff=Te-j.listStack[j.listStack.length-1])}var we=!ie&&!ve&&!j.prevLine.header&&(!Oe||!ce)&&!j.prevLine.fencedCodeEnd,Se=(j.list===!1||ve||ie)&&j.indentation<=xe&&z.match(P),pe=null;if(j.indentationDiff>=4&&(ce||j.prevLine.fencedCodeEnd||j.prevLine.header||ie))return z.skipToEnd(),j.indentedCode=!0,H.code;if(z.eatSpace())return null;if(q&&j.indentation<=xe&&(pe=z.match(A))&&pe[1].length<=6)return j.quote=0,j.header=pe[1].length,j.thisLine.header=!0,D.highlightFormatting&&(j.formatting="header"),j.f=j.inline,f(j);if(j.indentation<=xe&&z.eat(">"))return j.quote=q?1:j.quote+1,D.highlightFormatting&&(j.formatting="quote"),z.eatSpace(),f(j);if(!Se&&!j.setext&&q&&j.indentation<=xe&&(pe=z.match(_))){var oe=pe[1]?"ol":"ul";return j.indentation=Te+z.current().length,j.list=!0,j.quote=0,j.listStack.push(j.indentation),j.em=!1,j.strong=!1,j.code=!1,j.strikethrough=!1,D.taskLists&&z.match(y,!1)&&(j.taskList=!0),j.f=j.inline,D.highlightFormatting&&(j.formatting=["list","list-"+oe]),f(j)}else{if(q&&j.indentation<=xe&&(pe=z.match(w,!0)))return j.quote=0,j.fencedEndRE=new RegExp(pe[1]+"+ *$"),j.localMode=D.fencedCodeBlockHighlighting&&M(pe[2]||D.fencedCodeBlockDefaultMode),j.localMode&&(j.localState=re.startState(j.localMode)),j.f=j.block=E,D.highlightFormatting&&(j.formatting="code-block"),j.code=-1,f(j);if(j.setext||(!we||!Oe)&&!j.quote&&j.list===!1&&!j.code&&!Se&&!b.test(z.string)&&(pe=z.lookAhead(1))&&(pe=pe.match(R)))return j.setext?(j.header=j.setext,j.setext=0,z.skipToEnd(),D.highlightFormatting&&(j.formatting="header")):(j.header=pe[0].charAt(0)=="="?1:2,j.setext=j.header),j.thisLine.header=!0,j.f=j.inline,f(j);if(Se)return z.skipToEnd(),j.hr=!0,j.thisLine.hr=!0,H.hr;if(z.peek()==="[")return l(z,j,I)}return l(z,j,j.inline)}function k(z,j){var q=Y.token(z,j.htmlState);if(!N){var ie=re.innerMode(Y,j.htmlState);(ie.mode.name=="xml"&&ie.state.tagStart===null&&!ie.state.context&&ie.state.tokenize.isInText||j.md_inside&&z.current().indexOf(">")>-1)&&(j.f=d,j.block=p,j.htmlState=null)}return q}function E(z,j){var q=j.listStack[j.listStack.length-1]||0,ie=j.indentation<q,ce=q+3;if(j.fencedEndRE&&j.indentation<=ce&&(ie||z.match(j.fencedEndRE))){D.highlightFormatting&&(j.formatting="code-block");var ve;return ie||(ve=f(j)),j.localMode=j.localState=null,j.block=p,j.f=d,j.fencedEndRE=null,j.code=0,j.thisLine.fencedCodeEnd=!0,ie?h(z,j,j.block):ve}else return j.localMode?j.localMode.token(z,j.localState):(z.skipToEnd(),H.code)}function f(z){var j=[];if(z.formatting){j.push(H.formatting),typeof z.formatting=="string"&&(z.formatting=[z.formatting]);for(var q=0;q<z.formatting.length;q++)j.push(H.formatting+"-"+z.formatting[q]),z.formatting[q]==="header"&&j.push(H.formatting+"-"+z.formatting[q]+"-"+z.header),z.formatting[q]==="quote"&&(!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=z.quote?j.push(H.formatting+"-"+z.formatting[q]+"-"+z.quote):j.push("error"))}if(z.taskOpen)return j.push("meta"),j.length?j.join(" "):null;if(z.taskClosed)return j.push("property"),j.length?j.join(" "):null;if(z.linkHref?j.push(H.linkHref,"url"):(z.strong&&j.push(H.strong),z.em&&j.push(H.em),z.strikethrough&&j.push(H.strikethrough),z.emoji&&j.push(H.emoji),z.linkText&&j.push(H.linkText),z.code&&j.push(H.code),z.image&&j.push(H.image),z.imageAltText&&j.push(H.imageAltText,"link"),z.imageMarker&&j.push(H.imageMarker)),z.header&&j.push(H.header,H.header+"-"+z.header),z.quote&&(j.push(H.quote),!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=z.quote?j.push(H.quote+"-"+z.quote):j.push(H.quote+"-"+D.maxBlockquoteDepth)),z.list!==!1){var ie=(z.listStack.length-1)%3;ie?ie===1?j.push(H.list2):j.push(H.list3):j.push(H.list1)}return z.trailingSpaceNewLine?j.push("trailing-space-new-line"):z.trailingSpace&&j.push("trailing-space-"+(z.trailingSpace%2?"a":"b")),j.length?j.join(" "):null}function m(z,j){return z.match(L,!0)?f(j):void 0}function d(z,j){var q=j.text(z,j);if(typeof q!="undefined")return q;if(j.list)return j.list=null,f(j);if(j.taskList){var ie=z.match(y,!0)[1]===" ";return ie?j.taskOpen=!0:j.taskClosed=!0,D.highlightFormatting&&(j.formatting="task"),j.taskList=!1,f(j)}if(j.taskOpen=!1,j.taskClosed=!1,j.header&&z.match(/^#+$/,!0))return D.highlightFormatting&&(j.formatting="header"),f(j);var ce=z.next();if(j.linkTitle){j.linkTitle=!1;var ve=ce;ce==="("&&(ve=")"),ve=(ve+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var Oe="^\\s*(?:[^"+ve+"\\\\]+|\\\\\\\\|\\\\.)"+ve;if(z.match(new RegExp(Oe),!0))return H.linkHref}if(ce==="`"){var xe=j.formatting;D.highlightFormatting&&(j.formatting="code"),z.eatWhile("`");var Te=z.current().length;if(j.code==0&&(!j.quote||Te==1))return j.code=Te,f(j);if(Te==j.code){var we=f(j);return j.code=0,we}else return j.formatting=xe,f(j)}else if(j.code)return f(j);if(ce==="\\"&&(z.next(),D.highlightFormatting)){var Se=f(j),pe=H.formatting+"-escape";return Se?Se+" "+pe:pe}if(ce==="!"&&z.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return j.imageMarker=!0,j.image=!0,D.highlightFormatting&&(j.formatting="image"),f(j);if(ce==="["&&j.imageMarker&&z.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return j.imageMarker=!1,j.imageAltText=!0,D.highlightFormatting&&(j.formatting="image"),f(j);if(ce==="]"&&j.imageAltText){D.highlightFormatting&&(j.formatting="image");var Se=f(j);return j.imageAltText=!1,j.image=!1,j.inline=j.f=x,Se}if(ce==="["&&!j.image)return j.linkText&&z.match(/^.*?\]/)||(j.linkText=!0,D.highlightFormatting&&(j.formatting="link")),f(j);if(ce==="]"&&j.linkText){D.highlightFormatting&&(j.formatting="link");var Se=f(j);return j.linkText=!1,j.inline=j.f=z.match(/\(.*?\)| ?\[.*?\]/,!1)?x:d,Se}if(ce==="<"&&z.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=a,D.highlightFormatting&&(j.formatting="link");var Se=f(j);return Se?Se+=" ":Se="",Se+H.linkInline}if(ce==="<"&&z.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=a,D.highlightFormatting&&(j.formatting="link");var Se=f(j);return Se?Se+=" ":Se="",Se+H.linkEmail}if(D.xml&&ce==="<"&&z.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var oe=z.string.indexOf(">",z.pos);if(oe!=-1){var De=z.string.substring(z.start,oe);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(De)&&(j.md_inside=!0)}return z.backUp(1),j.htmlState=re.startState(Y),h(z,j,k)}if(D.xml&&ce==="<"&&z.match(/^\/\w*?>/))return j.md_inside=!1,"tag";if(ce==="*"||ce==="_"){for(var Ve=1,ze=z.pos==1?" ":z.string.charAt(z.pos-2);Ve<3&&z.eat(ce);)Ve++;var et=z.peek()||" ",Je=!/\s/.test(et)&&(!u.test(et)||/\s/.test(ze)||u.test(ze)),ke=!/\s/.test(ze)&&(!u.test(ze)||/\s/.test(et)||u.test(et)),Ie=null,He=null;if(Ve%2&&(!j.em&&Je&&(ce==="*"||!ke||u.test(ze))?Ie=!0:j.em==ce&&ke&&(ce==="*"||!Je||u.test(et))&&(Ie=!1)),Ve>1&&(!j.strong&&Je&&(ce==="*"||!ke||u.test(ze))?He=!0:j.strong==ce&&ke&&(ce==="*"||!Je||u.test(et))&&(He=!1)),He!=null||Ie!=null){D.highlightFormatting&&(j.formatting=Ie==null?"strong":He==null?"em":"strong em"),Ie===!0&&(j.em=ce),He===!0&&(j.strong=ce);var we=f(j);return Ie===!1&&(j.em=!1),He===!1&&(j.strong=!1),we}}else if(ce===" "&&(z.eat("*")||z.eat("_"))){if(z.peek()===" ")return f(j);z.backUp(1)}if(D.strikethrough){if(ce==="~"&&z.eatWhile(ce)){if(j.strikethrough){D.highlightFormatting&&(j.formatting="strikethrough");var we=f(j);return j.strikethrough=!1,we}else if(z.match(/^[^\s]/,!1))return j.strikethrough=!0,D.highlightFormatting&&(j.formatting="strikethrough"),f(j)}else if(ce===" "&&z.match(/^~~/,!0)){if(z.peek()===" ")return f(j);z.backUp(2)}}if(D.emoji&&ce===":"&&z.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){j.emoji=!0,D.highlightFormatting&&(j.formatting="emoji");var Ge=f(j);return j.emoji=!1,Ge}return ce===" "&&(z.match(/^ +$/,!1)?j.trailingSpace++:j.trailingSpace&&(j.trailingSpaceNewLine=!0)),f(j)}function a(z,j){var q=z.next();if(q===">"){j.f=j.inline=d,D.highlightFormatting&&(j.formatting="link");var ie=f(j);return ie?ie+=" ":ie="",ie+H.linkInline}return z.match(/^[^>]+/,!0),H.linkInline}function x(z,j){if(z.eatSpace())return null;var q=z.next();return q==="("||q==="["?(j.f=j.inline=T(q==="("?")":"]"),D.highlightFormatting&&(j.formatting="link-string"),j.linkHref=!0,f(j)):"error"}var v={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function T(z){return function(j,q){var ie=j.next();if(ie===z){q.f=q.inline=d,D.highlightFormatting&&(q.formatting="link-string");var ce=f(q);return q.linkHref=!1,ce}return j.match(v[z]),q.linkHref=!0,f(q)}}function I(z,j){return z.match(/^([^\]\\]|\\.)*\]:/,!1)?(j.f=G,z.next(),D.highlightFormatting&&(j.formatting="link"),j.linkText=!0,f(j)):l(z,j,d)}function G(z,j){if(z.match(/^\]:/,!0)){j.f=j.inline=V,D.highlightFormatting&&(j.formatting="link");var q=f(j);return j.linkText=!1,q}return z.match(/^([^\]\\]|\\.)+/,!0),H.linkText}function V(z,j){return z.eatSpace()?null:(z.match(/^[^\s]+/,!0),z.peek()===void 0?j.linkTitle=!0:z.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),j.f=j.inline=d,H.linkHref+" url")}var Q={startState:function(){return{f:p,prevLine:{stream:null},thisLine:{stream:null},block:p,htmlState:null,indentation:0,inline:d,text:m,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&&re.copyState(Y,z.htmlState),indentation:z.indentation,localMode:z.localMode,localState:z.localMode?re.copyState(z.localMode,z.localState):null,inline:z.inline,text:z.text,formatting:!1,linkText:z.linkText,linkTitle:z.linkTitle,linkHref:z.linkHref,code:z.code,em:z.em,strong:z.strong,strikethrough:z.strikethrough,emoji:z.emoji,header:z.header,setext:z.setext,hr:z.hr,taskList:z.taskList,list:z.list,listStack:z.listStack.slice(0),quote:z.quote,indentedCode:z.indentedCode,trailingSpace:z.trailingSpace,trailingSpaceNewLine:z.trailingSpaceNewLine,md_inside:z.md_inside,fencedEndRE:z.fencedEndRE}},token:function(z,j){if(j.formatting=!1,z!=j.thisLine.stream){if(j.header=0,j.hr=!1,z.match(/^\s*$/,!0))return g(j),null;if(j.prevLine=j.thisLine,j.thisLine={stream:z},j.taskList=!1,j.trailingSpace=0,j.trailingSpaceNewLine=!1,!j.localState&&(j.f=j.block,j.f!=k)){var q=z.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(j.indentation=q,j.indentationDiff=null,q>0)return null}}return j.f(z,j)},innerMode:function(z){return z.block==k?{state:z.htmlState,mode:Y}:z.localState?{state:z.localState,mode:z.localMode}:{state:z,mode:Q}},indent:function(z,j,q){return z.block==k&&Y.indent?Y.indent(z.htmlState,j,q):z.localState&&z.localMode.indent?z.localMode.indent(z.localState,j,q):re.Pass},blankLine:g,getType:f,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return Q},"xml"),re.defineMIME("text/markdown","markdown"),re.defineMIME("text/x-markdown","markdown")})},osHv:function(wt,pt,se){(function(re){re(se("VrN/"))})(function(re){"use strict";var Z=re.Pos;function D(u,o){return u.line-o.line||u.ch-o.ch}var Y="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",N=Y+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",M=new RegExp("<(/?)(["+Y+"]["+N+"]*)","g");function H(u,o,l,h){this.line=o,this.ch=l,this.cm=u,this.text=u.getLine(o),this.min=h?Math.max(h.from,u.firstLine()):u.firstLine(),this.max=h?Math.min(h.to-1,u.lastLine()):u.lastLine()}function U(u,o){var l=u.cm.getTokenTypeAt(Z(u.line,o));return l&&/\btag\b/.test(l)}function P(u){return u.line>=u.max?void 0:(u.ch=0,u.text=u.cm.getLine(++u.line),!0)}function _(u){return u.line<=u.min?void 0:(u.text=u.cm.getLine(--u.line),u.ch=u.text.length,!0)}function y(u){for(;;){var o=u.text.indexOf(">",u.ch);if(o==-1){if(P(u))continue;return}if(!U(u,o+1)){u.ch=o+1;continue}var l=u.text.lastIndexOf("/",o),h=l>-1&&!/\S/.test(u.text.slice(l+1,o));return u.ch=o+1,h?"selfClose":"regular"}}function A(u){for(;;){var o=u.ch?u.text.lastIndexOf("<",u.ch-1):-1;if(o==-1){if(_(u))continue;return}if(!U(u,o+1)){u.ch=o;continue}M.lastIndex=o,u.ch=o;var l=M.exec(u.text);if(l&&l.index==o)return l}}function R(u){for(;;){M.lastIndex=u.ch;var o=M.exec(u.text);if(!o){if(P(u))continue;return}if(!U(u,o.index+1)){u.ch=o.index+1;continue}return u.ch=o.index+o[0].length,o}}function L(u){for(;;){var o=u.ch?u.text.lastIndexOf(">",u.ch-1):-1;if(o==-1){if(_(u))continue;return}if(!U(u,o+1)){u.ch=o;continue}var l=u.text.lastIndexOf("/",o),h=l>-1&&!/\S/.test(u.text.slice(l+1,o));return u.ch=o+1,h?"selfClose":"regular"}}function w(u,o){for(var l=[];;){var h=R(u),C,g=u.line,p=u.ch-(h?h[0].length:0);if(!h||!(C=y(u)))return;if(C=="selfClose")continue;if(h[1]){for(var k=l.length-1;k>=0;--k)if(l[k]==h[2]){l.length=k;break}if(k<0&&(!o||o==h[2]))return{tag:h[2],from:Z(g,p),to:Z(u.line,u.ch)}}else l.push(h[2])}}function b(u,o){for(var l=[];;){var h=L(u);if(!h)return;if(h=="selfClose"){A(u);continue}var C=u.line,g=u.ch,p=A(u);if(!p)return;if(p[1])l.push(p[2]);else{for(var k=l.length-1;k>=0;--k)if(l[k]==p[2]){l.length=k;break}if(k<0&&(!o||o==p[2]))return{tag:p[2],from:Z(u.line,u.ch),to:Z(C,g)}}}}re.registerHelper("fold","xml",function(u,o){for(var l=new H(u,o.line,0);;){var h=R(l);if(!h||l.line!=o.line)return;var C=y(l);if(!C)return;if(!h[1]&&C!="selfClose"){var g=Z(l.line,l.ch),p=w(l,h[2]);return p&&D(p.from,g)>0?{from:g,to:p.from}:null}}}),re.findMatchingTag=function(u,o,l){var h=new H(u,o.line,o.ch,l);if(h.text.indexOf(">")==-1&&h.text.indexOf("<")==-1)return;var C=y(h),g=C&&Z(h.line,h.ch),p=C&&A(h);if(!C||!p||D(h,o)>0)return;var k={from:Z(h.line,h.ch),to:g,tag:p[2]};return C=="selfClose"?{open:k,close:null,at:"open"}:p[1]?{open:b(h,p[2]),close:k,at:"close"}:(h=new H(u,g.line,g.ch,l),{open:k,close:w(h,p[2]),at:"open"})},re.findEnclosingTag=function(u,o,l,h){for(var C=new H(u,o.line,o.ch,l);;){var g=b(C,h);if(!g)break;var p=new H(u,o.line,o.ch,l),k=w(p,g.tag);if(k)return{open:g,close:k}}},re.scanForClosingTag=function(u,o,l,h){var C=new H(u,o.line,o.ch,h?{from:0,to:h}:null);return w(C,l)}})},p5ED:function(wt,pt,se){"use strict";var re=se("+L6B"),Z=se("2/Rp"),D=se("5Dmo"),Y=se("3S7+"),N=se("k1fw"),M=se("tJVT"),H=se("q1tI"),U=se.n(H),P=se("vHTk"),_=se.n(P),y=se("yEEn"),A=se("ZW9T"),R=se("1vsH");pt.a=function(L){var w=L.name,b=L.data,u=L.theme,o=L.type,l=L.filename,h=L.monacoEditor,C=L.className,g=L.style,p=L.close,k=L.onClose,E=L.hasMask,f=Object(H.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),m=Object(M.a)(f,2),d=m[0],a=m[1],x=Object(H.useState)(""),v=Object(M.a)(x,2),T=v[0],I=v[1],G,V=1024*1024,Q=10*V,z=Object(H.useRef)();o==="office"&&(G=Object(R.T)(b).filesize,G>Q&&(o="other")),l&&(h.filename=l),Object(H.useEffect)(function(){var ie,ce,ve=(ie=document.cookie)===null||ie===void 0||((ce=ie.replace(/\s/g,""))===null||ce===void 0)?void 0:ce.split(";");ve==null||ve.map(function(Oe){var xe=Oe.split("=");xe[0]==="_educoder_session"&&I(xe[1])})},[]);var j=function(){if(b.startsWith("http")||b.startsWith("/")){q();return}Object(R.z)(l||"educoder",b,l)},q=function(){Object(R.x)(l||w,b)};return console.log("data:",b,"fileanme:",l," name:",w),U.a.createElement("div",{style:Object(N.a)({},g||{}),className:"".concat(E&&_.a.bgBlack," ").concat(o?_.a.wrp:"hide")},p&&U.a.createElement("div",{className:_.a.close,ref:z},U.a.createElement(Y.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return z.current}},U.a.createElement("span",{onClick:q},U.a.createElement("i",{className:"icon-quxiaozhiding"}))),U.a.createElement(Y.a,{title:"\u5173\u95ED",getPopupContainer:function(){return z.current}},U.a.createElement("span",{className:"",onClick:k},U.a.createElement("i",{className:"icon-guanbi1"})))),U.a.createElement("div",{className:"".concat(_.a[C]," ").concat(C," ").concat(_.a.monaco," ").concat(o==="txt"?"show":"hide")},o==="txt"&&U.a.createElement(A.b,h)),o==="audio"&&U.a.createElement("audio",{src:"".concat(b!=null&&b.startsWith("/")||(b==null?void 0:b.indexOf("https://"))>-1?b:"data:audio/mp3;base64,").concat(b),autoPlay:!0}),o==="video"&&U.a.createElement(U.a.Fragment,null,b!=null&&b.startsWith("/")?U.a.createElement("video",{controls:!0,src:"".concat(b),autoPlay:!0}):U.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(b),autoPlay:!0})),o==="html"&&U.a.createElement("iframe",{src:b+"&disposition=inline"}),o==="pdf"&&U.a.createElement("embed",{className:_.a.embed,src:b}),o==="image"&&U.a.createElement(U.a.Fragment,null,U.a.createElement("img",{src:"".concat(b!=null&&b.startsWith("/")||(b==null?void 0:b.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(b)})),o==="other"&&U.a.createElement("div",null,U.a.createElement(Z.a,{type:"primary",size:"large",onClick:j},U.a.createElement(y.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(o==="download"||o==="office")&&U.a.createElement(Z.a,{type:"primary",size:"large",onClick:j},U.a.createElement(y.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(wt,pt,se){},rUJ1:function(wt,pt){const se=/[&<>"']/,re=/[&<>"']/g,Z=/[<>"']|&(?!#?\w+;)/,D=/[<>"']|&(?!#?\w+;)/g,Y={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},N=E=>Y[E];function M(E,f){if(f){if(se.test(E))return E.replace(re,N)}else if(Z.test(E))return E.replace(D,N);return E}const H=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function U(E){return E.replace(H,(f,m)=>(m=m.toLowerCase(),m==="colon"?":":m.charAt(0)==="#"?m.charAt(1)==="x"?String.fromCharCode(parseInt(m.substring(2),16)):String.fromCharCode(+m.substring(1)):""))}const P=/(^|[^\[])\^/g;function _(E,f){E=E.source||E,f=f||"";const m={replace:(d,a)=>(a=a.source||a,a=a.replace(P,"$1"),E=E.replace(d,a),m),getRegex:()=>new RegExp(E,f)};return m}const y=/[^\w:]/g,A=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function R(E,f,m){if(E){let d;try{d=decodeURIComponent(U(m)).replace(y,"").toLowerCase()}catch(a){return null}if(d.indexOf("javascript:")===0||d.indexOf("vbscript:")===0||d.indexOf("data:")===0)return null}f&&!A.test(m)&&(m=o(f,m));try{m=encodeURI(m).replace(/%25/g,"%")}catch(d){return null}return m}const L={},w=/^[^:]+:\/*[^/]*$/,b=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(E,f){L[" "+E]||(w.test(E)?L[" "+E]=E+"/":L[" "+E]=g(E,"/",!0)),E=L[" "+E];const m=E.indexOf(":")===-1;return f.substring(0,2)==="//"?m?f:E.replace(b,"$1")+f:f.charAt(0)==="/"?m?f:E.replace(u,"$1")+f:E+f}const l={exec:function(){}};function h(E){let f=1,m,d;for(;f<arguments.length;f++){m=arguments[f];for(d in m)Object.prototype.hasOwnProperty.call(m,d)&&(E[d]=m[d])}return E}function C(E,f){const m=E.replace(/\|/g,(x,v,T)=>{let I=!1,G=v;for(;--G>=0&&T[G]==="\\";)I=!I;return I?"|":" |"}),d=m.split(/ \|/);let a=0;if(d.length>f)d.splice(f);else for(;d.length<f;)d.push("");for(;a<d.length;a++)d[a]=d[a].trim().replace(/\\\|/g,"|");return d}function g(E,f,m){const d=E.length;if(d===0)return"";let a=0;for(;a<d;){const x=E.charAt(d-a-1);if(x===f&&!m)a++;else if(x!==f&&m)a++;else break}return E.substr(0,d-a)}function p(E,f){if(E.indexOf(f[1])===-1)return-1;const m=E.length;let d=0,a=0;for(;a<m;a++)if(E[a]==="\\")a++;else if(E[a]===f[0])d++;else if(E[a]===f[1]&&(d--,d<0))return a;return-1}function k(E){E&&E.sanitize&&!E.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")}wt.exports={escape:M,unescape:U,edit:_,cleanUrl:R,resolveUrl:o,noopTest:l,merge:h,splitCells:C,rtrim:g,findClosingBracket:p,checkSanitizeDeprecation:k}},ulZh:function(wt,pt,se){typeof window!="undefined"&&function(Z,D){wt.exports=D()}(this,function(){return function(re){var Z={};function D(Y){if(Z[Y])return Z[Y].exports;var N=Z[Y]={i:Y,l:!1,exports:{}};return re[Y].call(N.exports,N,N.exports,D),N.l=!0,N.exports}return D.m=re,D.c=Z,D.d=function(Y,N,M){D.o(Y,N)||Object.defineProperty(Y,N,{enumerable:!0,get:M})},D.r=function(Y){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(Y,"__esModule",{value:!0})},D.t=function(Y,N){if(N&1&&(Y=D(Y)),N&8)return Y;if(N&4&&typeof Y=="object"&&Y&&Y.__esModule)return Y;var M=Object.create(null);if(D.r(M),Object.defineProperty(M,"default",{enumerable:!0,value:Y}),N&2&&typeof Y!="string")for(var H in Y)D.d(M,H,function(U){return Y[U]}.bind(null,H));return M},D.n=function(Y){var N=Y&&Y.__esModule?function(){return Y.default}:function(){return Y};return D.d(N,"a",N),N},D.o=function(Y,N){return Object.prototype.hasOwnProperty.call(Y,N)},D.p="/dist/",D(D.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(re,Z,D){"use strict";var Y=Object.prototype.hasOwnProperty,N="~";function M(){}Object.create&&(M.prototype=Object.create(null),new M().__proto__||(N=!1));function H(y,A,R){this.fn=y,this.context=A,this.once=R||!1}function U(y,A,R,L,w){if(typeof R!="function")throw new TypeError("The listener must be a function");var b=new H(R,L||y,w),u=N?N+A:A;return y._events[u]?y._events[u].fn?y._events[u]=[y._events[u],b]:y._events[u].push(b):(y._events[u]=b,y._eventsCount++),y}function P(y,A){--y._eventsCount===0?y._events=new M:delete y._events[A]}function _(){this._events=new M,this._eventsCount=0}_.prototype.eventNames=function(){var A=[],R,L;if(this._eventsCount===0)return A;for(L in R=this._events)Y.call(R,L)&&A.push(N?L.slice(1):L);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(R)):A},_.prototype.listeners=function(A){var R=N?N+A:A,L=this._events[R];if(!L)return[];if(L.fn)return[L.fn];for(var w=0,b=L.length,u=new Array(b);w<b;w++)u[w]=L[w].fn;return u},_.prototype.listenerCount=function(A){var R=N?N+A:A,L=this._events[R];return L?L.fn?1:L.length:0},_.prototype.emit=function(A,R,L,w,b,u){var o=N?N+A:A;if(!this._events[o])return!1;var l=this._events[o],h=arguments.length,C,g;if(l.fn){l.once&&this.removeListener(A,l.fn,void 0,!0);switch(h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,R),!0;case 3:return l.fn.call(l.context,R,L),!0;case 4:return l.fn.call(l.context,R,L,w),!0;case 5:return l.fn.call(l.context,R,L,w,b),!0;case 6:return l.fn.call(l.context,R,L,w,b,u),!0}for(g=1,C=new Array(h-1);g<h;g++)C[g-1]=arguments[g];l.fn.apply(l.context,C)}else{var p=l.length,k;for(g=0;g<p;g++){l[g].once&&this.removeListener(A,l[g].fn,void 0,!0);switch(h){case 1:l[g].fn.call(l[g].context);break;case 2:l[g].fn.call(l[g].context,R);break;case 3:l[g].fn.call(l[g].context,R,L);break;case 4:l[g].fn.call(l[g].context,R,L,w);break;default:if(!C)for(k=1,C=new Array(h-1);k<h;k++)C[k-1]=arguments[k];l[g].fn.apply(l[g].context,C)}}}return!0},_.prototype.on=function(A,R,L){return U(this,A,R,L,!1)},_.prototype.once=function(A,R,L){return U(this,A,R,L,!0)},_.prototype.removeListener=function(A,R,L,w){var b=N?N+A:A;if(!this._events[b])return this;if(!R)return P(this,b),this;var u=this._events[b];if(u.fn)u.fn===R&&(!w||u.once)&&(!L||u.context===L)&&P(this,b);else{for(var o=0,l=[],h=u.length;o<h;o++)(u[o].fn!==R||w&&!u[o].once||L&&u[o].context!==L)&&l.push(u[o]);l.length?this._events[b]=l.length===1?l[0]:l:P(this,b)}return this},_.prototype.removeAllListeners=function(A){var R;return A?(R=N?N+A:A,this._events[R]&&P(this,R)):(this._events=new M,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=N,_.EventEmitter=_,re.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(re,Z,D){(function(Y){var N=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,M=/^([^\/?#]*)([^]*)$/,H=/(?:\/|^)\.(?=\/)/g,U=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(_,y,A){if(A=A||{},_=_.trim(),y=y.trim(),!y){if(!A.alwaysNormalize)return _;var R=P.parseURL(_);if(!R)throw new Error("Error trying to parse base URL.");return R.path=P.normalizePath(R.path),P.buildURLFromParts(R)}var L=P.parseURL(y);if(!L)throw new Error("Error trying to parse relative URL.");if(L.scheme)return A.alwaysNormalize?(L.path=P.normalizePath(L.path),P.buildURLFromParts(L)):y;var w=P.parseURL(_);if(!w)throw new Error("Error trying to parse base URL.");if(!w.netLoc&&w.path&&w.path[0]!=="/"){var b=M.exec(w.path);w.netLoc=b[1],w.path=b[2]}w.netLoc&&!w.path&&(w.path="/");var u={scheme:w.scheme,netLoc:L.netLoc,path:null,params:L.params,query:L.query,fragment:L.fragment};if(!L.netLoc&&(u.netLoc=w.netLoc,L.path[0]!=="/"))if(!L.path)u.path=w.path,L.params||(u.params=w.params,L.query||(u.query=w.query));else{var o=w.path,l=o.substring(0,o.lastIndexOf("/")+1)+L.path;u.path=P.normalizePath(l)}return u.path===null&&(u.path=A.alwaysNormalize?P.normalizePath(L.path):L.path),P.buildURLFromParts(u)},parseURL:function(_){var y=N.exec(_);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(H,"");_.length!==(_=_.replace(U,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};re.exports=P})(this)},"./node_modules/webworkify-webpack/index.js":function(re,Z,D){function Y(A){var R={};function L(b){if(R[b])return R[b].exports;var u=R[b]={i:b,l:!1,exports:{}};return A[b].call(u.exports,u,u.exports,L),u.l=!0,u.exports}L.m=A,L.c=R,L.i=function(b){return b},L.d=function(b,u,o){L.o(b,u)||Object.defineProperty(b,u,{configurable:!1,enumerable:!0,get:o})},L.r=function(b){Object.defineProperty(b,"__esModule",{value:!0})},L.n=function(b){var u=b&&b.__esModule?function(){return b.default}:function(){return b};return L.d(u,"a",u),u},L.o=function(b,u){return Object.prototype.hasOwnProperty.call(b,u)},L.p="/",L.oe=function(b){throw console.error(b),b};var w=L(L.s=ENTRY_MODULE);return w.default||w}var N="[\\.|\\-|\\+|\\w|/|@]+",M="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+N+").*?\\)";function H(A){return(A+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function U(A){return!isNaN(1*A)}function P(A,R,L){var w={};w[L]=[];var b=R.toString(),u=b.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return w;for(var o=u[1],l=new RegExp("(\\\\n|\\W)"+H(o)+M,"g"),h;h=l.exec(b);){if(h[3]==="dll-reference")continue;w[L].push(h[3])}for(l=new RegExp("\\("+H(o)+'\\("(dll-reference\\s('+N+'))"\\)\\)'+M,"g");h=l.exec(b);)A[h[2]]||(w[L].push(h[1]),A[h[2]]=D(h[1]).m),w[h[2]]=w[h[2]]||[],w[h[2]].push(h[4]);for(var C=Object.keys(w),g=0;g<C.length;g++)for(var p=0;p<w[C[g]].length;p++)U(w[C[g]][p])&&(w[C[g]][p]=1*w[C[g]][p]);return w}function _(A){var R=Object.keys(A);return R.reduce(function(L,w){return L||A[w].length>0},!1)}function y(A,R){for(var L={main:[R]},w={main:[]},b={main:{}};_(L);)for(var u=Object.keys(L),o=0;o<u.length;o++){var l=u[o],h=L[l],C=h.pop();if(b[l]=b[l]||{},b[l][C]||!A[l][C])continue;b[l][C]=!0,w[l]=w[l]||[],w[l].push(C);for(var g=P(A,A[l][C],l),p=Object.keys(g),k=0;k<p.length;k++)L[p[k]]=L[p[k]]||[],L[p[k]]=L[p[k]].concat(g[p[k]])}return w}re.exports=function(A,R){R=R||{};var L={main:D.m},w=R.all?{main:Object.keys(L.main)}:y(L,A),b="";Object.keys(w).filter(function(C){return C!=="main"}).forEach(function(C){for(var g=0;w[C][g];)g++;w[C].push(g),L[C][g]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",b=b+"var "+C+" = ("+Y.toString().replace("ENTRY_MODULE",JSON.stringify(g))+")({"+w[C].map(function(p){return""+JSON.stringify(p)+": "+L[C][p].toString()}).join(",")+`});
`}),b=b+"new (("+Y.toString().replace("ENTRY_MODULE",JSON.stringify(A))+")({"+w.main.map(function(C){return""+JSON.stringify(C)+": "+L.main[C].toString()}).join(",")+"}))(self);";var u=new window.Blob([b],{type:"text/javascript"});if(R.bare)return u;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,l=o.createObjectURL(u),h=new window.Worker(l);return h.objectURL=l,h}},"./src/config.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"hlsDefaultConfig",function(){return k}),D.d(Z,"mergeConfig",function(){return f}),D.d(Z,"enableStreamingMode",function(){return m});var Y=D("./src/controller/abr-controller.ts"),N=D("./src/controller/audio-stream-controller.ts"),M=D("./src/controller/audio-track-controller.ts"),H=D("./src/controller/subtitle-stream-controller.ts"),U=D("./src/controller/subtitle-track-controller.ts"),P=D("./src/controller/buffer-controller.ts"),_=D("./src/controller/timeline-controller.ts"),y=D("./src/controller/cap-level-controller.ts"),A=D("./src/controller/fps-controller.ts"),R=D("./src/controller/eme-controller.ts"),L=D("./src/controller/cmcd-controller.ts"),w=D("./src/utils/xhr-loader.ts"),b=D("./src/utils/fetch-loader.ts"),u=D("./src/utils/cues.ts"),o=D("./src/utils/mediakeys-helper.ts"),l=D("./src/utils/logger.ts");function h(){return h=Object.assign||function(d){for(var a=1;a<arguments.length;a++){var x=arguments[a];for(var v in x)Object.prototype.hasOwnProperty.call(x,v)&&(d[v]=x[v])}return d},h.apply(this,arguments)}function C(d,a){var x=Object.keys(d);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(d);a&&(v=v.filter(function(T){return Object.getOwnPropertyDescriptor(d,T).enumerable})),x.push.apply(x,v)}return x}function g(d){for(var a=1;a<arguments.length;a++){var x=arguments[a]!=null?arguments[a]:{};a%2?C(Object(x),!0).forEach(function(v){p(d,v,x[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(x)):C(Object(x)).forEach(function(v){Object.defineProperty(d,v,Object.getOwnPropertyDescriptor(x,v))})}return d}function p(d,a,x){return a in d?Object.defineProperty(d,a,{value:x,enumerable:!0,configurable:!0,writable:!0}):d[a]=x,d}var k=g(g({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:w.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Y.default,bufferController:P.default,capLevelController:y.default,fpsController:A.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},E()),{},{subtitleStreamController:H.SubtitleStreamController,subtitleTrackController:U.default,timelineController:_.TimelineController,audioStreamController:N.default,audioTrackController:M.default,emeController:R.default,cmcdController:L.default});function E(){return{cueHandler:u.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function f(d,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},d,a)}function m(d){var a=d.loader;if(a!==b.default&&a!==w.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var x=Object(b.fetchSupported)();x&&(d.loader=b.default,d.progressive=!0,d.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/polyfills/number.ts"),N=D("./src/utils/ewma-bandwidth-estimator.ts"),M=D("./src/events.ts"),H=D("./src/utils/buffer-helper.ts"),U=D("./src/errors.ts"),P=D("./src/types/loader.ts"),_=D("./src/utils/logger.ts");function y(L,w){for(var b=0;b<w.length;b++){var u=w[b];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function A(L,w,b){return w&&y(L.prototype,w),b&&y(L,b),L}var R=function(){function L(b){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=b;var u=b.config;this.bwEstimator=new N.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var w=L.prototype;return w.registerListeners=function(){var u=this.hls;u.on(M.Events.FRAG_LOADING,this.onFragLoading,this),u.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(M.Events.ERROR,this.onError,this)},w.unregisterListeners=function(){var u=this.hls;u.off(M.Events.FRAG_LOADING,this.onFragLoading,this),u.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(M.Events.ERROR,this.onError,this)},w.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},w.onFragLoading=function(u,o){var l=o.frag;if(l.type===P.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=l,this.partCurrent=(h=o.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},w.onLevelLoaded=function(u,o){var l=this.hls.config;o.details.live?this.bwEstimator.update(l.abrEwmaSlowLive,l.abrEwmaFastLive):this.bwEstimator.update(l.abrEwmaSlowVoD,l.abrEwmaFastVoD)},w._abandonRulesCheck=function(){var u=this.fragCurrent,o=this.partCurrent,l=this.hls,h=l.autoLevelEnabled,C=l.config,g=l.media;if(!u||!g)return;var p=o?o.stats:u.stats,k=o?o.duration:u.duration;if(p.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!h||g.paused||!g.playbackRate||!g.readyState)return;var E=performance.now()-p.loading.start,f=Math.abs(g.playbackRate);if(E<=500*k/f)return;var m=l.levels,d=l.minAutoLevel,a=m[u.level],x=p.total||Math.max(p.loaded,Math.round(k*a.maxBitrate/8)),v=Math.max(1,p.bwEstimate?p.bwEstimate/8:p.loaded*1e3/E),T=(x-p.loaded)/v,I=g.currentTime,G=(H.BufferHelper.bufferInfo(g,I,C.maxBufferHole).end-I)/f;if(G>=2*k/f||T<=G)return;var V=Number.POSITIVE_INFINITY,Q;for(Q=u.level-1;Q>d;Q--){var z=m[Q].maxBitrate;if(V=k*z/(8*.8*v),V<G)break}if(V>=T)return;var j=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+u.sn+(o?" part "+o.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+Q+`
Current BW estimate: `+(Object(Y.isFiniteNumber)(j)?(j/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+T.toFixed(3)+` s
Estimated load time for the next fragment: `+V.toFixed(3)+` s
Time to underbuffer: `+G.toFixed(3)+" s"),l.nextLoadLevel=Q,this.bwEstimator.sample(E,p.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),l.trigger(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:o,stats:p})},w.onFragLoaded=function(u,o){var l=o.frag,h=o.part;if(l.type===P.PlaylistLevelType.MAIN&&Object(Y.isFiniteNumber)(l.sn)){var C=h?h.stats:l.stats,g=h?h.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var p=this.hls.levels[l.level],k=(p.loaded?p.loaded.bytes:0)+C.loaded,E=(p.loaded?p.loaded.duration:0)+g;p.loaded={bytes:k,duration:E},p.realBitrate=Math.round(8*k/E)}if(l.bitrateTest){var f={stats:C,frag:l,part:h,id:l.type};this.onFragBuffered(M.Events.FRAG_BUFFERED,f),l.bitrateTest=!1}}},w.onFragBuffered=function(u,o){var l=o.frag,h=o.part,C=h?h.stats:l.stats;if(C.aborted)return;if(l.type!==P.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var g=C.parsing.end-C.loading.start;this.bwEstimator.sample(g,C.loaded),C.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=g/1e3:this.bitrateTestDelay=0},w.onError=function(u,o){switch(o.details){case U.ErrorDetails.FRAG_LOAD_ERROR:case U.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},w.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},w.getNextABRAutoLevel=function(){var u=this.fragCurrent,o=this.partCurrent,l=this.hls,h=l.maxAutoLevel,C=l.config,g=l.minAutoLevel,p=l.media,k=o?o.duration:u?u.duration:0,E=p?p.currentTime:0,f=p&&p.playbackRate!==0?Math.abs(p.playbackRate):1,m=this.bwEstimator?this.bwEstimator.getEstimate():C.abrEwmaDefaultEstimate,d=(H.BufferHelper.bufferInfo(p,E,C.maxBufferHole).end-E)/f,a=this.findBestLevel(m,g,h,d,C.abrBandWidthFactor,C.abrBandWidthUpFactor);if(a>=0)return a;_.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var x=k?Math.min(k,C.maxStarvationDelay):C.maxStarvationDelay,v=C.abrBandWidthFactor,T=C.abrBandWidthUpFactor;if(!d){var I=this.bitrateTestDelay;if(I){var G=k?Math.min(k,C.maxLoadingDelay):C.maxLoadingDelay;x=G-I,_.logger.trace("bitrate test took "+Math.round(1e3*I)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*x)+" ms"),v=T=1}}return a=this.findBestLevel(m,g,h,d+x,v,T),Math.max(a,0)},w.findBestLevel=function(u,o,l,h,C,g){for(var p,k=this.fragCurrent,E=this.partCurrent,f=this.lastLoadedFragLevel,m=this.hls.levels,d=m[f],a=!!(d!=null&&(p=d.details)!==null&&p!==void 0&&p.live),x=d==null?void 0:d.codecSet,v=E?E.duration:k?k.duration:0,T=l;T>=o;T--){var I=m[T];if(!I||x&&I.codecSet!==x)continue;var G=I.details,V=(E?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||v,Q=void 0;T<=f?Q=C*u:Q=g*u;var z=m[T].maxBitrate,j=z*V/Q;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+T+"/"+Math.round(Q)+"/"+z+"/"+V+"/"+h+"/"+j),Q>z&&(!j||a&&!this.bitrateTestDelay||j<h))return T}return-1},A(L,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,o=this.bwEstimator;if(u!==-1&&(!o||!o.canEstimate()))return u;var l=this.getNextABRAutoLevel();return u!==-1&&(l=Math.min(u,l)),l},set:function(u){this._nextAutoLevel=u}}]),L}();Z.default=R},"./src/controller/audio-stream-controller.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/polyfills/number.ts"),N=D("./src/controller/base-stream-controller.ts"),M=D("./src/events.ts"),H=D("./src/utils/buffer-helper.ts"),U=D("./src/controller/fragment-tracker.ts"),P=D("./src/types/level.ts"),_=D("./src/types/loader.ts"),y=D("./src/loader/fragment.ts"),A=D("./src/demux/chunk-cache.ts"),R=D("./src/demux/transmuxer-interface.ts"),L=D("./src/types/transmuxer.ts"),w=D("./src/controller/fragment-finders.ts"),b=D("./src/utils/discontinuities.ts"),u=D("./src/errors.ts"),o=D("./src/utils/logger.ts");function l(){return l=Object.assign||function(k){for(var E=1;E<arguments.length;E++){var f=arguments[E];for(var m in f)Object.prototype.hasOwnProperty.call(f,m)&&(k[m]=f[m])}return k},l.apply(this,arguments)}function h(k,E){k.prototype=Object.create(E.prototype),k.prototype.constructor=k,C(k,E)}function C(k,E){return C=Object.setPrototypeOf||function(m,d){return m.__proto__=d,m},C(k,E)}var g=100,p=function(k){h(E,k);function E(m,d){var a;return a=k.call(this,m,d,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var f=E.prototype;return f.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},f._registerListeners=function(){var d=this.hls;d.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.on(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(M.Events.ERROR,this.onError,this),d.on(M.Events.BUFFER_RESET,this.onBufferReset,this),d.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),d.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.on(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},f._unregisterListeners=function(){var d=this.hls;d.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.off(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(M.Events.ERROR,this.onError,this),d.off(M.Events.BUFFER_RESET,this.onBufferReset,this),d.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),d.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.off(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},f.onInitPtsFound=function(d,a){var x=a.frag,v=a.id,T=a.initPTS;if(v==="main"){var I=x.cc;this.initPTS[x.cc]=T,this.log("InitPTS for cc: "+I+" found from main: "+T),this.videoTrackCC=I,this.state===N.State.WAITING_INIT_PTS&&this.tick()}},f.startLoad=function(d){if(!this.levels){this.startPosition=d,this.state=N.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(g),this.fragLoadError=0,a>0&&d===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=N.State.IDLE):(this.loadedmetadata=!1,this.state=N.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=d,this.tick()},f.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_TRACK:{var d,a=this.levels,x=this.trackId,v=a==null||((d=a[x])===null||d===void 0)?void 0:d.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=N.State.WAITING_INIT_PTS}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var T,I=performance.now(),G=this.retryDate;(!G||I>=G||(T=this.media)!==null&&T!==void 0&&T.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=N.State.IDLE);break}case N.State.WAITING_INIT_PTS:{var V=this.waitingData;if(V){var Q=V.frag,z=V.part,j=V.cache,q=V.complete;if(this.initPTS[Q.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.FRAG_LOADING;var ie=j.flush(),ce={frag:Q,part:z,payload:ie,networkDetails:null};this._handleFragmentLoadProgress(ce),q&&k.prototype._handleFragmentLoadComplete.call(this,ce)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+Q.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ve=this.getLoadPosition(),Oe=H.BufferHelper.bufferInfo(this.mediaBuffer,ve,this.config.maxBufferHole),xe=Object(w.fragmentWithinToleranceTest)(Oe.end,this.config.maxFragLookUpTolerance,Q);xe<0&&(o.logger.log("Waiting fragment cc ("+Q.cc+") @ "+Q.start+" cancelled because another fragment at "+Oe.end+" is needed"),this.clearWaitingFragment())}}else this.state=N.State.IDLE}}this.onTickEnd()},f.clearWaitingFragment=function(){var d=this.waitingData;d&&(this.fragmentTracker.removeFragment(d.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.IDLE)},f.onTickEnd=function(){var d=this.media;if(!d||!d.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:d,x=a.buffered;!this.loadedmetadata&&x.length&&(this.loadedmetadata=!0),this.lastCurrentTime=d.currentTime},f.doTickIdle=function(){var d,a,x=this.hls,v=this.levels,T=this.media,I=this.trackId,G=x.config;if(!v||!v[I])return;if(!T&&(this.startFragRequested||!G.startFragPrefetch))return;var V=v[I],Q=V.details;if(!Q||Q.live&&this.levelLastLoaded!==I||this.waitForCdnTuneIn(Q)){this.state=N.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,y.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.AUDIO);if(z===null)return;var j=z.len,q=this.getMaxBufferLength(),ie=this.audioSwitch;if(j>=q&&!ie)return;if(!ie&&this._streamEnded(z,Q)){x.trigger(M.Events.BUFFER_EOS,{type:"audio"}),this.state=N.State.ENDED;return}var ce=Q.fragments,ve=ce[0].start,Oe=z.end;if(ie){var xe=this.getLoadPosition();Oe=xe,Q.PTSKnown&&xe<ve&&((z.end>ve||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),T.currentTime=ve+.05))}var Te=this.getNextFragment(Oe,Q);if(!Te){this.bufferFlushed=!0;return}((d=Te.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((a=Te.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Te,Q):this.loadFragment(Te,Q,Oe)},f.getMaxBufferLength=function(){var d=k.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN);return a===null?d:Math.max(d,a.len)},f.onMediaDetaching=function(){this.videoBuffer=null,k.prototype.onMediaDetaching.call(this)},f.onAudioTracksUpdated=function(d,a){var x=a.audioTracks;this.resetTransmuxer(),this.levels=x.map(function(v){return new P.Level(v)})},f.onAudioTrackSwitching=function(d,a){var x=!!a.url;this.trackId=a.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),x?this.setInterval(g):this.resetTransmuxer(),x?(this.audioSwitch=!0,this.state=N.State.IDLE):this.state=N.State.STOPPED,this.tick()},f.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},f.onLevelLoaded=function(d,a){this.mainDetails=a.details},f.onAudioTrackLoaded=function(d,a){var x,v=this.levels,T=a.details,I=a.id;if(!v){this.warn("Audio tracks were reset while loading level "+I);return}this.log("Track "+I+" loaded ["+T.startSN+","+T.endSN+"],duration:"+T.totalduration);var G=v[I],V=0;if(T.live||(x=G.details)!==null&&x!==void 0&&x.live){var Q=this.mainDetails;if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed||!Q)return;!G.details&&T.hasProgramDateTime&&Q.hasProgramDateTime?(Object(b.alignMediaPlaylistByPDT)(T,Q),V=T.fragments[0].start):V=this.alignPlaylists(T,G.details)}G.details=T,this.levelLastLoaded=I,!this.startFragRequested&&(this.mainDetails||!T.live)&&this.setStartPosition(G.details,V),this.state===N.State.WAITING_TRACK&&!this.waitForCdnTuneIn(T)&&(this.state=N.State.IDLE),this.tick()},f._handleFragmentLoadProgress=function(d){var a,x=d.frag,v=d.part,T=d.payload,I=this.config,G=this.trackId,V=this.levels;if(!V){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+x.sn+" of level "+x.level+" will not be buffered");return}var Q=V[G];console.assert(Q,"Audio track is defined on fragment load progress");var z=Q.details;console.assert(z,"Audio track details are defined on fragment load progress");var j=I.defaultAudioCodec||Q.audioCodec||"mp4a.40.2",q=this.transmuxer;q||(q=this.transmuxer=new R.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ie=this.initPTS[x.cc],ce=(a=x.initSegment)===null||a===void 0?void 0:a.data;if(ie!==void 0){var ve=!1,Oe=v?v.index:-1,xe=Oe!==-1,Te=new L.ChunkMetadata(x.level,x.sn,x.stats.chunkCount,T.byteLength,Oe,xe);q.push(T,ce,j,"",x,v,z.totalduration,ve,Te,ie)}else{o.logger.log("Unknown video PTS for cc "+x.cc+", waiting for video PTS before demuxing audio frag "+x.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+G);var we=this.waitingData=this.waitingData||{frag:x,part:v,cache:new A.default,complete:!1},Se=we.cache;Se.push(new Uint8Array(T)),this.waitingVideoCC=this.videoTrackCC,this.state=N.State.WAITING_INIT_PTS}},f._handleFragmentLoadComplete=function(d){if(this.waitingData){this.waitingData.complete=!0;return}k.prototype._handleFragmentLoadComplete.call(this,d)},f.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},f.onBufferCreated=function(d,a){var x=a.tracks.audio;x&&(this.mediaBuffer=x.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},f.onFragBuffered=function(d,a){var x=a.frag,v=a.part;if(x.type!==_.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(x)){this.warn("Fragment "+x.sn+(v?" p: "+v.index:"")+" of level "+x.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}x.sn!=="initSegment"&&(this.fragPrevious=x,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(x,v)},f.onError=function(d,a){switch(a.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,a);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==N.State.ERROR&&this.state!==N.State.STOPPED&&(this.state=a.fatal?N.State.ERROR:N.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var x=!0,v=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);v&&v.len>.5&&(x=!this.reduceMaxBufferLength(v.len)),x&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,k.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},f.onBufferFlushed=function(d,a){var x=a.type;x===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},f._handleTransmuxComplete=function(d){var a,x="audio",v=this.hls,T=d.remuxResult,I=d.chunkMeta,G=this.getCurrentContext(I);if(!G){this.warn("The loading context changed while buffering fragment "+I.sn+" of level "+I.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(I.level);return}var V=G.frag,Q=G.part,z=T.audio,j=T.text,q=T.id3,ie=T.initSegment;if(this.fragContextChanged(V))return;if(this.state=N.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),ie!=null&&ie.tracks&&(this._bufferInitSegment(ie.tracks,V,I),v.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:V,id:x,tracks:ie.tracks})),z){var ce=z.startPTS,ve=z.endPTS,Oe=z.startDTS,xe=z.endDTS;Q&&(Q.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:ce,endPTS:ve,startDTS:Oe,endDTS:xe}),V.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,ce,ve,Oe,xe),this.bufferFragmentData(z,V,Q,I)}if(q!=null&&(a=q.samples)!==null&&a!==void 0&&a.length){var Te=l({frag:V,id:x},q);v.trigger(M.Events.FRAG_PARSING_METADATA,Te)}if(j){var we=l({frag:V,id:x},j);v.trigger(M.Events.FRAG_PARSING_USERDATA,we)}},f._bufferInitSegment=function(d,a,x){if(this.state!==N.State.PARSING)return;d.video&&delete d.video;var v=d.audio;if(!v)return;v.levelCodec=v.codec,v.id="audio",this.log("Init audio buffer, container:"+v.container+", codecs[parsed]=["+v.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,d);var T=v.initSegment;if(T!=null&&T.byteLength){var I={type:"audio",frag:a,part:null,chunkMeta:x,parent:a.type,data:T};this.hls.trigger(M.Events.BUFFER_APPENDING,I)}this.tick()},f.loadFragment=function(d,a,x){var v=this.fragmentTracker.getState(d);this.fragCurrent=d,(this.audioSwitch||v===U.FragmentState.NOT_LOADED||v===U.FragmentState.PARTIAL)&&(d.sn==="initSegment"?this._loadInitSegment(d):a.live&&!Object(Y.isFiniteNumber)(this.initPTS[d.cc])?(this.log("Waiting for video PTS in continuity counter "+d.cc+" of live stream before loading audio fragment "+d.sn+" of level "+this.trackId),this.state=N.State.WAITING_INIT_PTS):(this.startFragRequested=!0,k.prototype.loadFragment.call(this,d,a,x)))},f.completeAudioSwitch=function(){var d=this.hls,a=this.media,x=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),k.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,d.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:x})},E}(N.default);Z.default=p},"./src/controller/audio-track-controller.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/events.ts"),N=D("./src/errors.ts"),M=D("./src/controller/base-playlist-controller.ts"),H=D("./src/types/loader.ts");function U(R,L){for(var w=0;w<L.length;w++){var b=L[w];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(R,b.key,b)}}function P(R,L,w){return L&&U(R.prototype,L),w&&U(R,w),R}function _(R,L){R.prototype=Object.create(L.prototype),R.prototype.constructor=R,y(R,L)}function y(R,L){return y=Object.setPrototypeOf||function(b,u){return b.__proto__=u,b},y(R,L)}var A=function(R){_(L,R);function L(b){var u;return u=R.call(this,b,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var w=L.prototype;return w.registerListeners=function(){var u=this.hls;u.on(Y.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(Y.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(Y.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(Y.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(Y.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(Y.Events.ERROR,this.onError,this)},w.unregisterListeners=function(){var u=this.hls;u.off(Y.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(Y.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(Y.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(Y.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(Y.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(Y.Events.ERROR,this.onError,this)},w.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,R.prototype.destroy.call(this)},w.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},w.onManifestParsed=function(u,o){this.tracks=o.audioTracks||[]},w.onAudioTrackLoaded=function(u,o){var l=o.id,h=o.details,C=this.tracksInGroup[l];if(!C){this.warn("Invalid audio track id "+l);return}var g=C.details;C.details=o.details,this.log("audioTrack "+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,o,g))},w.onLevelLoading=function(u,o){this.switchLevel(o.level)},w.onLevelSwitching=function(u,o){this.switchLevel(o.level)},w.switchLevel=function(u){var o=this.hls.levels[u];if(!(o!=null&&o.audioGroupIds))return;var l=o.audioGroupIds[o.urlId];if(this.groupId!==l){this.groupId=l;var h=this.tracks.filter(function(g){return!l||g.groupId===l});this.selectDefaultTrack&&!h.some(function(g){return g.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var C={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(Y.Events.AUDIO_TRACKS_UPDATED,C),this.selectInitialTrack()}},w.onError=function(u,o){if(R.prototype.onError.call(this,u,o),o.fatal||!o.context)return;o.context.type===H.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},w.setAudioTrack=function(u){var o=this.tracksInGroup;if(u<0||u>=o.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=o[this.trackId];this.log("Now switching to audio-track index "+u);var h=o[u],C=h.id,g=h.groupId,p=g===void 0?"":g,k=h.name,E=h.type,f=h.url;if(this.trackId=u,this.trackName=k,this.selectDefaultTrack=!1,this.hls.trigger(Y.Events.AUDIO_TRACK_SWITCHING,{id:C,groupId:p,name:k,type:E,url:f}),h.details&&!h.details.live)return;var m=this.switchParams(h.url,l==null?void 0:l.details);this.loadPlaylist(m)},w.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.length,"Initial audio track should be selected when tracks are known");var o=this.trackName,l=this.findTrackId(o)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},w.findTrackId=function(u){for(var o=this.tracksInGroup,l=0;l<o.length;l++){var h=o[l];if((!this.selectDefaultTrack||h.default)&&(!u||u===h.name))return h.id}return-1},w.loadPlaylist=function(u){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var l=o.id,h=o.groupId,C=o.url;if(u)try{C=u.addDirectives(C)}catch(g){this.warn("Could not construct new URL with HLS Delivery Directives: "+g)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(Y.Events.AUDIO_TRACK_LOADING,{url:C,id:l,groupId:h,deliveryDirectives:u||null})}},P(L,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),L}(M.default);Z.default=A},"./src/controller/base-playlist-controller.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return P});var Y=D("./src/polyfills/number.ts"),N=D("./src/types/level.ts"),M=D("./src/controller/level-helper.ts"),H=D("./src/utils/logger.ts"),U=D("./src/errors.ts"),P=function(){function _(A,R){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=H.logger.log.bind(H.logger,R+":"),this.warn=H.logger.warn.bind(H.logger,R+":"),this.hls=A}var y=_.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(R,L){L.fatal&&L.type===U.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(R,L){var w=L==null?void 0:L.renditionReports;if(w)for(var b=0;b<w.length;b++){var u=w[b],o=""+u.URI;if(o===R.substr(-o.length)){var l=parseInt(u["LAST-MSN"]),h=parseInt(u["LAST-PART"]);if(L&&this.hls.config.lowLatencyMode){var C=Math.min(L.age-L.partTarget,L.targetduration);h!==void 0&&C>L.partTarget&&(h+=1)}if(Object(Y.isFiniteNumber)(l))return new N.HlsUrlParameters(l,Object(Y.isFiniteNumber)(h)?h:void 0,N.HlsSkip.No)}}},y.loadPlaylist=function(R){},y.shouldLoadTrack=function(R){return this.canLoad&&R&&!!R.url&&(!R.details||R.details.live)},y.playlistLoaded=function(R,L,w){var b=this,u=L.details,o=L.stats,l=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(u.advancedDateTime=Date.now()-l,u.live||w!=null&&w.live){if(u.reloaded(w),w&&this.log("live playlist "+R+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),w&&u.fragments.length>0&&Object(M.mergeDetails)(w,u),!this.canLoad||!u.live)return;var h,C=void 0,g=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var p=this.hls.config.lowLatencyMode,k=u.lastPartSn,E=u.endSN,f=u.lastPartIndex,m=f!==-1,d=k===E,a=p?0:f;m?(C=d?E+1:k,g=d?a:f+1):C=E+1;var x=u.age,v=x+u.ageHeader,T=Math.min(v-u.partTarget,u.targetduration*1.5);if(T>0){if(w&&T>w.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+w.tuneInGoal+" to: "+T+" with playlist age: "+u.age),T=0;else{var I=Math.floor(T/u.targetduration);if(C+=I,g!==void 0){var G=Math.round(T%u.targetduration/u.partTarget);g+=G}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+x.toFixed(2)+"s goal: "+T+" skip sn "+I+" to part "+g)}u.tuneInGoal=T}if(h=this.getDeliveryDirectives(u,L.deliveryDirectives,C,g),p||!d){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(u,L.deliveryDirectives,C,g);var V=Object(M.computeReloadInterval)(u,o);C!==void 0&&u.canBlockReload&&(V-=u.partTarget||1),this.log("reload live playlist "+R+" in "+Math.round(V)+" ms"),this.timer=self.setTimeout(function(){return b.loadPlaylist(h)},V)}else this.clearTimer()},y.getDeliveryDirectives=function(R,L,w,b){var u=Object(N.getSkipValue)(R,w);return L!=null&&L.skip&&R.deltaUpdateFailed&&(w=L.msn,b=L.part,u=N.HlsSkip.No),new N.HlsUrlParameters(w,b,u)},y.retryLoadingOrFail=function(R){var L=this,w=this.hls.config,b=this.retryCount<w.levelLoadingMaxRetry;if(b){var u;if(this.retryCount++,R.details.indexOf("LoadTimeOut")>-1&&(u=R.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+R.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*w.levelLoadingRetryDelay,w.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return L.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+R.details+'"')}}else this.warn('cannot recover from error "'+R.details+'"'),this.clearTimer(),R.fatal=!0;return b},_}()},"./src/controller/base-stream-controller.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"State",function(){return E}),D.d(Z,"default",function(){return f});var Y=D("./src/polyfills/number.ts"),N=D("./src/task-loop.ts"),M=D("./src/controller/fragment-tracker.ts"),H=D("./src/utils/buffer-helper.ts"),U=D("./src/utils/logger.ts"),P=D("./src/events.ts"),_=D("./src/errors.ts"),y=D("./src/types/transmuxer.ts"),A=D("./src/utils/mp4-tools.ts"),R=D("./src/utils/discontinuities.ts"),L=D("./src/controller/fragment-finders.ts"),w=D("./src/controller/level-helper.ts"),b=D("./src/loader/fragment-loader.ts"),u=D("./src/crypt/decrypter.ts"),o=D("./src/utils/time-ranges.ts"),l=D("./src/types/loader.ts");function h(m,d){for(var a=0;a<d.length;a++){var x=d[a];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(m,x.key,x)}}function C(m,d,a){return d&&h(m.prototype,d),a&&h(m,a),m}function g(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function p(m,d){m.prototype=Object.create(d.prototype),m.prototype.constructor=m,k(m,d)}function k(m,d){return k=Object.setPrototypeOf||function(x,v){return x.__proto__=v,x},k(m,d)}var E={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"},f=function(m){p(d,m);function d(x,v,T){var I;return I=m.call(this)||this,I.hls=void 0,I.fragPrevious=null,I.fragCurrent=null,I.fragmentTracker=void 0,I.transmuxer=null,I._state=E.STOPPED,I.media=void 0,I.mediaBuffer=void 0,I.config=void 0,I.bitrateTest=!1,I.lastCurrentTime=0,I.nextLoadPosition=0,I.startPosition=0,I.loadedmetadata=!1,I.fragLoadError=0,I.retryDate=0,I.levels=null,I.fragmentLoader=void 0,I.levelLastLoaded=null,I.startFragRequested=!1,I.decrypter=void 0,I.initPTS=[],I.onvseeking=null,I.onvended=null,I.logPrefix="",I.log=void 0,I.warn=void 0,I.logPrefix=T,I.log=U.logger.log.bind(U.logger,T+":"),I.warn=U.logger.warn.bind(U.logger,T+":"),I.hls=x,I.fragmentLoader=new b.default(x.config),I.fragmentTracker=v,I.config=x.config,I.decrypter=new u.default(x,x.config),x.on(P.Events.KEY_LOADED,I.onKeyLoaded,g(I)),I}var a=d.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(v){},a.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=E.STOPPED},a._streamEnded=function(v,T){var I=this.fragCurrent,G=this.fragmentTracker;if(!T.live&&I&&I.sn===T.endSN&&!v.nextStart){var V=G.getState(I);return V===M.FragmentState.PARTIAL||V===M.FragmentState.OK}return!1},a.onMediaAttached=function(v,T){var I=this.media=this.mediaBuffer=T.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),I.addEventListener("seeking",this.onvseeking),I.addEventListener("ended",this.onvended);var G=this.config;this.levels&&G.autoStartLoad&&this.state===E.STOPPED&&this.startLoad(G.startPosition)},a.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&(v.removeEventListener("seeking",this.onvseeking),v.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 v=this.config,T=this.fragCurrent,I=this.media,G=this.mediaBuffer,V=this.state,Q=I?I.currentTime:0,z=H.BufferHelper.bufferInfo(G||I,Q,v.maxBufferHole);if(this.log("media seeking to "+(Object(Y.isFiniteNumber)(Q)?Q.toFixed(3):Q)+", state: "+V),V===E.ENDED)this.resetLoadingState();else if(T&&!z.len){var j=v.maxFragLookUpTolerance,q=T.start-j,ie=T.start+T.duration+j,ce=Q>ie;(Q<q||ce)&&(ce&&T.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),T.loader.abort()),this.resetLoadingState())}I&&(this.lastCurrentTime=Q),!this.loadedmetadata&&!z.len&&(this.nextLoadPosition=this.startPosition=Q),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(v,T){if(this.state!==E.KEY_LOADING||T.frag!==this.fragCurrent||!this.levels)return;this.state=E.IDLE;var I=this.levels[T.frag.level].details;I&&this.loadFragment(T.frag,I,T.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),m.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=E.STOPPED,this.hls.off(P.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,m.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(v,T){this.log("Loading key for "+v.sn+" of ["+T.startSN+"-"+T.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=E.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(P.Events.KEY_LOADING,{frag:v})},a.loadFragment=function(v,T,I){this._loadFragForPlayback(v,T,I)},a._loadFragForPlayback=function(v,T,I){var G=this,V=function(z){if(G.fragContextChanged(v)){G.warn("Fragment "+v.sn+(z.part?" p: "+z.part.index:"")+" of level "+v.level+" was dropped during download."),G.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,G._handleFragmentLoadProgress(z)};this._doFragLoad(v,T,I,V).then(function(Q){if(!Q)return;G.fragLoadError=0;var z=G.state;if(G.fragContextChanged(v)){(z===E.FRAG_LOADING||z===E.BACKTRACKING||!G.fragCurrent&&z===E.PARSING)&&(G.fragmentTracker.removeFragment(v),G.state=E.IDLE);return}if("payload"in Q&&(G.log("Loaded fragment "+v.sn+" of level "+v.level),G.hls.trigger(P.Events.FRAG_LOADED,Q),G.state===E.BACKTRACKING)){G.fragmentTracker.backtrack(v,Q),G.resetFragmentLoading(v);return}G._handleFragmentLoadComplete(Q)}).catch(function(Q){G.warn(Q),G.resetFragmentLoading(v)})},a.flushMainBuffer=function(v,T,I){if(I===void 0&&(I=null),!(v-T))return;var G={startOffset:v,endOffset:T,type:I};this.fragLoadError=0,this.hls.trigger(P.Events.BUFFER_FLUSHING,G)},a._loadInitSegment=function(v){var T=this;this._doFragLoad(v).then(function(I){if(!I||T.fragContextChanged(v)||!T.levels)throw new Error("init load aborted");return I}).then(function(I){var G=T.hls,V=I.payload,Q=v.decryptdata;if(V&&V.byteLength>0&&Q&&Q.key&&Q.iv&&Q.method==="AES-128"){var z=self.performance.now();return T.decrypter.webCryptoDecrypt(new Uint8Array(V),Q.key.buffer,Q.iv.buffer).then(function(j){var q=self.performance.now();return G.trigger(P.Events.FRAG_DECRYPTED,{frag:v,payload:j,stats:{tstart:z,tdecrypt:q}}),I.payload=j,I})}return I}).then(function(I){var G=T.fragCurrent,V=T.hls,Q=T.levels;if(!Q)throw new Error("init load aborted, missing levels");var z=Q[v.level].details;console.assert(z,"Level details are defined when init segment is loaded");var j=v.stats;T.state=E.IDLE,T.fragLoadError=0,v.data=new Uint8Array(I.payload),j.parsing.start=j.buffering.start=self.performance.now(),j.parsing.end=j.buffering.end=self.performance.now(),I.frag===G&&V.trigger(P.Events.FRAG_BUFFERED,{stats:j,frag:G,part:null,id:v.type}),T.tick()}).catch(function(I){T.warn(I),T.resetFragmentLoading(v)})},a.fragContextChanged=function(v){var T=this.fragCurrent;return!v||!T||v.level!==T.level||v.sn!==T.sn||v.urlId!==T.urlId},a.fragBufferedComplete=function(v,T){var I=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(T?" part: "+T.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+o.default.toString(H.BufferHelper.getBuffered(I))),this.state=E.IDLE,this.tick()},a._handleFragmentLoadComplete=function(v){var T=this.transmuxer;if(!T)return;var I=v.frag,G=v.part,V=v.partsLoaded,Q=!V||V.length===0||V.some(function(j){return!j}),z=new y.ChunkMetadata(I.level,I.sn,I.stats.chunkCount+1,0,G?G.index:-1,!Q);T.flush(z)},a._handleFragmentLoadProgress=function(v){},a._doFragLoad=function(v,T,I,G){var V=this;if(I===void 0&&(I=null),!this.levels)throw new Error("frag load aborted, missing levels");if(I=Math.max(v.start,I||0),this.config.lowLatencyMode&&T){var Q=T.partList;if(Q&&G){I>v.end&&T.fragmentHint&&(v=T.fragmentHint);var z=this.getNextPart(Q,v,I);if(z>-1){var j=Q[z];return this.log("Loading part sn: "+v.sn+" p: "+j.index+" cc: "+v.cc+" of playlist ["+T.startSN+"-"+T.endSN+"] parts [0-"+z+"-"+(Q.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(I.toFixed(3))),this.nextLoadPosition=j.start+j.duration,this.state=E.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:v,part:Q[z],targetBufferTime:I}),this.doFragPartsLoad(v,Q,z,G).catch(function(q){return V.handleFragLoadError(q)})}else if(!v.url||this.loadedEndOfParts(Q,I))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(T?"of ["+T.startSN+"-"+T.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(I.toFixed(3))),Object(Y.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=E.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:v,targetBufferTime:I}),this.fragmentLoader.load(v,G).catch(function(q){return V.handleFragLoadError(q)})},a.doFragPartsLoad=function(v,T,I,G){var V=this;return new Promise(function(Q,z){var j=[],q=function ie(ce){var ve=T[ce];V.fragmentLoader.loadPart(v,ve,G).then(function(Oe){j[ve.index]=Oe;var xe=Oe.part;V.hls.trigger(P.Events.FRAG_LOADED,Oe);var Te=T[ce+1];if(Te&&Te.fragment===v)ie(ce+1);else return Q({frag:v,part:xe,partsLoaded:j})}).catch(z)};q(I)})},a.handleFragLoadError=function(v){var T=v.data;return T&&T.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(T.frag,T.part):this.hls.trigger(P.Events.ERROR,T),null},a._handleTransmuxerFlush=function(v){var T=this.getCurrentContext(v);if(!T||this.state!==E.PARSING){this.fragCurrent||(this.state=E.IDLE);return}var I=T.frag,G=T.part,V=T.level,Q=self.performance.now();I.stats.parsing.end=Q,G&&(G.stats.parsing.end=Q),this.updateLevelTiming(I,G,V,v.partial)},a.getCurrentContext=function(v){var T=this.levels,I=v.level,G=v.sn,V=v.part;if(!T||!T[I])return this.warn("Levels object was unset while buffering fragment "+G+" of level "+I+". The current chunk will not be buffered."),null;var Q=T[I],z=V>-1?Object(w.getPartWith)(Q,G,V):null,j=z?z.fragment:Object(w.getFragmentWithSN)(Q,G,this.fragCurrent);return j?{frag:j,part:z,level:Q}:null},a.bufferFragmentData=function(v,T,I,G){if(!v||this.state!==E.PARSING)return;var V=v.data1,Q=v.data2,z=V;if(V&&Q&&(z=Object(A.appendUint8Array)(V,Q)),!z||!z.length)return;var j={type:v.type,frag:T,part:I,chunkMeta:G,parent:T.type,data:z};this.hls.trigger(P.Events.BUFFER_APPENDING,j),v.dropped&&v.independent&&!I&&this.flushBufferGap(T)},a.flushBufferGap=function(v){var T=this.media;if(!T)return;if(!H.BufferHelper.isBuffered(T,T.currentTime)){this.flushMainBuffer(0,v.start);return}var I=T.currentTime,G=H.BufferHelper.bufferInfo(T,I,0),V=v.duration,Q=Math.min(this.config.maxFragLookUpTolerance*2,V*.25),z=Math.max(Math.min(v.start-Q,G.end-Q),I+Q);v.start-z>Q&&this.flushMainBuffer(z,v.start)},a.getFwdBufferInfo=function(v,T){var I=this.config,G=this.getLoadPosition();if(!Object(Y.isFiniteNumber)(G))return null;var V=H.BufferHelper.bufferInfo(v,G,I.maxBufferHole);if(V.len===0&&V.nextStart!==void 0){var Q=this.fragmentTracker.getBufferedFrag(G,T);if(Q&&V.nextStart<Q.end)return H.BufferHelper.bufferInfo(v,G,Math.max(V.nextStart,I.maxBufferHole))}return V},a.getMaxBufferLength=function(v){var T=this.config,I;return v?I=Math.max(8*T.maxBufferSize/v,T.maxBufferLength):I=T.maxBufferLength,Math.min(I,T.maxMaxBufferLength)},a.reduceMaxBufferLength=function(v){var T=this.config,I=v||T.maxBufferLength;return T.maxMaxBufferLength>=I?(T.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+T.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(v,T){var I,G,V=T.fragments,Q=V.length;if(!Q)return null;var z=this.config,j=V[0].start,q;if(T.live){var ie=z.initialLiveManifestSize;if(Q<ie)return this.warn("Not enough fragments to start playback (have: "+Q+", need: "+ie+")"),null;!T.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(q=this.getInitialLiveFragment(T,V),this.startPosition=q?this.hls.liveSyncPosition||q.start:v)}else v<=j&&(q=V[0]);if(!q){var ce=z.lowLatencyMode?T.partEnd:T.fragmentEnd;q=this.getFragmentAtPosition(v,ce,T)}return(I=q)!==null&&I!==void 0&&I.initSegment&&!((G=q)!==null&&G!==void 0&&G.initSegment.data)&&!this.bitrateTest&&(q=q.initSegment),q},a.getNextPart=function(v,T,I){for(var G=-1,V=!1,Q=!0,z=0,j=v.length;z<j;z++){var q=v[z];if(Q=Q&&!q.independent,G>-1&&I<q.start)break;var ie=q.loaded;!ie&&(V||q.independent||Q)&&q.fragment===T&&(G=z),V=ie}return G},a.loadedEndOfParts=function(v,T){var I=v[v.length-1];return I&&T>I.start&&I.loaded},a.getInitialLiveFragment=function(v,T){var I=this.fragPrevious,G=null;if(I){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+I.programDateTime),G=Object(L.findFragmentByPDT)(T,I.endProgramDateTime,this.config.maxFragLookUpTolerance)),!G){var V=I.sn+1;if(V>=v.startSN&&V<=v.endSN){var Q=T[V-v.startSN];I.cc===Q.cc&&(G=Q,this.log("Live playlist, switching playlist, load frag with next SN: "+G.sn))}G||(G=Object(L.findFragWithCC)(T,I.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?v.fragmentEnd:v.edge,v))}return G},a.getFragmentAtPosition=function(v,T,I){var G=this.config,V=this.fragPrevious,Q=I.fragments,z=I.endSN,j=I.fragmentHint,q=G.maxFragLookUpTolerance,ie=!!(G.lowLatencyMode&&I.partList&&j);ie&&j&&!this.bitrateTest&&(Q=Q.concat(j),z=j.sn);var ce;if(v<T){var ve=v>T-q?0:q;ce=Object(L.findFragmentByPTS)(V,Q,v,ve)}else ce=Q[Q.length-1];if(ce){var Oe=ce.sn-I.startSN,xe=V&&ce.level===V.level,Te=Q[Oe+1],we=this.fragmentTracker.getState(ce);if(we===M.FragmentState.BACKTRACKED){ce=null;for(var Se=Oe;Q[Se]&&this.fragmentTracker.getState(Q[Se])===M.FragmentState.BACKTRACKED;)V?ce=Q[Se--]:ce=Q[--Se];ce||(ce=Te)}else V&&ce.sn===V.sn&&!ie&&(xe&&(ce.sn<z&&this.fragmentTracker.getState(Te)!==M.FragmentState.OK?(this.log("SN "+ce.sn+" just loaded, load next one: "+Te.sn),ce=Te):ce=null))}return ce},a.synchronizeToLiveEdge=function(v){var T=this.config,I=this.media;if(!I)return;var G=this.hls.liveSyncPosition,V=I.currentTime,Q=v.fragments[0].start,z=v.edge,j=V>=Q-T.maxFragLookUpTolerance&&V<=z;if(G!==null&&I.duration>G&&(V<G||!j)){var q=T.liveMaxLatencyDuration!==void 0?T.liveMaxLatencyDuration:T.liveMaxLatencyDurationCount*v.targetduration;(!j&&I.readyState<4||V<z-q)&&(this.loadedmetadata||(this.nextLoadPosition=G),I.readyState&&(this.warn("Playback: "+V.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+G.toFixed(3)),I.currentTime=G))}},a.alignPlaylists=function(v,T){var I=this.levels,G=this.levelLastLoaded,V=this.fragPrevious,Q=G!==null?I[G]:null,z=v.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var j=v.fragments[0].start,q=!T,ie=v.alignedSliding&&Object(Y.isFiniteNumber)(j);if(q||!ie&&!j){Object(R.alignStream)(V,Q,v);var ce=v.fragments[0].start;return this.log("Live playlist sliding: "+ce.toFixed(2)+" start-sn: "+(T?T.startSN:"na")+"->"+v.startSN+" prev-sn: "+(V?V.sn:"na")+" fragments: "+z),ce}return j},a.waitForCdnTuneIn=function(v){var T=3;return v.live&&v.canBlockReload&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*T)},a.setStartPosition=function(v,T){var I=this.startPosition;if(I<T&&(I=-1),I===-1||this.lastCurrentTime===-1){var G=v.startTimeOffset;Object(Y.isFiniteNumber)(G)?(I=T+G,G<0&&(I+=v.totalduration),I=Math.min(Math.max(T,I),T+v.totalduration),this.log("Start time offset "+G+" found in playlist, adjust startPosition to "+I),this.startPosition=I):v.live?I=this.hls.liveSyncPosition||T:this.startPosition=I=0,this.lastCurrentTime=I}this.nextLoadPosition=I},a.getLoadPosition=function(){var v=this.media,T=0;return this.loadedmetadata&&v?T=v.currentTime:this.nextLoadPosition&&(T=this.nextLoadPosition),T},a.handleFragLoadAborted=function(v,T){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(T?" part"+T.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},a.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v))&&(this.state=E.IDLE)},a.onFragmentOrKeyLoadError=function(v,T){if(T.fatal)return;var I=T.frag;if(!I||I.type!==v)return;var G=this.fragCurrent;console.assert(G&&I.sn===G.sn&&I.level===G.level&&I.urlId===G.urlId,"Frag load error must match current frag to retry");var V=this.config;if(this.fragLoadError+1<=V.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(I.level))return;var Q=Math.min(Math.pow(2,this.fragLoadError)*V.fragLoadingRetryDelay,V.fragLoadingMaxRetryTimeout);this.warn("Fragment "+I.sn+" of "+v+" "+I.level+" failed to load, retrying in "+Q+"ms"),this.retryDate=self.performance.now()+Q,this.fragLoadError++,this.state=E.FRAG_LOADING_WAITING_RETRY}else T.levelRetry?(v===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=E.IDLE):(U.logger.error(T.details+" reaches max retry, redispatch as fatal ..."),T.fatal=!0,this.hls.stopLoad(),this.state=E.ERROR)},a.afterBufferFlushed=function(v,T,I){if(!v)return;var G=H.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(T,G,I),this.state===E.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=E.IDLE},a.resetLiveStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var T=this.levels?this.levels[v].details:null;if(T!=null&&T.live)return this.startPosition=-1,this.setStartPosition(T,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(v,T,I,G){var V=this,Q=I.details;console.assert(!!Q,"level.details must be defined");var z=Object.keys(v.elementaryStreams).reduce(function(j,q){var ie=v.elementaryStreams[q];if(ie){var ce=ie.endPTS-ie.startPTS;if(ce<=0)return V.warn("Could not parse fragment "+v.sn+" "+q+" duration reliably ("+ce+") resetting transmuxer to fallback to playlist timing"),V.resetTransmuxer(),j||!1;var ve=G?0:Object(w.updateFragPTSDTS)(Q,v,ie.startPTS,ie.endPTS,ie.startDTS,ie.endDTS);return V.hls.trigger(P.Events.LEVEL_PTS_UPDATED,{details:Q,level:I,drift:ve,type:q,frag:v,start:ie.startPTS,end:ie.endPTS}),!0}return j},!1);z?(this.state=E.PARSED,this.hls.trigger(P.Events.FRAG_PARSED,{frag:v,part:T})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},C(d,[{key:"state",get:function(){return this._state},set:function(v){var T=this._state;T!==v&&(this._state=v,this.log(T+"->"+v))}}]),d}(N.default)},"./src/controller/buffer-controller.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return L});var Y=D("./src/polyfills/number.ts"),N=D("./src/events.ts"),M=D("./src/utils/logger.ts"),H=D("./src/errors.ts"),U=D("./src/utils/buffer-helper.ts"),P=D("./src/utils/mediasource-helper.ts"),_=D("./src/loader/fragment.ts"),y=D("./src/controller/buffer-operation-queue.ts"),A=Object(P.getMediaSource)(),R=/([ha]vc.)(?:\.[^.,]+)+/,L=function(){function w(u){var o=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var l=o.hls,h=o.media,C=o.mediaSource;M.logger.log("[buffer-controller]: Media source opened"),h&&(o.updateMediaElementDuration(),l.trigger(N.Events.MEDIA_ATTACHED,{media:h})),C&&C.removeEventListener("sourceopen",o._onMediaSourceOpen),o.checkPendingTracks()},this._onMediaSourceClose=function(){M.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){M.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var b=w.prototype;return b.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},b.destroy=function(){this.unregisterListeners(),this.details=null},b.registerListeners=function(){var o=this.hls;o.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(N.Events.BUFFER_RESET,this.onBufferReset,this),o.on(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(N.Events.BUFFER_EOS,this.onBufferEos,this),o.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(N.Events.FRAG_PARSED,this.onFragParsed,this),o.on(N.Events.FRAG_CHANGED,this.onFragChanged,this)},b.unregisterListeners=function(){var o=this.hls;o.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(N.Events.BUFFER_RESET,this.onBufferReset,this),o.off(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(N.Events.BUFFER_EOS,this.onBufferEos,this),o.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(N.Events.FRAG_PARSED,this.onFragParsed,this),o.off(N.Events.FRAG_CHANGED,this.onFragChanged,this)},b._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},b.onManifestParsed=function(o,l){var h=2;(l.audio&&!l.video||!l.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,M.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},b.onMediaAttaching=function(o,l){var h=this.media=l.media;if(h&&A){var C=this.mediaSource=new A;C.addEventListener("sourceopen",this._onMediaSourceOpen),C.addEventListener("sourceended",this._onMediaSourceEnded),C.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(C),this._objectUrl=h.src}},b.onMediaDetaching=function(){var o=this.media,l=this.mediaSource,h=this._objectUrl;if(l){if(M.logger.log("[buffer-controller]: media source detaching"),l.readyState==="open")try{l.endOfStream()}catch(C){M.logger.warn("[buffer-controller]: onMediaDetaching: "+C.message+" while calling endOfStream")}this.onBufferReset(),l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(h&&self.URL.revokeObjectURL(h),o.src===h?(o.removeAttribute("src"),o.load()):M.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(N.Events.MEDIA_DETACHED,void 0)},b.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(l){var h=o.sourceBuffer[l];try{h&&(o.removeBufferListeners(l),o.mediaSource&&o.mediaSource.removeSourceBuffer(h),o.sourceBuffer[l]=void 0)}catch(C){M.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",C)}}),this._initSourceBuffer()},b.onBufferCodecs=function(o,l){var h=this,C=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(g){if(C){var p=h.tracks[g];if(p&&typeof p.buffer.changeType=="function"){var k=l[g],E=k.codec,f=k.levelCodec,m=k.container,d=(p.levelCodec||p.codec).replace(R,"$1"),a=(f||E).replace(R,"$1");if(d!==a){var x=m+";codecs="+(f||E);h.appendChangeType(g,x)}}}else h.pendingTracks[g]=l[g]}),C)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},b.appendChangeType=function(o,l){var h=this,C=this.operationQueue,g={execute:function(){var k=h.sourceBuffer[o];k&&(M.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+l),k.changeType(l)),C.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(k){M.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",k)}};C.append(g,o)},b.onBufferAppending=function(o,l){var h=this,C=this.hls,g=this.operationQueue,p=this.tracks,k=l.data,E=l.type,f=l.frag,m=l.part,d=l.chunkMeta,a=d.buffering[E],x=self.performance.now();a.start=x;var v=f.stats.buffering,T=m?m.stats.buffering:null;v.start===0&&(v.start=x),T&&T.start===0&&(T.start=x);var I=p.audio,G=E==="audio"&&d.id===1&&(I==null?void 0:I.container)==="audio/mpeg",V={execute:function(){if(a.executeStart=self.performance.now(),G){var z=h.sourceBuffer[E];if(z){var j=f.start-z.timestampOffset;Math.abs(j)>=.1&&(M.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+f.start+" (delta: "+j+") sn: "+f.sn+")"),z.timestampOffset=f.start)}}h.appendExecutor(k,E)},onStart:function(){},onComplete:function(){var z=self.performance.now();a.executeEnd=a.end=z,v.first===0&&(v.first=z),T&&T.first===0&&(T.first=z);var j=h.sourceBuffer,q={};for(var ie in j)q[ie]=U.BufferHelper.getBuffered(j[ie]);h.appendError=0,h.hls.trigger(N.Events.BUFFER_APPENDED,{type:E,frag:f,part:m,chunkMeta:d,parent:f.type,timeRanges:q})},onError:function(z){M.logger.error("[buffer-controller]: Error encountered while trying to append to the "+E+" SourceBuffer",z);var j={type:H.ErrorTypes.MEDIA_ERROR,parent:f.type,details:H.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?j.details=H.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,j.details=H.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>C.config.appendErrorMaxRetry&&(M.logger.error("[buffer-controller]: Failed "+C.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),j.fatal=!0)),C.trigger(N.Events.ERROR,j)}};g.append(V,E)},b.onBufferFlushing=function(o,l){var h=this,C=this.operationQueue,g=function(k){return{execute:h.removeExecutor.bind(h,k,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(N.Events.BUFFER_FLUSHED,{type:k})},onError:function(f){M.logger.warn("[buffer-controller]: Failed to remove from "+k+" SourceBuffer",f)}}};l.type?C.append(g(l.type),l.type):this.getSourceBufferTypes().forEach(function(p){C.append(g(p),p)})},b.onFragParsed=function(o,l){var h=this,C=l.frag,g=l.part,p=[],k=g?g.elementaryStreams:C.elementaryStreams;k[_.ElementaryStreamTypes.AUDIOVIDEO]?p.push("audiovideo"):(k[_.ElementaryStreamTypes.AUDIO]&&p.push("audio"),k[_.ElementaryStreamTypes.VIDEO]&&p.push("video"));var E=function(){var m=self.performance.now();C.stats.buffering.end=m,g&&(g.stats.buffering.end=m);var d=g?g.stats:C.stats;h.hls.trigger(N.Events.FRAG_BUFFERED,{frag:C,part:g,stats:d,id:C.type})};p.length===0&&M.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+C.type+" level: "+C.level+" sn: "+C.sn),this.blockBuffers(E,p)},b.onFragChanged=function(o,l){this.flushBackBuffer()},b.onBufferEos=function(o,l){var h=this,C=this.getSourceBufferTypes().reduce(function(g,p){var k=h.sourceBuffer[p];return(!l.type||l.type===p)&&(k&&!k.ended&&(k.ended=!0,M.logger.log("[buffer-controller]: "+p+" sourceBuffer now EOS"))),g&&!!(!k||k.ended)},!0);C&&this.blockBuffers(function(){var g=h.mediaSource;if(!g||g.readyState!=="open")return;g.endOfStream()})},b.onLevelUpdated=function(o,l){var h=l.details;if(!h.fragments.length)return;this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},b.flushBackBuffer=function(){var o=this.hls,l=this.details,h=this.media,C=this.sourceBuffer;if(!h||l===null)return;var g=this.getSourceBufferTypes();if(!g.length)return;var p=l.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(Y.isFiniteNumber)(p)||p<0)return;var k=h.currentTime,E=l.levelTargetDuration,f=Math.max(p,E),m=Math.floor(k/E)*E-f;g.forEach(function(d){var a=C[d];if(a){var x=U.BufferHelper.getBuffered(a);x.length>0&&m>x.start(0)&&(o.trigger(N.Events.BACK_BUFFER_REACHED,{bufferEnd:m}),l.live&&o.trigger(N.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:m}),o.trigger(N.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:m,type:d}))}})},b.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,l=this.hls,h=this.media,C=this.mediaSource,g=o.fragments[0].start+o.totalduration,p=h.duration,k=Object(Y.isFiniteNumber)(C.duration)?C.duration:0;o.live&&l.config.liveDurationInfinity?(M.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),C.duration=Infinity,this.updateSeekableRange(o)):(g>k&&g>p||!Object(Y.isFiniteNumber)(p))&&(M.logger.log("[buffer-controller]: Updating Media Source duration to "+g.toFixed(3)),C.duration=g)},b.updateSeekableRange=function(o){var l=this.mediaSource,h=o.fragments,C=h.length;if(C&&o.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var g=Math.max(0,h[0].start),p=Math.max(g,g+o.totalduration);l.setLiveSeekableRange(g,p)}},b.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,l=this.operationQueue,h=this.pendingTracks,C=Object.keys(h).length;if(C&&!o||C===2){this.createSourceBuffers(h),this.pendingTracks={};var g=this.getSourceBufferTypes();if(g.length===0){this.hls.trigger(N.Events.ERROR,{type:H.ErrorTypes.MEDIA_ERROR,details:H.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}g.forEach(function(p){l.executeNext(p)})}},b.createSourceBuffers=function(o){var l=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var C=0;for(var g in o)if(!l[g]){var p=o[g];if(!p)throw Error("source buffer exists for track "+g+", however track does not");var k=p.levelCodec||p.codec,E=p.container+";codecs="+k;M.logger.log("[buffer-controller]: creating sourceBuffer("+E+")");try{var f=l[g]=h.addSourceBuffer(E),m=g;this.addBufferListener(m,"updatestart",this._onSBUpdateStart),this.addBufferListener(m,"updateend",this._onSBUpdateEnd),this.addBufferListener(m,"error",this._onSBUpdateError),this.tracks[g]={buffer:f,codec:k,container:p.container,levelCodec:p.levelCodec,id:p.id},C++}catch(d){M.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+d.message),this.hls.trigger(N.Events.ERROR,{type:H.ErrorTypes.MEDIA_ERROR,details:H.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:E})}}C&&this.hls.trigger(N.Events.BUFFER_CREATED,{tracks:this.tracks})},b._onSBUpdateStart=function(o){var l=this.operationQueue,h=l.current(o);h.onStart()},b._onSBUpdateEnd=function(o){var l=this.operationQueue,h=l.current(o);h.onComplete(),l.shiftAndExecuteNext(o)},b._onSBUpdateError=function(o,l){M.logger.error("[buffer-controller]: "+o+" SourceBuffer error",l),this.hls.trigger(N.Events.ERROR,{type:H.ErrorTypes.MEDIA_ERROR,details:H.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(o);h&&h.onError(l)},b.removeExecutor=function(o,l,h){var C=this.media,g=this.mediaSource,p=this.operationQueue,k=this.sourceBuffer,E=k[o];if(!C||!g||!E){M.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),p.shiftAndExecuteNext(o);return}var f=Object(Y.isFiniteNumber)(C.duration)?C.duration:Infinity,m=Object(Y.isFiniteNumber)(g.duration)?g.duration:Infinity,d=Math.max(0,l),a=Math.min(h,f,m);a>d?(M.logger.log("[buffer-controller]: Removing ["+d+","+a+"] from the "+o+" SourceBuffer"),console.assert(!E.updating,o+" sourceBuffer must not be updating"),E.remove(d,a)):p.shiftAndExecuteNext(o)},b.appendExecutor=function(o,l){var h=this.operationQueue,C=this.sourceBuffer,g=C[l];if(!g){M.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(l);return}g.ended=!1,console.assert(!g.updating,l+" sourceBuffer must not be updating"),g.appendBuffer(o)},b.blockBuffers=function(o,l){var h=this;if(l===void 0&&(l=this.getSourceBufferTypes()),!l.length){M.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var C=this.operationQueue,g=l.map(function(p){return C.appendBlocker(p)});Promise.all(g).then(function(){o(),l.forEach(function(p){var k=h.sourceBuffer[p];(!k||!k.updating)&&C.shiftAndExecuteNext(p)})})},b.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},b.addBufferListener=function(o,l,h){var C=this.sourceBuffer[o];if(!C)return;var g=h.bind(this,o);this.listeners[o].push({event:l,listener:g}),C.addEventListener(l,g)},b.removeBufferListeners=function(o){var l=this.sourceBuffer[o];if(!l)return;this.listeners[o].forEach(function(h){l.removeEventListener(h.event,h.listener)})},w}()},"./src/controller/buffer-operation-queue.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return N});var Y=D("./src/utils/logger.ts"),N=function(){function M(U){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=U}var H=M.prototype;return H.append=function(P,_){var y=this.queues[_];y.push(P),y.length===1&&this.buffers[_]&&this.executeNext(_)},H.insertAbort=function(P,_){var y=this.queues[_];y.unshift(P),this.executeNext(_)},H.appendBlocker=function(P){var _,y=new Promise(function(R){_=R}),A={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(A,P),y},H.executeNext=function(P){var _=this.buffers,y=this.queues,A=_[P],R=y[P];if(R.length){var L=R[0];try{L.execute()}catch(w){Y.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),L.onError(w),(!A||!A.updating)&&(R.shift(),this.executeNext(P))}}},H.shiftAndExecuteNext=function(P){this.queues[P].shift(),this.executeNext(P)},H.current=function(P){return this.queues[P][0]},M}()},"./src/controller/cap-level-controller.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/events.ts");function N(U,P){for(var _=0;_<P.length;_++){var y=P[_];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(U,y.key,y)}}function M(U,P,_){return P&&N(U.prototype,P),_&&N(U,_),U}var H=function(){function U(_){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=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var P=U.prototype;return P.setStreamController=function(y){this.streamController=y},P.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},P.registerListeners=function(){var y=this.hls;y.on(Y.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(Y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(Y.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(Y.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(Y.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.unregisterListener=function(){var y=this.hls;y.off(Y.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(Y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(Y.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(Y.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(Y.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.onFpsDropLevelCapping=function(y,A){U.isLevelAllowed(A.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(A.droppedLevel)},P.onMediaAttaching=function(y,A){this.media=A.media instanceof HTMLVideoElement?A.media:null},P.onManifestParsed=function(y,A){var R=this.hls;this.restrictedLevels=[],this.firstLevel=A.firstLevel,R.config.capLevelToPlayerSize&&A.video&&this.startCapping()},P.onBufferCodecs=function(y,A){var R=this.hls;R.config.capLevelToPlayerSize&&A.video&&this.startCapping()},P.onMediaDetaching=function(){this.stopCapping()},P.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var A=this.hls;A.autoLevelCapping=this.getMaxLevel(y.length-1),A.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=A.autoLevelCapping}}},P.getMaxLevel=function(y){var A=this,R=this.hls.levels;if(!R.length)return-1;var L=R.filter(function(w,b){return U.isLevelAllowed(b,A.restrictedLevels)&&b<=y});return this.clientRect=null,U.getMaxLevelByMediaSize(L,this.mediaWidth,this.mediaHeight)},P.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()},P.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},P.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,A={width:0,height:0};if(y){var R=y.getBoundingClientRect();A.width=R.width,A.height=R.height,!A.width&&!A.height&&(A.width=R.right-R.left||y.width||0,A.height=R.bottom-R.top||y.height||0)}return this.clientRect=A,A},U.isLevelAllowed=function(y,A){return A===void 0&&(A=[]),A.indexOf(y)===-1},U.getMaxLevelByMediaSize=function(y,A,R){if(!y||!y.length)return-1;for(var L=function(l,h){return h?l.width!==h.width||l.height!==h.height:!0},w=y.length-1,b=0;b<y.length;b+=1){var u=y[b];if((u.width>=A||u.height>=R)&&L(u,y[b+1])){w=b;break}}return w},M(U,[{key:"mediaWidth",get:function(){return this.getDimensions().width*U.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*U.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var y=1;try{y=self.devicePixelRatio}catch(A){}return y}}]),U}();Z.default=H},"./src/controller/cmcd-controller.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return L});var Y=D("./src/events.ts"),N=D("./src/types/cmcd.ts"),M=D("./src/utils/buffer-helper.ts"),H=D("./src/utils/logger.ts");function U(w,b){for(var u=0;u<b.length;u++){var o=b[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(w,o.key,o)}}function P(w,b,u){return b&&U(w.prototype,b),u&&U(w,u),w}function _(w,b){var u=typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(u)return(u=u.call(w)).next.bind(u);if(Array.isArray(w)||(u=y(w))||b&&w&&typeof w.length=="number"){u&&(w=u);var o=0;return function(){return o>=w.length?{done:!0}:{done:!1,value:w[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 y(w,b){if(!w)return;if(typeof w=="string")return A(w,b);var u=Object.prototype.toString.call(w).slice(8,-1);if(u==="Object"&&w.constructor&&(u=w.constructor.name),u==="Map"||u==="Set")return Array.from(w);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return A(w,b)}function A(w,b){(b==null||b>w.length)&&(b=w.length);for(var u=0,o=new Array(b);u<b;u++)o[u]=w[u];return o}function R(){return R=Object.assign||function(w){for(var b=1;b<arguments.length;b++){var u=arguments[b];for(var o in u)Object.prototype.hasOwnProperty.call(u,o)&&(w[o]=u[o])}return w},R.apply(this,arguments)}var L=function(){function w(u){var o=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){o.initialized&&(o.starved=!0),o.buffering=!0},this.onPlaying=function(){o.initialized||(o.initialized=!0),o.buffering=!1},this.applyPlaylistData=function(C){try{o.apply(C,{ot:N.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(g){H.logger.warn("Could not generate manifest CMCD data.",g)}},this.applyFragmentData=function(C){try{var g=C.frag,p=o.hls.levels[g.level],k=o.getObjectType(g),E={d:g.duration*1e3,ot:k};(k===N.CMCDObjectType.VIDEO||k===N.CMCDObjectType.AUDIO||k==N.CMCDObjectType.MUXED)&&(E.br=p.bitrate/1e3,E.tb=o.getTopBandwidth(k),E.bl=o.getBufferLength(k)),o.apply(C,E)}catch(f){H.logger.warn("Could not generate segment CMCD data.",f)}},this.hls=u;var l=this.config=u.config,h=l.cmcd;h!=null&&(l.pLoader=this.createPlaylistLoader(),l.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||w.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var b=w.prototype;return b.registerListeners=function(){var o=this.hls;o.on(Y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(Y.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on(Y.Events.BUFFER_CREATED,this.onBufferCreated,this)},b.unregisterListeners=function(){var o=this.hls;o.off(Y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(Y.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off(Y.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},b.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},b.onMediaAttached=function(o,l){this.media=l.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},b.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},b.onBufferCreated=function(o,l){var h,C;this.audioBuffer=(h=l.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(C=l.tracks.video)===null||C===void 0?void 0:C.buffer},b.createData=function(){var o;return{v:N.CMCDVersion,sf:N.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}},b.apply=function(o,l){l===void 0&&(l={}),R(l,this.createData());var h=l.ot===N.CMCDObjectType.INIT||l.ot===N.CMCDObjectType.VIDEO||l.ot===N.CMCDObjectType.MUXED;if(this.starved&&h&&(l.bs=!0,l.su=!0,this.starved=!1),l.su==null&&(l.su=this.buffering),this.useHeaders){var C=w.toHeaders(l);if(!Object.keys(C).length)return;o.headers||(o.headers={}),R(o.headers,C)}else{var g=w.toQuery(l);if(!g)return;o.url=w.appendQueryToUri(o.url,g)}},b.getObjectType=function(o){var l=o.type;return l==="subtitle"?N.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?N.CMCDObjectType.INIT:l==="audio"?N.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?N.CMCDObjectType.VIDEO:N.CMCDObjectType.MUXED:void 0},b.getTopBandwidth=function(o){for(var l=0,h=o===N.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,C=_(h),g;!(g=C()).done;){var p=g.value;p.bitrate>l&&(l=p.bitrate)}return l>0?l:NaN},b.getBufferLength=function(o){var l=this.hls.media,h=o===N.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!l)return NaN;var C=M.BufferHelper.bufferInfo(h,l.currentTime,this.config.maxBufferHole);return C.len*1e3},b.createPlaylistLoader=function(){var o=this.config.pLoader,l=this.applyPlaylistData,h=o||this.config.loader;return function(){function C(p){this.loader=void 0,this.loader=new h(p)}var g=C.prototype;return g.destroy=function(){this.loader.destroy()},g.abort=function(){this.loader.abort()},g.load=function(k,E,f){l(k),this.loader.load(k,E,f)},P(C,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),C}()},b.createFragmentLoader=function(){var o=this.config.fLoader,l=this.applyFragmentData,h=o||this.config.loader;return function(){function C(p){this.loader=void 0,this.loader=new h(p)}var g=C.prototype;return g.destroy=function(){this.loader.destroy()},g.abort=function(){this.loader.abort()},g.load=function(k,E,f){l(k),this.loader.load(k,E,f)},P(C,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),C}()},w.uuid=function(){var o=URL.createObjectURL(new Blob),l=o.toString();return URL.revokeObjectURL(o),l.substr(l.lastIndexOf("/")+1)},w.serialize=function(o){for(var l=[],h=function(G){return!Number.isNaN(G)&&G!=null&&G!==""&&G!==!1},C=function(G){return Math.round(G)},g=function(G){return C(G/100)*100},p=function(G){return encodeURIComponent(G)},k={br:C,d:C,bl:g,dl:g,mtp:g,nor:p,rtp:g,tb:C},E=Object.keys(o||{}).sort(),f=_(E),m;!(m=f()).done;){var d=m.value,a=o[d];if(!h(a))continue;if(d==="v"&&a===1)continue;if(d=="pr"&&a===1)continue;var x=k[d];x&&(a=x(a));var v=typeof a,T=void 0;d==="ot"||d==="sf"||d==="st"?T=d+"="+a:v==="boolean"?T=d:v==="number"?T=d+"="+a:T=d+"="+JSON.stringify(a),l.push(T)}return l.join(",")},w.toHeaders=function(o){for(var l=Object.keys(o),h={},C=["Object","Request","Session","Status"],g=[{},{},{},{}],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},k=0,E=l;k<E.length;k++){var f=E[k],m=p[f]!=null?p[f]:1;g[m][f]=o[f]}for(var d=0;d<g.length;d++){var a=w.serialize(g[d]);a&&(h["CMCD-"+C[d]]=a)}return h},w.toQuery=function(o){return"CMCD="+encodeURIComponent(w.serialize(o))},w.appendQueryToUri=function(o,l){if(!l)return o;var h=o.includes("?")?"&":"?";return""+o+h+l},w}()},"./src/controller/eme-controller.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/events.ts"),N=D("./src/errors.ts"),M=D("./src/utils/logger.ts"),H=D("./src/utils/mediakeys-helper.ts");function U(L,w){for(var b=0;b<w.length;b++){var u=w[b];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function P(L,w,b){return w&&U(L.prototype,w),b&&U(L,b),L}var _=3,y=function(w,b,u){var o={audioCapabilities:[],videoCapabilities:[]};return w.forEach(function(l){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:u.audioRobustness||""})}),b.forEach(function(l){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:u.videoRobustness||""})}),[o]},A=function(w,b,u,o){switch(w){case H.KeySystems.WIDEVINE:return y(b,u,o);default:throw new Error("Unknown key-system: "+w)}},R=function(){function L(b){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=b,this._config=b.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var w=L.prototype;return w.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},w._registerListeners=function(){this.hls.on(Y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Y.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Y.Events.MANIFEST_PARSED,this.onManifestParsed,this)},w._unregisterListeners=function(){this.hls.off(Y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Y.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Y.Events.MANIFEST_PARSED,this.onManifestParsed,this)},w.getLicenseServerUrl=function(u){switch(u){case H.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},w._attemptKeySystemAccess=function(u,o,l){var h=this,C=A(u,o,l,this._drmSystemOptions);M.logger.log("Requesting encrypted media key-system access");var g=this.requestMediaKeySystemAccess(u,C);this.mediaKeysPromise=g.then(function(p){return h._onMediaKeySystemAccessObtained(u,p)}),g.catch(function(p){M.logger.error('Failed to obtain key-system "'+u+'" access:',p)})},w._onMediaKeySystemAccessObtained=function(u,o){var l=this;M.logger.log('Access for key-system "'+u+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:u};this._mediaKeysList.push(h);var C=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(g){return h.mediaKeys=g,M.logger.log('Media-keys created for key-system "'+u+'"'),l._onMediaKeysCreated(),g});return C.catch(function(g){M.logger.error("Failed to create media-keys:",g)}),C},w._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),u._onNewMediaKeySession(o.mediaKeysSession))})},w._onNewMediaKeySession=function(u){var o=this;M.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(l){o._onKeySessionMessage(u,l.message)},!1)},w._onKeySessionMessage=function(u,o){M.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(l){M.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),u.update(l)})},w.onMediaEncrypted=function(u){var o=this;if(M.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){M.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(C){if(!o._media)return;o._attemptSetMediaKeys(C),o._generateRequestWithPreferredKeySession(u.initDataType,u.initData)};this.mediaKeysPromise.then(l).catch(l)},w._attemptSetMediaKeys=function(u){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var o=this._mediaKeysList[0];if(!o||!o.mediaKeys){M.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}M.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},w._generateRequestWithPreferredKeySession=function(u,o){var l=this,h=this._mediaKeysList[0];if(!h){M.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){M.logger.warn("Key-Session already initialized but requested again");return}var C=h.mediaKeysSession;if(!C){M.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!o){M.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}M.logger.log('Generating key-session request for "'+u+'" init data type'),h.mediaKeysSessionInitialized=!0,C.generateRequest(u,o).then(function(){M.logger.debug("Key-session generation succeeded")}).catch(function(g){M.logger.error("Error generating key-session request:",g),l.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},w._createLicenseXhr=function(u,o,l){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,u,o,l);var C=this._licenseXhrSetup;if(C)try{C.call(this.hls,h,u),C=void 0}catch(g){M.logger.error(g)}try{h.readyState||h.open("POST",u,!0),C&&C.call(this.hls,h,u)}catch(g){throw new Error("issue setting up KeySystem license XHR "+g)}return h},w._onLicenseRequestReadyStageChange=function(u,o,l,h){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,M.logger.log("License request succeeded");var C=u.response,g=this._licenseResponseCallback;if(g)try{C=g.call(this.hls,u,o)}catch(k){M.logger.error(k)}h(C)}else{if(M.logger.error("License Request XHR failed ("+o+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var p=_-this._requestLicenseFailureCount+1;M.logger.warn("Retrying license request, "+p+" attempts left"),this._requestLicense(l,h)}break}},w._generateLicenseRequestChallenge=function(u,o){switch(u.mediaKeySystemDomain){case H.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},w._requestLicense=function(u,o){M.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){M.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(l.mediaKeySystemDomain),C=this._createLicenseXhr(h,u,o);M.logger.log("Sending license request to URL: "+h);var g=this._generateLicenseRequestChallenge(l,u);C.send(g)}catch(p){M.logger.error("Failure requesting DRM license: "+p),this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},w.onMediaAttached=function(u,o){if(!this._emeEnabled)return;var l=o.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},w.onMediaDetached=function(){var u=this._media,o=this._mediaKeysList;if(!u)return;u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(o.map(function(l){if(l.mediaKeysSession)return l.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){})},w.onManifestParsed=function(u,o){if(!this._emeEnabled)return;var l=o.levels.map(function(C){return C.audioCodec}).filter(function(C){return!!C}),h=o.levels.map(function(C){return C.videoCodec}).filter(function(C){return!!C});this._attemptKeySystemAccess(H.KeySystems.WIDEVINE,l,h)},P(L,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),L}();Z.default=R},"./src/controller/fps-controller.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/events.ts"),N=D("./src/utils/logger.ts"),M=function(){function H(P){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=P,this.registerListeners()}var U=H.prototype;return U.setStreamController=function(_){this.streamController=_},U.registerListeners=function(){this.hls.on(Y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},U.unregisterListeners=function(){this.hls.off(Y.Events.MEDIA_ATTACHING,this.onMediaAttaching)},U.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},U.onMediaAttaching=function(_,y){var A=this.hls.config;if(A.capLevelOnFPSDrop){var R=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=R,R&&typeof R.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),A.fpsDroppedMonitoringPeriod)}},U.checkFPS=function(_,y,A){var R=performance.now();if(y){if(this.lastTime){var L=R-this.lastTime,w=A-this.lastDroppedFrames,b=y-this.lastDecodedFrames,u=1e3*w/L,o=this.hls;if(o.trigger(Y.Events.FPS_DROP,{currentDropped:w,currentDecoded:b,totalDroppedFrames:A}),u>0&&w>o.config.fpsDroppedMonitoringThreshold*b){var l=o.currentLevel;N.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=l)&&(l=l-1,o.trigger(Y.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:o.currentLevel}),o.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=R,this.lastDroppedFrames=A,this.lastDecodedFrames=y}},U.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var y=_.getVideoPlaybackQuality();this.checkFPS(_,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},H}();Z.default=M},"./src/controller/fragment-finders.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"findFragmentByPDT",function(){return M}),D.d(Z,"findFragmentByPTS",function(){return H}),D.d(Z,"fragmentWithinToleranceTest",function(){return U}),D.d(Z,"pdtWithinToleranceTest",function(){return P}),D.d(Z,"findFragWithCC",function(){return _});var Y=D("./src/polyfills/number.ts"),N=D("./src/utils/binary-search.ts");function M(y,A,R){if(A===null||!Array.isArray(y)||!y.length||!Object(Y.isFiniteNumber)(A))return null;var L=y[0].programDateTime;if(A<(L||0))return null;var w=y[y.length-1].endProgramDateTime;if(A>=(w||0))return null;R=R||0;for(var b=0;b<y.length;++b){var u=y[b];if(P(A,R,u))return u}return null}function H(y,A,R,L){R===void 0&&(R=0),L===void 0&&(L=0);var w=null;if(y?w=A[y.sn-A[0].sn+1]||null:R===0&&A[0].start===0&&(w=A[0]),w&&U(R,L,w)===0)return w;var b=N.default.search(A,U.bind(null,R,L));return b||w}function U(y,A,R){y===void 0&&(y=0),A===void 0&&(A=0);var L=Math.min(A,R.duration+(R.deltaPTS?R.deltaPTS:0));return R.start+R.duration-L<=y?1:R.start-L>y&&R.start?-1:0}function P(y,A,R){var L=Math.min(A,R.duration+(R.deltaPTS?R.deltaPTS:0))*1e3,w=R.endProgramDateTime||0;return w-L>y}function _(y,A){return N.default.search(y,function(R){return R.cc<A?1:R.cc>A?-1:0})}},"./src/controller/fragment-tracker.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"FragmentState",function(){return M}),D.d(Z,"FragmentTracker",function(){return H});var Y=D("./src/events.ts"),N=D("./src/types/loader.ts"),M;(function(_){_.NOT_LOADED="NOT_LOADED",_.BACKTRACKED="BACKTRACKED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(M||(M={}));var H=function(){function _(A){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=A,this._registerListeners()}var y=_.prototype;return y._registerListeners=function(){var R=this.hls;R.on(Y.Events.BUFFER_APPENDED,this.onBufferAppended,this),R.on(Y.Events.FRAG_BUFFERED,this.onFragBuffered,this),R.on(Y.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var R=this.hls;R.off(Y.Events.BUFFER_APPENDED,this.onBufferAppended,this),R.off(Y.Events.FRAG_BUFFERED,this.onFragBuffered,this),R.off(Y.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(R,L){if(L===N.PlaylistLevelType.MAIN){var w=this.activeFragment,b=this.activeParts;if(!w)return null;if(b)for(var u=b.length;u--;){var o=b[u],l=o?o.end:w.appendedPTS;if(o.start<=R&&l!==void 0&&R<=l)return u>9&&(this.activeParts=b.slice(u-9)),o}else if(w.start<=R&&w.appendedPTS!==void 0&&R<=w.appendedPTS)return w}return this.getBufferedFrag(R,L)},y.getBufferedFrag=function(R,L){for(var w=this.fragments,b=Object.keys(w),u=b.length;u--;){var o=w[b[u]];if((o==null?void 0:o.body.type)===L&&o.buffered){var l=o.body;if(l.start<=R&&R<=l.end)return l}}return null},y.detectEvictedFragments=function(R,L,w){var b=this;Object.keys(this.fragments).forEach(function(u){var o=b.fragments[u];if(!o)return;if(!o.buffered){o.body.type===w&&b.removeFragment(o.body);return}var l=o.range[R];if(!l)return;l.time.some(function(h){var C=!b.isTimeBuffered(h.startPTS,h.endPTS,L);return C&&b.removeFragment(o.body),C})})},y.detectPartialFragments=function(R){var L=this,w=this.timeRanges,b=R.frag,u=R.part;if(!w||b.sn==="initSegment")return;var o=P(b),l=this.fragments[o];if(!l)return;Object.keys(w).forEach(function(h){var C=b.elementaryStreams[h];if(!C)return;var g=w[h],p=u!==null||C.partial===!0;l.range[h]=L.getBufferedTimes(b,u,p,g)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},y.fragBuffered=function(R){var L=P(R),w=this.fragments[L];w&&(w.backtrack=w.loaded=null,w.buffered=!0)},y.getBufferedTimes=function(R,L,w,b){for(var u={time:[],partial:w},o=L?L.start:R.start,l=L?L.end:R.end,h=R.minEndPTS||l,C=R.maxStartPTS||o,g=0;g<b.length;g++){var p=b.start(g)-this.bufferPadding,k=b.end(g)+this.bufferPadding;if(C>=p&&h<=k){u.time.push({startPTS:Math.max(o,b.start(g)),endPTS:Math.min(l,b.end(g))});break}else if(o<k&&l>p)u.partial=!0,u.time.push({startPTS:Math.max(o,b.start(g)),endPTS:Math.min(l,b.end(g))});else if(l<=p)break}return u},y.getPartialFragment=function(R){var L=null,w,b,u,o=0,l=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(C){var g=h[C];if(!g)return;U(g)&&(b=g.body.start-l,u=g.body.end+l,R>=b&&R<=u&&(w=Math.min(R-b,u-R),o<=w&&(L=g.body,o=w)))}),L},y.getState=function(R){var L=P(R),w=this.fragments[L];return w?w.buffered?U(w)?M.PARTIAL:M.OK:w.backtrack?M.BACKTRACKED:M.APPENDING:M.NOT_LOADED},y.backtrack=function(R,L){var w=P(R),b=this.fragments[w];if(!b||b.backtrack)return null;var u=b.backtrack=L||b.loaded;return b.loaded=null,u},y.getBacktrackData=function(R){var L=P(R),w=this.fragments[L];if(w){var b,u=w.backtrack;if(u!=null&&(b=u.payload)!==null&&b!==void 0&&b.byteLength)return u;this.removeFragment(R)}return null},y.isTimeBuffered=function(R,L,w){for(var b,u,o=0;o<w.length;o++){if(b=w.start(o)-this.bufferPadding,u=w.end(o)+this.bufferPadding,R>=b&&L<=u)return!0;if(L<=b)return!1}return!1},y.onFragLoaded=function(R,L){var w=L.frag,b=L.part;if(w.sn==="initSegment"||w.bitrateTest||b)return;var u=P(w);this.fragments[u]={body:w,loaded:L,backtrack:null,buffered:!1,range:Object.create(null)}},y.onBufferAppended=function(R,L){var w=this,b=L.frag,u=L.part,o=L.timeRanges;if(b.type===N.PlaylistLevelType.MAIN)if(this.activeFragment=b,u){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(u)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(h){var C=o[h];if(w.detectEvictedFragments(h,C),!u)for(var g=0;g<C.length;g++)b.appendedPTS=Math.max(C.end(g),b.appendedPTS||0)})},y.onFragBuffered=function(R,L){this.detectPartialFragments(L)},y.hasFragment=function(R){var L=P(R);return!!this.fragments[L]},y.removeFragmentsInRange=function(R,L,w){var b=this;Object.keys(this.fragments).forEach(function(u){var o=b.fragments[u];if(!o)return;if(o.buffered){var l=o.body;l.type===w&&l.start<L&&l.end>R&&b.removeFragment(l)}})},y.removeFragment=function(R){var L=P(R);R.stats.loaded=0,R.clearElementaryStreamInfo(),delete this.fragments[L]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function U(_){var y,A;return _.buffered&&(((y=_.range.video)===null||y===void 0?void 0:y.partial)||((A=_.range.audio)===null||A===void 0?void 0:A.partial))}function P(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"STALL_MINIMUM_DURATION_MS",function(){return U}),D.d(Z,"MAX_START_GAP_JUMP",function(){return P}),D.d(Z,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),D.d(Z,"SKIP_BUFFER_RANGE_START",function(){return y}),D.d(Z,"default",function(){return A});var Y=D("./src/utils/buffer-helper.ts"),N=D("./src/errors.ts"),M=D("./src/events.ts"),H=D("./src/utils/logger.ts"),U=250,P=2,_=.1,y=.05,A=function(){function R(w,b,u,o){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=w,this.media=b,this.fragmentTracker=u,this.hls=o}var L=R.prototype;return L.destroy=function(){this.hls=this.fragmentTracker=this.media=null},L.poll=function(b){var u=this.config,o=this.media,l=this.stalled,h=o.currentTime,C=o.seeking,g=this.seeking&&!C,p=!this.seeking&&C;if(this.seeking=C,h!==b){if(this.moved=!0,l!==null){if(this.stallReported){var k=self.performance.now()-l;H.logger.warn("playback not stuck anymore @"+h+", after "+Math.round(k)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((p||g)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!Y.BufferHelper.getBuffered(o).length)return;var E=Y.BufferHelper.bufferInfo(o,h,0),f=E.len>0,m=E.nextStart||0;if(!f&&!m)return;if(C){var d=E.len>P,a=!m||m-h>P&&!this.fragmentTracker.getPartialFragment(h);if(d||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var x,v=Math.max(m,E.start||0)-h,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,I=T==null||((x=T.details)===null||x===void 0)?void 0:x.live,G=I?T.details.targetduration*2:P;if(v>0&&v<=G){this._trySkipBufferHole(null);return}}var V=self.performance.now();if(l===null){this.stalled=V;return}var Q=V-l;!C&&Q>=U&&this._reportStall(E.len);var z=Y.BufferHelper.bufferInfo(o,h,u.maxBufferHole);this._tryFixBufferStall(z,Q)},L._tryFixBufferStall=function(b,u){var o=this.config,l=this.fragmentTracker,h=this.media,C=h.currentTime,g=l.getPartialFragment(C);if(g){var p=this._trySkipBufferHole(g);if(p)return}b.len>o.maxBufferHole&&u>o.highBufferWatchdogPeriod*1e3&&(H.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},L._reportStall=function(b){var u=this.hls,o=this.media,l=this.stallReported;l||(this.stallReported=!0,H.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+b+")"),u.trigger(M.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:b}))},L._trySkipBufferHole=function(b){for(var u=this.config,o=this.hls,l=this.media,h=l.currentTime,C=0,g=Y.BufferHelper.getBuffered(l),p=0;p<g.length;p++){var k=g.start(p);if(h+u.maxBufferHole>=C&&h<k){var E=Math.max(k+y,l.currentTime+_);return H.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+E),this.moved=!0,this.stalled=null,l.currentTime=E,b&&o.trigger(M.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+E,frag:b}),E}C=g.end(p)}return 0},L._tryNudgeBuffer=function(){var b=this.config,u=this.hls,o=this.media,l=o.currentTime,h=(this.nudgeRetry||0)+1;if(this.nudgeRetry=h,h<b.nudgeMaxRetry){var C=l+h*b.nudgeOffset;H.logger.warn("Nudging 'currentTime' from "+l+" to "+C),o.currentTime=C,u.trigger(M.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else H.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+b.nudgeMaxRetry+" nudges"),u.trigger(M.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},R}()},"./src/controller/id3-track-controller.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/events.ts"),N=D("./src/utils/texttrack-utils.ts"),M=D("./src/demux/id3.ts"),H=.25,U=function(){function P(y){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=y,this._registerListeners()}var _=P.prototype;return _.destroy=function(){this._unregisterListeners()},_._registerListeners=function(){var A=this.hls;A.on(Y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.on(Y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.on(Y.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.on(Y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_._unregisterListeners=function(){var A=this.hls;A.off(Y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.off(Y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.off(Y.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.off(Y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_.onMediaAttached=function(A,R){this.media=R.media},_.onMediaDetaching=function(){if(!this.id3Track)return;Object(N.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},_.getID3Track=function(A){if(!this.media)return;for(var R=0;R<A.length;R++){var L=A[R];if(L.kind==="metadata"&&L.label==="id3")return Object(N.sendAddTrackEvent)(L,this.media),L}return this.media.addTextTrack("metadata","id3")},_.onFragParsingMetadata=function(A,R){if(!this.media)return;var L=R.frag,w=R.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var b=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<w.length;u++){var o=M.getID3Frames(w[u].data);if(o){var l=w[u].pts,h=u<w.length-1?w[u+1].pts:L.end,C=h-l;C<=0&&(h=l+H);for(var g=0;g<o.length;g++){var p=o[g];if(!M.isTimeStampFrame(p)){var k=new b(l,h,"");k.value=p,this.id3Track.addCue(k)}}}}},_.onBufferFlushing=function(A,R){var L=R.startOffset,w=R.endOffset,b=R.type;if(!b||b==="audio"){var u=this.id3Track;u&&Object(N.removeCuesInRange)(u,L,w)}},P}();Z.default=U},"./src/controller/latency-controller.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return P});var Y=D("./src/errors.ts"),N=D("./src/events.ts"),M=D("./src/utils/logger.ts");function H(_,y){for(var A=0;A<y.length;A++){var R=y[A];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}function U(_,y,A){return y&&H(_.prototype,y),A&&H(_,A),_}var P=function(){function _(A){var R=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return R.timeupdate()},this.hls=A,this.config=A.config,this.registerListeners()}var y=_.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(N.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(N.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(N.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(N.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(N.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(N.Events.ERROR,this.onError)},y.onMediaAttached=function(R,L){this.media=L.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(R,L){var w=L.details;this.levelDetails=w,w.advanced&&this.timeupdate(),!w.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(R,L){if(L.details!==Y.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,M.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},y.timeupdate=function(){var R=this.media,L=this.levelDetails;if(!R||!L)return;this.currentTime=R.currentTime;var w=this.computeLatency();if(w===null)return;this._latency=w;var b=this.config,u=b.lowLatencyMode,o=b.maxLiveSyncPlaybackRate;if(!u||o===1)return;var l=this.targetLatency;if(l===null)return;var h=w-l,C=Math.min(this.maxLatency,l+L.targetduration),g=h<C;if(L.live&&g&&h>.05&&this.forwardBufferLength>1){var p=Math.min(2,Math.max(1,o)),k=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;R.playbackRate=Math.min(p,Math.max(1,k))}else R.playbackRate!==1&&R.playbackRate!==0&&(R.playbackRate=1)},y.estimateLiveEdge=function(){var R=this.levelDetails;return R===null?null:R.edge+R.age},y.computeLatency=function(){var R=this.estimateLiveEdge();return R===null?null:R-this.currentTime},U(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var R=this.config,L=this.levelDetails;return R.liveMaxLatencyDuration!==void 0?R.liveMaxLatencyDuration:L?R.liveMaxLatencyDurationCount*L.targetduration:0}},{key:"targetLatency",get:function(){var R=this.levelDetails;if(R===null)return null;var L=R.holdBack,w=R.partHoldBack,b=R.targetduration,u=this.config,o=u.liveSyncDuration,l=u.liveSyncDurationCount,h=u.lowLatencyMode,C=this.hls.userConfig,g=h&&w||L;(C.liveSyncDuration||C.liveSyncDurationCount||g===0)&&(g=o!==void 0?o:l*b);var p=b,k=1;return g+Math.min(this.stallCount*k,p)}},{key:"liveSyncPosition",get:function(){var R=this.estimateLiveEdge(),L=this.targetLatency,w=this.levelDetails;if(R===null||L===null||w===null)return null;var b=w.edge,u=R-L-this.edgeStalled,o=b-w.totalduration,l=b-(this.config.lowLatencyMode&&w.partTarget||w.targetduration);return Math.min(Math.max(o,u),l)}},{key:"drift",get:function(){var R=this.levelDetails;return R===null?1:R.drift}},{key:"edgeStalled",get:function(){var R=this.levelDetails;if(R===null)return 0;var L=(this.config.lowLatencyMode&&R.partTarget||R.targetduration)*3;return Math.max(R.age-L,0)}},{key:"forwardBufferLength",get:function(){var R=this.media,L=this.levelDetails;if(!R||!L)return 0;var w=R.buffered.length;return w?R.buffered.end(w-1):L.edge-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return u});var Y=D("./src/types/level.ts"),N=D("./src/events.ts"),M=D("./src/errors.ts"),H=D("./src/utils/codecs.ts"),U=D("./src/controller/level-helper.ts"),P=D("./src/controller/base-playlist-controller.ts"),_=D("./src/types/loader.ts");function y(){return y=Object.assign||function(o){for(var l=1;l<arguments.length;l++){var h=arguments[l];for(var C in h)Object.prototype.hasOwnProperty.call(h,C)&&(o[C]=h[C])}return o},y.apply(this,arguments)}function A(o,l){for(var h=0;h<l.length;h++){var C=l[h];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(o,C.key,C)}}function R(o,l,h){return l&&A(o.prototype,l),h&&A(o,h),o}function L(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,w(o,l)}function w(o,l){return w=Object.setPrototypeOf||function(C,g){return C.__proto__=g,C},w(o,l)}var b=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(o){L(l,o);function l(C){var g;return g=o.call(this,C,"[level-controller]")||this,g._levels=[],g._firstLevel=-1,g._startLevel=void 0,g.currentLevelIndex=-1,g.manualLevelIndex=-1,g.onParsedComplete=void 0,g._registerListeners(),g}var h=l.prototype;return h._registerListeners=function(){var g=this.hls;g.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.on(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),g.on(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),g.on(N.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var g=this.hls;g.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),g.off(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),g.off(N.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},h.startLoad=function(){var g=this._levels;g.forEach(function(p){p.loadError=0}),o.prototype.startLoad.call(this)},h.onManifestLoaded=function(g,p){var k=[],E=[],f=[],m,d={},a,x=!1,v=!1,T=!1;if(p.levels.forEach(function(Q){var z=Q.attrs;x=x||!!(Q.width&&Q.height),v=v||!!Q.videoCodec,T=T||!!Q.audioCodec,b&&Q.audioCodec&&Q.audioCodec.indexOf("mp4a.40.34")!==-1&&(Q.audioCodec=void 0);var j=Q.bitrate+"-"+Q.attrs.RESOLUTION+"-"+Q.attrs.CODECS;a=d[j],a?a.url.push(Q.url):(a=new Y.Level(Q),d[j]=a,k.push(a)),z&&(z.AUDIO&&Object(U.addGroupId)(a,"audio",z.AUDIO),z.SUBTITLES&&Object(U.addGroupId)(a,"text",z.SUBTITLES))}),(x||v)&&T&&(k=k.filter(function(Q){var z=Q.videoCodec,j=Q.width,q=Q.height;return!!z||!!(j&&q)})),k=k.filter(function(Q){var z=Q.audioCodec,j=Q.videoCodec;return(!z||Object(H.isCodecSupportedInMp4)(z,"audio"))&&(!j||Object(H.isCodecSupportedInMp4)(j,"video"))}),p.audioTracks&&(E=p.audioTracks.filter(function(Q){return!Q.audioCodec||Object(H.isCodecSupportedInMp4)(Q.audioCodec,"audio")}),Object(U.assignTrackIdsByGroup)(E)),p.subtitles&&(f=p.subtitles,Object(U.assignTrackIdsByGroup)(f)),k.length>0){m=k[0].bitrate,k.sort(function(Q,z){return Q.bitrate-z.bitrate}),this._levels=k;for(var I=0;I<k.length;I++)if(k[I].bitrate===m){this._firstLevel=I,this.log("manifest loaded, "+k.length+" level(s) found, first bitrate: "+m);break}var G=T&&!v,V={levels:k,audioTracks:E,subtitleTracks:f,firstLevel:this._firstLevel,stats:p.stats,audio:T,video:v,altAudio:!G&&E.some(function(Q){return!!Q.url})};this.hls.trigger(N.Events.MANIFEST_PARSED,V),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(N.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:p.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(g,p){if(o.prototype.onError.call(this,g,p),p.fatal)return;var k=p.context,E=this._levels[this.currentLevelIndex];if(k&&(k.type===_.PlaylistContextType.AUDIO_TRACK&&E.audioGroupIds&&k.groupId===E.audioGroupIds[E.urlId]||k.type===_.PlaylistContextType.SUBTITLE_TRACK&&E.textGroupIds&&k.groupId===E.textGroupIds[E.urlId])){this.redundantFailover(this.currentLevelIndex);return}var f=!1,m=!0,d;switch(p.details){case M.ErrorDetails.FRAG_LOAD_ERROR:case M.ErrorDetails.FRAG_LOAD_TIMEOUT:case M.ErrorDetails.KEY_LOAD_ERROR:case M.ErrorDetails.KEY_LOAD_TIMEOUT:if(p.frag){var a=this._levels[p.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(d=p.frag.level)):d=p.frag.level}break;case M.ErrorDetails.LEVEL_LOAD_ERROR:case M.ErrorDetails.LEVEL_LOAD_TIMEOUT:k&&(k.deliveryDirectives&&(m=!1),d=k.level),f=!0;break;case M.ErrorDetails.REMUX_ALLOC_ERROR:d=p.level,f=!0;break}d!==void 0&&this.recoverLevel(p,d,f,m)},h.recoverLevel=function(g,p,k,E){var f=g.details,m=this._levels[p];if(m.loadError++,k){var d=this.retryLoadingOrFail(g);if(d)g.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(E){var a=m.url.length;if(a>1&&m.loadError<a)g.levelRetry=!0,this.redundantFailover(p);else if(this.manualLevelIndex===-1){var x=p===0?this._levels.length-1:p-1;this.currentLevelIndex!==x&&this._levels[x].loadError===0&&(this.warn(f+": switch to "+x),g.levelRetry=!0,this.hls.nextAutoLevel=x)}}},h.redundantFailover=function(g){var p=this._levels[g],k=p.url.length;if(k>1){var E=(p.urlId+1)%k;this.warn("Switching to redundant URL-id "+E),this._levels.forEach(function(f){f.urlId=E}),this.level=g}},h.onFragLoaded=function(g,p){var k=p.frag;if(k!==void 0&&k.type===_.PlaylistLevelType.MAIN){var E=this._levels[k.level];E!==void 0&&(E.fragmentError=0,E.loadError=0)}},h.onLevelLoaded=function(g,p){var k,E=p.level,f=p.details,m=this._levels[E];if(!m){var d;this.warn("Invalid level index "+E),(d=p.deliveryDirectives)!==null&&d!==void 0&&d.skip&&(f.deltaUpdateFailed=!0);return}E===this.currentLevelIndex?(m.fragmentError===0&&(m.loadError=0,this.retryCount=0),this.playlistLoaded(E,p,m.details)):(k=p.deliveryDirectives)!==null&&k!==void 0&&k.skip&&(f.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(g,p){var k=this.hls.levels[this.currentLevelIndex];if(!k)return;if(k.audioGroupIds){for(var E=-1,f=this.hls.audioTracks[p.id].groupId,m=0;m<k.audioGroupIds.length;m++)if(k.audioGroupIds[m]===f){E=m;break}E!==k.urlId&&(k.urlId=E,this.startLoad())}},h.loadPlaylist=function(g){var p=this.currentLevelIndex,k=this._levels[p];if(this.canLoad&&k&&k.url.length>0){var E=k.urlId,f=k.url[E];if(g)try{f=g.addDirectives(f)}catch(m){this.warn("Could not construct new URL with HLS Delivery Directives: "+m)}this.log("Attempt loading level index "+p+(g?" at sn "+g.msn+" part "+g.part:"")+" with URL-id "+E+" "+f),this.clearTimer(),this.hls.trigger(N.Events.LEVEL_LOADING,{url:f,level:p,id:E,deliveryDirectives:g||null})}},h.removeLevel=function(g,p){var k=function(m,d){return d!==p},E=this._levels.filter(function(f,m){return m!==g?!0:f.url.length>1&&p!==void 0?(f.url=f.url.filter(k),f.audioGroupIds&&(f.audioGroupIds=f.audioGroupIds.filter(k)),f.textGroupIds&&(f.textGroupIds=f.textGroupIds.filter(k)),f.urlId=0,!0):!1}).map(function(f,m){var d=f.details;return d!=null&&d.fragments&&d.fragments.forEach(function(a){a.level=m}),f});this._levels=E,this.hls.trigger(N.Events.LEVELS_UPDATED,{levels:E})},R(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(g){var p,k=this._levels;if(k.length===0)return;if(this.currentLevelIndex===g&&(p=k[g])!==null&&p!==void 0&&p.details)return;if(g<0||g>=k.length){var E=g<0;if(this.hls.trigger(N.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.LEVEL_SWITCH_ERROR,level:g,fatal:E,reason:"invalid level idx"}),E)return;g=Math.min(g,k.length-1)}this.clearTimer();var f=this.currentLevelIndex,m=k[f],d=k[g];this.log("switching to level "+g+" from "+f),this.currentLevelIndex=g;var a=y({},d,{level:g,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete a._urlId,this.hls.trigger(N.Events.LEVEL_SWITCHING,a);var x=d.details;if(!x||x.live){var v=this.switchParams(d.uri,m==null?void 0:m.details);this.loadPlaylist(v)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(g){this.manualLevelIndex=g,this._startLevel===void 0&&(this._startLevel=g),g!==-1&&(this.level=g)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(g){this._firstLevel=g}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var g=this.hls.config.startLevel;return g!==void 0?g:this._firstLevel}else return this._startLevel},set:function(g){this._startLevel=g}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(g){this.level=g,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=g)}}]),l}(P.default)},"./src/controller/level-helper.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"addGroupId",function(){return M}),D.d(Z,"assignTrackIdsByGroup",function(){return H}),D.d(Z,"updatePTS",function(){return U}),D.d(Z,"updateFragPTSDTS",function(){return _}),D.d(Z,"mergeDetails",function(){return y}),D.d(Z,"mapPartIntersection",function(){return A}),D.d(Z,"mapFragmentIntersection",function(){return R}),D.d(Z,"adjustSliding",function(){return L}),D.d(Z,"addSliding",function(){return w}),D.d(Z,"computeReloadInterval",function(){return b}),D.d(Z,"getFragmentWithSN",function(){return u}),D.d(Z,"getPartWith",function(){return o});var Y=D("./src/polyfills/number.ts"),N=D("./src/utils/logger.ts");function M(l,h,C){switch(h){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(C);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(C);break}}function H(l){var h={};l.forEach(function(C){var g=C.groupId||"";C.id=h[g]=h[g]||0,h[g]++})}function U(l,h,C){var g=l[h],p=l[C];P(g,p)}function P(l,h){var C=h.startPTS;if(Object(Y.isFiniteNumber)(C)){var g=0,p;h.sn>l.sn?(g=C-l.start,p=l):(g=l.start-C,p=h),p.duration!==g&&(p.duration=g)}else if(h.sn>l.sn){var k=l.cc===h.cc;k&&l.minEndPTS?h.start=l.start+(l.minEndPTS-l.start):h.start=l.start+l.duration}else h.start=Math.max(l.start-h.duration,0)}function _(l,h,C,g,p,k){var E=g-C;E<=0&&(N.logger.warn("Fragment should have a positive duration",h),g=C+h.duration,k=p+h.duration);var f=C,m=g,d=h.startPTS,a=h.endPTS;if(Object(Y.isFiniteNumber)(d)){var x=Math.abs(d-C);Object(Y.isFiniteNumber)(h.deltaPTS)?h.deltaPTS=Math.max(x,h.deltaPTS):h.deltaPTS=x,f=Math.max(C,d),C=Math.min(C,d),p=Math.min(p,h.startDTS),m=Math.min(g,a),g=Math.max(g,a),k=Math.max(k,h.endDTS)}h.duration=g-C;var v=C-h.start;h.appendedPTS=g,h.start=h.startPTS=C,h.maxStartPTS=f,h.startDTS=p,h.endPTS=g,h.minEndPTS=m,h.endDTS=k;var T=h.sn;if(!l||T<l.startSN||T>l.endSN)return 0;var I,G=T-l.startSN,V=l.fragments;for(V[G]=h,I=G;I>0;I--)P(V[I],V[I-1]);for(I=G;I<V.length-1;I++)P(V[I],V[I+1]);return l.fragmentHint&&P(V[V.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,v}function y(l,h){for(var C=null,g=l.fragments,p=g.length-1;p>=0;p--){var k=g[p].initSegment;if(k){C=k;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var E=0,f;if(R(l,h,function(I,G){I.relurl&&(E=I.cc-G.cc),Object(Y.isFiniteNumber)(I.startPTS)&&Object(Y.isFiniteNumber)(I.endPTS)&&(G.start=G.startPTS=I.startPTS,G.startDTS=I.startDTS,G.appendedPTS=I.appendedPTS,G.maxStartPTS=I.maxStartPTS,G.endPTS=I.endPTS,G.endDTS=I.endDTS,G.minEndPTS=I.minEndPTS,G.duration=I.endPTS-I.startPTS,G.duration&&(f=G),h.PTSKnown=h.alignedSliding=!0),G.elementaryStreams=I.elementaryStreams,G.loader=I.loader,G.stats=I.stats,G.urlId=I.urlId,I.initSegment&&(G.initSegment=I.initSegment,C=I.initSegment)}),C){var m=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments;m.forEach(function(I){var G;(!I.initSegment||I.initSegment.relurl===((G=C)===null||G===void 0?void 0:G.relurl))&&(I.initSegment=C)})}if(h.skippedSegments&&(h.deltaUpdateFailed=h.fragments.some(function(I){return!I}),h.deltaUpdateFailed)){N.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=h.skippedSegments;d--;)h.fragments.shift();h.startSN=h.fragments[0].sn,h.startCC=h.fragments[0].cc}var a=h.fragments;if(E){N.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<a.length;x++)a[x].cc+=E}h.skippedSegments&&(h.startCC=h.fragments[0].cc),A(l.partList,h.partList,function(I,G){G.elementaryStreams=I.elementaryStreams,G.stats=I.stats}),f?_(h,f,f.startPTS,f.endPTS,f.startDTS,f.endDTS):L(l,h),a.length&&(h.totalduration=h.edge-a[0].start),h.driftStartTime=l.driftStartTime,h.driftStart=l.driftStart;var v=h.advancedDateTime;if(h.advanced&&v){var T=h.edge;h.driftStart||(h.driftStartTime=v,h.driftStart=T),h.driftEndTime=v,h.driftEnd=T}else h.driftEndTime=l.driftEndTime,h.driftEnd=l.driftEnd,h.advancedDateTime=l.advancedDateTime}function A(l,h,C){if(l&&h)for(var g=0,p=0,k=l.length;p<=k;p++){var E=l[p],f=h[p+g];E&&f&&E.index===f.index&&E.fragment.sn===f.fragment.sn?C(E,f):g--}}function R(l,h,C){for(var g=h.skippedSegments,p=Math.max(l.startSN,h.startSN)-h.startSN,k=(l.fragmentHint?1:0)+(g?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,E=h.startSN-l.startSN,f=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,m=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,d=p;d<=k;d++){var a=m[E+d],x=f[d];g&&!x&&d<g&&(x=h.fragments[d]=a),a&&x&&C(a,x)}}function L(l,h){var C=h.startSN+h.skippedSegments-l.startSN,g=l.fragments;if(C<0||C>=g.length)return;w(h,g[C].start)}function w(l,h){if(h){for(var C=l.fragments,g=l.skippedSegments;g<C.length;g++)C[g].start+=h;l.fragmentHint&&(l.fragmentHint.start+=h)}}function b(l,h){var C=1e3*l.levelTargetDuration,g=C/2,p=l.age,k=p>0&&p<C*3,E=h.loading.end-h.loading.start,f,m=l.availabilityDelay;if(l.updated===!1)if(k){var d=333*l.misses;f=Math.max(Math.min(g,E*2),d),l.availabilityDelay=(l.availabilityDelay||0)+f}else f=g;else k?(m=Math.min(m||C/2,p),l.availabilityDelay=m,f=m+C-p):f=C-E;return Math.round(f)}function u(l,h,C){if(!l||!l.details)return null;var g=l.details,p=g.fragments[h-g.startSN];return p||(p=g.fragmentHint,p&&p.sn===h?p:h<g.startSN&&C&&C.sn===h?C:null)}function o(l,h,C){if(!l||!l.details)return null;var g=l.details.partList;if(g)for(var p=g.length;p--;){var k=g[p];if(k.index===C&&k.fragment.sn===h)return k}return null}},"./src/controller/stream-controller.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return g});var Y=D("./src/polyfills/number.ts"),N=D("./src/controller/base-stream-controller.ts"),M=D("./src/is-supported.ts"),H=D("./src/events.ts"),U=D("./src/utils/buffer-helper.ts"),P=D("./src/controller/fragment-tracker.ts"),_=D("./src/types/loader.ts"),y=D("./src/loader/fragment.ts"),A=D("./src/demux/transmuxer-interface.ts"),R=D("./src/types/transmuxer.ts"),L=D("./src/controller/gap-controller.ts"),w=D("./src/errors.ts"),b=D("./src/utils/logger.ts");function u(p,k){for(var E=0;E<k.length;E++){var f=k[E];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(p,f.key,f)}}function o(p,k,E){return k&&u(p.prototype,k),E&&u(p,E),p}function l(p,k){p.prototype=Object.create(k.prototype),p.prototype.constructor=p,h(p,k)}function h(p,k){return h=Object.setPrototypeOf||function(f,m){return f.__proto__=m,f},h(p,k)}var C=100,g=function(p){l(k,p);function k(f,m){var d;return d=p.call(this,f,m,"[stream-controller]")||this,d.audioCodecSwap=!1,d.gapController=null,d.level=-1,d._forceStartLoad=!1,d.altAudio=!1,d.audioOnly=!1,d.fragPlaying=null,d.onvplaying=null,d.onvseeked=null,d.fragLastKbps=0,d.stalled=!1,d.couldBacktrack=!1,d.audioCodecSwitch=!1,d.videoBuffer=null,d._registerListeners(),d}var E=k.prototype;return E._registerListeners=function(){var m=this.hls;m.on(H.Events.MEDIA_ATTACHED,this.onMediaAttached,this),m.on(H.Events.MEDIA_DETACHING,this.onMediaDetaching,this),m.on(H.Events.MANIFEST_LOADING,this.onManifestLoading,this),m.on(H.Events.MANIFEST_PARSED,this.onManifestParsed,this),m.on(H.Events.LEVEL_LOADING,this.onLevelLoading,this),m.on(H.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.on(H.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),m.on(H.Events.ERROR,this.onError,this),m.on(H.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),m.on(H.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),m.on(H.Events.BUFFER_CREATED,this.onBufferCreated,this),m.on(H.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),m.on(H.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),m.on(H.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E._unregisterListeners=function(){var m=this.hls;m.off(H.Events.MEDIA_ATTACHED,this.onMediaAttached,this),m.off(H.Events.MEDIA_DETACHING,this.onMediaDetaching,this),m.off(H.Events.MANIFEST_LOADING,this.onManifestLoading,this),m.off(H.Events.MANIFEST_PARSED,this.onManifestParsed,this),m.off(H.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.off(H.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),m.off(H.Events.ERROR,this.onError,this),m.off(H.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),m.off(H.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),m.off(H.Events.BUFFER_CREATED,this.onBufferCreated,this),m.off(H.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),m.off(H.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),m.off(H.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},E.startLoad=function(m){if(this.levels){var d=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(C),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var x=a.startLevel;x===-1&&(a.config.testBandwidth?(x=0,this.bitrateTest=!0):x=a.nextAutoLevel),this.level=a.nextLoadLevel=x,this.loadedmetadata=!1}d>0&&m===-1&&(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),m=d),this.state=N.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=m,this.tick()}else this._forceStartLoad=!0,this.state=N.State.STOPPED},E.stopLoad=function(){this._forceStartLoad=!1,p.prototype.stopLoad.call(this)},E.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_LEVEL:{var m,d=this.levels,a=this.level,x=d==null||((m=d[a])===null||m===void 0)?void 0:m.details;if(x&&(!x.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(x))break;this.state=N.State.IDLE;break}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var v,T=self.performance.now(),I=this.retryDate;(!I||T>=I||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=N.State.IDLE)}break;default:break}this.onTickEnd()},E.onTickEnd=function(){p.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},E.doTickIdle=function(){var m,d,a=this.hls,x=this.levelLastLoaded,v=this.levels,T=this.media,I=a.config,G=a.nextLoadLevel;if(x===null||!T&&(this.startFragRequested||!I.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!v||!v[G])return;var V=v[G];this.level=a.nextLoadLevel=G;var Q=V.details;if(!Q||this.state===N.State.WAITING_LEVEL||Q.live&&this.levelLastLoaded!==G){this.state=N.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:T,_.PlaylistLevelType.MAIN);if(z===null)return;var j=z.len,q=this.getMaxBufferLength(V.maxBitrate);if(j>=q)return;if(this._streamEnded(z,Q)){var ie={};this.altAudio&&(ie.type="video"),this.hls.trigger(H.Events.BUFFER_EOS,ie),this.state=N.State.ENDED;return}var ce=z.end,ve=this.getNextFragment(ce,Q);if(this.couldBacktrack&&!this.fragPrevious&&ve&&ve.sn!=="initSegment"){var Oe=ve.sn-Q.startSN;Oe>1&&(ve=Q.fragments[Oe-1],this.fragmentTracker.removeFragment(ve))}if(ve&&this.fragmentTracker.getState(ve)===P.FragmentState.OK&&this.nextLoadPosition>ce){var xe=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(T,xe,_.PlaylistLevelType.MAIN),ve=this.getNextFragment(this.nextLoadPosition,Q)}if(!ve)return;ve.initSegment&&!ve.initSegment.data&&!this.bitrateTest&&(ve=ve.initSegment),((m=ve.decryptdata)===null||m===void 0?void 0:m.keyFormat)==="identity"&&!((d=ve.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(ve,Q):this.loadFragment(ve,Q,ce)},E.loadFragment=function(m,d,a){var x,v=this.fragmentTracker.getState(m);if(this.fragCurrent=m,v===P.FragmentState.BACKTRACKED){var T=this.fragmentTracker.getBacktrackData(m);if(T){this._handleFragmentLoadProgress(T),this._handleFragmentLoadComplete(T);return}else v=P.FragmentState.NOT_LOADED}v===P.FragmentState.NOT_LOADED||v===P.FragmentState.PARTIAL?m.sn==="initSegment"?this._loadInitSegment(m):this.bitrateTest?(m.bitrateTest=!0,this.log("Fragment "+m.sn+" of level "+m.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(m)):(this.startFragRequested=!0,p.prototype.loadFragment.call(this,m,d,a)):v===P.FragmentState.APPENDING?this.reduceMaxBufferLength(m.duration)&&this.fragmentTracker.removeFragment(m):((x=this.media)===null||x===void 0?void 0:x.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},E.getAppendedFrag=function(m){var d=this.fragmentTracker.getAppendedFrag(m,_.PlaylistLevelType.MAIN);return d&&"fragment"in d?d.fragment:d},E.getBufferedFrag=function(m){return this.fragmentTracker.getBufferedFrag(m,_.PlaylistLevelType.MAIN)},E.followingBufferedFrag=function(m){return m?this.getBufferedFrag(m.end+.5):null},E.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},E.nextLevelSwitch=function(){var m=this.levels,d=this.media;if(d!=null&&d.readyState){var a,x=this.getAppendedFrag(d.currentTime);if(x&&x.start>1&&this.flushMainBuffer(0,x.start-1),!d.paused&&m){var v=this.hls.nextLoadLevel,T=m[v],I=this.fragLastKbps;I&&this.fragCurrent?a=this.fragCurrent.duration*T.maxBitrate/(1e3*I)+1:a=0}else a=0;var G=this.getBufferedFrag(d.currentTime+a);if(G){var V=this.followingBufferedFrag(G);if(V){this.abortCurrentFrag();var Q=V.maxStartPTS?V.maxStartPTS:V.start,z=V.duration,j=Math.max(G.end,Q+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(j,Number.POSITIVE_INFINITY)}}}},E.abortCurrentFrag=function(){var m=this.fragCurrent;this.fragCurrent=null,m!=null&&m.loader&&m.loader.abort(),this.state===N.State.KEY_LOADING&&(this.state=N.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},E.flushMainBuffer=function(m,d){p.prototype.flushMainBuffer.call(this,m,d,this.altAudio?"video":null)},E.onMediaAttached=function(m,d){p.prototype.onMediaAttached.call(this,m,d);var a=d.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new L.default(this.config,a,this.fragmentTracker,this.hls)},E.onMediaDetaching=function(){var m=this.media;m&&(m.removeEventListener("playing",this.onvplaying),m.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)},E.onMediaPlaying=function(){this.tick()},E.onMediaSeeked=function(){var m=this.media,d=m?m.currentTime:null;Object(Y.isFiniteNumber)(d)&&this.log("Media seeked to "+d.toFixed(3)),this.tick()},E.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(H.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},E.onManifestParsed=function(m,d){var a=!1,x=!1,v;d.levels.forEach(function(T){v=T.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(a=!0),v.indexOf("mp4a.40.5")!==-1&&(x=!0))}),this.audioCodecSwitch=a&&x&&!Object(M.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=d.levels,this.startFragRequested=!1},E.onLevelLoading=function(m,d){var a=this.levels;if(!a||this.state!==N.State.IDLE)return;var x=a[d.level];(!x.details||x.details.live&&this.levelLastLoaded!==d.level||this.waitForCdnTuneIn(x.details))&&(this.state=N.State.WAITING_LEVEL)},E.onLevelLoaded=function(m,d){var a,x=this.levels,v=d.level,T=d.details,I=T.totalduration;if(!x){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+T.startSN+","+T.endSN+"], cc ["+T.startCC+", "+T.endCC+"] duration:"+I);var G=this.fragCurrent;G&&(this.state===N.State.FRAG_LOADING||this.state===N.State.FRAG_LOADING_WAITING_RETRY)&&(G.level!==d.level&&G.loader&&(this.state=N.State.IDLE,G.loader.abort()));var V=x[v],Q=0;if(T.live||(a=V.details)!==null&&a!==void 0&&a.live){if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed)return;Q=this.alignPlaylists(T,V.details)}if(V.details=T,this.levelLastLoaded=v,this.hls.trigger(H.Events.LEVEL_UPDATED,{details:T,level:v}),this.state===N.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(T))return;this.state=N.State.IDLE}this.startFragRequested?T.live&&this.synchronizeToLiveEdge(T):this.setStartPosition(T,Q),this.tick()},E._handleFragmentLoadProgress=function(m){var d,a=m.frag,x=m.part,v=m.payload,T=this.levels;if(!T){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var I=T[a.level],G=I.details;if(!G){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var V=I.videoCodec,Q=G.PTSKnown||!G.live,z=(d=a.initSegment)===null||d===void 0?void 0:d.data,j=this._getAudioCodec(I),q=this.transmuxer=this.transmuxer||new A.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ie=x?x.index:-1,ce=ie!==-1,ve=new R.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,v.byteLength,ie,ce),Oe=this.initPTS[a.cc];q.push(v,z,j,V,a,x,G.totalduration,Q,ve,Oe)},E.onAudioTrackSwitching=function(m,d){var a=this.altAudio,x=!!d.url,v=d.id;if(!x){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var T=this.fragCurrent;T!=null&&T.loader&&(this.log("Switching to main audio track, cancel main fragment load"),T.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var I=this.hls;a&&I.trigger(H.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),I.trigger(H.Events.AUDIO_TRACK_SWITCHED,{id:v})}},E.onAudioTrackSwitched=function(m,d){var a=d.id,x=!!this.hls.audioTracks[a].url;if(x){var v=this.videoBuffer;v&&this.mediaBuffer!==v&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=v)}this.altAudio=x,this.tick()},E.onBufferCreated=function(m,d){var a=d.tracks,x,v,T=!1;for(var I in a){var G=a[I];if(G.id==="main"){if(v=I,x=G,I==="video"){var V=a[I];V&&(this.videoBuffer=V.buffer)}}else T=!0}T&&x?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=x.buffer):this.mediaBuffer=this.media},E.onFragBuffered=function(m,d){var a=d.frag,x=d.part;if(a&&a.type!==_.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(x?" p: "+x.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===N.State.PARSED&&(this.state=N.State.IDLE);return}var v=x?x.stats:a.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,x)},E.onError=function(m,d){switch(d.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,d);break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==N.State.ERROR&&(d.fatal?(this.warn(""+d.details),this.state=N.State.ERROR):!d.levelRetry&&this.state===N.State.WAITING_LEVEL&&(this.state=N.State.IDLE));break;case w.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="main"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var a=!0,x=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);x&&x.len>.5&&(a=!this.reduceMaxBufferLength(x.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},E.checkBuffer=function(){var m=this.media,d=this.gapController;if(!m||!d||!m.readyState)return;var a=U.BufferHelper.getBuffered(m);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):d.poll(this.lastCurrentTime),this.lastCurrentTime=m.currentTime},E.onFragLoadEmergencyAborted=function(){this.state=N.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},E.onBufferFlushed=function(m,d){var a=d.type;if(a!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var x=(a===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(x,a,_.PlaylistLevelType.MAIN)}},E.onLevelsUpdated=function(m,d){this.levels=d.levels},E.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},E.seekToStartPos=function(){var m=this.media,d=m.currentTime,a=this.startPosition;if(a>=0&&d<a){if(m.seeking){b.logger.log("could not seek to "+a+", already seeking at "+d);return}var x=U.BufferHelper.getBuffered(m),v=x.length?x.start(0):0,T=v-a;T>0&&(T<this.config.maxBufferHole||T<this.config.maxFragLookUpTolerance)&&(b.logger.log("adjusting start position by "+T+" to match buffer start"),a+=T,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+d),m.currentTime=a}},E._getAudioCodec=function(m){var d=this.config.defaultAudioCodec||m.audioCodec;return this.audioCodecSwap&&d&&(this.log("Swapping audio codec"),d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5"),d},E._loadBitrateTestFrag=function(m){var d=this;this._doFragLoad(m).then(function(a){var x=d.hls;if(!a||x.nextLoadLevel||d.fragContextChanged(m))return;d.fragLoadError=0,d.state=N.State.IDLE,d.startFragRequested=!1,d.bitrateTest=!1;var v=m.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),x.trigger(H.Events.FRAG_LOADED,a)})},E._handleTransmuxComplete=function(m){var d,a="main",x=this.hls,v=m.remuxResult,T=m.chunkMeta,I=this.getCurrentContext(T);if(!I){this.warn("The loading context changed while buffering fragment "+T.sn+" of level "+T.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(T.level);return}var G=I.frag,V=I.part,Q=I.level,z=v.video,j=v.text,q=v.id3,ie=v.initSegment,ce=this.altAudio?void 0:v.audio;if(this.fragContextChanged(G))return;if(this.state=N.State.PARSING,ie){ie.tracks&&(this._bufferInitSegment(Q,ie.tracks,G,T),x.trigger(H.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:a,tracks:ie.tracks}));var ve=ie.initPTS,Oe=ie.timescale;Object(Y.isFiniteNumber)(ve)&&(this.initPTS[G.cc]=ve,x.trigger(H.Events.INIT_PTS_FOUND,{frag:G,id:a,initPTS:ve,timescale:Oe}))}if(z&&v.independent!==!1){if(Q.details){var xe=z.startPTS,Te=z.endPTS,we=z.startDTS,Se=z.endDTS;if(V)V.elementaryStreams[z.type]={startPTS:xe,endPTS:Te,startDTS:we,endDTS:Se};else if(z.firstKeyFrame&&z.independent&&(this.couldBacktrack=!0),z.dropped&&z.independent){var pe=this.getLoadPosition()+this.config.maxBufferHole;if(pe<xe){this.backtrack(G);return}G.setElementaryStreamInfo(z.type,G.start,Te,G.start,Se,!0)}G.setElementaryStreamInfo(z.type,xe,Te,we,Se),this.bufferFragmentData(z,G,V,T)}}else if(v.independent===!1){this.backtrack(G);return}if(ce){var oe=ce.startPTS,De=ce.endPTS,Ve=ce.startDTS,ze=ce.endDTS;V&&(V.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:oe,endPTS:De,startDTS:Ve,endDTS:ze}),G.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,oe,De,Ve,ze),this.bufferFragmentData(ce,G,V,T)}if(q!=null&&(d=q.samples)!==null&&d!==void 0&&d.length){var et={frag:G,id:a,samples:q.samples};x.trigger(H.Events.FRAG_PARSING_METADATA,et)}if(j){var Je={frag:G,id:a,samples:j.samples};x.trigger(H.Events.FRAG_PARSING_USERDATA,Je)}},E._bufferInitSegment=function(m,d,a,x){var v=this;if(this.state!==N.State.PARSING)return;this.audioOnly=!!d.audio&&!d.video,this.altAudio&&!this.audioOnly&&delete d.audio;var T=d.audio,I=d.video,G=d.audiovideo;if(T){var V=m.audioCodec,Q=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(V&&(V.indexOf("mp4a.40.5")!==-1?V="mp4a.40.2":V="mp4a.40.5"),T.metadata.channelCount!==1&&Q.indexOf("firefox")===-1&&(V="mp4a.40.5")),Q.indexOf("android")!==-1&&T.container!=="audio/mpeg"&&(V="mp4a.40.2",this.log("Android: force audio codec to "+V)),m.audioCodec&&m.audioCodec!==V&&this.log('Swapping manifest audio codec "'+m.audioCodec+'" for "'+V+'"'),T.levelCodec=V,T.id="main",this.log("Init audio buffer, container:"+T.container+", codecs[selected/level/parsed]=["+(V||"")+"/"+(m.audioCodec||"")+"/"+T.codec+"]")}I&&(I.levelCodec=m.videoCodec,I.id="main",this.log("Init video buffer, container:"+I.container+", codecs[level/parsed]=["+(m.videoCodec||"")+"/"+I.codec+"]")),G&&this.log("Init audiovideo buffer, container:"+G.container+", codecs[level/parsed]=["+(m.attrs.CODECS||"")+"/"+G.codec+"]"),this.hls.trigger(H.Events.BUFFER_CODECS,d),Object.keys(d).forEach(function(z){var j=d[z],q=j.initSegment;q!=null&&q.byteLength&&v.hls.trigger(H.Events.BUFFER_APPENDING,{type:z,data:q,frag:a,part:null,chunkMeta:x,parent:a.type})}),this.tick()},E.backtrack=function(m){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(m);var d=this.fragmentTracker.backtrack(m);this.fragPrevious=null,this.nextLoadPosition=m.start,d?this.resetFragmentLoading(m):this.state=N.State.BACKTRACKING},E.checkFragmentChanged=function(){var m=this.media,d=null;if(m&&m.readyState>1&&m.seeking===!1){var a=m.currentTime;if(U.BufferHelper.isBuffered(m,a)?d=this.getAppendedFrag(a):U.BufferHelper.isBuffered(m,a+.1)&&(d=this.getAppendedFrag(a+.1)),d){var x=this.fragPlaying,v=d.level;(!x||d.sn!==x.sn||x.level!==v||d.urlId!==x.urlId)&&(this.hls.trigger(H.Events.FRAG_CHANGED,{frag:d}),(!x||x.level!==v)&&this.hls.trigger(H.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=d)}}},o(k,[{key:"nextLevel",get:function(){var m=this.nextBufferedFrag;return m?m.level:-1}},{key:"currentLevel",get:function(){var m=this.media;if(m){var d=this.getAppendedFrag(m.currentTime);if(d)return d.level}return-1}},{key:"nextBufferedFrag",get:function(){var m=this.media;if(m){var d=this.getAppendedFrag(m.currentTime);return this.followingBufferedFrag(d)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),k}(N.default)},"./src/controller/subtitle-stream-controller.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"SubtitleStreamController",function(){return l});var Y=D("./src/events.ts"),N=D("./src/utils/logger.ts"),M=D("./src/utils/buffer-helper.ts"),H=D("./src/controller/fragment-finders.ts"),U=D("./src/utils/discontinuities.ts"),P=D("./src/controller/level-helper.ts"),_=D("./src/controller/fragment-tracker.ts"),y=D("./src/controller/base-stream-controller.ts"),A=D("./src/types/loader.ts"),R=D("./src/types/level.ts");function L(h,C){for(var g=0;g<C.length;g++){var p=C[g];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(h,p.key,p)}}function w(h,C,g){return C&&L(h.prototype,C),g&&L(h,g),h}function b(h,C){h.prototype=Object.create(C.prototype),h.prototype.constructor=h,u(h,C)}function u(h,C){return u=Object.setPrototypeOf||function(p,k){return p.__proto__=k,p},u(h,C)}var o=500,l=function(h){b(C,h);function C(p,k){var E;return E=h.call(this,p,k,"[subtitle-stream-controller]")||this,E.levels=[],E.currentTrackId=-1,E.tracksBuffered=[],E.mainDetails=null,E._registerListeners(),E}var g=C.prototype;return g.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},g._registerListeners=function(){var k=this.hls;k.on(Y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),k.on(Y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),k.on(Y.Events.MANIFEST_LOADING,this.onManifestLoading,this),k.on(Y.Events.LEVEL_LOADED,this.onLevelLoaded,this),k.on(Y.Events.ERROR,this.onError,this),k.on(Y.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),k.on(Y.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),k.on(Y.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),k.on(Y.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),k.on(Y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},g._unregisterListeners=function(){var k=this.hls;k.off(Y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),k.off(Y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),k.off(Y.Events.MANIFEST_LOADING,this.onManifestLoading,this),k.off(Y.Events.LEVEL_LOADED,this.onLevelLoaded,this),k.off(Y.Events.ERROR,this.onError,this),k.off(Y.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),k.off(Y.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),k.off(Y.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),k.off(Y.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),k.off(Y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},g.startLoad=function(){this.stopLoad(),this.state=y.State.IDLE,this.setInterval(o),this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},g.onLevelLoaded=function(k,E){this.mainDetails=E.details},g.onSubtitleFragProcessed=function(k,E){var f=E.frag,m=E.success;if(this.fragPrevious=f,this.state=y.State.IDLE,!m)return;var d=this.tracksBuffered[this.currentTrackId];if(!d)return;for(var a,x=f.start,v=0;v<d.length;v++)if(x>=d[v].start&&x<=d[v].end){a=d[v];break}var T=f.start+f.duration;a?a.end=T:(a={start:x,end:T},d.push(a)),this.fragmentTracker.fragBuffered(f)},g.onBufferFlushing=function(k,E){var f=E.startOffset,m=E.endOffset;if(f===0&&m!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,a=this.levels;if(!a.length||!a[d]||!a[d].details)return;var x=a[d].details,v=x.targetduration,T=m-v;if(T<=0)return;E.endOffsetSubtitles=Math.max(0,T),this.tracksBuffered.forEach(function(I){for(var G=0;G<I.length;){if(I[G].end<=T){I.shift();continue}else if(I[G].start<T)I[G].start=T;else break;G++}}),this.fragmentTracker.removeFragmentsInRange(f,T,A.PlaylistLevelType.SUBTITLE)}},g.onError=function(k,E){var f,m=E.frag;if(!m||m.type!==A.PlaylistLevelType.SUBTITLE)return;(f=this.fragCurrent)!==null&&f!==void 0&&f.loader&&this.fragCurrent.loader.abort(),this.state=y.State.IDLE},g.onSubtitleTracksUpdated=function(k,E){var f=this,m=E.subtitleTracks;this.tracksBuffered=[],this.levels=m.map(function(d){return new R.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){f.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},g.onSubtitleTrackSwitch=function(k,E){if(this.currentTrackId=E.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var f=this.levels[this.currentTrackId];f!=null&&f.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,f&&this.setInterval(o)},g.onSubtitleTrackLoaded=function(k,E){var f,m=E.details,d=E.id,a=this.currentTrackId,x=this.levels;if(!x.length)return;var v=x[a];if(d>=x.length||d!==a||!v)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,m.live||(f=v.details)!==null&&f!==void 0&&f.live){var T=this.mainDetails;if(m.deltaUpdateFailed||!T)return;var I=T.fragments[0];if(!v.details)m.hasProgramDateTime&&T.hasProgramDateTime?Object(U.alignMediaPlaylistByPDT)(m,T):I&&Object(P.addSliding)(m,I.start);else{var G=this.alignPlaylists(m,v.details);G===0&&I&&Object(P.addSliding)(m,I.start)}}if(v.details=m,this.levelLastLoaded=d,this.tick(),m.live&&!this.fragCurrent&&this.media&&this.state===y.State.IDLE){var V=Object(H.findFragmentByPTS)(null,m.fragments,this.media.currentTime,0);V||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}},g._handleFragmentLoadComplete=function(k){var E=k.frag,f=k.payload,m=E.decryptdata,d=this.hls;if(this.fragContextChanged(E))return;if(f&&f.byteLength>0&&m&&m.key&&m.iv&&m.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(f),m.key.buffer,m.iv.buffer).then(function(x){var v=performance.now();d.trigger(Y.Events.FRAG_DECRYPTED,{frag:E,payload:x,stats:{tstart:a,tdecrypt:v}})})}},g.doTick=function(){if(!this.media){this.state=y.State.IDLE;return}if(this.state===y.State.IDLE){var k,E=this.currentTrackId,f=this.levels;if(!f.length||!f[E]||!f[E].details)return;var m=f[E].details,d=m.targetduration,a=this.config,x=this.media,v=M.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,x.currentTime-d,a.maxBufferHole),T=v.end,I=v.len,G=this.getMaxBufferLength()+d;if(I>G)return;console.assert(m,"Subtitle track details are defined on idle subtitle stream controller tick");var V=m.fragments,Q=V.length,z=m.edge,j,q=this.fragPrevious;if(T<z){var ie=a.maxFragLookUpTolerance;q&&m.hasProgramDateTime&&(j=Object(H.findFragmentByPDT)(V,q.endProgramDateTime,ie)),j||(j=Object(H.findFragmentByPTS)(q,V,T,ie),!j&&q&&q.start<V[0].start&&(j=V[0]))}else j=V[Q-1];(k=j)!==null&&k!==void 0&&k.encrypted?(N.logger.log("Loading key for "+j.sn),this.state=y.State.KEY_LOADING,this.hls.trigger(Y.Events.KEY_LOADING,{frag:j})):j&&this.fragmentTracker.getState(j)===_.FragmentState.NOT_LOADED&&this.loadFragment(j,m,T)}},g.loadFragment=function(k,E,f){this.fragCurrent=k,h.prototype.loadFragment.call(this,k,E,f)},w(C,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),C}(y.default)},"./src/controller/subtitle-track-controller.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/events.ts"),N=D("./src/utils/texttrack-utils.ts"),M=D("./src/controller/base-playlist-controller.ts"),H=D("./src/types/loader.ts");function U(L,w){for(var b=0;b<w.length;b++){var u=w[b];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function P(L,w,b){return w&&U(L.prototype,w),b&&U(L,b),L}function _(L,w){L.prototype=Object.create(w.prototype),L.prototype.constructor=L,y(L,w)}function y(L,w){return y=Object.setPrototypeOf||function(u,o){return u.__proto__=o,u},y(L,w)}var A=function(L){_(w,L);function w(u){var o;return o=L.call(this,u,"[subtitle-track-controller]")||this,o.media=null,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.selectDefaultTrack=!0,o.queuedDefaultTrack=-1,o.trackChangeListener=function(){return o.onTextTracksChanged()},o.asyncPollTrackChange=function(){return o.pollTrackChange(0)},o.useTextTrackPolling=!1,o.subtitlePollingInterval=-1,o.subtitleDisplay=!0,o.registerListeners(),o}var b=w.prototype;return b.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,L.prototype.destroy.call(this)},b.registerListeners=function(){var o=this.hls;o.on(Y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(Y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(Y.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(Y.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(Y.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(Y.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(Y.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(Y.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var o=this.hls;o.off(Y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(Y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(Y.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(Y.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(Y.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(Y.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(Y.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(Y.Events.ERROR,this.onError,this)},b.onMediaAttached=function(o,l){if(this.media=l.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},b.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},b.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var o=R(this.media.textTracks);o.forEach(function(l){Object(N.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},b.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},b.onManifestParsed=function(o,l){this.tracks=l.subtitleTracks},b.onSubtitleTrackLoaded=function(o,l){var h=l.id,C=l.details,g=this.trackId,p=this.tracksInGroup[g];if(!p){this.warn("Invalid subtitle track id "+h);return}var k=p.details;p.details=l.details,this.log("subtitle track "+h+" loaded ["+C.startSN+"-"+C.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,l,k))},b.onLevelLoading=function(o,l){this.switchLevel(l.level)},b.onLevelSwitching=function(o,l){this.switchLevel(l.level)},b.switchLevel=function(o){var l=this.hls.levels[o];if(!(l!=null&&l.textGroupIds))return;var h=l.textGroupIds[l.urlId];if(this.groupId!==h){var C=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,g=this.tracks.filter(function(E){return!h||E.groupId===h});this.tracksInGroup=g;var p=this.findTrackId(C==null?void 0:C.name)||this.findTrackId();this.groupId=h;var k={subtitleTracks:g};this.log("Updating subtitle tracks, "+g.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(Y.Events.SUBTITLE_TRACKS_UPDATED,k),p!==-1&&this.setSubtitleTrack(p,C)}},b.findTrackId=function(o){for(var l=this.tracksInGroup,h=0;h<l.length;h++){var C=l[h];if((!this.selectDefaultTrack||C.default)&&(!o||o===C.name))return C.id}return-1},b.onError=function(o,l){if(L.prototype.onError.call(this,o,l),l.fatal||!l.context)return;l.context.type===H.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},b.loadPlaylist=function(o){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var h=l.id,C=l.groupId,g=l.url;if(o)try{g=o.addDirectives(g)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(Y.Events.SUBTITLE_TRACK_LOADING,{url:g,id:h,groupId:C,deliveryDirectives:o||null})}},b.toggleTrackModes=function(o){var l=this,h=this.media,C=this.subtitleDisplay,g=this.trackId;if(!h)return;var p=R(h.textTracks),k=p.filter(function(m){return m.groupId===l.groupId});if(o===-1)[].slice.call(p).forEach(function(m){m.mode="disabled"});else{var E=k[g];E&&(E.mode="disabled")}var f=k[o];f&&(f.mode=C?"showing":"hidden")},b.setSubtitleTrack=function(o,l){var h,C=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(h=C[o])!==null&&h!==void 0&&h.details)||o<-1||o>=C.length)return;this.clearTimer();var g=C[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,g){var p=g.id,k=g.groupId,E=k===void 0?"":k,f=g.name,m=g.type,d=g.url;this.hls.trigger(Y.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:E,name:f,type:m,url:d});var a=this.switchParams(g.url,l==null?void 0:l.details);this.loadPlaylist(a)}else this.hls.trigger(Y.Events.SUBTITLE_TRACK_SWITCH,{id:o})},b.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,l=R(this.media.textTracks),h=0;h<l.length;h++)if(l[h].mode==="hidden")o=h;else if(l[h].mode==="showing"){o=h;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},P(w,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(o,l)}}]),w}(M.default);function R(L){for(var w=[],b=0;b<L.length;b++){var u=L[b];u.kind==="subtitles"&&u.label&&w.push(L[b])}return w}Z.default=A},"./src/controller/timeline-controller.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"TimelineController",function(){return R});var Y=D("./src/polyfills/number.ts"),N=D("./src/events.ts"),M=D("./src/utils/cea-608-parser.ts"),H=D("./src/utils/output-filter.ts"),U=D("./src/utils/webvtt-parser.ts"),P=D("./src/utils/texttrack-utils.ts"),_=D("./src/utils/imsc1-ttml-parser.ts"),y=D("./src/types/loader.ts"),A=D("./src/utils/logger.ts"),R=function(){function u(l){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=b(),this.captionsProperties=void 0,this.hls=l,this.config=l.config,this.Cues=l.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var h=new H.default(this,"textTrack1"),C=new H.default(this,"textTrack2"),g=new H.default(this,"textTrack3"),p=new H.default(this,"textTrack4");this.cea608Parser1=new M.default(1,h,C),this.cea608Parser2=new M.default(3,g,p)}l.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(N.Events.FRAG_LOADING,this.onFragLoading,this),l.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=u.prototype;return o.destroy=function(){var h=this.hls;h.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.off(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(N.Events.FRAG_LOADING,this.onFragLoading,this),h.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.off(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.off(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(h,C,g,p,k){for(var E=!1,f=k.length;f--;){var m=k[f],d=w(m[0],m[1],C,g);if(d>=0&&(m[0]=Math.min(m[0],C),m[1]=Math.max(m[1],g),E=!0,d/(g-C)>.5))return}if(E||k.push([C,g]),this.config.renderTextTracksNatively){var a=this.captionsTracks[h];this.Cues.newCue(a,C,g,p)}else{var x=this.Cues.newCue(null,C,g,p);this.hls.trigger(N.Events.CUES_PARSED,{type:"captions",cues:x,track:h})}},o.onInitPtsFound=function(h,C){var g=this,p=C.frag,k=C.id,E=C.initPTS,f=C.timescale,m=this.unparsedVttFrags;k==="main"&&(this.initPTS[p.cc]=E,this.timescale[p.cc]=f),m.length&&(this.unparsedVttFrags=[],m.forEach(function(d){g.onFragLoaded(N.Events.FRAG_LOADED,d)}))},o.getExistingTrack=function(h){var C=this.media;if(C)for(var g=0;g<C.textTracks.length;g++){var p=C.textTracks[g];if(p[h])return p}return null},o.createCaptionsTrack=function(h){this.config.renderTextTracksNatively?this.createNativeTrack(h):this.createNonNativeTrack(h)},o.createNativeTrack=function(h){if(this.captionsTracks[h])return;var C=this.captionsProperties,g=this.captionsTracks,p=this.media,k=C[h],E=k.label,f=k.languageCode,m=this.getExistingTrack(h);if(m)g[h]=m,Object(P.clearCurrentCues)(g[h]),Object(P.sendAddTrackEvent)(g[h],p);else{var d=this.createTextTrack("captions",E,f);d&&(d[h]=!0,g[h]=d)}},o.createNonNativeTrack=function(h){if(this.nonNativeCaptionsTracks[h])return;var C=this.captionsProperties[h];if(!C)return;var g=C.label,p={_id:h,label:g,kind:"captions",default:C.media?!!C.media.default:!1,closedCaptions:C.media};this.nonNativeCaptionsTracks[h]=p,this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[p]})},o.createTextTrack=function(h,C,g){var p=this.media;return p?p.addTextTrack(h,C,g):void 0},o.onMediaAttaching=function(h,C){this.media=C.media,this._cleanTracks()},o.onMediaDetaching=function(){var h=this.captionsTracks;Object.keys(h).forEach(function(C){Object(P.clearCurrentCues)(h[C]),delete h[C]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=b(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var h=this.media;if(!h)return;var C=h.textTracks;if(C)for(var g=0;g<C.length;g++)Object(P.clearCurrentCues)(C[g])},o.onSubtitleTracksUpdated=function(h,C){var g=this;this.textTracks=[];var p=C.subtitleTracks||[],k=p.some(function(d){return d.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||k&&this.config.enableIMSC1){var E=this.tracks&&p&&this.tracks.length===p.length;if(this.tracks=p||[],this.config.renderTextTracksNatively){var f=this.media?this.media.textTracks:[];this.tracks.forEach(function(d,a){var x;if(a<f.length){for(var v=null,T=0;T<f.length;T++)if(L(f[T],d)){v=f[T];break}v&&(x=v)}x?Object(P.clearCurrentCues)(x):(x=g.createTextTrack("subtitles",d.name,d.lang),x&&(x.mode="disabled")),x&&(x.groupId=d.groupId,g.textTracks.push(x))})}else if(!E&&this.tracks&&this.tracks.length){var m=this.tracks.map(function(d){return{label:d.name,kind:d.type.toLowerCase(),default:d.default,subtitleTrack:d}});this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:m})}}},o.onManifestLoaded=function(h,C){var g=this;this.config.enableCEA708Captions&&C.captions&&C.captions.forEach(function(p){var k=/(?:CC|SERVICE)([1-4])/.exec(p.instreamId);if(!k)return;var E="textTrack"+k[1],f=g.captionsProperties[E];if(!f)return;f.label=p.name,p.lang&&(f.languageCode=p.lang),f.media=p})},o.onFragLoading=function(h,C){var g=this.cea608Parser1,p=this.cea608Parser2,k=this.lastSn,E=this.lastPartIndex;if(!this.enabled||!(g&&p))return;if(C.frag.type===y.PlaylistLevelType.MAIN){var f,m,d=C.frag.sn,a=(f=C==null||((m=C.part)===null||m===void 0)?void 0:m.index)!=null?f:-1;d===k+1||d===k&&a===E+1||(g.reset(),p.reset()),this.lastSn=d,this.lastPartIndex=a}},o.onFragLoaded=function(h,C){var g=C.frag,p=C.payload,k=this.initPTS,E=this.unparsedVttFrags;if(g.type===y.PlaylistLevelType.SUBTITLE)if(p.byteLength){if(!Object(Y.isFiniteNumber)(k[g.cc])){E.push(C),k.length&&this.hls.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:new Error("Missing initial subtitle PTS")});return}var f=g.decryptdata;if(f==null||f.key==null||f.method!=="AES-128"){var m=this.tracks[g.level],d=this.vttCCs;d[g.cc]||(d[g.cc]={start:g.start,prevCC:this.prevCC,new:!0},this.prevCC=g.cc),m&&m.textCodec===_.IMSC1_CODEC?this._parseIMSC1(g,p):this._parseVTTs(g,p,d)}}else this.hls.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(h,C){var g=this,p=this.hls;Object(_.parseIMSC1)(C,this.initPTS[h.cc],this.timescale[h.cc],function(k){g._appendCues(k,h.level),p.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(k){A.logger.log("Failed to parse IMSC1: "+k),p.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:k})})},o._parseVTTs=function(h,C,g){var p=this,k=this.hls;Object(U.parseWebVTT)(C,this.initPTS[h.cc],this.timescale[h.cc],g,h.cc,h.start,function(E){p._appendCues(E,h.level),k.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(E){p._fallbackToIMSC1(h,C),A.logger.log("Failed to parse VTT cue: "+E),k.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:E})})},o._fallbackToIMSC1=function(h,C){var g=this,p=this.tracks[h.level];p.textCodec||Object(_.parseIMSC1)(C,this.initPTS[h.cc],this.timescale[h.cc],function(){p.textCodec=_.IMSC1_CODEC,g._parseIMSC1(h,C)},function(){p.textCodec="wvtt"})},o._appendCues=function(h,C){var g=this.hls;if(this.config.renderTextTracksNatively){var p=this.textTracks[C];if(p.mode==="disabled")return;h.forEach(function(f){return Object(P.addCueToTrack)(p,f)})}else{var k=this.tracks[C],E=k.default?"default":"subtitles"+C;g.trigger(N.Events.CUES_PARSED,{type:"subtitles",cues:h,track:E})}},o.onFragDecrypted=function(h,C){var g=C.frag;if(g.type===y.PlaylistLevelType.SUBTITLE){if(!Object(Y.isFiniteNumber)(this.initPTS[g.cc])){this.unparsedVttFrags.push(C);return}this.onFragLoaded(N.Events.FRAG_LOADED,C)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(h,C){var g=this.cea608Parser1,p=this.cea608Parser2;if(!this.enabled||!(g&&p))return;for(var k=0;k<C.samples.length;k++){var E=C.samples[k].bytes;if(E){var f=this.extractCea608Data(E);g.addData(C.samples[k].pts,f[0]),p.addData(C.samples[k].pts,f[1])}}},o.onBufferFlushing=function(h,C){var g=C.startOffset,p=C.endOffset,k=C.endOffsetSubtitles,E=C.type,f=this.media;if(!f||f.currentTime<p)return;if(!E||E==="video"){var m=this.captionsTracks;Object.keys(m).forEach(function(a){return Object(P.removeCuesInRange)(m[a],g,p)})}if(this.config.renderTextTracksNatively&&(g===0&&k!==void 0)){var d=this.textTracks;Object.keys(d).forEach(function(a){return Object(P.removeCuesInRange)(d[a],g,k)})}},o.extractCea608Data=function(h){for(var C=h[0]&31,g=2,p=[[],[]],k=0;k<C;k++){var E=h[g++],f=127&h[g++],m=127&h[g++],d=(4&E)!==0,a=3&E;if(f===0&&m===0)continue;d&&((a===0||a===1)&&(p[a].push(f),p[a].push(m)))}return p},u}();function L(u,o){return u&&u.label===o.name&&!(u.textTrack1||u.textTrack2)}function w(u,o,l,h){return Math.min(o,h)-Math.max(u,l)}function b(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return Y});var Y=function(){function N(H,U){this.subtle=void 0,this.aesIV=void 0,this.subtle=H,this.aesIV=U}var M=N.prototype;return M.decrypt=function(U,P){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},P,U)},N}()},"./src/crypt/aes-decryptor.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"removePadding",function(){return N}),D.d(Z,"default",function(){return M});var Y=D("./src/utils/typed-array.ts");function N(H){var U=H.byteLength,P=U&&new DataView(H.buffer).getUint8(U-1);return P?Object(Y.sliceUint8)(H,0,U-P):H}var M=function(){function H(){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 U=H.prototype;return U.uint8ArrayToUint32Array_=function(_){for(var y=new DataView(_),A=new Uint32Array(4),R=0;R<4;R++)A[R]=y.getUint32(R*4);return A},U.initTable=function(){var _=this.sBox,y=this.invSBox,A=this.subMix,R=A[0],L=A[1],w=A[2],b=A[3],u=this.invSubMix,o=u[0],l=u[1],h=u[2],C=u[3],g=new Uint32Array(256),p=0,k=0,E=0;for(E=0;E<256;E++)E<128?g[E]=E<<1:g[E]=E<<1^283;for(E=0;E<256;E++){var f=k^k<<1^k<<2^k<<3^k<<4;f=f>>>8^f&255^99,_[p]=f,y[f]=p;var m=g[p],d=g[m],a=g[d],x=g[f]*257^f*16843008;R[p]=x<<24|x>>>8,L[p]=x<<16|x>>>16,w[p]=x<<8|x>>>24,b[p]=x,x=a*16843009^d*65537^m*257^p*16843008,o[f]=x<<24|x>>>8,l[f]=x<<16|x>>>16,h[f]=x<<8|x>>>24,C[f]=x,p?(p=m^g[g[g[a^m]]],k^=g[g[k]]):p=k=1}},U.expandKey=function(_){for(var y=this.uint8ArrayToUint32Array_(_),A=!0,R=0;R<y.length&&A;)A=y[R]===this.key[R],R++;if(A)return;this.key=y;var L=this.keySize=y.length;if(L!==4&&L!==6&&L!==8)throw new Error("Invalid aes key size="+L);var w=this.ksRows=(L+6+1)*4,b,u,o=this.keySchedule=new Uint32Array(w),l=this.invKeySchedule=new Uint32Array(w),h=this.sBox,C=this.rcon,g=this.invSubMix,p=g[0],k=g[1],E=g[2],f=g[3],m,d;for(b=0;b<w;b++){if(b<L){m=o[b]=y[b];continue}d=m,b%L===0?(d=d<<8|d>>>24,d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255],d^=C[b/L|0]<<24):L>6&&b%L===4&&(d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255]),o[b]=m=(o[b-L]^d)>>>0}for(u=0;u<w;u++)b=w-u,u&3?d=o[b]:d=o[b-4],u<4||b<=4?l[u]=d:l[u]=p[h[d>>>24]]^k[h[d>>>16&255]]^E[h[d>>>8&255]]^f[h[d&255]],l[u]=l[u]>>>0},U.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},U.decrypt=function(_,y,A){for(var R=this.keySize+6,L=this.invKeySchedule,w=this.invSBox,b=this.invSubMix,u=b[0],o=b[1],l=b[2],h=b[3],C=this.uint8ArrayToUint32Array_(A),g=C[0],p=C[1],k=C[2],E=C[3],f=new Int32Array(_),m=new Int32Array(f.length),d,a,x,v,T,I,G,V,Q,z,j,q,ie,ce,ve=this.networkToHostOrderSwap;y<f.length;){for(Q=ve(f[y]),z=ve(f[y+1]),j=ve(f[y+2]),q=ve(f[y+3]),T=Q^L[0],I=q^L[1],G=j^L[2],V=z^L[3],ie=4,ce=1;ce<R;ce++)d=u[T>>>24]^o[I>>16&255]^l[G>>8&255]^h[V&255]^L[ie],a=u[I>>>24]^o[G>>16&255]^l[V>>8&255]^h[T&255]^L[ie+1],x=u[G>>>24]^o[V>>16&255]^l[T>>8&255]^h[I&255]^L[ie+2],v=u[V>>>24]^o[T>>16&255]^l[I>>8&255]^h[G&255]^L[ie+3],T=d,I=a,G=x,V=v,ie=ie+4;d=w[T>>>24]<<24^w[I>>16&255]<<16^w[G>>8&255]<<8^w[V&255]^L[ie],a=w[I>>>24]<<24^w[G>>16&255]<<16^w[V>>8&255]<<8^w[T&255]^L[ie+1],x=w[G>>>24]<<24^w[V>>16&255]<<16^w[T>>8&255]<<8^w[I&255]^L[ie+2],v=w[V>>>24]<<24^w[T>>16&255]<<16^w[I>>8&255]<<8^w[G&255]^L[ie+3],m[y]=ve(d^g),m[y+1]=ve(v^p),m[y+2]=ve(x^k),m[y+3]=ve(a^E),g=Q,p=z,k=j,E=q,y=y+4}return m.buffer},H}()},"./src/crypt/decrypter.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return y});var Y=D("./src/crypt/aes-crypto.ts"),N=D("./src/crypt/fast-aes-key.ts"),M=D("./src/crypt/aes-decryptor.ts"),H=D("./src/utils/logger.ts"),U=D("./src/utils/mp4-tools.ts"),P=D("./src/utils/typed-array.ts"),_=16,y=function(){function A(L,w,b){var u=b===void 0?{}:b,o=u.removePKCS7Padding,l=o===void 0?!0:o;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=L,this.config=w,this.removePKCS7Padding=l,l)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch(C){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var R=A.prototype;return R.destroy=function(){this.observer=null},R.isSync=function(){return this.config.enableSoftwareAES},R.flush=function(){var w=this.currentResult;if(!w){this.reset();return}var b=new Uint8Array(w);return this.reset(),this.removePKCS7Padding?Object(M.removePadding)(b):b},R.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},R.decrypt=function(w,b,u,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(w),b,u);var l=this.flush();l&&o(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(w),b,u).then(o)},R.softwareDecrypt=function(w,b,u){var o=this.currentIV,l=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(w=Object(U.appendUint8Array)(h,w),this.remainderData=null);var C=this.getValidChunk(w);if(!C.length)return null;o&&(u=o);var g=this.softwareDecrypter;g||(g=this.softwareDecrypter=new M.default),g.expandKey(b);var p=l;return this.currentResult=g.decrypt(C.buffer,0,u),this.currentIV=Object(P.sliceUint8)(C,-16).buffer,p||null},R.webCryptoDecrypt=function(w,b,u){var o=this,l=this.subtle;return(this.key!==b||!this.fastAesKey)&&(this.key=b,this.fastAesKey=new N.default(l,b)),this.fastAesKey.expandKey().then(function(h){if(!l)return Promise.reject(new Error("web crypto not initialized"));var C=new Y.default(l,u);return C.decrypt(w.buffer,h)}).catch(function(h){return o.onWebCryptoError(h,w,b,u)})},R.onWebCryptoError=function(w,b,u,o){return H.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",w),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(b,u,o)},R.getValidChunk=function(w){var b=w,u=w.length-w.length%_;return u!==w.length&&(b=Object(P.sliceUint8)(w,0,u),this.remainderData=Object(P.sliceUint8)(w,u)),b},R.logOnce=function(w){if(!this.logEnabled)return;H.logger.log("[decrypter.ts]: "+w),this.logEnabled=!1},A}()},"./src/crypt/fast-aes-key.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return Y});var Y=function(){function N(H,U){this.subtle=void 0,this.key=void 0,this.subtle=H,this.key=U}var M=N.prototype;return M.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},N}()},"./src/demux/aacdemuxer.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/demux/base-audio-demuxer.ts"),N=D("./src/demux/adts.ts"),M=D("./src/utils/logger.ts"),H=D("./src/demux/id3.ts");function U(y,A){y.prototype=Object.create(A.prototype),y.prototype.constructor=y,P(y,A)}function P(y,A){return P=Object.setPrototypeOf||function(L,w){return L.__proto__=w,L},P(y,A)}var _=function(y){U(A,y);function A(L,w){var b;return b=y.call(this)||this,b.observer=void 0,b.config=void 0,b.observer=L,b.config=w,b}var R=A.prototype;return R.resetInitSegment=function(w,b,u){y.prototype.resetInitSegment.call(this,w,b,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:w,duration:u,inputTimeScale:9e4,dropped:0}},A.probe=function(w){if(!w)return!1;for(var b=H.getID3Data(w,0)||[],u=b.length,o=w.length;u<o;u++)if(N.probe(w,u))return M.logger.log("ADTS sync word found !"),!0;return!1},R.canParse=function(w,b){return N.canParse(w,b)},R.appendFrame=function(w,b,u){N.initTrackConfig(w,this.observer,b,u,w.manifestCodec);var o=N.appendFrame(w,b,u,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},A}(Y.default);_.minProbeByteLength=9,Z.default=_},"./src/demux/adts.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"getAudioConfig",function(){return H}),D.d(Z,"isHeaderPattern",function(){return U}),D.d(Z,"getHeaderLength",function(){return P}),D.d(Z,"getFullFrameLength",function(){return _}),D.d(Z,"canGetFrameLength",function(){return y}),D.d(Z,"isHeader",function(){return A}),D.d(Z,"canParse",function(){return R}),D.d(Z,"probe",function(){return L}),D.d(Z,"initTrackConfig",function(){return w}),D.d(Z,"getFrameDuration",function(){return b}),D.d(Z,"parseFrameHeader",function(){return u}),D.d(Z,"appendFrame",function(){return o});var Y=D("./src/utils/logger.ts"),N=D("./src/errors.ts"),M=D("./src/events.ts");function H(l,h,C,g){var p,k,E,f,m=navigator.userAgent.toLowerCase(),d=g,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];p=((h[C+2]&192)>>>6)+1;var x=(h[C+2]&60)>>>2;if(x>a.length-1){l.trigger(M.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+x});return}return E=(h[C+2]&1)<<2,E|=(h[C+3]&192)>>>6,Y.logger.log("manifest codec:"+g+", ADTS type:"+p+", samplingIndex:"+x),/firefox/i.test(m)?x>=6?(p=5,f=new Array(4),k=x-3):(p=2,f=new Array(2),k=x):m.indexOf("android")!==-1?(p=2,f=new Array(2),k=x):(p=5,f=new Array(4),g&&(g.indexOf("mp4a.40.29")!==-1||g.indexOf("mp4a.40.5")!==-1)||!g&&x>=6?k=x-3:((g&&g.indexOf("mp4a.40.2")!==-1&&(x>=6&&E===1||/vivaldi/i.test(m))||!g&&E===1)&&(p=2,f=new Array(2)),k=x)),f[0]=p<<3,f[0]|=(x&14)>>1,f[1]|=(x&1)<<7,f[1]|=E<<3,p===5&&(f[1]|=(k&14)>>1,f[2]=(k&1)<<7,f[2]|=2<<2,f[3]=0),{config:f,samplerate:a[x],channelCount:E,codec:"mp4a.40."+p,manifestCodec:d}}function U(l,h){return l[h]===255&&(l[h+1]&246)===240}function P(l,h){return l[h+1]&1?7:9}function _(l,h){return(l[h+3]&3)<<11|l[h+4]<<3|(l[h+5]&224)>>>5}function y(l,h){return h+5<l.length}function A(l,h){return h+1<l.length&&U(l,h)}function R(l,h){return y(l,h)&&U(l,h)&&_(l,h)<=l.length-h}function L(l,h){if(A(l,h)){var C=P(l,h);if(h+C>=l.length)return!1;var g=_(l,h);if(g<=C)return!1;var p=h+g;return p===l.length||A(l,p)}return!1}function w(l,h,C,g,p){if(!l.samplerate){var k=H(h,C,g,p);if(!k)return;l.config=k.config,l.samplerate=k.samplerate,l.channelCount=k.channelCount,l.codec=k.codec,l.manifestCodec=k.manifestCodec,Y.logger.log("parsed codec:"+l.codec+", rate:"+k.samplerate+", channels:"+k.channelCount)}}function b(l){return 1024*9e4/l}function u(l,h,C,g,p){var k=P(l,h),E=_(l,h);if(E-=k,E>0){var f=C+g*p;return{headerLength:k,frameLength:E,stamp:f}}}function o(l,h,C,g,p){var k=b(l.samplerate),E=u(h,C,g,p,k);if(E){var f=E.frameLength,m=E.headerLength,d=E.stamp,a=m+f,x=Math.max(0,C+a-h.length),v;x?(v=new Uint8Array(a-m),v.set(h.subarray(C+m,h.length),0)):v=h.subarray(C+m,C+a);var T={unit:v,pts:d};return x||l.samples.push(T),{sample:T,length:a,missing:x}}}},"./src/demux/base-audio-demuxer.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"initPTSFn",function(){return _});var Y=D("./src/polyfills/number.ts"),N=D("./src/demux/id3.ts"),M=D("./src/demux/dummy-demuxed-track.ts"),H=D("./src/utils/mp4-tools.ts"),U=D("./src/utils/typed-array.ts"),P=function(){function y(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var A=y.prototype;return A.resetInitSegment=function(L,w,b){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},A.resetTimeStamp=function(){},A.resetContiguity=function(){},A.canParse=function(L,w){return!1},A.appendFrame=function(L,w,b){},A.demux=function(L,w){this.cachedData&&(L=Object(H.appendUint8Array)(this.cachedData,L),this.cachedData=null);var b=N.getID3Data(L,0),u=b?b.length:0,o,l,h=this._audioTrack,C=this._id3Track,g=b?N.getTimeStamp(b):void 0,p=L.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=_(g,w)),b&&b.length>0&&C.samples.push({pts:this.initPTS,dts:this.initPTS,data:b}),l=this.initPTS;u<p;){if(this.canParse(L,u)){var k=this.appendFrame(h,L,u);k?(this.frameIndex++,l=k.sample.pts,u+=k.length,o=u):u=p}else N.canParse(L,u)?(b=N.getID3Data(L,u),C.samples.push({pts:l,dts:l,data:b}),u+=b.length,o=u):u++;if(u===p&&o!==p){var E=Object(U.sliceUint8)(L,o);this.cachedData?this.cachedData=Object(H.appendUint8Array)(this.cachedData,E):this.cachedData=E}}return{audioTrack:h,avcTrack:Object(M.dummyTrack)(),id3Track:C,textTrack:Object(M.dummyTrack)()}},A.demuxSampleAes=function(L,w,b){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},A.flush=function(L){var w=this.cachedData;return w&&(this.cachedData=null,this.demux(w,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(M.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(M.dummyTrack)()}},A.destroy=function(){},y}(),_=function(A,R){return Object(Y.isFiniteNumber)(A)?A*90:R*9e4};Z.default=P},"./src/demux/chunk-cache.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return Y});var Y=function(){function M(){this.chunks=[],this.dataLength=0}var H=M.prototype;return H.push=function(P){this.chunks.push(P),this.dataLength+=P.length},H.flush=function(){var P=this.chunks,_=this.dataLength,y;if(P.length)P.length===1?y=P[0]:y=N(P,_);else return new Uint8Array(0);return this.reset(),y},H.reset=function(){this.chunks.length=0,this.dataLength=0},M}();function N(M,H){for(var U=new Uint8Array(H),P=0,_=0;_<M.length;_++){var y=M[_];U.set(y,P),P+=y.length}return U}},"./src/demux/dummy-demuxed-track.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"dummyTrack",function(){return Y});function Y(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/utils/logger.ts"),N=function(){function M(U){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=U,this.bytesAvailable=U.byteLength,this.word=0,this.bitsAvailable=0}var H=M.prototype;return H.loadWord=function(){var P=this.data,_=this.bytesAvailable,y=P.byteLength-_,A=new Uint8Array(4),R=Math.min(4,_);if(R===0)throw new Error("no bytes available");A.set(P.subarray(y,y+R)),this.word=new DataView(A.buffer).getUint32(0),this.bitsAvailable=R*8,this.bytesAvailable-=R},H.skipBits=function(P){var _;this.bitsAvailable>P?(this.word<<=P,this.bitsAvailable-=P):(P-=this.bitsAvailable,_=P>>3,P-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=P,this.bitsAvailable-=P)},H.readBits=function(P){var _=Math.min(this.bitsAvailable,P),y=this.word>>>32-_;return P>32&&Y.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=P-_,_>0&&this.bitsAvailable?y<<_|this.readBits(_):y},H.skipLZ=function(){var P;for(P=0;P<this.bitsAvailable;++P)if((this.word&2147483648>>>P)!==0)return this.word<<=P,this.bitsAvailable-=P,P;return this.loadWord(),P+this.skipLZ()},H.skipUEG=function(){this.skipBits(1+this.skipLZ())},H.skipEG=function(){this.skipBits(1+this.skipLZ())},H.readUEG=function(){var P=this.skipLZ();return this.readBits(P+1)-1},H.readEG=function(){var P=this.readUEG();return 1&P?1+P>>>1:-1*(P>>>1)},H.readBoolean=function(){return this.readBits(1)===1},H.readUByte=function(){return this.readBits(8)},H.readUShort=function(){return this.readBits(16)},H.readUInt=function(){return this.readBits(32)},H.skipScalingList=function(P){for(var _=8,y=8,A,R=0;R<P;R++)y!==0&&(A=this.readEG(),y=(_+A+256)%256),_=y===0?_:y},H.readSPS=function(){var P=0,_=0,y=0,A=0,R,L,w,b=this.readUByte.bind(this),u=this.readBits.bind(this),o=this.readUEG.bind(this),l=this.readBoolean.bind(this),h=this.skipBits.bind(this),C=this.skipEG.bind(this),g=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);b();var k=b();if(u(5),h(3),b(),g(),k===100||k===110||k===122||k===244||k===44||k===83||k===86||k===118||k===128){var E=o();if(E===3&&h(1),g(),g(),h(1),l())for(L=E!==3?8:12,w=0;w<L;w++)l()&&(w<6?p(16):p(64))}g();var f=o();if(f===0)o();else if(f===1)for(h(1),C(),C(),R=o(),w=0;w<R;w++)C();g(),h(1);var m=o(),d=o(),a=u(1);a===0&&h(1),h(1),l()&&(P=o(),_=o(),y=o(),A=o());var x=[1,1];if(l()&&l()){var v=b();switch(v){case 1:x=[1,1];break;case 2:x=[12,11];break;case 3:x=[10,11];break;case 4:x=[16,11];break;case 5:x=[40,33];break;case 6:x=[24,11];break;case 7:x=[20,11];break;case 8:x=[32,11];break;case 9:x=[80,33];break;case 10:x=[18,11];break;case 11:x=[15,11];break;case 12:x=[64,33];break;case 13:x=[160,99];break;case 14:x=[4,3];break;case 15:x=[3,2];break;case 16:x=[2,1];break;case 255:{x=[b()<<8|b(),b()<<8|b()];break}}}return{width:Math.ceil((m+1)*16-P*2-_*2),height:(2-a)*(d+1)*16-(a?2:4)*(y+A),pixelRatio:x}},H.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},M}();Z.default=N},"./src/demux/id3.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"isHeader",function(){return Y}),D.d(Z,"isFooter",function(){return N}),D.d(Z,"getID3Data",function(){return M}),D.d(Z,"canParse",function(){return U}),D.d(Z,"getTimeStamp",function(){return P}),D.d(Z,"isTimeStampFrame",function(){return _}),D.d(Z,"getID3Frames",function(){return A}),D.d(Z,"decodeFrame",function(){return R}),D.d(Z,"utf8ArrayToStr",function(){return o}),D.d(Z,"testables",function(){return l});var Y=function(p,k){return k+10<=p.length&&(p[k]===73&&p[k+1]===68&&p[k+2]===51&&(p[k+3]<255&&p[k+4]<255&&(p[k+6]<128&&p[k+7]<128&&p[k+8]<128&&p[k+9]<128)))},N=function(p,k){return k+10<=p.length&&(p[k]===51&&p[k+1]===68&&p[k+2]===73&&(p[k+3]<255&&p[k+4]<255&&(p[k+6]<128&&p[k+7]<128&&p[k+8]<128&&p[k+9]<128)))},M=function(p,k){for(var E=k,f=0;Y(p,k);){f+=10;var m=H(p,k+6);f+=m,N(p,k+10)&&(f+=10),k+=f}return f>0?p.subarray(E,E+f):void 0},H=function(p,k){var E=0;return E=(p[k]&127)<<21,E|=(p[k+1]&127)<<14,E|=(p[k+2]&127)<<7,E|=p[k+3]&127,E},U=function(p,k){return Y(p,k)&&H(p,k+6)+10<=p.length-k},P=function(p){for(var k=A(p),E=0;E<k.length;E++){var f=k[E];if(_(f))return u(f)}return},_=function(p){return p&&p.key==="PRIV"&&p.info==="com.apple.streaming.transportStreamTimestamp"},y=function(p){var k=String.fromCharCode(p[0],p[1],p[2],p[3]),E=H(p,4),f=10;return{type:k,size:E,data:p.subarray(f,f+E)}},A=function(p){for(var k=0,E=[];Y(p,k);){var f=H(p,k+6);k+=10;for(var m=k+f;k+8<m;){var d=y(p.subarray(k)),a=R(d);a&&E.push(a),k+=d.size+10}N(p,k)&&(k+=10)}return E},R=function(p){return p.type==="PRIV"?L(p):p.type[0]==="W"?b(p):w(p)},L=function(p){if(p.size<2)return;var k=o(p.data,!0),E=new Uint8Array(p.data.subarray(k.length+1));return{key:p.type,info:k,data:E.buffer}},w=function(p){if(p.size<2)return;if(p.type==="TXXX"){var k=1,E=o(p.data.subarray(k),!0);k+=E.length+1;var f=o(p.data.subarray(k));return{key:p.type,info:E,data:f}}var m=o(p.data.subarray(1));return{key:p.type,data:m}},b=function(p){if(p.type==="WXXX"){if(p.size<2)return;var k=1,E=o(p.data.subarray(k),!0);k+=E.length+1;var f=o(p.data.subarray(k));return{key:p.type,info:E,data:f}}var m=o(p.data);return{key:p.type,data:m}},u=function(p){if(p.data.byteLength===8){var k=new Uint8Array(p.data),E=k[3]&1,f=(k[4]<<23)+(k[5]<<15)+(k[6]<<7)+k[7];return f/=45,E&&(f+=4772185884e-2),Math.round(f)}return},o=function(p,k){k===void 0&&(k=!1);var E=C();if(E){var f=E.decode(p);if(k){var m=f.indexOf("\0");return m!==-1?f.substring(0,m):f}return f.replace(/\0/g,"")}for(var d=p.length,a,x,v,T="",I=0;I<d;){if(a=p[I++],a===0&&k)return T;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:T+=String.fromCharCode(a);break;case 12:case 13:x=p[I++],T+=String.fromCharCode((a&31)<<6|x&63);break;case 14:x=p[I++],v=p[I++],T+=String.fromCharCode((a&15)<<12|(x&63)<<6|(v&63)<<0);break;default:}}return T},l={decodeTextFrame:w},h;function C(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/demux/base-audio-demuxer.ts"),N=D("./src/demux/id3.ts"),M=D("./src/utils/logger.ts"),H=D("./src/demux/mpegaudio.ts");function U(y,A){y.prototype=Object.create(A.prototype),y.prototype.constructor=y,P(y,A)}function P(y,A){return P=Object.setPrototypeOf||function(L,w){return L.__proto__=w,L},P(y,A)}var _=function(y){U(A,y);function A(){return y.apply(this,arguments)||this}var R=A.prototype;return R.resetInitSegment=function(w,b,u){y.prototype.resetInitSegment.call(this,w,b,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:w,duration:u,inputTimeScale:9e4,dropped:0}},A.probe=function(w){if(!w)return!1;for(var b=N.getID3Data(w,0)||[],u=b.length,o=w.length;u<o;u++)if(H.probe(w,u))return M.logger.log("MPEG Audio sync word found !"),!0;return!1},R.canParse=function(w,b){return H.canParse(w,b)},R.appendFrame=function(w,b,u){return this.initPTS===null?void 0:H.appendFrame(w,b,u,this.initPTS,this.frameIndex)},A}(Y.default);_.minProbeByteLength=4,Z.default=_},"./src/demux/mp4demuxer.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/utils/mp4-tools.ts"),N=D("./src/demux/dummy-demuxed-track.ts"),M=function(){function H(P,_){this.remainderData=null,this.config=void 0,this.config=_}var U=H.prototype;return U.resetTimeStamp=function(){},U.resetInitSegment=function(){},U.resetContiguity=function(){},H.probe=function(_){return Object(Y.findBox)({data:_,start:0,end:Math.min(_.length,16384)},["moof"]).length>0},U.demux=function(_){var y=_,A=Object(N.dummyTrack)();if(this.config.progressive){this.remainderData&&(y=Object(Y.appendUint8Array)(this.remainderData,_));var R=Object(Y.segmentValidRange)(y);this.remainderData=R.remainder,A.samples=R.valid||new Uint8Array}else A.samples=y;return{audioTrack:Object(N.dummyTrack)(),avcTrack:A,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},U.flush=function(){var _=Object(N.dummyTrack)();return _.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(N.dummyTrack)(),avcTrack:_,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},U.demuxSampleAes=function(_,y,A){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},U.destroy=function(){},H}();M.minProbeByteLength=1024,Z.default=M},"./src/demux/mpegaudio.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"appendFrame",function(){return P}),D.d(Z,"parseHeader",function(){return _}),D.d(Z,"isHeaderPattern",function(){return y}),D.d(Z,"isHeader",function(){return A}),D.d(Z,"canParse",function(){return R}),D.d(Z,"probe",function(){return L});var Y=null,N=[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],M=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],H=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],U=[0,1,1,4];function P(w,b,u,o,l){if(u+24>b.length)return;var h=_(b,u);if(h&&u+h.frameLength<=b.length){var C=h.samplesPerFrame*9e4/h.sampleRate,g=o+l*C,p={unit:b.subarray(u,u+h.frameLength),pts:g,dts:g};return w.config=[],w.channelCount=h.channelCount,w.samplerate=h.sampleRate,w.samples.push(p),{sample:p,length:h.frameLength,missing:0}}}function _(w,b){var u=w[b+1]>>3&3,o=w[b+1]>>1&3,l=w[b+2]>>4&15,h=w[b+2]>>2&3;if(u!==1&&l!==0&&l!==15&&h!==3){var C=w[b+2]>>1&1,g=w[b+3]>>6,p=u===3?3-o:o===3?3:4,k=N[p*14+l-1]*1e3,E=u===3?0:u===2?1:2,f=M[E*3+h],m=g===3?1:2,d=H[u][o],a=U[o],x=d*8*a,v=Math.floor(d*k/f+C)*a;if(Y===null){var T=navigator.userAgent||"",I=T.match(/Chrome\/(\d+)/i);Y=I?parseInt(I[1]):0}var G=!!Y&&Y<=87;return G&&o===2&&k>=224e3&&g===0&&(w[b+3]=w[b+3]|128),{sampleRate:f,channelCount:m,frameLength:v,samplesPerFrame:x}}}function y(w,b){return w[b]===255&&(w[b+1]&224)===224&&(w[b+1]&6)!==0}function A(w,b){return b+1<w.length&&y(w,b)}function R(w,b){var u=4;return y(w,b)&&u<=w.length-b}function L(w,b){if(b+1<w.length&&y(w,b)){var u=4,o=_(w,b),l=u;o!=null&&o.frameLength&&(l=o.frameLength);var h=b+l;return h===w.length||A(w,h)}return!1}},"./src/demux/sample-aes.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/crypt/decrypter.ts"),N=D("./src/demux/tsdemuxer.ts"),M=function(){function H(P,_,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new Y.default(P,_,{removePKCS7Padding:!1})}var U=H.prototype;return U.decryptBuffer=function(_,y){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,y)},U.decryptAacSample=function(_,y,A,R){var L=_[y].unit,w=L.subarray(16,L.length-L.length%16),b=w.buffer.slice(w.byteOffset,w.byteOffset+w.length),u=this;this.decryptBuffer(b,function(o){var l=new Uint8Array(o);L.set(l,16),R||u.decryptAacSamples(_,y+1,A)})},U.decryptAacSamples=function(_,y,A){for(;;y++){if(y>=_.length){A();return}if(_[y].unit.length<32)continue;var R=this.decrypter.isSync();if(this.decryptAacSample(_,y,A,R),!R)return}},U.getAvcEncryptedData=function(_){for(var y=Math.floor((_.length-48)/160)*16+16,A=new Int8Array(y),R=0,L=32;L<=_.length-16;L+=160,R+=16)A.set(_.subarray(L,L+16),R);return A},U.getAvcDecryptedUnit=function(_,y){for(var A=new Uint8Array(y),R=0,L=32;L<=_.length-16;L+=160,R+=16)_.set(A.subarray(R,R+16),L);return _},U.decryptAvcSample=function(_,y,A,R,L,w){var b=Object(N.discardEPB)(L.data),u=this.getAvcEncryptedData(b),o=this;this.decryptBuffer(u.buffer,function(l){L.data=o.getAvcDecryptedUnit(b,l),w||o.decryptAvcSamples(_,y,A+1,R)})},U.decryptAvcSamples=function(_,y,A,R){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,A=0){if(y>=_.length){R();return}for(var L=_[y].units;!(A>=L.length);A++){var w=L[A];if(w.data.length<=48||w.type!==1&&w.type!==5)continue;var b=this.decrypter.isSync();if(this.decryptAvcSample(_,y,A,R,w,b),!b)return}}},H}();Z.default=M},"./src/demux/transmuxer-interface.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return L});var Y=D("./node_modules/webworkify-webpack/index.js"),N=D.n(Y),M=D("./src/events.ts"),H=D("./src/demux/transmuxer.ts"),U=D("./src/utils/logger.ts"),P=D("./src/errors.ts"),_=D("./src/utils/mediasource-helper.ts"),y=D("./node_modules/eventemitter3/index.js"),A=D.n(y),R=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},L=function(){function w(u,o,l,h){var C=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=u,this.id=o,this.onTransmuxComplete=l,this.onFlush=h;var g=u.config,p=function(d,a){a=a||{},a.frag=C.frag,a.id=C.id,u.trigger(d,a)};this.observer=new y.EventEmitter,this.observer.on(M.Events.FRAG_DECRYPTED,p),this.observer.on(M.Events.ERROR,p);var k={mp4:R.isTypeSupported("video/mp4"),mpeg:R.isTypeSupported("audio/mpeg"),mp3:R.isTypeSupported('audio/mp4; codecs="mp3"')},E=navigator.vendor;if(g.enableWorker&&typeof Worker!="undefined"){U.logger.log("demuxing in webworker");var f;try{f=this.worker=Y("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),f.addEventListener("message",this.onwmsg),f.onerror=function(m){u.trigger(M.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(m.message+" ("+m.filename+":"+m.lineno+")")})},f.postMessage({cmd:"init",typeSupported:k,vendor:E,id:o,config:JSON.stringify(g)})}catch(m){U.logger.warn("Error in worker:",m),U.logger.error("Error while initializing DemuxerWorker, fallback to inline"),f&&self.URL.revokeObjectURL(f.objectURL),this.transmuxer=new H.default(this.observer,k,g,E,o),this.worker=null}}else this.transmuxer=new H.default(this.observer,k,g,E,o)}var b=w.prototype;return b.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var l=this.transmuxer;l&&(l.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.observer=null},b.push=function(o,l,h,C,g,p,k,E,f,m){var d=this;f.transmuxing.start=self.performance.now();var a=this.transmuxer,x=this.worker,v=p?p.start:g.start,T=g.decryptdata,I=this.frag,G=!(I&&g.cc===I.cc),V=!(I&&f.level===I.level),Q=I?f.sn-I.sn:-1,z=this.part?f.part-this.part.index:1,j=!V&&(Q===1||Q===0&&z===1),q=self.performance.now();(V||Q||g.stats.parsing.start===0)&&(g.stats.parsing.start=q),p&&(z||!j)&&(p.stats.parsing.start=q);var ie=new H.TransmuxState(G,j,E,V,v);if(!j||G){U.logger.log("[transmuxer-interface, "+g.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+`
discontinuity: `+G+`
trackSwitch: `+V+`
contiguous: `+j+`
accurateTimeOffset: `+E+`
timeOffset: `+v);var ce=new H.TransmuxConfig(h,C,l,k,m);this.configureTransmuxer(ce)}if(this.frag=g,this.part=p,x)x.postMessage({cmd:"demux",data:o,decryptdata:T,chunkMeta:f,state:ie},o instanceof ArrayBuffer?[o]:[]);else if(a){var ve=a.push(o,T,f,ie);Object(H.isPromise)(ve)?ve.then(function(Oe){d.handleTransmuxComplete(Oe)}):this.handleTransmuxComplete(ve)}},b.flush=function(o){var l=this;o.transmuxing.start=self.performance.now();var h=this.transmuxer,C=this.worker;if(C)C.postMessage({cmd:"flush",chunkMeta:o});else if(h){var g=h.flush(o);Object(H.isPromise)(g)?g.then(function(p){l.handleFlushResult(p,o)}):this.handleFlushResult(g,o)}},b.handleFlushResult=function(o,l){var h=this;o.forEach(function(C){h.handleTransmuxComplete(C)}),this.onFlush(l)},b.onWorkerMessage=function(o){var l=o.data,h=this.hls;switch(l.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.id=this.id,h.trigger(l.event,l.data);break}}},b.configureTransmuxer=function(o){var l=this.worker,h=this.transmuxer;l?l.postMessage({cmd:"configure",config:o}):h&&h.configure(o)},b.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},w}()},"./src/demux/transmuxer-worker.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return P});var Y=D("./src/demux/transmuxer.ts"),N=D("./src/events.ts"),M=D("./src/utils/logger.ts"),H=D("./node_modules/eventemitter3/index.js"),U=D.n(H);function P(L){var w=new H.EventEmitter,b=function(o,l){L.postMessage({event:o,data:l})};w.on(N.Events.FRAG_DECRYPTED,b),w.on(N.Events.ERROR,b),L.addEventListener("message",function(u){var o=u.data;switch(o.cmd){case"init":{var l=JSON.parse(o.config);L.transmuxer=new Y.default(w,o.typeSupported,l,o.vendor,o.id),Object(M.enableLogs)(l.debug),b("init",null);break}case"configure":{L.transmuxer.configure(o.config);break}case"demux":{var h=L.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(Y.isPromise)(h)?h.then(function(p){_(L,p)}):_(L,h);break}case"flush":{var C=o.chunkMeta,g=L.transmuxer.flush(C);Object(Y.isPromise)(g)?g.then(function(p){A(L,p,C)}):A(L,g,C);break}default:break}})}function _(L,w){if(R(w.remuxResult))return;var b=[],u=w.remuxResult,o=u.audio,l=u.video;o&&y(b,o),l&&y(b,l),L.postMessage({event:"transmuxComplete",data:w},b)}function y(L,w){w.data1&&L.push(w.data1.buffer),w.data2&&L.push(w.data2.buffer)}function A(L,w,b){w.forEach(function(u){_(L,u)}),L.postMessage({event:"flush",data:b})}function R(L){return!L.audio&&!L.video&&!L.text&&!L.id3&&!L.initSegment}},"./src/demux/transmuxer.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return l}),D.d(Z,"isPromise",function(){return g}),D.d(Z,"TransmuxConfig",function(){return p}),D.d(Z,"TransmuxState",function(){return k});var Y=D("./src/events.ts"),N=D("./src/errors.ts"),M=D("./src/crypt/decrypter.ts"),H=D("./src/demux/aacdemuxer.ts"),U=D("./src/demux/mp4demuxer.ts"),P=D("./src/demux/tsdemuxer.ts"),_=D("./src/demux/mp3demuxer.ts"),y=D("./src/remux/mp4-remuxer.ts"),A=D("./src/remux/passthrough-remuxer.ts"),R=D("./src/demux/chunk-cache.ts"),L=D("./src/utils/mp4-tools.ts"),w=D("./src/utils/logger.ts"),b;try{b=self.performance.now.bind(self.performance)}catch(E){w.logger.debug("Unable to use Performance API on this environment"),b=self.Date.now}var u=[{demux:P.default,remux:y.default},{demux:U.default,remux:A.default},{demux:H.default,remux:y.default},{demux:_.default,remux:y.default}],o=1024;u.forEach(function(E){var f=E.demux;o=Math.max(o,f.minProbeByteLength)});var l=function(){function E(m,d,a,x,v){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new R.default,this.observer=m,this.typeSupported=d,this.config=a,this.vendor=x,this.id=v}var f=E.prototype;return f.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},f.push=function(d,a,x,v){var T=this,I=x.transmuxing;I.executeStart=b();var G=new Uint8Array(d),V=this.cache,Q=this.config,z=this.currentTransmuxState,j=this.transmuxConfig;v&&(this.currentTransmuxState=v);var q=h(G,a);if(q&&q.method==="AES-128"){var ie=this.getDecrypter();if(Q.enableSoftwareAES){var ce=ie.softwareDecrypt(G,q.key.buffer,q.iv.buffer);if(!ce)return I.executeEnd=b(),C(x);G=new Uint8Array(ce)}else return this.decryptionPromise=ie.webCryptoDecrypt(G,q.key.buffer,q.iv.buffer).then(function(Ie){var He=T.push(Ie,null,x);return T.decryptionPromise=null,He}),this.decryptionPromise}var ve=v||z,Oe=ve.contiguous,xe=ve.discontinuity,Te=ve.trackSwitch,we=ve.accurateTimeOffset,Se=ve.timeOffset,pe=j.audioCodec,oe=j.videoCodec,De=j.defaultInitPts,Ve=j.duration,ze=j.initSegmentData;if((xe||Te)&&this.resetInitSegment(ze,pe,oe,Ve),xe&&this.resetInitialTimestamp(De),Oe||this.resetContiguity(),this.needsProbing(G,xe,Te)){if(V.dataLength){var et=V.flush();G=Object(L.appendUint8Array)(et,G)}this.configureTransmuxer(G,j)}var Je=this.transmux(G,q,Se,we,x),ke=this.currentTransmuxState;return ke.contiguous=!0,ke.discontinuity=!1,ke.trackSwitch=!1,I.executeEnd=b(),Je},f.flush=function(d){var a=this,x=d.transmuxing;x.executeStart=b();var v=this.decrypter,T=this.cache,I=this.currentTransmuxState,G=this.decryptionPromise;if(G)return G.then(function(){return a.flush(d)});var V=[],Q=I.timeOffset;if(v){var z=v.flush();z&&V.push(this.push(z,null,d))}var j=T.dataLength;T.reset();var q=this.demuxer,ie=this.remuxer;if(!q||!ie)return j>=o&&this.observer.emit(Y.Events.ERROR,Y.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),x.executeEnd=b(),[C(d)];var ce=q.flush(Q);return g(ce)?ce.then(function(ve){return a.flushRemux(V,ve,d),V}):(this.flushRemux(V,ce,d),V)},f.flushRemux=function(d,a,x){var v=a.audioTrack,T=a.avcTrack,I=a.id3Track,G=a.textTrack,V=this.currentTransmuxState,Q=V.accurateTimeOffset,z=V.timeOffset;w.logger.log("[transmuxer.ts]: Flushed fragment "+x.sn+(x.part>-1?" p: "+x.part:"")+" of level "+x.level);var j=this.remuxer.remux(v,T,I,G,z,Q,!0,this.id);d.push({remuxResult:j,chunkMeta:x}),x.transmuxing.executeEnd=b()},f.resetInitialTimestamp=function(d){var a=this.demuxer,x=this.remuxer;if(!a||!x)return;a.resetTimeStamp(d),x.resetTimeStamp(d)},f.resetContiguity=function(){var d=this.demuxer,a=this.remuxer;if(!d||!a)return;d.resetContiguity(),a.resetNextTimestamp()},f.resetInitSegment=function(d,a,x,v){var T=this.demuxer,I=this.remuxer;if(!T||!I)return;T.resetInitSegment(a,x,v),I.resetInitSegment(d,a,x)},f.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},f.transmux=function(d,a,x,v,T){var I;return a&&a.method==="SAMPLE-AES"?I=this.transmuxSampleAes(d,a,x,v,T):I=this.transmuxUnencrypted(d,x,v,T),I},f.transmuxUnencrypted=function(d,a,x,v){var T=this.demuxer.demux(d,a,!1,!this.config.progressive),I=T.audioTrack,G=T.avcTrack,V=T.id3Track,Q=T.textTrack,z=this.remuxer.remux(I,G,V,Q,a,x,!1,this.id);return{remuxResult:z,chunkMeta:v}},f.transmuxSampleAes=function(d,a,x,v,T){var I=this;return this.demuxer.demuxSampleAes(d,a,x).then(function(G){var V=I.remuxer.remux(G.audioTrack,G.avcTrack,G.id3Track,G.textTrack,x,v,!1,I.id);return{remuxResult:V,chunkMeta:T}})},f.configureTransmuxer=function(d,a){for(var x=this.config,v=this.observer,T=this.typeSupported,I=this.vendor,G=a.audioCodec,V=a.defaultInitPts,Q=a.duration,z=a.initSegmentData,j=a.videoCodec,q,ie=0,ce=u.length;ie<ce;ie++)if(u[ie].demux.probe(d)){q=u[ie];break}q||(w.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),q={demux:U.default,remux:A.default});var ve=this.demuxer,Oe=this.remuxer,xe=q.remux,Te=q.demux;(!Oe||!(Oe instanceof xe))&&(this.remuxer=new xe(v,x,T,I)),(!ve||!(ve instanceof Te))&&(this.demuxer=new Te(v,x,T),this.probe=Te.probe),this.resetInitSegment(z,G,j,Q),this.resetInitialTimestamp(V)},f.needsProbing=function(d,a,x){return!this.demuxer||!this.remuxer||a||x},f.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new M.default(this.observer,this.config)),d},E}();function h(E,f){var m=null;return E.byteLength>0&&f!=null&&f.key!=null&&f.iv!==null&&f.method!=null&&(m=f),m}var C=function(f){return{remuxResult:{},chunkMeta:f}};function g(E){return"then"in E&&E.then instanceof Function}var p=function(f,m,d,a,x){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=f,this.videoCodec=m,this.initSegmentData=d,this.duration=a,this.defaultInitPts=x},k=function(f,m,d,a,x){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=f,this.contiguous=m,this.accurateTimeOffset=d,this.trackSwitch=a,this.timeOffset=x}},"./src/demux/tsdemuxer.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"discardEPB",function(){return C});var Y=D("./src/demux/adts.ts"),N=D("./src/demux/mpegaudio.ts"),M=D("./src/demux/exp-golomb.ts"),H=D("./src/demux/id3.ts"),U=D("./src/demux/sample-aes.ts"),P=D("./src/events.ts"),_=D("./src/utils/mp4-tools.ts"),y=D("./src/utils/logger.ts"),A=D("./src/errors.ts"),R={video:1,audio:2,id3:3,text:4},L=function(){function g(k,E,f){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=k,this.config=E,this.typeSupported=f}g.probe=function(E){var f=g.syncOffset(E);return f<0?!1:(f&&y.logger.warn("MPEG2-TS detected but first sync word found @ offset "+f+", junk ahead ?"),!0)},g.syncOffset=function(E){for(var f=Math.min(1e3,E.length-3*188),m=0;m<f;){if(E[m]===71&&E[m+188]===71&&E[m+2*188]===71)return m;m++}return-1},g.createTrack=function(E,f){return{container:E==="video"||E==="audio"?"video/mp2t":void 0,type:E,id:R[E],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:E==="audio"?f:void 0}};var p=g.prototype;return p.resetInitSegment=function(E,f,m){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video",m),this._audioTrack=g.createTrack("audio",m),this._id3Track=g.createTrack("id3",m),this._txtTrack=g.createTrack("text",m),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=E,this.videoCodec=f,this._duration=m},p.resetTimeStamp=function(){},p.resetContiguity=function(){var E=this._audioTrack,f=this._avcTrack,m=this._id3Track;E&&(E.pesData=null),f&&(f.pesData=null),m&&(m.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},p.demux=function(E,f,m,d){m===void 0&&(m=!1),d===void 0&&(d=!1),m||(this.sampleAes=null);var a,x=this._avcTrack,v=this._audioTrack,T=this._id3Track,I=x.pid,G=x.pesData,V=v.pid,Q=T.pid,z=v.pesData,j=T.pesData,q=!1,ie=this.pmtParsed,ce=this._pmtId,ve=E.length;if(this.remainderData&&(E=Object(_.appendUint8Array)(this.remainderData,E),ve=E.length,this.remainderData=null),ve<188&&!d)return this.remainderData=E,{audioTrack:v,avcTrack:x,id3Track:T,textTrack:this._txtTrack};var Oe=Math.max(0,g.syncOffset(E));ve-=(ve+Oe)%188,ve<E.byteLength&&!d&&(this.remainderData=new Uint8Array(E.buffer,ve,E.buffer.byteLength-ve));for(var xe=Oe;xe<ve;xe+=188)if(E[xe]===71){var Te=!!(E[xe+1]&64),we=((E[xe+1]&31)<<8)+E[xe+2],Se=(E[xe+3]&48)>>4,pe=void 0;if(Se>1){if(pe=xe+5+E[xe+4],pe===xe+188)continue}else pe=xe+4;switch(we){case I:Te&&(G&&(a=o(G))&&this.parseAVCPES(a,!1),G={data:[],size:0}),G&&(G.data.push(E.subarray(pe,xe+188)),G.size+=xe+188-pe);break;case V:Te&&(z&&(a=o(z))&&(v.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),z={data:[],size:0}),z&&(z.data.push(E.subarray(pe,xe+188)),z.size+=xe+188-pe);break;case Q:Te&&(j&&(a=o(j))&&this.parseID3PES(a),j={data:[],size:0}),j&&(j.data.push(E.subarray(pe,xe+188)),j.size+=xe+188-pe);break;case 0:Te&&(pe+=E[pe]+1),ce=this._pmtId=b(E,pe);break;case ce:{Te&&(pe+=E[pe]+1);var oe=u(E,pe,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,m);I=oe.avc,I>0&&(x.pid=I),V=oe.audio,V>0&&(v.pid=V,v.isAAC=oe.isAAC),Q=oe.id3,Q>0&&(T.pid=Q),q&&!ie&&(y.logger.log("reparse from beginning"),q=!1,xe=Oe-188),ie=this.pmtParsed=!0;break}case 17:case 8191:break;default:q=!0;break}}else this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});x.pesData=G,v.pesData=z,T.pesData=j;var De={audioTrack:v,avcTrack:x,id3Track:T,textTrack:this._txtTrack};return d&&this.extractRemainingSamples(De),De},p.flush=function(){var E=this.remainderData;this.remainderData=null;var f;return E?f=this.demux(E,-1,!1,!0):f={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(f),this.sampleAes?this.decrypt(f,this.sampleAes):f},p.extractRemainingSamples=function(E){var f=E.audioTrack,m=E.avcTrack,d=E.id3Track,a=m.pesData,x=f.pesData,v=d.pesData,T;a&&(T=o(a))?(this.parseAVCPES(T,!0),m.pesData=null):m.pesData=a,x&&(T=o(x))?(f.isAAC?this.parseAACPES(T):this.parseMPEGPES(T),f.pesData=null):(x!=null&&x.size&&y.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=x),v&&(T=o(v))?(this.parseID3PES(T),d.pesData=null):d.pesData=v},p.demuxSampleAes=function(E,f,m){var d=this.demux(E,m,!0,!this.config.progressive),a=this.sampleAes=new U.default(this.observer,this.config,f);return this.decrypt(d,a)},p.decrypt=function(E,f){return new Promise(function(m){var d=E.audioTrack,a=E.avcTrack;d.samples&&d.isAAC?f.decryptAacSamples(d.samples,0,function(){a.samples?f.decryptAvcSamples(a.samples,0,0,function(){m(E)}):m(E)}):a.samples&&f.decryptAvcSamples(a.samples,0,0,function(){m(E)})})},p.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},p.parseAVCPES=function(E,f){var m=this,d=this._avcTrack,a=this.parseAVCNALu(E.data),x=!1,v=this.avcSample,T,I=!1;E.data=null,v&&a.length&&!d.audFound&&(l(v,d),v=this.avcSample=w(!1,E.pts,E.dts,"")),a.forEach(function(G){switch(G.type){case 1:{T=!0,v||(v=m.avcSample=w(!0,E.pts,E.dts,"")),x&&(v.debug+="NDR "),v.frame=!0;var V=G.data;if(I&&V.length>4){var Q=new M.default(V).readSliceType();(Q===2||Q===4||Q===7||Q===9)&&(v.key=!0)}break}case 5:T=!0,v||(v=m.avcSample=w(!0,E.pts,E.dts,"")),x&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{T=!0,x&&v&&(v.debug+="SEI ");var z=new M.default(C(G.data));z.readUByte();for(var j=0,q=0,ie=!1,ce=0;!ie&&z.bytesAvailable>1;){j=0;do ce=z.readUByte(),j+=ce;while(ce===255);q=0;do ce=z.readUByte(),q+=ce;while(ce===255);if(j===4&&z.bytesAvailable!==0){ie=!0;var ve=z.readUByte();if(ve===181){var Oe=z.readUShort();if(Oe===49){var xe=z.readUInt();if(xe===1195456820){var Te=z.readUByte();if(Te===3){for(var we=z.readUByte(),Se=z.readUByte(),pe=31&we,oe=[we,Se],De=0;De<pe;De++)oe.push(z.readUByte()),oe.push(z.readUByte()),oe.push(z.readUByte());h(m._txtTrack.samples,{type:3,pts:E.pts,bytes:oe})}}}}}else if(j===5&&z.bytesAvailable!==0){if(ie=!0,q>16){for(var Ve=[],ze=0;ze<16;ze++)Ve.push(z.readUByte().toString(16)),(ze===3||ze===5||ze===7||ze===9)&&Ve.push("-");for(var et=q-16,Je=new Uint8Array(et),ke=0;ke<et;ke++)Je[ke]=z.readUByte();h(m._txtTrack.samples,{pts:E.pts,payloadType:j,uuid:Ve.join(""),userData:Object(H.utf8ArrayToStr)(Je),userDataBytes:Je})}}else if(q<z.bytesAvailable)for(var Ie=0;Ie<q;Ie++)z.readUByte()}break}case 7:if(T=!0,I=!0,x&&v&&(v.debug+="SPS "),!d.sps){var He=new M.default(G.data),Ge=He.readSPS();d.width=Ge.width,d.height=Ge.height,d.pixelRatio=Ge.pixelRatio,d.sps=[G.data],d.duration=m._duration;for(var je=G.data.subarray(1,4),_e="avc1.",Be=0;Be<3;Be++){var $e=je[Be].toString(16);$e.length<2&&($e="0"+$e),_e+=$e}d.codec=_e}break;case 8:T=!0,x&&v&&(v.debug+="PPS "),d.pps||(d.pps=[G.data]);break;case 9:T=!1,d.audFound=!0,v&&l(v,d),v=m.avcSample=w(!1,E.pts,E.dts,x?"AUD ":"");break;case 12:T=!1;break;default:T=!1,v&&(v.debug+="unknown NAL "+G.type+" ");break}if(v&&T){var qe=v.units;qe.push(G)}}),f&&v&&(l(v,d),this.avcSample=null)},p.getLastNalUnit=function(){var E,f=this.avcSample,m;if(!f||f.units.length===0){var d=this._avcTrack.samples;f=d[d.length-1]}if((E=f)!==null&&E!==void 0&&E.units){var a=f.units;m=a[a.length-1]}return m},p.parseAVCNALu=function(E){var f=E.byteLength,m=this._avcTrack,d=m.naluState||0,a=d,x=[],v=0,T,I,G,V=-1,Q=0;for(d===-1&&(V=0,Q=E[0]&31,d=0,v=1);v<f;){if(T=E[v++],!d){d=T?0:1;continue}if(d===1){d=T?0:2;continue}if(!T)d=3;else if(T===1){if(V>=0){var z={data:E.subarray(V,v-d-1),type:Q};x.push(z)}else{var j=this.getLastNalUnit();if(j&&(a&&v<=4-a&&(j.state&&(j.data=j.data.subarray(0,j.data.byteLength-a))),I=v-d-1,I>0)){var q=new Uint8Array(j.data.byteLength+I);q.set(j.data,0),q.set(E.subarray(0,I),j.data.byteLength),j.data=q,j.state=0}}v<f?(G=E[v]&31,V=v,Q=G,d=0):d=-1}else d=0}if(V>=0&&d>=0){var ie={data:E.subarray(V,f),type:Q,state:d};x.push(ie)}if(x.length===0){var ce=this.getLastNalUnit();if(ce){var ve=new Uint8Array(ce.data.byteLength+E.byteLength);ve.set(ce.data,0),ve.set(E,ce.data.byteLength),ce.data=ve}}return m.naluState=d,x},p.parseAACPES=function(E){var f=0,m=this._audioTrack,d=this.aacOverFlow,a=E.data;if(d){this.aacOverFlow=null;var x=d.sample.unit.byteLength,v=Math.min(d.missing,x),T=x-v;d.sample.unit.set(a.subarray(0,v),T),m.samples.push(d.sample),f=d.missing}var I,G;for(I=f,G=a.length;I<G-1&&!Y.isHeader(a,I);I++);if(I!==f){var V,Q;if(I<G-1?(V="AAC PES did not start with ADTS header,offset:"+I,Q=!1):(V="no ADTS header found in AAC PES",Q=!0),y.logger.warn("parsing error:"+V),this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:Q,reason:V}),Q)return}Y.initTrackConfig(m,this.observer,a,I,this.audioCodec);var z;if(E.pts!==void 0)z=E.pts;else if(d){var j=Y.getFrameDuration(m.samplerate);z=d.sample.pts+j}else{y.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var q=0;I<G;)if(Y.isHeader(a,I)){if(I+5<G){var ie=Y.appendFrame(m,a,I,z,q);if(ie)if(ie.missing)this.aacOverFlow=ie;else{I+=ie.length,q++;continue}}break}else I++},p.parseMPEGPES=function(E){var f=E.data,m=f.length,d=0,a=0,x=E.pts;if(x===void 0){y.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<m;)if(N.isHeader(f,a)){var v=N.appendFrame(this._audioTrack,f,a,x,d);if(v)a+=v.length,d++;else break}else a++},p.parseID3PES=function(E){if(E.pts===void 0){y.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(E)},g}();L.minProbeByteLength=188;function w(g,p,k,E){return{key:g,frame:!1,pts:p,dts:k,units:[],debug:E,length:0}}function b(g,p){return(g[p+10]&31)<<8|g[p+11]}function u(g,p,k,E){var f={audio:-1,avc:-1,id3:-1,isAAC:!0},m=(g[p+1]&15)<<8|g[p+2],d=p+3+m-4,a=(g[p+10]&15)<<8|g[p+11];for(p+=12+a;p<d;){var x=(g[p+1]&31)<<8|g[p+2];switch(g[p]){case 207:if(!E){y.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:f.audio===-1&&(f.audio=x);break;case 21:f.id3===-1&&(f.id3=x);break;case 219:if(!E){y.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:f.avc===-1&&(f.avc=x);break;case 3:case 4:k?f.audio===-1&&(f.audio=x,f.isAAC=!1):y.logger.log("MPEG audio found, not supported in this browser");break;case 36:y.logger.warn("Unsupported HEVC stream type found");break;default:break}p+=((g[p+3]&15)<<8|g[p+4])+5}return f}function o(g){var p=0,k,E,f,m,d,a=g.data;if(!g||g.size===0)return null;for(;a[0].length<19&&a.length>1;){var x=new Uint8Array(a[0].length+a[1].length);x.set(a[0]),x.set(a[1],a[0].length),a[0]=x,a.splice(1,1)}k=a[0];var v=(k[0]<<16)+(k[1]<<8)+k[2];if(v===1){if(E=(k[4]<<8)+k[5],E&&E>g.size-6)return null;var T=k[7];T&192&&(m=(k[9]&14)*536870912+(k[10]&255)*4194304+(k[11]&254)*16384+(k[12]&255)*128+(k[13]&254)/2,T&64?(d=(k[14]&14)*536870912+(k[15]&255)*4194304+(k[16]&254)*16384+(k[17]&255)*128+(k[18]&254)/2,m-d>60*9e4&&(y.logger.warn(Math.round((m-d)/9e4)+"s delta between PTS and DTS, align them"),m=d)):d=m),f=k[8];var I=f+9;if(g.size<=I)return null;g.size-=I;for(var G=new Uint8Array(g.size),V=0,Q=a.length;V<Q;V++){k=a[V];var z=k.byteLength;if(I)if(I>z){I-=z;continue}else k=k.subarray(I),z-=I,I=0;G.set(k,p),p+=z}return E&&(E-=f+3),{data:G,pts:m,dts:d,len:E}}return null}function l(g,p){if(g.units.length&&g.frame){if(g.pts===void 0){var k=p.samples,E=k.length;if(E){var f=k[E-1];g.pts=f.pts,g.dts=f.dts}else{p.dropped++;return}}p.samples.push(g)}g.debug.length&&y.logger.log(g.pts+"/"+g.dts+":"+g.debug)}function h(g,p){var k=g.length;if(k>0){if(p.pts>=g[k-1].pts)g.push(p);else for(var E=k-1;E>=0;E--)if(p.pts<g[E].pts){g.splice(E,0,p);break}}else g.push(p)}function C(g){for(var p=g.byteLength,k=[],E=1;E<p-2;)g[E]===0&&g[E+1]===0&&g[E+2]===3?(k.push(E+2),E+=2):E++;if(k.length===0)return g;var f=p-k.length,m=new Uint8Array(f),d=0;for(E=0;E<f;d++,E++)d===k[0]&&(d++,k.shift()),m[E]=g[d];return m}Z.default=L},"./src/errors.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"ErrorTypes",function(){return Y}),D.d(Z,"ErrorDetails",function(){return N});var Y;(function(M){M.NETWORK_ERROR="networkError",M.MEDIA_ERROR="mediaError",M.KEY_SYSTEM_ERROR="keySystemError",M.MUX_ERROR="muxError",M.OTHER_ERROR="otherError"})(Y||(Y={}));var N;(function(M){M.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",M.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",M.KEY_SYSTEM_NO_SESSION="keySystemNoSession",M.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",M.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",M.MANIFEST_LOAD_ERROR="manifestLoadError",M.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",M.MANIFEST_PARSING_ERROR="manifestParsingError",M.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",M.LEVEL_EMPTY_ERROR="levelEmptyError",M.LEVEL_LOAD_ERROR="levelLoadError",M.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",M.LEVEL_SWITCH_ERROR="levelSwitchError",M.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",M.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",M.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",M.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",M.FRAG_LOAD_ERROR="fragLoadError",M.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",M.FRAG_DECRYPT_ERROR="fragDecryptError",M.FRAG_PARSING_ERROR="fragParsingError",M.REMUX_ALLOC_ERROR="remuxAllocError",M.KEY_LOAD_ERROR="keyLoadError",M.KEY_LOAD_TIMEOUT="keyLoadTimeOut",M.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",M.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",M.BUFFER_APPEND_ERROR="bufferAppendError",M.BUFFER_APPENDING_ERROR="bufferAppendingError",M.BUFFER_STALLED_ERROR="bufferStalledError",M.BUFFER_FULL_ERROR="bufferFullError",M.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",M.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",M.INTERNAL_EXCEPTION="internalException",M.INTERNAL_ABORTED="aborted",M.UNKNOWN="unknown"})(N||(N={}))},"./src/events.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"Events",function(){return Y});var Y;(function(N){N.MEDIA_ATTACHING="hlsMediaAttaching",N.MEDIA_ATTACHED="hlsMediaAttached",N.MEDIA_DETACHING="hlsMediaDetaching",N.MEDIA_DETACHED="hlsMediaDetached",N.BUFFER_RESET="hlsBufferReset",N.BUFFER_CODECS="hlsBufferCodecs",N.BUFFER_CREATED="hlsBufferCreated",N.BUFFER_APPENDING="hlsBufferAppending",N.BUFFER_APPENDED="hlsBufferAppended",N.BUFFER_EOS="hlsBufferEos",N.BUFFER_FLUSHING="hlsBufferFlushing",N.BUFFER_FLUSHED="hlsBufferFlushed",N.MANIFEST_LOADING="hlsManifestLoading",N.MANIFEST_LOADED="hlsManifestLoaded",N.MANIFEST_PARSED="hlsManifestParsed",N.LEVEL_SWITCHING="hlsLevelSwitching",N.LEVEL_SWITCHED="hlsLevelSwitched",N.LEVEL_LOADING="hlsLevelLoading",N.LEVEL_LOADED="hlsLevelLoaded",N.LEVEL_UPDATED="hlsLevelUpdated",N.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",N.LEVELS_UPDATED="hlsLevelsUpdated",N.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",N.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",N.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",N.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",N.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",N.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",N.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",N.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",N.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",N.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",N.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",N.CUES_PARSED="hlsCuesParsed",N.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",N.INIT_PTS_FOUND="hlsInitPtsFound",N.FRAG_LOADING="hlsFragLoading",N.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",N.FRAG_LOADED="hlsFragLoaded",N.FRAG_DECRYPTED="hlsFragDecrypted",N.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",N.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",N.FRAG_PARSING_METADATA="hlsFragParsingMetadata",N.FRAG_PARSED="hlsFragParsed",N.FRAG_BUFFERED="hlsFragBuffered",N.FRAG_CHANGED="hlsFragChanged",N.FPS_DROP="hlsFpsDrop",N.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",N.ERROR="hlsError",N.DESTROYING="hlsDestroying",N.KEY_LOADING="hlsKeyLoading",N.KEY_LOADED="hlsKeyLoaded",N.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",N.BACK_BUFFER_REACHED="hlsBackBufferReached"})(Y||(Y={}))},"./src/hls.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return g});var Y=D("./node_modules/url-toolkit/src/url-toolkit.js"),N=D.n(Y),M=D("./src/loader/playlist-loader.ts"),H=D("./src/loader/key-loader.ts"),U=D("./src/controller/id3-track-controller.ts"),P=D("./src/controller/latency-controller.ts"),_=D("./src/controller/level-controller.ts"),y=D("./src/controller/fragment-tracker.ts"),A=D("./src/controller/stream-controller.ts"),R=D("./src/is-supported.ts"),L=D("./src/utils/logger.ts"),w=D("./src/config.ts"),b=D("./node_modules/eventemitter3/index.js"),u=D.n(b),o=D("./src/events.ts"),l=D("./src/errors.ts");function h(p,k){for(var E=0;E<k.length;E++){var f=k[E];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(p,f.key,f)}}function C(p,k,E){return k&&h(p.prototype,k),E&&h(p,E),p}var g=function(){p.isSupported=function(){return Object(R.isSupported)()};function p(E){E===void 0&&(E={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new b.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var f=this.config=Object(w.mergeConfig)(p.DefaultConfig,E);this.userConfig=E,Object(L.enableLogs)(f.debug),this._autoLevelCapping=-1,f.progressive&&Object(w.enableStreamingMode)(f);var m=f.abrController,d=f.bufferController,a=f.capLevelController,x=f.fpsController,v=this.abrController=new m(this),T=this.bufferController=new d(this),I=this.capLevelController=new a(this),G=new x(this),V=new M.default(this),Q=new H.default(this),z=new U.default(this),j=this.levelController=new _.default(this),q=new y.FragmentTracker(this),ie=this.streamController=new A.default(this,q);I.setStreamController(ie),G.setStreamController(ie);var ce=[j,ie];this.networkControllers=ce;var ve=[V,Q,v,T,I,G,z,q];this.audioTrackController=this.createController(f.audioTrackController,null,ce),this.createController(f.audioStreamController,q,ce),this.subtitleTrackController=this.createController(f.subtitleTrackController,null,ce),this.createController(f.subtitleStreamController,q,ce),this.createController(f.timelineController,null,ve),this.emeController=this.createController(f.emeController,null,ve),this.cmcdController=this.createController(f.cmcdController,null,ve),this.latencyController=this.createController(P.default,null,ve),this.coreComponents=ve}var k=p.prototype;return k.createController=function(f,m,d){if(f){var a=m?new f(this,m):new f(this);return d&&d.push(a),a}return null},k.on=function(f,m,d){d===void 0&&(d=this),this._emitter.on(f,m,d)},k.once=function(f,m,d){d===void 0&&(d=this),this._emitter.once(f,m,d)},k.removeAllListeners=function(f){this._emitter.removeAllListeners(f)},k.off=function(f,m,d,a){d===void 0&&(d=this),this._emitter.off(f,m,d,a)},k.listeners=function(f){return this._emitter.listeners(f)},k.emit=function(f,m,d){return this._emitter.emit(f,m,d)},k.trigger=function(f,m){if(this.config.debug)return this.emit(f,f,m);try{return this.emit(f,f,m)}catch(d){L.logger.error("An internal error happened while handling event "+f+'. Error message: "'+d.message+'". Here is a stacktrace:',d),this.trigger(o.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:f,error:d})}return!1},k.listenerCount=function(f){return this._emitter.listenerCount(f)},k.destroy=function(){L.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(f){return f.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(f){return f.destroy()}),this.coreComponents.length=0},k.attachMedia=function(f){L.logger.log("attachMedia"),this._media=f,this.trigger(o.Events.MEDIA_ATTACHING,{media:f})},k.detachMedia=function(){L.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},k.loadSource=function(f){this.stopLoad();var m=this.media,d=this.url,a=this.url=Y.buildAbsoluteURL(self.location.href,f,{alwaysNormalize:!0});L.logger.log("loadSource:"+a),m&&d&&d!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(m)),this.trigger(o.Events.MANIFEST_LOADING,{url:f})},k.startLoad=function(f){f===void 0&&(f=-1),L.logger.log("startLoad("+f+")"),this.networkControllers.forEach(function(m){m.startLoad(f)})},k.stopLoad=function(){L.logger.log("stopLoad"),this.networkControllers.forEach(function(f){f.stopLoad()})},k.swapAudioCodec=function(){L.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},k.recoverMediaError=function(){L.logger.log("recoverMediaError");var f=this._media;this.detachMedia(),f&&this.attachMedia(f)},k.removeLevel=function(f,m){m===void 0&&(m=0),this.levelController.removeLevel(f,m)},C(p,[{key:"levels",get:function(){var f=this.levelController.levels;return f||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(f){L.logger.log("set currentLevel:"+f),this.loadLevel=f,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(f){L.logger.log("set nextLevel:"+f),this.levelController.manualLevel=f,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(f){L.logger.log("set loadLevel:"+f),this.levelController.manualLevel=f}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(f){this.levelController.nextLoadLevel=f}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(f){L.logger.log("set firstLevel:"+f),this.levelController.firstLevel=f}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(f){L.logger.log("set startLevel:"+f),f!==-1&&(f=Math.max(f,this.minAutoLevel)),this.levelController.startLevel=f}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(f){var m=!!f;m!==this.config.capLevelToPlayerSize&&(m?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=m)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(f){this._autoLevelCapping!==f&&(L.logger.log("set autoLevelCapping:"+f),this._autoLevelCapping=f)}},{key:"bandwidthEstimate",get:function(){var f=this.abrController.bwEstimator;return f?f.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var f=this.levels,m=this.config.minAutoBitrate;if(!f)return 0;for(var d=f.length,a=0;a<d;a++)if(f[a].maxBitrate>m)return a;return 0}},{key:"maxAutoLevel",get:function(){var f=this.levels,m=this.autoLevelCapping,d;return m===-1&&f&&f.length?d=f.length-1:d=m,d}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(f){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,f)}},{key:"audioTracks",get:function(){var f=this.audioTrackController;return f?f.audioTracks:[]}},{key:"audioTrack",get:function(){var f=this.audioTrackController;return f?f.audioTrack:-1},set:function(f){var m=this.audioTrackController;m&&(m.audioTrack=f)}},{key:"subtitleTracks",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTrack:-1},set:function(f){var m=this.subtitleTrackController;m&&(m.subtitleTrack=f)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var f=this.subtitleTrackController;return f?f.subtitleDisplay:!1},set:function(f){var m=this.subtitleTrackController;m&&(m.subtitleDisplay=f)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(f){this.config.lowLatencyMode=f}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return o.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return p.defaultConfig?p.defaultConfig:w.hlsDefaultConfig},set:function(f){p.defaultConfig=f}}]),p}();g.defaultConfig=void 0},"./src/is-supported.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"isSupported",function(){return M}),D.d(Z,"changeTypeSupported",function(){return H});var Y=D("./src/utils/mediasource-helper.ts");function N(){return self.SourceBuffer||self.WebKitSourceBuffer}function M(){var U=Object(Y.getMediaSource)();if(!U)return!1;var P=N(),_=U&&typeof U.isTypeSupported=="function"&&U.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!P||P.prototype&&typeof P.prototype.appendBuffer=="function"&&typeof P.prototype.remove=="function";return!!_&&!!y}function H(){var U,P=N();return typeof(P==null||((U=P.prototype)===null||U===void 0)?void 0:U.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return L}),D.d(Z,"LoadError",function(){return b});var Y=D("./src/polyfills/number.ts"),N=D("./src/errors.ts");function M(u,o){u.prototype=Object.create(o.prototype),u.prototype.constructor=u,y(u,o)}function H(u){var o=typeof Map=="function"?new Map:void 0;return H=function(h){if(h===null||!_(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(h))return o.get(h);o.set(h,C)}function C(){return U(h,arguments,A(this).constructor)}return C.prototype=Object.create(h.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),y(C,h)},H(u)}function U(u,o,l){return P()?U=Reflect.construct:U=function(C,g,p){var k=[null];k.push.apply(k,g);var E=Function.bind.apply(C,k),f=new E;return p&&y(f,p.prototype),f},U.apply(null,arguments)}function P(){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 _(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function y(u,o){return y=Object.setPrototypeOf||function(h,C){return h.__proto__=C,h},y(u,o)}function A(u){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},A(u)}var R=Math.pow(2,17),L=function(){function u(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var o=u.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(h,C){var g=this,p=h.url;if(!p)return Promise.reject(new b({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(p?"part list":"url")));this.abort();var k=this.config,E=k.fLoader,f=k.loader;return new Promise(function(m,d){g.loader&&g.loader.destroy();var a=g.loader=h.loader=E?new E(k):new f(k),x=w(h),v={timeout:k.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:k.fragLoadingMaxRetryTimeout,highWaterMark:R};h.stats=a.stats,a.load(x,v,{onSuccess:function(I,G,V,Q){g.resetLoader(h,a),m({frag:h,part:null,payload:I.data,networkDetails:Q})},onError:function(I,G,V){g.resetLoader(h,a),d(new b({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:I,networkDetails:V}))},onAbort:function(I,G,V){g.resetLoader(h,a),d(new b({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:V}))},onTimeout:function(I,G,V){g.resetLoader(h,a),d(new b({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:V}))},onProgress:function(I,G,V,Q){C&&C({frag:h,part:null,payload:V,networkDetails:Q})}})})},o.loadPart=function(h,C,g){var p=this;this.abort();var k=this.config,E=k.fLoader,f=k.loader;return new Promise(function(m,d){p.loader&&p.loader.destroy();var a=p.loader=h.loader=E?new E(k):new f(k),x=w(h,C),v={timeout:k.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:k.fragLoadingMaxRetryTimeout,highWaterMark:R};C.stats=a.stats,a.load(x,v,{onSuccess:function(I,G,V,Q){p.resetLoader(h,a),p.updateStatsFromPart(h,C);var z={frag:h,part:C,payload:I.data,networkDetails:Q};g(z),m(z)},onError:function(I,G,V){p.resetLoader(h,a),d(new b({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:C,response:I,networkDetails:V}))},onAbort:function(I,G,V){h.stats.aborted=C.stats.aborted,p.resetLoader(h,a),d(new b({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:C,networkDetails:V}))},onTimeout:function(I,G,V){p.resetLoader(h,a),d(new b({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:C,networkDetails:V}))}})})},o.updateStatsFromPart=function(h,C){var g=h.stats,p=C.stats,k=p.total;if(g.loaded+=p.loaded,k){var E=Math.round(h.duration/C.duration),f=Math.min(Math.round(g.loaded/k),E),m=E-f,d=m*Math.round(g.loaded/f);g.total=g.loaded+d}else g.total=Math.max(g.loaded,g.total);var a=g.loading,x=p.loading;a.start?a.first+=x.first-x.start:(a.start=x.start,a.first=x.first),a.end=x.end},o.resetLoader=function(h,C){h.loader=null,this.loader===C&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),C.destroy()},u}();function w(u,o){o===void 0&&(o=null);var l=o||u,h={frag:u,part:o,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},C=l.byteRangeStartOffset,g=l.byteRangeEndOffset;return Object(Y.isFiniteNumber)(C)&&Object(Y.isFiniteNumber)(g)&&(h.rangeStart=C,h.rangeEnd=g),h}var b=function(u){M(o,u);function o(l){for(var h,C=arguments.length,g=new Array(C>1?C-1:0),p=1;p<C;p++)g[p-1]=arguments[p];return h=u.call.apply(u,[this].concat(g))||this,h.data=void 0,h.data=l,h}return o}(H(Error))},"./src/loader/fragment.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"ElementaryStreamTypes",function(){return L}),D.d(Z,"BaseSegment",function(){return w}),D.d(Z,"Fragment",function(){return b}),D.d(Z,"Part",function(){return u});var Y=D("./src/polyfills/number.ts"),N=D("./node_modules/url-toolkit/src/url-toolkit.js"),M=D.n(N),H=D("./src/utils/logger.ts"),U=D("./src/loader/level-key.ts"),P=D("./src/loader/load-stats.ts");function _(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,y(o,l)}function y(o,l){return y=Object.setPrototypeOf||function(C,g){return C.__proto__=g,C},y(o,l)}function A(o,l){for(var h=0;h<l.length;h++){var C=l[h];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(o,C.key,C)}}function R(o,l,h){return l&&A(o.prototype,l),h&&A(o,h),o}var L;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(L||(L={}));var w=function(){function o(h){var C;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(C={},C[L.AUDIO]=null,C[L.VIDEO]=null,C[L.AUDIOVIDEO]=null,C),this.baseurl=h}var l=o.prototype;return l.setByteRange=function(C,g){var p=C.split("@",2),k=[];p.length===1?k[0]=g?g.byteRangeEndOffset:0:k[0]=parseInt(p[1]),k[1]=parseInt(p[0])+k[0],this._byteRange=k},R(o,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(N.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(C){this._url=C}}]),o}(),b=function(o){_(l,o);function l(C,g){var p;return p=o.call(this,g)||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 P.LoadStats,p.urlId=0,p.data=void 0,p.bitrateTest=!1,p.title=null,p.initSegment=null,p.type=C,p}var h=l.prototype;return h.createInitializationVector=function(g){for(var p=new Uint8Array(16),k=12;k<16;k++)p[k]=g>>8*(15-k)&255;return p},h.setDecryptDataFromLevelKey=function(g,p){var k=g;return(g==null?void 0:g.method)==="AES-128"&&g.uri&&!g.iv&&(k=U.LevelKey.fromURI(g.uri),k.method=g.method,k.iv=this.createInitializationVector(p),k.keyFormat="identity"),k},h.setElementaryStreamInfo=function(g,p,k,E,f,m){m===void 0&&(m=!1);var d=this.elementaryStreams,a=d[g];if(!a){d[g]={startPTS:p,endPTS:k,startDTS:E,endDTS:f,partial:m};return}a.startPTS=Math.min(a.startPTS,p),a.endPTS=Math.max(a.endPTS,k),a.startDTS=Math.min(a.startDTS,E),a.endDTS=Math.max(a.endDTS,f)},h.clearElementaryStreamInfo=function(){var g=this.elementaryStreams;g[L.AUDIO]=null,g[L.VIDEO]=null,g[L.AUDIOVIDEO]=null},R(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var g=this.sn;typeof g!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&H.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),g=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,g)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(Y.isFiniteNumber)(this.programDateTime))return null;var g=Object(Y.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+g*1e3}},{key:"encrypted",get:function(){var g;return!!((g=this.decryptdata)!==null&&g!==void 0&&g.keyFormat&&this.decryptdata.uri)}}]),l}(w),u=function(o){_(l,o);function l(h,C,g,p,k){var E;E=o.call(this,g)||this,E.fragOffset=0,E.duration=0,E.gap=!1,E.independent=!1,E.relurl=void 0,E.fragment=void 0,E.index=void 0,E.stats=new P.LoadStats,E.duration=h.decimalFloatingPoint("DURATION"),E.gap=h.bool("GAP"),E.independent=h.bool("INDEPENDENT"),E.relurl=h.enumeratedString("URI"),E.fragment=C,E.index=p;var f=h.enumeratedString("BYTERANGE");return f&&E.setByteRange(f,k),k&&(E.fragOffset=k.fragOffset+k.duration),E}return R(l,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var C=this.elementaryStreams;return!!(C.audio||C.video||C.audiovideo)}}]),l}(w)},"./src/loader/key-loader.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return H});var Y=D("./src/events.ts"),N=D("./src/errors.ts"),M=D("./src/utils/logger.ts"),H=function(){function U(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this._registerListeners()}var P=U.prototype;return P._registerListeners=function(){this.hls.on(Y.Events.KEY_LOADING,this.onKeyLoading,this)},P._unregisterListeners=function(){this.hls.off(Y.Events.KEY_LOADING,this.onKeyLoading)},P.destroy=function(){this._unregisterListeners();for(var y in this.loaders){var A=this.loaders[y];A&&A.destroy()}this.loaders={}},P.onKeyLoading=function(y,A){var R=A.frag,L=R.type,w=this.loaders[L];if(!R.decryptdata){M.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var b=R.decryptdata.uri;if(b!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(w&&(M.logger.warn("abort previous key loader for type:"+L),w.abort()),!b){M.logger.warn("key uri is falsy");return}var o=u.loader,l=R.loader=this.loaders[L]=new o(u);this.decrypturl=b,this.decryptkey=null;var h={url:b,frag:R,responseType:"arraybuffer"},C={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(h,C,g)}else this.decryptkey&&(R.decryptdata.key=this.decryptkey,this.hls.trigger(Y.Events.KEY_LOADED,{frag:R}))},P.loadsuccess=function(y,A,R){var L=R.frag;if(!L.decryptdata){M.logger.error("after key load, decryptdata unset");return}this.decryptkey=L.decryptdata.key=new Uint8Array(y.data),L.loader=null,delete this.loaders[L.type],this.hls.trigger(Y.Events.KEY_LOADED,{frag:L})},P.loaderror=function(y,A){var R=A.frag,L=R.loader;L&&L.abort(),delete this.loaders[R.type],this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:R,response:y})},P.loadtimeout=function(y,A){var R=A.frag,L=R.loader;L&&L.abort(),delete this.loaders[R.type],this.hls.trigger(Y.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:R})},U}()},"./src/loader/level-details.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"LevelDetails",function(){return U});var Y=D("./src/polyfills/number.ts");function N(P,_){for(var y=0;y<_.length;y++){var A=_[y];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(P,A.key,A)}}function M(P,_,y){return _&&N(P.prototype,_),y&&N(P,y),P}var H=10,U=function(){function P(y){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=y}var _=P.prototype;return _.reloaded=function(A){if(!A){this.advanced=!0,this.updated=!0;return}var R=this.lastPartSn-A.lastPartSn,L=this.lastPartIndex-A.lastPartIndex;this.updated=this.endSN!==A.endSN||!!L||!!R,this.advanced=this.endSN>A.endSN||R>0||R===0&&L>0,this.updated||this.advanced?this.misses=Math.floor(A.misses*.6):this.misses=A.misses+1,this.availabilityDelay=A.availabilityDelay},M(P,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(Y.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||H}},{key:"drift",get:function(){var A=this.driftEndTime-this.driftStartTime;if(A>0){var R=this.driftEnd-this.driftStart;return R*1e3/A}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var A;return(A=this.fragments)!==null&&A!==void 0&&A.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 A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),P}()},"./src/loader/level-key.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"LevelKey",function(){return U});var Y=D("./node_modules/url-toolkit/src/url-toolkit.js"),N=D.n(Y);function M(P,_){for(var y=0;y<_.length;y++){var A=_[y];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(P,A.key,A)}}function H(P,_,y){return _&&M(P.prototype,_),y&&M(P,y),P}var U=function(){P.fromURL=function(y,A){return new P(y,A)},P.fromURI=function(y){return new P(y)};function P(_,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(Y.buildAbsoluteURL)(_,y,{alwaysNormalize:!0}):this._uri=_}return H(P,[{key:"uri",get:function(){return this._uri}}]),P}()},"./src/loader/load-stats.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"LoadStats",function(){return Y});var Y=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(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return l});var Y=D("./src/polyfills/number.ts"),N=D("./node_modules/url-toolkit/src/url-toolkit.js"),M=D.n(N),H=D("./src/loader/fragment.ts"),U=D("./src/loader/level-details.ts"),P=D("./src/loader/level-key.ts"),_=D("./src/utils/attr-list.ts"),y=D("./src/utils/logger.ts"),A=D("./src/utils/codecs.ts"),R=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,L=/#EXT-X-MEDIA:(.*)/g,w=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),b=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function o(k){var E,f;return u.test((E=(f=N.parseURL(k))===null||f===void 0?void 0:f.path)!=null?E:"")}var l=function(){function k(){}return k.findGroup=function(f,m){for(var d=0;d<f.length;d++){var a=f[d];if(a.id===m)return a}},k.convertAVC1ToAVCOTI=function(f){var m=f.split(".");if(m.length>2){var d=m.shift()+".";return d+=parseInt(m.shift()).toString(16),d+=("000"+parseInt(m.shift()).toString(16)).substr(-4),d}return f},k.resolve=function(f,m){return N.buildAbsoluteURL(m,f,{alwaysNormalize:!0})},k.parseMasterPlaylist=function(f,m){var d=[],a={},x=!1;R.lastIndex=0;for(var v;(v=R.exec(f))!=null;)if(v[1]){var T=new _.AttrList(v[1]),I={attrs:T,bitrate:T.decimalInteger("AVERAGE-BANDWIDTH")||T.decimalInteger("BANDWIDTH"),name:T.NAME,url:k.resolve(v[2],m)},G=T.decimalResolution("RESOLUTION");G&&(I.width=G.width,I.height=G.height),h((T.CODECS||"").split(/[ ,]+/).filter(function(Q){return Q}),I),I.videoCodec&&I.videoCodec.indexOf("avc1")!==-1&&(I.videoCodec=k.convertAVC1ToAVCOTI(I.videoCodec)),d.push(I)}else if(v[3]){var V=new _.AttrList(v[3]);V["DATA-ID"]&&(x=!0,a[V["DATA-ID"]]=V)}return{levels:d,sessionData:x?a:null}},k.parseMasterPlaylistMedia=function(f,m,d,a){a===void 0&&(a=[]);var x,v=[],T=0;for(L.lastIndex=0;(x=L.exec(f))!==null;){var I=new _.AttrList(x[1]);if(I.TYPE===d){var G={attrs:I,bitrate:0,id:T++,groupId:I["GROUP-ID"],instreamId:I["INSTREAM-ID"],name:I.NAME||I.LANGUAGE||"",type:d,default:I.bool("DEFAULT"),autoselect:I.bool("AUTOSELECT"),forced:I.bool("FORCED"),lang:I.LANGUAGE,url:I.URI?k.resolve(I.URI,m):""};if(a.length){var V=k.findGroup(a,G.groupId)||a[0];C(G,V,"audioCodec"),C(G,V,"textCodec")}v.push(G)}}return v},k.parseLevelPlaylist=function(f,m,d,a,x){var v=new U.LevelDetails(m),T=v.fragments,I=null,G=0,V=0,Q=0,z=0,j=null,q=new H.Fragment(a,m),ie,ce,ve,Oe=-1,xe=!1;for(w.lastIndex=0,v.m3u8=f;(ie=w.exec(f))!==null;){xe&&(xe=!1,q=new H.Fragment(a,m),q.start=Q,q.sn=G,q.cc=z,q.level=d,I&&(q.initSegment=I,q.rawProgramDateTime=I.rawProgramDateTime));var Te=ie[1];if(Te){q.duration=parseFloat(Te);var we=(" "+ie[2]).slice(1);q.title=we||null,q.tagList.push(we?["INF",Te,we]:["INF",Te])}else if(ie[3])Object(Y.isFiniteNumber)(q.duration)&&(q.start=Q,ve&&(q.levelkey=ve),q.sn=G,q.level=d,q.cc=z,q.urlId=x,T.push(q),q.relurl=(" "+ie[3]).slice(1),p(q,j),j=q,Q+=q.duration,G++,V=0,xe=!0);else if(ie[4]){var Se=(" "+ie[4]).slice(1);j?q.setByteRange(Se,j):q.setByteRange(Se)}else if(ie[5])q.rawProgramDateTime=(" "+ie[5]).slice(1),q.tagList.push(["PROGRAM-DATE-TIME",q.rawProgramDateTime]),Oe===-1&&(Oe=T.length);else{if(ie=ie[0].match(b),!ie){y.logger.warn("No matches on slow regex match for level playlist!");continue}for(ce=1;ce<ie.length&&!(typeof ie[ce]!="undefined");ce++);var pe=(" "+ie[ce]).slice(1),oe=(" "+ie[ce+1]).slice(1),De=ie[ce+2]?(" "+ie[ce+2]).slice(1):"";switch(pe){case"PLAYLIST-TYPE":v.type=oe.toUpperCase();break;case"MEDIA-SEQUENCE":G=v.startSN=parseInt(oe);break;case"SKIP":{var Ve=new _.AttrList(oe),ze=Ve.decimalInteger("SKIPPED-SEGMENTS");if(Object(Y.isFiniteNumber)(ze)){v.skippedSegments=ze;for(var et=ze;et--;)T.unshift(null);G+=ze}var Je=Ve.enumeratedString("RECENTLY-REMOVED-DATERANGES");Je&&(v.recentlyRemovedDateranges=Je.split(" "));break}case"TARGETDURATION":v.targetduration=parseFloat(oe);break;case"VERSION":v.version=parseInt(oe);break;case"EXTM3U":break;case"ENDLIST":v.live=!1;break;case"#":(oe||De)&&q.tagList.push(De?[oe,De]:[oe]);break;case"DIS":z++;case"GAP":q.tagList.push([pe]);break;case"BITRATE":q.tagList.push([pe,oe]);break;case"DISCONTINUITY-SEQ":z=parseInt(oe);break;case"KEY":{var ke,Ie=new _.AttrList(oe),He=Ie.enumeratedString("METHOD"),Ge=Ie.URI,je=Ie.hexadecimalInteger("IV"),_e=Ie.enumeratedString("KEYFORMATVERSIONS"),Be=Ie.enumeratedString("KEYID"),$e=(ke=Ie.enumeratedString("KEYFORMAT"))!=null?ke:"identity",qe=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(qe.indexOf($e)>-1){y.logger.warn("Keyformat "+$e+" is not supported from the manifest");continue}else if($e!=="identity")continue;He&&(ve=P.LevelKey.fromURL(m,Ge),Ge&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(He)>=0&&(ve.method=He,ve.keyFormat=$e,Be&&(ve.keyID=Be),_e&&(ve.keyFormatVersions=_e),ve.iv=je));break}case"START":{var Qe=new _.AttrList(oe),Ze=Qe.decimalFloatingPoint("TIME-OFFSET");Object(Y.isFiniteNumber)(Ze)&&(v.startTimeOffset=Ze);break}case"MAP":{var ct=new _.AttrList(oe);q.relurl=ct.URI,ct.BYTERANGE&&q.setByteRange(ct.BYTERANGE),q.level=d,q.sn="initSegment",ve&&(q.levelkey=ve),q.initSegment=null,I=q,xe=!0;break}case"SERVER-CONTROL":{var it=new _.AttrList(oe);v.canBlockReload=it.bool("CAN-BLOCK-RELOAD"),v.canSkipUntil=it.optionalFloat("CAN-SKIP-UNTIL",0),v.canSkipDateRanges=v.canSkipUntil>0&&it.bool("CAN-SKIP-DATERANGES"),v.partHoldBack=it.optionalFloat("PART-HOLD-BACK",0),v.holdBack=it.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var rt=new _.AttrList(oe);v.partTarget=rt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ce=v.partList;Ce||(Ce=v.partList=[]);var lt=V>0?Ce[Ce.length-1]:void 0,nt=V++,Ae=new H.Part(new _.AttrList(oe),q,m,nt,lt);Ce.push(Ae),q.duration+=Ae.duration;break}case"PRELOAD-HINT":{var Fe=new _.AttrList(oe);v.preloadHint=Fe;break}case"RENDITION-REPORT":{var ge=new _.AttrList(oe);v.renditionReports=v.renditionReports||[],v.renditionReports.push(ge);break}default:y.logger.warn("line parsed but not handled: "+ie);break}}}j&&!j.relurl?(T.pop(),Q-=j.duration,v.partList&&(v.fragmentHint=j)):v.partList&&(p(q,j),q.cc=z,v.fragmentHint=q);var de=T.length,fe=T[0],ee=T[de-1];if(Q+=v.skippedSegments*v.targetduration,Q>0&&de&&ee){v.averagetargetduration=Q/de;var te=ee.sn;v.endSN=te!=="initSegment"?te:0,fe&&(v.startCC=fe.cc,fe.initSegment||v.fragments.every(function(ne){return ne.relurl&&o(ne.relurl)})&&(y.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),q=new H.Fragment(a,m),q.relurl=ee.relurl,q.level=d,q.sn="initSegment",fe.initSegment=q,v.needSidxRanges=!0))}else v.endSN=0,v.startCC=0;return v.fragmentHint&&(Q+=v.fragmentHint.duration),v.totalduration=Q,v.endCC=z,Oe>0&&g(T,Oe),v},k}();function h(k,E){["video","audio","text"].forEach(function(f){var m=k.filter(function(a){return Object(A.isCodecType)(a,f)});if(m.length){var d=m.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});E[f+"Codec"]=d.length>0?d[0]:m[0],k=k.filter(function(a){return m.indexOf(a)===-1})}}),E.unknownCodecs=k}function C(k,E,f){var m=E[f];m&&(k[f]=m)}function g(k,E){for(var f=k[E],m=E;m--;){var d=k[m];if(!d)return;d.programDateTime=f.programDateTime-d.duration*1e3,f=d}}function p(k,E){k.rawProgramDateTime?k.programDateTime=Date.parse(k.rawProgramDateTime):E!=null&&E.programDateTime&&(k.programDateTime=E.endProgramDateTime),Object(Y.isFiniteNumber)(k.programDateTime)||(k.programDateTime=null,k.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/polyfills/number.ts"),N=D("./src/events.ts"),M=D("./src/errors.ts"),H=D("./src/utils/logger.ts"),U=D("./src/utils/mp4-tools.ts"),P=D("./src/loader/m3u8-parser.ts"),_=D("./src/types/loader.ts"),y=D("./src/utils/attr-list.ts");function A(w){var b=w.type;switch(b){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function R(w,b){var u=w.url;return(u===void 0||u.indexOf("data:")===0)&&(u=b.url),u}var L=function(){function w(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var b=w.prototype;return b.registerListeners=function(){var o=this.hls;o.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(N.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},b.unregisterListeners=function(){var o=this.hls;o.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(N.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},b.createInternalLoader=function(o){var l=this.hls.config,h=l.pLoader,C=l.loader,g=h||C,p=new g(l);return o.loader=p,this.loaders[o.type]=p,p},b.getInternalLoader=function(o){return this.loaders[o.type]},b.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},b.destroyInternalLoaders=function(){for(var o in this.loaders){var l=this.loaders[o];l&&l.destroy(),this.resetInternalLoader(o)}},b.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},b.onManifestLoading=function(o,l){var h=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},b.onLevelLoading=function(o,l){var h=l.id,C=l.level,g=l.url,p=l.deliveryDirectives;this.load({id:h,groupId:null,level:C,responseType:"text",type:_.PlaylistContextType.LEVEL,url:g,deliveryDirectives:p})},b.onAudioTrackLoading=function(o,l){var h=l.id,C=l.groupId,g=l.url,p=l.deliveryDirectives;this.load({id:h,groupId:C,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:g,deliveryDirectives:p})},b.onSubtitleTrackLoading=function(o,l){var h=l.id,C=l.groupId,g=l.url,p=l.deliveryDirectives;this.load({id:h,groupId:C,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:g,deliveryDirectives:p})},b.load=function(o){var l,h=this.hls.config,C=this.getInternalLoader(o);if(C){var g=C.context;if(g&&g.url===o.url){H.logger.trace("[playlist-loader]: playlist request ongoing");return}H.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),C.abort()}var p,k,E,f;switch(o.type){case _.PlaylistContextType.MANIFEST:p=h.manifestLoadingMaxRetry,k=h.manifestLoadingTimeOut,E=h.manifestLoadingRetryDelay,f=h.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:p=0,k=h.levelLoadingTimeOut;break;default:p=h.levelLoadingMaxRetry,k=h.levelLoadingTimeOut,E=h.levelLoadingRetryDelay,f=h.levelLoadingMaxRetryTimeout;break}if(C=this.createInternalLoader(o),(l=o.deliveryDirectives)!==null&&l!==void 0&&l.part){var m;if(o.type===_.PlaylistContextType.LEVEL&&o.level!==null?m=this.hls.levels[o.level].details:o.type===_.PlaylistContextType.AUDIO_TRACK&&o.id!==null?m=this.hls.audioTracks[o.id].details:o.type===_.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(m=this.hls.subtitleTracks[o.id].details),m){var d=m.partTarget,a=m.targetduration;d&&a&&(k=Math.min(Math.max(d*3,a*.8)*1e3,k))}}var x={timeout:k,maxRetry:p,retryDelay:E,maxRetryDelay:f,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};C.load(o,x,v)},b.loadsuccess=function(o,l,h,C){if(C===void 0&&(C=null),h.isSidxRequest){this.handleSidxRequest(o,h),this.handlePlaylistLoaded(o,l,h,C);return}this.resetInternalLoader(h.type);var g=o.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,h,"no EXTM3U delimiter",C);return}l.parsing.start=performance.now(),g.indexOf("#EXTINF:")>0||g.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,l,h,C):this.handleMasterPlaylist(o,l,h,C)},b.loaderror=function(o,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!1,o)},b.loadtimeout=function(o,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!0)},b.handleMasterPlaylist=function(o,l,h,C){var g=this.hls,p=o.data,k=R(o,h),E=P.default.parseMasterPlaylist(p,k),f=E.levels,m=E.sessionData;if(!f.length){this.handleManifestParsingError(o,h,"no level found in manifest",C);return}var d=f.map(function(G){return{id:G.attrs.AUDIO,audioCodec:G.audioCodec}}),a=f.map(function(G){return{id:G.attrs.SUBTITLES,textCodec:G.textCodec}}),x=P.default.parseMasterPlaylistMedia(p,k,"AUDIO",d),v=P.default.parseMasterPlaylistMedia(p,k,"SUBTITLES",a),T=P.default.parseMasterPlaylistMedia(p,k,"CLOSED-CAPTIONS");if(x.length){var I=x.some(function(G){return!G.url});!I&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(H.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),x.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}g.trigger(N.Events.MANIFEST_LOADED,{levels:f,audioTracks:x,subtitles:v,captions:T,url:k,stats:l,networkDetails:C,sessionData:m})},b.handleTrackOrLevelPlaylist=function(o,l,h,C){var g=this.hls,p=h.id,k=h.level,E=h.type,f=R(o,h),m=Object(Y.isFiniteNumber)(p)?p:0,d=Object(Y.isFiniteNumber)(k)?k:m,a=A(h),x=P.default.parseLevelPlaylist(o.data,f,d,a,m);if(!x.fragments.length){g.trigger(N.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:f,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(E===_.PlaylistContextType.MANIFEST){var v={attrs:new y.AttrList({}),bitrate:0,details:x,name:"",url:f};g.trigger(N.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:f,stats:l,networkDetails:C,sessionData:null})}if(l.parsing.end=performance.now(),x.needSidxRanges){var T,I=(T=x.fragments[0].initSegment)===null||T===void 0?void 0:T.url;this.load({url:I,isSidxRequest:!0,type:E,level:k,levelDetails:x,id:p,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=x,this.handlePlaylistLoaded(o,l,h,C)},b.handleSidxRequest=function(o,l){var h=Object(U.parseSegmentIndex)(new Uint8Array(o.data));if(!h)return;var C=h.references,g=l.levelDetails;C.forEach(function(p,k){var E=p.info,f=g.fragments[k];f.byteRange.length===0&&f.setByteRange(String(1+E.end-E.start)+"@"+String(E.start)),f.initSegment&&f.initSegment.setByteRange(String(h.moovEndOffset)+"@0")})},b.handleManifestParsingError=function(o,l,h,C){this.hls.trigger(N.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===_.PlaylistContextType.MANIFEST,url:o.url,reason:h,response:o,context:l,networkDetails:C})},b.handleNetworkError=function(o,l,h,C){h===void 0&&(h=!1),H.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var g=M.ErrorDetails.UNKNOWN,p=!1,k=this.getInternalLoader(o);switch(o.type){case _.PlaylistContextType.MANIFEST:g=h?M.ErrorDetails.MANIFEST_LOAD_TIMEOUT:M.ErrorDetails.MANIFEST_LOAD_ERROR,p=!0;break;case _.PlaylistContextType.LEVEL:g=h?M.ErrorDetails.LEVEL_LOAD_TIMEOUT:M.ErrorDetails.LEVEL_LOAD_ERROR,p=!1;break;case _.PlaylistContextType.AUDIO_TRACK:g=h?M.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:M.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:g=h?M.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:M.ErrorDetails.SUBTITLE_LOAD_ERROR,p=!1;break}k&&this.resetInternalLoader(o.type);var E={type:M.ErrorTypes.NETWORK_ERROR,details:g,fatal:p,url:o.url,loader:k,context:o,networkDetails:l};C&&(E.response=C),this.hls.trigger(N.Events.ERROR,E)},b.handlePlaylistLoaded=function(o,l,h,C){var g=h.type,p=h.level,k=h.id,E=h.groupId,f=h.loader,m=h.levelDetails,d=h.deliveryDirectives;if(!(m!=null&&m.targetduration)){this.handleManifestParsingError(o,h,"invalid target duration",C);return}if(!f)return;m.live&&(f.getCacheAge&&(m.ageHeader=f.getCacheAge()||0),(!f.getCacheAge||isNaN(m.ageHeader))&&(m.ageHeader=0));switch(g){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(N.Events.LEVEL_LOADED,{details:m,level:p||0,id:k||0,stats:l,networkDetails:C,deliveryDirectives:d});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(N.Events.AUDIO_TRACK_LOADED,{details:m,id:k||0,groupId:E||"",stats:l,networkDetails:C,deliveryDirectives:d});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(N.Events.SUBTITLE_TRACK_LOADED,{details:m,id:k||0,groupId:E||"",stats:l,networkDetails:C,deliveryDirectives:d});break}},w}();Z.default=L},"./src/polyfills/number.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"isFiniteNumber",function(){return Y}),D.d(Z,"MAX_SAFE_INTEGER",function(){return N});var Y=Number.isFinite||function(M){return typeof M=="number"&&isFinite(M)},N=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(re,Z,D){"use strict";D.r(Z);var Y=function(){function N(){}return N.getSilentFrame=function(H,U){switch(H){case"mp4a.40.2":if(U===1)return new Uint8Array([0,200,0,128,35,128]);if(U===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(U===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(U===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(U===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(U===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(U===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(U===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(U===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},N}();Z.default=Y},"./src/remux/mp4-generator.ts":function(re,Z,D){"use strict";D.r(Z);var Y=Math.pow(2,32)-1,N=function(){function M(){}return M.init=function(){M.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 U;for(U in M.types)M.types.hasOwnProperty(U)&&(M.types[U]=[U.charCodeAt(0),U.charCodeAt(1),U.charCodeAt(2),U.charCodeAt(3)]);var P=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]),_=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]);M.HDLR_TYPES={video:P,audio:_};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),A=new Uint8Array([0,0,0,0,0,0,0,0]);M.STTS=M.STSC=M.STCO=A,M.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),M.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),M.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),M.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var R=new Uint8Array([105,115,111,109]),L=new Uint8Array([97,118,99,49]),w=new Uint8Array([0,0,0,1]);M.FTYP=M.box(M.types.ftyp,R,w,R,L),M.DINF=M.box(M.types.dinf,M.box(M.types.dref,y))},M.box=function(U){for(var P=8,_=arguments.length,y=new Array(_>1?_-1:0),A=1;A<_;A++)y[A-1]=arguments[A];for(var R=y.length,L=R;R--;)P+=y[R].byteLength;var w=new Uint8Array(P);for(w[0]=P>>24&255,w[1]=P>>16&255,w[2]=P>>8&255,w[3]=P&255,w.set(U,4),R=0,P=8;R<L;R++)w.set(y[R],P),P+=y[R].byteLength;return w},M.hdlr=function(U){return M.box(M.types.hdlr,M.HDLR_TYPES[U])},M.mdat=function(U){return M.box(M.types.mdat,U)},M.mdhd=function(U,P){P*=U;var _=Math.floor(P/(Y+1)),y=Math.floor(P%(Y+1));return M.box(M.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,U&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},M.mdia=function(U){return M.box(M.types.mdia,M.mdhd(U.timescale,U.duration),M.hdlr(U.type),M.minf(U))},M.mfhd=function(U){return M.box(M.types.mfhd,new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]))},M.minf=function(U){return U.type==="audio"?M.box(M.types.minf,M.box(M.types.smhd,M.SMHD),M.DINF,M.stbl(U)):M.box(M.types.minf,M.box(M.types.vmhd,M.VMHD),M.DINF,M.stbl(U))},M.moof=function(U,P,_){return M.box(M.types.moof,M.mfhd(U),M.traf(_,P))},M.moov=function(U){for(var P=U.length,_=[];P--;)_[P]=M.trak(U[P]);return M.box.apply(null,[M.types.moov,M.mvhd(U[0].timescale,U[0].duration)].concat(_).concat(M.mvex(U)))},M.mvex=function(U){for(var P=U.length,_=[];P--;)_[P]=M.trex(U[P]);return M.box.apply(null,[M.types.mvex].concat(_))},M.mvhd=function(U,P){P*=U;var _=Math.floor(P/(Y+1)),y=Math.floor(P%(Y+1)),A=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,U&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return M.box(M.types.mvhd,A)},M.sdtp=function(U){var P=U.samples||[],_=new Uint8Array(4+P.length),y,A;for(y=0;y<P.length;y++)A=P[y].flags,_[y+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return M.box(M.types.sdtp,_)},M.stbl=function(U){return M.box(M.types.stbl,M.stsd(U),M.box(M.types.stts,M.STTS),M.box(M.types.stsc,M.STSC),M.box(M.types.stsz,M.STSZ),M.box(M.types.stco,M.STCO))},M.avc1=function(U){var P=[],_=[],y,A,R;for(y=0;y<U.sps.length;y++)A=U.sps[y],R=A.byteLength,P.push(R>>>8&255),P.push(R&255),P=P.concat(Array.prototype.slice.call(A));for(y=0;y<U.pps.length;y++)A=U.pps[y],R=A.byteLength,_.push(R>>>8&255),_.push(R&255),_=_.concat(Array.prototype.slice.call(A));var L=M.box(M.types.avcC,new Uint8Array([1,P[3],P[4],P[5],252|3,224|U.sps.length].concat(P).concat([U.pps.length]).concat(_))),w=U.width,b=U.height,u=U.pixelRatio[0],o=U.pixelRatio[1];return M.box(M.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,w>>8&255,w&255,b>>8&255,b&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),L,M.box(M.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),M.box(M.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255])))},M.esds=function(U){var P=U.config.length;return new Uint8Array([0,0,0,0,3,23+P,0,1,0,4,15+P,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([P]).concat(U.config).concat([6,1,2]))},M.mp4a=function(U){var P=U.samplerate;return M.box(M.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,P>>8&255,P&255,0,0]),M.box(M.types.esds,M.esds(U)))},M.mp3=function(U){var P=U.samplerate;return M.box(M.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,P>>8&255,P&255,0,0]))},M.stsd=function(U){return U.type==="audio"?!U.isAAC&&U.codec==="mp3"?M.box(M.types.stsd,M.STSD,M.mp3(U)):M.box(M.types.stsd,M.STSD,M.mp4a(U)):M.box(M.types.stsd,M.STSD,M.avc1(U))},M.tkhd=function(U){var P=U.id,_=U.duration*U.timescale,y=U.width,A=U.height,R=Math.floor(_/(Y+1)),L=Math.floor(_%(Y+1));return M.box(M.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,P>>24&255,P>>16&255,P>>8&255,P&255,0,0,0,0,R>>24,R>>16&255,R>>8&255,R&255,L>>24,L>>16&255,L>>8&255,L&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,A>>8&255,A&255,0,0]))},M.traf=function(U,P){var _=M.sdtp(U),y=U.id,A=Math.floor(P/(Y+1)),R=Math.floor(P%(Y+1));return M.box(M.types.traf,M.box(M.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),M.box(M.types.tfdt,new Uint8Array([1,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,R>>24,R>>16&255,R>>8&255,R&255])),M.trun(U,_.length+16+20+8+16+8+8),_)},M.trak=function(U){return U.duration=U.duration||4294967295,M.box(M.types.trak,M.tkhd(U),M.mdia(U))},M.trex=function(U){var P=U.id;return M.box(M.types.trex,new Uint8Array([0,0,0,0,P>>24,P>>16&255,P>>8&255,P&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},M.trun=function(U,P){var _=U.samples||[],y=_.length,A=12+16*y,R=new Uint8Array(A),L,w,b,u,o,l;for(P+=8+A,R.set([0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,P>>>24&255,P>>>16&255,P>>>8&255,P&255],0),L=0;L<y;L++)w=_[L],b=w.duration,u=w.size,o=w.flags,l=w.cts,R.set([b>>>24&255,b>>>16&255,b>>>8&255,b&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*L);return M.box(M.types.trun,R)},M.initSegment=function(U){M.types||M.init();var P=M.moov(U),_=new Uint8Array(M.FTYP.byteLength+P.byteLength);return _.set(M.FTYP),_.set(P,M.FTYP.byteLength),_},M}();N.types=void 0,N.HDLR_TYPES=void 0,N.STTS=void 0,N.STSC=void 0,N.STCO=void 0,N.STSZ=void 0,N.VMHD=void 0,N.SMHD=void 0,N.STSD=void 0,N.FTYP=void 0,N.DINF=void 0,Z.default=N},"./src/remux/mp4-remuxer.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return l}),D.d(Z,"normalizePts",function(){return h});var Y=D("./src/polyfills/number.ts"),N=D("./src/remux/aac-helper.ts"),M=D("./src/remux/mp4-generator.ts"),H=D("./src/events.ts"),U=D("./src/errors.ts"),P=D("./src/utils/logger.ts"),_=D("./src/types/loader.ts"),y=D("./src/utils/timescale-conversion.ts");function A(){return A=Object.assign||function(k){for(var E=1;E<arguments.length;E++){var f=arguments[E];for(var m in f)Object.prototype.hasOwnProperty.call(f,m)&&(k[m]=f[m])}return k},A.apply(this,arguments)}var R=10*1e3,L=1024,w=1152,b=null,u=null,o=!1,l=function(){function k(f,m,d,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=f,this.config=m,this.typeSupported=d,this.ISGenerated=!1,b===null){var x=navigator.userAgent||"",v=x.match(/Chrome\/(\d+)/i);b=v?parseInt(v[1]):0}if(u===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);u=T?parseInt(T[1]):0}o=!!b&&b<75||!!u&&u<600}var E=k.prototype;return E.destroy=function(){},E.resetTimeStamp=function(m){P.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=m},E.resetNextTimestamp=function(){P.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},E.resetInitSegment=function(){P.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},E.getVideoStartPts=function(m){var d=!1,a=m.reduce(function(x,v){var T=v.pts-x;return T<-4294967296?(d=!0,h(x,v.pts)):T>0?x:v.pts},m[0].pts);return d&&P.logger.debug("PTS rollover detected"),a},E.remux=function(m,d,a,x,v,T,I,G){var V,Q,z,j,q,ie,ce=v,ve=v,Oe=m.pid>-1,xe=d.pid>-1,Te=d.samples.length,we=m.samples.length>0,Se=Te>1,pe=(!Oe||we)&&(!xe||Se)||this.ISGenerated||I;if(pe){this.ISGenerated||(z=this.generateIS(m,d,v));var oe=this.isVideoContiguous,De=-1;if(Se&&(De=C(d.samples),!oe&&this.config.forceKeyFrameOnDiscontinuity))if(ie=!0,De>0){P.logger.warn("[mp4-remuxer]: Dropped "+De+" out of "+Te+" video samples due to a missing keyframe");var Ve=this.getVideoStartPts(d.samples);d.samples=d.samples.slice(De),d.dropped+=De,ve+=(d.samples[0].pts-Ve)/(d.timescale||9e4)}else De===-1&&(P.logger.warn("[mp4-remuxer]: No keyframe found out of "+Te+" video samples"),ie=!1);if(this.ISGenerated){if(we&&Se){var ze=this.getVideoStartPts(d.samples),et=h(m.samples[0].pts,ze)-ze,Je=et/d.inputTimeScale;ce+=Math.max(0,Je),ve+=Math.max(0,-Je)}if(we){if(m.samplerate||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(m,d,v)),Q=this.remuxAudio(m,ce,this.isAudioContiguous,T,xe||Se||G===_.PlaylistLevelType.AUDIO?ve:void 0),Se){var ke=Q?Q.endPTS-Q.startPTS:0;d.inputTimeScale||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(m,d,v)),V=this.remuxVideo(d,ve,oe,ke)}}else Se&&(V=this.remuxVideo(d,ve,oe,0));V&&(V.firstKeyFrame=De,V.independent=De!==-1)}}return this.ISGenerated&&(a.samples.length&&(q=this.remuxID3(a,v)),x.samples.length&&(j=this.remuxText(x,v))),{audio:Q,video:V,initSegment:z,independent:ie,text:j,id3:q}},E.generateIS=function(m,d,a){var x=m.samples,v=d.samples,T=this.typeSupported,I={},G=!Object(Y.isFiniteNumber)(this._initPTS),V="audio/mp4",Q,z,j;if(G&&(Q=z=Infinity),m.config&&x.length&&(m.timescale=m.samplerate,m.isAAC||(T.mpeg?(V="audio/mpeg",m.codec=""):T.mp3&&(m.codec="mp3")),I.audio={id:"audio",container:V,codec:m.codec,initSegment:!m.isAAC&&T.mpeg?new Uint8Array(0):M.default.initSegment([m]),metadata:{channelCount:m.channelCount}},G&&(j=m.inputTimeScale,Q=z=x[0].pts-Math.round(j*a))),d.sps&&d.pps&&v.length&&(d.timescale=d.inputTimeScale,I.video={id:"main",container:"video/mp4",codec:d.codec,initSegment:M.default.initSegment([d]),metadata:{width:d.width,height:d.height}},G)){j=d.inputTimeScale;var q=this.getVideoStartPts(v),ie=Math.round(j*a);z=Math.min(z,h(v[0].dts,q)-ie),Q=Math.min(Q,q-ie)}if(Object.keys(I).length)return this.ISGenerated=!0,G&&(this._initPTS=Q,this._initDTS=z),{tracks:I,initPTS:Q,timescale:j}},E.remuxVideo=function(m,d,a,x){var v=m.inputTimeScale,T=m.samples,I=[],G=T.length,V=this._initPTS,Q=this.nextAvcDts,z=8,j,q,ie,ce=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,Oe=0,xe=!1;if(!a||Q===null){var Te=d*v,we=T[0].pts-h(T[0].dts,T[0].pts);Q=Te-we}for(var Se=0;Se<G;Se++){var pe=T[Se];if(pe.pts=h(pe.pts-V,Q),pe.dts=h(pe.dts-V,Q),pe.dts>pe.pts){var oe=9e4*.2;Oe=Math.max(Math.min(Oe,pe.pts-pe.dts),-1*oe)}pe.dts<T[Se>0?Se-1:Se].dts&&(xe=!0)}xe&&T.sort(function(Ct,St){var st=Ct.dts-St.dts,Ft=Ct.pts-St.pts;return st||Ft}),q=T[0].dts,ie=T[T.length-1].dts;var De=Math.round((ie-q)/(G-1));if(Oe<0){if(Oe<De*-2){P.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(y.toMsFromMpegTsClock)(-De,!0)+" ms");for(var Ve=Oe,ze=0;ze<G;ze++)T[ze].dts=Ve=Math.max(Ve,T[ze].pts-De),T[ze].pts=Math.max(Ve,T[ze].pts)}else{P.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(y.toMsFromMpegTsClock)(Oe,!0)+" ms to overcome this issue");for(var et=0;et<G;et++)T[et].dts=T[et].dts+Oe}q=T[0].dts}if(a){var Je=q-Q,ke=Je>De,Ie=Je<-1;if(ke||Ie){ke?P.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(Je,!0)+" ms ("+Je+"dts) hole between fragments detected, filling it"):P.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-Je,!0)+" ms ("+Je+"dts) overlapping between fragments detected"),q=Q;var He=T[0].pts-Je;T[0].dts=q,T[0].pts=He,P.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(He,!0)+"/"+Object(y.toMsFromMpegTsClock)(q,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(Je,!0)+" ms")}}o&&(q=Math.max(0,q));for(var Ge=0,je=0,_e=0;_e<G;_e++){for(var Be=T[_e],$e=Be.units,qe=$e.length,Qe=0,Ze=0;Ze<qe;Ze++)Qe+=$e[Ze].data.length;je+=Qe,Ge+=qe,Be.length=Qe,Be.dts=Math.max(Be.dts,q),Be.pts=Math.max(Be.pts,Be.dts,0),ce=Math.min(Be.pts,ce),ve=Math.max(Be.pts,ve)}ie=T[G-1].dts;var ct=je+4*Ge+8,it;try{it=new Uint8Array(ct)}catch(Ct){this.observer.emit(H.Events.ERROR,H.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ct,reason:"fail allocating video mdat "+ct});return}var rt=new DataView(it.buffer);rt.setUint32(0,ct),it.set(M.default.types.mdat,4);for(var Ce=0;Ce<G;Ce++){for(var lt=T[Ce],nt=lt.units,Ae=0,Fe=0,ge=nt.length;Fe<ge;Fe++){var de=nt[Fe],fe=de.data,ee=de.data.byteLength;rt.setUint32(z,ee),z+=4,it.set(fe,z),z+=ee,Ae+=4+ee}if(Ce<G-1)j=T[Ce+1].dts-lt.dts;else{var te=this.config,ne=lt.dts-T[Ce>0?Ce-1:Ce].dts;if(te.stretchShortVideoTrack&&this.nextAudioPts!==null){var ue=Math.floor(te.maxBufferHole*v),me=(x?ce+x*v:this.nextAudioPts)-lt.pts;me>ue?(j=me-ne,j<0&&(j=ne),P.logger.log("[mp4-remuxer]: It is approximately "+me/90+" ms to the next segment; using duration "+j/90+" ms for the last video frame.")):j=ne}else j=ne}var Ee=Math.round(lt.pts-lt.dts);I.push(new g(lt.key,j,Ae,Ee))}if(I.length&&b&&b<70){var Me=I[0].flags;Me.dependsOn=2,Me.isNonSync=0}console.assert(j!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=Q=ie+j,this.isVideoContiguous=!0;var tt=M.default.moof(m.sequenceNumber++,q,A({},m,{samples:I})),mt="video",dt={data1:tt,data2:it,startPTS:ce/v,endPTS:(ve+j)/v,startDTS:q/v,endDTS:Q/v,type:mt,hasAudio:!1,hasVideo:!0,nb:I.length,dropped:m.dropped};return m.samples=[],m.dropped=0,console.assert(it.length,"MDAT length must not be zero"),dt},E.remuxAudio=function(m,d,a,x,v){var T=m.inputTimeScale,I=m.samplerate?m.samplerate:T,G=T/I,V=m.isAAC?L:w,Q=V*G,z=this._initPTS,j=!m.isAAC&&this.typeSupported.mpeg,q=[],ie=m.samples,ce=j?0:8,ve=this.nextAudioPts||-1,Oe=d*T;if(this.isAudioContiguous=a=a||ie.length&&ve>0&&(x&&Math.abs(Oe-ve)<9e3||Math.abs(h(ie[0].pts-z,Oe)-ve)<20*Q),ie.forEach(function(fe){fe.pts=h(fe.pts-z,Oe)}),!a||ve<0){if(ie=ie.filter(function(fe){return fe.pts>=0}),!ie.length)return;v===0?ve=0:x?ve=Math.max(0,Oe):ve=ie[0].pts}if(m.isAAC)for(var xe=v!==void 0,Te=this.config.maxAudioFramesDrift,we=0,Se=ve;we<ie.length;we++){var pe=ie[we],oe=pe.pts,De=oe-Se,Ve=Math.abs(1e3*De/T);if(De<=-Te*Q&&xe)we===0&&(P.logger.warn("Audio frame @ "+(oe/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*De/T)+" ms."),this.nextAudioPts=ve=Se=oe);else if(De>=Te*Q&&Ve<R&&xe){var ze=Math.round(De/Q);Se=oe-ze*Q,Se<0&&(ze--,Se+=Q),we===0&&(this.nextAudioPts=ve=Se),P.logger.warn("[mp4-remuxer]: Injecting "+ze+" audio frame @ "+(Se/T).toFixed(3)+"s due to "+Math.round(1e3*De/T)+" ms gap.");for(var et=0;et<ze;et++){var Je=Math.max(Se,0),ke=N.default.getSilentFrame(m.manifestCodec||m.codec,m.channelCount);ke||(P.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ke=pe.unit.subarray()),ie.splice(we,0,{unit:ke,pts:Je}),Se+=Q,we++}}pe.pts=Se,Se+=Q}for(var Ie=null,He=null,Ge,je=0,_e=ie.length;_e--;)je+=ie[_e].unit.byteLength;for(var Be=0,$e=ie.length;Be<$e;Be++){var qe=ie[Be],Qe=qe.unit,Ze=qe.pts;if(He!==null){var ct=q[Be-1];ct.duration=Math.round((Ze-He)/G)}else if(a&&m.isAAC&&(Ze=ve),Ie=Ze,je>0){je+=ce;try{Ge=new Uint8Array(je)}catch(fe){this.observer.emit(H.Events.ERROR,H.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:je,reason:"fail allocating audio mdat "+je});return}if(!j){var it=new DataView(Ge.buffer);it.setUint32(0,je),Ge.set(M.default.types.mdat,4)}}else return;Ge.set(Qe,ce);var rt=Qe.byteLength;ce+=rt,q.push(new g(!0,V,rt,0)),He=Ze}var Ce=q.length;if(!Ce)return;var lt=q[q.length-1];this.nextAudioPts=ve=He+G*lt.duration;var nt=j?new Uint8Array(0):M.default.moof(m.sequenceNumber++,Ie/G,A({},m,{samples:q}));m.samples=[];var Ae=Ie/T,Fe=ve/T,ge="audio",de={data1:nt,data2:Ge,startPTS:Ae,endPTS:Fe,startDTS:Ae,endDTS:Fe,type:ge,hasAudio:!0,hasVideo:!1,nb:Ce};return this.isAudioContiguous=!0,console.assert(Ge.length,"MDAT length must not be zero"),de},E.remuxEmptyAudio=function(m,d,a,x){var v=m.inputTimeScale,T=m.samplerate?m.samplerate:v,I=v/T,G=this.nextAudioPts,V=(G!==null?G:x.startDTS*v)+this._initDTS,Q=x.endDTS*v+this._initDTS,z=I*L,j=Math.ceil((Q-V)/z),q=N.default.getSilentFrame(m.manifestCodec||m.codec,m.channelCount);if(P.logger.warn("[mp4-remuxer]: remux empty Audio"),!q){P.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ie=[],ce=0;ce<j;ce++){var ve=V+ce*z;ie.push({unit:q,pts:ve,dts:ve})}return m.samples=ie,this.remuxAudio(m,d,a,!1)},E.remuxID3=function(m,d){var a=m.samples.length;if(!a)return;for(var x=m.inputTimeScale,v=this._initPTS,T=this._initDTS,I=0;I<a;I++){var G=m.samples[I];G.pts=h(G.pts-v,d*x)/x,G.dts=h(G.dts-T,d*x)/x}var V=m.samples;return m.samples=[],{samples:V}},E.remuxText=function(m,d){var a=m.samples.length;if(!a)return;for(var x=m.inputTimeScale,v=this._initPTS,T=0;T<a;T++){var I=m.samples[T];I.pts=h(I.pts-v,d*x)/x}m.samples.sort(function(V,Q){return V.pts-Q.pts});var G=m.samples;return m.samples=[],{samples:G}},k}();function h(k,E){var f;if(E===null)return k;for(E<k?f=-8589934592:f=8589934592;Math.abs(k-E)>4294967296;)k+=f;return k}function C(k){for(var E=0;E<k.length;E++)if(k[E].key)return E;return-1}var g=function(E,f,m,d){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=f,this.size=m,this.cts=d,this.flags=new p(E)},p=function(E){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=E?2:1,this.isNonSync=E?0:1}},"./src/remux/passthrough-remuxer.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/polyfills/number.ts"),N=D("./src/utils/mp4-tools.ts"),M=D("./src/loader/fragment.ts"),H=D("./src/utils/logger.ts"),U=function(){function y(){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 A=y.prototype;return A.destroy=function(){},A.resetTimeStamp=function(L){this.initPTS=L,this.lastEndDTS=null},A.resetNextTimestamp=function(){this.lastEndDTS=null},A.resetInitSegment=function(L,w,b){this.audioCodec=w,this.videoCodec=b,this.generateInitSegment(L),this.emitInitSegment=!0},A.generateInitSegment=function(L){var w=this.audioCodec,b=this.videoCodec;if(!L||!L.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(N.parseInitSegment)(L);w||(w=_(u.audio,M.ElementaryStreamTypes.AUDIO)),b||(b=_(u.video,M.ElementaryStreamTypes.VIDEO));var o={};u.audio&&u.video?o.audiovideo={container:"video/mp4",codec:w+","+b,initSegment:L,id:"main"}:u.audio?o.audio={container:"audio/mp4",codec:w,initSegment:L,id:"audio"}:u.video?o.video={container:"video/mp4",codec:b,initSegment:L,id:"main"}:H.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},A.remux=function(L,w,b,u,o){var l=this.initPTS,h=this.lastEndDTS,C={audio:void 0,video:void 0,text:u,id3:b,initSegment:void 0};Object(Y.isFiniteNumber)(h)||(h=this.lastEndDTS=o||0);var g=w.samples;if(!g||!g.length)return C;var p={initPTS:void 0,timescale:1},k=this.initData;if((!k||!k.length)&&(this.generateInitSegment(g),k=this.initData),!k||!k.length)return H.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),C;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1),Object(Y.isFiniteNumber)(l)||(this.initPTS=p.initPTS=l=P(k,g,h));var E=Object(N.getDuration)(g,k),f=h,m=E+f;Object(N.offsetStartDTS)(k,g,l),E>0?this.lastEndDTS=m:(H.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!k.audio,a=!!k.video,x="";d&&(x+="audio"),a&&(x+="video");var v={data1:g,startPTS:f,startDTS:f,endPTS:m,endDTS:m,type:x,hasAudio:d,hasVideo:a,nb:1,dropped:0};return C.audio=v.type==="audio"?v:void 0,C.video=v.type!=="audio"?v:void 0,C.text=u,C.id3=b,C.initSegment=p,C},y}(),P=function(A,R,L){return Object(N.getStartDTS)(A,R)-L};function _(y,A){var R=y==null?void 0:y.codec;return R&&R.length>4?R:R==="hvc1"?"hvc1.1.c.L120.90":R==="av01"?"av01.0.04M.08":R==="avc1"||A===M.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}Z.default=U},"./src/task-loop.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return Y});var Y=function(){function N(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var M=N.prototype;return M.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},M.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},M.onHandlerDestroyed=function(){},M.hasInterval=function(){return!!this._tickInterval},M.hasNextTick=function(){return!!this._tickTimer},M.setInterval=function(U){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,U),!0)},M.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},M.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},M.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},M.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},M.doTick=function(){},N}()},"./src/types/cmcd.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"CMCDVersion",function(){return Y}),D.d(Z,"CMCDObjectType",function(){return N}),D.d(Z,"CMCDStreamingFormat",function(){return M}),D.d(Z,"CMCDStreamType",function(){return H});var Y=1,N;(function(U){U.MANIFEST="m",U.AUDIO="a",U.VIDEO="v",U.MUXED="av",U.INIT="i",U.CAPTION="c",U.TIMED_TEXT="tt",U.KEY="k",U.OTHER="o"})(N||(N={}));var M;(function(U){U.DASH="d",U.HLS="h",U.SMOOTH="s",U.OTHER="o"})(M||(M={}));var H;(function(U){U.VOD="v",U.LIVE="l"})(H||(H={}))},"./src/types/level.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"HlsSkip",function(){return M}),D.d(Z,"getSkipValue",function(){return H}),D.d(Z,"HlsUrlParameters",function(){return U}),D.d(Z,"Level",function(){return P});function Y(_,y){for(var A=0;A<y.length;A++){var R=y[A];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}function N(_,y,A){return y&&Y(_.prototype,y),A&&Y(_,A),_}var M;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(M||(M={}));function H(_,y){var A=_.canSkipUntil,R=_.canSkipDateRanges,L=_.endSN,w=y!==void 0?y-L:0;return A&&w<A?R?M.v2:M.Yes:M.No}var U=function(){function _(A,R,L){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=A,this.part=R,this.skip=L}var y=_.prototype;return y.addDirectives=function(R){var L=new self.URL(R);return this.msn!==void 0&&L.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&L.searchParams.set("_HLS_part",this.part.toString()),this.skip&&L.searchParams.set("_HLS_skip",this.skip),L.toString()},_}(),P=function(){function _(y){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=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(A){return A}).join(",").replace(/\.[^.,]+/g,"")}return N(_,[{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(A){var R=A%this.url.length;this._urlId!==R&&(this.details=void 0,this._urlId=R)}}]),_}()},"./src/types/loader.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"PlaylistContextType",function(){return Y}),D.d(Z,"PlaylistLevelType",function(){return N});var Y;(function(M){M.MANIFEST="manifest",M.LEVEL="level",M.AUDIO_TRACK="audioTrack",M.SUBTITLE_TRACK="subtitleTrack"})(Y||(Y={}));var N;(function(M){M.MAIN="main",M.AUDIO="audio",M.SUBTITLE="subtitle"})(N||(N={}))},"./src/types/transmuxer.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"ChunkMetadata",function(){return Y});var Y=function(H,U,P,_,y,A){_===void 0&&(_=0),y===void 0&&(y=-1),A===void 0&&(A=!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=N(),this.buffering={audio:N(),video:N(),audiovideo:N()},this.level=H,this.sn=U,this.id=P,this.size=_,this.part=y,this.partial=A};function N(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"AttrList",function(){return M});var Y=/^(\d+)x(\d+)$/,N=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,M=function(){function H(P){typeof P=="string"&&(P=H.parseAttrList(P));for(var _ in P)P.hasOwnProperty(_)&&(this[_]=P[_])}var U=H.prototype;return U.decimalInteger=function(_){var y=parseInt(this[_],10);return y>Number.MAX_SAFE_INTEGER?Infinity:y},U.hexadecimalInteger=function(_){if(this[_]){var y=(this[_]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var A=new Uint8Array(y.length/2),R=0;R<y.length/2;R++)A[R]=parseInt(y.slice(R*2,R*2+2),16);return A}else return null},U.hexadecimalIntegerAsNumber=function(_){var y=parseInt(this[_],16);return y>Number.MAX_SAFE_INTEGER?Infinity:y},U.decimalFloatingPoint=function(_){return parseFloat(this[_])},U.optionalFloat=function(_,y){var A=this[_];return A?parseFloat(A):y},U.enumeratedString=function(_){return this[_]},U.bool=function(_){return this[_]==="YES"},U.decimalResolution=function(_){var y=Y.exec(this[_]);return y===null?void 0:{width:parseInt(y[1],10),height:parseInt(y[2],10)}},H.parseAttrList=function(_){var y,A={},R='"';for(N.lastIndex=0;(y=N.exec(_))!==null;){var L=y[2];L.indexOf(R)===0&&L.lastIndexOf(R)===L.length-1&&(L=L.slice(1,-1)),A[y[1]]=L}return A},H}()},"./src/utils/binary-search.ts":function(re,Z,D){"use strict";D.r(Z);var Y={search:function(M,H){for(var U=0,P=M.length-1,_=null,y=null;U<=P;){_=(U+P)/2|0,y=M[_];var A=H(y);if(A>0)U=_+1;else if(A<0)P=_-1;else return y}return null}};Z.default=Y},"./src/utils/buffer-helper.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"BufferHelper",function(){return M});var Y=D("./src/utils/logger.ts"),N={length:0,start:function(){return 0},end:function(){return 0}},M=function(){function H(){}return H.isBuffered=function(P,_){try{if(P){for(var y=H.getBuffered(P),A=0;A<y.length;A++)if(_>=y.start(A)&&_<=y.end(A))return!0}}catch(R){}return!1},H.bufferInfo=function(P,_,y){try{if(P){var A=H.getBuffered(P),R=[],L;for(L=0;L<A.length;L++)R.push({start:A.start(L),end:A.end(L)});return this.bufferedInfo(R,_,y)}}catch(w){}return{len:0,start:_,end:_,nextStart:void 0}},H.bufferedInfo=function(P,_,y){_=Math.max(0,_),P.sort(function(p,k){var E=p.start-k.start;return E||k.end-p.end});var A=[];if(y)for(var R=0;R<P.length;R++){var L=A.length;if(L){var w=A[L-1].end;P[R].start-w<y?P[R].end>w&&(A[L-1].end=P[R].end):A.push(P[R])}else A.push(P[R])}else A=P;for(var b=0,u,o=_,l=_,h=0;h<A.length;h++){var C=A[h].start,g=A[h].end;if(_+y>=C&&_<g)o=C,l=g,b=l-_;else if(_+y<C){u=C;break}}return{len:b,start:o||0,end:l||0,nextStart:u}},H.getBuffered=function(P){try{return P.buffered}catch(_){return Y.logger.log("failed to get media.buffered",_),N}},H}()},"./src/utils/cea-608-parser.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"Row",function(){return l}),D.d(Z,"CaptionScreen",function(){return h});var Y=D("./src/utils/logger.ts"),N={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},M=function(m){var d=m;return N.hasOwnProperty(m)&&(d=N[m]),String.fromCharCode(d)},H=15,U=100,P={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},A={25:2,26:4,29:6,30:8,31:10,27:13,28:15},R=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],L;(function(f){f[f.ERROR=0]="ERROR",f[f.TEXT=1]="TEXT",f[f.WARNING=2]="WARNING",f[f.INFO=2]="INFO",f[f.DEBUG=3]="DEBUG",f[f.DATA=3]="DATA"})(L||(L={}));var w=function(){function f(){this.time=null,this.verboseLevel=L.ERROR}var m=f.prototype;return m.log=function(a,x){this.verboseLevel>=a&&Y.logger.log(this.time+" ["+a+"] "+x)},f}(),b=function(m){for(var d=[],a=0;a<m.length;a++)d.push(m[a].toString(16));return d},u=function(){function f(d,a,x,v,T){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=d||"white",this.underline=a||!1,this.italics=x||!1,this.background=v||"black",this.flash=T||!1}var m=f.prototype;return m.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},m.setStyles=function(a){for(var x=["foreground","underline","italics","background","flash"],v=0;v<x.length;v++){var T=x[v];a.hasOwnProperty(T)&&(this[T]=a[T])}},m.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},m.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},m.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},m.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},f}(),o=function(){function f(d,a,x,v,T,I){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new u(a,x,v,T,I)}var m=f.prototype;return m.reset=function(){this.uchar=" ",this.penState.reset()},m.setChar=function(a,x){this.uchar=a,this.penState.copy(x)},m.setPenState=function(a){this.penState.copy(a)},m.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},m.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},m.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},f}(),l=function(){function f(d){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<U;a++)this.chars.push(new o);this.logger=d,this.pos=0,this.currPenState=new u}var m=f.prototype;return m.equals=function(a){for(var x=!0,v=0;v<U;v++)if(!this.chars[v].equals(a.chars[v])){x=!1;break}return x},m.copy=function(a){for(var x=0;x<U;x++)this.chars[x].copy(a.chars[x])},m.isEmpty=function(){for(var a=!0,x=0;x<U;x++)if(!this.chars[x].isEmpty()){a=!1;break}return a},m.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(L.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>U&&(this.logger.log(L.DEBUG,"Too large cursor position "+this.pos),this.pos=U)},m.moveCursor=function(a){var x=this.pos+a;if(a>1)for(var v=this.pos+1;v<x+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(x)},m.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},m.insertChar=function(a){a>=144&&this.backSpace();var x=M(a);if(this.pos>=U){this.logger.log(L.ERROR,"Cannot insert "+a.toString(16)+" ("+x+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(x,this.currPenState),this.moveCursor(1)},m.clearFromPos=function(a){var x;for(x=a;x<U;x++)this.chars[x].reset()},m.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},m.clearToEndOfRow=function(){this.clearFromPos(this.pos)},m.getTextString=function(){for(var a=[],x=!0,v=0;v<U;v++){var T=this.chars[v].uchar;T!==" "&&(x=!1),a.push(T)}return x?"":a.join("")},m.setPenStyles=function(a){this.currPenState.setStyles(a);var x=this.chars[this.pos];x.setPenState(this.currPenState)},f}(),h=function(){function f(d){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<H;a++)this.rows.push(new l(d));this.logger=d,this.currRow=H-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var m=f.prototype;return m.reset=function(){for(var a=0;a<H;a++)this.rows[a].clear();this.currRow=H-1},m.equals=function(a){for(var x=!0,v=0;v<H;v++)if(!this.rows[v].equals(a.rows[v])){x=!1;break}return x},m.copy=function(a){for(var x=0;x<H;x++)this.rows[x].copy(a.rows[x])},m.isEmpty=function(){for(var a=!0,x=0;x<H;x++)if(!this.rows[x].isEmpty()){a=!1;break}return a},m.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},m.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},m.insertChar=function(a){var x=this.rows[this.currRow];x.insertChar(a)},m.setPen=function(a){var x=this.rows[this.currRow];x.setPenStyles(a)},m.moveCursor=function(a){var x=this.rows[this.currRow];x.moveCursor(a)},m.setCursor=function(a){this.logger.log(L.INFO,"setCursor: "+a);var x=this.rows[this.currRow];x.setCursor(a)},m.setPAC=function(a){this.logger.log(L.INFO,"pacData = "+JSON.stringify(a));var x=a.row-1;if(this.nrRollUpRows&&x<this.nrRollUpRows-1&&(x=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==x){for(var v=0;v<H;v++)this.rows[v].clear();var T=this.currRow+1-this.nrRollUpRows,I=this.lastOutputScreen;if(I){var G=I.rows[T].cueStartTime,V=this.logger.time;if(G&&V!==null&&G<V)for(var Q=0;Q<this.nrRollUpRows;Q++)this.rows[x-this.nrRollUpRows+Q+1].copy(I.rows[T+Q])}}this.currRow=x;var z=this.rows[this.currRow];if(a.indent!==null){var j=a.indent,q=Math.max(j-1,0);z.setCursor(a.indent),a.color=z.chars[q].penState.foreground}var ie={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ie)},m.setBkgData=function(a){this.logger.log(L.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},m.setRollUpRows=function(a){this.nrRollUpRows=a},m.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(L.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(L.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,x=this.rows.splice(a,1)[0];x.clear(),this.rows.splice(this.currRow,0,x),this.logger.log(L.INFO,"Rolling up")},m.getDisplayText=function(a){a=a||!1;for(var x=[],v="",T=-1,I=0;I<H;I++){var G=this.rows[I].getTextString();G&&(T=I+1,a?x.push("Row "+T+": '"+G+"'"):x.push(G.trim()))}return x.length>0&&(a?v="["+x.join(" | ")+"]":v=x.join(`
`)),v},m.getTextAndFormat=function(){return this.rows},f}(),C=function(){function f(d,a,x){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=d,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new h(x),this.nonDisplayedMemory=new h(x),this.lastOutputScreen=new h(x),this.currRollUpRow=this.displayedMemory.rows[H-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=x}var m=f.prototype;return m.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[H-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},m.getHandler=function(){return this.outputFilter},m.setHandler=function(a){this.outputFilter=a},m.setPAC=function(a){this.writeScreen.setPAC(a)},m.setBkgData=function(a){this.writeScreen.setBkgData(a)},m.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(L.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},m.insertChars=function(a){for(var x=0;x<a.length;x++)this.writeScreen.insertChar(a[x]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(L.INFO,v+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(L.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},m.ccRCL=function(){this.logger.log(L.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},m.ccBS=function(){if(this.logger.log(L.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},m.ccAOF=function(){},m.ccAON=function(){},m.ccDER=function(){this.logger.log(L.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},m.ccRU=function(a){this.logger.log(L.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},m.ccFON=function(){this.logger.log(L.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},m.ccRDC=function(){this.logger.log(L.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},m.ccTR=function(){this.logger.log(L.INFO,"TR"),this.setMode("MODE_TEXT")},m.ccRTD=function(){this.logger.log(L.INFO,"RTD"),this.setMode("MODE_TEXT")},m.ccEDM=function(){this.logger.log(L.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},m.ccCR=function(){this.logger.log(L.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},m.ccENM=function(){this.logger.log(L.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},m.ccEOC=function(){if(this.logger.log(L.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(L.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},m.ccTO=function(a){this.logger.log(L.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},m.ccMIDROW=function(a){var x={flash:!1};if(x.underline=a%2===1,x.italics=a>=46,x.italics)x.foreground="white";else{var v=Math.floor(a/2)-16,T=["white","green","blue","cyan","red","yellow","magenta"];x.foreground=T[v]}this.logger.log(L.INFO,"MIDROW: "+JSON.stringify(x)),this.writeScreen.setPen(x)},m.outputDataUpdate=function(a){a===void 0&&(a=!1);var x=this.logger.time;if(x===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=x:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,x,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:x),this.lastOutputScreen.copy(this.displayedMemory))},m.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},f}(),g=function(){function f(d,a,x){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new w;this.channels=[null,new C(d,a,v),new C(d+1,x,v)],this.cmdHistory=E(),this.logger=v}var m=f.prototype;return m.getHandler=function(a){return this.channels[a].getHandler()},m.setHandler=function(a,x){this.channels[a].setHandler(x)},m.addData=function(a,x){var v,T,I,G=!1;this.logger.time=a;for(var V=0;V<x.length;V+=2){if(T=x[V]&127,I=x[V+1]&127,T===0&&I===0)continue;if(this.logger.log(L.DATA,"["+b([x[V],x[V+1]])+"] -> ("+b([T,I])+")"),v=this.parseCmd(T,I),v||(v=this.parseMidrow(T,I)),v||(v=this.parsePAC(T,I)),v||(v=this.parseBackgroundAttributes(T,I)),!v&&(G=this.parseChars(T,I),G)){var Q=this.currentChannel;if(Q&&Q>0){var z=this.channels[Q];z.insertChars(G)}else this.logger.log(L.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!G&&this.logger.log(L.WARNING,"Couldn't parse cleaned data "+b([T,I])+" orig: "+b([x[V],x[V+1]]))}},m.parseCmd=function(a,x){var v=this.cmdHistory,T=(a===20||a===28||a===21||a===29)&&x>=32&&x<=47,I=(a===23||a===31)&&x>=33&&x<=35;if(!(T||I))return!1;if(k(a,x,v))return p(null,null,v),this.logger.log(L.DEBUG,"Repeated command ("+b([a,x])+") is dropped"),!0;var G=a===20||a===21||a===23?1:2,V=this.channels[G];return a===20||a===21||a===28||a===29?x===32?V.ccRCL():x===33?V.ccBS():x===34?V.ccAOF():x===35?V.ccAON():x===36?V.ccDER():x===37?V.ccRU(2):x===38?V.ccRU(3):x===39?V.ccRU(4):x===40?V.ccFON():x===41?V.ccRDC():x===42?V.ccTR():x===43?V.ccRTD():x===44?V.ccEDM():x===45?V.ccCR():x===46?V.ccENM():x===47&&V.ccEOC():V.ccTO(x-32),p(a,x,v),this.currentChannel=G,!0},m.parseMidrow=function(a,x){var v=0;if((a===17||a===25)&&x>=32&&x<=47){if(a===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(L.ERROR,"Mismatch channel in midrow parsing"),!1;var T=this.channels[v];return T?(T.ccMIDROW(x),this.logger.log(L.DEBUG,"MIDROW ("+b([a,x])+")"),!0):!1}return!1},m.parsePAC=function(a,x){var v,T=this.cmdHistory,I=(a>=17&&a<=23||a>=25&&a<=31)&&x>=64&&x<=127,G=(a===16||a===24)&&x>=64&&x<=95;if(!(I||G))return!1;if(k(a,x,T))return p(null,null,T),!0;var V=a<=23?1:2;x>=64&&x<=95?v=V===1?P[a]:y[a]:v=V===1?_[a]:A[a];var Q=this.channels[V];return Q?(Q.setPAC(this.interpretPAC(v,x)),p(a,x,T),this.currentChannel=V,!0):!1},m.interpretPAC=function(a,x){var v,T={color:null,italics:!1,indent:null,underline:!1,row:a};return x>95?v=x-96:v=x-64,T.underline=(v&1)===1,v<=13?T.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(T.italics=!0,T.color="white"):T.indent=Math.floor((v-16)/2)*4,T},m.parseChars=function(a,x){var v,T=null,I=null;if(a>=25?(v=2,I=a-8):(v=1,I=a),I>=17&&I<=19){var G;I===17?G=x+80:I===18?G=x+112:G=x+144,this.logger.log(L.INFO,"Special char '"+M(G)+"' in channel "+v),T=[G]}else a>=32&&a<=127&&(T=x===0?[a]:[a,x]);if(T){var V=b(T);this.logger.log(L.DEBUG,"Char codes = "+V.join(",")),p(a,x,this.cmdHistory)}return T},m.parseBackgroundAttributes=function(a,x){var v=(a===16||a===24)&&x>=32&&x<=47,T=(a===23||a===31)&&x>=45&&x<=47;if(!(v||T))return!1;var I,G={};a===16||a===24?(I=Math.floor((x-32)/2),G.background=R[I],x%2===1&&(G.background=G.background+"_semi")):x===45?G.background="transparent":(G.foreground="black",x===47&&(G.underline=!0));var V=a<=23?1:2,Q=this.channels[V];return Q.setBkgData(G),p(a,x,this.cmdHistory),!0},m.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var x=this.channels[a];x&&x.reset()}this.cmdHistory=E()},m.cueSplitAtTime=function(a){for(var x=0;x<this.channels.length;x++){var v=this.channels[x];v&&v.cueSplitAtTime(a)}},f}();function p(f,m,d){d.a=f,d.b=m}function k(f,m,d){return d.a===f&&d.b===m}function E(){return{a:null,b:null}}Z.default=g},"./src/utils/codecs.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"isCodecType",function(){return N}),D.d(Z,"isCodecSupportedInMp4",function(){return M});var Y={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 N(H,U){var P=Y[U];return!!P&&P[H.slice(0,4)]===!0}function M(H,U){return MediaSource.isTypeSupported((U||"video")+'/mp4;codecs="'+H+'"')}},"./src/utils/cues.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/utils/vttparser.ts"),N=D("./src/utils/webvtt-parser.ts"),M=D("./src/utils/texttrack-utils.ts"),H=/\s/,U={newCue:function(_,y,A,R){for(var L=[],w,b,u,o,l,h=self.VTTCue||self.TextTrackCue,C=0;C<R.rows.length;C++)if(w=R.rows[C],u=!0,o=0,l="",!w.isEmpty()){for(var g=0;g<w.chars.length;g++)H.test(w.chars[g].uchar)&&u?o++:(l+=w.chars[g].uchar,u=!1);w.cueStartTime=y,y===A&&(A+=1e-4),o>=16?o--:o++;var p=Object(Y.fixLineBreaks)(l.trim()),k=Object(N.generateCueId)(y,A,p);(!_||!_.cues||!_.cues.getCueById(k))&&(b=new h(y,A,p),b.id=k,b.line=C+1,b.align="left",b.position=10+Math.min(80,Math.floor(o*8/32)*10),L.push(b))}return _&&L.length&&(L.sort(function(E,f){return E.line==="auto"||f.line==="auto"?0:E.line>8&&f.line>8?f.line-E.line:E.line-f.line}),L.forEach(function(E){return Object(M.addCueToTrack)(_,E)})),L}};Z.default=U},"./src/utils/discontinuities.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"findFirstFragWithCC",function(){return H}),D.d(Z,"shouldAlignOnDiscontinuities",function(){return U}),D.d(Z,"findDiscontinuousReferenceFrag",function(){return P}),D.d(Z,"adjustSlidingStart",function(){return y}),D.d(Z,"alignStream",function(){return A}),D.d(Z,"alignPDT",function(){return L}),D.d(Z,"alignFragmentByPDTDelta",function(){return w}),D.d(Z,"alignMediaPlaylistByPDT",function(){return b});var Y=D("./src/polyfills/number.ts"),N=D("./src/utils/logger.ts"),M=D("./src/controller/level-helper.ts");function H(u,o){for(var l=null,h=0,C=u.length;h<C;h++){var g=u[h];if(g&&g.cc===o){l=g;break}}return l}function U(u,o,l){return!!(o.details&&(l.endCC>l.startCC||u&&u.cc<l.startCC))}function P(u,o){var l=u.fragments,h=o.fragments;if(!h.length||!l.length){N.logger.log("No fragments to align");return}var C=H(l,h[0].cc);if(!C||C&&!C.startPTS){N.logger.log("No frag in previous level to align on");return}return C}function _(u,o){if(u){var l=u.start+o;u.start=u.startPTS=l,u.endPTS=l+u.duration}}function y(u,o){for(var l=o.fragments,h=0,C=l.length;h<C;h++)_(l[h],u);o.fragmentHint&&_(o.fragmentHint,u),o.alignedSliding=!0}function A(u,o,l){if(!o)return;R(u,l,o),!l.alignedSliding&&o.details&&L(l,o.details),!l.alignedSliding&&o.details&&!l.skippedSegments&&Object(M.adjustSliding)(o.details,l)}function R(u,o,l){if(U(u,l,o)){var h=P(l.details,o);h&&Object(Y.isFiniteNumber)(h.start)&&(N.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),y(h.start,o))}}function L(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,h=u.fragments[0].programDateTime,C=(h-l)/1e3+o.fragments[0].start;C&&Object(Y.isFiniteNumber)(C)&&(N.logger.log("Adjusting PTS using programDateTime delta "+(h-l)+"ms, sliding:"+C.toFixed(3)+" "+u.url+" "),y(C,u))}function w(u,o){var l=u.programDateTime;if(!l)return;var h=(l-o)/1e3;u.start=u.startPTS=h,u.endPTS=h+u.duration}function b(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,h=o.fragments[0].start,C=l-h*1e3;u.fragments.forEach(function(g){w(g,C)}),u.fragmentHint&&w(u.fragmentHint,C),u.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/utils/ewma.ts"),N=function(){function M(U,P,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Y.default(U),this.fast_=new Y.default(P)}var H=M.prototype;return H.update=function(P,_){var y=this.slow_,A=this.fast_;this.slow_.halfLife!==P&&(this.slow_=new Y.default(P,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new Y.default(_,A.getEstimate(),A.getTotalWeight()))},H.sample=function(P,_){P=Math.max(P,this.minDelayMs_);var y=8*_,A=P/1e3,R=y/A;this.fast_.sample(A,R),this.slow_.sample(A,R)},H.canEstimate=function(){var P=this.fast_;return P&&P.getTotalWeight()>=this.minWeight_},H.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},H.destroy=function(){},M}();Z.default=N},"./src/utils/ewma.ts":function(re,Z,D){"use strict";D.r(Z);var Y=function(){function N(H,U,P){U===void 0&&(U=0),P===void 0&&(P=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=H,this.alpha_=H?Math.exp(Math.log(.5)/H):0,this.estimate_=U,this.totalWeight_=P}var M=N.prototype;return M.sample=function(U,P){var _=Math.pow(this.alpha_,U);this.estimate_=P*(1-_)+_*this.estimate_,this.totalWeight_+=U},M.getTotalWeight=function(){return this.totalWeight_},M.getEstimate=function(){if(this.alpha_){var U=1-Math.pow(this.alpha_,this.totalWeight_);if(U)return this.estimate_/U}return this.estimate_},N}();Z.default=Y},"./src/utils/fetch-loader.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"fetchSupported",function(){return w});var Y=D("./src/polyfills/number.ts"),N=D("./src/loader/load-stats.ts"),M=D("./src/demux/chunk-cache.ts");function H(h,C){h.prototype=Object.create(C.prototype),h.prototype.constructor=h,A(h,C)}function U(h){var C=typeof Map=="function"?new Map:void 0;return U=function(p){if(p===null||!y(p))return p;if(typeof p!="function")throw new TypeError("Super expression must either be null or a function");if(typeof C!="undefined"){if(C.has(p))return C.get(p);C.set(p,k)}function k(){return P(p,arguments,R(this).constructor)}return k.prototype=Object.create(p.prototype,{constructor:{value:k,enumerable:!1,writable:!0,configurable:!0}}),A(k,p)},U(h)}function P(h,C,g){return _()?P=Reflect.construct:P=function(k,E,f){var m=[null];m.push.apply(m,E);var d=Function.bind.apply(k,m),a=new d;return f&&A(a,f.prototype),a},P.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(h){return!1}}function y(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function A(h,C){return A=Object.setPrototypeOf||function(p,k){return p.__proto__=k,p},A(h,C)}function R(h){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(g){return g.__proto__||Object.getPrototypeOf(g)},R(h)}function L(){return L=Object.assign||function(h){for(var C=1;C<arguments.length;C++){var g=arguments[C];for(var p in g)Object.prototype.hasOwnProperty.call(g,p)&&(h[p]=g[p])}return h},L.apply(this,arguments)}function w(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(h){}return!1}var b=function(){function h(g){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=g.fetchSetup||o,this.controller=new self.AbortController,this.stats=new N.LoadStats}var C=h.prototype;return C.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},C.abortInternal=function(){var p=this.response;(!p||!p.ok)&&(this.stats.aborted=!0,this.controller.abort())},C.abort=function(){var p;this.abortInternal(),(p=this.callbacks)!==null&&p!==void 0&&p.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},C.load=function(p,k,E){var f=this,m=this.stats;if(m.loading.start)throw new Error("Loader can only be used once.");m.loading.start=self.performance.now();var d=u(p,this.controller.signal),a=E.onProgress,x=p.responseType==="arraybuffer",v=x?"byteLength":"length";this.context=p,this.config=k,this.callbacks=E,this.request=this.fetchSetup(p,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){f.abortInternal(),E.onTimeout(m,p,f.response)},k.timeout),self.fetch(this.request).then(function(T){if(f.response=f.loader=T,!T.ok){var I=T.status,G=T.statusText;throw new l(G||"fetch, bad network response",I,T)}return m.loading.first=Math.max(self.performance.now(),m.loading.start),m.total=parseInt(T.headers.get("Content-Length")||"0"),a&&Object(Y.isFiniteNumber)(k.highWaterMark)?f.loadProgressively(T,m,p,k.highWaterMark,a):x?T.arrayBuffer():T.text()}).then(function(T){var I=f.response;self.clearTimeout(f.requestTimeout),m.loading.end=Math.max(self.performance.now(),m.loading.first),m.loaded=m.total=T[v];var G={url:I.url,data:T};a&&!Object(Y.isFiniteNumber)(k.highWaterMark)&&a(m,p,T,I),E.onSuccess(G,m,p,I)}).catch(function(T){if(self.clearTimeout(f.requestTimeout),m.aborted)return;var I=T.code||0;E.onError({code:I,text:T.message},p,T.details)})},C.getCacheAge=function(){var p=null;if(this.response){var k=this.response.headers.get("age");p=k?parseFloat(k):null}return p},C.loadProgressively=function(p,k,E,f,m){f===void 0&&(f=0);var d=new M.default,a=p.body.getReader(),x=function v(){return a.read().then(function(T){if(T.done)return d.dataLength&&m(k,E,d.flush(),p),Promise.resolve(new ArrayBuffer(0));var I=T.value,G=I.length;return k.loaded+=G,G<f||d.dataLength?(d.push(I),d.dataLength>=f&&m(k,E,d.flush(),p)):m(k,E,I,p),v()}).catch(function(){return Promise.reject()})};return x()},h}();function u(h,C){var g={method:"GET",mode:"cors",credentials:"same-origin",signal:C,headers:new self.Headers(L({},h.headers))};return h.rangeEnd&&g.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),g}function o(h,C){return new self.Request(h.url,C)}var l=function(h){H(C,h);function C(g,p,k){var E;return E=h.call(this,g)||this,E.code=void 0,E.details=void 0,E.code=p,E.details=k,E}return C}(U(Error));Z.default=b},"./src/utils/imsc1-ttml-parser.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"IMSC1_CODEC",function(){return y}),D.d(Z,"parseIMSC1",function(){return w});var Y=D("./src/utils/mp4-tools.ts"),N=D("./src/utils/vttparser.ts"),M=D("./src/utils/vttcue.ts"),H=D("./src/demux/id3.ts"),U=D("./src/utils/timescale-conversion.ts"),P=D("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign||function(f){for(var m=1;m<arguments.length;m++){var d=arguments[m];for(var a in d)Object.prototype.hasOwnProperty.call(d,a)&&(f[a]=d[a])}return f},_.apply(this,arguments)}var y="stpp.ttml.im1t",A=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,R=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,L={left:"start",center:"center",right:"end",start:"start",end:"end"};function w(f,m,d,a,x){var v=Object(Y.findBox)(new Uint8Array(f),["mdat"]);if(v.length===0){x(new Error("Could not parse IMSC1 mdat"));return}var T=v[0],I=Object(H.utf8ArrayToStr)(new Uint8Array(f,T.start,T.end-T.start)),G=Object(U.toTimescaleFromScale)(m,1,d);try{a(b(I,G))}catch(V){x(V)}}function b(f,m){var d=new DOMParser,a=d.parseFromString(f,"text/xml"),x=a.getElementsByTagName("tt")[0];if(!x)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},T=Object.keys(v).reduce(function(z,j){return z[j]=x.getAttribute("ttp:"+j)||v[j],z},{}),I=x.getAttribute("xml:space")!=="preserve",G=o(u(x,"styling","style")),V=o(u(x,"layout","region")),Q=u(x,"body","[begin]");return[].map.call(Q,function(z){var j=l(z,I);if(!j||!z.hasAttribute("begin"))return null;var q=p(z.getAttribute("begin"),T),ie=p(z.getAttribute("dur"),T),ce=p(z.getAttribute("end"),T);if(q===null)throw g(z);if(ce===null){if(ie===null)throw g(z);ce=q+ie}var ve=new M.default(q-m,ce-m,j);ve.id=Object(P.generateCueId)(ve.startTime,ve.endTime,ve.text);var Oe=V[z.getAttribute("region")],xe=G[z.getAttribute("style")];ve.position=10,ve.size=80;var Te=h(Oe,xe),we=Te.textAlign;if(we){var Se=L[we];Se&&(ve.lineAlign=Se),ve.align=we}return _(ve,Te),ve}).filter(function(z){return z!==null})}function u(f,m,d){var a=f.getElementsByTagName(m)[0];return a?[].slice.call(a.querySelectorAll(d)):[]}function o(f){return f.reduce(function(m,d){var a=d.getAttribute("xml:id");return a&&(m[a]=d),m},{})}function l(f,m){return[].slice.call(f.childNodes).reduce(function(d,a,x){var v;return a.nodeName==="br"&&x?d+`
`:(v=a.childNodes)!==null&&v!==void 0&&v.length?l(a,m):m?d+a.textContent.trim().replace(/\s+/g," "):d+a.textContent},"")}function h(f,m){var d="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(x,v){var T=C(m,d,v)||C(f,d,v);return T&&(x[v]=T),x},{})}function C(f,m,d){return f.hasAttributeNS(m,d)?f.getAttributeNS(m,d):null}function g(f){return new Error("Could not parse ttml timestamp "+f)}function p(f,m){if(!f)return null;var d=Object(N.parseTimeStamp)(f);return d===null&&(A.test(f)?d=k(f,m):R.test(f)&&(d=E(f,m))),d}function k(f,m){var d=A.exec(f),a=(d[4]|0)+(d[5]|0)/m.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+a/m.frameRate}function E(f,m){var d=R.exec(f),a=Number(d[1]),x=d[2];switch(x){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/m.frameRate;case"t":return a/m.tickRate}return a}},"./src/utils/logger.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"enableLogs",function(){return P}),D.d(Z,"logger",function(){return _});var Y=function(){},N={trace:Y,debug:Y,log:Y,warn:Y,info:Y,error:Y},M=N;function H(y){var A=self.console[y];return A?A.bind(self.console,"["+y+"] >"):Y}function U(y){for(var A=arguments.length,R=new Array(A>1?A-1:0),L=1;L<A;L++)R[L-1]=arguments[L];R.forEach(function(w){M[w]=y[w]?y[w].bind(y):H(w)})}function P(y){if(self.console&&y===!0||typeof y=="object"){U(y,"debug","log","info","warn","error");try{M.log()}catch(A){M=N}}else M=N}var _=M},"./src/utils/mediakeys-helper.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"KeySystems",function(){return Y}),D.d(Z,"requestMediaKeySystemAccess",function(){return N});var Y;(function(M){M.WIDEVINE="com.widevine.alpha",M.PLAYREADY="com.microsoft.playready"})(Y||(Y={}));var N=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"getMediaSource",function(){return Y});function Y(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"bin2str",function(){return U}),D.d(Z,"readUint16",function(){return P}),D.d(Z,"readUint32",function(){return _}),D.d(Z,"writeUint32",function(){return y}),D.d(Z,"findBox",function(){return A}),D.d(Z,"parseSegmentIndex",function(){return R}),D.d(Z,"parseInitSegment",function(){return L}),D.d(Z,"getStartDTS",function(){return w}),D.d(Z,"getDuration",function(){return b}),D.d(Z,"computeRawDurationFromSamples",function(){return u}),D.d(Z,"offsetStartDTS",function(){return o}),D.d(Z,"segmentValidRange",function(){return l}),D.d(Z,"appendUint8Array",function(){return h});var Y=D("./src/utils/typed-array.ts"),N=D("./src/loader/fragment.ts"),M=Math.pow(2,32)-1,H=[].push;function U(C){return String.fromCharCode.apply(null,C)}function P(C,g){"data"in C&&(g+=C.start,C=C.data);var p=C[g]<<8|C[g+1];return p<0?65536+p:p}function _(C,g){"data"in C&&(g+=C.start,C=C.data);var p=C[g]<<24|C[g+1]<<16|C[g+2]<<8|C[g+3];return p<0?4294967296+p:p}function y(C,g,p){"data"in C&&(g+=C.start,C=C.data),C[g]=p>>24,C[g+1]=p>>16&255,C[g+2]=p>>8&255,C[g+3]=p&255}function A(C,g){var p=[];if(!g.length)return p;var k,E,f;"data"in C?(k=C.data,E=C.start,f=C.end):(k=C,E=0,f=k.byteLength);for(var m=E;m<f;){var d=_(k,m),a=U(k.subarray(m+4,m+8)),x=d>1?m+d:f;if(a===g[0])if(g.length===1)p.push({data:k,start:m+8,end:x});else{var v=A({data:k,start:m+8,end:x},g.slice(1));v.length&&H.apply(p,v)}m=x}return p}function R(C){var g=A(C,["moov"]),p=g[0],k=p?p.end:null,E=A(C,["sidx"]);if(!E||!E[0])return null;var f=[],m=E[0],d=m.data[0],a=d===0?8:16,x=_(m,a);a+=4;var v=0,T=0;d===0?a+=8:a+=16,a+=2;var I=m.end+T,G=P(m,a);a+=2;for(var V=0;V<G;V++){var Q=a,z=_(m,Q);Q+=4;var j=z&2147483647,q=(z&2147483648)>>>31;if(q===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ie=_(m,Q);Q+=4,f.push({referenceSize:j,subsegmentDuration:ie,info:{duration:ie/x,start:I,end:I+j-1}}),I+=j,Q+=4,a=Q}return{earliestPresentationTime:v,timescale:x,version:d,referencesCount:G,references:f,moovEndOffset:k}}function L(C){for(var g=[],p=A(C,["moov","trak"]),k=0;k<p.length;k++){var E=p[k],f=A(E,["tkhd"])[0];if(f){var m=f.data[f.start],d=m===0?12:20,a=_(f,d),x=A(E,["mdia","mdhd"])[0];if(x){m=x.data[x.start],d=m===0?12:20;var v=_(x,d),T=A(E,["mdia","hdlr"])[0];if(T){var I=U(T.data.subarray(T.start+8,T.start+12)),G={soun:N.ElementaryStreamTypes.AUDIO,vide:N.ElementaryStreamTypes.VIDEO}[I];if(G){var V=A(E,["mdia","minf","stbl","stsd"])[0],Q=void 0;V&&(Q=U(V.data.subarray(V.start+12,V.start+16))),g[a]={timescale:v,type:G},g[G]={timescale:v,id:a,codec:Q}}}}}}var z=A(C,["moov","mvex","trex"]);return z.forEach(function(j){var q=_(j,4),ie=g[q];ie&&(ie.default={duration:_(j,12),flags:_(j,20)})}),g}function w(C,g){return A(g,["moof","traf"]).reduce(function(p,k){var E=A(k,["tfdt"])[0],f=E.data[E.start],m=A(k,["tfhd"]).reduce(function(d,a){var x=_(a,4),v=C[x];if(v){var T=_(E,4);f===1&&(T*=Math.pow(2,32),T+=_(E,8));var I=v.timescale||9e4,G=T/I;if(isFinite(G)&&(d===null||G<d))return G}return d},null);return m!==null&&isFinite(m)&&(p===null||m<p)?m:p},null)||0}function b(C,g){for(var p=0,k=0,E=0,f=A(C,["moof","traf"]),m=0;m<f.length;m++){var d=f[m],a=A(d,["tfhd"])[0],x=_(a,4),v=g[x];if(!v)continue;var T=v.default,I=_(a,0)|(T==null?void 0:T.flags),G=T==null?void 0:T.duration;I&8&&(I&2?G=_(a,12):G=_(a,8));for(var V=v.timescale||9e4,Q=A(d,["trun"]),z=0;z<Q.length;z++){if(G){var j=_(Q[z],4);p=G*j}else p=u(Q[z]);v.type===N.ElementaryStreamTypes.VIDEO?k+=p/V:v.type===N.ElementaryStreamTypes.AUDIO&&(E+=p/V)}}if(k===0&&E===0){var q=R(C);if(q!=null&&q.references)return q.references.reduce(function(ie,ce){return ie+ce.info.duration||0},0)}return k||E}function u(C){var g=_(C,0),p=8;g&1&&(p+=4),g&4&&(p+=4);for(var k=0,E=_(C,4),f=0;f<E;f++){if(g&256){var m=_(C,p);k+=m,p+=4}g&512&&(p+=4),g&1024&&(p+=4),g&2048&&(p+=4)}return k}function o(C,g,p){A(g,["moof","traf"]).forEach(function(k){A(k,["tfhd"]).forEach(function(E){var f=_(E,4),m=C[f];if(!m)return;var d=m.timescale||9e4;A(k,["tfdt"]).forEach(function(a){var x=a.data[a.start],v=_(a,4);if(x===0)y(a,4,v-p*d);else{v*=Math.pow(2,32),v+=_(a,8),v-=p*d,v=Math.max(v,0);var T=Math.floor(v/(M+1)),I=Math.floor(v%(M+1));y(a,4,T),y(a,8,I)}})})})}function l(C){var g={valid:null,remainder:null},p=A(C,["moof"]);if(p){if(p.length<2)return g.remainder=C,g}else return g;var k=p[p.length-1];return g.valid=Object(Y.sliceUint8)(C,0,k.start-8),g.remainder=Object(Y.sliceUint8)(C,k.start-8),g}function h(C,g){var p=new Uint8Array(C.length+g.length);return p.set(C),p.set(g,C.length),p}},"./src/utils/output-filter.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"default",function(){return Y});var Y=function(){function N(H,U){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=H,this.trackName=U}var M=N.prototype;return M.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},M.newCue=function(U,P,_){(this.startTime===null||this.startTime>U)&&(this.startTime=U),this.endTime=P,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},M.reset=function(){this.cueRanges=[]},N}()},"./src/utils/texttrack-utils.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"sendAddTrackEvent",function(){return N}),D.d(Z,"addCueToTrack",function(){return M}),D.d(Z,"clearCurrentCues",function(){return H}),D.d(Z,"removeCuesInRange",function(){return U}),D.d(Z,"getCuesInRange",function(){return _});var Y=D("./src/utils/logger.ts");function N(y,A){var R;try{R=new Event("addtrack")}catch(L){R=document.createEvent("Event"),R.initEvent("addtrack",!1,!1)}R.track=y,A.dispatchEvent(R)}function M(y,A){var R=y.mode;if(R==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(A.id))try{if(y.addCue(A),!y.cues.getCueById(A.id))throw new Error("addCue is failed for: "+A)}catch(w){Y.logger.debug("[texttrack-utils]: "+w);var L=new self.TextTrackCue(A.startTime,A.endTime,A.text);L.id=A.id,y.addCue(L)}R==="disabled"&&(y.mode=R)}function H(y){var A=y.mode;if(A==="disabled"&&(y.mode="hidden"),y.cues)for(var R=y.cues.length;R--;)y.removeCue(y.cues[R]);A==="disabled"&&(y.mode=A)}function U(y,A,R){var L=y.mode;if(L==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var w=_(y.cues,A,R),b=0;b<w.length;b++)y.removeCue(w[b]);L==="disabled"&&(y.mode=L)}function P(y,A){if(A<y[0].startTime)return 0;var R=y.length-1;if(A>y[R].endTime)return-1;for(var L=0,w=R;L<=w;){var b=Math.floor((w+L)/2);if(A<y[b].startTime)w=b-1;else if(A>y[b].startTime&&L<R)L=b+1;else return b}return y[L].startTime-A<A-y[w].startTime?L:w}function _(y,A,R){var L=[],w=P(y,A);if(w>-1)for(var b=w,u=y.length;b<u;b++){var o=y[b];if(o.startTime>=A&&o.endTime<=R)L.push(o);else if(o.startTime>R)return L}return L}},"./src/utils/time-ranges.ts":function(re,Z,D){"use strict";D.r(Z);var Y={toString:function(M){for(var H="",U=M.length,P=0;P<U;P++)H+="["+M.start(P).toFixed(3)+","+M.end(P).toFixed(3)+"]";return H}};Z.default=Y},"./src/utils/timescale-conversion.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"toTimescaleFromBase",function(){return N}),D.d(Z,"toTimescaleFromScale",function(){return M}),D.d(Z,"toMsFromMpegTsClock",function(){return H}),D.d(Z,"toMpegTsClockFromTimescale",function(){return U});var Y=9e4;function N(P,_,y,A){y===void 0&&(y=1),A===void 0&&(A=!1);var R=P*_*y;return A?Math.round(R):R}function M(P,_,y,A){return y===void 0&&(y=1),A===void 0&&(A=!1),N(P,_,1/y,A)}function H(P,_){return _===void 0&&(_=!1),N(P,1e3,1/Y,_)}function U(P,_){return _===void 0&&(_=1),N(P,Y,1/_)}},"./src/utils/typed-array.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"sliceUint8",function(){return Y});function Y(N,M,H){return Uint8Array.prototype.slice?N.slice(M,H):new Uint8Array(Array.prototype.slice.call(N,M,H))}},"./src/utils/vttcue.ts":function(re,Z,D){"use strict";D.r(Z),Z.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var Y=["","lr","rl"],N=["start","middle","end","left","right"];function M(y,A){if(typeof A!="string")return!1;if(!Array.isArray(y))return!1;var R=A.toLowerCase();return~y.indexOf(R)?R:!1}function H(y){return M(Y,y)}function U(y){return M(N,y)}function P(y){for(var A=arguments.length,R=new Array(A>1?A-1:0),L=1;L<A;L++)R[L-1]=arguments[L];for(var w=1;w<arguments.length;w++){var b=arguments[w];for(var u in b)y[u]=b[u]}return y}function _(y,A,R){var L=this,w={enumerable:!0};L.hasBeenReset=!1;var b="",u=!1,o=y,l=A,h=R,C=null,g="",p=!0,k="auto",E="start",f=50,m="middle",d=50,a="middle";Object.defineProperty(L,"id",P({},w,{get:function(){return b},set:function(v){b=""+v}})),Object.defineProperty(L,"pauseOnExit",P({},w,{get:function(){return u},set:function(v){u=!!v}})),Object.defineProperty(L,"startTime",P({},w,{get:function(){return o},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");o=v,this.hasBeenReset=!0}})),Object.defineProperty(L,"endTime",P({},w,{get:function(){return l},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");l=v,this.hasBeenReset=!0}})),Object.defineProperty(L,"text",P({},w,{get:function(){return h},set:function(v){h=""+v,this.hasBeenReset=!0}})),Object.defineProperty(L,"region",P({},w,{get:function(){return C},set:function(v){C=v,this.hasBeenReset=!0}})),Object.defineProperty(L,"vertical",P({},w,{get:function(){return g},set:function(v){var T=H(v);if(T===!1)throw new SyntaxError("An invalid or illegal string was specified.");g=T,this.hasBeenReset=!0}})),Object.defineProperty(L,"snapToLines",P({},w,{get:function(){return p},set:function(v){p=!!v,this.hasBeenReset=!0}})),Object.defineProperty(L,"line",P({},w,{get:function(){return k},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");k=v,this.hasBeenReset=!0}})),Object.defineProperty(L,"lineAlign",P({},w,{get:function(){return E},set:function(v){var T=U(v);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");E=T,this.hasBeenReset=!0}})),Object.defineProperty(L,"position",P({},w,{get:function(){return f},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");f=v,this.hasBeenReset=!0}})),Object.defineProperty(L,"positionAlign",P({},w,{get:function(){return m},set:function(v){var T=U(v);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");m=T,this.hasBeenReset=!0}})),Object.defineProperty(L,"size",P({},w,{get:function(){return d},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");d=v,this.hasBeenReset=!0}})),Object.defineProperty(L,"align",P({},w,{get:function(){return a},set:function(v){var T=U(v);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");a=T,this.hasBeenReset=!0}})),L.displayState=void 0}return _.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"parseTimeStamp",function(){return M}),D.d(Z,"fixLineBreaks",function(){return A}),D.d(Z,"VTTParser",function(){return R});var Y=D("./src/utils/vttcue.ts"),N=function(){function L(){}var w=L.prototype;return w.decode=function(u,o){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},L}();function M(L){function w(u,o,l,h){return(u|0)*3600+(o|0)*60+(l|0)+parseFloat(h||0)}var b=L.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return b?parseFloat(b[2])>59?w(b[2],b[3],0,b[4]):w(b[1],b[2],b[3],b[4]):null}var H=function(){function L(){this.values=Object.create(null)}var w=L.prototype;return w.set=function(u,o){!this.get(u)&&o!==""&&(this.values[u]=o)},w.get=function(u,o,l){return l?this.has(u)?this.values[u]:o[l]:this.has(u)?this.values[u]:o},w.has=function(u){return u in this.values},w.alt=function(u,o,l){for(var h=0;h<l.length;++h)if(o===l[h]){this.set(u,o);break}},w.integer=function(u,o){/^-?\d+$/.test(o)&&this.set(u,parseInt(o,10))},w.percent=function(u,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var l=parseFloat(o);if(l>=0&&l<=100)return this.set(u,l),!0}return!1},L}();function U(L,w,b,u){var o=u?L.split(u):[L];for(var l in o){if(typeof o[l]!="string")continue;var h=o[l].split(b);if(h.length!==2)continue;var C=h[0],g=h[1];w(C,g)}}var P=new Y.default(0,0,""),_=P.align==="middle"?"middle":"center";function y(L,w,b){var u=L;function o(){var C=M(L);if(C===null)throw new Error("Malformed timestamp: "+u);return L=L.replace(/^[^\sa-zA-Z-]+/,""),C}function l(C,g){var p=new H;U(C,function(f,m){var d;switch(f){case"region":for(var a=b.length-1;a>=0;a--)if(b[a].id===m){p.set(f,b[a].region);break}break;case"vertical":p.alt(f,m,["rl","lr"]);break;case"line":d=m.split(","),p.integer(f,d[0]),p.percent(f,d[0])&&p.set("snapToLines",!1),p.alt(f,d[0],["auto"]),d.length===2&&p.alt("lineAlign",d[1],["start",_,"end"]);break;case"position":d=m.split(","),p.percent(f,d[0]),d.length===2&&p.alt("positionAlign",d[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":p.percent(f,m);break;case"align":p.alt(f,m,["start",_,"end","left","right"]);break}},/:/,/\s/),g.region=p.get("region",null),g.vertical=p.get("vertical","");var k=p.get("line","auto");k==="auto"&&P.line===-1&&(k=-1),g.line=k,g.lineAlign=p.get("lineAlign","start"),g.snapToLines=p.get("snapToLines",!0),g.size=p.get("size",100),g.align=p.get("align",_);var E=p.get("position","auto");E==="auto"&&P.position===50&&(E=g.align==="start"||g.align==="left"?0:g.align==="end"||g.align==="right"?100:50),g.position=E}function h(){L=L.replace(/^\s+/,"")}if(h(),w.startTime=o(),h(),L.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);L=L.substr(3),h(),w.endTime=o(),h(),l(L,w)}function A(L){return L.replace(/<br(?: \/)?>/gi,`
`)}var R=function(){function L(){this.state="INITIAL",this.buffer="",this.decoder=new N,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var w=L.prototype;return w.parse=function(u){var o=this;u&&(o.buffer+=o.decoder.decode(u,{stream:!0}));function l(){var E=o.buffer,f=0;for(E=A(E);f<E.length&&E[f]!=="\r"&&E[f]!==`
`;)++f;var m=E.substr(0,f);return E[f]==="\r"&&++f,E[f]===`
`&&++f,o.buffer=E.substr(f),m}function h(E){U(E,function(f,m){},/:/)}try{var C="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;C=l();var g=C.match(/^()?WEBVTT([ \t].*)?$/);if(!g||!g[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:C=l();switch(o.state){case"HEADER":/:/.test(C)?h(C):C||(o.state="ID");continue;case"NOTE":C||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(C)){o.state="NOTE";break}if(!C)continue;if(o.cue=new Y.default(0,0,""),o.state="CUE",C.indexOf("-->")===-1){o.cue.id=C;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{y(C,o.cue,o.regionList)}catch(E){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var k=C.indexOf("-->")!==-1;if(!C||k&&(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+=C}continue;case"BADCUE":C||(o.state="ID")}}}catch(E){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},w.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
`,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){u.onparsingerror&&u.onparsingerror(o)}return u.onflush&&u.onflush(),this},L}()},"./src/utils/webvtt-parser.ts":function(re,Z,D){"use strict";D.r(Z),D.d(Z,"generateCueId",function(){return R}),D.d(Z,"parseWebVTT",function(){return w});var Y=D("./src/polyfills/number.ts"),N=D("./src/utils/vttparser.ts"),M=D("./src/demux/id3.ts"),H=D("./src/utils/timescale-conversion.ts"),U=D("./src/remux/mp4-remuxer.ts"),P=/\r\n|\n\r|\n|\r/g,_=function(u,o,l){return l===void 0&&(l=0),u.substr(l,o.length)===o},y=function(u){var o=parseInt(u.substr(-3)),l=parseInt(u.substr(-6,2)),h=parseInt(u.substr(-9,2)),C=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object(Y.isFiniteNumber)(o)||!Object(Y.isFiniteNumber)(l)||!Object(Y.isFiniteNumber)(h)||!Object(Y.isFiniteNumber)(C))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return o+=1e3*l,o+=60*1e3*h,o+=60*60*1e3*C,o},A=function(u){for(var o=5381,l=u.length;l;)o=o*33^u.charCodeAt(--l);return(o>>>0).toString()};function R(b,u,o){return A(b.toString())+A(u.toString())+A(o)}var L=function(u,o,l){var h=u[o],C=u[h.prevCC];if(!C||!C.new&&h.new){u.ccOffset=u.presentationOffset=h.start,h.new=!1;return}for(;(g=C)!==null&&g!==void 0&&g.new;){var g;u.ccOffset+=h.start-C.start,h.new=!1,h=C,C=u[h.prevCC]}u.presentationOffset=l};function w(b,u,o,l,h,C,g,p){var k=new N.VTTParser,E=Object(M.utf8ArrayToStr)(new Uint8Array(b)).trim().replace(P,`
`).split(`
`),f=[],m=Object(H.toMpegTsClockFromTimescale)(u,o),d="00:00.000",a=0,x=0,v,T=!0,I=!1;k.oncue=function(G){var V=l[h],Q=l.ccOffset,z=(a-m)/9e4;if(V!=null&&V.new&&(x!==void 0?Q=l.ccOffset=V.start:L(l,h,z)),z&&(Q=z-l.presentationOffset),I){var j=G.endTime-G.startTime,q=Object(U.normalizePts)((G.startTime+Q-x)*9e4,C*9e4)/9e4;G.startTime=q,G.endTime=q+j}var ie=G.text.trim();G.text=decodeURIComponent(encodeURIComponent(ie)),G.id||(G.id=R(G.startTime,G.endTime,ie)),G.endTime>0&&f.push(G)},k.onparsingerror=function(G){v=G},k.onflush=function(){if(v){p(v);return}g(f)},E.forEach(function(G){if(T)if(_(G,"X-TIMESTAMP-MAP=")){T=!1,I=!0,G.substr(16).split(",").forEach(function(V){_(V,"LOCAL:")?d=V.substr(6):_(V,"MPEGTS:")&&(a=parseInt(V.substr(7)))});try{x=y(d)/1e3}catch(V){I=!1,v=V}return}else G===""&&(T=!1);k.parse(G+`
`)}),k.flush()}},"./src/utils/xhr-loader.ts":function(re,Z,D){"use strict";D.r(Z);var Y=D("./src/utils/logger.ts"),N=D("./src/loader/load-stats.ts"),M=/^age:\s*[\d.]+\s*$/m,H=function(){function U(_){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=_?_.xhrSetup:null,this.stats=new N.LoadStats,this.retryDelay=0}var P=U.prototype;return P.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},P.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},P.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},P.load=function(y,A,R){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=A,this.callbacks=R,this.retryDelay=A.retryDelay,this.loadInternal()},P.loadInternal=function(){var y=this.config,A=this.context;if(!y)return;var R=this.loader=new self.XMLHttpRequest,L=this.stats;L.loading.first=0,L.loaded=0;var w=this.xhrSetup;try{if(w)try{w(R,A.url)}catch(o){R.open("GET",A.url,!0),w(R,A.url)}R.readyState||R.open("GET",A.url,!0);var b=this.context.headers;if(b)for(var u in b)R.setRequestHeader(u,b[u])}catch(o){this.callbacks.onError({code:R.status,text:o.message},A,R);return}A.rangeEnd&&R.setRequestHeader("Range","bytes="+A.rangeStart+"-"+(A.rangeEnd-1)),R.onreadystatechange=this.readystatechange.bind(this),R.onprogress=this.loadprogress.bind(this),R.responseType=A.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),R.send()},P.readystatechange=function(){var y=this.context,A=this.loader,R=this.stats;if(!y||!A)return;var L=A.readyState,w=this.config;if(R.aborted)return;if(L>=2)if(self.clearTimeout(this.requestTimeout),R.loading.first===0&&(R.loading.first=Math.max(self.performance.now(),R.loading.start)),L===4){A.onreadystatechange=null,A.onprogress=null;var b=A.status;if(b>=200&&b<300){R.loading.end=Math.max(self.performance.now(),R.loading.first);var u,o;if(y.responseType==="arraybuffer"?(u=A.response,o=u.byteLength):(u=A.responseText,o=u.length),R.loaded=R.total=o,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(R,y,u,A),!this.callbacks)return;var h={url:A.responseURL,data:u};this.callbacks.onSuccess(h,R,y,A)}else R.retry>=w.maxRetry||b>=400&&b<499?(Y.logger.error(b+" while loading "+y.url),this.callbacks.onError({code:b,text:A.statusText},y,A)):(Y.logger.warn(b+" while loading "+y.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,w.maxRetryDelay),R.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),w.timeout)},P.loadtimeout=function(){Y.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},P.loadprogress=function(y){var A=this.stats;A.loaded=y.loaded,y.lengthComputable&&(A.total=y.total)},P.getCacheAge=function(){var y=null;if(this.loader&&M.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");y=A?parseFloat(A):null}return y},U}();Z.default=H}}).default})},vHTk:function(wt,pt,se){wt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);